]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/vertical_speed_indicator.cxx
#346 related: missing status message for property server
[flightgear.git] / src / Instrumentation / vertical_speed_indicator.cxx
index 295346691025d904303404e945837731db7faabd..e5c9f743274e9671c0674ab52ce3a3d3de218930 100644 (file)
 #include <Main/util.hxx>
 
 
-VerticalSpeedIndicator::VerticalSpeedIndicator ()
-    : _internal_pressure_inhg(29.92)
+VerticalSpeedIndicator::VerticalSpeedIndicator ( SGPropertyNode *node )
+    : _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"))
 {
 }
 
@@ -22,30 +25,22 @@ VerticalSpeedIndicator::~VerticalSpeedIndicator ()
 void
 VerticalSpeedIndicator::init ()
 {
-    _serviceable_node =
-        fgGetNode("/instrumentation/vertical-speed-indicator/serviceable",
-                  true);
-    _pressure_node =
-        fgGetNode("/systems/static/pressure-inhg", true);
-    _speed_node =
-        fgGetNode("/instrumentation/vertical-speed-indicator/indicated-speed-fpm",
-                  true);
-}
+    string branch;
+    branch = "/instrumentation/" + _name;
 
-void
-VerticalSpeedIndicator::bind ()
-{
-}
+    SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true );
+    _serviceable_node = node->getChild("serviceable", 0, true);
+    _pressure_node = fgGetNode(_static_pressure.c_str(), true);
+    _speed_node = node->getChild("indicated-speed-fpm", 0, true);
 
-void
-VerticalSpeedIndicator::unbind ()
-{
+                                // Initialize at ambient pressure
+    _internal_pressure_inhg = _pressure_node->getDoubleValue();
 }
 
 void
 VerticalSpeedIndicator::update (double dt)
 {
-                                // model take from steam.cxx, with change
+                                // model taken from steam.cxx, with change
                                 // from 10000 to 10500 for manual factor
     if (_serviceable_node->getBoolValue()) {
         double pressure = _pressure_node->getDoubleValue();