From ec036a7be8ce9838aa5b296fb1bd8c788fed2faa Mon Sep 17 00:00:00 2001 From: curt Date: Fri, 2 Apr 2004 16:19:59 +0000 Subject: [PATCH] native_ctrls: - We need to be able to support a per engine master bat/alt switch. - Forgot to write the gear level state into the network structure. native_fdm: - renamed EGT->egt for consistancy. - added manifold pressure to the structure. --- src/Network/native_ctrls.cxx | 29 ++++++++++++++++------------- src/Network/native_fdm.cxx | 12 ++++++++---- src/Network/net_ctrls.hxx | 8 ++++---- src/Network/net_fdm.hxx | 15 ++++++++------- 4 files changed, 36 insertions(+), 28 deletions(-) diff --git a/src/Network/native_ctrls.cxx b/src/Network/native_ctrls.cxx index ace029444..10e78028b 100644 --- a/src/Network/native_ctrls.cxx +++ b/src/Network/native_ctrls.cxx @@ -125,6 +125,16 @@ void FGProps2NetCtrls( FGNetCtrls *net, bool honor_freezes, node = fgGetNode("/controls/engines/engine", i ); starter = fgGetNode("/systems/electrical/outputs/starter", i ); fuelpump = fgGetNode("/systems/electrical/outputs/fuel-pump", i ); + + tempnode = node->getChild("master-bat"); + if ( tempnode != NULL ) { + net->master_bat[i] = tempnode->getBoolValue(); + } + tempnode = node->getChild("master-alt"); + if ( tempnode != NULL ) { + net->master_alt[i] = tempnode->getBoolValue(); + } + net->throttle[i] = node->getDoubleValue( "throttle", 0.0 ); net->mixture[i] = node->getDoubleValue( "mixture", 0.0 ); net->prop_advance[i] = node->getDoubleValue( "propeller-pitch", 0.0 ); @@ -178,15 +188,8 @@ void FGProps2NetCtrls( FGNetCtrls *net, bool honor_freezes, net->brake_right = node->getChild("brake-right")->getDoubleValue(); net->brake_parking = node->getChild("brake-parking")->getDoubleValue(); - node = fgGetNode("/controls/switches", true); - tempnode = node->getChild("master-bat"); - if ( tempnode != NULL ) { - net->master_bat = tempnode->getBoolValue(); - } - tempnode = node->getChild("master-alt"); - if ( tempnode != NULL ) { - net->master_alt = tempnode->getBoolValue(); - } + net->gear_handle = fgGetBool( "controls/gear/gear-down" ); + tempnode = node->getChild("master-avionics"); if ( tempnode != NULL ) { net->master_avionics = tempnode->getBoolValue(); @@ -232,6 +235,8 @@ void FGProps2NetCtrls( FGNetCtrls *net, bool honor_freezes, net->flaps_power = htonl(net->flaps_power); net->flap_motor_ok = htonl(net->flap_motor_ok); for ( i = 0; i < FGNetCtrls::FG_MAX_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]); @@ -254,8 +259,6 @@ void FGProps2NetCtrls( FGNetCtrls *net, bool honor_freezes, htond(net->brake_right); htond(net->brake_parking); net->gear_handle = htonl(net->gear_handle); - net->master_bat = htonl(net->master_bat); - net->master_alt = htonl(net->master_alt); net->master_avionics = htonl(net->master_avionics); htond(net->wind_speed_kt); htond(net->wind_dir_deg); @@ -290,6 +293,8 @@ void FGNetCtrls2Props( FGNetCtrls *net, bool honor_freezes, net->flap_motor_ok = htonl(net->flap_motor_ok); net->num_engines = htonl(net->num_engines); for ( i = 0; i < 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]); @@ -311,8 +316,6 @@ void FGNetCtrls2Props( FGNetCtrls *net, bool honor_freezes, htond(net->brake_right); htond(net->brake_parking); net->gear_handle = htonl(net->gear_handle); - net->master_bat = htonl(net->master_bat); - net->master_alt = htonl(net->master_alt); net->master_avionics = htonl(net->master_avionics); htond(net->wind_speed_kt); htond(net->wind_dir_deg); diff --git a/src/Network/native_fdm.cxx b/src/Network/native_fdm.cxx index c80c41056..939c93dda 100644 --- a/src/Network/native_fdm.cxx +++ b/src/Network/native_fdm.cxx @@ -171,8 +171,9 @@ void FGProps2NetFDM( FGNetFDM *net, bool net_byte_order ) { } net->rpm[i] = node->getDoubleValue( "rpm" ); net->fuel_flow[i] = node->getDoubleValue( "fuel-flow-gph" ); - net->EGT[i] = node->getDoubleValue( "egt-degf" ); + net->egt[i] = node->getDoubleValue( "egt-degf" ); // cout << "egt = " << aero->EGT << endl; + net->mp_osi[i] = node->getDoubleValue( "mp-osi" ); net->oil_temp[i] = node->getDoubleValue( "oil-temperature-degf" ); net->oil_px[i] = node->getDoubleValue( "oil-pressure-psi" ); } @@ -249,7 +250,8 @@ void FGProps2NetFDM( FGNetFDM *net, bool net_byte_order ) { net->eng_state[i] = htonl(net->eng_state[i]); htonf(net->rpm[i]); htonf(net->fuel_flow[i]); - htonf(net->EGT[i]); + htonf(net->egt[i]); + htonf(net->mp_osi[i]); htonf(net->oil_temp[i]); htonf(net->oil_px[i]); } @@ -326,7 +328,8 @@ void FGNetFDM2Props( FGNetFDM *net, bool net_byte_order ) { net->eng_state[i] = htonl(net->eng_state[i]); htonf(net->rpm[i]); htonf(net->fuel_flow[i]); - htonf(net->EGT[i]); + htonf(net->egt[i]); + htonf(net->mp_osi[i]); htonf(net->oil_temp[i]); htonf(net->oil_px[i]); } @@ -420,7 +423,8 @@ void FGNetFDM2Props( FGNetFDM *net, bool net_byte_order ) { node->setDoubleValue( "rpm", net->rpm[i] ); node->setDoubleValue( "fuel-flow-gph", net->fuel_flow[i] ); - node->setDoubleValue( "egt-degf", net->EGT[i] ); + node->setDoubleValue( "egt-degf", net->egt[i] ); + node->setDoubleValue( "mp-osi", net->mp_osi[i] ); node->setDoubleValue( "oil-temperature-degf", net->oil_temp[i] ); node->setDoubleValue( "oil-pressure-psi", net->oil_px[i] ); } diff --git a/src/Network/net_ctrls.hxx b/src/Network/net_ctrls.hxx index 26b3bc62a..31f21cb51 100644 --- a/src/Network/net_ctrls.hxx +++ b/src/Network/net_ctrls.hxx @@ -16,7 +16,7 @@ # error This library requires C++ #endif -const int FG_NET_CTRLS_VERSION = 19; +const int FG_NET_CTRLS_VERSION = 20; // Define a structure containing the control parameters @@ -46,6 +46,8 @@ public: // Engine controls int num_engines; // number of valid engines + bool master_bat[FG_MAX_ENGINES]; + bool master_alt[FG_MAX_ENGINES]; int magnetos[FG_MAX_ENGINES]; bool starter_power[FG_MAX_ENGINES]; // true = starter power double throttle[FG_MAX_ENGINES]; // 0 ... 1 @@ -57,7 +59,7 @@ public: 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 + 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]; @@ -74,8 +76,6 @@ public: bool gear_handle; // true=gear handle down; false= gear handle up // Switches - bool master_bat; - bool master_alt; bool master_avionics; // wind and turbulance diff --git a/src/Network/net_fdm.hxx b/src/Network/net_fdm.hxx index d9c0f33dd..160a54ba6 100644 --- a/src/Network/net_fdm.hxx +++ b/src/Network/net_fdm.hxx @@ -18,7 +18,7 @@ #include // time_t -const int FG_NET_FDM_VERSION = 17; +const int FG_NET_FDM_VERSION = 18; // Define a structure containing the top level flight dynamics model @@ -79,13 +79,14 @@ public: // Pressure // Engine status - int num_engines; // Number of valid engines - int eng_state[FG_MAX_ENGINES]; // Engine state (off, cranking, running) - float rpm[FG_MAX_ENGINES]; // Engine RPM rev/min + int num_engines; // Number of valid engines + int eng_state[FG_MAX_ENGINES]; // Engine state (off, cranking, running) + float rpm[FG_MAX_ENGINES]; // Engine RPM rev/min float fuel_flow[FG_MAX_ENGINES]; // Fuel flow gallons/hr - float EGT[FG_MAX_ENGINES]; // Exhuast gas temp deg F - float oil_temp[FG_MAX_ENGINES]; // Oil temp deg F - float oil_px[FG_MAX_ENGINES]; // Oil pressure psi + float egt[FG_MAX_ENGINES]; // Exhuast gas temp deg F + float mp_osi[FG_MAX_ENGINES]; // Manifold pressure + float oil_temp[FG_MAX_ENGINES]; // Oil temp deg F + float oil_px[FG_MAX_ENGINES]; // Oil pressure psi // Consumables int num_tanks; // Max number of fuel tanks