From 4b2506d709fb03d7021ac9be1e259e0fa46625d9 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sat, 19 Nov 2011 15:37:49 +0100 Subject: [PATCH 01/18] Add new performance monitoring subsystem. Rename some subsystems for naming consistency. --- src/AIModel/AIManager.cxx | 2 +- src/AIModel/submodel.cxx | 2 +- src/Main/fg_init.cxx | 19 ++++++++++++++----- src/Main/globals.cxx | 2 +- src/Main/main.cxx | 30 ------------------------------ src/MultiPlayer/multiplaymgr.cxx | 2 +- src/Network/HLA/hla.cxx | 2 +- src/Time/TimeManager.cxx | 3 +++ src/Time/TimeManager.hxx | 1 + src/Traffic/Schedule.cxx | 6 +++--- 10 files changed, 26 insertions(+), 43 deletions(-) diff --git a/src/AIModel/AIManager.cxx b/src/AIModel/AIManager.cxx index 2ad548371..731983f25 100644 --- a/src/AIModel/AIManager.cxx +++ b/src/AIModel/AIManager.cxx @@ -146,7 +146,7 @@ FGAIManager::update(double dt) { if (!enabled) return; - FGTrafficManager *tmgr = (FGTrafficManager*) globals->get_subsystem("Traffic Manager"); + FGTrafficManager *tmgr = (FGTrafficManager*) globals->get_subsystem("traffic-manager"); _dt = dt; ai_list_iterator ai_list_itr = ai_list.begin(); diff --git a/src/AIModel/submodel.cxx b/src/AIModel/submodel.cxx index a25212198..83bb681b0 100644 --- a/src/AIModel/submodel.cxx +++ b/src/AIModel/submodel.cxx @@ -45,7 +45,7 @@ FGSubmodelMgr::~FGSubmodelMgr() FGAIManager* FGSubmodelMgr::aiManager() { - return (FGAIManager*)globals->get_subsystem("ai_model"); + return (FGAIManager*)globals->get_subsystem("ai-model"); } void FGSubmodelMgr::init() diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 4a1881da9..7e842f9ba 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -1199,6 +1200,14 @@ bool fgInitSubsystems() { //////////////////////////////////////////////////////////////////// globals->add_subsystem("properties", new FGProperties); + + //////////////////////////////////////////////////////////////////// + // Add the performance monitoring system. + //////////////////////////////////////////////////////////////////// + globals->add_subsystem("performance-mon", + new SGPerformanceMonitor(globals->get_subsystem_mgr(), + fgGetNode("/sim/performance", true))); + //////////////////////////////////////////////////////////////////// // Initialize the material property subsystem. //////////////////////////////////////////////////////////////////// @@ -1282,7 +1291,7 @@ bool fgInitSubsystems() { // sub system infrastructure. //////////////////////////////////////////////////////////////////// - globals->add_subsystem("Old ATC", new FGATCMgr, SGSubsystemMgr::INIT); + globals->add_subsystem("ATC-old", new FGATCMgr, SGSubsystemMgr::INIT); //////////////////////////////////////////////////////////////////// // Initialize the ATC subsystem @@ -1304,14 +1313,14 @@ bool fgInitSubsystems() { // Initialise the AI Model Manager //////////////////////////////////////////////////////////////////// SG_LOG(SG_GENERAL, SG_INFO, " AI Model Manager"); - globals->add_subsystem("ai_model", new FGAIManager, SGSubsystemMgr::POST_FDM); - globals->add_subsystem("submodel_mgr", new FGSubmodelMgr, SGSubsystemMgr::POST_FDM); + globals->add_subsystem("ai-model", new FGAIManager, SGSubsystemMgr::POST_FDM); + globals->add_subsystem("submodel-mgr", new FGSubmodelMgr, SGSubsystemMgr::POST_FDM); // It's probably a good idea to initialize the top level traffic manager // After the AI and ATC systems have been initialized properly. // AI Traffic manager - globals->add_subsystem("Traffic Manager", new FGTrafficManager, SGSubsystemMgr::POST_FDM); + globals->add_subsystem("traffic-manager", new FGTrafficManager, SGSubsystemMgr::POST_FDM); //////////////////////////////////////////////////////////////////// // Add a new 2D panel. @@ -1446,7 +1455,7 @@ void fgReInitSubsystems() // Force reupdating the positions of the ai 3d models. They are used for // initializing ground level for the FDM. - globals->get_subsystem("ai_model")->reinit(); + globals->get_subsystem("ai-model")->reinit(); // Initialize the FDM globals->get_subsystem("flight")->reinit(); diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index 5f5fa60a3..dc48bd846 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -167,7 +167,7 @@ FGGlobals::~FGGlobals() // deallocation of AIModel objects. To ensure we can safely // shut down all subsystems, make sure we take down the // AIModels system first. - SGSubsystem* ai = subsystem_mgr->remove("ai_model"); + SGSubsystem* ai = subsystem_mgr->remove("ai-model"); if (ai) { ai->unbind(); delete ai; diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 3532bcb5e..3afaeceae 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -108,15 +108,6 @@ static void fgMainLoop( void ) static SGPropertyNode_ptr frame_signal = fgGetNode("/sim/signals/frame", true); - static SGPropertyNode_ptr _statisticsFlag - = fgGetNode("/sim/timing-statistics/enabled", true); - static SGPropertyNode_ptr _statisticsInterval - = fgGetNode("/sim/timing-statistics/interval-s", true); - static SGPropertyNode_ptr _statiticsMinJitter - = fgGetNode("/sim/timing-statistics/min-jitter-ms", true); - static SGPropertyNode_ptr _statiticsMinTime - = fgGetNode("/sim/timing-statistics/min-time-ms", true); - frame_signal->fireValueChanged(); SG_LOG( SG_GENERAL, SG_DEBUG, "Running Main Loop"); @@ -197,27 +188,6 @@ static void fgMainLoop( void ) } } - // print timing statistics - static bool _lastStatisticsFlag = false; - if (_lastStatisticsFlag != _statisticsFlag->getBoolValue()) - { - // flag has changed, update subsystem manager - _lastStatisticsFlag = _statisticsFlag->getBoolValue(); - globals->get_subsystem_mgr()->collectDebugTiming(_lastStatisticsFlag); - } - if (_lastStatisticsFlag) - { - static double elapsed = 0; - elapsed += real_dt; - if (elapsed >= _statisticsInterval->getDoubleValue()) - { - // print and reset timing statistics - globals->get_subsystem_mgr()->printTimingStatistics(_statiticsMinTime->getDoubleValue(), - _statiticsMinJitter->getDoubleValue()); - elapsed = 0; - } - } - simgear::AtomicChangeListener::fireChangeListeners(); SG_LOG( SG_GENERAL, SG_DEBUG, "" ); diff --git a/src/MultiPlayer/multiplaymgr.cxx b/src/MultiPlayer/multiplaymgr.cxx index 22703a28c..123317c63 100644 --- a/src/MultiPlayer/multiplaymgr.cxx +++ b/src/MultiPlayer/multiplaymgr.cxx @@ -1309,7 +1309,7 @@ FGMultiplayMgr::addMultiplayer(const std::string& callsign, mp->setCallSign(callsign); mMultiPlayerMap[callsign] = mp; - FGAIManager *aiMgr = (FGAIManager*)globals->get_subsystem("ai_model"); + FGAIManager *aiMgr = (FGAIManager*)globals->get_subsystem("ai-model"); if (aiMgr) { aiMgr->attach(mp); diff --git a/src/Network/HLA/hla.cxx b/src/Network/HLA/hla.cxx index 22450de10..5f8d15731 100644 --- a/src/Network/HLA/hla.cxx +++ b/src/Network/HLA/hla.cxx @@ -701,7 +701,7 @@ public: if (modelPath.empty()) return; FGAIManager *aiMgr; - aiMgr = static_cast(globals->get_subsystem("ai_model")); + aiMgr = static_cast(globals->get_subsystem("ai-model")); if (!aiMgr) return; diff --git a/src/Time/TimeManager.cxx b/src/Time/TimeManager.cxx index eb3bb25a1..00f6f31b9 100644 --- a/src/Time/TimeManager.cxx +++ b/src/Time/TimeManager.cxx @@ -102,6 +102,7 @@ void TimeManager::init() // frame-rate / worst-case latency / update-rate counters _frameRate = fgGetNode("/sim/frame-rate", true); _frameLatency = fgGetNode("/sim/frame-latency-max-ms", true); + _frameRateWorst = fgGetNode("/sim/frame-rate-worst", true); _lastFrameTime = 0; _frameLatencyMax = 0.0; _frameCount = 0; @@ -267,6 +268,8 @@ void TimeManager::computeFrameRate() if ((_impl->get_cur_time() != _lastFrameTime)) { _frameRate->setIntValue(_frameCount); _frameLatency->setDoubleValue(_frameLatencyMax*1000); + if (_frameLatencyMax>0) + _frameRateWorst->setIntValue(1/_frameLatencyMax); _frameCount = 0; _frameLatencyMax = 0.0; } diff --git a/src/Time/TimeManager.hxx b/src/Time/TimeManager.hxx index 6f0d35acb..10226eaf6 100644 --- a/src/Time/TimeManager.hxx +++ b/src/Time/TimeManager.hxx @@ -82,6 +82,7 @@ private: // frame-rate / worst-case latency / update-rate counters SGPropertyNode_ptr _frameRate; + SGPropertyNode_ptr _frameRateWorst; SGPropertyNode_ptr _frameLatency; time_t _lastFrameTime; double _frameLatencyMax; diff --git a/src/Traffic/Schedule.cxx b/src/Traffic/Schedule.cxx index 4314d0237..85343db29 100644 --- a/src/Traffic/Schedule.cxx +++ b/src/Traffic/Schedule.cxx @@ -228,7 +228,7 @@ bool FGAISchedule::update(time_t now, const SGVec3d& userCart) if (AIManagerRef) { // Check if this aircraft has been released. - FGTrafficManager *tmgr = (FGTrafficManager *) globals->get_subsystem("Traffic Manager"); + FGTrafficManager *tmgr = (FGTrafficManager *) globals->get_subsystem("traffic-manager"); if (tmgr->isReleased(AIManagerRef)) { AIManagerRef = 0; } else { @@ -347,7 +347,7 @@ bool FGAISchedule::createAIAircraft(FGScheduledFlight* flight, double speedKnots airline); if (fp->isValidPlan()) { aircraft->SetFlightPlan(fp); - FGAIManager* aimgr = (FGAIManager *) globals-> get_subsystem("ai_model"); + FGAIManager* aimgr = (FGAIManager *) globals-> get_subsystem("ai-model"); aimgr->attach(aircraft); AIManagerRef = aircraft->getID(); return true; @@ -465,7 +465,7 @@ FGScheduledFlight* FGAISchedule::findAvailableFlight (const string ¤tDesti { time_t now = time(NULL) + fgGetLong("/sim/time/warp"); - FGTrafficManager *tmgr = (FGTrafficManager *) globals->get_subsystem("Traffic Manager"); + FGTrafficManager *tmgr = (FGTrafficManager *) globals->get_subsystem("traffic-manager"); FGScheduledFlightVecIterator fltBegin, fltEnd; fltBegin = tmgr->getFirstFlight(req); fltEnd = tmgr->getLastFlight(req); From a05ea36acb143e1d50c70f5af444e3ffe50b5222 Mon Sep 17 00:00:00 2001 From: James Turner Date: Sat, 19 Nov 2011 20:25:51 +0000 Subject: [PATCH 02/18] Restructure GUI code, isolate PLIB in source files, to ease future refactoring and alternative GUI layers. --- src/ATC/atcdialog.cxx | 1 + src/ATCDCL/ATCDialogOld.cxx | 1 + src/Cockpit/panel.cxx | 2 +- src/GUI/CMakeLists.txt | 4 + src/GUI/FGColor.cxx | 54 +++++++ src/GUI/FGColor.hxx | 49 +++++++ src/GUI/FGFontCache.cxx | 223 ++++++++++++++++++++++++++++ src/GUI/FGFontCache.hxx | 96 +++++++++++++ src/GUI/dialog.cxx | 4 + src/GUI/gui.cxx | 1 + src/GUI/new_gui.cxx | 248 +------------------------------- src/GUI/new_gui.hxx | 118 +-------------- src/Instrumentation/HUD/HUD.cxx | 3 + src/Main/globals.cxx | 4 +- src/Main/main.cxx | 2 +- src/Main/splash.cxx | 5 +- utils/fgpanel/FGFontCache.cxx | 15 +- utils/fgpanel/FGFontCache.hxx | 10 +- 18 files changed, 469 insertions(+), 371 deletions(-) create mode 100644 src/GUI/FGColor.cxx create mode 100644 src/GUI/FGColor.hxx create mode 100644 src/GUI/FGFontCache.cxx create mode 100644 src/GUI/FGFontCache.hxx diff --git a/src/ATC/atcdialog.cxx b/src/ATC/atcdialog.cxx index 912f35446..5185ee0c0 100644 --- a/src/ATC/atcdialog.cxx +++ b/src/ATC/atcdialog.cxx @@ -24,6 +24,7 @@ #include
#include
+#include
#include #include diff --git a/src/ATCDCL/ATCDialogOld.cxx b/src/ATCDCL/ATCDialogOld.cxx index 20e2f1f83..b1824180c 100644 --- a/src/ATCDCL/ATCDialogOld.cxx +++ b/src/ATCDCL/ATCDialogOld.cxx @@ -30,6 +30,7 @@ #include
#include // mkDialog #include +#include
#include "ATCDialogOld.hxx" #include "ATC.hxx" diff --git a/src/Cockpit/panel.cxx b/src/Cockpit/panel.cxx index 916771726..6cdce3d70 100644 --- a/src/Cockpit/panel.cxx +++ b/src/Cockpit/panel.cxx @@ -57,7 +57,7 @@ #include
#include
#include