From: david Date: Tue, 24 Sep 2002 14:51:37 +0000 (+0000) Subject: Flattened src/Systems/ subtree. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=682feb8f2d4803444b5a95d956de3979a7a7fcc7;p=flightgear.git Flattened src/Systems/ subtree. Added src/Instrumentation/ with partial stab at a vacuum-driven attitude indicator. --- diff --git a/configure.ac b/configure.ac index 1ff028228..528f070d5 100644 --- a/configure.ac +++ b/configure.ac @@ -587,6 +587,7 @@ AC_CONFIG_FILES([ \ src/FDM/Makefile \ src/GUI/Makefile \ src/Input/Makefile \ + src/Instrumentation/Makefile \ src/Main/Makefile \ src/Main/runfgfs \ src/Main/runfgfs.bat \ @@ -598,7 +599,6 @@ AC_CONFIG_FILES([ \ src/Scenery/Makefile \ src/Sound/Makefile \ src/Systems/Makefile \ - src/Systems/Vacuum/Makefile \ src/Time/Makefile \ src/WeatherCM/Makefile \ tests/Makefile \ diff --git a/src/Instrumentation/Makefile.am b/src/Instrumentation/Makefile.am new file mode 100644 index 000000000..e66685e74 --- /dev/null +++ b/src/Instrumentation/Makefile.am @@ -0,0 +1,6 @@ +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 diff --git a/src/Instrumentation/attitude_indicator.cxx b/src/Instrumentation/attitude_indicator.cxx new file mode 100644 index 000000000..f48eda7c7 --- /dev/null +++ b/src/Instrumentation/attitude_indicator.cxx @@ -0,0 +1,76 @@ +// 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
+ + +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 diff --git a/src/Instrumentation/attitude_indicator.hxx b/src/Instrumentation/attitude_indicator.hxx new file mode 100644 index 000000000..81ad86aee --- /dev/null +++ b/src/Instrumentation/attitude_indicator.hxx @@ -0,0 +1,61 @@ +// 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 +#include
+ + +/** + * 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 diff --git a/src/Instrumentation/instrument_mgr.cxx b/src/Instrumentation/instrument_mgr.cxx new file mode 100644 index 000000000..f330856e9 --- /dev/null +++ b/src/Instrumentation/instrument_mgr.cxx @@ -0,0 +1,54 @@ +// 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 diff --git a/src/Instrumentation/instrument_mgr.hxx b/src/Instrumentation/instrument_mgr.hxx new file mode 100644 index 000000000..6e0bf4d12 --- /dev/null +++ b/src/Instrumentation/instrument_mgr.hxx @@ -0,0 +1,50 @@ +// 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 +#endif + +#include + +#include
+ +#include + +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 _instruments; + +}; + +#endif // __INSTRUMENT_MGR_HXX diff --git a/src/Main/Makefile.am b/src/Main/Makefile.am index e8c2c3d34..90b1d5d96 100644 --- a/src/Main/Makefile.am +++ b/src/Main/Makefile.am @@ -67,10 +67,10 @@ fgfs_LDADD = \ $(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 \ diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index caf1d0216..b5c3f1afe 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -97,6 +97,7 @@ #include #include #include +#include // #include #include #include @@ -1025,6 +1026,12 @@ bool fgInitSubsystems( void ) { globals->get_systemmgr()->init(); globals->get_systemmgr()->bind(); + //////////////////////////////////////////////////////////////////// + // Initialize the instrumentation. + //////////////////////////////////////////////////////////////////// + globals->get_instrumentmgr()->init(); + globals->get_instrumentmgr()->bind(); + //////////////////////////////////////////////////////////////////// // Initialize the radio stack subsystem. //////////////////////////////////////////////////////////////////// diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index 86a3bcb5b..a8c9d4751 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -24,6 +24,7 @@ #include #include +#include #include #include "globals.hxx" @@ -51,6 +52,7 @@ FGGlobals::FGGlobals() : warp_delta( 0 ), logger(0), systemmgr(new FGSystemMgr), + instrumentmgr(new FGInstrumentMgr), props(new SGPropertyNode), initial_state(0), commands(new SGCommandMgr), diff --git a/src/Main/globals.hxx b/src/Main/globals.hxx index b0995524d..4346f6e6a 100644 --- a/src/Main/globals.hxx +++ b/src/Main/globals.hxx @@ -60,6 +60,7 @@ class FGControls; class FGSteam; class FGSoundMgr; class FGSystemMgr; +class FGInstrumentMgr; class FGAutopilot; class FGFX; class FGViewMgr; @@ -136,6 +137,9 @@ private: // aircraft system manager FGSystemMgr * systemmgr; + // aircraft instrument manager + FGInstrumentMgr * instrumentmgr; + // environment information FGEnvironmentMgr * environment_mgr; @@ -253,6 +257,8 @@ public: 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; } diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 3e7b97598..67f97a319 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -119,6 +119,7 @@ SG_USING_STD(endl); # include #endif #include +#include #include