From 330024e0b7d0bdf67134a2af4b471ef644062bfe Mon Sep 17 00:00:00 2001 From: curt Date: Sat, 15 Oct 2005 20:03:17 +0000 Subject: [PATCH] Allow a single vacuum system to be driven by multiple pumps. This allows modeling of a simple single vacuum system with a pump source on each engine in a multiengine aircraft. The highest rpm engine takes priority for driving the vacuum system. --- src/Systems/vacuum.cxx | 22 +++++++++++++++++----- src/Systems/vacuum.hxx | 11 +++++++---- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/Systems/vacuum.cxx b/src/Systems/vacuum.cxx index 256e6efaf..3e75aa323 100644 --- a/src/Systems/vacuum.cxx +++ b/src/Systems/vacuum.cxx @@ -11,10 +11,10 @@ VacuumSystem::VacuumSystem ( SGPropertyNode *node ) : name("vacuum"), num(0), - rpm("/engines/engine[0]/rpm"), scale(1.0) { + rpms.clear(); int i; for ( i = 0; i < node->nChildren(); ++i ) { SGPropertyNode *child = node->getChild(i); @@ -25,7 +25,7 @@ VacuumSystem::VacuumSystem ( SGPropertyNode *node ) } else if ( cname == "number" ) { num = child->getIntValue(); } else if ( cname == "rpm" ) { - rpm = cval; + rpms.push_back(cval); } else if ( cname == "scale" ) { scale = child->getDoubleValue(); } else { @@ -41,7 +41,7 @@ VacuumSystem::VacuumSystem( int i ) { name = "vacuum"; num = i; - rpm = "/engines/engine[0]/rpm"; + rpms.clear(); scale = 1.0; } @@ -52,12 +52,16 @@ VacuumSystem::~VacuumSystem () void VacuumSystem::init() { + unsigned int i; string branch; branch = "/systems/" + name; 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); } @@ -78,11 +82,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); diff --git a/src/Systems/vacuum.hxx b/src/Systems/vacuum.hxx index d3034e16f..d03cb758c 100644 --- a/src/Systems/vacuum.hxx +++ b/src/Systems/vacuum.hxx @@ -11,6 +11,7 @@ # error This library requires C++ #endif +#include #include #include @@ -18,11 +19,13 @@ /** * Model a vacuum-pump system. * - * This first, simple draft is hard-wired to engine #1. + * Multiple pumps (i.e. for a multiengine aircraft) can be specified. * * Input properties: * - * "rpm" + * "rpm1" + * "rpm2" + * "..." * /environment/pressure-inhg * /systems/"name"/serviceable * @@ -48,10 +51,10 @@ private: string name; int num; - string rpm; + string_list rpms; double scale; SGPropertyNode_ptr _serviceable_node; - SGPropertyNode_ptr _rpm_node; + vector _rpm_nodes; SGPropertyNode_ptr _pressure_node; SGPropertyNode_ptr _suction_node;