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.
This commit is contained in:
parent
5c0dbf7b65
commit
330024e0b7
2 changed files with 24 additions and 9 deletions
|
@ -11,10 +11,10 @@ VacuumSystem::VacuumSystem ( SGPropertyNode *node )
|
||||||
:
|
:
|
||||||
name("vacuum"),
|
name("vacuum"),
|
||||||
num(0),
|
num(0),
|
||||||
rpm("/engines/engine[0]/rpm"),
|
|
||||||
scale(1.0)
|
scale(1.0)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
rpms.clear();
|
||||||
int i;
|
int i;
|
||||||
for ( i = 0; i < node->nChildren(); ++i ) {
|
for ( i = 0; i < node->nChildren(); ++i ) {
|
||||||
SGPropertyNode *child = node->getChild(i);
|
SGPropertyNode *child = node->getChild(i);
|
||||||
|
@ -25,7 +25,7 @@ VacuumSystem::VacuumSystem ( SGPropertyNode *node )
|
||||||
} else if ( cname == "number" ) {
|
} else if ( cname == "number" ) {
|
||||||
num = child->getIntValue();
|
num = child->getIntValue();
|
||||||
} else if ( cname == "rpm" ) {
|
} else if ( cname == "rpm" ) {
|
||||||
rpm = cval;
|
rpms.push_back(cval);
|
||||||
} else if ( cname == "scale" ) {
|
} else if ( cname == "scale" ) {
|
||||||
scale = child->getDoubleValue();
|
scale = child->getDoubleValue();
|
||||||
} else {
|
} else {
|
||||||
|
@ -41,7 +41,7 @@ VacuumSystem::VacuumSystem( int i )
|
||||||
{
|
{
|
||||||
name = "vacuum";
|
name = "vacuum";
|
||||||
num = i;
|
num = i;
|
||||||
rpm = "/engines/engine[0]/rpm";
|
rpms.clear();
|
||||||
scale = 1.0;
|
scale = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,12 +52,16 @@ VacuumSystem::~VacuumSystem ()
|
||||||
void
|
void
|
||||||
VacuumSystem::init()
|
VacuumSystem::init()
|
||||||
{
|
{
|
||||||
|
unsigned int i;
|
||||||
string branch;
|
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);
|
_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);
|
_pressure_node = fgGetNode("/environment/pressure-inhg", true);
|
||||||
_suction_node = node->getChild("suction-inhg", 0, true);
|
_suction_node = node->getChild("suction-inhg", 0, true);
|
||||||
}
|
}
|
||||||
|
@ -78,11 +82,19 @@ VacuumSystem::update (double dt)
|
||||||
// Model taken from steam.cxx
|
// Model taken from steam.cxx
|
||||||
|
|
||||||
double suction;
|
double suction;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
if (!_serviceable_node->getBoolValue()) {
|
if (!_serviceable_node->getBoolValue()) {
|
||||||
suction = 0.0;
|
suction = 0.0;
|
||||||
} else {
|
} 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();
|
double pressure = _pressure_node->getDoubleValue();
|
||||||
// This magic formula yields about 4 inhg at 700 rpm
|
// This magic formula yields about 4 inhg at 700 rpm
|
||||||
suction = pressure * rpm / (rpm + 4875.0);
|
suction = pressure * rpm / (rpm + 4875.0);
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
# error This library requires C++
|
# error This library requires C++
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <simgear/math/sg_types.hxx>
|
||||||
#include <simgear/props/props.hxx>
|
#include <simgear/props/props.hxx>
|
||||||
#include <simgear/structure/subsystem_mgr.hxx>
|
#include <simgear/structure/subsystem_mgr.hxx>
|
||||||
|
|
||||||
|
@ -18,11 +19,13 @@
|
||||||
/**
|
/**
|
||||||
* Model a vacuum-pump system.
|
* 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:
|
* Input properties:
|
||||||
*
|
*
|
||||||
* "rpm"
|
* "rpm1"
|
||||||
|
* "rpm2"
|
||||||
|
* "..."
|
||||||
* /environment/pressure-inhg
|
* /environment/pressure-inhg
|
||||||
* /systems/"name"/serviceable
|
* /systems/"name"/serviceable
|
||||||
*
|
*
|
||||||
|
@ -48,10 +51,10 @@ private:
|
||||||
|
|
||||||
string name;
|
string name;
|
||||||
int num;
|
int num;
|
||||||
string rpm;
|
string_list rpms;
|
||||||
double scale;
|
double scale;
|
||||||
SGPropertyNode_ptr _serviceable_node;
|
SGPropertyNode_ptr _serviceable_node;
|
||||||
SGPropertyNode_ptr _rpm_node;
|
vector<SGPropertyNode_ptr> _rpm_nodes;
|
||||||
SGPropertyNode_ptr _pressure_node;
|
SGPropertyNode_ptr _pressure_node;
|
||||||
SGPropertyNode_ptr _suction_node;
|
SGPropertyNode_ptr _suction_node;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue