1 // vacuum.cxx - a vacuum pump connected to the aircraft engine.
2 // Written by David Megginson, started 2002.
4 // This file is in the Public Domain and comes with no warranty.
7 #include <Main/fg_props.hxx>
10 VacuumSystem::VacuumSystem ( SGPropertyNode *node )
14 rpm("/engines/engine[0]/rpm"),
19 for ( i = 0; i < node->nChildren(); ++i ) {
20 SGPropertyNode *child = node->getChild(i);
21 string cname = child->getName();
22 string cval = child->getStringValue();
23 if ( cname == "name" ) {
25 } else if ( cname == "number" ) {
26 num = child->getIntValue();
27 } else if ( cname == "rpm" ) {
29 } else if ( cname == "scale" ) {
30 scale = child->getDoubleValue();
32 SG_LOG( SG_SYSTEMS, SG_WARN, "Error in vacuum config logic" );
33 if ( name.length() ) {
34 SG_LOG( SG_SYSTEMS, SG_WARN, "Section = " << name );
40 VacuumSystem::VacuumSystem( int i )
44 rpm = "/engines/engine[0]/rpm";
48 VacuumSystem::~VacuumSystem ()
56 branch = "/systems/" + name;
58 SGPropertyNode *node = fgGetNode(branch.c_str(), num, true );
59 _serviceable_node = node->getChild("serviceable", 0, true);
60 _rpm_node = fgGetNode(rpm.c_str(), true);
61 _pressure_node = fgGetNode("/environment/pressure-inhg", true);
62 _suction_node = node->getChild("suction-inhg", 0, true);
64 _serviceable_node->setBoolValue(true);
73 VacuumSystem::unbind ()
78 VacuumSystem::update (double dt)
80 // Model taken from steam.cxx
84 if (!_serviceable_node->getBoolValue()) {
87 double rpm = _rpm_node->getDoubleValue() * scale;
88 double pressure = _pressure_node->getDoubleValue();
89 // This magic formula yields about 4 inhg at 700 rpm
90 suction = pressure * rpm / (rpm + 4875.0);
92 // simple regulator model that clamps smoothly to about 5 inhg
93 // over a normal rpm range
94 double max = (rpm > 0 ? 5.39 - 1.0 / ( rpm * 0.00111 ) : 0);
95 if ( suction < 0.0 ) suction = 0.0;
96 if ( suction > max ) suction = max;
98 _suction_node->setDoubleValue(suction);