]> git.mxchange.org Git - flightgear.git/blob - src/Systems/static.cxx
Migrate FlightGear code to use "#include SG_GL*" defined in
[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("static"),
14     num(0)
15 {
16     int i;
17     for ( i = 0; i < node->nChildren(); ++i ) {
18         SGPropertyNode *child = node->getChild(i);
19         string cname = child->getName();
20         string cval = child->getStringValue();
21         if ( cname == "name" ) {
22             name = cval;
23         } else if ( cname == "number" ) {
24             num = child->getIntValue();
25         } else {
26             SG_LOG( SG_SYSTEMS, SG_WARN, "Error in systems config logic" );
27             if ( name.length() ) {
28                 SG_LOG( SG_SYSTEMS, SG_WARN, "Section = " << name );
29             }
30         }
31     }
32 }
33
34 StaticSystem::StaticSystem ( int i )
35 {
36     name = "static";
37     num = i;
38 }
39
40 StaticSystem::~StaticSystem ()
41 {
42 }
43
44 void
45 StaticSystem::init ()
46 {
47     string branch;
48     branch = "/systems/" + name;
49
50     SGPropertyNode *node = fgGetNode(branch.c_str(), num, true );
51     _serviceable_node = node->getChild("serviceable", 0, true);
52     _pressure_in_node = fgGetNode("/environment/pressure-inhg", true);
53     _pressure_out_node = node->getChild("pressure-inhg", 0, true);
54 }
55
56 void
57 StaticSystem::bind ()
58 {
59 }
60
61 void
62 StaticSystem::unbind ()
63 {
64 }
65
66 void
67 StaticSystem::update (double dt)
68 {
69     if (_serviceable_node->getBoolValue()) {
70         
71         double target = _pressure_in_node->getDoubleValue();
72         double current = _pressure_out_node->getDoubleValue();
73         // double delta = target - current;
74         _pressure_out_node->setDoubleValue(fgGetLowPass(current, target, dt));
75     }
76 }
77
78 // end of static.cxx