]> git.mxchange.org Git - flightgear.git/blob - src/Systems/static.cxx
Fix a couple of 64-bit warnings identified by GCC.
[flightgear.git] / src / Systems / static.cxx
1 // static.cxx - the static 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 #ifdef HAVE_CONFIG_H
7 #  include "config.h"
8 #endif
9
10 #include "static.hxx"
11
12 #include <string>
13
14 #include <Main/fg_props.hxx>
15 #include <Main/util.hxx>
16
17
18 StaticSystem::StaticSystem ( SGPropertyNode *node )
19     :
20     _name(node->getStringValue("name", "static")),
21     _num(node->getIntValue("number", 0)),
22     _tau(node->getDoubleValue("tau", 1))
23
24 {
25 }
26
27 StaticSystem::~StaticSystem ()
28 {
29 }
30
31 void
32 StaticSystem::init ()
33 {
34     std::string branch = "/systems/" + _name;
35
36     SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true );
37     _serviceable_node = node->getChild("serviceable", 0, true);
38     _pressure_in_node = fgGetNode("/environment/pressure-inhg", true);
39     _pressure_out_node = node->getChild("pressure-inhg", 0, true);
40
41     reinit();
42 }
43
44 void
45 StaticSystem::reinit ()
46 {
47     // start with settled static pressure
48     _pressure_out_node->setDoubleValue(_pressure_in_node->getDoubleValue());
49 }
50
51 void
52 StaticSystem::bind ()
53 {
54 }
55
56 void
57 StaticSystem::unbind ()
58 {
59 }
60
61 void
62 StaticSystem::update (double dt)
63 {
64     if (_serviceable_node->getBoolValue()) {
65         double trat = _tau ? dt/_tau : 100;
66         double target = _pressure_in_node->getDoubleValue();
67         double current = _pressure_out_node->getDoubleValue();
68         _pressure_out_node->setDoubleValue(fgGetLowPass(current, target, trat));
69     }
70 }
71
72 // end of static.cxx