bool net_byte_order )
{
int i;
- SGPropertyNode * node;
- SGPropertyNode * tempnode;
+ SGPropertyNode *node;
+ SGPropertyNode *tempnode;
// fill in values
node = fgGetNode("/controls/flight", true);
1.0 ) >= 1.0;
net->num_engines = FGNetCtrls::FG_MAX_ENGINES;
for ( i = 0; i < FGNetCtrls::FG_MAX_ENGINES; ++i ) {
+ // Controls
node = fgGetNode("/controls/engines/engine", i );
net->throttle[i] = node->getDoubleValue( "throttle", 0.0 );
net->mixture[i] = node->getDoubleValue( "mixture", 0.0 );
// cout << "Starter -> " << node->getIntValue( "starter", false )
// << endl;
}
- node = fgGetNode("/controls", true);
net->fuel_pump_power[i]
= node->getDoubleValue( "/systems/electrical/outputs/fuel-pump",
1.0 ) >= 1.0;
net->starter_power[i]
= node->getDoubleValue( "/systems/electrical/outputs/starter",
1.0 ) >= 1.0;
+
+ // Faults
+ SGPropertyNode *faults = node->getChild( "faults", 0, true );
+ net->engine_ok[i] = faults->getBoolValue( "serviceable", true );
+ net->mag_left_ok[i]
+ = faults->getBoolValue( "left-magneto-serviceable", true );
+ net->mag_right_ok[i]
+ = faults->getBoolValue( "right-magneto-serviceable", true);
+ net->spark_plugs_ok[i]
+ = faults->getBoolValue( "spark-plugs-serviceable", true );
+ net->oil_press_status[i]
+ = faults->getIntValue( "oil-pressure-status", 0 );
+ net->fuel_pump_ok[i]
+ = faults->getBoolValue( "fuel-pump-serviceable", true );
}
net->num_tanks = FGNetCtrls::FG_MAX_TANKS;
for ( i = 0; i < FGNetCtrls::FG_MAX_TANKS; ++i ) {
htond(net->flaps);
net->flaps_power = htonl(net->flaps_power);
for ( i = 0; i < FGNetCtrls::FG_MAX_ENGINES; ++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]);
- net->magnetos[i] = htonl(net->magnetos[i]);
- net->starter_power[i] = htonl(net->starter_power[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_engines = htonl(net->num_engines);
for ( i = 0; i < FGNetCtrls::FG_MAX_TANKS; ++i ) {
htond(net->mixture[i]);
net->fuel_pump_power[i] = htonl(net->fuel_pump_power[i]);
htond(net->prop_advance[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 < net->num_tanks; ++i ) {
fgSetBool( "/systems/electrical/outputs/flaps", net->flaps_power );
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( "magnetos" )->setDoubleValue( net->magnetos[i] );
+
+ // Faults
+ SGPropertyNode *faults = node->getNode( "faults", true );
+ faults->setBoolValue( "serviceable", net->engine_ok[i] );
+ faults->setBoolValue( "left-magneto-serviceable",
+ net->mag_left_ok[i] );
+ faults->setBoolValue( "right-magneto-serviceable",
+ net->mag_right_ok[i]);
+ faults->setBoolValue( "spark-plugs-serviceable",
+ net->spark_plugs_ok[i] );
+ faults->setIntValue( "oil-pressure-status", net->oil_press_status[i] );
+ faults->setBoolValue( "fuel-pump-serviceable", net->fuel_pump_ok[i] );
}
fgSetBool( "/systems/electrical/outputs/fuel-pump",
# error This library requires C++
#endif
-const int FG_NET_CTRLS_VERSION = 14;
+const int FG_NET_CTRLS_VERSION = 15;
// Define a structure containing the control parameters
double elevator_trim; // -1 ... 1
double rudder; // -1 ... 1
double flaps; // 0 ... 1
+
+ // Aero control faults
bool flaps_power; // true = power available
// Engine controls
bool fuel_pump_power[FG_MAX_ENGINES];// true = on
double prop_advance[FG_MAX_ENGINES]; // 0 ... 1
+ // Engine faults
+ bool engine_ok[FG_MAX_ENGINES];
+ bool mag_left_ok[FG_MAX_ENGINES];
+ bool mag_right_ok[FG_MAX_ENGINES];
+ bool spark_plugs_ok[FG_MAX_ENGINES]; // false = fouled plugs
+ int oil_press_status[FG_MAX_ENGINES]; // 0 = normal, 1 = low, 2 = full fail
+ bool fuel_pump_ok[FG_MAX_ENGINES];
+
// Fuel management
int num_tanks; // number of valid tanks
bool fuel_selector[FG_MAX_TANKS]; // false = off, true = on