mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
refs #395, moved thread safe aircraft parts / situations (from interpolator) to airspace
* access via provider, access now possible also beyond the scope of interpolator * will be used in (to be written airpace analyzer) * renamed some member functions as required * fixed some asserts / Doxygen comments * adjusted unit tests * added vtolAircraft flag for interpolator, not fully used everywhere remarks: update signals for parts / situation still only needed in XP driver
This commit is contained in:
committed by
Mathew Sutcliffe
parent
32e65669a3
commit
48188dd28d
@@ -76,13 +76,13 @@ namespace BlackSimPlugin
|
||||
void CFs9Client::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
Q_ASSERT(m_interpolator);
|
||||
Q_ASSERT_X(m_interpolator, Q_FUNC_INFO, "Missing interpolator");
|
||||
|
||||
if (m_clientStatus == Disconnected) { return; }
|
||||
|
||||
|
||||
IInterpolator::InterpolationStatus status;
|
||||
CAircraftSituation situation = this->m_interpolator->getInterpolatedSituation(m_callsign, -1, status);
|
||||
bool vtolAircraft(false);
|
||||
CAircraftSituation situation = this->m_interpolator->getInterpolatedSituation(m_callsign, -1, vtolAircraft, status);
|
||||
|
||||
// Test only for successful interpolation. FS9 requires constant positions
|
||||
if (!status.interpolationSucceeded) { return; }
|
||||
|
||||
@@ -151,8 +151,8 @@ namespace BlackSimPlugin
|
||||
CLogMessage(this).warning("Have to remove aircraft %1 before I can add it") << callsign;
|
||||
}
|
||||
|
||||
CSimulatedAircraft newRemoteAircraftCopy(newRemoteAircraft);
|
||||
this->setInitialAircraftSituationAndParts(newRemoteAircraftCopy);
|
||||
CSimulatedAircraft newRemoteAircraftCopy(newRemoteAircraft); // copy which can be modified
|
||||
this->setInitialAircraftSituationAndParts(newRemoteAircraftCopy); // set interpolated data/parts if available
|
||||
SIMCONNECT_DATA_INITPOSITION initialPosition = aircraftSituationToFsxInitPosition(newRemoteAircraftCopy.getSituation());
|
||||
|
||||
CSimConnectObject simObj;
|
||||
@@ -611,7 +611,7 @@ namespace BlackSimPlugin
|
||||
{
|
||||
static_assert(sizeof(DataDefinitionRemoteAircraftParts) == 120, "DataDefinitionRemoteAircraftParts has an incorrect size.");
|
||||
Q_ASSERT(this->m_interpolator);
|
||||
Q_ASSERT_X(this->m_interpolator->thread() != this->thread(), "updateOtherAircraft", "interpolator should run in its own thread");
|
||||
Q_ASSERT_X(this->m_interpolator->thread() != this->thread(), Q_FUNC_INFO, "interpolator should run in its own thread");
|
||||
|
||||
// nothing to do, reset request id and exit
|
||||
if (this->isPaused()) { return; } // no interpolation while paused
|
||||
@@ -623,19 +623,29 @@ namespace BlackSimPlugin
|
||||
|
||||
// values used for position and parts
|
||||
bool isOnGround = false;
|
||||
bool isVtolAircraft = false; //! \todo determine VTOL aircraft in interpolator
|
||||
|
||||
qint64 currentTimestamp = QDateTime::currentMSecsSinceEpoch();
|
||||
CCallsignSet aircraftWithParts(this->remoteAircraftSupportingParts()); // optimization, fetch all parts supporting aircraft in one step (one lock)
|
||||
|
||||
for (const CSimConnectObject &simObj : m_simConnectObjects)
|
||||
{
|
||||
if (simObj.getObjectId() < 1) { continue; }
|
||||
|
||||
const CCallsign callsign(simObj.getCallsign());
|
||||
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "missing callsign");
|
||||
IInterpolator::InterpolationStatus interpolatorStatus;
|
||||
if (simObj.getObjectId() == 0) { continue; }
|
||||
CAircraftSituation interpolatedSituation = this->m_interpolator->getInterpolatedSituation(callsign, currentTimestamp, interpolatorStatus);
|
||||
CAircraftSituation interpolatedSituation = this->m_interpolator->getInterpolatedSituation(callsign, currentTimestamp, isVtolAircraft, interpolatorStatus);
|
||||
|
||||
// having the onGround flag in parts forces me to obtain parts here
|
||||
// which is not the smartest thing regarding performance
|
||||
IInterpolator::PartsStatus partsStatus;
|
||||
CAircraftPartsList parts = this->m_interpolator->getAndRemovePartsBeforeTime(callsign, currentTimestamp - IInterpolator::TimeOffsetMs, partsStatus);
|
||||
partsStatus.supportsParts = aircraftWithParts.contains(callsign);
|
||||
CAircraftPartsList parts;
|
||||
if (partsStatus.supportsParts)
|
||||
{
|
||||
this->m_interpolator->getPartsBeforeTime(callsign, currentTimestamp - IInterpolator::TimeOffsetMs, partsStatus);
|
||||
}
|
||||
|
||||
if (interpolatorStatus.allTrue())
|
||||
{
|
||||
@@ -643,6 +653,7 @@ namespace BlackSimPlugin
|
||||
SIMCONNECT_DATA_INITPOSITION position = aircraftSituationToFsxInitPosition(interpolatedSituation);
|
||||
|
||||
//! \todo The onGround in parts is nuts, as already mentioned in the discussion
|
||||
// Currently ignored here, only guessing which is faster as aircraft without parts can just be
|
||||
// a) I am forced to read parts even if i just want to update position
|
||||
// b) Unlike the other values it is not a fire and forget value, as I need it again in the next cycle
|
||||
if (partsStatus.supportsParts && !parts.isEmpty())
|
||||
@@ -662,8 +673,6 @@ namespace BlackSimPlugin
|
||||
sizeof(SIMCONNECT_DATA_INITPOSITION), &position);
|
||||
if (hr != S_OK) { CLogMessage(this).warning("Failed so set position on SimObject %1 callsign: %2") << simObj.getObjectId() << callsign; }
|
||||
|
||||
|
||||
|
||||
} // interpolation data
|
||||
|
||||
if (interpolatorStatus.interpolationSucceeded)
|
||||
|
||||
@@ -47,10 +47,13 @@ namespace BlackSimPlugin
|
||||
m_watcher = new QDBusServiceWatcher(this);
|
||||
m_watcher->setWatchMode(QDBusServiceWatcher::WatchForUnregistration);
|
||||
m_watcher->addWatchedService(xbusServiceName());
|
||||
m_watcher->setObjectName("QDBusServiceWatcher");
|
||||
connect(m_watcher, &QDBusServiceWatcher::serviceUnregistered, this, &CSimulatorXPlane::ps_serviceUnregistered);
|
||||
|
||||
m_fastTimer = new QTimer(this);
|
||||
m_slowTimer = new QTimer(this);
|
||||
m_fastTimer->setObjectName(this->objectName().append(":m_fastTimer"));
|
||||
m_slowTimer->setObjectName(this->objectName().append(":m_slowTimer"));
|
||||
connect(m_fastTimer, &QTimer::timeout, this, &CSimulatorXPlane::ps_fastTimerTimeout);
|
||||
connect(m_slowTimer, &QTimer::timeout, this, &CSimulatorXPlane::ps_slowTimerTimeout);
|
||||
m_fastTimer->start(100);
|
||||
|
||||
Reference in New Issue
Block a user