From 1acb43dbfc021715ddf56bbb55e818ce3429fa14 Mon Sep 17 00:00:00 2001 From: david Date: Sat, 28 Sep 2002 20:48:53 +0000 Subject: [PATCH] Added pitot system and new airspeed indicator. --- src/Instrumentation/Makefile.am | 1 + src/Instrumentation/airspeed_indicator.cxx | 72 ++++++++++++++++++++++ src/Instrumentation/airspeed_indicator.hxx | 53 ++++++++++++++++ src/Instrumentation/instrument_mgr.cxx | 2 + src/Systems/Makefile.am | 1 + src/Systems/pitot.cxx | 54 ++++++++++++++++ src/Systems/pitot.hxx | 58 +++++++++++++++++ src/Systems/system_mgr.cxx | 2 + 8 files changed, 243 insertions(+) create mode 100644 src/Instrumentation/airspeed_indicator.cxx create mode 100644 src/Instrumentation/airspeed_indicator.hxx create mode 100644 src/Systems/pitot.cxx create mode 100644 src/Systems/pitot.hxx diff --git a/src/Instrumentation/Makefile.am b/src/Instrumentation/Makefile.am index 7553264cf..c21a11273 100644 --- a/src/Instrumentation/Makefile.am +++ b/src/Instrumentation/Makefile.am @@ -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 index 000000000..27f2f0f17 --- /dev/null +++ b/src/Instrumentation/airspeed_indicator.cxx @@ -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 + +#include + +#include "airspeed_indicator.hxx" +#include
+#include
+ + +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 index 000000000..cb52e1a7d --- /dev/null +++ b/src/Instrumentation/airspeed_indicator.hxx @@ -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 +#include
+ + +/** + * 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 diff --git a/src/Instrumentation/instrument_mgr.cxx b/src/Instrumentation/instrument_mgr.cxx index 765c48715..38504df7a 100644 --- a/src/Instrumentation/instrument_mgr.cxx +++ b/src/Instrumentation/instrument_mgr.cxx @@ -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); diff --git a/src/Systems/Makefile.am b/src/Systems/Makefile.am index a4de5c996..93ff9c946 100644 --- a/src/Systems/Makefile.am +++ b/src/Systems/Makefile.am @@ -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 index 000000000..0a58805b5 --- /dev/null +++ b/src/Systems/pitot.cxx @@ -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
+#include
+ + +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 index 000000000..65a3896aa --- /dev/null +++ b/src/Systems/pitot.hxx @@ -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 +#include
+ + +/** + * 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 diff --git a/src/Systems/system_mgr.cxx b/src/Systems/system_mgr.cxx index f30f88f71..8deb5a763 100644 --- a/src/Systems/system_mgr.cxx +++ b/src/Systems/system_mgr.cxx @@ -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); -- 2.39.5