// A higher number means more responsive.
#define RESPONSIVENESS 50.0
-
-AirspeedIndicator::AirspeedIndicator ()
+AirspeedIndicator::AirspeedIndicator ( SGPropertyNode *node )
+ :
+ _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"))
{
}
void
AirspeedIndicator::init ()
{
- _serviceable_node =
- fgGetNode("/instrumentation/airspeed-indicator/serviceable",
- true);
- _total_pressure_node =
- fgGetNode("/systems/pitot/total-pressure-inhg", true);
- _static_pressure_node =
- fgGetNode("/systems/static/pressure-inhg", true);
- _speed_node =
- fgGetNode("/instrumentation/airspeed-indicator/indicated-speed-kt",
- true);
+ string branch;
+ branch = "/instrumentation/" + _name;
+
+ SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true );
+ _serviceable_node = node->getChild("serviceable", 0, 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);
}
-#ifndef SEA_LEVEL_DENSITY_SLUGFG3
-# define SEA_LEVEL_DENSITY_SLUGFT3 0.002378
-#endif
-
#ifndef FPSTOKTS
# define FPSTOKTS 0.592484
#endif
AirspeedIndicator::update (double dt)
{
if (_serviceable_node->getBoolValue()) {
- double pt = _total_pressure_node->getDoubleValue();
- double p = _static_pressure_node->getDoubleValue();
- double q = ( pt - p ) * INHGTOPSF; // dynamic pressure
+ double pt = _total_pressure_node->getDoubleValue() * INHGTOPSF;
+ double p = _static_pressure_node->getDoubleValue() * INHGTOPSF;
+ double r = _density_node->getDoubleValue();
+ double q = ( pt - p ); // dynamic pressure
// Now, reverse the equation (normalize dynamic pressure to
// avoid "nan" results from sqrt)
if ( q < 0 ) { q = 0.0; }
- double v_fps = sqrt((2 * q) / SEA_LEVEL_DENSITY_SLUGFT3);
+ double v_fps = sqrt((2 * q) / r);
// Publish the indicated airspeed
double last_speed_kt = _speed_node->getDoubleValue();