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 AirspeedIndicator::update (double dt)
60 if (_serviceable_node->getBoolValue()) {
61 double pt = _total_pressure_node->getDoubleValue();
62 double p = _static_pressure_node->getDoubleValue();
63 double q = pt - p; // dynamic pressure
65 // Now, reverse the equation
66 double v_fps = sqrt((2 * q) / SEA_LEVEL_DENSITY_SLUGFT3);
68 _speed_node->setDoubleValue(v_fps * FPSTOKTS);
72 // end of airspeed_indicator.cxx