]> git.mxchange.org Git - flightgear.git/commitdiff
Flattened src/Systems/ subtree.
authordavid <david>
Tue, 24 Sep 2002 14:51:37 +0000 (14:51 +0000)
committerdavid <david>
Tue, 24 Sep 2002 14:51:37 +0000 (14:51 +0000)
Added src/Instrumentation/ with partial stab at a vacuum-driven
attitude indicator.

16 files changed:
configure.ac
src/Instrumentation/Makefile.am [new file with mode: 0644]
src/Instrumentation/attitude_indicator.cxx [new file with mode: 0644]
src/Instrumentation/attitude_indicator.hxx [new file with mode: 0644]
src/Instrumentation/instrument_mgr.cxx [new file with mode: 0644]
src/Instrumentation/instrument_mgr.hxx [new file with mode: 0644]
src/Main/Makefile.am
src/Main/fg_init.cxx
src/Main/globals.cxx
src/Main/globals.hxx
src/Main/main.cxx
src/Makefile.am
src/Systems/Makefile.am
src/Systems/system_mgr.cxx
src/Systems/vacuum.cxx [new file with mode: 0644]
src/Systems/vacuum.hxx [new file with mode: 0644]

index 1ff028228f7113056006d47aefeb74259fcdd868..528f070d5ac7fe355e3547d1134ff3df23d69429 100644 (file)
@@ -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 (file)
index 0000000..e66685e
--- /dev/null
@@ -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 (file)
index 0000000..f48eda7
--- /dev/null
@@ -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 <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
diff --git a/src/Instrumentation/attitude_indicator.hxx b/src/Instrumentation/attitude_indicator.hxx
new file mode 100644 (file)
index 0000000..81ad86a
--- /dev/null
@@ -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 <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
diff --git a/src/Instrumentation/instrument_mgr.cxx b/src/Instrumentation/instrument_mgr.cxx
new file mode 100644 (file)
index 0000000..f330856
--- /dev/null
@@ -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 (file)
index 0000000..6e0bf4d
--- /dev/null
@@ -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 <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
index e8c2c3d349910334e446609cb0c8183a2aeeb403..90b1d5d96774aff9747e41cc397352bd434f1647 100644 (file)
@@ -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 \
index caf1d0216f613dc5e27d5ada86180e297094e9c1..b5c3f1afe35d28129909201e2a5af0535e02e161 100644 (file)
@@ -97,6 +97,7 @@
 #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>
@@ -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.
     ////////////////////////////////////////////////////////////////////
index 86a3bcb5b545b5e3a8c7c298c438d69e62868de2..a8c9d475145264c60b9ffa317ff47a284d135656 100644 (file)
@@ -24,6 +24,7 @@
 #include <simgear/misc/commands.hxx>
 
 #include <Environment/environment_mgr.hxx>
+#include <Instrumentation/instrument_mgr.hxx>
 #include <Systems/system_mgr.hxx>
 
 #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),
index b0995524d96487c3ed7ae7df60b6a4e9c6168048..4346f6e6a88c672ccd7b7a55879ca74fcb39f6a1 100644 (file)
@@ -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; }
 
index 3e7b9759803a2e1d1ffe51e98b1e5955b0f40360..67f97a319d7c559c73478d27f69ea54ca17636a5 100644 (file)
@@ -119,6 +119,7 @@ SG_USING_STD(endl);
 #  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>
@@ -1140,6 +1141,7 @@ static void fgMainLoop( void ) {
 #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.
index ba84d64872f1c6889bb88fbc61ac1a5fea21c055..e2eceacfc8527f0f3f253ab1054a43a3cccc9bb8 100644 (file)
@@ -21,6 +21,7 @@ SUBDIRS = \
         FDM \
         GUI \
         Input \
+       Instrumentation \
         Model \
         Navaids \
         $(NETWORK_DIRS) \
index 253408590187be298789f599b0d3f37ed2ddf288..15d9b863e768cd95258c3e194c91beed5cc4af1f 100644 (file)
@@ -1,7 +1,6 @@
-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
index b6ec4d44e108f6a857594a1512526dc0e058b16c..0feedc134512d7f700f1906a567d97bf07f4cb6e 100644 (file)
@@ -5,7 +5,7 @@
 
 
 #include "system_mgr.hxx"
-#include "Vacuum/vacuum.hxx"
+#include "vacuum.hxx"
 
 
 FGSystemMgr::FGSystemMgr ()
diff --git a/src/Systems/vacuum.cxx b/src/Systems/vacuum.cxx
new file mode 100644 (file)
index 0000000..19bde57
--- /dev/null
@@ -0,0 +1,58 @@
+// 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
diff --git a/src/Systems/vacuum.hxx b/src/Systems/vacuum.hxx
new file mode 100644 (file)
index 0000000..197b1d1
--- /dev/null
@@ -0,0 +1,55 @@
+// 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