2002-09-28 20:48:53 +00:00
|
|
|
// pitot.cxx - the pitot air system.
|
|
|
|
// Written by David Megginson, started 2002.
|
|
|
|
//
|
|
|
|
// This file is in the Public Domain and comes with no warranty.
|
|
|
|
|
|
|
|
#include "pitot.hxx"
|
|
|
|
#include <Main/fg_props.hxx>
|
|
|
|
#include <Main/util.hxx>
|
|
|
|
|
|
|
|
|
2004-10-16 12:37:39 +00:00
|
|
|
|
|
|
|
PitotSystem::PitotSystem ( SGPropertyNode *node )
|
|
|
|
:
|
2006-03-04 22:05:19 +00:00
|
|
|
num(0),
|
|
|
|
name("pitot")
|
2002-09-28 20:48:53 +00:00
|
|
|
{
|
2004-10-16 12:37:39 +00:00
|
|
|
int i;
|
|
|
|
for ( i = 0; i < node->nChildren(); ++i ) {
|
|
|
|
SGPropertyNode *child = node->getChild(i);
|
|
|
|
string cname = child->getName();
|
|
|
|
string cval = child->getStringValue();
|
|
|
|
if ( cname == "name" ) {
|
|
|
|
name = cval;
|
|
|
|
} else if ( cname == "number" ) {
|
|
|
|
num = child->getIntValue();
|
|
|
|
} else {
|
2004-10-24 11:05:14 +00:00
|
|
|
SG_LOG( SG_SYSTEMS, SG_WARN, "Error in systems config logic" );
|
2004-10-16 12:37:39 +00:00
|
|
|
if ( name.length() ) {
|
2004-10-24 11:05:14 +00:00
|
|
|
SG_LOG( SG_SYSTEMS, SG_WARN, "Section = " << name );
|
2004-10-16 12:37:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PitotSystem::PitotSystem ( int i )
|
|
|
|
{
|
|
|
|
num = i;
|
|
|
|
name = "pitot";
|
2002-09-28 20:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PitotSystem::~PitotSystem ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PitotSystem::init ()
|
|
|
|
{
|
2004-10-16 12:37:39 +00:00
|
|
|
string branch;
|
|
|
|
branch = "/systems/" + name;
|
|
|
|
|
|
|
|
SGPropertyNode *node = fgGetNode(branch.c_str(), num, true );
|
|
|
|
_serviceable_node = node->getChild("serviceable", 0, true);
|
2002-09-28 20:48:53 +00:00
|
|
|
_pressure_node = fgGetNode("/environment/pressure-inhg", true);
|
|
|
|
_density_node = fgGetNode("/environment/density-slugft3", true);
|
2002-10-16 22:09:26 +00:00
|
|
|
_velocity_node = fgGetNode("/velocities/airspeed-kt", true);
|
2004-10-16 12:37:39 +00:00
|
|
|
_total_pressure_node = node->getChild("total-pressure-inhg", 0, true);
|
2002-09-28 20:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PitotSystem::bind ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PitotSystem::unbind ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-10-10 18:15:22 +00:00
|
|
|
#ifndef INHGTOPSF
|
|
|
|
# define INHGTOPSF (2116.217/29.9212)
|
|
|
|
#endif
|
|
|
|
|
2003-03-12 20:28:54 +00:00
|
|
|
#ifndef PSFTOINHG
|
|
|
|
# define PSFTOINHG (1/INHGTOPSF)
|
|
|
|
#endif
|
|
|
|
|
2002-10-16 22:09:26 +00:00
|
|
|
#ifndef KTTOFPS
|
|
|
|
# define KTTOFPS 1.68781
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2002-09-28 20:48:53 +00:00
|
|
|
void
|
|
|
|
PitotSystem::update (double dt)
|
|
|
|
{
|
|
|
|
if (_serviceable_node->getBoolValue()) {
|
|
|
|
// The pitot tube sees the forward
|
|
|
|
// velocity in the body axis.
|
2003-03-12 20:28:54 +00:00
|
|
|
double p = _pressure_node->getDoubleValue() * INHGTOPSF;
|
2002-09-28 20:48:53 +00:00
|
|
|
double r = _density_node->getDoubleValue();
|
2002-10-16 22:09:26 +00:00
|
|
|
double v = _velocity_node->getDoubleValue() * KTTOFPS;
|
2003-03-12 20:28:54 +00:00
|
|
|
double q = 0.5 * r * v * v; // dynamic
|
|
|
|
_total_pressure_node->setDoubleValue((p + q) * PSFTOINHG);
|
2002-09-28 20:48:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// end of pitot.cxx
|