X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInstrumentation%2Fvertical_speed_indicator.cxx;h=f5991265107fded22a674b2a4bf5e6dc06ea4621;hb=fe0a703a192a37b96aa4f6048c8e542c24671705;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..f59912651 100644 --- a/src/Instrumentation/vertical_speed_indicator.cxx +++ b/src/Instrumentation/vertical_speed_indicator.cxx @@ -3,15 +3,23 @@ // // This file is in the Public Domain and comes with no warranty. +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include #include "vertical_speed_indicator.hxx" #include
#include
+using std::string; -VerticalSpeedIndicator::VerticalSpeedIndicator () - : _internal_pressure_inhg(29.92) +VerticalSpeedIndicator::VerticalSpeedIndicator ( SGPropertyNode *node ) + : _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")) { } @@ -22,23 +30,29 @@ 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; + + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); + _serviceable_node = node->getChild("serviceable", 0, true); + _pressure_node = fgGetNode(_static_pressure.c_str(), true); + _speed_node = node->getChild("indicated-speed-fpm", 0, true); + _speed_up_node = fgGetNode("/sim/speed-up", 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(); + double speed_up = _speed_up_node->getDoubleValue(); + if( speed_up > 1 ) + dt *= speed_up; _speed_node ->setDoubleValue((_internal_pressure_inhg - pressure) * 10500); _internal_pressure_inhg =