]> git.mxchange.org Git - flightgear.git/blobdiff - src/Systems/static.cxx
Sync. w. JSBSim CVS
[flightgear.git] / src / Systems / static.cxx
index f6cfa47b4be31831e46fd551bdc171a02baff1fe..d3cbbbf361d7090053355cdb91603f607179bd7d 100644 (file)
 
 StaticSystem::StaticSystem ( SGPropertyNode *node )
     :
-    name("static"),
-    num(0)
-{
-    int i;
-    for ( i = 0; i < node->nChildren(); ++i ) {
-        SGPropertyNode *child = node->getChild(i);
-        string cname = child->getName();
-        string cval = child->getStringValue();
-        if ( cname == "name" ) {
-            name = cval;
-        } else if ( cname == "number" ) {
-            num = child->getIntValue();
-        } else {
-            SG_LOG( SG_SYSTEMS, SG_WARN, "Error in systems config logic" );
-            if ( name.length() ) {
-                SG_LOG( SG_SYSTEMS, SG_WARN, "Section = " << name );
-            }
-        }
-    }
-}
+    _name(node->getStringValue("name", "static")),
+    _num(node->getIntValue("number", 0)),
+    _tau(node->getDoubleValue("tau", 1))
 
-StaticSystem::StaticSystem ( int i )
 {
-    name = "static";
-    num = i;
 }
 
 StaticSystem::~StaticSystem ()
@@ -45,9 +25,9 @@ void
 StaticSystem::init ()
 {
     string branch;
-    branch = "/systems/" + name;
+    branch = "/systems/" + _name;
 
-    SGPropertyNode *node = fgGetNode(branch.c_str(), num, true );
+    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 = node->getChild("pressure-inhg", 0, true);
@@ -67,11 +47,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));
+        _pressure_out_node->setDoubleValue(fgGetLowPass(current, target, trat));
     }
 }