]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/vertical_speed_indicator.cxx
Make traffic take-off roll look a little better.
[flightgear.git] / src / Instrumentation / vertical_speed_indicator.cxx
1 // vertical_speed_indicator.cxx - a regular VSI.
2 // Written by David Megginson, started 2002.
3 //
4 // This file is in the Public Domain and comes with no warranty.
5
6 #ifdef HAVE_CONFIG_H
7 #  include "config.h"
8 #endif
9
10 #include <simgear/math/interpolater.hxx>
11
12 #include "vertical_speed_indicator.hxx"
13 #include <Main/fg_props.hxx>
14 #include <Main/util.hxx>
15
16 using std::string;
17
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"))
23 {
24 }
25
26 VerticalSpeedIndicator::~VerticalSpeedIndicator ()
27 {
28 }
29
30 void
31 VerticalSpeedIndicator::init ()
32 {
33     string branch;
34     branch = "/instrumentation/" + _name;
35
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);
41
42     reinit();
43 }
44
45 void
46 VerticalSpeedIndicator::reinit ()
47 {
48     // Initialize at ambient pressure
49     _internal_pressure_inhg = _pressure_node->getDoubleValue();
50 }
51
52 void
53 VerticalSpeedIndicator::update (double dt)
54 {
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();
60         if( speed_up > 1 )
61             dt *= speed_up;
62         _speed_node
63             ->setDoubleValue((_internal_pressure_inhg - pressure) * 10500);
64         _internal_pressure_inhg =
65             fgGetLowPass(_internal_pressure_inhg,
66                          _pressure_node->getDoubleValue(),
67                          dt/6.0);
68     }
69 }
70
71 // end of vertical_speed_indicator.cxx