]> git.mxchange.org Git - flightgear.git/blob - src/Systems/static.cxx
Roy Vegard Ovesen:
[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     _serviceable_node->setBoolValue(true);
56 }
57
58 void
59 StaticSystem::bind ()
60 {
61 }
62
63 void
64 StaticSystem::unbind ()
65 {
66 }
67
68 void
69 StaticSystem::update (double dt)
70 {
71     if (_serviceable_node->getBoolValue()) {
72         
73         double target = _pressure_in_node->getDoubleValue();
74         double current = _pressure_out_node->getDoubleValue();
75         // double delta = target - current;
76         _pressure_out_node->setDoubleValue(fgGetLowPass(current, target, dt));
77     }
78 }
79
80 // end of static.cxx