Move FGEventMgr and FGSubsystemMgr over to SimGear, add SGEventMgr to FlightGear's globals structre and some small code cleanups
This commit is contained in:
parent
e35e54b8c9
commit
980012e168
88 changed files with 279 additions and 1354 deletions
|
@ -19,10 +19,10 @@
|
|||
// 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>
|
||||
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
#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>
|
||||
|
@ -33,7 +34,7 @@
|
|||
SG_USING_STD(list);
|
||||
|
||||
|
||||
class FGAIMgr : public FGSubsystem
|
||||
class FGAIMgr : public SGSubsystem
|
||||
{
|
||||
|
||||
private:
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
|
||||
#include <simgear/sound/soundmgr.hxx>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
#include <Main/fg_props.hxx>
|
||||
|
||||
#include "ATC.hxx"
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
// 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"
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
@ -49,7 +49,7 @@ struct atcMessage {
|
|||
typedef vector<atcMessage> atcMessageList;
|
||||
typedef atcMessageList::iterator atcMessageListIterator;
|
||||
|
||||
class FGATCDisplay : public FGSubsystem
|
||||
class FGATCDisplay : public SGSubsystem
|
||||
{
|
||||
|
||||
private:
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
// 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>
|
||||
|
@ -36,6 +34,7 @@ static void fgATCSearch( void ) {
|
|||
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),
|
||||
|
@ -90,9 +89,12 @@ void FGATCMgr::init() {
|
|||
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;
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
#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>
|
||||
|
||||
|
@ -72,7 +73,7 @@ struct AirportATC {
|
|||
bool set_by_comm[2]; // true when the relevant comm_freq has activated this station
|
||||
};
|
||||
|
||||
class FGATCMgr : public FGSubsystem
|
||||
class FGATCMgr : public SGSubsystem
|
||||
{
|
||||
|
||||
private:
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
#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>
|
||||
|
@ -41,7 +41,6 @@
|
|||
#include <Cockpit/panel_io.hxx>
|
||||
#include <Model/acmodel.hxx>
|
||||
#include <Autopilot/newauto.hxx>
|
||||
#include <Main/fgfs.hxx>
|
||||
|
||||
#include "aircraft.hxx"
|
||||
|
||||
|
|
|
@ -28,13 +28,13 @@
|
|||
|
||||
|
||||
#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:
|
||||
|
@ -165,7 +165,7 @@ public:
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Implementation of FGSubsystem.
|
||||
// Implementation of SGSubsystem.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
void init ();
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include <Navaids/ilslist.hxx>
|
||||
#include <Navaids/mkrbeacons.hxx>
|
||||
#include <Navaids/navlist.hxx>
|
||||
#include <Time/FGEventMgr.hxx>
|
||||
|
||||
#include "dme.hxx"
|
||||
|
||||
|
|
|
@ -25,11 +25,10 @@
|
|||
#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>
|
||||
|
||||
|
@ -42,7 +41,7 @@
|
|||
// #include "kt_70.hxx" // Transponder
|
||||
// #include "navcom.hxx"
|
||||
|
||||
class FGDME : public FGSubsystem
|
||||
class FGDME : public SGSubsystem
|
||||
{
|
||||
SGPropertyNode *lon_node;
|
||||
SGPropertyNode *lat_node;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
// $Id$
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/misc/exception.hxx>
|
||||
#include <simgear/structure/exception.hxx>
|
||||
|
||||
#include STL_STRING
|
||||
#include STL_FSTREAM
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
|
||||
#include <Aircraft/aircraft.hxx>
|
||||
#include <Navaids/navlist.hxx>
|
||||
#include <Time/FGEventMgr.hxx>
|
||||
|
||||
#include "kr_87.hxx"
|
||||
|
||||
|
|
|
@ -25,18 +25,17 @@
|
|||
#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;
|
||||
|
||||
|
|
|
@ -25,11 +25,10 @@
|
|||
#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>
|
||||
|
||||
|
@ -38,7 +37,7 @@
|
|||
#include <Sound/morse.hxx>
|
||||
|
||||
|
||||
class FGKT_70 : public FGSubsystem
|
||||
class FGKT_70 : public SGSubsystem
|
||||
{
|
||||
SGPropertyNode *lon_node;
|
||||
SGPropertyNode *lat_node;
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
|
||||
#include <Aircraft/aircraft.hxx>
|
||||
#include <Navaids/mkrbeacons.hxx>
|
||||
#include <Time/FGEventMgr.hxx>
|
||||
|
||||
#include "marker_beacon.hxx"
|
||||
|
||||
|
|
|
@ -25,11 +25,10 @@
|
|||
#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>
|
||||
|
||||
|
@ -37,7 +36,7 @@
|
|||
#include <Sound/morse.hxx>
|
||||
|
||||
|
||||
class FGMarkerBeacon : public FGSubsystem
|
||||
class FGMarkerBeacon : public SGSubsystem
|
||||
{
|
||||
FGBeacon beacon;
|
||||
FGMorse morse;
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include <Aircraft/aircraft.hxx>
|
||||
#include <Navaids/ilslist.hxx>
|
||||
#include <Navaids/navlist.hxx>
|
||||
#include <Time/FGEventMgr.hxx>
|
||||
|
||||
#include "navcom.hxx"
|
||||
|
||||
|
|
|
@ -25,11 +25,10 @@
|
|||
#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>
|
||||
|
||||
|
@ -37,7 +36,7 @@
|
|||
#include <Navaids/navlist.hxx>
|
||||
#include <Sound/morse.hxx>
|
||||
|
||||
class FGNavCom : public FGSubsystem
|
||||
class FGNavCom : public SGSubsystem
|
||||
{
|
||||
FGMorse morse;
|
||||
|
||||
|
|
|
@ -30,26 +30,24 @@
|
|||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <simgear/compiler.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);
|
||||
|
@ -130,7 +128,7 @@ private:
|
|||
* 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:
|
||||
|
||||
|
|
|
@ -29,8 +29,7 @@
|
|||
#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>
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include <Navaids/ilslist.hxx>
|
||||
#include <Navaids/mkrbeacons.hxx>
|
||||
#include <Navaids/navlist.hxx>
|
||||
#include <Time/FGEventMgr.hxx>
|
||||
|
||||
#include "radiostack.hxx"
|
||||
|
||||
|
@ -78,9 +77,8 @@ FGRadioStack::init ()
|
|||
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 );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,11 +25,10 @@
|
|||
#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>
|
||||
|
||||
|
@ -45,7 +44,7 @@
|
|||
#include "navcom.hxx"
|
||||
|
||||
|
||||
class FGRadioStack : public FGSubsystem
|
||||
class FGRadioStack : public SGSubsystem
|
||||
{
|
||||
FGDME dme;
|
||||
FGKR_87 adf; // King KR 87 Digital ADF model
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
#define _CONTROLS_HXX
|
||||
|
||||
#include <simgear/props/props.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
#include <Main/globals.hxx>
|
||||
|
||||
#ifndef __cplusplus
|
||||
|
@ -36,7 +36,7 @@
|
|||
|
||||
// Define a structure containing the control parameters
|
||||
|
||||
class FGControls : public FGSubsystem
|
||||
class FGControls : public SGSubsystem
|
||||
{
|
||||
|
||||
public:
|
||||
|
@ -240,7 +240,7 @@ public:
|
|||
FGControls();
|
||||
~FGControls();
|
||||
|
||||
// Implementation of FGSubsystem.
|
||||
// Implementation of SGSubsystem.
|
||||
void init ();
|
||||
void bind ();
|
||||
void unbind ();
|
||||
|
|
|
@ -26,8 +26,6 @@
|
|||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
|
||||
#ifdef SG_HAVE_STD_INCLUDES
|
||||
# include <cmath>
|
||||
#else
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#define _ENVIRONMENT_CTRL_HXX
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
#ifdef SG_HAVE_STD_INCLUDES
|
||||
# include <cmath>
|
||||
|
@ -37,8 +38,6 @@ SG_USING_STD(vector);
|
|||
|
||||
class SGPropertyNode;
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
|
||||
#include "environment.hxx"
|
||||
|
||||
|
||||
|
@ -46,7 +45,7 @@ class SGPropertyNode;
|
|||
/**
|
||||
* Interface to control environment information for a specific location.
|
||||
*/
|
||||
class FGEnvironmentCtrl : public FGSubsystem
|
||||
class FGEnvironmentCtrl : public SGSubsystem
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -50,7 +50,7 @@ void
|
|||
FGEnvironmentMgr::init ()
|
||||
{
|
||||
SG_LOG( SG_GENERAL, SG_INFO, "Initializing environment subsystem");
|
||||
FGSubsystemGroup::init();
|
||||
SGSubsystemGroup::init();
|
||||
_update_fdm();
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ void
|
|||
FGEnvironmentMgr::reinit ()
|
||||
{
|
||||
SG_LOG( SG_GENERAL, SG_INFO, "Reinitializing environment subsystem");
|
||||
FGSubsystemGroup::reinit();
|
||||
SGSubsystemGroup::reinit();
|
||||
_update_fdm();
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ FGEnvironmentMgr::unbind ()
|
|||
void
|
||||
FGEnvironmentMgr::update (double dt)
|
||||
{
|
||||
FGSubsystemGroup::update(dt);
|
||||
SGSubsystemGroup::update(dt);
|
||||
|
||||
// FIXME: the FDMs should update themselves
|
||||
current_aircraft.fdm_state
|
||||
|
|
|
@ -24,8 +24,7 @@
|
|||
#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>
|
||||
|
@ -40,7 +39,7 @@ class FGEnvironmentCtrl;
|
|||
/**
|
||||
* Manage environment information.
|
||||
*/
|
||||
class FGEnvironmentMgr : public FGSubsystemGroup
|
||||
class FGEnvironmentMgr : public SGSubsystemGroup
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -81,16 +81,15 @@
|
|||
*/
|
||||
|
||||
|
||||
#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);
|
||||
|
@ -102,7 +101,7 @@ class FGAircraftModel;
|
|||
typedef double FG_VECTOR_3[3];
|
||||
|
||||
// This is based heavily on LaRCsim/ls_generic.h
|
||||
class FGInterface : public FGSubsystem {
|
||||
class FGInterface : public SGSubsystem {
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
# 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>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include <plib/pu.h> // plib include
|
||||
|
||||
#include <simgear/misc/exception.hxx>
|
||||
#include <simgear/structure/exception.hxx>
|
||||
|
||||
#define TR_HIRES_SNAP 1
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
#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"
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#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);
|
||||
|
@ -18,7 +19,6 @@ SG_USING_STD(vector);
|
|||
#include <map>
|
||||
SG_USING_STD(map);
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
#include <Main/fg_props.hxx>
|
||||
|
||||
class FGMenuBar;
|
||||
|
@ -35,7 +35,7 @@ class FGBinding;
|
|||
* 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:
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
# 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>
|
||||
|
|
|
@ -3,7 +3,6 @@ EXTRA_DIST = \
|
|||
config.h.in \
|
||||
config.h-msvc6 \
|
||||
cmdargs.h \
|
||||
fg_callback.hxx \
|
||||
fg_typedefs.h \
|
||||
fg_stl_config.h \
|
||||
general.hxx
|
||||
|
|
|
@ -32,11 +32,11 @@
|
|||
|
||||
#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>
|
||||
|
||||
|
@ -166,7 +166,7 @@ private:
|
|||
* 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:
|
||||
|
||||
|
@ -192,7 +192,7 @@ public:
|
|||
virtual ~FGInput();
|
||||
|
||||
//
|
||||
// Implementation of FGSubsystem.
|
||||
// Implementation of SGSubsystem.
|
||||
//
|
||||
virtual void init ();
|
||||
virtual void update (double dt);
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
#endif
|
||||
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
|
||||
/**
|
||||
|
@ -30,7 +29,7 @@
|
|||
*
|
||||
* /instrumentation/airspeed-indicator/indicated-speed-kt
|
||||
*/
|
||||
class AirspeedIndicator : public FGSubsystem
|
||||
class AirspeedIndicator : public SGSubsystem
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#endif
|
||||
|
||||
#include <simgear/props/props.hxx>
|
||||
#include <Main/fgfs.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
|
||||
class SGInterpTable;
|
||||
|
@ -31,7 +31,7 @@ class SGInterpTable;
|
|||
*
|
||||
* /instrumentation/altimeter/indicated-altitude-ft
|
||||
*/
|
||||
class Altimeter : public FGSubsystem
|
||||
class Altimeter : public SGSubsystem
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -10,8 +10,7 @@
|
|||
#endif
|
||||
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
|
||||
/**
|
||||
|
@ -28,7 +27,7 @@
|
|||
*
|
||||
* /instrumentation/airspeed-indicator/indicated-speed-kt
|
||||
*/
|
||||
class Annunciator : public FGSubsystem
|
||||
class Annunciator : public SGSubsystem
|
||||
{
|
||||
|
||||
// timers
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
#endif
|
||||
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
#include "gyro.hxx"
|
||||
|
||||
|
@ -39,7 +38,7 @@
|
|||
* /instrumentation/attitude-indicator/indicated-roll-deg
|
||||
* /instrumentation/attitude-indicator/tumble-norm
|
||||
*/
|
||||
class AttitudeIndicator : public FGSubsystem
|
||||
class AttitudeIndicator : public SGSubsystem
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
#endif
|
||||
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
|
||||
/**
|
||||
|
@ -31,7 +30,7 @@
|
|||
* /instrumentation/clock/indicated-sec
|
||||
* /instrumentation/clock/indicated-string
|
||||
*/
|
||||
class Clock : public FGSubsystem
|
||||
class Clock : public SGSubsystem
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -13,8 +13,7 @@
|
|||
|
||||
#include <simgear/math/point3d.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
|
||||
/**
|
||||
|
@ -37,7 +36,7 @@
|
|||
* /instrumentation/dme/indicated-ground-speed-kt
|
||||
* /instrumentation/dme/indicated-time-kt
|
||||
*/
|
||||
class DME : public FGSubsystem
|
||||
class DME : public SGSubsystem
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
#endif
|
||||
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
|
||||
/**
|
||||
|
@ -37,7 +36,7 @@
|
|||
* /instrumentation/gps/indicated-track-magnetic-deg
|
||||
* /instrumentation/gps/indicated-ground-speed-kt
|
||||
*/
|
||||
class GPS : public FGSubsystem
|
||||
class GPS : public SGSubsystem
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
#endif
|
||||
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
#include "gyro.hxx"
|
||||
|
||||
|
@ -35,7 +34,7 @@
|
|||
*
|
||||
* /instrumentation/heading-indicator/indicated-heading-deg
|
||||
*/
|
||||
class HeadingIndicator : public FGSubsystem
|
||||
class HeadingIndicator : public SGSubsystem
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
#endif
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
|
||||
/**
|
||||
|
@ -26,7 +25,7 @@
|
|||
* 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:
|
||||
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
#endif
|
||||
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
|
||||
/**
|
||||
|
@ -34,7 +33,7 @@
|
|||
*
|
||||
* /instrumentation/magnetic-compass/indicated-heading-deg
|
||||
*/
|
||||
class MagCompass : public FGSubsystem
|
||||
class MagCompass : public SGSubsystem
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
#endif
|
||||
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
#include "gyro.hxx"
|
||||
|
||||
|
@ -31,7 +30,7 @@
|
|||
*
|
||||
* /instrumentation/slip-skid-ball/indicated-slip-skid
|
||||
*/
|
||||
class SlipSkidBall : public FGSubsystem
|
||||
class SlipSkidBall : public SGSubsystem
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
#endif
|
||||
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
#include "gyro.hxx"
|
||||
|
||||
|
@ -36,7 +35,7 @@
|
|||
*
|
||||
* /instrumentation/turn-indicator/indicated-turn-rate
|
||||
*/
|
||||
class TurnIndicator : public FGSubsystem
|
||||
class TurnIndicator : public SGSubsystem
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
#endif
|
||||
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
|
||||
/**
|
||||
|
@ -28,7 +27,7 @@
|
|||
*
|
||||
* /instrumentation/vertical-speed-indicator/indicated-speed-fpm
|
||||
*/
|
||||
class VerticalSpeedIndicator : public FGSubsystem
|
||||
class VerticalSpeedIndicator : public SGSubsystem
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -54,7 +54,6 @@ libMain_a_SOURCES = \
|
|||
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 \
|
||||
|
@ -102,7 +101,7 @@ fgfs_LDADD = \
|
|||
$(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) \
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#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
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include <string.h> // strcmp()
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/misc/exception.hxx>
|
||||
|
||||
#include STL_STRING
|
||||
#include STL_FSTREAM
|
||||
|
@ -11,7 +10,8 @@
|
|||
#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>
|
||||
|
@ -202,7 +202,7 @@ do_reinit (const SGPropertyNode * arg)
|
|||
} 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,
|
||||
|
@ -213,6 +213,8 @@ do_reinit (const SGPropertyNode * arg)
|
|||
}
|
||||
}
|
||||
|
||||
globals->get_event_mgr()->reinit();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -229,7 +231,7 @@ do_suspend (const SGPropertyNode * arg)
|
|||
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");
|
||||
|
@ -253,7 +255,7 @@ do_resume (const SGPropertyNode * arg)
|
|||
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");
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <simgear/misc/commands.hxx>
|
||||
#include <simgear/structure/commands.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
/**
|
||||
|
|
|
@ -47,12 +47,13 @@
|
|||
#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>
|
||||
|
@ -106,7 +107,6 @@
|
|||
#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>
|
||||
|
@ -1410,6 +1410,18 @@ bool fgInitSubsystems() {
|
|||
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.
|
||||
|
@ -1422,17 +1434,6 @@ bool fgInitSubsystems() {
|
|||
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.
|
||||
|
@ -1449,10 +1450,10 @@ bool fgInitSubsystems() {
|
|||
}
|
||||
|
||||
// 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 " <<
|
||||
|
@ -1477,12 +1478,6 @@ bool fgInitSubsystems() {
|
|||
fgInitView();
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Initialize the lighting subsystem.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
globals->add_subsystem("lighting", new FGLight);
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Create and register the logger.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -1503,7 +1498,7 @@ bool fgInitSubsystems() {
|
|||
// Create and register the XML GUI.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
globals->add_subsystem("gui", new NewGUI, FGSubsystemMgr::INIT);
|
||||
globals->add_subsystem("gui", new NewGUI, SGSubsystemMgr::INIT);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -1511,8 +1506,8 @@ bool fgInitSubsystems() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
// 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 );
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -1558,12 +1553,20 @@ bool fgInitSubsystems() {
|
|||
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.
|
||||
|
@ -1740,7 +1743,6 @@ bool fgInitSubsystems() {
|
|||
globals->get_subsystem_mgr()->bind();
|
||||
globals->get_subsystem_mgr()->init();
|
||||
|
||||
|
||||
#ifdef FG_MPLAYER_AS
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Initialize multiplayer subsystem
|
||||
|
|
|
@ -26,17 +26,17 @@
|
|||
|
||||
|
||||
#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();
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
# 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>
|
||||
|
@ -46,7 +46,6 @@
|
|||
#include <GUI/gui.h>
|
||||
|
||||
#include "globals.hxx"
|
||||
#include "fgfs.hxx"
|
||||
#include "fg_props.hxx"
|
||||
|
||||
SG_USING_STD(istream);
|
||||
|
|
|
@ -1,337 +0,0 @@
|
|||
#include "fgfs.hxx"
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/misc/exception.hxx>
|
||||
|
||||
#include "globals.hxx"
|
||||
#include "fg_props.hxx"
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// 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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// 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
|
|
@ -1,355 +0,0 @@
|
|||
// 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>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
|
@ -21,7 +21,7 @@
|
|||
// $Id$
|
||||
|
||||
|
||||
#include <simgear/misc/commands.hxx>
|
||||
#include <simgear/structure/commands.hxx>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
|
||||
#include "globals.hxx"
|
||||
|
@ -41,7 +41,8 @@ FGGlobals *globals;
|
|||
|
||||
// Constructor
|
||||
FGGlobals::FGGlobals() :
|
||||
subsystem_mgr( new FGSubsystemMgr ),
|
||||
subsystem_mgr( new SGSubsystemMgr ),
|
||||
event_mgr( new SGEventMgr ),
|
||||
sim_time_sec( 0.0 ),
|
||||
fg_root( "" ),
|
||||
fg_scenery( "" ),
|
||||
|
@ -73,8 +74,7 @@ FGGlobals::FGGlobals() :
|
|||
channel_options_list( NULL ),
|
||||
scenery( NULL ),
|
||||
tile_mgr( NULL ),
|
||||
io( new FGIO ),
|
||||
cur_light_params( NULL )
|
||||
io( new FGIO )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -83,6 +83,7 @@ FGGlobals::FGGlobals() :
|
|||
FGGlobals::~FGGlobals()
|
||||
{
|
||||
delete subsystem_mgr;
|
||||
delete event_mgr;
|
||||
delete initial_state;
|
||||
delete props;
|
||||
delete commands;
|
||||
|
@ -104,13 +105,13 @@ void FGGlobals::set_fg_root (const string &root) {
|
|||
}
|
||||
|
||||
|
||||
FGSubsystemMgr *
|
||||
SGSubsystemMgr *
|
||||
FGGlobals::get_subsystem_mgr () const
|
||||
{
|
||||
return subsystem_mgr;
|
||||
}
|
||||
|
||||
FGSubsystem *
|
||||
SGSubsystem *
|
||||
FGGlobals::get_subsystem (const char * name)
|
||||
{
|
||||
return subsystem_mgr->get_subsystem(name);
|
||||
|
@ -118,20 +119,48 @@ FGGlobals::get_subsystem (const char * 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");
|
||||
}
|
||||
|
|
|
@ -24,14 +24,18 @@
|
|||
#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 );
|
||||
|
||||
|
@ -84,12 +88,14 @@ class FGViewer;
|
|||
/**
|
||||
* 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;
|
||||
|
@ -185,9 +191,6 @@ private:
|
|||
// Input/Ouput subsystem
|
||||
FGIO *io;
|
||||
|
||||
// light parameters
|
||||
FGLight *cur_light_params;
|
||||
|
||||
#ifdef FG_MPLAYER_AS
|
||||
//Mulitplayer managers
|
||||
FGMultiplayTxMgr *multiplayer_tx_mgr;
|
||||
|
@ -200,16 +203,47 @@ public:
|
|||
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; }
|
||||
|
|
|
@ -19,26 +19,25 @@
|
|||
|
||||
#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 ();
|
||||
|
|
|
@ -64,7 +64,6 @@
|
|||
|
||||
#include <Include/general.hxx>
|
||||
#include <Scenery/tileentry.hxx>
|
||||
#include <Time/FGEventMgr.hxx>
|
||||
#include <Time/light.hxx>
|
||||
#include <Time/light.hxx>
|
||||
#include <Aircraft/aircraft.hxx>
|
||||
|
@ -133,8 +132,6 @@ bool glPointParameterIsSupported = false;
|
|||
# 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;
|
||||
|
||||
|
@ -374,9 +371,6 @@ void fgRenderFrame() {
|
|||
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
|
||||
|
@ -510,18 +504,18 @@ void fgRenderFrame() {
|
|||
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;
|
||||
|
@ -549,7 +543,7 @@ void fgRenderFrame() {
|
|||
<< " 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()
|
||||
|
@ -1019,6 +1013,8 @@ static void fgMainLoop( void ) {
|
|||
|
||||
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();
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#endif
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/misc/exception.hxx>
|
||||
#include <simgear/structure/exception.hxx>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#include <math.h> // rint()
|
||||
|
|
|
@ -34,12 +34,11 @@
|
|||
|
||||
#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
|
||||
|
||||
|
@ -49,7 +48,7 @@ enum fgViewType {
|
|||
};
|
||||
|
||||
// Define a structure containing view information
|
||||
class FGViewer : public FGSubsystem {
|
||||
class FGViewer : public SGSubsystem {
|
||||
|
||||
public:
|
||||
|
||||
|
@ -74,7 +73,7 @@ public:
|
|||
virtual ~FGViewer( void );
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Part 1: standard FGSubsystem implementation.
|
||||
// Part 1: standard SGSubsystem implementation.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual void init ();
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
|
@ -38,14 +39,13 @@
|
|||
|
||||
#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:
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#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>
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
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.
|
||||
|
@ -24,7 +24,7 @@ class ssgSelector;
|
|||
class SGModelPlacement;
|
||||
|
||||
|
||||
class FGAircraftModel : public FGSubsystem
|
||||
class FGAircraftModel : public SGSubsystem
|
||||
{
|
||||
public:
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#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>
|
||||
|
|
|
@ -13,8 +13,7 @@
|
|||
#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);
|
||||
|
||||
|
@ -27,7 +26,7 @@ class SGModelPlacement;
|
|||
/**
|
||||
* Manage a list of user-specified models.
|
||||
*/
|
||||
class FGModelMgr : public FGSubsystem
|
||||
class FGModelMgr : public SGSubsystem
|
||||
{
|
||||
public:
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#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>
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#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>
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#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>
|
||||
|
|
|
@ -34,10 +34,10 @@
|
|||
|
||||
#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);
|
||||
|
||||
|
@ -60,7 +60,7 @@ typedef deque < FGReplayData > replay_list_type;
|
|||
*
|
||||
*/
|
||||
|
||||
class FGReplay : public FGSubsystem
|
||||
class FGReplay : public SGSubsystem
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -33,13 +33,12 @@
|
|||
#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;
|
||||
|
||||
|
@ -74,7 +73,7 @@ public:
|
|||
FGScenery();
|
||||
~FGScenery();
|
||||
|
||||
// Implementation of FGSubsystem.
|
||||
// Implementation of SGSubsystem.
|
||||
void init ();
|
||||
void bind ();
|
||||
void unbind ();
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#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>
|
||||
|
|
|
@ -11,8 +11,7 @@
|
|||
#endif
|
||||
|
||||
#include <simgear/compiler.h> // for SG_USING_STD
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
class pslExtension;
|
||||
|
||||
|
@ -32,7 +31,7 @@ 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:
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#endif
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/misc/exception.hxx>
|
||||
#include <simgear/structure/exception.hxx>
|
||||
#ifdef __BORLANDC__
|
||||
# define exception c_exception
|
||||
#endif
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#ifndef __FGFX_HXX
|
||||
#define __FGFX_HXX 1
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
class SGSound;
|
||||
|
||||
|
@ -35,7 +35,7 @@ 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:
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
// $Id$
|
||||
|
||||
|
||||
#include <simgear/misc/exception.hxx>
|
||||
#include <simgear/structure/exception.hxx>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
|
||||
#include <Main/fg_props.hxx>
|
||||
|
|
|
@ -39,8 +39,7 @@ SG_USING_STD(string);
|
|||
SG_USING_STD(vector);
|
||||
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
|
||||
// Forward declaration
|
||||
|
@ -184,7 +183,7 @@ public:
|
|||
*
|
||||
*/
|
||||
|
||||
class FGElectricalSystem : public FGSubsystem
|
||||
class FGElectricalSystem : public SGSubsystem
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
#endif
|
||||
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
|
||||
/**
|
||||
|
@ -33,7 +32,7 @@
|
|||
*
|
||||
* /systems/pitot[0]/total-pressure-inhg
|
||||
*/
|
||||
class PitotSystem : public FGSubsystem
|
||||
class PitotSystem : public SGSubsystem
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
#endif
|
||||
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
|
||||
/**
|
||||
|
@ -31,7 +30,7 @@
|
|||
* TODO: support multiple static ports and specific locations
|
||||
* TODO: support alternate air with errors
|
||||
*/
|
||||
class StaticSystem : public FGSubsystem
|
||||
class StaticSystem : public SGSubsystem
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
#endif
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
|
||||
/**
|
||||
|
@ -26,7 +25,7 @@
|
|||
* 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:
|
||||
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
#endif
|
||||
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
|
||||
/**
|
||||
|
@ -31,7 +30,7 @@
|
|||
*
|
||||
* /systems/vacuum[n]/suction-inhg
|
||||
*/
|
||||
class VacuumSystem : public FGSubsystem
|
||||
class VacuumSystem : public SGSubsystem
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -1,217 +0,0 @@
|
|||
//
|
||||
// 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, "" );
|
||||
}
|
|
@ -1,187 +0,0 @@
|
|||
// 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
|
|
@ -1,7 +1,6 @@
|
|||
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 \
|
||||
|
|
|
@ -42,12 +42,13 @@
|
|||
|
||||
#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:
|
||||
|
|
Loading…
Reference in a new issue