X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FSystems%2Fvacuum.cxx;h=9303073b27089a6adb46b4562338e82ec16a94d2;hb=729e28754a5ff709d0a39d82d9734c8288ea0db1;hp=fcf80d5c31838a8b15e7d98a7186fcb453276b9c;hpb=0ab2a40c2a2c75d117744f63a1bd74ccc7ea3a4e;p=flightgear.git diff --git a/src/Systems/vacuum.cxx b/src/Systems/vacuum.cxx index fcf80d5c3..9303073b2 100644 --- a/src/Systems/vacuum.cxx +++ b/src/Systems/vacuum.cxx @@ -3,48 +3,27 @@ // // This file is in the Public Domain and comes with no warranty. +#ifdef HAVE_CONFIG_H +# include +#endif + #include "vacuum.hxx" #include
VacuumSystem::VacuumSystem ( SGPropertyNode *node ) : - name("vacuum"), - num(0), - rpm("/engines/engine[0]/rpm"), - scale(1.0) - + _name(node->getStringValue("name", "vacuum")), + _num(node->getIntValue("number", 0)), + _scale(node->getDoubleValue("scale", 1.0)) { - int i; - for ( i = 0; i < node->nChildren(); ++i ) { + for ( int 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 == "rpm" ) { - rpm = cval; - } else if ( cname == "scale" ) { - scale = child->getDoubleValue(); - } else { - SG_LOG( SG_SYSTEMS, SG_WARN, "Error in vacuum config logic" ); - if ( name.length() ) { - SG_LOG( SG_SYSTEMS, SG_WARN, "Section = " << name ); - } - } + if (!strcmp(child->getName(), "rpm")) + _rpms.push_back(child->getStringValue()); } } -VacuumSystem::VacuumSystem( int i ) -{ - name = "vacuum"; - num = i; - rpm = "/engines/engine[0]/rpm"; - scale = 1.0; -} - VacuumSystem::~VacuumSystem () { } @@ -52,16 +31,18 @@ VacuumSystem::~VacuumSystem () void VacuumSystem::init() { + unsigned int i; 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); - _rpm_node = fgGetNode(rpm.c_str(), true); + for ( i = 0; i < _rpms.size(); i++ ) { + SGPropertyNode_ptr _rpm_node = fgGetNode(_rpms[i].c_str(), true); + _rpm_nodes.push_back( _rpm_node ); + } _pressure_node = fgGetNode("/environment/pressure-inhg", true); _suction_node = node->getChild("suction-inhg", 0, true); - - _serviceable_node->setBoolValue(true); } void @@ -80,11 +61,19 @@ VacuumSystem::update (double dt) // Model taken from steam.cxx double suction; + unsigned int i; if (!_serviceable_node->getBoolValue()) { suction = 0.0; } else { - double rpm = _rpm_node->getDoubleValue() * scale; + // select the source with the max rpm + double rpm = 0.0; + for ( i = 0; i < _rpm_nodes.size(); i++ ) { + double tmp = _rpm_nodes[i]->getDoubleValue() * _scale; + if ( tmp > rpm ) { + rpm = tmp; + } + } double pressure = _pressure_node->getDoubleValue(); // This magic formula yields about 4 inhg at 700 rpm suction = pressure * rpm / (rpm + 4875.0);