1 // airspeed_indicator.cxx - a regular VSI.
2 // Written by David Megginson, started 2002.
4 // This file is in the Public Domain and comes with no warranty.
8 #include <simgear/math/interpolater.hxx>
10 #include "airspeed_indicator.hxx"
11 #include <Main/fg_props.hxx>
12 #include <Main/util.hxx>
15 AirspeedIndicator::AirspeedIndicator ()
19 AirspeedIndicator::~AirspeedIndicator ()
24 AirspeedIndicator::init ()
27 fgGetNode("/instrumentation/airspeed-indicator/serviceable",
29 _total_pressure_node =
30 fgGetNode("/systems/pitot/total-pressure-inhg", true);
31 _static_pressure_node =
32 fgGetNode("/systems/static/pressure-inhg", true);
34 fgGetNode("/instrumentation/airspeed-indicator/indicated-speed-kt",
39 AirspeedIndicator::bind ()
44 AirspeedIndicator::unbind ()
49 #ifndef SEA_LEVEL_DENSITY_SLUGFG3
50 # define SEA_LEVEL_DENSITY_SLUGFT3 0.002378
54 # define FPSTOKTS 0.592484
58 # define INHGTOPSF (2116.217/29.9212)
62 AirspeedIndicator::update (double dt)
64 if (_serviceable_node->getBoolValue()) {
65 double pt = _total_pressure_node->getDoubleValue();
66 double p = _static_pressure_node->getDoubleValue();
67 double q = ( pt - p ) * INHGTOPSF; // dynamic pressure
69 // Now, reverse the equation
70 double v_fps = sqrt((2 * q) / SEA_LEVEL_DENSITY_SLUGFT3);
72 _speed_node->setDoubleValue(v_fps * FPSTOKTS);
76 // end of airspeed_indicator.cxx