+ SGPropertyNode * node;
+
+ if ( net_byte_order ) {
+ // convert from network byte order
+ net->version = htonl(net->version);
+ htond(net->aileron);
+ htond(net->elevator);
+ htond(net->rudder);
+ htond(net->aileron_trim);
+ htond(net->elevator_trim);
+ htond(net->rudder_trim);
+ htond(net->flaps);
+ htond(net->speedbrake);
+ htond(net->spoilers);
+ net->flaps_power = htonl(net->flaps_power);
+ net->flap_motor_ok = htonl(net->flap_motor_ok);
+
+ net->num_engines = htonl(net->num_engines);
+ for ( i = 0; i < (int)net->num_engines; ++i ) {
+ net->master_bat[i] = htonl(net->master_bat[i]);
+ net->master_alt[i] = htonl(net->master_alt[i]);
+ net->magnetos[i] = htonl(net->magnetos[i]);
+ net->starter_power[i] = htonl(net->starter_power[i]);
+ htond(net->throttle[i]);
+ htond(net->mixture[i]);
+ net->fuel_pump_power[i] = htonl(net->fuel_pump_power[i]);
+ htond(net->prop_advance[i]);
+ htond(net->condition[i]);
+ net->engine_ok[i] = htonl(net->engine_ok[i]);
+ net->mag_left_ok[i] = htonl(net->mag_left_ok[i]);
+ net->mag_right_ok[i] = htonl(net->mag_right_ok[i]);
+ net->spark_plugs_ok[i] = htonl(net->spark_plugs_ok[i]);
+ net->oil_press_status[i] = htonl(net->oil_press_status[i]);
+ net->fuel_pump_ok[i] = htonl(net->fuel_pump_ok[i]);
+ }
+
+ net->num_tanks = htonl(net->num_tanks);
+ for ( i = 0; i < FGNetCtrls::FG_MAX_TANKS; ++i ) {
+ net->fuel_selector[i] = htonl(net->fuel_selector[i]);
+ }
+
+ net->cross_feed = htonl(net->cross_feed);
+ htond(net->brake_left);
+ htond(net->brake_right);
+ htond(net->copilot_brake_left);
+ htond(net->copilot_brake_right);
+ htond(net->brake_parking);
+ net->gear_handle = htonl(net->gear_handle);
+ net->master_avionics = htonl(net->master_avionics);
+ htond(net->wind_speed_kt);
+ htond(net->wind_dir_deg);
+ htond(net->turbulence_norm);
+ htond(net->temp_c);
+ htond(net->press_inhg);
+ htond(net->hground);
+ htond(net->magvar);
+ net->icing = htonl(net->icing);
+ net->speedup = htonl(net->speedup);
+ net->freeze = htonl(net->freeze);
+ }
+
+ if ( net->version != FG_NET_CTRLS_VERSION ) {
+ SG_LOG( SG_IO, SG_ALERT,
+ "Version mismatch with raw controls packet format." );
+ SG_LOG( SG_IO, SG_ALERT,
+ "FlightGear needs version = " << FG_NET_CTRLS_VERSION
+ << " but is receiving version = " << net->version );
+ }
+ node = fgGetNode("/controls/flight", true);
+ node->setDoubleValue( "aileron", net->aileron );
+ node->setDoubleValue( "elevator", net->elevator );
+ node->setDoubleValue( "rudder", net->rudder );
+ node->setDoubleValue( "aileron-trim", net->aileron_trim );
+ node->setDoubleValue( "elevator-trim", net->elevator_trim );
+ node->setDoubleValue( "rudder-trim", net->rudder_trim );
+ node->setDoubleValue( "flaps", net->flaps );
+ node->setDoubleValue( "speedbrake", net->speedbrake ); //JWW
+ // or
+ node->setDoubleValue( "spoilers", net->spoilers ); //JWW
+// cout << "NET->Spoilers: " << net->spoilers << endl;
+ fgSetBool( "/systems/electrical/outputs/flaps", net->flaps_power > 0 );
+ node->setBoolValue( "flaps-serviceable", net->flap_motor_ok > 0 );
+
+ for ( i = 0; i < FGNetCtrls::FG_MAX_ENGINES; ++i ) {
+ // Controls
+ node = fgGetNode("/controls/engines/engine", i);
+ node->getChild( "throttle" )->setDoubleValue( net->throttle[i] );
+ node->getChild( "mixture" )->setDoubleValue( net->mixture[i] );
+ node->getChild( "propeller-pitch" )
+ ->setDoubleValue( net->prop_advance[i] );
+ node->getChild( "condition" )
+ ->setDoubleValue( net->condition[i] );
+ node->getChild( "magnetos" )->setDoubleValue( net->magnetos[i] );
+ node->getChild( "starter" )->setDoubleValue( net->starter_power[i] );
+ node->getChild( "feed_tank" )->setIntValue( net->feed_tank_to[i] );
+ node->getChild( "reverser" )->setBoolValue( net->reverse[i] > 0 );
+ // Faults
+ SGPropertyNode *faults = node->getNode( "faults", true );
+ faults->setBoolValue( "serviceable", net->engine_ok[i] > 0 );
+ faults->setBoolValue( "left-magneto-serviceable",
+ net->mag_left_ok[i] > 0 );
+ faults->setBoolValue( "right-magneto-serviceable",
+ net->mag_right_ok[i] > 0);
+ faults->setBoolValue( "spark-plugs-serviceable",
+ net->spark_plugs_ok[i] > 0);
+ faults->setIntValue( "oil-pressure-status", net->oil_press_status[i] );
+ faults->setBoolValue( "fuel-pump-serviceable", net->fuel_pump_ok[i] > 0);