// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#include <Main/fgfs.hxx>
+#include <simgear/misc/sg_path.hxx>
+
#include <Main/fg_props.hxx>
#include <Main/globals.hxx>
-#include <simgear/misc/sg_path.hxx>
#include <list>
#ifndef _FG_AIMGR_HXX
#define _FG_AIMGR_HXX
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
+
#include <Main/fg_props.hxx>
#include <list>
SG_USING_STD(list);
-class FGAIMgr : public FGSubsystem
+class FGAIMgr : public SGSubsystem
{
private:
#include <simgear/sound/soundmgr.hxx>
-#include <Main/fgfs.hxx>
#include <Main/fg_props.hxx>
#include "ATC.hxx"
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#include <simgear/structure/commands.hxx>
+
#include <Main/globals.hxx>
-#include <Main/fgfs.hxx>
#include <GUI/gui.h>
-#include <simgear/misc/commands.hxx>
#include "ATCDialog.hxx"
#include "ATC.hxx"
# include <config.h>
#endif
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
#include <vector>
#include <string>
typedef vector<atcMessage> atcMessageList;
typedef atcMessageList::iterator atcMessageListIterator;
-class FGATCDisplay : public FGSubsystem
+class FGATCDisplay : public SGSubsystem
{
private:
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//#include <Time/event.hxx>
-
#include <simgear/misc/sg_path.hxx>
#include <simgear/debug/logstream.hxx>
#include <Airports/simple.hxx>
globals->get_ATC_mgr()->Search();
}
*/ //This wouldn't compile - including Time/event.hxx breaks it :-(
+ // Is this still true?? -EMH-
AirportATC::AirportATC() :
lon(0.0),
atc_list_itr = atc_list.begin();
// Search for connected ATC stations once per 0.8 seconds or so
- // global_events.Register( "fgATCSearch()", fgATCSearch,
- // fgEVENT::FG_EVENT_READY, 800);
+ // globals->get_event_mgr()->add( "fgATCSearch()", fgATCSearch,
+ // FGEvent::FG_EVENT_READY, 800);
+ //
// For some reason the above doesn't compile - including Time/event.hxx stops compilation.
+ // Is this still true after the reorganization of the event managar??
+ // -EMH-
// Initialise the frequency search map
current_commlist = new FGCommList;
#ifndef _FG_ATCMGR_HXX
#define _FG_ATCMGR_HXX
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
+
#include <Main/fg_props.hxx>
#include <GUI/gui.h>
bool set_by_comm[2]; // true when the relevant comm_freq has activated this station
};
-class FGATCMgr : public FGSubsystem
+class FGATCMgr : public SGSubsystem
{
private:
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/misc/sg_path.hxx>
-#include <simgear/misc/commands.hxx>
-#include <simgear/misc/exception.hxx>
+#include <simgear/structure/commands.hxx>
+#include <simgear/structure/exception.hxx>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#include <Cockpit/panel_io.hxx>
#include <Model/acmodel.hxx>
#include <Autopilot/newauto.hxx>
-#include <Main/fgfs.hxx>
#include "aircraft.hxx"
#include <simgear/props/props.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/route/waypoint.hxx>
-#include <Main/fgfs.hxx>
#include <Main/fg_props.hxx>
// Structures
-class FGAutopilot : public FGSubsystem
+class FGAutopilot : public SGSubsystem
{
public:
\f
////////////////////////////////////////////////////////////////////
- // Implementation of FGSubsystem.
+ // Implementation of SGSubsystem.
////////////////////////////////////////////////////////////////////
void init ();
#include <Navaids/ilslist.hxx>
#include <Navaids/mkrbeacons.hxx>
#include <Navaids/navlist.hxx>
-#include <Time/FGEventMgr.hxx>
#include "dme.hxx"
#define _FG_DME_HXX
-#include <Main/fgfs.hxx>
#include <Main/fg_props.hxx>
#include <simgear/compiler.h>
-
+#include <simgear/structure/subsystem_mgr.hxx>
// #include <simgear/math/interpolater.hxx>
#include <simgear/timing/timestamp.hxx>
// #include "kt_70.hxx" // Transponder
// #include "navcom.hxx"
-class FGDME : public FGSubsystem
+class FGDME : public SGSubsystem
{
SGPropertyNode *lon_node;
SGPropertyNode *lat_node;
// $Id$
#include <simgear/compiler.h>
-#include <simgear/misc/exception.hxx>
+#include <simgear/structure/exception.hxx>
#include STL_STRING
#include STL_FSTREAM
#include <Aircraft/aircraft.hxx>
#include <Navaids/navlist.hxx>
-#include <Time/FGEventMgr.hxx>
#include "kr_87.hxx"
#define _FG_KR_87_HXX
-#include <Main/fgfs.hxx>
#include <Main/fg_props.hxx>
#include <simgear/compiler.h>
-
+#include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/timing/timestamp.hxx>
#include <Navaids/navlist.hxx>
#include <Sound/morse.hxx>
-class FGKR_87 : public FGSubsystem
+class FGKR_87 : public SGSubsystem
{
FGMorse morse;
#define _FG_KT_70_HXX
-#include <Main/fgfs.hxx>
#include <Main/fg_props.hxx>
#include <simgear/compiler.h>
-
+#include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/math/interpolater.hxx>
#include <simgear/timing/timestamp.hxx>
#include <Sound/morse.hxx>
-class FGKT_70 : public FGSubsystem
+class FGKT_70 : public SGSubsystem
{
SGPropertyNode *lon_node;
SGPropertyNode *lat_node;
#include <Aircraft/aircraft.hxx>
#include <Navaids/mkrbeacons.hxx>
-#include <Time/FGEventMgr.hxx>
#include "marker_beacon.hxx"
#define _FG_MARKER_BEACON_HXX
-#include <Main/fgfs.hxx>
#include <Main/fg_props.hxx>
#include <simgear/compiler.h>
-
+#include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/math/interpolater.hxx>
#include <simgear/timing/timestamp.hxx>
#include <Sound/morse.hxx>
-class FGMarkerBeacon : public FGSubsystem
+class FGMarkerBeacon : public SGSubsystem
{
FGBeacon beacon;
FGMorse morse;
#include <Aircraft/aircraft.hxx>
#include <Navaids/ilslist.hxx>
#include <Navaids/navlist.hxx>
-#include <Time/FGEventMgr.hxx>
#include "navcom.hxx"
#define _FG_NAVCOM_HXX
-#include <Main/fgfs.hxx>
#include <Main/fg_props.hxx>
#include <simgear/compiler.h>
-
+#include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/math/interpolater.hxx>
#include <simgear/timing/timestamp.hxx>
#include <Navaids/navlist.hxx>
#include <Sound/morse.hxx>
-class FGNavCom : public FGSubsystem
+class FGNavCom : public SGSubsystem
{
FGMorse morse;
# include <config.h>
#endif
-#include <simgear/compiler.h>
-
-#ifdef HAVE_WINDOWS_H
+#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif
#include <plib/ssg.h>
+#include <plib/fnt.h>
-#include <simgear/math/interpolater.hxx>
+#include <simgear/compiler.h>
#include <simgear/props/props.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
+#include <simgear/math/interpolater.hxx>
#include <simgear/timing/timestamp.hxx>
#include <cmath>
#include <vector>
#include <map>
-#include <plib/fnt.h>
-#include <Main/fgfs.hxx>
#include <Main/fg_props.hxx>
-
#include <Input/input.hxx>
SG_USING_STD(vector);
* redraw themselves when necessary, and will pass mouse clicks on to
* the appropriate instruments for processing.
*/
-class FGPanel : public FGSubsystem
+class FGPanel : public SGSubsystem
{
public:
#include <string.h> // for strcmp()
#include <simgear/compiler.h>
-#include <simgear/misc/exception.hxx>
-
+#include <simgear/structure/exception.hxx>
#include <simgear/debug/logstream.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/props/props.hxx>
#include <Navaids/ilslist.hxx>
#include <Navaids/mkrbeacons.hxx>
#include <Navaids/navlist.hxx>
-#include <Time/FGEventMgr.hxx>
#include "radiostack.hxx"
update(0); // FIXME: use dt
// Search radio database once per second
- global_events.Register( "fgRadioSearch()",
- current_radiostack, &FGRadioStack::search,
- 1000 );
+ globals->get_event_mgr()->add( "fgRadioSearch()", current_radiostack,
+ &FGRadioStack::search, 1000 );
}
#define _FG_RADIOSTACK_HXX
-#include <Main/fgfs.hxx>
#include <Main/fg_props.hxx>
#include <simgear/compiler.h>
-
+#include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/math/interpolater.hxx>
#include <simgear/timing/timestamp.hxx>
#include "navcom.hxx"
-class FGRadioStack : public FGSubsystem
+class FGRadioStack : public SGSubsystem
{
FGDME dme;
FGKR_87 adf; // King KR 87 Digital ADF model
#define _CONTROLS_HXX
#include <simgear/props/props.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
-#include <Main/fgfs.hxx>
#include <Main/globals.hxx>
#ifndef __cplusplus
// Define a structure containing the control parameters
-class FGControls : public FGSubsystem
+class FGControls : public SGSubsystem
{
public:
FGControls();
~FGControls();
- // Implementation of FGSubsystem.
+ // Implementation of SGSubsystem.
void init ();
void bind ();
void unbind ();
#include <simgear/compiler.h>
-#include <Main/fgfs.hxx>
-
#ifdef SG_HAVE_STD_INCLUDES
# include <cmath>
#else
#define _ENVIRONMENT_CTRL_HXX
#include <simgear/compiler.h>
+#include <simgear/structure/subsystem_mgr.hxx>
#ifdef SG_HAVE_STD_INCLUDES
# include <cmath>
class SGPropertyNode;
-#include <Main/fgfs.hxx>
-
#include "environment.hxx"
/**
* Interface to control environment information for a specific location.
*/
-class FGEnvironmentCtrl : public FGSubsystem
+class FGEnvironmentCtrl : public SGSubsystem
{
public:
FGEnvironmentMgr::init ()
{
SG_LOG( SG_GENERAL, SG_INFO, "Initializing environment subsystem");
- FGSubsystemGroup::init();
+ SGSubsystemGroup::init();
_update_fdm();
}
FGEnvironmentMgr::reinit ()
{
SG_LOG( SG_GENERAL, SG_INFO, "Reinitializing environment subsystem");
- FGSubsystemGroup::reinit();
+ SGSubsystemGroup::reinit();
_update_fdm();
}
void
FGEnvironmentMgr::update (double dt)
{
- FGSubsystemGroup::update(dt);
+ SGSubsystemGroup::update(dt);
// FIXME: the FDMs should update themselves
current_aircraft.fdm_state
#define _ENVIRONMENT_MGR_HXX
#include <simgear/compiler.h>
-
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
#ifdef SG_HAVE_STD_INCLUDES
# include <cmath>
/**
* Manage environment information.
*/
-class FGEnvironmentMgr : public FGSubsystemGroup
+class FGEnvironmentMgr : public SGSubsystemGroup
{
public:
*/
-#include <simgear/compiler.h>
-
#include <math.h>
#include <list>
#include <vector>
#include <string>
+#include <simgear/compiler.h>
#include <simgear/constants.h>
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
SG_USING_STD(list);
SG_USING_STD(vector);
typedef double FG_VECTOR_3[3];
// This is based heavily on LaRCsim/ls_generic.h
-class FGInterface : public FGSubsystem {
+class FGInterface : public SGSubsystem {
private:
# include <windows.h>
#endif
-#include <simgear/misc/exception.hxx>
+#include <simgear/structure/exception.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/props/props.hxx>
#include <simgear/props/props_io.hxx>
#include <plib/pu.h> // plib include
-#include <simgear/misc/exception.hxx>
+#include <simgear/structure/exception.hxx>
#define TR_HIRES_SNAP 1
#include <plib/ul.h>
#include <simgear/compiler.h>
-#include <simgear/misc/exception.hxx>
+#include <simgear/structure/exception.hxx>
+
#include <Main/fg_props.hxx>
#include "menubar.hxx"
#include <simgear/compiler.h> // for SG_USING_STD
#include <simgear/props/props.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
#include <vector>
SG_USING_STD(vector);
#include <map>
SG_USING_STD(map);
-#include <Main/fgfs.hxx>
#include <Main/fg_props.hxx>
class FGMenuBar;
* for XML-configured dialog boxes found in $FG_ROOT/gui/dialogs/. It
* can show or hide the menubar, and can display any dialog by name.
*/
-class NewGUI : public FGSubsystem
+class NewGUI : public SGSubsystem
{
public:
# include <windows.h>
#endif
-#include <simgear/misc/commands.hxx>
+#include <simgear/structure/commands.hxx>
#include <simgear/misc/sg_path.hxx>
#include <Main/fg_props.hxx>
config.h.in \
config.h-msvc6 \
cmdargs.h \
- fg_callback.hxx \
fg_typedefs.h \
fg_stl_config.h \
general.hxx
#include <simgear/compiler.h>
-#include <simgear/misc/commands.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
+#include <simgear/structure/commands.hxx>
#include <simgear/props/condition.hxx>
#include <simgear/props/props.hxx>
-#include <Main/fgfs.hxx>
#include <Main/fg_props.hxx>
#include <Main/globals.hxx>
* keyboard, joystick, mouse, or even panel switches -- in a consistent
* way, and to allow users to rebind any of the actions at runtime.</p>
*/
-class FGInput : public FGSubsystem
+class FGInput : public SGSubsystem
{
public:
virtual ~FGInput();
//
- // Implementation of FGSubsystem.
+ // Implementation of SGSubsystem.
//
virtual void init ();
virtual void update (double dt);
#endif
#include <simgear/props/props.hxx>
-
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
/**
*
* /instrumentation/airspeed-indicator/indicated-speed-kt
*/
-class AirspeedIndicator : public FGSubsystem
+class AirspeedIndicator : public SGSubsystem
{
public:
#endif
#include <simgear/props/props.hxx>
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
class SGInterpTable;
*
* /instrumentation/altimeter/indicated-altitude-ft
*/
-class Altimeter : public FGSubsystem
+class Altimeter : public SGSubsystem
{
public:
#endif
#include <simgear/props/props.hxx>
-
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
/**
*
* /instrumentation/airspeed-indicator/indicated-speed-kt
*/
-class Annunciator : public FGSubsystem
+class Annunciator : public SGSubsystem
{
// timers
#endif
#include <simgear/props/props.hxx>
-
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
#include "gyro.hxx"
* /instrumentation/attitude-indicator/indicated-roll-deg
* /instrumentation/attitude-indicator/tumble-norm
*/
-class AttitudeIndicator : public FGSubsystem
+class AttitudeIndicator : public SGSubsystem
{
public:
#endif
#include <simgear/props/props.hxx>
-
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
/**
* /instrumentation/clock/indicated-sec
* /instrumentation/clock/indicated-string
*/
-class Clock : public FGSubsystem
+class Clock : public SGSubsystem
{
public:
#include <simgear/math/point3d.hxx>
#include <simgear/props/props.hxx>
-
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
/**
* /instrumentation/dme/indicated-ground-speed-kt
* /instrumentation/dme/indicated-time-kt
*/
-class DME : public FGSubsystem
+class DME : public SGSubsystem
{
public:
#endif
#include <simgear/props/props.hxx>
-
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
/**
* /instrumentation/gps/indicated-track-magnetic-deg
* /instrumentation/gps/indicated-ground-speed-kt
*/
-class GPS : public FGSubsystem
+class GPS : public SGSubsystem
{
public:
#endif
#include <simgear/props/props.hxx>
-
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
#include "gyro.hxx"
*
* /instrumentation/heading-indicator/indicated-heading-deg
*/
-class HeadingIndicator : public FGSubsystem
+class HeadingIndicator : public SGSubsystem
{
public:
#endif
#include <simgear/compiler.h>
-
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
/**
* In the initial draft, the instruments present are hard-coded, but they
* will soon be configurable for individual aircraft.
*/
-class FGInstrumentMgr : public FGSubsystemGroup
+class FGInstrumentMgr : public SGSubsystemGroup
{
public:
#endif
#include <simgear/props/props.hxx>
-
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
/**
*
* /instrumentation/magnetic-compass/indicated-heading-deg
*/
-class MagCompass : public FGSubsystem
+class MagCompass : public SGSubsystem
{
public:
#endif
#include <simgear/props/props.hxx>
-
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
#include "gyro.hxx"
*
* /instrumentation/slip-skid-ball/indicated-slip-skid
*/
-class SlipSkidBall : public FGSubsystem
+class SlipSkidBall : public SGSubsystem
{
public:
#endif
#include <simgear/props/props.hxx>
-
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
#include "gyro.hxx"
*
* /instrumentation/turn-indicator/indicated-turn-rate
*/
-class TurnIndicator : public FGSubsystem
+class TurnIndicator : public SGSubsystem
{
public:
#endif
#include <simgear/props/props.hxx>
-
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
/**
*
* /instrumentation/vertical-speed-indicator/indicated-speed-fpm
*/
-class VerticalSpeedIndicator : public FGSubsystem
+class VerticalSpeedIndicator : public SGSubsystem
{
public:
fg_init.cxx fg_init.hxx \
fg_io.cxx fg_io.hxx \
fg_props.cxx fg_props.hxx \
- fgfs.cxx fgfs.hxx \
globals.cxx globals.hxx \
logger.cxx logger.hxx \
options.cxx options.hxx \
$(CLOUD3D_LIBS) \
-lsgroute -lsgsky -lsgsound -lsgephem -lsgmaterial -lsgtgdb -lsgmodel \
-lsgtiming -lsgio -lsgscreen -lsgmath -lsgbucket -lsgprops -lsgdebug \
- -lsgmagvar -lsgmisc -lsgxml -lsgsound -lsgserial \
+ -lsgmagvar -lsgmisc -lsgxml -lsgsound -lsgserial -lsgstructure \
$(THREAD_LIBS) \
-lplibpu -lplibfnt -lplibjs -lplibnet -lplibssg -lplibsg -lplibul \
$(network_LIBS) \
#include <stdlib.h>
#include <simgear/compiler.h>
-#include <simgear/misc/exception.hxx>
+#include <simgear/structure/exception.hxx>
#include <simgear/debug/logstream.hxx>
#include STL_IOSTREAM
#include <string.h> // strcmp()
#include <simgear/compiler.h>
-#include <simgear/misc/exception.hxx>
#include STL_STRING
#include STL_FSTREAM
#include <simgear/sg_inlines.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/sg_random.h>
-#include <simgear/misc/commands.hxx>
+#include <simgear/structure/exception.hxx>
+#include <simgear/structure/commands.hxx>
#include <simgear/props/props.hxx>
#include <Cockpit/panel.hxx>
} else {
for ( unsigned int i = 0; i < subsystems.size(); i++ ) {
const char * name = subsystems[i]->getStringValue();
- FGSubsystem * subsystem = globals->get_subsystem(name);
+ SGSubsystem * subsystem = globals->get_subsystem(name);
if (subsystem == 0) {
result = false;
SG_LOG( SG_GENERAL, SG_ALERT,
}
}
+ globals->get_event_mgr()->reinit();
+
return result;
}
vector<SGPropertyNode_ptr> subsystems = arg->getChildren("subsystem");
for ( unsigned int i = 0; i < subsystems.size(); i++ ) {
const char * name = subsystems[i]->getStringValue();
- FGSubsystem * subsystem = globals->get_subsystem(name);
+ SGSubsystem * subsystem = globals->get_subsystem(name);
if (subsystem == 0) {
result = false;
SG_LOG(SG_GENERAL, SG_ALERT, "Subsystem " << name << "not found");
vector<SGPropertyNode_ptr> subsystems = arg->getChildren("subsystem");
for ( unsigned int i = 0; i < subsystems.size(); i++ ) {
const char * name = subsystems[i]->getStringValue();
- FGSubsystem * subsystem = globals->get_subsystem(name);
+ SGSubsystem * subsystem = globals->get_subsystem(name);
if (subsystem == 0) {
result = false;
SG_LOG(SG_GENERAL, SG_ALERT, "Subsystem " << name << "not found");
# include <windows.h>
#endif
-#include <simgear/misc/commands.hxx>
+#include <simgear/structure/commands.hxx>
#include <simgear/props/props.hxx>
/**
#endif
#include <simgear/compiler.h>
-#include <simgear/misc/exception.hxx>
#include STL_STRING
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
+#include <simgear/structure/exception.hxx>
+#include <simgear/structure/event_mgr.hxx>
#include <simgear/math/point3d.hxx>
#include <simgear/math/polar3d.hxx>
#include <simgear/math/sg_geodesy.hxx>
#endif
#include <Sound/fg_fx.hxx>
#include <Systems/system_mgr.hxx>
-#include <Time/FGEventMgr.hxx>
#include <Time/light.hxx>
#include <Time/moonpos.hxx>
#include <Time/sunpos.hxx>
SG_LOG( SG_GENERAL, SG_INFO, "Initialize Subsystems");
SG_LOG( SG_GENERAL, SG_INFO, "========== ==========");
+ ////////////////////////////////////////////////////////////////////
+ // Initialize the event manager subsystem.
+ ////////////////////////////////////////////////////////////////////
+
+ globals->get_event_mgr()->bind();
+ globals->get_event_mgr()->init();
+
+ // Output event stats every 60 seconds
+ globals->get_event_mgr()->add( "SGEventMgr::print_stats()",
+ globals->get_event_mgr(),
+ &SGEventMgr::print_stats,
+ 60000 );
////////////////////////////////////////////////////////////////////
// Initialize the material property subsystem.
exit(-1);
}
- ////////////////////////////////////////////////////////////////////
- // Initialize the event manager subsystem.
- ////////////////////////////////////////////////////////////////////
-
- global_events.init();
-
- // Output event stats every 60 seconds
- global_events.Register( "FGEventMgr::print_stats()",
- &global_events, &FGEventMgr::print_stats,
- 60000 );
-
////////////////////////////////////////////////////////////////////
// Initialize the scenery management subsystem.
}
// cause refresh of viewer scenery timestamps every 15 seconds...
- global_events.Register( "FGTileMgr::refresh_view_timestamps()",
- globals->get_tile_mgr(),
- &FGTileMgr::refresh_view_timestamps,
- 15000 );
+ globals->get_event_mgr()->add( "FGTileMgr::refresh_view_timestamps()",
+ globals->get_tile_mgr(),
+ &FGTileMgr::refresh_view_timestamps,
+ 15000 );
SG_LOG( SG_GENERAL, SG_DEBUG,
"Current terrain elevation after tile mgr init " <<
fgInitView();
- ////////////////////////////////////////////////////////////////////
- // Initialize the lighting subsystem.
- ////////////////////////////////////////////////////////////////////
-
- globals->add_subsystem("lighting", new FGLight);
-
////////////////////////////////////////////////////////////////////
// Create and register the logger.
////////////////////////////////////////////////////////////////////
// Create and register the XML GUI.
////////////////////////////////////////////////////////////////////
- globals->add_subsystem("gui", new NewGUI, FGSubsystemMgr::INIT);
+ globals->add_subsystem("gui", new NewGUI, SGSubsystemMgr::INIT);
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// update the current timezone each 30 minutes
- global_events.Register( "fgUpdateLocalTime()", &fgUpdateLocalTime,
- 30*60*1000 );
+ globals->get_event_mgr()->add( "fgUpdateLocalTime()",
+ &fgUpdateLocalTime, 30*60*1000 );
////////////////////////////////////////////////////////////////////
WeatherDatabase = FGLocalWeatherDatabase::theFGLocalWeatherDatabase;
// register the periodic update of the weather
- global_events.Register( "weather update", &fgUpdateWeatherDatabase,
- 30000);
+ globals->get_event_mgr()->add( "weather update",
+ &fgUpdateWeatherDatabase, 30000);
#else
globals->add_subsystem("environment", new FGEnvironmentMgr);
#endif
+
+ ////////////////////////////////////////////////////////////////////
+ // Initialize the lighting subsystem.
+ ////////////////////////////////////////////////////////////////////
+
+ globals->add_subsystem("lighting", new FGLight);
+
+
#ifdef FG_USE_CLOUDS_3D
////////////////////////////////////////////////////////////////////
// Initialize the 3D cloud subsystem.
globals->get_subsystem_mgr()->bind();
globals->get_subsystem_mgr()->init();
-
#ifdef FG_MPLAYER_AS
////////////////////////////////////////////////////////////////////
// Initialize multiplayer subsystem
#include <simgear/compiler.h>
+#include <simgear/structure/subsystem_mgr.hxx>
+
#include <vector>
#include STL_STRING
-#include "fgfs.hxx"
-
SG_USING_STD(vector);
SG_USING_STD(string);
class FGProtocol;
-class FGIO : public FGSubsystem
+class FGIO : public SGSubsystem
{
public:
FGIO();
# include <simgear/compiler.h>
#endif
-#include <simgear/misc/exception.hxx>
+#include <simgear/structure/exception.hxx>
#include <simgear/magvar/magvar.hxx>
#include <simgear/timing/sg_time.hxx>
#include <simgear/misc/sg_path.hxx>
#include <GUI/gui.h>
#include "globals.hxx"
-#include "fgfs.hxx"
#include "fg_props.hxx"
SG_USING_STD(istream);
+++ /dev/null
-#include "fgfs.hxx"
-
-#include <simgear/debug/logstream.hxx>
-#include <simgear/misc/exception.hxx>
-
-#include "globals.hxx"
-#include "fg_props.hxx"
-
-
-\f
-////////////////////////////////////////////////////////////////////////
-// Implementation of FGSubsystem
-////////////////////////////////////////////////////////////////////////
-
-
-FGSubsystem::FGSubsystem ()
- : _suspended(false)
-{
-}
-
-FGSubsystem::~FGSubsystem ()
-{
-}
-
-void
-FGSubsystem::init ()
-{
-}
-
-void
-FGSubsystem::reinit ()
-{
-}
-
-void
-FGSubsystem::bind ()
-{
-}
-
-void
-FGSubsystem::unbind ()
-{
-}
-
-void
-FGSubsystem::suspend ()
-{
- _suspended = true;
-}
-
-void
-FGSubsystem::suspend (bool suspended)
-{
- _suspended = suspended;
-}
-
-void
-FGSubsystem::resume ()
-{
- _suspended = false;
-}
-
-bool
-FGSubsystem::is_suspended () const
-{
- if (!_freeze_master_node.valid())
- _freeze_master_node = fgGetNode("/sim/freeze/master", true);
- return _suspended || _freeze_master_node->getBoolValue();
-}
-
-
-\f
-////////////////////////////////////////////////////////////////////////
-// Implementation of FGSubsystemGroup.
-////////////////////////////////////////////////////////////////////////
-
-FGSubsystemGroup::FGSubsystemGroup ()
-{
-}
-
-FGSubsystemGroup::~FGSubsystemGroup ()
-{
- for (unsigned int i = 0; i < _members.size(); i++)
- delete _members[i];
-}
-
-void
-FGSubsystemGroup::init ()
-{
- for (unsigned int i = 0; i < _members.size(); i++)
- _members[i]->subsystem->init();
-}
-
-void
-FGSubsystemGroup::reinit ()
-{
- for (unsigned int i = 0; i < _members.size(); i++)
- _members[i]->subsystem->reinit();
-}
-
-void
-FGSubsystemGroup::bind ()
-{
- for (unsigned int i = 0; i < _members.size(); i++)
- _members[i]->subsystem->bind();
-}
-
-void
-FGSubsystemGroup::unbind ()
-{
- for (unsigned int i = 0; i < _members.size(); i++)
- _members[i]->subsystem->unbind();
-}
-
-void
-FGSubsystemGroup::update (double delta_time_sec)
-{
- for (unsigned int i = 0; i < _members.size(); i++)
- _members[i]->update(delta_time_sec); // indirect call
-}
-
-void
-FGSubsystemGroup::suspend ()
-{
- for (unsigned int i = 0; i < _members.size(); i++)
- _members[i]->subsystem->suspend();
-}
-
-void
-FGSubsystemGroup::resume ()
-{
- for (unsigned int i = 0; i < _members.size(); i++)
- _members[i]->subsystem->resume();
-}
-
-bool
-FGSubsystemGroup::is_suspended () const
-{
- return false;
-}
-
-void
-FGSubsystemGroup::set_subsystem (const string &name, FGSubsystem * subsystem,
- double min_step_sec)
-{
- Member * member = get_member(name, true);
- if (member->subsystem != 0)
- delete member->subsystem;
- member->name = name;
- member->subsystem = subsystem;
- member->min_step_sec = min_step_sec;
-}
-
-FGSubsystem *
-FGSubsystemGroup::get_subsystem (const string &name)
-{
- Member * member = get_member(name);
- if (member != 0)
- return member->subsystem;
- else
- return 0;
-}
-
-void
-FGSubsystemGroup::remove_subsystem (const string &name)
-{
- for (unsigned int i = 0; i < _members.size(); i++) {
- if (name == _members[i]->name) {
- _members.erase(_members.begin() + i);
- return;
- }
- }
-}
-
-bool
-FGSubsystemGroup::has_subsystem (const string &name) const
-{
- return (((FGSubsystemGroup *)this)->get_member(name) != 0);
-}
-
-FGSubsystemGroup::Member *
-FGSubsystemGroup::get_member (const string &name, bool create)
-{
- for (unsigned int i = 0; i < _members.size(); i++) {
- if (_members[i]->name == name)
- return _members[i];
- }
- if (create) {
- Member * member = new Member;
- _members.push_back(member);
- return member;
- } else {
- return 0;
- }
-}
-
-
-\f
-////////////////////////////////////////////////////////////////////////
-// Implementation of FGSubsystemGroup::Member
-////////////////////////////////////////////////////////////////////////
-
-
-FGSubsystemGroup::Member::Member ()
- : name(""),
- subsystem(0),
- min_step_sec(0),
- elapsed_sec(0)
-{
-}
-
-FGSubsystemGroup::Member::Member (const Member &)
-{
- Member();
-}
-
-FGSubsystemGroup::Member::~Member ()
-{
- // FIXME: causes a crash
-// delete subsystem;
-}
-
-void
-FGSubsystemGroup::Member::update (double delta_time_sec)
-{
- elapsed_sec += delta_time_sec;
- if (elapsed_sec >= min_step_sec) {
- if (!subsystem->is_suspended()) {
- subsystem->update(elapsed_sec);
- elapsed_sec = 0;
- }
- }
-}
-
-
-\f
-////////////////////////////////////////////////////////////////////////
-// Implementation of FGSubsystemMgr.
-////////////////////////////////////////////////////////////////////////
-
-
-FGSubsystemMgr::FGSubsystemMgr ()
-{
-}
-
-FGSubsystemMgr::~FGSubsystemMgr ()
-{
-}
-
-void
-FGSubsystemMgr::init ()
-{
- for (int i = 0; i < MAX_GROUPS; i++)
- _groups[i].init();
-}
-
-void
-FGSubsystemMgr::reinit ()
-{
- for (int i = 0; i < MAX_GROUPS; i++)
- _groups[i].reinit();
-}
-
-void
-FGSubsystemMgr::bind ()
-{
- for (int i = 0; i < MAX_GROUPS; i++)
- _groups[i].bind();
-}
-
-void
-FGSubsystemMgr::unbind ()
-{
- for (int i = 0; i < MAX_GROUPS; i++)
- _groups[i].unbind();
-}
-
-void
-FGSubsystemMgr::update (double delta_time_sec)
-{
- for (int i = 0; i < MAX_GROUPS; i++) {
- _groups[i].update(delta_time_sec);
- }
-}
-
-void
-FGSubsystemMgr::suspend ()
-{
- for (int i = 0; i < MAX_GROUPS; i++)
- _groups[i].suspend();
-}
-
-void
-FGSubsystemMgr::resume ()
-{
- for (int i = 0; i < MAX_GROUPS; i++)
- _groups[i].resume();
-}
-
-bool
-FGSubsystemMgr::is_suspended () const
-{
- return false;
-}
-
-void
-FGSubsystemMgr::add (const char * name, FGSubsystem * subsystem,
- GroupType group, double min_time_sec)
-{
- SG_LOG(SG_GENERAL, SG_INFO, "Adding subsystem " << name);
- get_group(group)->set_subsystem(name, subsystem, min_time_sec);
-
- if (_subsystem_map.find(name) != _subsystem_map.end()) {
- SG_LOG(SG_GENERAL, SG_ALERT, "Adding duplicate subsystem " << name);
- throw sg_exception("duplicate subsystem");
- }
- _subsystem_map[name] = subsystem;
-}
-
-FGSubsystemGroup *
-FGSubsystemMgr::get_group (GroupType group)
-{
- return &(_groups[group]);
-}
-
-FGSubsystem *
-FGSubsystemMgr::get_subsystem (const string &name)
-{
- map<string,FGSubsystem *>::iterator s =_subsystem_map.find(name);
-
- if (s == _subsystem_map.end())
- return 0;
- else
- return s->second;
-}
-
-// end of fgfs.cxx
+++ /dev/null
-// fgfs.hxx -- top level include file for FlightGear.
-//
-// Written by David Megginson, started 2000-12
-//
-// Copyright (C) 2000 David Megginson, david@megginson.com
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-
-#ifndef __FGFS_HXX
-#define __FGFS_HXX 1
-
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <simgear/compiler.h>
-
-// #ifdef SG_MATH_EXCEPTION_CLASH
-// # include <math.h>
-// #endif
-
-#ifdef HAVE_WINDOWS_H
-# include <windows.h>
-# include <float.h>
-#endif
-
-#include STL_STRING
-SG_USING_STD(string);
-
-#include <vector>
-SG_USING_STD(vector);
-
-#include <map>
-SG_USING_STD(map);
-
-#include <simgear/props/props.hxx>
-
-
-\f
-/**
- * Basic interface for all FlightGear subsystems.
- *
- * <p>This is an abstract interface that all FlightGear subsystems
- * will eventually implement. It defines the basic operations for
- * each subsystem: initialization, property binding and unbinding, and
- * updating. Interfaces may define additional methods, but the
- * preferred way of exchanging information with other subsystems is
- * through the property tree.</p>
- *
- * <p>To publish information through a property, a subsystem should
- * bind it to a variable or (if necessary) a getter/setter pair in the
- * bind() method, and release the property in the unbind() method:</p>
- *
- * <pre>
- * void MySubsystem::bind ()
- * {
- * fgTie("/controls/flight/elevator", &_elevator);
- * fgSetArchivable("/controls/flight/elevator");
- * }
- *
- * void MySubsystem::unbind ()
- * {
- * fgUntie("/controls/flight/elevator");
- * }
- * </pre>
- *
- * <p>To reference a property (possibly) from another subsystem, there
- * are two alternatives. If the property will be referenced only
- * infrequently (say, in the init() method), then the fgGet* methods
- * declared in fg_props.hxx are the simplest:</p>
- *
- * <pre>
- * void MySubsystem::init ()
- * {
- * _errorMargin = fgGetFloat("/display/error-margin-pct");
- * }
- * </pre>
- *
- * <p>On the other hand, if the property will be referenced frequently
- * (say, in the update() method), then the hash-table lookup required
- * by the fgGet* methods might be too expensive; instead, the
- * subsystem should obtain a reference to the actual property node in
- * its init() function and use that reference in the main loop:</p>
- *
- * <pre>
- * void MySubsystem::init ()
- * {
- * _errorNode = fgGetNode("/display/error-margin-pct", true);
- * }
- *
- * void MySubsystem::update (double delta_time_sec)
- * {
- * do_something(_errorNode.getFloatValue());
- * }
- * </pre>
- *
- * <p>The node returned will always be a pointer to SGPropertyNode,
- * and the subsystem should <em>not</em> delete it in its destructor
- * (the pointer belongs to the property tree, not the subsystem).</p>
- *
- * <p>The program may ask the subsystem to suspend or resume
- * sim-time-dependent operations; by default, the suspend() and
- * resume() methods set the protected variable <var>_suspended</var>,
- * which the subsystem can reference in its update() method, but
- * subsystems may also override the suspend() and resume() methods to
- * take different actions.</p>
- */
-class FGSubsystem
-{
-public:
-
- /**
- * Default constructor.
- */
- FGSubsystem ();
-
- /**
- * Virtual destructor to ensure that subclass destructors are called.
- */
- virtual ~FGSubsystem ();
-
-
- /**
- * Initialize the subsystem.
- *
- * <p>This method should set up the state of the subsystem, but
- * should not bind any properties. Note that any dependencies on
- * the state of other subsystems should be placed here rather than
- * in the constructor, so that FlightGear can control the
- * initialization order.</p>
- */
- virtual void init ();
-
-
- /**
- * Reinitialize the subsystem.
- *
- * <p>This method should cause the subsystem to reinitialize itself,
- * and (normally) to reload any configuration files.</p>
- */
- virtual void reinit ();
-
-
- /**
- * Acquire the subsystem's property bindings.
- *
- * <p>This method should bind all properties that the subsystem
- * publishes. It will be invoked after init, but before any
- * invocations of update.</p>
- */
- virtual void bind ();
-
-
- /**
- * Release the subsystem's property bindings.
- *
- * <p>This method should release all properties that the subsystem
- * publishes. It will be invoked by FlightGear (not the destructor)
- * just before the subsystem is removed.</p>
- */
- virtual void unbind ();
-
-
- /**
- * Update the subsystem.
- *
- * <p>FlightGear invokes this method every time the subsystem should
- * update its state.</p>
- *
- * @param delta_time_sec The delta time, in seconds, since the last
- * update. On first update, delta time will be 0.
- */
- virtual void update (double delta_time_sec) = 0;
-
-
- /**
- * Suspend operation of this subsystem.
- *
- * <p>This method instructs the subsystem to suspend
- * sim-time-dependent operations until asked to resume. The update
- * method will still be invoked so that the subsystem can take any
- * non-time-dependent actions, such as updating the display.</p>
- *
- * <p>It is not an error for the suspend method to be invoked when
- * the subsystem is already suspended; the invocation should simply
- * be ignored.</p>
- */
- virtual void suspend ();
-
-
- /**
- * Suspend or resum operation of this subsystem.
- *
- * @param suspended true if the subsystem should be suspended, false
- * otherwise.
- */
- virtual void suspend (bool suspended);
-
-
- /**
- * Resume operation of this subsystem.
- *
- * <p>This method instructs the subsystem to resume
- * sim-time-depended operations. It is not an error for the resume
- * method to be invoked when the subsystem is not suspended; the
- * invocation should simply be ignored.</p>
- */
- virtual void resume ();
-
-
- /**
- * Test whether this subsystem is suspended.
- *
- * @return true if the subsystem is suspended, false if it is not.
- */
- virtual bool is_suspended () const;
-
-
-protected:
-
- mutable SGPropertyNode_ptr _freeze_master_node;
- bool _suspended;
-
-};
-
-
-\f
-/**
- * A group of FlightGear subsystems.
- */
-class FGSubsystemGroup : public FGSubsystem
-{
-public:
-
- FGSubsystemGroup ();
- virtual ~FGSubsystemGroup ();
-
- virtual void init ();
- virtual void reinit ();
- virtual void bind ();
- virtual void unbind ();
- virtual void update (double delta_time_sec);
- virtual void suspend ();
- virtual void resume ();
- virtual bool is_suspended () const;
-
- virtual void set_subsystem (const string &name,
- FGSubsystem * subsystem,
- double min_step_sec = 0);
- virtual FGSubsystem * get_subsystem (const string &name);
- virtual void remove_subsystem (const string &name);
- virtual bool has_subsystem (const string &name) const;
-
-private:
-
- struct Member {
-
- Member ();
- Member (const Member &member);
- virtual ~Member ();
-
- virtual void update (double delta_time_sec);
-
- string name;
- FGSubsystem * subsystem;
- double min_step_sec;
- double elapsed_sec;
- };
-
- Member * get_member (const string &name, bool create = false);
-
- vector<Member *> _members;
-};
-
-
-\f
-/**
- * Manage subsystems for FlightGear.
- *
- * This top-level subsystem will eventually manage all of the
- * subsystems in FlightGear: it broadcasts its life-cycle events
- * (init, bind, etc.) to all of the subsystems it manages. Subsystems
- * are grouped to guarantee order of initialization and execution --
- * currently, the only two groups are INIT and GENERAL, but others
- * will appear in the future.
- *
- * All subsystems are named as well as grouped, and subsystems can be
- * looked up by name and cast to the appropriate subtype when another
- * subsystem needs to invoke specialized methods.
- *
- * The subsystem manager owns the pointers to all the subsystems in
- * it.
- */
-class FGSubsystemMgr : public FGSubsystem
-{
-public:
-
- /**
- * Types of subsystem groups.
- */
- enum GroupType {
- INIT = 0,
- GENERAL,
- MAX_GROUPS
- };
-
- FGSubsystemMgr ();
- virtual ~FGSubsystemMgr ();
-
- virtual void init ();
- virtual void reinit ();
- virtual void bind ();
- virtual void unbind ();
- virtual void update (double delta_time_sec);
- virtual void suspend ();
- virtual void resume ();
- virtual bool is_suspended () const;
-
- virtual void add (const char * name,
- FGSubsystem * subsystem,
- GroupType group = GENERAL,
- double min_time_sec = 0);
-
- virtual FGSubsystemGroup * get_group (GroupType group);
-
- virtual FGSubsystem * get_subsystem(const string &name);
-
-private:
-
- FGSubsystemGroup _groups[MAX_GROUPS];
- map<string,FGSubsystem *> _subsystem_map;
-
-};
-
-
-
-#endif // __FGFS_HXX
-
-// end of fgfs.hxx
// $Id$
-#include <simgear/misc/commands.hxx>
+#include <simgear/structure/commands.hxx>
#include <simgear/misc/sg_path.hxx>
#include "globals.hxx"
// Constructor
FGGlobals::FGGlobals() :
- subsystem_mgr( new FGSubsystemMgr ),
+ subsystem_mgr( new SGSubsystemMgr ),
+ event_mgr( new SGEventMgr ),
sim_time_sec( 0.0 ),
fg_root( "" ),
fg_scenery( "" ),
channel_options_list( NULL ),
scenery( NULL ),
tile_mgr( NULL ),
- io( new FGIO ),
- cur_light_params( NULL )
+ io( new FGIO )
{
}
FGGlobals::~FGGlobals()
{
delete subsystem_mgr;
+ delete event_mgr;
delete initial_state;
delete props;
delete commands;
}
-FGSubsystemMgr *
+SGSubsystemMgr *
FGGlobals::get_subsystem_mgr () const
{
return subsystem_mgr;
}
-FGSubsystem *
+SGSubsystem *
FGGlobals::get_subsystem (const char * name)
{
return subsystem_mgr->get_subsystem(name);
void
FGGlobals::add_subsystem (const char * name,
- FGSubsystem * subsystem,
- FGSubsystemMgr::GroupType type,
+ SGSubsystem * subsystem,
+ SGSubsystemMgr::GroupType type,
double min_time_sec)
{
subsystem_mgr->add(name, subsystem, type, min_time_sec);
}
+SGEventMgr *
+FGGlobals::get_event_mgr () const
+{
+ return event_mgr;
+}
+
+
+void
+FGGlobals::add_event (const char * name,
+ int repeat_value,
+ int initial_value)
+{
+ event_mgr->add(name, subsystem_mgr->get_subsystem(name),
+ repeat_value, initial_value);
+}
+
+void
+FGGlobals::add_event (const char * name,
+ const SGSubsystem * subsystem,
+ int repeat_value,
+ int initial_value)
+{
+ event_mgr->add(name, subsystem, repeat_value, initial_value);
+}
+
+
+
// Save the current state as the initial state.
void
FGGlobals::saveInitialState ()
{
delete initial_state;
initial_state = new SGPropertyNode();
+
if (!copyProperties(props, initial_state))
SG_LOG(SG_GENERAL, SG_ALERT, "Error saving initial state");
}
#ifndef _GLOBALS_HXX
#define _GLOBALS_HXX
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <simgear/compiler.h>
+#include <simgear/structure/callback.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
+#include <simgear/structure/event_mgr.hxx>
#include <vector>
#include STL_STRING
-#include "fgfs.hxx"
-
-
SG_USING_STD( vector );
SG_USING_STD( string );
/**
* Bucket for subsystem pointers representing the sim's state.
*/
+
class FGGlobals
{
private:
- FGSubsystemMgr * subsystem_mgr;
+ SGSubsystemMgr * subsystem_mgr;
+ SGEventMgr * event_mgr;
// Number of milliseconds elapsed since the start of the program.
double sim_time_sec;
// Input/Ouput subsystem
FGIO *io;
- // light parameters
- FGLight *cur_light_params;
-
#ifdef FG_MPLAYER_AS
//Mulitplayer managers
FGMultiplayTxMgr *multiplayer_tx_mgr;
FGGlobals();
virtual ~FGGlobals();
- virtual FGSubsystemMgr * get_subsystem_mgr () const;
+ virtual SGSubsystemMgr * get_subsystem_mgr () const;
- virtual FGSubsystem * get_subsystem (const char * name);
+ virtual SGSubsystem * get_subsystem (const char * name);
virtual void add_subsystem (const char * name,
- FGSubsystem * subsystem,
- FGSubsystemMgr::GroupType
- type = FGSubsystemMgr::GENERAL,
+ SGSubsystem * subsystem,
+ SGSubsystemMgr::GroupType
+ type = SGSubsystemMgr::GENERAL,
double min_time_sec = 0);
+ virtual SGEventMgr * get_event_mgr () const;
+
+ virtual void add_event (const char * name,
+ int repeat_value,
+ int initial_value = -1 );
+
+ virtual void add_event (const char * name,
+ const SGSubsystem * subsystem,
+ int repeat_value,
+ int initial_value = -1 );
+
+ template< typename Fun >
+ inline void add_event( const char * name,
+ const Fun& func,
+ SGEvent::interval_type repeat_value,
+ SGEvent::interval_type initial_value = -1 )
+ {
+ event_mgr->add( name, get_subsystem( name ), func,
+ repeat_value, initial_value);
+ }
+
+ template< typename Fun >
+ inline void add_event( const char * name,
+ const SGSubsystem * subsystem,
+ const Fun& func,
+ SGEvent::interval_type repeat_value,
+ SGEvent::interval_type initial_value = -1 )
+ {
+ event_mgr->add( name, subsystem, func, repeat_value, initial_value);
+ }
+
inline double get_sim_time_sec () const { return sim_time_sec; }
inline void inc_sim_time_sec (double dt) { sim_time_sec += dt; }
inline void set_sim_time_sec (double t) { sim_time_sec = t; }
#include <simgear/compiler.h>
#include <simgear/debug/logstream.hxx>
-#include <simgear/misc/exception.hxx>
+#include <simgear/structure/exception.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/props/props.hxx>
SG_USING_STD(ostream);
SG_USING_STD(vector);
-#include "fgfs.hxx"
-
/**
* Log any property values to any number of CSV files.
*/
-class FGLogger : public FGSubsystem
+class FGLogger : public SGSubsystem
{
public:
FGLogger ();
virtual ~FGLogger ();
- // Implementation of FGSubsystem
+ // Implementation of SGSubsystem
virtual void init ();
virtual void reinit ();
virtual void bind ();
#include <Include/general.hxx>
#include <Scenery/tileentry.hxx>
-#include <Time/FGEventMgr.hxx>
#include <Time/light.hxx>
#include <Time/light.hxx>
#include <Aircraft/aircraft.hxx>
# include <console.h> // -dw- for command line dialog
#endif
-FGEventMgr global_events;
-
// This is a record containing a bit of global housekeeping information
FGGeneral general;
GLfloat black[4] = { 0.0, 0.0, 0.0, 1.0 };
GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
- // Process/manage pending events
- global_events.update( delta_time_sec );
-
// static const SGPropertyNode *longitude
// = fgGetNode("/position/longitude-deg");
// static const SGPropertyNode *latitude
if ( skyblend ) {
/*
SG_LOG( SG_GENERAL, SG_BULK, "thesky->repaint() sky_color = "
- << cur_light_params.sky_color[0] << " "
- << cur_light_params.sky_color[1] << " "
- << cur_light_params.sky_color[2] << " "
- << cur_light_params.sky_color[3] );
+ << l->sky_color()[0] << " "
+ << l->sky_color()[1] << " "
+ << l->sky_color()[2] << " "
+ << l->sky_color()[3] );
SG_LOG( SG_GENERAL, SG_BULK, " fog = "
- << cur_light_params.fog_color[0] << " "
- << cur_light_params.fog_color[1] << " "
- << cur_light_params.fog_color[2] << " "
- << cur_light_params.fog_color[3] );
+ << l->fog_color()[0] << " "
+ << l->fog_color()[1] << " "
+ << l->fog_color()[2] << " "
+ << l->fog_color()[3] );
SG_LOG( SG_GENERAL, SG_BULK,
- " sun_angle = " << cur_light_params.sun_angle
- << " moon_angle = " << cur_light_params.moon_angle );
+ " sun_angle = " << l->sun_angle
+ << " moon_angle = " << l->moon_angle );
*/
static SGSkyColor scolor;
<< " lon = " << cur_fdm_state->get_Longitude()
<< " lat = " << cur_fdm_state->get_Latitude() );
SG_LOG( SG_GENERAL, SG_BULK,
- " sun_rot = " << cur_light_params.sun_rotation
+ " sun_rot = " << l->get_sun_rotation
<< " gst = " << SGTime::cur_time_params->getGst() );
SG_LOG( SG_GENERAL, SG_BULK,
" sun ra = " << globals->get_ephem()->getSunRightAscension()
SGTime *t = globals->get_time_params();
+ globals->get_event_mgr()->update(delta_time_sec);
+
SGLocation * acmodel_location = 0;
if(cur_fdm_state->getACModel() != 0) {
acmodel_location = (SGLocation *) cur_fdm_state->getACModel()->get3DModel()->getSGLocation();
#endif
#include <simgear/compiler.h>
-#include <simgear/misc/exception.hxx>
+#include <simgear/structure/exception.hxx>
#include <simgear/debug/logstream.hxx>
#include <math.h> // rint()
#include <simgear/compiler.h>
#include <simgear/constants.h>
+#include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/scene/model/location.hxx>
#include <plib/sg.h> // plib include
-#include "fgfs.hxx"
-
#define FG_FOV_MIN 0.1
#define FG_FOV_MAX 179.9
};
// Define a structure containing view information
-class FGViewer : public FGSubsystem {
+class FGViewer : public SGSubsystem {
public:
virtual ~FGViewer( void );
//////////////////////////////////////////////////////////////////////
- // Part 1: standard FGSubsystem implementation.
+ // Part 1: standard SGSubsystem implementation.
//////////////////////////////////////////////////////////////////////
virtual void init ();
#include <simgear/compiler.h>
+#include <simgear/structure/subsystem_mgr.hxx>
#ifdef HAVE_CONFIG_H
# include <config.h>
#include <vector>
-#include "fgfs.hxx"
#include "viewer.hxx"
SG_USING_STD(vector);
// Define a structure containing view information
-class FGViewMgr : public FGSubsystem
+class FGViewMgr : public SGSubsystem
{
public:
#include <simgear/compiler.h>
#include <simgear/debug/logstream.hxx>
-#include <simgear/misc/exception.hxx>
+#include <simgear/structure/exception.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/scene/model/placement.hxx>
SG_USING_STD(string);
SG_USING_STD(vector);
-#include <Main/fgfs.hxx> // for FGSubsystem
+#include <simgear/structure/subsystem_mgr.hxx> // for SGSubsystem
// Don't pull in the headers, since we don't need them here.
class SGModelPlacement;
-class FGAircraftModel : public FGSubsystem
+class FGAircraftModel : public SGSubsystem
{
public:
#include <plib/ssg.h>
#include <plib/ul.h>
-#include <simgear/misc/exception.hxx>
+#include <simgear/structure/exception.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/props/props.hxx>
#include <simgear/props/props_io.hxx>
#include <vector>
#include <simgear/compiler.h> // for SG_USING_STD
-
-#include <Main/fgfs.hxx> // for FGSubsystem
+#include <simgear/structure/subsystem_mgr.hxx>
SG_USING_STD(vector);
/**
* Manage a list of user-specified models.
*/
-class FGModelMgr : public FGSubsystem
+class FGModelMgr : public SGSubsystem
{
public:
#include <simgear/debug/logstream.hxx>
#include <simgear/io/iochannel.hxx>
-#include <simgear/misc/exception.hxx>
+#include <simgear/structure/exception.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/props/props.hxx>
#include <simgear/props/props_io.hxx>
#include <simgear/debug/logstream.hxx>
#include <simgear/io/iochannel.hxx>
#include <simgear/math/sg_types.hxx>
-#include <simgear/misc/commands.hxx>
+#include <simgear/structure/commands.hxx>
#include <simgear/props/props.hxx>
#include <Main/fg_props.hxx>
#include <simgear/compiler.h>
#include <simgear/debug/logstream.hxx>
-#include <simgear/misc/commands.hxx>
+#include <simgear/structure/commands.hxx>
#include <simgear/misc/strutils.hxx>
#include <simgear/props/props.hxx>
#include <simgear/props/props_io.hxx>
#include <simgear/math/sg_types.hxx>
#include <simgear/props/props.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
#include <Network/net_ctrls.hxx>
#include <Network/net_fdm.hxx>
-#include <Main/fgfs.hxx>
SG_USING_STD(deque);
*
*/
-class FGReplay : public FGSubsystem
+class FGReplay : public SGSubsystem
{
public:
#include <plib/sg.h>
#include <plib/ssg.h>
+#include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/math/point3d.hxx>
-#include <Main/fgfs.hxx>
-
// Define a structure containing global scenery parameters
-class FGScenery : public FGSubsystem {
+class FGScenery : public SGSubsystem {
// center of current scenery chunk
Point3D center;
FGScenery();
~FGScenery();
- // Implementation of FGSubsystem.
+ // Implementation of SGSubsystem.
void init ();
void bind ();
void unbind ();
#include <simgear/math/polar3d.hxx>
#include <simgear/math/sg_geodesy.hxx>
#include <simgear/math/vector.hxx>
-#include <simgear/misc/exception.hxx>
+#include <simgear/structure/exception.hxx>
#include <simgear/scene/model/modellib.hxx>
#include <Main/globals.hxx>
#endif
#include <simgear/compiler.h> // for SG_USING_STD
-
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
class pslExtension;
* get_property(name) - get a property value
* set_property(name, value) - set a property value
*/
-class FGScriptMgr : public FGSubsystem
+class FGScriptMgr : public SGSubsystem
{
public:
#endif
#include <simgear/debug/logstream.hxx>
-#include <simgear/misc/exception.hxx>
+#include <simgear/structure/exception.hxx>
#ifdef __BORLANDC__
# define exception c_exception
#endif
#ifndef __FGFX_HXX
#define __FGFX_HXX 1
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
class SGSound;
* on current flight conditions. The sound manager must be initialized
* before this object is.
*/
-class FGFX : public FGSubsystem
+class FGFX : public SGSubsystem
{
public:
// $Id$
-#include <simgear/misc/exception.hxx>
+#include <simgear/structure/exception.hxx>
#include <simgear/misc/sg_path.hxx>
#include <Main/fg_props.hxx>
SG_USING_STD(vector);
#include <simgear/props/props.hxx>
-
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
// Forward declaration
*
*/
-class FGElectricalSystem : public FGSubsystem
+class FGElectricalSystem : public SGSubsystem
{
public:
#endif
#include <simgear/props/props.hxx>
-
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
/**
*
* /systems/pitot[0]/total-pressure-inhg
*/
-class PitotSystem : public FGSubsystem
+class PitotSystem : public SGSubsystem
{
public:
#endif
#include <simgear/props/props.hxx>
-
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
/**
* TODO: support multiple static ports and specific locations
* TODO: support alternate air with errors
*/
-class StaticSystem : public FGSubsystem
+class StaticSystem : public SGSubsystem
{
public:
#endif
#include <simgear/compiler.h>
-
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
/**
* In the initial draft, the systems present are hard-coded, but they
* will soon be configurable for individual aircraft.
*/
-class FGSystemMgr : public FGSubsystemGroup
+class FGSystemMgr : public SGSubsystemGroup
{
public:
#endif
#include <simgear/props/props.hxx>
-
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
/**
*
* /systems/vacuum[n]/suction-inhg
*/
-class VacuumSystem : public FGSubsystem
+class VacuumSystem : public SGSubsystem
{
public:
+++ /dev/null
-//
-// FGEventMgr.cxx -- Event Manager
-//
-// Written by Bernie Bright, started April 2002.
-//
-// Copyright (C) 2002 Curtis L. Olson - curt@me.umn.edu
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <simgear/compiler.h>
-#include <simgear/debug/logstream.hxx>
-
-#include "FGEventMgr.hxx"
-
-FGEventMgr::FGEvent::FGEvent()
- : name_(""),
- callback_(0),
- repeat_value_(0),
- initial_value_(0),
- ms_to_go_(0),
- cum_time(0),
- min_time(100000),
- max_time(0),
- count(0)
-{
-}
-
-FGEventMgr::FGEvent::FGEvent( const char* name,
- fgCallback* cb,
- interval_type repeat_value,
- interval_type initial_value )
- : name_(name),
- callback_(cb),
- repeat_value_(repeat_value),
- initial_value_(initial_value),
- //ms_to_go_(repeat_value_),
- cum_time(0),
- min_time(100000),
- max_time(0),
- count(0)
-{
- if (initial_value_ < 0)
- {
- this->run();
- ms_to_go_ = repeat_value_;
- }
- else
- {
- ms_to_go_ = initial_value_;
- }
-}
-
-
-FGEventMgr::FGEvent::~FGEvent()
-{
- //delete callback_;
-}
-
-void
-FGEventMgr::FGEvent::run()
-{
- SGTimeStamp start_time;
- SGTimeStamp finish_time;
-
- start_time.stamp();
-
- // run the event
- (*callback_)();
-
- finish_time.stamp();
-
- ++count;
-
- unsigned long duration = finish_time - start_time;
-
- cum_time += duration;
-
- if ( duration < min_time ) {
- min_time = duration;
- }
-
- if ( duration > max_time ) {
- max_time = duration;
- }
-}
-
-void
-FGEventMgr::FGEvent::print_stats() const
-{
- SG_LOG( SG_EVENT, SG_INFO,
- " " << name_
- << " int=" << repeat_value_ / 1000.0
- << " cum=" << cum_time
- << " min=" << min_time
- << " max=" << max_time
- << " count=" << count
- << " ave=" << cum_time / (double)count );
-}
-
-FGEventMgr::FGEventMgr()
-{
-}
-
-FGEventMgr::~FGEventMgr()
-{
-}
-
-void
-FGEventMgr::init()
-{
- SG_LOG( SG_EVENT, SG_INFO, "Initializing event manager" );
-
- event_table.clear();
-}
-
-void
-FGEventMgr::bind()
-{
-}
-
-void
-FGEventMgr::unbind()
-{
-}
-
-void
-FGEventMgr::update( double dt )
-{
- int dt_ms = int(dt * 1000);
-
- if (dt_ms < 0)
- {
- SG_LOG( SG_GENERAL, SG_ALERT,
- "FGEventMgr::update() called with negative delta T" );
- return;
- }
-
- int min_value = 0;
- event_container_type::iterator first = event_table.begin();
- event_container_type::iterator last = event_table.end();
- event_container_type::iterator event = event_table.end();
-
- // Scan all events. Run one whose interval has expired.
- while (first != last)
- {
- if (first->update( dt_ms ))
- {
- if (first->value() < min_value)
- {
- // Select event with largest negative value.
- // Its been waiting longest.
- min_value = first->value();
- event = first;
- }
- }
- ++first;
- }
-
- if (event != last)
- {
- event->run();
-
- if (event->repeat_value() > 0)
- {
- event->reset();
- }
- else
- {
- SG_LOG( SG_GENERAL, SG_DEBUG, "Deleting event " << event->name() );
- event_table.erase( event );
- }
- }
-}
-
-void
-FGEventMgr::Register( const FGEvent& event )
-{
- event_table.push_back( event );
-
- SG_LOG( SG_EVENT, SG_INFO, "Registered event " << event.name()
- << " to run every " << event.repeat_value() << "ms" );
-}
-
-void
-FGEventMgr::print_stats() const
-{
- SG_LOG( SG_EVENT, SG_INFO, "" );
- SG_LOG( SG_EVENT, SG_INFO, "Event Stats" );
- SG_LOG( SG_EVENT, SG_INFO, "-----------" );
-
- event_container_type::const_iterator first = event_table.begin();
- event_container_type::const_iterator last = event_table.end();
- for (; first != last; ++first)
- {
- first->print_stats();
- }
-
- SG_LOG( SG_EVENT, SG_INFO, "" );
-}
+++ /dev/null
-// FGEventMgr.hxx -- Flight Gear periodic event scheduler
-//
-// Written by Curtis Olson, started December 1997.
-// Modified by Bernie Bright, April 2002.
-//
-// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-#ifndef FG_EVENT_MGR_H_INCLUDED
-#define FG_EVENT_MGR_H_INCLUDED 1
-
-#include <simgear/compiler.h>
-#include <simgear/timing/timestamp.hxx>
-
-#include <Main/fgfs.hxx>
-#include <Include/fg_callback.hxx>
-
-#include <vector>
-#include <string>
-
-SG_USING_STD(vector);
-SG_USING_STD(string);
-
-/**
- *
- */
-class FGEventMgr : public FGSubsystem
-{
-public:
-
- typedef int interval_type;
-
-private:
-
- /**
- *
- */
- class FGEvent
- {
- public:
- /**
- *
- */
- FGEvent();
-
- FGEvent( const char* desc,
- fgCallback* cb,
- interval_type repeat_value,
- interval_type initial_value );
-
- /**
- *
- */
- ~FGEvent();
-
- /**
- *
- */
- void reset()
- {
- ms_to_go_ = repeat_value_;
- }
-
- /**
- * Execute this event's callback.
- */
- void run();
-
- string name() const { return name_; }
- interval_type repeat_value() const { return repeat_value_; }
- int value() const { return ms_to_go_; }
-
- /**
- * Display event statistics.
- */
- void print_stats() const;
-
- /**
- * Update the elapsed time for this event.
- * @param dt_ms elapsed time in milliseconds.
- * @return true if elapsed time has expired.
- */
- bool update( int dt_ms )
- {
- ms_to_go_ -= dt_ms;
- return ms_to_go_ <= 0;
- }
-
- private:
- string name_;
- fgCallback* callback_;
- interval_type repeat_value_;
- interval_type initial_value_;
- int ms_to_go_;
-
- unsigned long cum_time; // cumulative processor time of this event
- unsigned long min_time; // time of quickest execution
- unsigned long max_time; // time of slowest execution
- unsigned long count; // number of times executed
- };
-
-public:
- FGEventMgr();
- ~FGEventMgr();
-
- /**
- * Initialize the scheduling subsystem.
- */
- void init();
-
- void bind();
-
- void unbind();
-
- /*
- * Update the elapsed time for all events.
- * @param dt elapsed time in seconds.
- */
- void update( double dt );
-
- /**
- * Register a free standing function to be executed some time in the future.
- * @param desc A brief description of this callback for logging.
- * @param cb The callback function to be executed.
- * @param repeat_value repetition rate in milliseconds.
- * @param initial_value initial delay value in milliseconds. A value of
- * -1 means run immediately.
- */
- template< typename Fun >
- void Register( const char* name,
- const Fun& f,
- interval_type repeat_value,
- interval_type initial_value = -1 )
- {
- this->Register( FGEvent( name,
- make_callback(f),
- repeat_value,
- initial_value ) );
- }
-
- template< class ObjPtr, typename MemFn >
- void Register( const char* name,
- const ObjPtr& p,
- MemFn pmf,
- interval_type repeat_value,
- interval_type initial_value = -1 )
- {
- this->Register( FGEvent( name,
- make_callback(p,pmf),
- repeat_value,
- initial_value ) );
- }
-
- /**
- * Display statistics for all registered events.
- */
- void print_stats() const;
-
-private:
- void Register( const FGEvent& event );
-
-private:
-
- typedef vector< FGEvent > event_container_type;
-
- // Registered events.
- event_container_type event_table;
-};
-
-extern FGEventMgr global_events;
-
-#endif //FG_ EVENT_MGR_H_INCLUDED
noinst_LIBRARIES = libTime.a
libTime_a_SOURCES = \
- FGEventMgr.cxx FGEventMgr.hxx \
fg_timer.cxx fg_timer.hxx \
light.cxx light.hxx \
moonpos.cxx moonpos.hxx \
#include <plib/sg.h> // plib include
+#include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/math/interpolater.hxx>
#include <simgear/math/point3d.hxx>
// Define a structure containing the global lighting parameters
-class FGLight : public FGSubsystem
+class FGLight : public SGSubsystem
{
private: