]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/vertical_speed_indicator.cxx
Initialize the internal pressure to ambient pressure.
[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 #include <simgear/math/interpolater.hxx>
7
8 #include "vertical_speed_indicator.hxx"
9 #include <Main/fg_props.hxx>
10 #include <Main/util.hxx>
11
12
13 VerticalSpeedIndicator::VerticalSpeedIndicator ()
14     : _internal_pressure_inhg(29.92)
15 {
16 }
17
18 VerticalSpeedIndicator::~VerticalSpeedIndicator ()
19 {
20 }
21
22 void
23 VerticalSpeedIndicator::init ()
24 {
25     _serviceable_node =
26         fgGetNode("/instrumentation/vertical-speed-indicator/serviceable",
27                   true);
28     _pressure_node =
29         fgGetNode("/systems/static/pressure-inhg", true);
30     _speed_node =
31         fgGetNode("/instrumentation/vertical-speed-indicator/indicated-speed-fpm",
32                   true);
33
34                                 // Initialize at ambient pressure
35     _internal_pressure_inhg = _pressure_node->getDoubleValue();
36 }
37
38 void
39 VerticalSpeedIndicator::update (double dt)
40 {
41                                 // model taken from steam.cxx, with change
42                                 // from 10000 to 10500 for manual factor
43     if (_serviceable_node->getBoolValue()) {
44         double pressure = _pressure_node->getDoubleValue();
45         _speed_node
46             ->setDoubleValue((_internal_pressure_inhg - pressure) * 10500);
47         _internal_pressure_inhg =
48             fgGetLowPass(_internal_pressure_inhg,
49                          _pressure_node->getDoubleValue(),
50                          dt/6.0);
51     }
52 }
53
54 // end of vertical_speed_indicator.cxx