1 // altimeter.cxx - an altimeter tied to the static port.
2 // Written by David Megginson, started 2002.
4 // This file is in the Public Domain and comes with no warranty.
6 #include <simgear/math/interpolater.hxx>
8 #include "altimeter.hxx"
9 #include <Main/fg_props.hxx>
12 // Altitude based on pressure difference from sea level.
13 // pressure difference inHG, altitude ft
14 static double altitude_data[][2] = {
38 29.62, 100000.00 // just to fill it in
43 Altimeter::Altimeter ()
44 : _altitude_table(new SGInterpTable)
47 for (int i = 0; altitude_data[i][0] != -1; i++)
48 _altitude_table->addEntry(altitude_data[i][0], altitude_data[i][1]);
51 Altimeter::~Altimeter ()
53 delete _altitude_table;
60 fgGetNode("/instrumentation/altimeter/serviceable", true);
62 fgGetNode("/instrumentation/altimeter/setting-inhg", true);
64 fgGetNode("/systems/static/pressure-inhg", true);
66 fgGetNode("/instrumentation/altimeter/indicated-altitude-ft", true);
80 Altimeter::update (double dt)
82 if (_serviceable_node->getBoolValue()) {
83 double pressure = _pressure_node->getDoubleValue();
84 double setting = _setting_node->getDoubleValue();
86 ->setDoubleValue(_altitude_table->interpolate(setting-pressure));
90 // end of altimeter.cxx