+void FGNetFDM2Props( FGNetFDM *net, bool net_byte_order ) {
+ unsigned int i;
+ FlightProperties fdm_state;
+
+ if ( net_byte_order ) {
+ // Convert to the net buffer from network format
+ net->version = ntohl(net->version);
+
+ htond(net->longitude);
+ htond(net->latitude);
+ htond(net->altitude);
+ htonf(net->agl);
+ htonf(net->phi);
+ htonf(net->theta);
+ htonf(net->psi);
+ htonf(net->alpha);
+ htonf(net->beta);
+
+ htonf(net->phidot);
+ htonf(net->thetadot);
+ htonf(net->psidot);
+ htonf(net->vcas);
+ htonf(net->climb_rate);
+ htonf(net->v_north);
+ htonf(net->v_east);
+ htonf(net->v_down);
+ htonf(net->v_wind_body_north);
+ htonf(net->v_wind_body_east);
+ htonf(net->v_wind_body_down);
+
+ htonf(net->A_X_pilot);
+ htonf(net->A_Y_pilot);
+ htonf(net->A_Z_pilot);
+
+ htonf(net->stall_warning);
+ htonf(net->slip_deg);
+
+ net->num_engines = htonl(net->num_engines);
+ for ( i = 0; i < net->num_engines; ++i ) {
+ net->eng_state[i] = htonl(net->eng_state[i]);
+ htonf(net->rpm[i]);
+ htonf(net->fuel_flow[i]);
+ htonf(net->fuel_px[i]);
+ htonf(net->egt[i]);
+ htonf(net->cht[i]);
+ htonf(net->mp_osi[i]);
+ htonf(net->tit[i]);
+ htonf(net->oil_temp[i]);
+ htonf(net->oil_px[i]);
+ }
+
+ net->num_tanks = htonl(net->num_tanks);
+ for ( i = 0; i < net->num_tanks; ++i ) {
+ htonf(net->fuel_quantity[i]);
+ }
+
+ net->num_wheels = htonl(net->num_wheels);
+ for ( i = 0; i < net->num_wheels; ++i ) {
+ net->wow[i] = htonl(net->wow[i]);
+ htonf(net->gear_pos[i]);
+ htonf(net->gear_steer[i]);
+ htonf(net->gear_compression[i]);
+ }
+
+ net->cur_time = htonl(net->cur_time);
+ net->warp = ntohl(net->warp);
+ htonf(net->visibility);
+
+ htonf(net->elevator);
+ htonf(net->elevator_trim_tab);
+ htonf(net->left_flap);
+ htonf(net->right_flap);
+ htonf(net->left_aileron);
+ htonf(net->right_aileron);
+ htonf(net->rudder);
+ htonf(net->nose_wheel);
+ htonf(net->speedbrake);
+ htonf(net->spoilers);
+ }
+
+ if ( net->version == FG_NET_FDM_VERSION ) {
+ // cout << "pos = " << net->longitude << " " << net->latitude << endl;
+ // cout << "sea level rad = " << fdm_state.get_Sea_level_radius()
+ // << endl;
+
+ fdm_state.set_Latitude(net->latitude);
+ fdm_state.set_Longitude(net->longitude);
+ fdm_state.set_Altitude(net->altitude * SG_METER_TO_FEET);
+
+ if ( net->agl > -9000 ) {
+ fdm_state.set_Altitude_AGL( net->agl * SG_METER_TO_FEET );
+ } else {
+ double agl_m = net->altitude
+ - fdm_state.get_Runway_altitude_m();
+ fdm_state.set_Altitude_AGL( agl_m * SG_METER_TO_FEET );
+ }
+ fdm_state.set_Euler_Angles( net->phi,
+ net->theta,
+ net->psi );
+ fdm_state.set_Alpha( net->alpha );
+ fdm_state.set_Beta( net->beta );
+ fdm_state.set_Euler_Rates( net->phidot,
+ net->thetadot,
+ net->psidot );
+ fdm_state.set_V_calibrated_kts( net->vcas );
+ fdm_state.set_Climb_Rate( net->climb_rate );
+ fdm_state.set_Velocities_Local( net->v_north,
+ net->v_east,
+ net->v_down );
+ fdm_state.set_Velocities_Wind_Body( net->v_wind_body_north,
+ net->v_wind_body_east,
+ net->v_wind_body_down );
+
+ fdm_state.set_Accels_Pilot_Body( net->A_X_pilot,
+ net->A_Y_pilot,
+ net->A_Z_pilot );
+
+ fgSetDouble( "/sim/alarms/stall-warning", net->stall_warning );
+ fgSetDouble( "/instrumentation/slip-skid-ball/indicated-slip-skid",
+ net->slip_deg );
+ fgSetBool( "/instrumentation/slip-skid-ball/override", true );
+
+ for ( i = 0; i < net->num_engines; ++i ) {
+ SGPropertyNode *node = fgGetNode( "engines/engine", i, true );
+
+ // node->setBoolValue("running", t->isRunning());
+ // node->setBoolValue("cranking", t->isCranking());
+
+ // cout << net->eng_state[i] << endl;
+ if ( net->eng_state[i] == 0 ) {
+ node->setBoolValue( "cranking", false );
+ node->setBoolValue( "running", false );
+ } else if ( net->eng_state[i] == 1 ) {
+ node->setBoolValue( "cranking", true );
+ node->setBoolValue( "running", false );
+ } else if ( net->eng_state[i] == 2 ) {
+ node->setBoolValue( "cranking", false );
+ node->setBoolValue( "running", true );
+ }
+
+ node->setDoubleValue( "rpm", net->rpm[i] );
+ node->setDoubleValue( "fuel-flow-gph", net->fuel_flow[i] );
+ node->setDoubleValue( "fuel-px-psi", net->fuel_px[i] );
+ node->setDoubleValue( "egt-degf", net->egt[i] );
+ node->setDoubleValue( "cht-degf", net->cht[i] );
+ node->setDoubleValue( "mp-osi", net->mp_osi[i] );
+ node->setDoubleValue( "tit", net->tit[i] );
+ node->setDoubleValue( "oil-temperature-degf", net->oil_temp[i] );
+ node->setDoubleValue( "oil-pressure-psi", net->oil_px[i] );
+ }
+
+ for (i = 0; i < net->num_tanks; ++i ) {
+ SGPropertyNode * node
+ = fgGetNode("/consumables/fuel/tank", i, true);
+ node->setDoubleValue("level-gal_us", net->fuel_quantity[i] );
+ }
+
+ for (i = 0; i < net->num_wheels; ++i ) {
+ SGPropertyNode * node = fgGetNode("/gear/gear", i, true);
+ node->setDoubleValue("wow", net->wow[i] );
+ node->setDoubleValue("position-norm", net->gear_pos[i] );
+ node->setDoubleValue("steering-norm", net->gear_steer[i] );
+ node->setDoubleValue("compression-norm", net->gear_compression[i] );
+ }
+
+ /* these are ignored for now ... */
+ /*
+ if ( net->cur_time ) {
+ fgSetLong("/sim/time/cur-time-override", net->cur_time);
+ }
+
+ globals->set_warp( net->warp );
+ last_warp = net->warp;
+ */
+
+ SGPropertyNode *node = fgGetNode("/surface-positions", true);
+ node->setDoubleValue("elevator-pos-norm", net->elevator);
+ node->setDoubleValue("elevator-trim-tab-pos-norm",
+ net->elevator_trim_tab);
+ // FIXME: CLO 10/28/04 - This really should be separated out
+ // into 2 values
+ node->setDoubleValue("flap-pos-norm", net->left_flap);
+ node->setDoubleValue("flap-pos-norm", net->right_flap);
+ node->setDoubleValue("left-aileron-pos-norm", net->left_aileron);
+ node->setDoubleValue("right-aileron-pos-norm", net->right_aileron);
+ node->setDoubleValue("rudder-pos-norm", net->rudder);
+ node->setDoubleValue("nose-wheel-pos-norm", net->nose_wheel);
+ node->setDoubleValue("speedbrake-pos-norm", net->speedbrake);
+ node->setDoubleValue("spoilers-pos-norm", net->spoilers);