1
0
Fork 0

src/Main/fg_init.cxx: fgCreateSubsystems(): group registrations by GroupType.

This is just for code clarity.

It changes the order of construction/registration of subsystems to match the
order in which subsystem groups are called when Flightgear is running.
This commit is contained in:
Julian Smith 2021-04-02 10:27:48 +01:00
parent d7d87479a9
commit ae9d8ce088

View file

@ -921,16 +921,21 @@ void fgOutputSettings()
// Returns non-zero if a problem encountered.
void fgCreateSubsystems(bool duringReset) {
SG_LOG( SG_GENERAL, SG_INFO, "Creating Subsystems");
SG_LOG( SG_GENERAL, SG_INFO, "======== ==========");
SG_LOG( SG_GENERAL, SG_INFO, "== Creating Subsystems");
globals->get_event_mgr()->init();
globals->get_event_mgr()->setRealtimeProperty(fgGetNode("/sim/time/delta-realtime-sec", true));
// SGSubsystemMgr::INIT
{
// Initialize the property interpolator subsystem. Put into the INIT
// group because the "nasal" subsystem may need it at GENERAL take-down.
globals->add_subsystem("prop-interpolator", new FGInterpolator, SGSubsystemMgr::INIT);
globals->add_subsystem("gui", new NewGUI, SGSubsystemMgr::INIT);
}
// SGSubsystemMgr::GENERAL
{
globals->add_subsystem("properties", new FGProperties, SGSubsystemMgr::GENERAL);
globals->add_new_subsystem<flightgear::AirportDynamicsManager>(SGSubsystemMgr::GENERAL);
globals->add_subsystem("performance-mon",
@ -954,30 +959,43 @@ void fgCreateSubsystems(bool duringReset) {
}
globals->add_new_subsystem<FGDNSClient>(SGSubsystemMgr::GENERAL);
globals->add_subsystem("flight", new FDMShell, SGSubsystemMgr::FDM);
// Initialize the weather modeling subsystem
globals->add_subsystem("environment", new FGEnvironmentMgr, SGSubsystemMgr::GENERAL);
globals->add_new_subsystem<Ephemeris>(SGSubsystemMgr::GENERAL);
globals->add_subsystem( "xml-proprules", FGXMLAutopilotGroup::createInstance("property-rule"), SGSubsystemMgr::GENERAL );
globals->add_new_subsystem<FGRouteMgr>(SGSubsystemMgr::GENERAL);
globals->add_subsystem( "io", new FGIO, SGSubsystemMgr::GENERAL );
globals->add_subsystem("logger", new FGLogger, SGSubsystemMgr::GENERAL);
globals->add_new_subsystem<FGControls>(SGSubsystemMgr::GENERAL);
globals->add_new_subsystem<FGInput>(SGSubsystemMgr::GENERAL);
globals->add_subsystem("history", new FGFlightHistory, SGSubsystemMgr::GENERAL);
{
SGSubsystem * httpd = flightgear::http::FGHttpd::createInstance( fgGetNode(flightgear::http::PROPERTY_ROOT) );
if( NULL != httpd )
globals->add_subsystem("httpd", httpd, SGSubsystemMgr::GENERAL );
}
if (!duringReset) {
globals->add_subsystem("tides", new FGTide, SGSubsystemMgr::GENERAL );
}
}
// SGSubsystemMgr::FDM
{
globals->add_subsystem("flight", new FDMShell, SGSubsystemMgr::FDM);
// Initialize the aircraft systems and instrumentation (before the
// autopilot.)
globals->add_subsystem("systems", new FGSystemMgr, SGSubsystemMgr::FDM);
globals->add_subsystem("instrumentation", new FGInstrumentMgr, SGSubsystemMgr::FDM);
globals->add_subsystem("hud", new HUD, SGSubsystemMgr::DISPLAY);
globals->add_subsystem("cockpit-displays", new flightgear::CockpitDisplayManager, SGSubsystemMgr::DISPLAY);
globals->add_subsystem( "xml-autopilot", FGXMLAutopilotGroup::createInstance("autopilot"), SGSubsystemMgr::FDM );
globals->add_subsystem( "xml-proprules", FGXMLAutopilotGroup::createInstance("property-rule"), SGSubsystemMgr::GENERAL );
globals->add_new_subsystem<FGRouteMgr>(SGSubsystemMgr::GENERAL);
globals->add_subsystem( "io", new FGIO, SGSubsystemMgr::GENERAL );
globals->add_subsystem("logger", new FGLogger, SGSubsystemMgr::GENERAL);
globals->add_subsystem("gui", new NewGUI, SGSubsystemMgr::INIT);
}
simgear::canvas::Canvas::setSystemAdapter(
simgear::canvas::SystemAdapterPtr(new canvas::FGCanvasSystemAdapter)
);
globals->add_subsystem("Canvas", new CanvasMgr, SGSubsystemMgr::DISPLAY);
globals->add_subsystem("CanvasGUI", new GUIMgr, SGSubsystemMgr::DISPLAY);
// SGSubsystemMgr::POST_FDM
{
globals->add_new_subsystem<PerformanceDB>(SGSubsystemMgr::POST_FDM);
globals->add_subsystem("ATC", new FGATCManager, SGSubsystemMgr::POST_FDM);
globals->add_subsystem("mp", new FGMultiplayMgr, SGSubsystemMgr::POST_FDM);
@ -999,22 +1017,42 @@ void fgCreateSubsystems(bool duringReset) {
fgSetArchivable("/sim/panel/y-offset");
fgSetArchivable("/sim/panel/jitter");
globals->add_new_subsystem<FGControls>(SGSubsystemMgr::GENERAL);
globals->add_new_subsystem<FGInput>(SGSubsystemMgr::GENERAL);
// We also call FGReplay::unit() method here, to work around a
// problem where JSBSim appears to rely on FGReplay creating certain
// properties before it is initialised. This caused problems when
// FGReplay was changed to be POST_FDM.
globals->add_new_subsystem<FGReplay>(SGSubsystemMgr::POST_FDM)
->init(); // Special case.
}
globals->add_subsystem("history", new FGFlightHistory, SGSubsystemMgr::GENERAL);
// SGSubsystemMgr::DISPLAY
{
globals->add_subsystem("hud", new HUD, SGSubsystemMgr::DISPLAY);
globals->add_subsystem("cockpit-displays", new flightgear::CockpitDisplayManager, SGSubsystemMgr::DISPLAY);
simgear::canvas::Canvas::setSystemAdapter(
simgear::canvas::SystemAdapterPtr(new canvas::FGCanvasSystemAdapter)
);
globals->add_subsystem("Canvas", new CanvasMgr, SGSubsystemMgr::DISPLAY);
globals->add_subsystem("CanvasGUI", new GUIMgr, SGSubsystemMgr::DISPLAY);
#ifdef ENABLE_AUDIO_SUPPORT
globals->add_subsystem("voice", new FGVoiceMgr, SGSubsystemMgr::DISPLAY);
#endif
// ordering here is important : Nasal (via events), then models, then views
if (!duringReset) {
globals->add_subsystem("lighting", new FGLight, SGSubsystemMgr::DISPLAY);
globals->add_subsystem("events", globals->get_event_mgr(), SGSubsystemMgr::DISPLAY);
}
globals->add_new_subsystem<FGAircraftModel>(SGSubsystemMgr::DISPLAY);
globals->add_new_subsystem<FGModelMgr>(SGSubsystemMgr::DISPLAY);
globals->add_new_subsystem<FGViewMgr>(SGSubsystemMgr::DISPLAY);
}
// SGSubsystemMgr::SOUND
{
// Sound manager uses an own subsystem group "SOUND" which is the last
// to be updated in every loop.
// Sound manager is updated last so it can use the CPU while the GPU
@ -1029,23 +1067,7 @@ void fgCreateSubsystems(bool duringReset) {
// Sentry: FLIGHTGEAR-66
globals->add_new_subsystem<FGCom>(SGSubsystemMgr::SOUND);
#endif
{
SGSubsystem * httpd = flightgear::http::FGHttpd::createInstance( fgGetNode(flightgear::http::PROPERTY_ROOT) );
if( NULL != httpd )
globals->add_subsystem("httpd", httpd, SGSubsystemMgr::GENERAL );
}
// ordering here is important : Nasal (via events), then models, then views
if (!duringReset) {
globals->add_subsystem("lighting", new FGLight, SGSubsystemMgr::DISPLAY);
globals->add_subsystem("events", globals->get_event_mgr(), SGSubsystemMgr::DISPLAY);
globals->add_subsystem("tides", new FGTide, SGSubsystemMgr::GENERAL );
}
globals->add_new_subsystem<FGAircraftModel>(SGSubsystemMgr::DISPLAY);
globals->add_new_subsystem<FGModelMgr>(SGSubsystemMgr::DISPLAY);
globals->add_new_subsystem<FGViewMgr>(SGSubsystemMgr::DISPLAY);
}
void fgPostInitSubsystems()