]> git.mxchange.org Git - flightgear.git/commitdiff
Added pitot system and new airspeed indicator.
authordavid <david>
Sat, 28 Sep 2002 20:48:53 +0000 (20:48 +0000)
committerdavid <david>
Sat, 28 Sep 2002 20:48:53 +0000 (20:48 +0000)
src/Instrumentation/Makefile.am
src/Instrumentation/airspeed_indicator.cxx [new file with mode: 0644]
src/Instrumentation/airspeed_indicator.hxx [new file with mode: 0644]
src/Instrumentation/instrument_mgr.cxx
src/Systems/Makefile.am
src/Systems/pitot.cxx [new file with mode: 0644]
src/Systems/pitot.hxx [new file with mode: 0644]
src/Systems/system_mgr.cxx

index 7553264cf5932a9574de3373d43ec0028899d620..c21a1127318cf072576c47a0da701df6ff43e017 100644 (file)
@@ -1,6 +1,7 @@
 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 \
diff --git a/src/Instrumentation/airspeed_indicator.cxx b/src/Instrumentation/airspeed_indicator.cxx
new file mode 100644 (file)
index 0000000..27f2f0f
--- /dev/null
@@ -0,0 +1,72 @@
+// 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
diff --git a/src/Instrumentation/airspeed_indicator.hxx b/src/Instrumentation/airspeed_indicator.hxx
new file mode 100644 (file)
index 0000000..cb52e1a
--- /dev/null
@@ -0,0 +1,53 @@
+// 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
index 765c487158852c8ba9cbf1d1d3b1547ab5a8d807..38504df7ae38249edd1dab01a8b48321d60ff143 100644 (file)
@@ -5,6 +5,7 @@
 
 
 #include "instrument_mgr.hxx"
+#include "airspeed_indicator.hxx"
 #include "altimeter.hxx"
 #include "attitude_indicator.hxx"
 #include "heading_indicator.hxx"
@@ -28,6 +29,7 @@ void
 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);
index a4de5c996dc3f3e92ee04addbb036f0a029a9b4c..93ff9c9468c474dc11220d78d2831e88efacd8f5 100644 (file)
@@ -3,6 +3,7 @@ noinst_LIBRARIES = libSystems.a
 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
 
diff --git a/src/Systems/pitot.cxx b/src/Systems/pitot.cxx
new file mode 100644 (file)
index 0000000..0a58805
--- /dev/null
@@ -0,0 +1,54 @@
+// 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
diff --git a/src/Systems/pitot.hxx b/src/Systems/pitot.hxx
new file mode 100644 (file)
index 0000000..65a3896
--- /dev/null
@@ -0,0 +1,58 @@
+// 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
index f30f88f711941eccea1f851d6c2e943e9ac58f60..8deb5a763c39f994cdab06846e5339b8191d212b 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "system_mgr.hxx"
 #include "electrical.hxx"
+#include "pitot.hxx"
 #include "static.hxx"
 #include "vacuum.hxx"
 
@@ -28,6 +29,7 @@ FGSystemMgr::init ()
 {
                                 // 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);