Tweaks to 'native fdm' output. Time offset should now be properly supported
as well as visibility. This means that if you are using this protocal to exchange data with a visual channel, you should be able to change time and visibility on the master and all the slaved visual channels will match it.
This commit is contained in:
parent
de2b5f50e9
commit
61d31ab822
2 changed files with 34 additions and 16 deletions
|
@ -30,6 +30,8 @@
|
|||
#include <simgear/io/iochannel.hxx>
|
||||
|
||||
#include <FDM/flight.hxx>
|
||||
#include <Time/tmp.hxx>
|
||||
#include <Main/fg_props.hxx>
|
||||
#include <Main/globals.hxx>
|
||||
|
||||
#include "native_fdm.hxx"
|
||||
|
@ -98,6 +100,9 @@ bool FGNativeFDM::open() {
|
|||
|
||||
|
||||
static void global2net( const FGInterface *global, FGNetFDM *net ) {
|
||||
static const SGPropertyNode *visibility
|
||||
= fgGetNode("/environment/visibility-m");
|
||||
|
||||
net->version = FG_NET_FDM_VERSION;
|
||||
|
||||
// positions
|
||||
|
@ -112,9 +117,10 @@ static void global2net( const FGInterface *global, FGNetFDM *net ) {
|
|||
net->vcas = cur_fdm_state->get_V_calibrated_kts();
|
||||
net->climb_rate = cur_fdm_state->get_Climb_Rate();
|
||||
|
||||
// time
|
||||
// environment
|
||||
net->cur_time = globals->get_time_params()->get_cur_time();
|
||||
net->warp = globals->get_warp();
|
||||
net->visibility = visibility->getDoubleValue();
|
||||
|
||||
// Convert the net buffer to network format
|
||||
net->version = htonl(net->version);
|
||||
|
@ -128,13 +134,15 @@ static void global2net( const FGInterface *global, FGNetFDM *net ) {
|
|||
htond(net->climb_rate);
|
||||
net->cur_time = htonl( net->cur_time );
|
||||
net->warp = htonl( net->warp );
|
||||
htond(net->visibility);
|
||||
}
|
||||
|
||||
|
||||
static void net2global( FGNetFDM *net, FGInterface *global ) {
|
||||
static long int last_warp = 0;
|
||||
|
||||
// Convert to the net buffer from network format
|
||||
net->version = htonl(net->version);
|
||||
net->version = ntohl(net->version);
|
||||
htond(net->longitude);
|
||||
htond(net->latitude);
|
||||
htond(net->altitude);
|
||||
|
@ -143,8 +151,9 @@ static void net2global( FGNetFDM *net, FGInterface *global ) {
|
|||
htond(net->psi);
|
||||
htond(net->vcas);
|
||||
htond(net->climb_rate);
|
||||
net->cur_time = htonl(net->cur_time);
|
||||
net->warp = htonl(net->warp);
|
||||
net->cur_time = ntohl(net->cur_time);
|
||||
net->warp = ntohl(net->warp);
|
||||
htond(net->visibility);
|
||||
|
||||
if ( net->version == FG_NET_FDM_VERSION ) {
|
||||
// cout << "pos = " << net->longitude << " " << net->latitude << endl;
|
||||
|
@ -160,8 +169,16 @@ static void net2global( FGNetFDM *net, FGInterface *global ) {
|
|||
cur_fdm_state->_set_Climb_Rate( net->climb_rate );
|
||||
|
||||
globals->set_warp( net->warp );
|
||||
if ( net->warp != last_warp ) {
|
||||
fgUpdateSkyAndLightingParams();
|
||||
}
|
||||
last_warp = net->warp;
|
||||
|
||||
fgSetDouble( "/environment/visibility-m", net->visibility );
|
||||
} else {
|
||||
SG_LOG( SG_IO, SG_ALERT, "Error: version mismatch in net2global()" );
|
||||
SG_LOG( SG_IO, SG_ALERT,
|
||||
"\tread " << net->version << " need " << FG_NET_FDM_VERSION );
|
||||
SG_LOG( SG_IO, SG_ALERT,
|
||||
"\tsomeone needs to upgrade net_fdm.hxx and recompile." );
|
||||
}
|
||||
|
|
|
@ -58,9 +58,10 @@ public:
|
|||
double vcas; // calibrated airspeed
|
||||
double climb_rate; // feet per second
|
||||
|
||||
// Time
|
||||
// Environment
|
||||
time_t cur_time; // current unix time
|
||||
long int warp; // offset in seconds to unix time
|
||||
double visibility; // visibility in meters (for env. effects)
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue