1 // pitot.cxx - the pitot air system.
2 // Written by David Megginson, started 2002.
4 // Last modified by Eric van den Berg, 24 Nov 2012
5 // This file is in the Public Domain and comes with no warranty.
11 #include <simgear/constants.h>
13 #include <Main/fg_props.hxx>
14 #include <Main/util.hxx>
19 PitotSystem::PitotSystem ( SGPropertyNode *node )
21 _name(node->getStringValue("name", "pitot")),
22 _num(node->getIntValue("number", 0))
26 PitotSystem::~PitotSystem ()
34 branch = "/systems/" + _name;
36 SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true );
37 _serviceable_node = node->getChild("serviceable", 0, true);
38 _pressure_node = fgGetNode("/environment/pressure-inhg", true);
39 _mach_node = fgGetNode("/velocities/mach", true);
40 _total_pressure_node = node->getChild("total-pressure-inhg", 0, true);
41 _measured_total_pressure_node = node->getChild("measured-total-pressure-inhg", 0, true);
50 PitotSystem::unbind ()
55 PitotSystem::update (double dt)
57 if (_serviceable_node->getBoolValue()) {
58 double p = _pressure_node->getDoubleValue();
59 double mach = _mach_node->getDoubleValue();
60 mach = std::max( mach , 0.0 );
61 double p_t = p * pow(1 + 0.2 * mach*mach, 3.5 ); // true total pressure around aircraft
62 _total_pressure_node->setDoubleValue(p_t);
63 double p_t_meas = p_t;
65 p_t_meas = p * pow( 1.2 * mach*mach, 3.5 ) * pow( 2.8/2.4*mach*mach - 0.4 / 2.4 , -2.5 ); // measured total pressure by pitot tube (Rayleigh formula, at Mach>1, normal shockwave in front of pitot tube)
67 _measured_total_pressure_node->setDoubleValue(p_t_meas);