X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInstrumentation%2Fvertical_speed_indicator.cxx;h=2188637e077ae76ab4c4eb81b3894038f2665c1a;hb=3f1af3334fe5368d9286d5971576c63093f56992;hp=d707b704442d0dc81d371b4cadfd84948ef682d5;hpb=f72891e113b79c96e23f46a8ae2a0ecdacc9155f;p=flightgear.git diff --git a/src/Instrumentation/vertical_speed_indicator.cxx b/src/Instrumentation/vertical_speed_indicator.cxx index d707b7044..2188637e0 100644 --- a/src/Instrumentation/vertical_speed_indicator.cxx +++ b/src/Instrumentation/vertical_speed_indicator.cxx @@ -10,6 +10,32 @@ #include
+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) { @@ -22,20 +48,23 @@ VerticalSpeedIndicator::~VerticalSpeedIndicator () void VerticalSpeedIndicator::init () { - _serviceable_node = - fgGetNode("/instrumentation/vertical-speed-indicator/serviceable", - true); - _pressure_node = - fgGetNode("/systems/static/pressure-inhg", true); - _speed_node = - fgGetNode("/instrumentation/vertical-speed-indicator/indicated-speed-fpm", - true); + string branch; + branch = "/instrumentation/" + name; + static_port += "/pressure-inhg"; + + SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); + _serviceable_node = node->getChild("serviceable", 0, true); + _pressure_node = fgGetNode(static_port.c_str(), true); + _speed_node = node->getChild("indicated-speed-fpm", 0, true); + + // Initialize at ambient pressure + _internal_pressure_inhg = _pressure_node->getDoubleValue(); } void VerticalSpeedIndicator::update (double dt) { - // model take from steam.cxx, with change + // model taken from steam.cxx, with change // from 10000 to 10500 for manual factor if (_serviceable_node->getBoolValue()) { double pressure = _pressure_node->getDoubleValue();