]> git.mxchange.org Git - flightgear.git/blob - src/Systems/static.cxx
Merge branch 'next' into comm-subsystem
[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 #include "static.hxx"
7
8 #include <string>
9
10 #include <Main/fg_props.hxx>
11 #include <Main/util.hxx>
12
13
14 StaticSystem::StaticSystem ( SGPropertyNode *node )
15     :
16     _name(node->getStringValue("name", "static")),
17     _num(node->getIntValue("number", 0)),
18     _tau(node->getDoubleValue("tau", 1))
19
20 {
21 }
22
23 StaticSystem::~StaticSystem ()
24 {
25 }
26
27 void
28 StaticSystem::init ()
29 {
30     std::string branch = "/systems/" + _name;
31
32     SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true );
33     _serviceable_node = node->getChild("serviceable", 0, true);
34     _pressure_in_node = fgGetNode("/environment/pressure-inhg", true);
35     _pressure_out_node = node->getChild("pressure-inhg", 0, true);
36 }
37
38 void
39 StaticSystem::bind ()
40 {
41 }
42
43 void
44 StaticSystem::unbind ()
45 {
46 }
47
48 void
49 StaticSystem::update (double dt)
50 {
51     if (_serviceable_node->getBoolValue()) {
52         double trat = _tau ? dt/_tau : 100;
53         double target = _pressure_in_node->getDoubleValue();
54         double current = _pressure_out_node->getDoubleValue();
55         // double delta = target - current;
56         _pressure_out_node->setDoubleValue(fgGetLowPass(current, target, trat));
57     }
58 }
59
60 // end of static.cxx