]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/vertical_speed_indicator.cxx
Merge branch 'next' into durk-atc
[flightgear.git] / src / Instrumentation / vertical_speed_indicator.cxx
index fb2924600f738f27f832dacf9491252aea023a11..e062db010087e8f3a646a5282c750a99d0999967 100644 (file)
 
 VerticalSpeedIndicator::VerticalSpeedIndicator ( SGPropertyNode *node )
     : _internal_pressure_inhg(29.92),
-      name("vertical-speed-indicator"),
-      num(0),
-      static_port("/systems/static")
-{
-    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 if ( cname == "static-port" ) {
-            static_port = cval;
-        } else {
-            SG_LOG( SG_INSTR, SG_WARN, "Error in vertical-speed-indicator config logic" );
-            if ( name.length() ) {
-                SG_LOG( SG_INSTR, SG_WARN, "Section = " << name );
-            }
-        }
-    }
-}
-
-VerticalSpeedIndicator::VerticalSpeedIndicator ()
-    : _internal_pressure_inhg(29.92)
+      _name(node->getStringValue("name", "vertical-speed-indicator")),
+      _num(node->getIntValue("number", 0)),
+      _static_pressure(node->getStringValue("static-pressure", "/systems/static/pressure-inhg"))
 {
 }
 
@@ -49,15 +26,14 @@ void
 VerticalSpeedIndicator::init ()
 {
     string branch;
-    branch = "/instrumentation/" + name;
-    static_port += "/pressure-inhg";
+    branch = "/instrumentation/" + _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_node = fgGetNode(static_port.c_str(), true);
+    _pressure_node = fgGetNode(_static_pressure.c_str(), true);
     _speed_node = node->getChild("indicated-speed-fpm", 0, true);
+    _speed_up_node = fgGetNode("/sim/speed-up", true);
 
-    _serviceable_node->setBoolValue(true);
                                 // Initialize at ambient pressure
     _internal_pressure_inhg = _pressure_node->getDoubleValue();
 }
@@ -69,6 +45,9 @@ VerticalSpeedIndicator::update (double dt)
                                 // from 10000 to 10500 for manual factor
     if (_serviceable_node->getBoolValue()) {
         double pressure = _pressure_node->getDoubleValue();
+        double speed_up = _speed_up_node->getDoubleValue();
+        if( speed_up > 1 )
+            dt *= speed_up;
         _speed_node
             ->setDoubleValue((_internal_pressure_inhg - pressure) * 10500);
         _internal_pressure_inhg =