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.
6 #include <simgear/math/interpolater.hxx>
8 #include "vertical_speed_indicator.hxx"
9 #include <Main/fg_props.hxx>
10 #include <Main/util.hxx>
13 VerticalSpeedIndicator::VerticalSpeedIndicator ( SGPropertyNode *node )
14 : _internal_pressure_inhg(29.92),
15 name("vertical-speed-indicator"),
17 static_port("/systems/static")
20 for ( i = 0; i < node->nChildren(); ++i ) {
21 SGPropertyNode *child = node->getChild(i);
22 string cname = child->getName();
23 string cval = child->getStringValue();
24 if ( cname == "name" ) {
26 } else if ( cname == "number" ) {
27 num = child->getIntValue();
28 } else if ( cname == "static-port" ) {
31 SG_LOG( SG_INSTR, SG_WARN, "Error in vertical-speed-indicator config logic" );
32 if ( name.length() ) {
33 SG_LOG( SG_INSTR, SG_WARN, "Section = " << name );
39 VerticalSpeedIndicator::VerticalSpeedIndicator ()
40 : _internal_pressure_inhg(29.92)
44 VerticalSpeedIndicator::~VerticalSpeedIndicator ()
49 VerticalSpeedIndicator::init ()
52 branch = "/instrumentation/" + name;
53 static_port += "/pressure-inhg";
55 SGPropertyNode *node = fgGetNode(branch.c_str(), num, true );
56 _serviceable_node = node->getChild("serviceable", 0, true);
57 _pressure_node = fgGetNode(static_port.c_str(), true);
58 _speed_node = node->getChild("indicated-speed-fpm", 0, true);
60 // Initialize at ambient pressure
61 _internal_pressure_inhg = _pressure_node->getDoubleValue();
65 VerticalSpeedIndicator::update (double dt)
67 // model taken from steam.cxx, with change
68 // from 10000 to 10500 for manual factor
69 if (_serviceable_node->getBoolValue()) {
70 double pressure = _pressure_node->getDoubleValue();
72 ->setDoubleValue((_internal_pressure_inhg - pressure) * 10500);
73 _internal_pressure_inhg =
74 fgGetLowPass(_internal_pressure_inhg,
75 _pressure_node->getDoubleValue(),
80 // end of vertical_speed_indicator.cxx