mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-12 23:35:33 +08:00
Ref T180, function to stop requesting remote aircraft data
Also added details to trace function
This commit is contained in:
@@ -1458,6 +1458,27 @@ namespace BlackSimPlugin
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CSimulatorFsxCommon::stopRequestingDataForSimObject(const CSimConnectObject &simObject)
|
||||||
|
{
|
||||||
|
if (!simObject.hasValidRequestAndObjectId()) { return false; }
|
||||||
|
if (!m_hSimConnect) { return false; }
|
||||||
|
|
||||||
|
// always request, not only when something has changed
|
||||||
|
HRESULT result = SimConnect_RequestDataOnSimObject(
|
||||||
|
m_hSimConnect, simObject.getRequestId() + RequestSimDataOffset,
|
||||||
|
CSimConnectDefinitions::DataRemoteAircraftGetPosition,
|
||||||
|
simObject.getObjectId(), SIMCONNECT_PERIOD_NEVER);
|
||||||
|
if (result == S_OK) { if (m_traceSendId) { this->traceSendId(simObject.getObjectId(), Q_FUNC_INFO, "Position");} }
|
||||||
|
|
||||||
|
result = SimConnect_RequestDataOnSimObject(
|
||||||
|
m_hSimConnect, simObject.getRequestId() + RequestLightsOffset,
|
||||||
|
CSimConnectDefinitions::DataRemoteAircraftLights, simObject.getObjectId(),
|
||||||
|
SIMCONNECT_PERIOD_NEVER);
|
||||||
|
if (result == S_OK) { if (m_traceSendId) { this->traceSendId(simObject.getObjectId(), Q_FUNC_INFO, "Lights");} }
|
||||||
|
Q_UNUSED(result);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void CSimulatorFsxCommon::initSimulatorInternals()
|
void CSimulatorFsxCommon::initSimulatorInternals()
|
||||||
{
|
{
|
||||||
CSimulatorFsCommon::initSimulatorInternals();
|
CSimulatorFsCommon::initSimulatorInternals();
|
||||||
@@ -1550,7 +1571,7 @@ namespace BlackSimPlugin
|
|||||||
return simObjectCallsigns.difference(providerCallsigns);
|
return simObjectCallsigns.difference(providerCallsigns);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimulatorFsxCommon::traceSendId(DWORD simObjectId, const QString &comment)
|
void CSimulatorFsxCommon::traceSendId(DWORD simObjectId, const QString &function, const QString &details)
|
||||||
{
|
{
|
||||||
if (!m_traceSendId) { return; }
|
if (!m_traceSendId) { return; }
|
||||||
if (MaxSendIdTraces < 1) { return; }
|
if (MaxSendIdTraces < 1) { return; }
|
||||||
@@ -1558,8 +1579,9 @@ namespace BlackSimPlugin
|
|||||||
const HRESULT hr = SimConnect_GetLastSentPacketID(m_hSimConnect, &dwLastId);
|
const HRESULT hr = SimConnect_GetLastSentPacketID(m_hSimConnect, &dwLastId);
|
||||||
if (hr != S_OK || dwLastId < 0) { return; }
|
if (hr != S_OK || dwLastId < 0) { return; }
|
||||||
if (m_sendIdTraces.size() > MaxSendIdTraces) { m_sendIdTraces.removeFirst(); }
|
if (m_sendIdTraces.size() > MaxSendIdTraces) { m_sendIdTraces.removeFirst(); }
|
||||||
const TraceFsxSendId t(dwLastId, simObjectId, comment);
|
const TraceFsxSendId trace(dwLastId, simObjectId,
|
||||||
m_sendIdTraces.push_back(t);
|
details.isEmpty() ? function : details + ", " + function);
|
||||||
|
m_sendIdTraces.push_back(trace);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CSimulatorFsxCommon::getSendIdTraceDetails(DWORD sendId) const
|
QString CSimulatorFsxCommon::getSendIdTraceDetails(DWORD sendId) const
|
||||||
|
|||||||
@@ -302,6 +302,9 @@ namespace BlackSimPlugin
|
|||||||
//! Request lights for a CSimConnectObject
|
//! Request lights for a CSimConnectObject
|
||||||
bool requestLightsForSimObject(const CSimConnectObject &simObject);
|
bool requestLightsForSimObject(const CSimConnectObject &simObject);
|
||||||
|
|
||||||
|
//! Stop requesting data for CSimConnectObject
|
||||||
|
bool stopRequestingDataForSimObject(const CSimConnectObject &simObject);
|
||||||
|
|
||||||
//! FSX position as string
|
//! FSX position as string
|
||||||
static QString fsxPositionToString(const SIMCONNECT_DATA_INITPOSITION &position);
|
static QString fsxPositionToString(const SIMCONNECT_DATA_INITPOSITION &position);
|
||||||
|
|
||||||
@@ -312,7 +315,7 @@ namespace BlackSimPlugin
|
|||||||
void setTraceSendId(bool traceSendId) { m_traceSendId = traceSendId; }
|
void setTraceSendId(bool traceSendId) { m_traceSendId = traceSendId; }
|
||||||
|
|
||||||
//! Trace the send id
|
//! Trace the send id
|
||||||
void traceSendId(DWORD simObjectId, const QString &comment);
|
void traceSendId(DWORD simObjectId, const QString &function, const QString &details = {});
|
||||||
|
|
||||||
//! Get the trace details, otherwise empty string
|
//! Get the trace details, otherwise empty string
|
||||||
QString getSendIdTraceDetails(DWORD sendId) const;
|
QString getSendIdTraceDetails(DWORD sendId) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user