src/FDM/Makefile \
src/GUI/Makefile \
src/Input/Makefile \
+ src/Instrumentation/Makefile \
src/Main/Makefile \
src/Main/runfgfs \
src/Main/runfgfs.bat \
src/Scenery/Makefile \
src/Sound/Makefile \
src/Systems/Makefile \
- src/Systems/Vacuum/Makefile \
src/Time/Makefile \
src/WeatherCM/Makefile \
tests/Makefile \
--- /dev/null
+noinst_LIBRARIES = libInstrumentation.a
+
+libInstrumentation_a_SOURCES = instrument_mgr.cxx instrument_mgr.hxx \
+ attitude_indicator.cxx attitude_indicator.hxx
+
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src
--- /dev/null
+// attitude_indicator.cxx - a vacuum-powered attitude indicator.
+// Written by David Megginson, started 2002.
+//
+// This file is in the Public Domain and comes with no warranty.
+
+#include "attitude_indicator.hxx"
+#include <Main/fg_props.hxx>
+
+
+AttitudeIndicator::AttitudeIndicator ()
+{
+}
+
+AttitudeIndicator::~AttitudeIndicator ()
+{
+}
+
+void
+AttitudeIndicator::init ()
+{
+ // TODO: allow index of pump and AI
+ // to be configured.
+ _serviceable_node =
+ fgGetNode("/instrumentation/attitude-indicator/serviceable", true);
+ _pitch_in_node = fgGetNode("/orientation/pitch-deg", true);
+ _roll_in_node = fgGetNode("/orientation/roll-deg", true);
+ _suction_node = fgGetNode("/systems/vacuum[0]/suction-inhg", true);
+ _pitch_out_node =
+ fgGetNode("/instrumentation/attitude-indicator/indicated-pitch-deg",
+ true);
+ _roll_out_node =
+ fgGetNode("/instrumentation/attitude-indicator/indicated-roll-deg",
+ true);
+}
+
+void
+AttitudeIndicator::bind ()
+{
+}
+
+void
+AttitudeIndicator::unbind ()
+{
+}
+
+void
+AttitudeIndicator::update (double dt)
+{
+ // First, calculate the bogo-spin from 0 to 1.
+ // All numbers are made up.
+
+ _spin -= 0.01 * dt; // spin decays every 1% every second.
+
+ // spin increases up to 10% every second
+ // if suction is available and the gauge
+ // is serviceable.
+ if (_serviceable_node->getBoolValue()) {
+ double suction = _suction_node->getDoubleValue();
+ double step = 0.10 * (suction / 5.0) * dt;
+ if ((_spin + step) <= (suction / 5.0))
+ _spin += step;
+ }
+
+ // Next, calculate the indicated roll
+ // and pitch, introducing errors if
+ // the spin is less than 0.8 (80%).
+ double roll = _roll_in_node->getDoubleValue();
+ double pitch = _pitch_in_node->getDoubleValue();
+ if (_spin < 0.8) {
+ // TODO
+ }
+ _roll_out_node->setDoubleValue(roll);
+ _pitch_out_node->setDoubleValue(pitch);
+}
+
+// end of attitude_indicator.cxx
--- /dev/null
+// attitude_indicator.hxx - a vacuum-powered attitude indicator.
+// Written by David Megginson, started 2002.
+//
+// This file is in the Public Domain and comes with no warranty.
+
+
+#ifndef __INSTRUMENTS_ATTITUDE_INDICATOR_HXX
+#define __INSTRUMENTS_ATTITUDE_INDICATOR_HXX 1
+
+#ifndef __cplusplus
+# error This library requires C++
+#endif
+
+#include <simgear/misc/props.hxx>
+#include <Main/fgfs.hxx>
+
+
+/**
+ * Model a vacuum-powered attitude indicator.
+ *
+ * This first, simple draft is hard-wired to vacuum pump #1.
+ *
+ * Input properties:
+ *
+ * /instrumentation/attitude-indicator/serviceable
+ * /orientation/pitch-deg
+ * /orientation/roll-deg
+ * /systems/vacuum[0]/suction-inhg
+ *
+ * Output properties:
+ *
+ * /instrumentation/attitude-indicator/indicated-pitch-deg
+ * /instrumentation/attitude-indicator/indicated-roll-deg
+ */
+class AttitudeIndicator : public FGSubsystem
+{
+
+public:
+
+ AttitudeIndicator ();
+ virtual ~AttitudeIndicator ();
+
+ virtual void init ();
+ virtual void bind ();
+ virtual void unbind ();
+ virtual void update (double dt);
+
+private:
+
+ double _spin;
+
+ SGPropertyNode_ptr _serviceable_node;
+ SGPropertyNode_ptr _pitch_in_node;
+ SGPropertyNode_ptr _roll_in_node;
+ SGPropertyNode_ptr _suction_node;
+ SGPropertyNode_ptr _pitch_out_node;
+ SGPropertyNode_ptr _roll_out_node;
+
+};
+
+#endif // __INSTRUMENTS_ATTITUDE_INDICATOR_HXX
--- /dev/null
+// instrument_mgr.cxx - manage aircraft instruments.
+// Written by David Megginson, started 2002.
+//
+// This file is in the Public Domain and comes with no warranty.
+
+
+#include "instrument_mgr.hxx"
+#include "attitude_indicator.hxx"
+
+
+FGInstrumentMgr::FGInstrumentMgr ()
+{
+ // NO-OP
+}
+
+FGInstrumentMgr::~FGInstrumentMgr ()
+{
+ for (unsigned int i = 0; i < _instruments.size(); i++) {
+ delete _instruments[i];
+ _instruments[i] = 0;
+ }
+}
+
+void
+FGInstrumentMgr::init ()
+{
+ // TODO: replace with XML configuration
+ _instruments.push_back(new AttitudeIndicator);
+
+ // Initialize the individual instruments
+ for (unsigned int i = 0; i < _instruments.size(); i++)
+ _instruments[i]->init();
+}
+
+void
+FGInstrumentMgr::bind ()
+{
+ // NO-OP
+}
+
+void
+FGInstrumentMgr::unbind ()
+{
+ // NO-OP
+}
+
+void
+FGInstrumentMgr::update (double dt)
+{
+ for (unsigned int i = 0; i < _instruments.size(); i++)
+ _instruments[i]->update(dt);
+}
+
+// end of instrument_manager.cxx
--- /dev/null
+// instrument_mgr.hxx - manage aircraft instruments.
+// Written by David Megginson, started 2002.
+//
+// This file is in the Public Domain and comes with no warranty.
+
+
+#ifndef __INSTRUMENT_MGR_HXX
+#define __INSTRUMENT_MGR_HXX 1
+
+#ifndef __cplusplus
+# error This library requires C++
+#endif
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <simgear/compiler.h>
+
+#include <Main/fgfs.hxx>
+
+#include <vector>
+
+SG_USING_STD(vector);
+
+
+/**
+ * Manage aircraft instruments.
+ *
+ * In the initial draft, the instruments present are hard-coded, but they
+ * will soon be configurable for individual aircraft.
+ */
+class FGInstrumentMgr : public FGSubsystem
+{
+public:
+
+ FGInstrumentMgr ();
+ virtual ~FGInstrumentMgr ();
+
+ virtual void init ();
+ virtual void bind ();
+ virtual void unbind ();
+ virtual void update (double dt);
+
+private:
+ vector<FGSubsystem *> _instruments;
+
+};
+
+#endif // __INSTRUMENT_MGR_HXX
$(NETWORK_LIBS) \
$(top_builddir)/src/Objects/libObjects.a \
$(top_builddir)/src/Systems/libSystems.a \
- $(top_builddir)/src/Systems/Vacuum/libVacuum.a \
$(top_builddir)/src/Time/libTime.a \
$(WEATHER_LIBS) \
$(top_builddir)/src/Input/libInput.a \
+ $(top_builddir)/src/Instrumentation/libInstrumentation.a \
-lsgroute -lsgsky -lsgclouds3d -lsgephem -lsgtiming -lsgio -lsgscreen \
-lsgmath -lsgbucket -lsgdebug -lsgmagvar -lsgmisc -lsgxml \
-lsgserial \
#include <FDM/YASim/YASim.hxx>
#include <Include/general.hxx>
#include <Input/input.hxx>
+#include <Instrumentation/instrument_mgr.hxx>
// #include <Joystick/joystick.hxx>
#include <Objects/matlib.hxx>
#include <Model/acmodel.hxx>
globals->get_systemmgr()->init();
globals->get_systemmgr()->bind();
+ ////////////////////////////////////////////////////////////////////
+ // Initialize the instrumentation.
+ ////////////////////////////////////////////////////////////////////
+ globals->get_instrumentmgr()->init();
+ globals->get_instrumentmgr()->bind();
+
////////////////////////////////////////////////////////////////////
// Initialize the radio stack subsystem.
////////////////////////////////////////////////////////////////////
#include <simgear/misc/commands.hxx>
#include <Environment/environment_mgr.hxx>
+#include <Instrumentation/instrument_mgr.hxx>
#include <Systems/system_mgr.hxx>
#include "globals.hxx"
warp_delta( 0 ),
logger(0),
systemmgr(new FGSystemMgr),
+ instrumentmgr(new FGInstrumentMgr),
props(new SGPropertyNode),
initial_state(0),
commands(new SGCommandMgr),
class FGSteam;
class FGSoundMgr;
class FGSystemMgr;
+class FGInstrumentMgr;
class FGAutopilot;
class FGFX;
class FGViewMgr;
// aircraft system manager
FGSystemMgr * systemmgr;
+ // aircraft instrument manager
+ FGInstrumentMgr * instrumentmgr;
+
// environment information
FGEnvironmentMgr * environment_mgr;
inline FGSystemMgr *get_systemmgr() const { return systemmgr; }
+ inline FGInstrumentMgr *get_instrumentmgr() const { return instrumentmgr; }
+
inline FGFX *get_fx() const { return fx; }
inline void set_fx( FGFX *x ) { fx = x; }
# include <Sound/morse.hxx>
#endif
#include <Systems/system_mgr.hxx>
+#include <Instrumentation/instrument_mgr.hxx>
#include <Time/FGEventMgr.hxx>
#include <Time/fg_timer.hxx>
#include <Time/light.hxx>
#endif
globals->get_systemmgr()->update( delta_time_sec );
+ globals->get_instrumentmgr()->update( delta_time_sec );
//
// Tile Manager updates - see if we need to load any new scenery tiles.
FDM \
GUI \
Input \
+ Instrumentation \
Model \
Navaids \
$(NETWORK_DIRS) \
-SUBDIRS = Vacuum
-
noinst_LIBRARIES = libSystems.a
-libSystems_a_SOURCES = system_mgr.cxx system_mgr.hxx
+libSystems_a_SOURCES = system_mgr.cxx system_mgr.hxx \
+ vacuum.cxx vacuum.hxx
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src
#include "system_mgr.hxx"
-#include "Vacuum/vacuum.hxx"
+#include "vacuum.hxx"
FGSystemMgr::FGSystemMgr ()
--- /dev/null
+// vacuum.cxx - a vacuum pump connected to the aircraft engine.
+// Written by David Megginson, started 2002.
+//
+// This file is in the Public Domain and comes with no warranty.
+
+#include "vacuum.hxx"
+#include <Main/fg_props.hxx>
+
+
+VacuumSystem::VacuumSystem ()
+{
+}
+
+VacuumSystem::~VacuumSystem ()
+{
+}
+
+void
+VacuumSystem::init ()
+{
+ // TODO: allow index of pump and engine
+ // to be configured.
+ _serviceable_node = fgGetNode("/systems/vacuum[0]/serviceable", true);
+ _rpm_node = fgGetNode("/engines/engine[0]/rpm", true);
+ _pressure_node = fgGetNode("/environment/pressure-inhg", true);
+ _suction_node = fgGetNode("/systems/vacuum[0]/suction-inhg", true);
+}
+
+void
+VacuumSystem::bind ()
+{
+}
+
+void
+VacuumSystem::unbind ()
+{
+}
+
+void
+VacuumSystem::update (double dt)
+{
+ // Model taken from steam.cxx
+
+ double suction;
+
+ if (!_serviceable_node->getBoolValue()) {
+ suction = 0.0;
+ } else {
+ double rpm = _rpm_node->getDoubleValue();
+ double pressure = _pressure_node->getDoubleValue();
+ suction = pressure * rpm / (rpm + 10000.0);
+ if (suction > 5.0)
+ suction = 5.0;
+ }
+ _suction_node->setDoubleValue(suction);
+}
+
+// end of vacuum.cxx
--- /dev/null
+// vacuum.hxx - a vacuum pump connected to the aircraft engine.
+// Written by David Megginson, started 2002.
+//
+// This file is in the Public Domain and comes with no warranty.
+
+
+#ifndef __SYSTEMS_VACUUM_HXX
+#define __SYSTEMS_VACUUM_HXX 1
+
+#ifndef __cplusplus
+# error This library requires C++
+#endif
+
+#include <simgear/misc/props.hxx>
+#include <Main/fgfs.hxx>
+
+
+/**
+ * Model a vacuum-pump system.
+ *
+ * This first, simple draft is hard-wired to engine #1.
+ *
+ * Input properties:
+ *
+ * /engines/engine[0]/rpm
+ * /environment/pressure-inhg
+ * /systems/vacuum[0]/serviceable
+ *
+ * Output properties:
+ *
+ * /systems/vacuum[0]/suction-inhg
+ */
+class VacuumSystem : public FGSubsystem
+{
+
+public:
+
+ VacuumSystem ();
+ virtual ~VacuumSystem ();
+
+ virtual void init ();
+ virtual void bind ();
+ virtual void unbind ();
+ virtual void update (double dt);
+
+private:
+
+ SGPropertyNode_ptr _serviceable_node;
+ SGPropertyNode_ptr _rpm_node;
+ SGPropertyNode_ptr _pressure_node;
+ SGPropertyNode_ptr _suction_node;
+
+};
+
+#endif // __SYSTEMS_VACUUM_HXX