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",
38 #ifndef SEA_LEVEL_DENSITY_SLUGFG3
39 # define SEA_LEVEL_DENSITY_SLUGFT3 0.002378
43 # define FPSTOKTS 0.592484
47 # define INHGTOPSF (2116.217/29.9212)
51 AirspeedIndicator::update (double dt)
53 if (_serviceable_node->getBoolValue()) {
54 double pt = _total_pressure_node->getDoubleValue();
55 double p = _static_pressure_node->getDoubleValue();
56 double q = ( pt - p ) * INHGTOPSF; // dynamic pressure
58 // Now, reverse the equation
59 double v_fps = sqrt((2 * q) / SEA_LEVEL_DENSITY_SLUGFT3);
61 _speed_node->setDoubleValue(v_fps * FPSTOKTS);
65 // end of airspeed_indicator.cxx