Flattened src/Systems/ subtree.
Added src/Instrumentation/ with partial stab at a vacuum-driven attitude indicator.
This commit is contained in:
parent
5becd2a1bd
commit
682feb8f2d
16 changed files with 383 additions and 6 deletions
|
@ -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 \
|
||||
|
|
6
src/Instrumentation/Makefile.am
Normal file
6
src/Instrumentation/Makefile.am
Normal file
|
@ -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
|
76
src/Instrumentation/attitude_indicator.cxx
Normal file
76
src/Instrumentation/attitude_indicator.cxx
Normal file
|
@ -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
|
61
src/Instrumentation/attitude_indicator.hxx
Normal file
61
src/Instrumentation/attitude_indicator.hxx
Normal file
|
@ -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
|
54
src/Instrumentation/instrument_mgr.cxx
Normal file
54
src/Instrumentation/instrument_mgr.cxx
Normal file
|
@ -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
|
50
src/Instrumentation/instrument_mgr.hxx
Normal file
50
src/Instrumentation/instrument_mgr.hxx
Normal file
|
@ -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
|
|
@ -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 \
|
||||
|
|
|
@ -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.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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; }
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -21,6 +21,7 @@ SUBDIRS = \
|
|||
FDM \
|
||||
GUI \
|
||||
Input \
|
||||
Instrumentation \
|
||||
Model \
|
||||
Navaids \
|
||||
$(NETWORK_DIRS) \
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
|
||||
#include "system_mgr.hxx"
|
||||
#include "Vacuum/vacuum.hxx"
|
||||
#include "vacuum.hxx"
|
||||
|
||||
|
||||
FGSystemMgr::FGSystemMgr ()
|
||||
|
|
58
src/Systems/vacuum.cxx
Normal file
58
src/Systems/vacuum.cxx
Normal file
|
@ -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
|
55
src/Systems/vacuum.hxx
Normal file
55
src/Systems/vacuum.hxx
Normal file
|
@ -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
|
Loading…
Add table
Reference in a new issue