mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 23:25:53 +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:
@@ -114,8 +114,7 @@ namespace BlackSimPlugin
|
||||
this->reset(); // mark as disconnected and reset all values
|
||||
|
||||
// emit status and disconnect FSUIPC
|
||||
CSimulatorFsCommon::disconnectFrom();
|
||||
return true;
|
||||
return CSimulatorFsCommon::disconnectFrom();
|
||||
}
|
||||
|
||||
bool CSimulatorFsxCommon::physicallyAddRemoteAircraft(const CSimulatedAircraft &newRemoteAircraft)
|
||||
@@ -367,7 +366,17 @@ namespace BlackSimPlugin
|
||||
|
||||
void CSimulatorFsxCommon::onSimFrame()
|
||||
{
|
||||
this->updateRemoteAircraft();
|
||||
QPointer<CSimulatorFsxCommon> myself(this);
|
||||
if (m_updateRemoteAircraftInProgress)
|
||||
{
|
||||
return;
|
||||
}
|
||||
QTimer::singleShot(0, this, [ = ]
|
||||
{
|
||||
// run decoupled from simconnect event queue
|
||||
if (!myself) { return; }
|
||||
myself->updateRemoteAircraft();
|
||||
});
|
||||
}
|
||||
|
||||
void CSimulatorFsxCommon::onSimExit()
|
||||
@@ -1236,13 +1245,11 @@ namespace BlackSimPlugin
|
||||
|
||||
// nothing to do, reset request id and exit
|
||||
const int remoteAircraftNo = this->getAircraftInRangeCount();
|
||||
if (remoteAircraftNo < 1) { m_interpolationRequest = 0; return; }
|
||||
|
||||
// interpolate and send to simulator
|
||||
m_interpolationRequest++;
|
||||
if (remoteAircraftNo < 1) { m_statsUpdateAircraftRuns = 0; return; }
|
||||
|
||||
// values used for position and parts
|
||||
const qint64 currentTimestamp = QDateTime::currentMSecsSinceEpoch();
|
||||
m_updateRemoteAircraftInProgress = true;
|
||||
|
||||
// interpolation for all remote aircraft
|
||||
const QList<CSimConnectObject> simObjects(m_simConnectObjects.values());
|
||||
@@ -1298,10 +1305,8 @@ namespace BlackSimPlugin
|
||||
|
||||
} // all callsigns
|
||||
|
||||
const qint64 dt = QDateTime::currentMSecsSinceEpoch() - currentTimestamp;
|
||||
m_statsUpdateAircraftTimeTotalMs += dt;
|
||||
m_statsUpdateAircraftCountMs++;
|
||||
m_statsUpdateAircraftTimeAvgMs = m_statsUpdateAircraftTimeTotalMs / m_statsUpdateAircraftCountMs;
|
||||
// stats
|
||||
this->setStatsRemoteAircraftUpdate(currentTimestamp);
|
||||
}
|
||||
|
||||
bool CSimulatorFsxCommon::updateRemoteAircraftParts(const CSimConnectObject &simObject, const CInterpolationResult &result)
|
||||
@@ -1608,7 +1613,6 @@ namespace BlackSimPlugin
|
||||
m_simSimulating = false;
|
||||
m_syncDeferredCounter = 0;
|
||||
m_skipCockpitUpdateCycles = 0;
|
||||
m_interpolationRequest = 0;
|
||||
m_requestIdSimData = static_cast<SIMCONNECT_DATA_REQUEST_ID>(RequestIdSimDataStart);
|
||||
m_dispatchErrors = 0;
|
||||
m_receiveExceptionCount = 0;
|
||||
@@ -1618,6 +1622,7 @@ namespace BlackSimPlugin
|
||||
// m_simConnectObjects
|
||||
// m_simConnectObjectsPositionAndPartsTraces
|
||||
// m_addPendingAircraft
|
||||
// m_updateRemoteAircraftInProgress
|
||||
CSimulatorFsCommon::reset(); // clears all pending aircraft etc
|
||||
}
|
||||
|
||||
|
||||
@@ -249,7 +249,7 @@ namespace BlackSimPlugin
|
||||
//! Deferred version of onSimRunning to avoid jitter
|
||||
void onSimRunningDefered(qint64 referenceTs);
|
||||
|
||||
//! Slot called every visual frame
|
||||
//! Called every visual frame
|
||||
void onSimFrame();
|
||||
|
||||
//! Called when simulator has stopped, e.g. by selecting the "select aircraft screen"
|
||||
@@ -393,11 +393,10 @@ namespace BlackSimPlugin
|
||||
bool m_useSbOffsets = true; //!< with SB offsets
|
||||
bool m_traceSendId = false; //!< trace the send ids, meant for debugging
|
||||
qint64 m_simulatingChangedTs = -1; //!< timestamp, when simulating changed (used to avoid jitter)
|
||||
int m_syncDeferredCounter = 0; //!< Set when synchronized, used to wait some time
|
||||
int m_skipCockpitUpdateCycles = 0; //!< skip some update cycles to allow changes in simulator cockpit to be set
|
||||
int m_interpolationRequest = 0; //!< current interpolation request
|
||||
int m_dispatchErrors = 0; //!< number of dispatched failed, \sa dispatch
|
||||
int m_receiveExceptionCount = 0; //!< exceptions
|
||||
int m_syncDeferredCounter = 0; //!< Set when synchronized, used to wait some time
|
||||
int m_skipCockpitUpdateCycles = 0; //!< skip some update cycles to allow changes in simulator cockpit to be set
|
||||
int m_dispatchErrors = 0; //!< number of dispatched failed, \sa dispatch
|
||||
int m_receiveExceptionCount = 0; //!< exceptions
|
||||
QList<TraceFsxSendId> m_sendIdTraces; //!< Send id traces for debugging
|
||||
CSimConnectObjects m_simConnectObjects; //!< AI objects and their object / request ids
|
||||
CSimConnectObjects m_simConnectProbes; //!< AI terrain probes
|
||||
|
||||
Reference in New Issue
Block a user