1 // vertical_speed_indicator.cxx - a regular VSI.
2 // Written by David Megginson, started 2002.
4 // This file is in the Public Domain and comes with no warranty.
10 #include <simgear/math/interpolater.hxx>
12 #include "vertical_speed_indicator.hxx"
13 #include <Main/fg_props.hxx>
14 #include <Main/util.hxx>
18 VerticalSpeedIndicator::VerticalSpeedIndicator ( SGPropertyNode *node )
19 : _internal_pressure_inhg(29.92),
20 _name(node->getStringValue("name", "vertical-speed-indicator")),
21 _num(node->getIntValue("number", 0)),
22 _static_pressure(node->getStringValue("static-pressure", "/systems/static/pressure-inhg"))
26 VerticalSpeedIndicator::~VerticalSpeedIndicator ()
31 VerticalSpeedIndicator::init ()
34 branch = "/instrumentation/" + _name;
36 SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true );
37 _serviceable_node = node->getChild("serviceable", 0, true);
38 _pressure_node = fgGetNode(_static_pressure.c_str(), true);
39 _speed_node = node->getChild("indicated-speed-fpm", 0, true);
40 _speed_up_node = fgGetNode("/sim/speed-up", true);
46 VerticalSpeedIndicator::reinit ()
48 // Initialize at ambient pressure
49 _internal_pressure_inhg = _pressure_node->getDoubleValue();
53 VerticalSpeedIndicator::update (double dt)
55 // model taken from steam.cxx, with change
56 // from 10000 to 10500 for manual factor
57 if (_serviceable_node->getBoolValue()) {
58 double pressure = _pressure_node->getDoubleValue();
59 double speed_up = _speed_up_node->getDoubleValue();
63 ->setDoubleValue((_internal_pressure_inhg - pressure) * 10500);
64 _internal_pressure_inhg =
65 fgGetLowPass(_internal_pressure_inhg,
66 _pressure_node->getDoubleValue(),
71 // end of vertical_speed_indicator.cxx