From 2eaaddc52a2522f5b2756d3c7b2973b1d8921d83 Mon Sep 17 00:00:00 2001 From: curt Date: Sat, 28 Sep 2002 22:10:49 +0000 Subject: [PATCH] Renamed raw_ctrls.hxx -> net_ctrls.hxx which makes more sense and matches net_fdm.hxx. --- src/FDM/ExternalNet/ExternalNet.cxx | 118 +++++++++---------- src/FDM/ExternalNet/ExternalNet.hxx | 4 +- src/Network/Makefile.am | 3 +- src/Network/native_ctrls.cxx | 84 ++++++------- src/Network/native_ctrls.hxx | 4 +- src/Network/{raw_ctrls.hxx => net_ctrls.hxx} | 12 +- 6 files changed, 112 insertions(+), 113 deletions(-) rename src/Network/{raw_ctrls.hxx => net_ctrls.hxx} (93%) diff --git a/src/FDM/ExternalNet/ExternalNet.cxx b/src/FDM/ExternalNet/ExternalNet.cxx index cde754cfe..3f2fbc9ce 100644 --- a/src/FDM/ExternalNet/ExternalNet.cxx +++ b/src/FDM/ExternalNet/ExternalNet.cxx @@ -62,33 +62,33 @@ static void htond (double &x) } -static void global2raw( FGRawCtrls *raw ) { +static void global2net( FGNetCtrls *net ) { int i; // fill in values SGPropertyNode * node = fgGetNode("/controls", true); - raw->version = FG_RAW_CTRLS_VERSION; - raw->aileron = node->getDoubleValue( "aileron" ); - raw->elevator = node->getDoubleValue( "elevator" ); - raw->elevator_trim = node->getDoubleValue( "elevator-trim" ); - raw->rudder = node->getDoubleValue( "rudder" ); - raw->flaps = node->getDoubleValue( "flaps" ); - raw->flaps_power + net->version = FG_NET_CTRLS_VERSION; + net->aileron = node->getDoubleValue( "aileron" ); + net->elevator = node->getDoubleValue( "elevator" ); + net->elevator_trim = node->getDoubleValue( "elevator-trim" ); + net->rudder = node->getDoubleValue( "rudder" ); + net->flaps = node->getDoubleValue( "flaps" ); + net->flaps_power = node->getDoubleValue( "/systems/electrical/outputs/flaps", 1.0 ) >= 1.0; - raw->num_engines = FGRawCtrls::FG_MAX_ENGINES; - for ( i = 0; i < FGRawCtrls::FG_MAX_ENGINES; ++i ) { - raw->throttle[i] = node->getDoubleValue( "throttle", 0.0 ); - raw->mixture[i] = node->getDoubleValue( "mixture", 0.0 ); - raw->fuel_pump_power[i] + net->num_engines = FGNetCtrls::FG_MAX_ENGINES; + for ( i = 0; i < FGNetCtrls::FG_MAX_ENGINES; ++i ) { + net->throttle[i] = node->getDoubleValue( "throttle", 0.0 ); + net->mixture[i] = node->getDoubleValue( "mixture", 0.0 ); + net->fuel_pump_power[i] = node->getDoubleValue( "/systems/electrical/outputs/fuel-pump", 1.0 ) >= 1.0; - raw->prop_advance[i] = node->getDoubleValue( "propeller-pitch", 0.0 ); - raw->magnetos[i] = node->getIntValue( "magnetos", 0 ); + net->prop_advance[i] = node->getDoubleValue( "propeller-pitch", 0.0 ); + net->magnetos[i] = node->getIntValue( "magnetos", 0 ); if ( i == 0 ) { // cout << "Magnetos -> " << node->getIntValue( "magnetos", 0 ); } - raw->starter_power[i] + net->starter_power[i] = node->getDoubleValue( "/systems/electrical/outputs/starter", 1.0 ) >= 1.0; if ( i == 0 ) { @@ -96,71 +96,71 @@ static void global2raw( FGRawCtrls *raw ) { // << endl; } } - raw->num_tanks = FGRawCtrls::FG_MAX_TANKS; - for ( i = 0; i < FGRawCtrls::FG_MAX_TANKS; ++i ) { + net->num_tanks = FGNetCtrls::FG_MAX_TANKS; + for ( i = 0; i < FGNetCtrls::FG_MAX_TANKS; ++i ) { if ( node->getChild("fuel-selector", i) != 0 ) { - raw->fuel_selector[i] + net->fuel_selector[i] = node->getChild("fuel-selector", i)->getDoubleValue(); } else { - raw->fuel_selector[i] = false; + net->fuel_selector[i] = false; } } - raw->num_wheels = FGRawCtrls::FG_MAX_WHEELS; - for ( i = 0; i < FGRawCtrls::FG_MAX_WHEELS; ++i ) { + net->num_wheels = FGNetCtrls::FG_MAX_WHEELS; + for ( i = 0; i < FGNetCtrls::FG_MAX_WHEELS; ++i ) { if ( node->getChild("brakes", i) != 0 ) { - raw->brake[i] + net->brake[i] = node->getChild("brakes", i)->getDoubleValue(); } else { - raw->brake[i] = 0.0; + net->brake[i] = 0.0; } } node = fgGetNode("/controls/switches", true); - raw->master_bat = node->getChild("master-bat")->getBoolValue(); - raw->master_alt = node->getChild("master-alt")->getBoolValue(); - raw->master_avionics = node->getChild("master-avionics")->getBoolValue(); + net->master_bat = node->getChild("master-bat")->getBoolValue(); + net->master_alt = node->getChild("master-alt")->getBoolValue(); + net->master_avionics = node->getChild("master-avionics")->getBoolValue(); // cur_fdm_state->get_ground_elev_ft() is what we want ... this // reports the altitude of the aircraft. // "/environment/ground-elevation-m" reports the ground elevation // of the current view point which could change substantially if // the user is switching views. - raw->hground = cur_fdm_state->get_ground_elev_ft() * SG_FEET_TO_METER; - raw->magvar = fgGetDouble("/environment/magnetic-variation-deg"); - raw->speedup = fgGetInt("/sim/speed-up"); + net->hground = cur_fdm_state->get_ground_elev_ft() * SG_FEET_TO_METER; + net->magvar = fgGetDouble("/environment/magnetic-variation-deg"); + net->speedup = fgGetInt("/sim/speed-up"); // convert to network byte order - raw->version = htonl(raw->version); - htond(raw->aileron); - htond(raw->elevator); - htond(raw->elevator_trim); - htond(raw->rudder); - htond(raw->flaps); - raw->flaps_power = htonl(raw->flaps_power); - for ( i = 0; i < FGRawCtrls::FG_MAX_ENGINES; ++i ) { - htond(raw->throttle[i]); - htond(raw->mixture[i]); - raw->fuel_pump_power[i] = htonl(raw->fuel_pump_power[i]); - htond(raw->prop_advance[i]); - raw->magnetos[i] = htonl(raw->magnetos[i]); - raw->starter_power[i] = htonl(raw->starter_power[i]); + net->version = htonl(net->version); + htond(net->aileron); + htond(net->elevator); + htond(net->elevator_trim); + htond(net->rudder); + htond(net->flaps); + net->flaps_power = htonl(net->flaps_power); + for ( i = 0; i < FGNetCtrls::FG_MAX_ENGINES; ++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]); } - raw->num_engines = htonl(raw->num_engines); - for ( i = 0; i < FGRawCtrls::FG_MAX_TANKS; ++i ) { - raw->fuel_selector[i] = htonl(raw->fuel_selector[i]); + net->num_engines = htonl(net->num_engines); + for ( i = 0; i < FGNetCtrls::FG_MAX_TANKS; ++i ) { + net->fuel_selector[i] = htonl(net->fuel_selector[i]); } - raw->num_tanks = htonl(raw->num_tanks); - for ( i = 0; i < FGRawCtrls::FG_MAX_WHEELS; ++i ) { - htond(raw->brake[i]); + net->num_tanks = htonl(net->num_tanks); + for ( i = 0; i < FGNetCtrls::FG_MAX_WHEELS; ++i ) { + htond(net->brake[i]); } - raw->num_wheels = htonl(raw->num_wheels); - raw->gear_handle = htonl(raw->gear_handle); - raw->master_bat = htonl(raw->master_bat); - raw->master_alt = htonl(raw->master_alt); - raw->master_avionics = htonl(raw->master_avionics); - htond(raw->hground); - htond(raw->magvar); - raw->speedup = htonl(raw->speedup); + net->num_wheels = htonl(net->num_wheels); + 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->hground); + htond(net->magvar); + net->speedup = htonl(net->speedup); } @@ -419,7 +419,7 @@ void FGExternalNet::update( double dt ) { // Send control positions to remote fdm length = sizeof(ctrls); - global2raw( &ctrls ); + global2net( &ctrls ); if ( data_client.send( (char *)(& ctrls), length, 0 ) != length ) { SG_LOG( SG_IO, SG_DEBUG, "Error writing data." ); } else { diff --git a/src/FDM/ExternalNet/ExternalNet.hxx b/src/FDM/ExternalNet/ExternalNet.hxx index d314cfaa0..3943e1a89 100644 --- a/src/FDM/ExternalNet/ExternalNet.hxx +++ b/src/FDM/ExternalNet/ExternalNet.hxx @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include @@ -79,7 +79,7 @@ private: bool valid; - FGRawCtrls ctrls; + FGNetCtrls ctrls; FGNetFDM fdm; public: diff --git a/src/Network/Makefile.am b/src/Network/Makefile.am index 87fda61fb..a1306b5cd 100644 --- a/src/Network/Makefile.am +++ b/src/Network/Makefile.am @@ -17,12 +17,11 @@ libNetwork_a_SOURCES = \ native.cxx native.hxx \ native_ctrls.cxx native_ctrls.hxx \ native_fdm.cxx native_fdm.hxx \ - net_fdm.hxx \ + net_ctrls.hxx net_fdm.hxx \ nmea.cxx nmea.hxx \ opengc.cxx opengc.hxx opengc_data.hxx \ props.cxx props.hxx \ pve.cxx pve.hxx \ - raw_ctrls.hxx \ ray.cxx ray.hxx \ rul.cxx rul.hxx diff --git a/src/Network/native_ctrls.cxx b/src/Network/native_ctrls.cxx index e5c79b2f7..28573c89c 100644 --- a/src/Network/native_ctrls.cxx +++ b/src/Network/native_ctrls.cxx @@ -57,57 +57,57 @@ bool FGNativeCtrls::open() { } -static void global2raw( const FGControls *global, FGRawCtrls *raw ) { +static void global2net( const FGControls *global, FGNetCtrls *net ) { int i; - raw->version = FG_RAW_CTRLS_VERSION; - raw->aileron = globals->get_controls()->get_aileron(); - raw->elevator = globals->get_controls()->get_elevator(); - raw->elevator_trim = globals->get_controls()->get_elevator_trim(); - raw->rudder = globals->get_controls()->get_rudder(); - raw->flaps = globals->get_controls()->get_flaps(); - for ( i = 0; i < FGRawCtrls::FG_MAX_ENGINES; ++i ) { - raw->throttle[i] = globals->get_controls()->get_throttle(i); - raw->mixture[i] = globals->get_controls()->get_mixture(i); - raw->prop_advance[i] = globals->get_controls()->get_prop_advance(i); + net->version = FG_NET_CTRLS_VERSION; + net->aileron = globals->get_controls()->get_aileron(); + net->elevator = globals->get_controls()->get_elevator(); + net->elevator_trim = globals->get_controls()->get_elevator_trim(); + net->rudder = globals->get_controls()->get_rudder(); + net->flaps = globals->get_controls()->get_flaps(); + for ( i = 0; i < FGNetCtrls::FG_MAX_ENGINES; ++i ) { + net->throttle[i] = globals->get_controls()->get_throttle(i); + net->mixture[i] = globals->get_controls()->get_mixture(i); + net->prop_advance[i] = globals->get_controls()->get_prop_advance(i); } - for ( i = 0; i < FGRawCtrls::FG_MAX_TANKS; ++i ) { - raw->fuel_selector[i] = globals->get_controls()->get_fuel_selector(i); + for ( i = 0; i < FGNetCtrls::FG_MAX_TANKS; ++i ) { + net->fuel_selector[i] = globals->get_controls()->get_fuel_selector(i); } - for ( i = 0; i < FGRawCtrls::FG_MAX_WHEELS; ++i ) { - raw->brake[i] = globals->get_controls()->get_brake(i); + for ( i = 0; i < FGNetCtrls::FG_MAX_WHEELS; ++i ) { + net->brake[i] = globals->get_controls()->get_brake(i); } - raw->hground = globals->get_scenery()->get_cur_elev(); + net->hground = globals->get_scenery()->get_cur_elev(); } -static void raw2global( const FGRawCtrls *raw, FGControls *global ) { +static void net2global( const FGNetCtrls *net, FGControls *global ) { int i; - if ( raw->version == FG_RAW_CTRLS_VERSION ) { - globals->get_controls()->set_aileron( raw->aileron ); - globals->get_controls()->set_elevator( raw->elevator ); - globals->get_controls()->set_elevator_trim( raw->elevator_trim ); - globals->get_controls()->set_rudder( raw->rudder ); - globals->get_controls()->set_flaps( raw->flaps ); - for ( i = 0; i < FGRawCtrls::FG_MAX_ENGINES; ++i ) { - globals->get_controls()->set_throttle( i, raw->throttle[i] ); - globals->get_controls()->set_mixture( i, raw->mixture[i] ); - globals->get_controls()->set_prop_advance( i, raw->prop_advance[i]); + if ( net->version == FG_NET_CTRLS_VERSION ) { + globals->get_controls()->set_aileron( net->aileron ); + globals->get_controls()->set_elevator( net->elevator ); + globals->get_controls()->set_elevator_trim( net->elevator_trim ); + globals->get_controls()->set_rudder( net->rudder ); + globals->get_controls()->set_flaps( net->flaps ); + for ( i = 0; i < FGNetCtrls::FG_MAX_ENGINES; ++i ) { + globals->get_controls()->set_throttle( i, net->throttle[i] ); + globals->get_controls()->set_mixture( i, net->mixture[i] ); + globals->get_controls()->set_prop_advance( i, net->prop_advance[i]); } - for ( i = 0; i < FGRawCtrls::FG_MAX_TANKS; ++i ) { - globals->get_controls()->set_fuel_selector( i, raw->fuel_selector[i] ); + for ( i = 0; i < FGNetCtrls::FG_MAX_TANKS; ++i ) { + globals->get_controls()->set_fuel_selector( i, net->fuel_selector[i] ); } - for ( i = 0; i < FGRawCtrls::FG_MAX_WHEELS; ++i ) { - globals->get_controls()->set_brake( i, raw->brake[i] ); + for ( i = 0; i < FGNetCtrls::FG_MAX_WHEELS; ++i ) { + globals->get_controls()->set_brake( i, net->brake[i] ); } - globals->get_controls()->set_gear_down( raw->gear_handle ); - globals->get_scenery()->set_cur_elev( raw->hground ); + globals->get_controls()->set_gear_down( net->gear_handle ); + globals->get_scenery()->set_cur_elev( net->hground ); } else { - SG_LOG( SG_IO, SG_ALERT, "Error: version mismatch in raw2global()" ); + SG_LOG( SG_IO, SG_ALERT, "Error: version mismatch in net2global()" ); SG_LOG( SG_IO, SG_ALERT, - "\tsomeone needs to upgrade raw_ctrls.hxx and recompile." ); + "\tsomeone needs to upgrade net_ctrls.hxx and recompile." ); } } @@ -115,27 +115,27 @@ static void raw2global( const FGRawCtrls *raw, FGControls *global ) { // process work for this port bool FGNativeCtrls::process() { SGIOChannel *io = get_io_channel(); - int length = sizeof(FGRawCtrls); + int length = sizeof(FGNetCtrls); if ( get_direction() == SG_IO_OUT ) { // cout << "size of cur_fdm_state = " << length << endl; - global2raw( globals->get_controls(), &raw_ctrls ); + global2net( globals->get_controls(), &net_ctrls ); - if ( ! io->write( (char *)(& raw_ctrls), length ) ) { + if ( ! io->write( (char *)(& net_ctrls), length ) ) { SG_LOG( SG_IO, SG_ALERT, "Error writing data." ); return false; } } else if ( get_direction() == SG_IO_IN ) { if ( io->get_type() == sgFileType ) { - if ( io->read( (char *)(& raw_ctrls), length ) == length ) { + if ( io->read( (char *)(& net_ctrls), length ) == length ) { SG_LOG( SG_IO, SG_DEBUG, "Success reading data." ); - raw2global( &raw_ctrls, globals->get_controls() ); + net2global( &net_ctrls, globals->get_controls() ); } } else { - while ( io->read( (char *)(& raw_ctrls), length ) == length ) { + while ( io->read( (char *)(& net_ctrls), length ) == length ) { SG_LOG( SG_IO, SG_DEBUG, "Success reading data." ); - raw2global( &raw_ctrls, globals->get_controls() ); + net2global( &net_ctrls, globals->get_controls() ); } } } diff --git a/src/Network/native_ctrls.hxx b/src/Network/native_ctrls.hxx index db47daff3..ce05affd2 100644 --- a/src/Network/native_ctrls.hxx +++ b/src/Network/native_ctrls.hxx @@ -32,14 +32,14 @@ #include #include "protocol.hxx" -#include "raw_ctrls.hxx" +#include "net_ctrls.hxx" SG_USING_STD(string); class FGNativeCtrls : public FGProtocol { - FGRawCtrls raw_ctrls; + FGNetCtrls net_ctrls; FGControls ctrls; int length; diff --git a/src/Network/raw_ctrls.hxx b/src/Network/net_ctrls.hxx similarity index 93% rename from src/Network/raw_ctrls.hxx rename to src/Network/net_ctrls.hxx index 69bb39683..a1797b3f6 100644 --- a/src/Network/raw_ctrls.hxx +++ b/src/Network/net_ctrls.hxx @@ -1,4 +1,4 @@ -// raw_ctrls.hxx -- defines a common raw I/O interface to the flight +// net_ctrls.hxx -- defines a common net I/O interface to the flight // sim controls // // Written by Curtis Olson, started July 2001. @@ -22,20 +22,20 @@ // $Id$ -#ifndef _RAW_CTRLS_HXX -#define _RAW_CTRLS_HXX +#ifndef _NET_CTRLS_HXX +#define _NET_CTRLS_HXX #ifndef __cplusplus # error This library requires C++ #endif -const int FG_RAW_CTRLS_VERSION = 11; +const int FG_NET_CTRLS_VERSION = 11; // Define a structure containing the control parameters -class FGRawCtrls { +class FGNetCtrls { public: @@ -87,6 +87,6 @@ public: }; -#endif // _RAW_CTRLS_HXX +#endif // _NET_CTRLS_HXX -- 2.39.5