]> git.mxchange.org Git - flightgear.git/blob - src/Systems/static.cxx
Canvas: Add new element type map for geo mapping.
[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
42 void
43 StaticSystem::bind ()
44 {
45 }
46
47 void
48 StaticSystem::unbind ()
49 {
50 }
51
52 void
53 StaticSystem::update (double dt)
54 {
55     if (_serviceable_node->getBoolValue()) {
56         double trat = _tau ? dt/_tau : 100;
57         double target = _pressure_in_node->getDoubleValue();
58         double current = _pressure_out_node->getDoubleValue();
59         // double delta = target - current;
60         _pressure_out_node->setDoubleValue(fgGetLowPass(current, target, trat));
61     }
62 }
63
64 // end of static.cxx