]> git.mxchange.org Git - flightgear.git/blobdiff - src/Systems/static.cxx
Fix shared library build for metar executable
[flightgear.git] / src / Systems / static.cxx
index 7f9a287be75b227b71835187096dbfccdf634fb4..e8447121c14caf51946e97acbb96fefe7a60d4b6 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,12 @@ 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);
 }
 
 void
@@ -38,11 +53,11 @@ 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));
+        // double delta = target - current;
+        _pressure_out_node->setDoubleValue(fgGetLowPass(current, target, trat));
     }
 }