X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInstrumentation%2Faltimeter.cxx;h=ebd2f6d0de6fee2f28ac253f49db61322253c58e;hb=9bb55e78be6c6a9da4be26a3671e7d4bf6332d50;hp=86190d25379f252be182609fb929f906877ae050;hpb=e2ce033a8cef3f468dfde9ec27dbf4f8ab984db6;p=flightgear.git diff --git a/src/Instrumentation/altimeter.cxx b/src/Instrumentation/altimeter.cxx index 86190d253..ebd2f6d0d 100644 --- a/src/Instrumentation/altimeter.cxx +++ b/src/Instrumentation/altimeter.cxx @@ -46,40 +46,14 @@ static double altitude_data[][2] = { Altimeter::Altimeter ( SGPropertyNode *node ) - : _altitude_table(new SGInterpTable), - name("altimeter"), - num(0), - static_port("/systems/static") + : _name(node->getStringValue("name", "altimeter")), + _num(node->getIntValue("number", 0)), + _static_pressure(node->getStringValue("static-pressure", "/systems/static/pressure-inhg")), + _altitude_table(new SGInterpTable) { int i; for (i = 0; altitude_data[i][0] != -1; i++) _altitude_table->addEntry(altitude_data[i][0], altitude_data[i][1]); - - 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_AUTOPILOT, SG_WARN, "Error in altimeter config logic" ); - if ( name.length() ) { - SG_LOG( SG_AUTOPILOT, SG_WARN, "Section = " << name ); - } - } - } -} - -Altimeter::Altimeter () - : _altitude_table(new SGInterpTable) -{ - - for (int i = 0; altitude_data[i][0] != -1; i++) - _altitude_table->addEntry(altitude_data[i][0], altitude_data[i][1]); } Altimeter::~Altimeter () @@ -91,18 +65,14 @@ void Altimeter::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); _setting_node = node->getChild("setting-inhg", 0, true); - _pressure_node = fgGetNode(static_port.c_str(), true); + _pressure_node = fgGetNode(_static_pressure.c_str(), true); _altitude_node = node->getChild("indicated-altitude-ft", 0, true); - - _serviceable_node->setBoolValue(true); - _setting_node->setDoubleValue(29.92); } void