Added pitot system and new airspeed indicator.
This commit is contained in:
parent
dc7103245a
commit
1acb43dbfc
8 changed files with 243 additions and 0 deletions
|
@ -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 \
|
||||
|
|
72
src/Instrumentation/airspeed_indicator.cxx
Normal file
72
src/Instrumentation/airspeed_indicator.cxx
Normal file
|
@ -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
|
53
src/Instrumentation/airspeed_indicator.hxx
Normal file
53
src/Instrumentation/airspeed_indicator.hxx
Normal file
|
@ -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
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
54
src/Systems/pitot.cxx
Normal file
54
src/Systems/pitot.cxx
Normal file
|
@ -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
|
58
src/Systems/pitot.hxx
Normal file
58
src/Systems/pitot.hxx
Normal file
|
@ -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
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue