]> git.mxchange.org Git - flightgear.git/commitdiff
Add new performance monitoring subsystem.
authorThorstenB <brehmt@gmail.com>
Sat, 19 Nov 2011 14:37:49 +0000 (15:37 +0100)
committerThorstenB <brehmt@gmail.com>
Sat, 19 Nov 2011 14:37:49 +0000 (15:37 +0100)
Rename some subsystems for naming consistency.

src/AIModel/AIManager.cxx
src/AIModel/submodel.cxx
src/Main/fg_init.cxx
src/Main/globals.cxx
src/Main/main.cxx
src/MultiPlayer/multiplaymgr.cxx
src/Network/HLA/hla.cxx
src/Time/TimeManager.cxx
src/Time/TimeManager.hxx
src/Traffic/Schedule.cxx

index 2ad54837113ec7a6d5e22ca48583208603d54c82..731983f25dc710c4ced8042edbc7e1ebf4b85f13 100644 (file)
@@ -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();
index a25212198584427cbcb3fa74c4013d6cce694153..83bb681b071665aaac8f6e908e6b8122714fa278 100644 (file)
@@ -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()
index 4a1881da96541b052571f76f6831a672369ab499..7e842f9baf8f7cf90e9228150c641e98fdd6faf3 100644 (file)
@@ -56,6 +56,7 @@
 #include <simgear/debug/logstream.hxx>
 #include <simgear/structure/exception.hxx>
 #include <simgear/structure/event_mgr.hxx>
+#include <simgear/structure/SGPerfMon.hxx>
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/misc/sg_dir.hxx>
 #include <simgear/misc/sgstream.hxx>
@@ -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();
index 5f5fa60a353f76ff82e846e2bf1622dd55899db6..dc48bd8467ed543dd5d94cd14ec484f5728b6b72 100644 (file)
@@ -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;
index 3532bcb5ea4fdac6a5900238c49989b8f95eda87..3afaeceaef43e33c82a85aa6bc9454b904136b65 100644 (file)
@@ -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, "" );
index 22703a28c612cc5c1d60476608be8b465c207b35..123317c63536b25d5d9893f8fd13a41a7e09055c 100644 (file)
@@ -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);
 
index 22450de1073eef224071a024504bbf844b958986..5f8d157310649eae1a7f5e176c0dfd9904d8858a 100644 (file)
@@ -701,7 +701,7 @@ public:
             if (modelPath.empty())
                 return;
             FGAIManager *aiMgr;
-            aiMgr = static_cast<FGAIManager*>(globals->get_subsystem("ai_model"));
+            aiMgr = static_cast<FGAIManager*>(globals->get_subsystem("ai-model"));
             if (!aiMgr)
                 return;
 
index eb3bb25a167fd98d9b6991d9275ed1bb1b2a034b..00f6f31b9a50560a45e57cac9157b12f680ce91b 100644 (file)
@@ -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;
   }
index 6f0d35acbbfa858e77a756e455a18b7b4785f755..10226eaf63446f4882f93db65ada92a9284eaaf2 100644 (file)
@@ -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;
index 4314d0237b5abed9679d36ca7fd0148c14d800fe..85343db293fb8d605537eb8e2aea936ec8f06b6e 100644 (file)
@@ -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 &currentDesti
 {
     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);