1
0
Fork 0

Add new performance monitoring subsystem.

Rename some subsystems for naming consistency.
This commit is contained in:
ThorstenB 2011-11-19 15:37:49 +01:00
parent c0c7dd4358
commit 4b2506d709
10 changed files with 26 additions and 43 deletions

View 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();

View 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()

View 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();

View 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;

View 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, "" );

View 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);

View 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;

View 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;
}

View 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;

View 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);