]> git.mxchange.org Git - flightgear.git/blob - src/Systems/vacuum.cxx
5b07b77f564e7fd737674e9f1c9abfe749f8c49a
[flightgear.git] / src / Systems / vacuum.cxx
1 // vacuum.cxx - a vacuum pump connected to the aircraft engine.
2 // Written by David Megginson, started 2002.
3 //
4 // This file is in the Public Domain and comes with no warranty.
5
6 #include "vacuum.hxx"
7 #include <Main/fg_props.hxx>
8
9
10 VacuumSystem::VacuumSystem( int i )
11 {
12     num = i;
13 }
14
15 VacuumSystem::~VacuumSystem ()
16 {
17 }
18
19 void
20 VacuumSystem::init()
21 {
22                                 // TODO: allow index of engine to be
23                                 // configured.
24     SGPropertyNode *node = fgGetNode("/systems/vacuum", num, true );
25     _serviceable_node = node->getChild("serviceable", 0, true);
26     _rpm_node = fgGetNode("/engines/engine[0]/rpm", true);
27     _pressure_node = fgGetNode("/environment/pressure-inhg", true);
28     _suction_node = node->getChild("suction-inhg", 0, true);
29 }
30
31 void
32 VacuumSystem::bind ()
33 {
34 }
35
36 void
37 VacuumSystem::unbind ()
38 {
39 }
40
41 void
42 VacuumSystem::update (double dt)
43 {
44     // Model taken from steam.cxx
45
46     double suction;
47
48     if (!_serviceable_node->getBoolValue()) {
49         suction = 0.0;
50     } else {
51         double rpm = _rpm_node->getDoubleValue();
52         double pressure = _pressure_node->getDoubleValue();
53         // suction = pressure * rpm / (rpm + 5000.0);
54         // This magic formula yields about 4.1 inhg at 700 rpm and
55         // about 6.0 inhg at 2200 rpm (numbers by observation)
56         suction = 5.39 - 1.0 / ( rpm * 0.00111 );
57         if ( suction < 0.0 ) suction = 0.0;
58         if ( suction > 5.0 ) suction = 5.0;
59     }
60     _suction_node->setDoubleValue(suction);
61 }
62
63 // end of vacuum.cxx