mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 21:56:43 +08:00
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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user