]> git.mxchange.org Git - flightgear.git/blobdiff - src/Systems/static.cxx
Fix a couple of 64-bit warnings identified by GCC.
[flightgear.git] / src / Systems / static.cxx
index 866845befdb8b0d19b0431c1fc0385c143859b80..f58d1ce3cd457a675caa914515a2eaef4bf0a4b0 100644 (file)
@@ -3,12 +3,24 @@
 //
 // This file is in the Public Domain and comes with no warranty.
 
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
 #include "static.hxx"
+
+#include <string>
+
 #include <Main/fg_props.hxx>
 #include <Main/util.hxx>
 
 
-StaticSystem::StaticSystem ()
+StaticSystem::StaticSystem ( SGPropertyNode *node )
+    :
+    _name(node->getStringValue("name", "static")),
+    _num(node->getIntValue("number", 0)),
+    _tau(node->getDoubleValue("tau", 1))
+
 {
 }
 
@@ -19,9 +31,21 @@ StaticSystem::~StaticSystem ()
 void
 StaticSystem::init ()
 {
-    _serviceable_node = fgGetNode("/systems/static[0]/serviceable", true);
+    std::string branch = "/systems/" + _name;
+
+    SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true );
+    _serviceable_node = node->getChild("serviceable", 0, true);
     _pressure_in_node = fgGetNode("/environment/pressure-inhg", true);
-    _pressure_out_node = fgGetNode("/systems/static[0]/pressure-inhg", true);
+    _pressure_out_node = node->getChild("pressure-inhg", 0, true);
+
+    reinit();
+}
+
+void
+StaticSystem::reinit ()
+{
+    // start with settled static pressure
+    _pressure_out_node->setDoubleValue(_pressure_in_node->getDoubleValue());
 }
 
 void
@@ -38,11 +62,10 @@ void
 StaticSystem::update (double dt)
 {
     if (_serviceable_node->getBoolValue()) {
-        
+        double trat = _tau ? dt/_tau : 100;
         double target = _pressure_in_node->getDoubleValue();
         double current = _pressure_out_node->getDoubleValue();
-        // double delta = target - current;
-        _pressure_out_node->setDoubleValue(fgGetLowPass(current, target, dt));
+        _pressure_out_node->setDoubleValue(fgGetLowPass(current, target, trat));
     }
 }