From b9e4775a7a4bbeac9e3af2bf617ddacfbc2d47bf Mon Sep 17 00:00:00 2001 From: mfranz Date: Wed, 6 Dec 2006 22:11:43 +0000 Subject: [PATCH] Roy Vegard Ovesen: - finish cleanup/optimization of instrumentation system (started by mfranz) - improve configuration of special properties by addressing them directly --- src/Instrumentation/airspeed_indicator.cxx | 18 +++---- src/Instrumentation/airspeed_indicator.hxx | 9 ++-- src/Instrumentation/altimeter.cxx | 39 +++----------- src/Instrumentation/altimeter.hxx | 15 +++--- src/Instrumentation/attitude_indicator.cxx | 43 ++++----------- src/Instrumentation/attitude_indicator.hxx | 7 ++- src/Instrumentation/dme.cxx | 37 ++----------- src/Instrumentation/dme.hxx | 5 +- src/Instrumentation/encoder.cxx | 33 +++--------- src/Instrumentation/encoder.hxx | 6 +-- src/Instrumentation/gps.cxx | 42 ++------------- src/Instrumentation/gps.hxx | 16 +++--- src/Instrumentation/heading_indicator.cxx | 43 ++++----------- src/Instrumentation/heading_indicator.hxx | 6 +-- src/Instrumentation/mag_compass.cxx | 54 +++++-------------- src/Instrumentation/mag_compass.hxx | 4 +- src/Instrumentation/mrg.cxx | 36 +++---------- src/Instrumentation/mrg.hxx | 5 +- src/Instrumentation/navradio.cxx | 41 ++++---------- src/Instrumentation/navradio.hxx | 4 +- src/Instrumentation/slip_skid_ball.cxx | 28 ++-------- src/Instrumentation/slip_skid_ball.hxx | 8 +-- src/Instrumentation/transponder.cxx | 33 +++--------- src/Instrumentation/transponder.hxx | 6 +-- src/Instrumentation/turn_indicator.cxx | 37 +++---------- src/Instrumentation/turn_indicator.hxx | 5 +- .../vertical_speed_indicator.cxx | 36 +++---------- .../vertical_speed_indicator.hxx | 7 ++- src/Instrumentation/wxradar.cxx | 28 ++-------- src/Instrumentation/wxradar.hxx | 4 +- src/Systems/pitot.cxx | 30 ++--------- src/Systems/pitot.hxx | 5 +- src/Systems/static.cxx | 30 ++--------- src/Systems/static.hxx | 4 +- src/Systems/vacuum.cxx | 41 +++++--------- src/Systems/vacuum.hxx | 8 +-- 36 files changed, 188 insertions(+), 585 deletions(-) diff --git a/src/Instrumentation/airspeed_indicator.cxx b/src/Instrumentation/airspeed_indicator.cxx index 5d5c6c39e..0196ddbae 100644 --- a/src/Instrumentation/airspeed_indicator.cxx +++ b/src/Instrumentation/airspeed_indicator.cxx @@ -17,10 +17,10 @@ AirspeedIndicator::AirspeedIndicator ( SGPropertyNode *node ) : - name(node->getStringValue("name", "airspeed-indicator")), - num(node->getIntValue("number", 0)), - pitot_port(node->getStringValue("pitot-port", "/systems/pitot")), - static_port(node->getStringValue("static-port", "/systems/static")) + _name(node->getStringValue("name", "airspeed-indicator")), + _num(node->getIntValue("number", 0)), + _total_pressure(node->getStringValue("total-pressure", "/systems/pitot/total-pressure-inhg")), + _static_pressure(node->getStringValue("static-pressure", "/systems/static/pressure-inhg")) { } @@ -32,14 +32,12 @@ void AirspeedIndicator::init () { string branch; - branch = "/instrumentation/" + name; - pitot_port += "/total-pressure-inhg"; - static_port += "/pressure-inhg"; + branch = "/instrumentation/" + _name; - SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); _serviceable_node = node->getChild("serviceable", 0, true); - _total_pressure_node = fgGetNode(pitot_port.c_str(), true); - _static_pressure_node = fgGetNode(static_port.c_str(), true); + _total_pressure_node = fgGetNode(_total_pressure.c_str(), true); + _static_pressure_node = fgGetNode(_static_pressure.c_str(), true); _density_node = fgGetNode("/environment/density-slugft3", true); _speed_node = node->getChild("indicated-speed-kt", 0, true); } diff --git a/src/Instrumentation/airspeed_indicator.hxx b/src/Instrumentation/airspeed_indicator.hxx index 5bab3aa7a..e4827081d 100644 --- a/src/Instrumentation/airspeed_indicator.hxx +++ b/src/Instrumentation/airspeed_indicator.hxx @@ -35,7 +35,6 @@ class AirspeedIndicator : public SGSubsystem public: AirspeedIndicator ( SGPropertyNode *node ); - AirspeedIndicator ( int i); virtual ~AirspeedIndicator (); virtual void init (); @@ -43,10 +42,10 @@ public: private: - string name; - unsigned int num; - string pitot_port; - string static_port; + string _name; + unsigned int _num; + string _total_pressure; + string _static_pressure; SGPropertyNode_ptr _serviceable_node; SGPropertyNode_ptr _total_pressure_node; SGPropertyNode_ptr _static_pressure_node; diff --git a/src/Instrumentation/altimeter.cxx b/src/Instrumentation/altimeter.cxx index ceea78ddc..ebd2f6d0d 100644 --- a/src/Instrumentation/altimeter.cxx +++ b/src/Instrumentation/altimeter.cxx @@ -46,40 +46,14 @@ static double altitude_data[][2] = { Altimeter::Altimeter ( SGPropertyNode *node ) - : name("altimeter"), - num(0), - static_port("/systems/static"), + : _name(node->getStringValue("name", "altimeter")), + _num(node->getIntValue("number", 0)), + _static_pressure(node->getStringValue("static-pressure", "/systems/static/pressure-inhg")), _altitude_table(new SGInterpTable) { int i; for (i = 0; altitude_data[i][0] != -1; i++) _altitude_table->addEntry(altitude_data[i][0], altitude_data[i][1]); - - for ( i = 0; i < node->nChildren(); ++i ) { - SGPropertyNode *child = node->getChild(i); - string cname = child->getName(); - string cval = child->getStringValue(); - if ( cname == "name" ) { - name = cval; - } else if ( cname == "number" ) { - num = child->getIntValue(); - } else if ( cname == "static-port" ) { - static_port = cval; - } else { - SG_LOG( SG_INSTR, SG_WARN, "Error in altimeter config logic" ); - if ( name.length() ) { - SG_LOG( SG_INSTR, SG_WARN, "Section = " << name ); - } - } - } -} - -Altimeter::Altimeter () - : _altitude_table(new SGInterpTable) -{ - - for (int i = 0; altitude_data[i][0] != -1; i++) - _altitude_table->addEntry(altitude_data[i][0], altitude_data[i][1]); } Altimeter::~Altimeter () @@ -91,14 +65,13 @@ void Altimeter::init () { string branch; - branch = "/instrumentation/" + name; - static_port += "/pressure-inhg"; + branch = "/instrumentation/" + _name; - SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); _serviceable_node = node->getChild("serviceable", 0, true); _setting_node = node->getChild("setting-inhg", 0, true); - _pressure_node = fgGetNode(static_port.c_str(), true); + _pressure_node = fgGetNode(_static_pressure.c_str(), true); _altitude_node = node->getChild("indicated-altitude-ft", 0, true); } diff --git a/src/Instrumentation/altimeter.hxx b/src/Instrumentation/altimeter.hxx index f75c207bd..1e4aa1202 100644 --- a/src/Instrumentation/altimeter.hxx +++ b/src/Instrumentation/altimeter.hxx @@ -23,13 +23,13 @@ class SGInterpTable; * * Input properties: * - * /instrumentation/"name"/serviceable - * /instrumentation/"name"/setting-inhg - * "static_port"/pressure-inhg + * /instrumentation//serviceable + * /instrumentation//setting-inhg + * * * Output properties: * - * /instrumentation/"name"/indicated-altitude-ft + * /instrumentation//indicated-altitude-ft */ class Altimeter : public SGSubsystem { @@ -37,7 +37,6 @@ class Altimeter : public SGSubsystem public: Altimeter (SGPropertyNode *node); - Altimeter (); virtual ~Altimeter (); virtual void init (); @@ -45,9 +44,9 @@ public: private: - string name; - int num; - string static_port; + string _name; + int _num; + string _static_pressure; SGPropertyNode_ptr _serviceable_node; SGPropertyNode_ptr _setting_node; diff --git a/src/Instrumentation/attitude_indicator.cxx b/src/Instrumentation/attitude_indicator.cxx index 1555c2c74..4753afd0a 100644 --- a/src/Instrumentation/attitude_indicator.cxx +++ b/src/Instrumentation/attitude_indicator.cxx @@ -21,31 +21,9 @@ AttitudeIndicator::AttitudeIndicator ( SGPropertyNode *node ) : - name("attitude-indicator"), - num(0), - vacuum_system("/systems/vacuum") -{ - int i; - for ( i = 0; i < node->nChildren(); ++i ) { - SGPropertyNode *child = node->getChild(i); - string cname = child->getName(); - string cval = child->getStringValue(); - if ( cname == "name" ) { - name = cval; - } else if ( cname == "number" ) { - num = (int) child->getDoubleValue(); - } else if ( cname == "vacuum-system" ) { - vacuum_system = cval; - } else { - SG_LOG( SG_INSTR, SG_WARN, "Error in attitude-indicator config logic" ); - if ( name.length() ) { - SG_LOG( SG_INSTR, SG_WARN, "Section = " << name ); - } - } - } -} - -AttitudeIndicator::AttitudeIndicator () + _name(node->getStringValue("name", "attitude-indicator")), + _num(node->getIntValue("number", 0)), + _suction(node->getStringValue("suction", "/systems/vacuum/suction-inhg")) { } @@ -57,14 +35,13 @@ void AttitudeIndicator::init () { string branch; - branch = "/instrumentation/" + name; - vacuum_system += "/suction-inhg"; + branch = "/instrumentation/" + _name; - SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); _pitch_in_node = fgGetNode("/orientation/pitch-deg", true); _roll_in_node = fgGetNode("/orientation/roll-deg", true); - _suction_node = fgGetNode(vacuum_system.c_str(), true); + _suction_node = fgGetNode(_suction.c_str(), true); SGPropertyNode *cnode = node->getChild("config", 0, true); _tumble_flag_node = cnode->getChild("tumble-flag", 0, true); _caged_node = node->getChild("caged-flag", 0, true); @@ -80,8 +57,8 @@ AttitudeIndicator::bind () { std::ostringstream temp; string branch; - temp << num; - branch = "/instrumentation/" + name + "[" + temp.str() + "]"; + temp << _num; + branch = "/instrumentation/" + _name + "[" + temp.str() + "]"; fgTie((branch + "/serviceable").c_str(), &_gyro, &Gyro::is_serviceable, &Gyro::set_serviceable); @@ -94,8 +71,8 @@ AttitudeIndicator::unbind () { std::ostringstream temp; string branch; - temp << num; - branch = "/instrumentation/" + name + "[" + temp.str() + "]"; + temp << _num; + branch = "/instrumentation/" + _name + "[" + temp.str() + "]"; fgUntie((branch + "/serviceable").c_str()); fgUntie((branch + "/spin").c_str()); diff --git a/src/Instrumentation/attitude_indicator.hxx b/src/Instrumentation/attitude_indicator.hxx index 1895760ad..2e8bdf128 100644 --- a/src/Instrumentation/attitude_indicator.hxx +++ b/src/Instrumentation/attitude_indicator.hxx @@ -42,7 +42,6 @@ class AttitudeIndicator : public SGSubsystem public: AttitudeIndicator ( SGPropertyNode *node ); - AttitudeIndicator (); virtual ~AttitudeIndicator (); virtual void init (); @@ -52,9 +51,9 @@ public: private: - string name; - int num; - string vacuum_system; + string _name; + int _num; + string _suction; Gyro _gyro; diff --git a/src/Instrumentation/dme.cxx b/src/Instrumentation/dme.cxx index 485412a12..f12b4f80e 100644 --- a/src/Instrumentation/dme.cxx +++ b/src/Instrumentation/dme.cxx @@ -48,35 +48,8 @@ DME::DME ( SGPropertyNode *node ) _transmitter_elevation_ft(0), _transmitter_range_nm(0), _transmitter_bias(0.0), - name("dme"), - num(0) -{ - int i; - for ( i = 0; i < node->nChildren(); ++i ) { - SGPropertyNode *child = node->getChild(i); - string cname = child->getName(); - string cval = child->getStringValue(); - if ( cname == "name" ) { - name = cval; - } else if ( cname == "number" ) { - num = child->getIntValue(); - } else { - SG_LOG( SG_INSTR, SG_WARN, "Error in dme config logic" ); - if ( name.length() ) { - SG_LOG( SG_INSTR, SG_WARN, "Section = " << name ); - } - } - } -} - -DME::DME () - : _last_distance_nm(0), - _last_frequency_mhz(-1), - _time_before_search_sec(0), - _transmitter_valid(false), - _transmitter_elevation_ft(0), - _transmitter_range_nm(0), - _transmitter_bias(0.0) + _name(node->getStringValue("name", "dme")), + _num(node->getIntValue("number", 0)) { } @@ -88,9 +61,9 @@ void DME::init () { string branch; - branch = "/instrumentation/" + name; + branch = "/instrumentation/" + _name; - SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); _longitude_node = fgGetNode("/position/longitude-deg", true); _latitude_node = fgGetNode("/position/latitude-deg", true); @@ -113,7 +86,7 @@ DME::update (double delta_time_sec) const char * source = _source_node->getStringValue(); if (source[0] == '\0') { string branch; - branch = "/instrumentation/" + name + "/frequencies/selected-mhz"; + branch = "/instrumentation/" + _name + "/frequencies/selected-mhz"; _source_node->setStringValue(branch.c_str()); source = _source_node->getStringValue(); } diff --git a/src/Instrumentation/dme.hxx b/src/Instrumentation/dme.hxx index 1d3e2e1cc..03ecca231 100644 --- a/src/Instrumentation/dme.hxx +++ b/src/Instrumentation/dme.hxx @@ -42,7 +42,6 @@ class DME : public SGSubsystem public: DME ( SGPropertyNode *node ); - DME (); virtual ~DME (); virtual void init (); @@ -76,8 +75,8 @@ private: double _transmitter_range_nm; double _transmitter_bias; - string name; - int num; + string _name; + int _num; }; diff --git a/src/Instrumentation/encoder.cxx b/src/Instrumentation/encoder.cxx index 5fd5504e7..fa603f72f 100644 --- a/src/Instrumentation/encoder.cxx +++ b/src/Instrumentation/encoder.cxx @@ -60,35 +60,17 @@ int round (double value, int nearest=1) return ((int) (value/nearest + 0.5)) * nearest; } + Encoder::Encoder(SGPropertyNode *node) : - name("encoder"), - num(0), - staticPort("/systems/static"), + _name(node->getStringValue("name", "encoder")), + _num(node->getIntValue("number", 0)), + _static_pressure(node->getStringValue("static-pressure", "/systems/static/pressure-inhg")), altitudeTable(new SGInterpTable) { int i; for ( i = 0; altitude_data[i][0] != -1; i++ ) altitudeTable->addEntry(altitude_data[i][0], altitude_data[i][1]); - - for ( i = 0; i < node->nChildren(); ++i ) { - SGPropertyNode *child = node->getChild(i); - string cname = child->getName(); - string cval = child->getStringValue(); - if ( cname == "name" ) { - name = cval; - } else if ( cname == "number" ) { - num = child->getIntValue(); - } else if ( cname == "static-port" ) { - staticPort = cval; - } else { - SG_LOG( SG_INSTR, SG_WARN, - "Error in encoder config logic" ); - if ( name.length() ) { - SG_LOG( SG_INSTR, SG_WARN, "Section = " << name ); - } - } - } } @@ -101,12 +83,11 @@ Encoder::~Encoder() void Encoder::init() { string branch; - branch = "/instrumentation/" + name; - staticPort += "/pressure-inhg"; + branch = "/instrumentation/" + _name; - SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); // Inputs - staticPressureNode = fgGetNode(staticPort.c_str(), true); + staticPressureNode = fgGetNode(_static_pressure.c_str(), true); busPowerNode = fgGetNode("/systems/electrical/outputs/encoder", true); serviceableNode = node->getChild("serviceable", 0, true); // Outputs diff --git a/src/Instrumentation/encoder.hxx b/src/Instrumentation/encoder.hxx index 39a0489f1..755ebcdea 100644 --- a/src/Instrumentation/encoder.hxx +++ b/src/Instrumentation/encoder.hxx @@ -51,9 +51,9 @@ private: SGPropertyNode_ptr modeCAltitudeNode; // Internal - string name; - int num; - string staticPort; + string _name; + int _num; + string _static_pressure; SGInterpTable* altitudeTable; }; diff --git a/src/Instrumentation/gps.cxx b/src/Instrumentation/gps.cxx index 26c007352..ae0f3c810 100644 --- a/src/Instrumentation/gps.cxx +++ b/src/Instrumentation/gps.cxx @@ -41,41 +41,9 @@ GPS::GPS ( SGPropertyNode *node) _wp1_altitude_m(0), _alt_dist_ratio(0), _distance_m(0), - _course_deg(0) -{ - int i; - for ( i = 0; i < node->nChildren(); ++i ) { - SGPropertyNode *child = node->getChild(i); - string cname = child->getName(); - string cval = child->getStringValue(); - if ( cname == "name" ) { - name = cval; - } else if ( cname == "number" ) { - num = child->getIntValue(); - } else { - SG_LOG( SG_INSTR, SG_WARN, "Error in gps config logic" ); - if ( name.length() ) { - SG_LOG( SG_INSTR, SG_WARN, "Section = " << name ); - } - } - } -} - -GPS::GPS () - : _last_valid(false), - _last_longitude_deg(0), - _last_latitude_deg(0), - _last_altitude_m(0), - _last_speed_kts(0), - _wp0_latitude_deg(0), - _wp0_longitude_deg(0), - _wp0_altitude_m(0), - _wp1_latitude_deg(0), - _wp1_longitude_deg(0), - _wp1_altitude_m(0), - _alt_dist_ratio(0), - _distance_m(0), - _course_deg(0) + _course_deg(0), + _name(node->getStringValue("name", "gps")), + _num(node->getIntValue("number", 0)) { } @@ -90,9 +58,9 @@ GPS::init () route->clear(); string branch; - branch = "/instrumentation/" + name; + branch = "/instrumentation/" + _name; - SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); _longitude_node = fgGetNode("/position/longitude-deg", true); _latitude_node = fgGetNode("/position/latitude-deg", true); diff --git a/src/Instrumentation/gps.hxx b/src/Instrumentation/gps.hxx index fb068ac7b..27948ecb4 100644 --- a/src/Instrumentation/gps.hxx +++ b/src/Instrumentation/gps.hxx @@ -166,14 +166,14 @@ private: double _distance_m; double _course_deg; - double bias_length; - double bias_angle; - double azimuth_error; - double range_error; - double elapsed_time; - - string name; - int num; + double _bias_length; + double _bias_angle; + double _azimuth_error; + double _range_error; + double _elapsed_time; + + string _name; + int _num; }; diff --git a/src/Instrumentation/heading_indicator.cxx b/src/Instrumentation/heading_indicator.cxx index 4ab01a60f..a7e96e550 100644 --- a/src/Instrumentation/heading_indicator.cxx +++ b/src/Instrumentation/heading_indicator.cxx @@ -15,31 +15,9 @@ HeadingIndicator::HeadingIndicator ( SGPropertyNode *node ) : - name("heading-indicator"), - num(0), - vacuum_system("/systems/vacuum") -{ - int i; - for ( i = 0; i < node->nChildren(); ++i ) { - SGPropertyNode *child = node->getChild(i); - string cname = child->getName(); - string cval = child->getStringValue(); - if ( cname == "name" ) { - name = cval; - } else if ( cname == "number" ) { - num = child->getIntValue(); - } else if ( cname == "vacuum-system" ) { - vacuum_system = cval; - } else { - SG_LOG( SG_INSTR, SG_WARN, "Error in heading-indicator config logic" ); - if ( name.length() ) { - SG_LOG( SG_INSTR, SG_WARN, "Section = " << name ); - } - } - } -} - -HeadingIndicator::HeadingIndicator () + _name(node->getStringValue("name", "heading-indicator")), + _num(node->getIntValue("number", 0)), + _suction(node->getStringValue("suction", "/systems/vacuum/suction-inhg")) { } @@ -51,13 +29,12 @@ void HeadingIndicator::init () { string branch; - branch = "/instrumentation/" + name; - vacuum_system += "/suction-inhg"; + branch = "/instrumentation/" + _name; - SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); _offset_node = node->getChild("offset-deg", 0, true); _heading_in_node = fgGetNode("/orientation/heading-deg", true); - _suction_node = fgGetNode(vacuum_system.c_str(), true); + _suction_node = fgGetNode(_suction.c_str(), true); _heading_out_node = node->getChild("indicated-heading-deg", 0, true); _last_heading_deg = (_heading_in_node->getDoubleValue() + _offset_node->getDoubleValue()); @@ -68,8 +45,8 @@ HeadingIndicator::bind () { std::ostringstream temp; string branch; - temp << num; - branch = "/instrumentation/" + name + "[" + temp.str() + "]"; + temp << _num; + branch = "/instrumentation/" + _name + "[" + temp.str() + "]"; fgTie((branch + "/serviceable").c_str(), &_gyro, &Gyro::is_serviceable, &Gyro::set_serviceable); @@ -82,8 +59,8 @@ HeadingIndicator::unbind () { std::ostringstream temp; string branch; - temp << num; - branch = "/instrumentation/" + name + "[" + temp.str() + "]"; + temp << _num; + branch = "/instrumentation/" + _name + "[" + temp.str() + "]"; fgUntie((branch + "/serviceable").c_str()); fgUntie((branch + "/spin").c_str()); diff --git a/src/Instrumentation/heading_indicator.hxx b/src/Instrumentation/heading_indicator.hxx index 4ba772d22..831638407 100644 --- a/src/Instrumentation/heading_indicator.hxx +++ b/src/Instrumentation/heading_indicator.hxx @@ -51,9 +51,9 @@ private: Gyro _gyro; double _last_heading_deg; - string name; - int num; - string vacuum_system; + string _name; + int _num; + string _suction; SGPropertyNode_ptr _offset_node; SGPropertyNode_ptr _heading_in_node; diff --git a/src/Instrumentation/mag_compass.cxx b/src/Instrumentation/mag_compass.cxx index e67d35074..223c77708 100644 --- a/src/Instrumentation/mag_compass.cxx +++ b/src/Instrumentation/mag_compass.cxx @@ -21,30 +21,8 @@ MagCompass::MagCompass ( SGPropertyNode *node ) : _error_deg(0.0), _rate_degps(0.0), - name("magnetic-compass"), - num(0) -{ - int i; - for ( i = 0; i < node->nChildren(); ++i ) { - SGPropertyNode *child = node->getChild(i); - string cname = child->getName(); - string cval = child->getStringValue(); - if ( cname == "name" ) { - name = cval; - } else if ( cname == "number" ) { - num = child->getIntValue(); - } else { - SG_LOG( SG_INSTR, SG_WARN, "Error in magnetic-compass config logic" ); - if ( name.length() ) { - SG_LOG( SG_INSTR, SG_WARN, "Section = " << name ); - } - } - } -} - -MagCompass::MagCompass () - : _error_deg(0.0), - _rate_degps(0.0) + _name(node->getStringValue("name", "magnetic-compass")), + _num(node->getIntValue("number", 0)) { } @@ -56,26 +34,18 @@ void MagCompass::init () { string branch; - branch = "/instrumentation/" + name; + branch = "/instrumentation/" + _name; - SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); _serviceable_node = node->getChild("serviceable", 0, true); - _roll_node = - fgGetNode("/orientation/roll-deg", true); - _pitch_node = - fgGetNode("/orientation/pitch-deg", true); - _heading_node = - fgGetNode("/orientation/heading-magnetic-deg", true); - _beta_node = - fgGetNode("/orientation/side-slip-deg", true); - _dip_node = - fgGetNode("/environment/magnetic-dip-deg", true); - _x_accel_node = - fgGetNode("/accelerations/pilot/x-accel-fps_sec", true); - _y_accel_node = - fgGetNode("/accelerations/pilot/y-accel-fps_sec", true); - _z_accel_node = - fgGetNode("/accelerations/pilot/z-accel-fps_sec", true); + _roll_node = fgGetNode("/orientation/roll-deg", true); + _pitch_node = fgGetNode("/orientation/pitch-deg", true); + _heading_node = fgGetNode("/orientation/heading-magnetic-deg", true); + _beta_node = fgGetNode("/orientation/side-slip-deg", true); + _dip_node = fgGetNode("/environment/magnetic-dip-deg", true); + _x_accel_node = fgGetNode("/accelerations/pilot/x-accel-fps_sec", true); + _y_accel_node = fgGetNode("/accelerations/pilot/y-accel-fps_sec", true); + _z_accel_node = fgGetNode("/accelerations/pilot/z-accel-fps_sec", true); _out_node = node->getChild("indicated-heading-deg", 0, true); } diff --git a/src/Instrumentation/mag_compass.hxx b/src/Instrumentation/mag_compass.hxx index ea5ac60ec..919f26bc9 100644 --- a/src/Instrumentation/mag_compass.hxx +++ b/src/Instrumentation/mag_compass.hxx @@ -51,8 +51,8 @@ private: double _error_deg; double _rate_degps; - string name; - int num; + string _name; + int _num; SGPropertyNode_ptr _serviceable_node; SGPropertyNode_ptr _roll_node; diff --git a/src/Instrumentation/mrg.cxx b/src/Instrumentation/mrg.cxx index 830079172..d890ee266 100644 --- a/src/Instrumentation/mrg.cxx +++ b/src/Instrumentation/mrg.cxx @@ -20,28 +20,8 @@ MasterReferenceGyro::MasterReferenceGyro ( SGPropertyNode *node ) : - name("master-reference-gyro"), - num(0) -{ - int i; - for ( i = 0; i < node->nChildren(); ++i ) { - SGPropertyNode *child = node->getChild(i); - string cname = child->getName(); - string cval = child->getStringValue(); - if ( cname == "name" ) { - name = cval; - } else if ( cname == "number" ) { - num = (int) child->getDoubleValue(); - } else { - SG_LOG( SG_INSTR, SG_WARN, "Error in mrg config logic" ); - if ( name.length() ) { - SG_LOG( SG_INSTR, SG_WARN, "Section = " << name ); - } - } - } -} - -MasterReferenceGyro::MasterReferenceGyro () + _name(node->getStringValue("name", "master-reference-gyro")), + _num(node->getIntValue("number", 0)) { } @@ -63,7 +43,7 @@ MasterReferenceGyro::init () _indicated_pitch_rate = 0; string branch; - branch = "/instrumentation/" + name; + branch = "/instrumentation/" + _name; _pitch_in_node = fgGetNode("/orientation/pitch-deg", true); _roll_in_node = fgGetNode("/orientation/roll-deg", true); @@ -74,7 +54,7 @@ MasterReferenceGyro::init () _g_in_node = fgGetNode("/accelerations/pilot-g-damped", true); _electrical_node = fgGetNode("/systems/electrical/outputs/MRG", true); - SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); _off_node = node->getChild("off-flag", 0, true); _pitch_out_node = node->getChild("indicated-pitch-deg", 0, true); _roll_out_node = node->getChild("indicated-roll-deg", 0, true); @@ -95,8 +75,8 @@ MasterReferenceGyro::bind () { std::ostringstream temp; string branch; - temp << num; - branch = "/instrumentation/" + name + "[" + temp.str() + "]"; + temp << _num; + branch = "/instrumentation/" + _name + "[" + temp.str() + "]"; fgTie((branch + "/serviceable").c_str(), &_gyro, &Gyro::is_serviceable, &Gyro::set_serviceable); @@ -109,8 +89,8 @@ MasterReferenceGyro::unbind () { std::ostringstream temp; string branch; - temp << num; - branch = "/instrumentation/" + name + "[" + temp.str() + "]"; + temp << _num; + branch = "/instrumentation/" + _name + "[" + temp.str() + "]"; fgUntie((branch + "/serviceable").c_str()); fgUntie((branch + "/spin").c_str()); diff --git a/src/Instrumentation/mrg.hxx b/src/Instrumentation/mrg.hxx index b10f653ce..a12df8aaf 100644 --- a/src/Instrumentation/mrg.hxx +++ b/src/Instrumentation/mrg.hxx @@ -25,7 +25,6 @@ * /instrumentation/"name"/tumble-norm * /orientation/pitch-deg * /orientation/roll-deg - * "vacuum-system"/suction-inhg * * Output properties: * @@ -50,8 +49,8 @@ public: private: - string name; - int num; + string _name; + int _num; double _last_roll; double _last_pitch; diff --git a/src/Instrumentation/navradio.cxx b/src/Instrumentation/navradio.cxx index 4bec5789b..1eae58fe1 100644 --- a/src/Instrumentation/navradio.cxx +++ b/src/Instrumentation/navradio.cxx @@ -100,8 +100,8 @@ FGNavRadio::FGNavRadio(SGPropertyNode *node) : last_x(0.0), last_loc_dist(0.0), last_xtrack_error(0.0), - name("nav"), - num(0), + _name(node->getStringValue("name", "nav")), + _num(node->getIntValue("number", 0)), _time_before_search_sec(-1.0) { SGPath path( globals->get_fg_root() ); @@ -115,25 +115,6 @@ FGNavRadio::FGNavRadio(SGPropertyNode *node) : term_tbl = new SGInterpTable( term.str() ); low_tbl = new SGInterpTable( low.str() ); high_tbl = new SGInterpTable( high.str() ); - - int i; - for ( i = 0; i < node->nChildren(); ++i ) { - SGPropertyNode *child = node->getChild(i); - string cname = child->getName(); - string cval = child->getStringValue(); - if ( cname == "name" ) { - name = cval; - } else if ( cname == "number" ) { - num = child->getIntValue(); - } else { - SG_LOG( SG_INSTR, SG_WARN, - "Error in nav radio config logic" ); - if ( name.length() ) { - SG_LOG( SG_INSTR, SG_WARN, "Section = " << name ); - } - } - } - } @@ -152,12 +133,12 @@ FGNavRadio::init () morse.init(); string branch; - branch = "/instrumentation/" + name; + branch = "/instrumentation/" + _name; - SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); bus_power_node = - fgGetNode(("/systems/electrical/outputs/" + name).c_str(), true); + fgGetNode(("/systems/electrical/outputs/" + _name).c_str(), true); // inputs is_valid_node = node->getChild("data-is-valid", 0, true); @@ -222,9 +203,9 @@ FGNavRadio::init () gps_from_flag_node = fgGetNode("/instrumentation/gps/from-flag", true); std::ostringstream temp; - temp << name << "nav-ident" << num; + temp << _name << "nav-ident" << _num; nav_fx_name = temp.str(); - temp << name << "dme-ident" << num; + temp << _name << "dme-ident" << _num; dme_fx_name = temp.str(); } @@ -233,8 +214,8 @@ FGNavRadio::bind () { std::ostringstream temp; string branch; - temp << num; - branch = "/instrumentation/" + name + "[" + temp.str() + "]"; + temp << _num; + branch = "/instrumentation/" + _name + "[" + temp.str() + "]"; } @@ -243,8 +224,8 @@ FGNavRadio::unbind () { std::ostringstream temp; string branch; - temp << num; - branch = "/instrumentation/" + name + "[" + temp.str() + "]"; + temp << _num; + branch = "/instrumentation/" + _name + "[" + temp.str() + "]"; } diff --git a/src/Instrumentation/navradio.hxx b/src/Instrumentation/navradio.hxx index 4dde4ae20..34c1350b0 100644 --- a/src/Instrumentation/navradio.hxx +++ b/src/Instrumentation/navradio.hxx @@ -142,8 +142,8 @@ class FGNavRadio : public SGSubsystem double last_loc_dist; double last_xtrack_error; - string name; - int num; + string _name; + int _num; // internal periodic station search timer double _time_before_search_sec; diff --git a/src/Instrumentation/slip_skid_ball.cxx b/src/Instrumentation/slip_skid_ball.cxx index 9f4193ee5..4925e1fa9 100644 --- a/src/Instrumentation/slip_skid_ball.cxx +++ b/src/Instrumentation/slip_skid_ball.cxx @@ -10,28 +10,8 @@ SlipSkidBall::SlipSkidBall ( SGPropertyNode *node) : - name("slip-skid-ball"), - num(0) -{ - int i; - for ( i = 0; i < node->nChildren(); ++i ) { - SGPropertyNode *child = node->getChild(i); - string cname = child->getName(); - string cval = child->getStringValue(); - if ( cname == "name" ) { - name = cval; - } else if ( cname == "number" ) { - num = child->getIntValue(); - } else { - SG_LOG( SG_INSTR, SG_WARN, "Error in slip-skid-ball config logic" ); - if ( name.length() ) { - SG_LOG( SG_INSTR, SG_WARN, "Section = " << name ); - } - } - } -} - -SlipSkidBall::SlipSkidBall () + _name(node->getStringValue("name", "slip-skid-ball")), + _num(node->getIntValue("number", 0)) { } @@ -43,9 +23,9 @@ void SlipSkidBall::init () { string branch; - branch = "/instrumentation/" + name; + branch = "/instrumentation/" + _name; - SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); _serviceable_node = node->getChild("serviceable", 0, true); _y_accel_node = fgGetNode("/accelerations/pilot/y-accel-fps_sec", true); _z_accel_node = fgGetNode("/accelerations/pilot/z-accel-fps_sec", true); diff --git a/src/Instrumentation/slip_skid_ball.hxx b/src/Instrumentation/slip_skid_ball.hxx index 7266cdfce..3a95b115a 100644 --- a/src/Instrumentation/slip_skid_ball.hxx +++ b/src/Instrumentation/slip_skid_ball.hxx @@ -14,8 +14,6 @@ #include #include -#include "gyro.hxx" - /** * Model a slip-skid ball. @@ -36,7 +34,6 @@ class SlipSkidBall : public SGSubsystem public: SlipSkidBall ( SGPropertyNode *node ); - SlipSkidBall (); virtual ~SlipSkidBall (); virtual void init (); @@ -44,11 +41,10 @@ public: private: - Gyro _gyro; double _last_pos; - string name; - int num; + string _name; + int _num; SGPropertyNode_ptr _serviceable_node; SGPropertyNode_ptr _y_accel_node; diff --git a/src/Instrumentation/transponder.cxx b/src/Instrumentation/transponder.cxx index 192593b3b..9fa5f13a3 100644 --- a/src/Instrumentation/transponder.cxx +++ b/src/Instrumentation/transponder.cxx @@ -26,29 +26,11 @@ Transponder::Transponder(SGPropertyNode *node) : - name("transponder"), - num(0), - encoder("/instrumentation/encoder") + _name(node->getStringValue("name", "transponder")), + _num(node->getIntValue("number", 0)), + _mode_c_altitude(node->getStringValue("mode-c-altitude", + "/instrumentation/encoder/mode-c-alt-ft")) { - int i; - for ( i = 0; i < node->nChildren(); ++i ) { - SGPropertyNode *child = node->getChild(i); - string cname = child->getName(); - string cval = child->getStringValue(); - if ( cname == "name" ) { - name = cval; - } else if ( cname == "number" ) { - num = child->getIntValue(); - } else if ( cname == "encoder" ) { - encoder = cval; - } else { - SG_LOG( SG_INSTR, SG_WARN, - "Error in transponder config logic" ); - if ( name.length() ) { - SG_LOG( SG_INSTR, SG_WARN, "Section = " << name ); - } - } - } } @@ -60,12 +42,11 @@ Transponder::~Transponder() void Transponder::init() { string branch; - branch = "/instrumentation/" + name; - encoder += "/mode-c-alt-ft"; + branch = "/instrumentation/" + _name; - SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); // Inputs - pressureAltitudeNode = fgGetNode(encoder.c_str(), true); + pressureAltitudeNode = fgGetNode(_mode_c_altitude.c_str(), true); busPowerNode = fgGetNode("/systems/electrical/outputs/transponder", true); serviceableNode = node->getChild("serviceable", 0, true); // Outputs diff --git a/src/Instrumentation/transponder.hxx b/src/Instrumentation/transponder.hxx index 765edb431..f0a58efd2 100644 --- a/src/Instrumentation/transponder.hxx +++ b/src/Instrumentation/transponder.hxx @@ -50,9 +50,9 @@ private: SGPropertyNode_ptr flightLevelNode; // Internal - string name; - int num; - string encoder; + string _name; + int _num; + string _mode_c_altitude; }; #endif // TRANSPONDER_HXX diff --git a/src/Instrumentation/turn_indicator.cxx b/src/Instrumentation/turn_indicator.cxx index 124186c1f..c8d295fee 100644 --- a/src/Instrumentation/turn_indicator.cxx +++ b/src/Instrumentation/turn_indicator.cxx @@ -20,29 +20,8 @@ TurnIndicator::TurnIndicator ( SGPropertyNode *node) : _last_rate(0), - name("turn-indicator"), - num(0) -{ - int i; - for ( i = 0; i < node->nChildren(); ++i ) { - SGPropertyNode *child = node->getChild(i); - string cname = child->getName(); - string cval = child->getStringValue(); - if ( cname == "name" ) { - name = cval; - } else if ( cname == "number" ) { - num = child->getIntValue(); - } else { - SG_LOG( SG_INSTR, SG_WARN, "Error in turn-indicator config logic" ); - if ( name.length() ) { - SG_LOG( SG_INSTR, SG_WARN, "Section = " << name ); - } - } - } -} - -TurnIndicator::TurnIndicator () : - _last_rate(0) + _name(node->getStringValue("name", "turn-indicator")), + _num(node->getIntValue("number", 0)) { } @@ -54,9 +33,9 @@ void TurnIndicator::init () { string branch; - branch = "/instrumentation/" + name; + branch = "/instrumentation/" + _name; - SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); _roll_rate_node = fgGetNode("/orientation/roll-rate-degps", true); _yaw_rate_node = fgGetNode("/orientation/yaw-rate-degps", true); _electric_current_node = @@ -69,8 +48,8 @@ TurnIndicator::bind () { std::ostringstream temp; string branch; - temp << num; - branch = "/instrumentation/" + name + "[" + temp.str() + "]"; + temp << _num; + branch = "/instrumentation/" + _name + "[" + temp.str() + "]"; fgTie((branch + "/serviceable").c_str(), &_gyro, &Gyro::is_serviceable, &Gyro::set_serviceable); @@ -83,8 +62,8 @@ TurnIndicator::unbind () { std::ostringstream temp; string branch; - temp << num; - branch = "/instrumentation/" + name + "[" + temp.str() + "]"; + temp << _num; + branch = "/instrumentation/" + _name + "[" + temp.str() + "]"; fgUntie((branch + "/serviceable").c_str()); fgUntie((branch + "/serviceable").c_str()); diff --git a/src/Instrumentation/turn_indicator.hxx b/src/Instrumentation/turn_indicator.hxx index d1b2a2917..b96873081 100644 --- a/src/Instrumentation/turn_indicator.hxx +++ b/src/Instrumentation/turn_indicator.hxx @@ -41,7 +41,6 @@ class TurnIndicator : public SGSubsystem public: TurnIndicator ( SGPropertyNode *node ); - TurnIndicator (); virtual ~TurnIndicator (); virtual void init (); @@ -54,8 +53,8 @@ private: Gyro _gyro; double _last_rate; - string name; - int num; + string _name; + int _num; SGPropertyNode_ptr _roll_rate_node; SGPropertyNode_ptr _yaw_rate_node; diff --git a/src/Instrumentation/vertical_speed_indicator.cxx b/src/Instrumentation/vertical_speed_indicator.cxx index 2188637e0..8a4318a9e 100644 --- a/src/Instrumentation/vertical_speed_indicator.cxx +++ b/src/Instrumentation/vertical_speed_indicator.cxx @@ -12,32 +12,9 @@ VerticalSpeedIndicator::VerticalSpeedIndicator ( SGPropertyNode *node ) : _internal_pressure_inhg(29.92), - name("vertical-speed-indicator"), - num(0), - static_port("/systems/static") -{ - int i; - for ( i = 0; i < node->nChildren(); ++i ) { - SGPropertyNode *child = node->getChild(i); - string cname = child->getName(); - string cval = child->getStringValue(); - if ( cname == "name" ) { - name = cval; - } else if ( cname == "number" ) { - num = child->getIntValue(); - } else if ( cname == "static-port" ) { - static_port = cval; - } else { - SG_LOG( SG_INSTR, SG_WARN, "Error in vertical-speed-indicator config logic" ); - if ( name.length() ) { - SG_LOG( SG_INSTR, SG_WARN, "Section = " << name ); - } - } - } -} - -VerticalSpeedIndicator::VerticalSpeedIndicator () - : _internal_pressure_inhg(29.92) + _name(node->getStringValue("name", "vertical-speed-indicator")), + _num(node->getIntValue("number", 0)), + _static_pressure(node->getStringValue("static-pressure", "/Systems/static/pressure-inhg")) { } @@ -49,12 +26,11 @@ void VerticalSpeedIndicator::init () { string branch; - branch = "/instrumentation/" + name; - static_port += "/pressure-inhg"; + branch = "/instrumentation/" + _name; - SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); _serviceable_node = node->getChild("serviceable", 0, true); - _pressure_node = fgGetNode(static_port.c_str(), true); + _pressure_node = fgGetNode(_static_pressure.c_str(), true); _speed_node = node->getChild("indicated-speed-fpm", 0, true); // Initialize at ambient pressure diff --git a/src/Instrumentation/vertical_speed_indicator.hxx b/src/Instrumentation/vertical_speed_indicator.hxx index 0c2a5a3a9..2b6a930d4 100644 --- a/src/Instrumentation/vertical_speed_indicator.hxx +++ b/src/Instrumentation/vertical_speed_indicator.hxx @@ -33,7 +33,6 @@ class VerticalSpeedIndicator : public SGSubsystem public: VerticalSpeedIndicator ( SGPropertyNode *node ); - VerticalSpeedIndicator (); virtual ~VerticalSpeedIndicator (); virtual void init (); @@ -43,9 +42,9 @@ private: double _internal_pressure_inhg; - string name; - int num; - string static_port; + string _name; + int _num; + string _static_pressure; SGPropertyNode_ptr _serviceable_node; SGPropertyNode_ptr _pressure_node; diff --git a/src/Instrumentation/wxradar.cxx b/src/Instrumentation/wxradar.cxx index 1a879ed5f..7319a5b41 100644 --- a/src/Instrumentation/wxradar.cxx +++ b/src/Instrumentation/wxradar.cxx @@ -41,33 +41,13 @@ static const char *odgauge_name = "Aircraft/Instruments/Textures/od_wxradar.rgb"; wxRadarBg::wxRadarBg ( SGPropertyNode *node) : - name("wxRadar"), - num(0), + _name(node->getStringValue("name", "wxRadar")), + _num(node->getIntValue("number", 0)), resultTexture( 0 ), wxEcho( 0 ), last_switchKnob( "off" ), sim_init_done ( false ), odg( 0 ) -{ - int i; - for ( i = 0; i < node->nChildren(); ++i ) { - SGPropertyNode *child = node->getChild(i); - string cname = child->getName(); - string cval = child->getStringValue(); - if ( cname == "name" ) { - name = cval; - } else if ( cname == "number" ) { - num = child->getIntValue(); - } else { - SG_LOG( SG_INSTR, SG_WARN, "Error in wxRadar config logic" ); - if ( name.length() ) { - SG_LOG( SG_INSTR, SG_WARN, "Section = " << name ); - } - } - } -} - -wxRadarBg::wxRadarBg () { } @@ -79,9 +59,9 @@ void wxRadarBg::init () { string branch; - branch = "/instrumentation/" + name; + branch = "/instrumentation/" + _name; - _Instrument = fgGetNode(branch.c_str(), num, true ); + _Instrument = fgGetNode(branch.c_str(), _num, true ); _serviceable_node = _Instrument->getChild("serviceable", 0, true); resultTexture = FGTextureManager::createTexture( odgauge_name ); SGPath tpath(globals->get_fg_root()); diff --git a/src/Instrumentation/wxradar.hxx b/src/Instrumentation/wxradar.hxx index acaa6680b..575519015 100644 --- a/src/Instrumentation/wxradar.hxx +++ b/src/Instrumentation/wxradar.hxx @@ -46,8 +46,8 @@ public: private: - string name; - int num; + string _name; + int _num; SGPropertyNode_ptr _serviceable_node; SGPropertyNode_ptr _Instrument; diff --git a/src/Systems/pitot.cxx b/src/Systems/pitot.cxx index 136533f1b..535caa09d 100644 --- a/src/Systems/pitot.cxx +++ b/src/Systems/pitot.cxx @@ -13,31 +13,9 @@ PitotSystem::PitotSystem ( SGPropertyNode *node ) : - num(0), - name("pitot") + _name(node->getStringValue("name", "pitot")), + _num(node->getIntValue("number", 0)) { - int i; - for ( i = 0; i < node->nChildren(); ++i ) { - SGPropertyNode *child = node->getChild(i); - string cname = child->getName(); - string cval = child->getStringValue(); - if ( cname == "name" ) { - name = cval; - } else if ( cname == "number" ) { - num = child->getIntValue(); - } else { - SG_LOG( SG_SYSTEMS, SG_WARN, "Error in systems config logic" ); - if ( name.length() ) { - SG_LOG( SG_SYSTEMS, SG_WARN, "Section = " << name ); - } - } - } -} - -PitotSystem::PitotSystem ( int i ) -{ - num = i; - name = "pitot"; } PitotSystem::~PitotSystem () @@ -48,9 +26,9 @@ void PitotSystem::init () { string branch; - branch = "/systems/" + name; + branch = "/systems/" + _name; - SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); _serviceable_node = node->getChild("serviceable", 0, true); _pressure_node = fgGetNode("/environment/pressure-inhg", true); _density_node = fgGetNode("/environment/density-slugft3", true); diff --git a/src/Systems/pitot.hxx b/src/Systems/pitot.hxx index b0c39b31c..3cf64b090 100644 --- a/src/Systems/pitot.hxx +++ b/src/Systems/pitot.hxx @@ -43,7 +43,6 @@ class PitotSystem : public SGSubsystem public: PitotSystem ( SGPropertyNode *node ); - PitotSystem ( int i ); virtual ~PitotSystem (); virtual void init (); @@ -53,8 +52,8 @@ public: private: - int num; - string name; + string _name; + int _num; SGPropertyNode_ptr _serviceable_node; SGPropertyNode_ptr _pressure_node; SGPropertyNode_ptr _density_node; diff --git a/src/Systems/static.cxx b/src/Systems/static.cxx index f6cfa47b4..b3c916d80 100644 --- a/src/Systems/static.cxx +++ b/src/Systems/static.cxx @@ -10,31 +10,9 @@ StaticSystem::StaticSystem ( SGPropertyNode *node ) : - name("static"), - num(0) + _name(node->getStringValue("name", "static")), + _num(node->getIntValue("number", 0)) { - int i; - for ( i = 0; i < node->nChildren(); ++i ) { - SGPropertyNode *child = node->getChild(i); - string cname = child->getName(); - string cval = child->getStringValue(); - if ( cname == "name" ) { - name = cval; - } else if ( cname == "number" ) { - num = child->getIntValue(); - } else { - SG_LOG( SG_SYSTEMS, SG_WARN, "Error in systems config logic" ); - if ( name.length() ) { - SG_LOG( SG_SYSTEMS, SG_WARN, "Section = " << name ); - } - } - } -} - -StaticSystem::StaticSystem ( int i ) -{ - name = "static"; - num = i; } StaticSystem::~StaticSystem () @@ -45,9 +23,9 @@ void StaticSystem::init () { string branch; - branch = "/systems/" + name; + branch = "/systems/" + _name; - SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); _serviceable_node = node->getChild("serviceable", 0, true); _pressure_in_node = fgGetNode("/environment/pressure-inhg", true); _pressure_out_node = node->getChild("pressure-inhg", 0, true); diff --git a/src/Systems/static.hxx b/src/Systems/static.hxx index fcacd925b..f777863bd 100644 --- a/src/Systems/static.hxx +++ b/src/Systems/static.hxx @@ -46,8 +46,8 @@ public: private: - string name; - int num; + string _name; + int _num; SGPropertyNode_ptr _serviceable_node; SGPropertyNode_ptr _pressure_in_node; SGPropertyNode_ptr _pressure_out_node; diff --git a/src/Systems/vacuum.cxx b/src/Systems/vacuum.cxx index 36bbf5962..cab464404 100644 --- a/src/Systems/vacuum.cxx +++ b/src/Systems/vacuum.cxx @@ -13,42 +13,27 @@ VacuumSystem::VacuumSystem ( SGPropertyNode *node ) : - name("vacuum"), - num(0), - scale(1.0) - + _name(node->getStringValue("name", "vacuum")), + _num(node->getIntValue("number", 0)), + _scale(node->getDoubleValue("scale", 1.0)) { - rpms.clear(); + _rpms.clear(); int i; for ( i = 0; i < node->nChildren(); ++i ) { SGPropertyNode *child = node->getChild(i); string cname = child->getName(); string cval = child->getStringValue(); - if ( cname == "name" ) { - name = cval; - } else if ( cname == "number" ) { - num = child->getIntValue(); - } else if ( cname == "rpm" ) { - rpms.push_back(cval); - } else if ( cname == "scale" ) { - scale = child->getDoubleValue(); + if ( cname == "rpm" ) { + _rpms.push_back(cval); } else { SG_LOG( SG_SYSTEMS, SG_WARN, "Error in vacuum config logic" ); - if ( name.length() ) { - SG_LOG( SG_SYSTEMS, SG_WARN, "Section = " << name ); + if ( _name.length() ) { + SG_LOG( SG_SYSTEMS, SG_WARN, "Section = " << _name ); } } } } -VacuumSystem::VacuumSystem( int i ) -{ - name = "vacuum"; - num = i; - rpms.clear(); - scale = 1.0; -} - VacuumSystem::~VacuumSystem () { } @@ -58,12 +43,12 @@ VacuumSystem::init() { unsigned int i; string branch; - branch = "/systems/" + name; + branch = "/systems/" + _name; - SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); _serviceable_node = node->getChild("serviceable", 0, true); - for ( i = 0; i < rpms.size(); i++ ) { - SGPropertyNode_ptr _rpm_node = fgGetNode(rpms[i].c_str(), true); + for ( i = 0; i < _rpms.size(); i++ ) { + SGPropertyNode_ptr _rpm_node = fgGetNode(_rpms[i].c_str(), true); _rpm_nodes.push_back( _rpm_node ); } _pressure_node = fgGetNode("/environment/pressure-inhg", true); @@ -94,7 +79,7 @@ VacuumSystem::update (double dt) // select the source with the max rpm double rpm = 0.0; for ( i = 0; i < _rpm_nodes.size(); i++ ) { - double tmp = _rpm_nodes[i]->getDoubleValue() * scale; + double tmp = _rpm_nodes[i]->getDoubleValue() * _scale; if ( tmp > rpm ) { rpm = tmp; } diff --git a/src/Systems/vacuum.hxx b/src/Systems/vacuum.hxx index d03cb758c..fd6913596 100644 --- a/src/Systems/vacuum.hxx +++ b/src/Systems/vacuum.hxx @@ -49,10 +49,10 @@ public: private: - string name; - int num; - string_list rpms; - double scale; + string _name; + int _num; + string_list _rpms; + double _scale; SGPropertyNode_ptr _serviceable_node; vector _rpm_nodes; SGPropertyNode_ptr _pressure_node; -- 2.39.5