]> git.mxchange.org Git - flightgear.git/blob - src/Systems/pitot.cxx
Moved some of the low level scene graph construction code over to simgear.
[flightgear.git] / src / Systems / pitot.cxx
1 // pitot.cxx - the pitot air system.
2 // Written by David Megginson, started 2002.
3 //
4 // This file is in the Public Domain and comes with no warranty.
5
6 #include "pitot.hxx"
7 #include <Main/fg_props.hxx>
8 #include <Main/util.hxx>
9
10
11 PitotSystem::PitotSystem ()
12 {
13 }
14
15 PitotSystem::~PitotSystem ()
16 {
17 }
18
19 void
20 PitotSystem::init ()
21 {
22     _serviceable_node = fgGetNode("/systems/pitot[0]/serviceable", true);
23     _pressure_node = fgGetNode("/environment/pressure-inhg", true);
24     _density_node = fgGetNode("/environment/density-slugft3", true);
25     _velocity_node = fgGetNode("/velocities/airspeed-kt", true);
26     _total_pressure_node =
27         fgGetNode("/systems/pitot[0]/total-pressure-inhg", true);
28 }
29
30 void
31 PitotSystem::bind ()
32 {
33 }
34
35 void
36 PitotSystem::unbind ()
37 {
38 }
39
40 #ifndef INHGTOPSF
41 # define INHGTOPSF (2116.217/29.9212)
42 #endif
43
44 #ifndef PSFTOINHG
45 # define PSFTOINHG (1/INHGTOPSF)
46 #endif
47
48 #ifndef KTTOFPS
49 # define KTTOFPS 1.68781
50 #endif
51
52
53 void
54 PitotSystem::update (double dt)
55 {
56     if (_serviceable_node->getBoolValue()) {
57                                 // The pitot tube sees the forward
58                                 // velocity in the body axis.
59         double p = _pressure_node->getDoubleValue() * INHGTOPSF;
60         double r = _density_node->getDoubleValue();
61         double v = _velocity_node->getDoubleValue() * KTTOFPS;
62         double q = 0.5 * r * v * v; // dynamic
63         _total_pressure_node->setDoubleValue((p + q) * PSFTOINHG);
64     }
65 }
66
67 // end of pitot.cxx