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