X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FSystems%2Fvacuum.cxx;h=5244a4e7b3ad9128afff5416db7151eef66f4793;hb=3cd828b3b67a2890f7564fe349e604228ed50fd4;hp=19bde57773912bd073779970f47bd67dc4650bc6;hpb=682feb8f2d4803444b5a95d956de3979a7a7fcc7;p=flightgear.git diff --git a/src/Systems/vacuum.cxx b/src/Systems/vacuum.cxx index 19bde5777..5244a4e7b 100644 --- a/src/Systems/vacuum.cxx +++ b/src/Systems/vacuum.cxx @@ -7,8 +7,9 @@ #include
-VacuumSystem::VacuumSystem () +VacuumSystem::VacuumSystem( int i ) { + num = i; } VacuumSystem::~VacuumSystem () @@ -16,14 +17,15 @@ VacuumSystem::~VacuumSystem () } void -VacuumSystem::init () +VacuumSystem::init() { - // TODO: allow index of pump and engine - // to be configured. - _serviceable_node = fgGetNode("/systems/vacuum[0]/serviceable", true); + // TODO: allow index of engine to be + // configured. + SGPropertyNode *node = fgGetNode("/systems/vacuum", num, true ); + _serviceable_node = node->getChild("serviceable", 0, true); _rpm_node = fgGetNode("/engines/engine[0]/rpm", true); _pressure_node = fgGetNode("/environment/pressure-inhg", true); - _suction_node = fgGetNode("/systems/vacuum[0]/suction-inhg", true); + _suction_node = node->getChild("suction-inhg", 0, true); } void @@ -48,9 +50,14 @@ VacuumSystem::update (double dt) } else { double rpm = _rpm_node->getDoubleValue(); double pressure = _pressure_node->getDoubleValue(); - suction = pressure * rpm / (rpm + 10000.0); - if (suction > 5.0) - suction = 5.0; + // 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 + double max = 5.39 - 1.0 / ( rpm * 0.00111 ); + if ( suction < 0.0 ) suction = 0.0; + if ( suction > max ) suction = max; } _suction_node->setDoubleValue(suction); }