1
0
Fork 0

Added a heading-indicator connected to the vacuum pump and a

vertical-speed indicator connected to the static port.
This commit is contained in:
david 2002-09-27 22:03:48 +00:00
parent c542559097
commit 5289055776
6 changed files with 275 additions and 1 deletions

View file

@ -2,6 +2,8 @@ noinst_LIBRARIES = libInstrumentation.a
libInstrumentation_a_SOURCES = instrument_mgr.cxx instrument_mgr.hxx \
altimeter.cxx altimeter.hxx \
attitude_indicator.cxx attitude_indicator.hxx
attitude_indicator.cxx attitude_indicator.hxx \
heading_indicator.cxx heading_indicator.hxx \
vertical_speed_indicator.cxx vertical_speed_indicator.hxx
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src

View file

@ -0,0 +1,94 @@
// heading_indicator.cxx - a vacuum-powered heading indicator.
// Written by David Megginson, started 2002.
//
// This file is in the Public Domain and comes with no warranty.
#include "heading_indicator.hxx"
#include <Main/fg_props.hxx>
#include <Main/util.hxx>
HeadingIndicator::HeadingIndicator ()
{
}
HeadingIndicator::~HeadingIndicator ()
{
}
void
HeadingIndicator::init ()
{
_serviceable_node =
fgGetNode("/instrumentation/heading-indicator/serviceable", true);
_offset_node =
fgGetNode("/instrumentation/heading-indicator/offset-deg", true);
_heading_in_node = fgGetNode("/orientation/heading-deg", true);
_suction_node = fgGetNode("/systems/vacuum[0]/suction-inhg", true);
_heading_out_node =
fgGetNode("/instrumentation/heading-indicator/indicated-heading-deg",
true);
_last_heading_deg = (_heading_in_node->getDoubleValue() +
_offset_node->getDoubleValue());
}
void
HeadingIndicator::bind ()
{
}
void
HeadingIndicator::unbind ()
{
}
void
HeadingIndicator::update (double dt)
{
// First, calculate the bogo-spin from 0 to 1.
// All numbers are made up.
_spin -= 0.005 * dt; // spin decays every 0.5% every second.
// spin increases up to 25% every second
// if suction is available and the gauge
// is serviceable.
if (_serviceable_node->getBoolValue()) {
double suction = _suction_node->getDoubleValue();
double step = 0.25 * (suction / 5.0) * dt;
if ((_spin + step) <= (suction / 5.0))
_spin += step;
}
if (_spin > 1.0)
_spin = 1.0;
else if (_spin < 0.0)
_spin = 0.0;
// Next, calculate time-based precession
double offset = _offset_node->getDoubleValue();
offset -= dt * (0.25 / 60.0); // 360deg/day
while (offset < -360)
offset += 360;
while (offset > 360)
offset -= 360;
_offset_node->setDoubleValue(offset);
// TODO: movement-induced error
// Next, calculate the indicated heading,
// introducing errors.
double factor = 0.01 / (_spin * _spin * _spin * _spin * _spin * _spin);
double heading = _heading_in_node->getDoubleValue();
heading = fgGetLowPass(_last_heading_deg, heading, dt/factor);
_last_heading_deg = heading;
heading += offset;
while (heading < 0)
heading += 360;
while (heading > 360)
heading -= 360;
_heading_out_node->setDoubleValue(heading);
}
// end of heading_indicator.cxx

View file

@ -0,0 +1,60 @@
// heading_indicator.hxx - a vacuum-powered heading indicator.
// Written by David Megginson, started 2002.
//
// This file is in the Public Domain and comes with no warranty.
#ifndef __INSTRUMENTS_HEADING_INDICATOR_HXX
#define __INSTRUMENTS_HEADING_INDICATOR_HXX 1
#ifndef __cplusplus
# error This library requires C++
#endif
#include <simgear/misc/props.hxx>
#include <Main/fgfs.hxx>
/**
* Model a vacuum-powered heading indicator.
*
* This first, simple draft is hard-wired to vacuum pump #1.
*
* Input properties:
*
* /instrumentation/heading-indicator/serviceable
* /instrumentation/heading-indicator/offset-deg
* /orientation/heading-deg
* /systems/vacuum[0]/suction-inhg
*
* Output properties:
*
* /instrumentation/heading-indicator/indicated-heading-deg
*/
class HeadingIndicator : public FGSubsystem
{
public:
HeadingIndicator ();
virtual ~HeadingIndicator ();
virtual void init ();
virtual void bind ();
virtual void unbind ();
virtual void update (double dt);
private:
double _spin;
double _last_heading_deg;
SGPropertyNode_ptr _serviceable_node;
SGPropertyNode_ptr _offset_node;
SGPropertyNode_ptr _heading_in_node;
SGPropertyNode_ptr _suction_node;
SGPropertyNode_ptr _heading_out_node;
};
#endif // __INSTRUMENTS_HEADING_INDICATOR_HXX

View file

@ -7,6 +7,8 @@
#include "instrument_mgr.hxx"
#include "altimeter.hxx"
#include "attitude_indicator.hxx"
#include "heading_indicator.hxx"
#include "vertical_speed_indicator.hxx"
FGInstrumentMgr::FGInstrumentMgr ()
@ -28,6 +30,8 @@ FGInstrumentMgr::init ()
// TODO: replace with XML configuration
_instruments.push_back(new Altimeter);
_instruments.push_back(new AttitudeIndicator);
_instruments.push_back(new HeadingIndicator);
_instruments.push_back(new VerticalSpeedIndicator);
// Initialize the individual instruments
for (unsigned int i = 0; i < _instruments.size(); i++)

View file

@ -0,0 +1,61 @@
// vertical_speed_indicator.cxx - a regular VSI.
// Written by David Megginson, started 2002.
//
// This file is in the Public Domain and comes with no warranty.
#include <simgear/math/interpolater.hxx>
#include "vertical_speed_indicator.hxx"
#include <Main/fg_props.hxx>
#include <Main/util.hxx>
VerticalSpeedIndicator::VerticalSpeedIndicator ()
: _internal_pressure_inhg(29.92)
{
}
VerticalSpeedIndicator::~VerticalSpeedIndicator ()
{
}
void
VerticalSpeedIndicator::init ()
{
_serviceable_node =
fgGetNode("/instrumentation/vertical-speed-indicator/serviceable",
true);
_pressure_node =
fgGetNode("/systems/static/pressure-inhg", true);
_speed_node =
fgGetNode("/instrumentation/vertical-speed-indicator/indicated-speed-fpm",
true);
}
void
VerticalSpeedIndicator::bind ()
{
}
void
VerticalSpeedIndicator::unbind ()
{
}
void
VerticalSpeedIndicator::update (double dt)
{
// model take from steam.cxx, with change
// from 10000 to 10500 for manual factor
if (_serviceable_node->getBoolValue()) {
double pressure = _pressure_node->getDoubleValue();
_speed_node
->setDoubleValue((_internal_pressure_inhg - pressure) * 10500);
_internal_pressure_inhg =
fgGetLowPass(_internal_pressure_inhg,
_pressure_node->getDoubleValue(),
dt/6.0);
}
}
// end of vertical_speed_indicator.cxx

View file

@ -0,0 +1,53 @@
// vertical_speed_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_VERTICAL_SPEED_INDICATOR_HXX
#define __INSTRUMENTS_VERTICAL_SPEED_INDICATOR_HXX 1
#ifndef __cplusplus
# error This library requires C++
#endif
#include <simgear/misc/props.hxx>
#include <Main/fgfs.hxx>
/**
* Model a non-instantaneous VSI tied to the static port.
*
* Input properties:
*
* /instrumentation/vertical-speed-indicator/serviceable
* /systems/static[0]/pressure-inhg
*
* Output properties:
*
* /instrumentation/vertical-speed-indicator/indicated-speed-fpm
*/
class VerticalSpeedIndicator : public FGSubsystem
{
public:
VerticalSpeedIndicator ();
virtual ~VerticalSpeedIndicator ();
virtual void init ();
virtual void bind ();
virtual void unbind ();
virtual void update (double dt);
private:
double _internal_pressure_inhg;
SGPropertyNode_ptr _serviceable_node;
SGPropertyNode_ptr _pressure_node;
SGPropertyNode_ptr _speed_node;
};
#endif // __INSTRUMENTS_VERTICAL_SPEED_INDICATOR_HXX