]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/airspeed_indicator.cxx
James Turner:
[flightgear.git] / src / Instrumentation / airspeed_indicator.cxx
index db34f3fce6f70739b3ab29cd504f0307a6167649..0196ddbaef9bd20b3d420f1c0f78ae0f868b9af0 100644 (file)
 
 AirspeedIndicator::AirspeedIndicator ( SGPropertyNode *node )
     :
-    name("airspeed-indicator"),
-    num(0),
-    pitot_port("/systems/pitot"),
-    static_port("/systems/static")
+    _name(node->getStringValue("name", "airspeed-indicator")),
+    _num(node->getIntValue("number", 0)),
+    _total_pressure(node->getStringValue("total-pressure", "/systems/pitot/total-pressure-inhg")),
+    _static_pressure(node->getStringValue("static-pressure", "/systems/static/pressure-inhg"))
 {
-    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 == "pitot-port" ) {
-            pitot_port = cval;
-        } else if ( cname == "static-port" ) {
-            static_port = cval;
-        } else {
-            SG_LOG( SG_INSTR, SG_WARN, "Error in aispeed-indicator config logic" );
-            if ( name.length() ) {
-                SG_LOG( SG_INSTR, SG_WARN, "Section = " << name );
-            }
-        }
-    }
-}
-
-
-AirspeedIndicator::AirspeedIndicator ( int i )
-    :
-    name("airspeed-indicator"),
-    num(0),
-    pitot_port("/systems/pitot"),
-    static_port("/systems/static")
-{
-    num = i;
 }
 
 AirspeedIndicator::~AirspeedIndicator ()
@@ -63,14 +32,12 @@ void
 AirspeedIndicator::init ()
 {
     string branch;
-    branch = "/instrumentation/" + name;
-    pitot_port += "/total-pressure-inhg";
-    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);
-    _total_pressure_node = fgGetNode(pitot_port.c_str(), true);
-    _static_pressure_node = fgGetNode(static_port.c_str(), true);
+    _total_pressure_node = fgGetNode(_total_pressure.c_str(), true);
+    _static_pressure_node = fgGetNode(_static_pressure.c_str(), true);
     _density_node = fgGetNode("/environment/density-slugft3", true);
     _speed_node = node->getChild("indicated-speed-kt", 0, true);
 }