FlightGear next
vacuum.cxx
Go to the documentation of this file.
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#ifdef HAVE_CONFIG_H
7# include <config.h>
8#endif
9
10#include "vacuum.hxx"
11
12#include <cstring>
13
14#include <Main/fg_props.hxx>
15
16
17VacuumSystem::VacuumSystem ( SGPropertyNode *node )
18 :
19 _name(node->getStringValue("name", "vacuum")),
20 _num(node->getIntValue("number", 0)),
21 _scale(node->getDoubleValue("scale", 1.0))
22{
23 for ( int i = 0; i < node->nChildren(); ++i ) {
24 SGPropertyNode *child = node->getChild(i);
25 if (child->getNameString() == "rpm")
26 _rpms.push_back(child->getStringValue());
27 }
28}
29
33
34void
36{
37 unsigned int i;
38 std::string branch;
39 branch = "/systems/" + _name;
40
41 SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true );
42 _serviceable_node = node->getChild("serviceable", 0, true);
43 for ( i = 0; i < _rpms.size(); i++ ) {
44 SGPropertyNode_ptr _rpm_node = fgGetNode(_rpms[i].c_str(), true);
45 _rpm_nodes.push_back( _rpm_node );
46 }
47 _pressure_node = fgGetNode("/environment/pressure-inhg", true);
48 _suction_node = node->getChild("suction-inhg", 0, true);
49
50 reinit();
51}
52
53void
55{
56 _suction_node->setDoubleValue(0.0);
57}
58
59void
63
64void
68
69void
71{
72 // Model taken from steam.cxx
73
74 double suction;
75 unsigned int i;
76
77 if (!_serviceable_node->getBoolValue()) {
78 suction = 0.0;
79 } else {
80 // select the source with the max rpm
81 double rpm = 0.0;
82 for ( i = 0; i < _rpm_nodes.size(); i++ ) {
83 double tmp = _rpm_nodes[i]->getDoubleValue() * _scale;
84 if ( tmp > rpm ) {
85 rpm = tmp;
86 }
87 }
88 double pressure = _pressure_node->getDoubleValue();
89 // This magic formula yields about 4 inhg at 700 rpm
90 suction = pressure * rpm / (rpm + 4875.0);
91
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;
97 }
98 _suction_node->setDoubleValue(suction);
99}
100
101
102// Register the subsystem.
103#if 0
104SGSubsystemMgr::Registrant<VacuumSystem> registrantVacuumSystem;
105#endif
106
107// end of vacuum.cxx
#define i(x)
void unbind() override
Definition vacuum.cxx:65
void init() override
Definition vacuum.cxx:35
virtual ~VacuumSystem()
Definition vacuum.cxx:30
void bind() override
Definition vacuum.cxx:60
void reinit() override
Definition vacuum.cxx:54
void update(double dt) override
Definition vacuum.cxx:70
VacuumSystem(SGPropertyNode *node)
Definition vacuum.cxx:17
SGPropertyNode * fgGetNode(const char *path, bool create)
Get a property node.
Definition proptest.cpp:27