noinst_LIBRARIES = libInstrumentation.a
libInstrumentation_a_SOURCES = instrument_mgr.cxx instrument_mgr.hxx \
+ airspeed_indicator.cxx airspeed_indicator.hxx \
altimeter.cxx altimeter.hxx \
attitude_indicator.cxx attitude_indicator.hxx \
heading_indicator.cxx heading_indicator.hxx \
--- /dev/null
+// airspeed_indicator.cxx - a regular VSI.
+// Written by David Megginson, started 2002.
+//
+// This file is in the Public Domain and comes with no warranty.
+
+#include <math.h>
+
+#include <simgear/math/interpolater.hxx>
+
+#include "airspeed_indicator.hxx"
+#include <Main/fg_props.hxx>
+#include <Main/util.hxx>
+
+
+AirspeedIndicator::AirspeedIndicator ()
+{
+}
+
+AirspeedIndicator::~AirspeedIndicator ()
+{
+}
+
+void
+AirspeedIndicator::init ()
+{
+ _serviceable_node =
+ fgGetNode("/instrumentation/airspeed-indicator/serviceable",
+ true);
+ _total_pressure_node =
+ fgGetNode("/systems/pitot/total-pressure-inhg", true);
+ _static_pressure_node =
+ fgGetNode("/systems/static/pressure-inhg", true);
+ _speed_node =
+ fgGetNode("/instrumentation/airspeed-indicator/indicated-speed-kt",
+ true);
+}
+
+void
+AirspeedIndicator::bind ()
+{
+}
+
+void
+AirspeedIndicator::unbind ()
+{
+}
+
+
+#ifndef SEA_LEVEL_DENSITY_SLUGFG3
+# define SEA_LEVEL_DENSITY_SLUGFT3 0.002378
+#endif
+
+#ifndef FPSTOKTS
+# define FPSTOKTS 0.592484
+#endif
+
+void
+AirspeedIndicator::update (double dt)
+{
+ if (_serviceable_node->getBoolValue()) {
+ double pt = _total_pressure_node->getDoubleValue();
+ double p = _static_pressure_node->getDoubleValue();
+ double q = pt - p; // dynamic pressure
+
+ // Now, reverse the equation
+ double v_fps = sqrt((2 * q) / SEA_LEVEL_DENSITY_SLUGFT3);
+
+ _speed_node->setDoubleValue(v_fps * FPSTOKTS);
+ }
+}
+
+// end of airspeed_indicator.cxx
--- /dev/null
+// airspeed_indicator.hxx - a regular VSI tied to the static port.
+// Written by David Megginson, started 2002.
+//
+// This file is in the Public Domain and comes with no warranty.
+
+
+#ifndef __INSTRUMENTS_AIRSPEED_INDICATOR_HXX
+#define __INSTRUMENTS_AIRSPEED_INDICATOR_HXX 1
+
+#ifndef __cplusplus
+# error This library requires C++
+#endif
+
+#include <simgear/misc/props.hxx>
+#include <Main/fgfs.hxx>
+
+
+/**
+ * Model an airspeed indicator tied to the pitot and static ports.
+ *
+ * Input properties:
+ *
+ * /instrumentation/airspeed-indicator/serviceable
+ * /systems/pitot[0]/total-pressure-inhg
+ * /systems/static[0]/pressure-inhg
+ *
+ * Output properties:
+ *
+ * /instrumentation/airspeed-indicator/indicated-speed-kt
+ */
+class AirspeedIndicator : public FGSubsystem
+{
+
+public:
+
+ AirspeedIndicator ();
+ virtual ~AirspeedIndicator ();
+
+ virtual void init ();
+ virtual void bind ();
+ virtual void unbind ();
+ virtual void update (double dt);
+
+private:
+
+ SGPropertyNode_ptr _serviceable_node;
+ SGPropertyNode_ptr _total_pressure_node;
+ SGPropertyNode_ptr _static_pressure_node;
+ SGPropertyNode_ptr _speed_node;
+
+};
+
+#endif // __INSTRUMENTS_AIRSPEED_INDICATOR_HXX
#include "instrument_mgr.hxx"
+#include "airspeed_indicator.hxx"
#include "altimeter.hxx"
#include "attitude_indicator.hxx"
#include "heading_indicator.hxx"
FGInstrumentMgr::init ()
{
// TODO: replace with XML configuration
+ _instruments.push_back(new AirspeedIndicator);
_instruments.push_back(new Altimeter);
_instruments.push_back(new AttitudeIndicator);
_instruments.push_back(new HeadingIndicator);
libSystems_a_SOURCES = \
system_mgr.cxx system_mgr.hxx \
electrical.cxx electrical.hxx \
+ pitot.cxx pitot.hxx \
static.cxx static.hxx \
vacuum.cxx vacuum.hxx
--- /dev/null
+// pitot.cxx - the pitot air system.
+// Written by David Megginson, started 2002.
+//
+// This file is in the Public Domain and comes with no warranty.
+
+#include "pitot.hxx"
+#include <Main/fg_props.hxx>
+#include <Main/util.hxx>
+
+
+PitotSystem::PitotSystem ()
+{
+}
+
+PitotSystem::~PitotSystem ()
+{
+}
+
+void
+PitotSystem::init ()
+{
+ _serviceable_node = fgGetNode("/systems/pitot[0]/serviceable", true);
+ _pressure_node = fgGetNode("/environment/pressure-inhg", true);
+ _density_node = fgGetNode("/environment/density-slugft3", true);
+ _velocity_node = fgGetNode("/velocities/uBody-fps", true);
+ _total_pressure_node =
+ fgGetNode("/systems/pitot[0]/total-pressure-inhg", true);
+}
+
+void
+PitotSystem::bind ()
+{
+}
+
+void
+PitotSystem::unbind ()
+{
+}
+
+void
+PitotSystem::update (double dt)
+{
+ if (_serviceable_node->getBoolValue()) {
+ // The pitot tube sees the forward
+ // velocity in the body axis.
+ double p = _pressure_node->getDoubleValue();
+ double r = _density_node->getDoubleValue();
+ double v = _velocity_node->getDoubleValue();
+ double q = 0.5 * r * v * v; // dynamic pressure
+ _total_pressure_node->setDoubleValue(p + q);
+ }
+}
+
+// end of pitot.cxx
--- /dev/null
+// pitot.hxx - the pitot air system.
+// Written by David Megginson, started 2002.
+//
+// This file is in the Public Domain and comes with no warranty.
+
+
+#ifndef __SYSTEMS_PITOT_HXX
+#define __SYSTEMS_PITOT_HXX 1
+
+#ifndef __cplusplus
+# error This library requires C++
+#endif
+
+#include <simgear/misc/props.hxx>
+#include <Main/fgfs.hxx>
+
+
+/**
+ * Model a pitot air system.
+ *
+ * The output is the sum of static and dynamic pressure (not just the
+ * dynamic pressure).
+ *
+ * Input properties:
+ *
+ * /systems/pitot[0]/serviceable
+ * /environment/pressure-slugft3
+ * /environment/density-slugft3
+ * /velocities/uBody-fps
+ *
+ * Output properties:
+ *
+ * /systems/pitot[0]/total-pressure-inhg
+ */
+class PitotSystem : public FGSubsystem
+{
+
+public:
+
+ PitotSystem ();
+ virtual ~PitotSystem ();
+
+ virtual void init ();
+ virtual void bind ();
+ virtual void unbind ();
+ virtual void update (double dt);
+
+private:
+
+ SGPropertyNode_ptr _serviceable_node;
+ SGPropertyNode_ptr _pressure_node;
+ SGPropertyNode_ptr _density_node;
+ SGPropertyNode_ptr _velocity_node;
+ SGPropertyNode_ptr _total_pressure_node;
+
+};
+
+#endif // __SYSTEMS_PITOT_HXX
#include "system_mgr.hxx"
#include "electrical.hxx"
+#include "pitot.hxx"
#include "static.hxx"
#include "vacuum.hxx"
{
// TODO: replace with XML configuration
_systems.push_back(new FGElectricalSystem);
+ _systems.push_back(new PitotSystem);
_systems.push_back(new StaticSystem);
_systems.push_back(new VacuumSystem);