X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInstrumentation%2Finst_vertical_speed_indicator.cxx;h=0237a6ded883c7a98a68a1e5fba518c0aee8a2fe;hb=a6db6d89ff41a619569e6433409e8bf62ff98499;hp=134e853ab5ee170ccefa32c56a8e6aee34a741d7;hpb=c9813d1b5d79b4aad13c263690a0223086af25ac;p=flightgear.git diff --git a/src/Instrumentation/inst_vertical_speed_indicator.cxx b/src/Instrumentation/inst_vertical_speed_indicator.cxx index 134e853ab..0237a6ded 100644 --- a/src/Instrumentation/inst_vertical_speed_indicator.cxx +++ b/src/Instrumentation/inst_vertical_speed_indicator.cxx @@ -20,6 +20,7 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // +#include #include #include "inst_vertical_speed_indicator.hxx" @@ -131,10 +132,12 @@ static double altitude_data[][2] = { InstVerticalSpeedIndicator::InstVerticalSpeedIndicator ( SGPropertyNode *node ) : + _name(node->getStringValue("name", "inst-vertical-speed-indicator")), + _num(node->getIntValue("number", 0)), _internal_pressure_inhg( SEA_LEVEL_INHG ), - _internal_sea_inhg( SEA_LEVEL_INHG ), - _speed_ft_per_s( 0 ), - _pressure_table(new SGInterpTable), + _internal_sea_inhg( SEA_LEVEL_INHG ), + _speed_ft_per_s( 0 ), + _pressure_table(new SGInterpTable), _altitude_table(new SGInterpTable) { int i; @@ -143,22 +146,6 @@ InstVerticalSpeedIndicator::InstVerticalSpeedIndicator ( SGPropertyNode *node ) 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 { - SG_LOG( SG_INSTR, SG_WARN, "Error in inst-vertical-speed-indicator config logic" ); - if ( name.length() ) { - SG_LOG( SG_INSTR, SG_WARN, "Section = " << name ); - } - } - } } @@ -171,8 +158,10 @@ InstVerticalSpeedIndicator::~InstVerticalSpeedIndicator () void InstVerticalSpeedIndicator::init () { + SGPropertyNode *node = fgGetNode("/instrumentation", true)->getChild(_name, _num, true); + _serviceable_node = - fgGetNode("/instrumentation/inst-vertical-speed-indicator/serviceable", true); + node->getNode("serviceable", true); _freeze_node = fgGetNode("/sim/freeze/master", true); @@ -189,11 +178,9 @@ void InstVerticalSpeedIndicator::init () _speed_up_node = fgGetNode("/sim/speed-up", true); _speed_node = - fgGetNode("/instrumentation/inst-vertical-speed-indicator/indicated-speed-fps", - true); + node->getNode("indicated-speed-fps", true); _speed_min_node = - fgGetNode("/instrumentation/inst-vertical-speed-indicator/indicated-speed-fpm", - true); + node->getNode("indicated-speed-fpm", true); // Initialize at ambient pressure _internal_pressure_inhg = _pressure_node->getDoubleValue(); @@ -205,7 +192,7 @@ void InstVerticalSpeedIndicator::update (double dt) if (_serviceable_node->getBoolValue()) { // avoids hang, when freeze - if( !_freeze_node->getBoolValue() ) + if( !_freeze_node->getBoolValue() && std::numeric_limits::min() < fabs(dt)) { double pressure_inhg = _pressure_node->getDoubleValue(); double sea_inhg = _sea_node->getDoubleValue();