Ref T270, Ref T268, plugin common / simulator improvements

* connect with "about to quit"
* added interface declarations
* sim statistics, use common function setStatsRemoteAircraftUpdate and double for average values
This commit is contained in:
Klaus Basan
2018-05-30 12:51:07 +02:00
parent 2923df27e2
commit aa7363dcad
11 changed files with 114 additions and 48 deletions

View File

@@ -80,6 +80,8 @@ namespace BlackCore
connect(sApp->getWebDataServices(), &CWebDataServices::swiftDbModelMatchingEntitiesRead, this, &CSimulatorCommon::onSwiftDbModelMatchingEntitiesRead, Qt::QueuedConnection);
}
connect(sApp, &CApplication::aboutToShutdown, this, &CSimulatorCommon::unload, Qt::QueuedConnection);
// info
CLogMessage(this).info("Initialized simulator driver: '%1'") << this->getSimulatorInfo().toQString();
}
@@ -299,6 +301,12 @@ namespace BlackCore
m_remoteAircraftProviderConnections.disconnectAll(); // disconnect signals from provider
}
bool CSimulatorCommon::disconnectFrom()
{
// supposed to be overridden
return true;
}
bool CSimulatorCommon::isShuttingDown() const
{
return (!sApp || sApp->isShuttingDown());
@@ -574,7 +582,7 @@ namespace BlackCore
void CSimulatorCommon::resetAircraftStatistics()
{
m_statsUpdateAircraftCountMs = 0;
m_statsUpdateAircraftRuns = 0;
m_statsUpdateAircraftTimeAvgMs = 0;
m_statsUpdateAircraftTimeTotalMs = 0;
m_statsPhysicallyAddedAircraft = 0;
@@ -628,6 +636,15 @@ namespace BlackCore
m_clampedLogMsg.remove(callsign);
}
void CSimulatorCommon::setStatsRemoteAircraftUpdate(qint64 startTime)
{
const qint64 dt = QDateTime::currentMSecsSinceEpoch() - startTime;
m_statsUpdateAircraftTimeTotalMs += dt;
m_statsUpdateAircraftRuns++;
m_statsUpdateAircraftTimeAvgMs = static_cast<double>(m_statsUpdateAircraftTimeTotalMs) / static_cast<double>(m_statsUpdateAircraftRuns);
m_updateRemoteAircraftInProgress = false;
}
void CSimulatorCommon::onRecalculatedRenderedAircraft(const CAirspaceAircraftSnapshot &snapshot)
{
if (!snapshot.isValidSnapshot()) { return;}
@@ -710,6 +727,7 @@ namespace BlackCore
m_addAgainAircraftWhenRemoved.clear();
m_callsignsToBeRendered.clear();
m_clampedLogMsg.clear();
m_updateRemoteAircraftInProgress = false;
this->resetHighlighting();
this->resetAircraftStatistics();