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_SYSTEMS, SG_WARN, "Error in systems config logic" );
28 if ( name.length() ) {
29 SG_LOG( SG_SYSTEMS, 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);
65 PitotSystem::unbind ()
70 # define INHGTOPSF (2116.217/29.9212)
74 # define PSFTOINHG (1/INHGTOPSF)
78 # define KTTOFPS 1.68781
83 PitotSystem::update (double dt)
85 if (_serviceable_node->getBoolValue()) {
86 // The pitot tube sees the forward
87 // velocity in the body axis.
88 double p = _pressure_node->getDoubleValue() * INHGTOPSF;
89 double r = _density_node->getDoubleValue();
90 double v = _velocity_node->getDoubleValue() * KTTOFPS;
91 double q = 0.5 * r * v * v; // dynamic
92 _total_pressure_node->setDoubleValue((p + q) * PSFTOINHG);