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.
|
|
|
|
|
2006-07-17 18:14:31 +00:00
|
|
|
#include <simgear/constants.h>
|
|
|
|
|
2002-09-28 20:48:53 +00:00
|
|
|
#include <Main/fg_props.hxx>
|
|
|
|
#include <Main/util.hxx>
|
|
|
|
|
2006-07-17 18:14:31 +00:00
|
|
|
#include "pitot.hxx"
|
2002-09-28 20:48:53 +00:00
|
|
|
|
2004-10-16 12:37:39 +00:00
|
|
|
|
|
|
|
PitotSystem::PitotSystem ( SGPropertyNode *node )
|
|
|
|
:
|
2006-12-06 22:11:43 +00:00
|
|
|
_name(node->getStringValue("name", "pitot")),
|
|
|
|
_num(node->getIntValue("number", 0))
|
2002-09-28 20:48:53 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PitotSystem::~PitotSystem ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PitotSystem::init ()
|
|
|
|
{
|
2004-10-16 12:37:39 +00:00
|
|
|
string branch;
|
2006-12-06 22:11:43 +00:00
|
|
|
branch = "/systems/" + _name;
|
2004-10-16 12:37:39 +00:00
|
|
|
|
2006-12-06 22:11:43 +00:00
|
|
|
SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true );
|
2004-10-16 12:37:39 +00:00
|
|
|
_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);
|
2006-07-17 18:14:31 +00:00
|
|
|
_slip_angle = fgGetNode("/orientation/side-slip-rad", 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
|
|
|
|
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();
|
2006-07-17 18:14:31 +00:00
|
|
|
double v = _velocity_node->getDoubleValue() * SG_KT_TO_FPS;
|
|
|
|
v *= cos(_slip_angle->getDoubleValue());
|
|
|
|
if (v < 0.0)
|
|
|
|
v = 0.0;
|
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
|