2002-09-24 14:51:37 +00:00
|
|
|
// vacuum.cxx - a vacuum pump connected to the aircraft engine.
|
|
|
|
// Written by David Megginson, started 2002.
|
|
|
|
//
|
|
|
|
// This file is in the Public Domain and comes with no warranty.
|
|
|
|
|
|
|
|
#include "vacuum.hxx"
|
|
|
|
#include <Main/fg_props.hxx>
|
|
|
|
|
|
|
|
|
2004-10-16 12:37:39 +00:00
|
|
|
VacuumSystem::VacuumSystem ( SGPropertyNode *node )
|
|
|
|
:
|
|
|
|
name("vacuum"),
|
|
|
|
num(0),
|
|
|
|
rpm("/engines/engine[0]/rpm"),
|
|
|
|
scale(1.0)
|
|
|
|
|
|
|
|
{
|
|
|
|
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 == "rpm" ) {
|
|
|
|
rpm = cval;
|
|
|
|
} else if ( cname == "scale" ) {
|
|
|
|
scale = child->getDoubleValue();
|
|
|
|
} else {
|
|
|
|
SG_LOG( SG_AUTOPILOT, SG_WARN, "Error in vacuum config logic" );
|
|
|
|
if ( name.length() ) {
|
|
|
|
SG_LOG( SG_AUTOPILOT, SG_WARN, "Section = " << name );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-27 19:25:27 +00:00
|
|
|
VacuumSystem::VacuumSystem( int i )
|
2002-09-24 14:51:37 +00:00
|
|
|
{
|
2004-10-16 12:37:39 +00:00
|
|
|
name = "vacuum";
|
2003-05-27 19:25:27 +00:00
|
|
|
num = i;
|
2004-10-16 12:37:39 +00:00
|
|
|
rpm = "/engines/engine[0]/rpm";
|
|
|
|
scale = 1.0;
|
2002-09-24 14:51:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VacuumSystem::~VacuumSystem ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-05-27 19:25:27 +00:00
|
|
|
VacuumSystem::init()
|
2002-09-24 14:51:37 +00:00
|
|
|
{
|
2004-10-16 12:37:39 +00:00
|
|
|
string branch;
|
|
|
|
branch = "/systems/" + name;
|
|
|
|
|
|
|
|
SGPropertyNode *node = fgGetNode(branch.c_str(), num, true );
|
2003-05-27 19:25:27 +00:00
|
|
|
_serviceable_node = node->getChild("serviceable", 0, true);
|
2004-10-16 12:37:39 +00:00
|
|
|
_rpm_node = fgGetNode(rpm.c_str(), true);
|
2002-09-24 14:51:37 +00:00
|
|
|
_pressure_node = fgGetNode("/environment/pressure-inhg", true);
|
2003-05-27 19:25:27 +00:00
|
|
|
_suction_node = node->getChild("suction-inhg", 0, true);
|
2004-10-16 12:37:39 +00:00
|
|
|
|
|
|
|
_serviceable_node->setBoolValue(true);
|
2002-09-24 14:51:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VacuumSystem::bind ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VacuumSystem::unbind ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VacuumSystem::update (double dt)
|
|
|
|
{
|
|
|
|
// Model taken from steam.cxx
|
|
|
|
|
|
|
|
double suction;
|
|
|
|
|
|
|
|
if (!_serviceable_node->getBoolValue()) {
|
|
|
|
suction = 0.0;
|
|
|
|
} else {
|
2004-10-16 12:37:39 +00:00
|
|
|
double rpm = _rpm_node->getDoubleValue() * scale;
|
2002-09-24 14:51:37 +00:00
|
|
|
double pressure = _pressure_node->getDoubleValue();
|
2003-05-28 18:48:00 +00:00
|
|
|
// This magic formula yields about 4 inhg at 700 rpm
|
|
|
|
suction = pressure * rpm / (rpm + 4875.0);
|
|
|
|
|
|
|
|
// simple regulator model that clamps smoothly to about 5 inhg
|
|
|
|
// over a normal rpm range
|
2003-07-22 02:05:50 +00:00
|
|
|
double max = (rpm > 0 ? 5.39 - 1.0 / ( rpm * 0.00111 ) : 0);
|
2003-05-27 19:25:27 +00:00
|
|
|
if ( suction < 0.0 ) suction = 0.0;
|
2003-05-28 18:48:00 +00:00
|
|
|
if ( suction > max ) suction = max;
|
2002-09-24 14:51:37 +00:00
|
|
|
}
|
|
|
|
_suction_node->setDoubleValue(suction);
|
|
|
|
}
|
|
|
|
|
|
|
|
// end of vacuum.cxx
|