1
0
Fork 0

Roy Vegard Ovesen:

- finish cleanup/optimization of instrumentation system (started by mfranz)
- improve configuration of special properties by
  addressing them directly
This commit is contained in:
mfranz 2006-12-06 22:11:43 +00:00
parent 880e4908ac
commit b9e4775a7a
36 changed files with 187 additions and 584 deletions

View file

@ -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);
}

View file

@ -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;

View file

@ -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);
}

View file

@ -23,13 +23,13 @@ class SGInterpTable;
*
* Input properties:
*
* /instrumentation/"name"/serviceable
* /instrumentation/"name"/setting-inhg
* "static_port"/pressure-inhg
* /instrumentation/<name>/serviceable
* /instrumentation/<name>/setting-inhg
* <static_pressure>
*
* Output properties:
*
* /instrumentation/"name"/indicated-altitude-ft
* /instrumentation/<name>/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;

View file

@ -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());

View file

@ -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;

View file

@ -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();
}

View file

@ -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;
};

View file

@ -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

View file

@ -51,9 +51,9 @@ private:
SGPropertyNode_ptr modeCAltitudeNode;
// Internal
string name;
int num;
string staticPort;
string _name;
int _num;
string _static_pressure;
SGInterpTable* altitudeTable;
};

View file

@ -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);

View file

@ -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;
double _bias_length;
double _bias_angle;
double _azimuth_error;
double _range_error;
double _elapsed_time;
string name;
int num;
string _name;
int _num;
};

View file

@ -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());

View file

@ -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;

View file

@ -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);
}

View file

@ -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;

View file

@ -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());

View file

@ -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;

View file

@ -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() + "]";
}

View file

@ -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;

View file

@ -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);

View file

@ -14,8 +14,6 @@
#include <simgear/props/props.hxx>
#include <simgear/structure/subsystem_mgr.hxx>
#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;

View file

@ -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

View file

@ -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

View file

@ -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());

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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());

View file

@ -46,8 +46,8 @@ public:
private:
string name;
int num;
string _name;
int _num;
SGPropertyNode_ptr _serviceable_node;
SGPropertyNode_ptr _Instrument;

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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;
}

View file

@ -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<SGPropertyNode_ptr> _rpm_nodes;
SGPropertyNode_ptr _pressure_node;