1 // pitot.cxx - the pitot air system.
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>
8 #include <Main/util.hxx>
12 PitotSystem::PitotSystem ( SGPropertyNode *node )
18 for ( i = 0; i < node->nChildren(); ++i ) {
19 SGPropertyNode *child = node->getChild(i);
20 string cname = child->getName();
21 string cval = child->getStringValue();
22 if ( cname == "name" ) {
24 } else if ( cname == "number" ) {
25 num = child->getIntValue();
27 SG_LOG( SG_AUTOPILOT, SG_WARN, "Error in systems config logic" );
28 if ( name.length() ) {
29 SG_LOG( SG_AUTOPILOT, SG_WARN, "Section = " << name );
35 PitotSystem::PitotSystem ( int i )
41 PitotSystem::~PitotSystem ()
49 branch = "/systems/" + name;
51 SGPropertyNode *node = fgGetNode(branch.c_str(), num, true );
52 _serviceable_node = node->getChild("serviceable", 0, true);
53 _pressure_node = fgGetNode("/environment/pressure-inhg", true);
54 _density_node = fgGetNode("/environment/density-slugft3", true);
55 _velocity_node = fgGetNode("/velocities/airspeed-kt", true);
56 _total_pressure_node = node->getChild("total-pressure-inhg", 0, true);
58 _serviceable_node->setBoolValue(true);
67 PitotSystem::unbind ()
72 # define INHGTOPSF (2116.217/29.9212)
76 # define PSFTOINHG (1/INHGTOPSF)
80 # define KTTOFPS 1.68781
85 PitotSystem::update (double dt)
87 if (_serviceable_node->getBoolValue()) {
88 // The pitot tube sees the forward
89 // velocity in the body axis.
90 double p = _pressure_node->getDoubleValue() * INHGTOPSF;
91 double r = _density_node->getDoubleValue();
92 double v = _velocity_node->getDoubleValue() * KTTOFPS;
93 double q = 0.5 * r * v * v; // dynamic
94 _total_pressure_node->setDoubleValue((p + q) * PSFTOINHG);