Ref T410, simConnectProc / FsxCommon SB area

* count number of received data
* set network and SB running flag
This commit is contained in:
Klaus Basan
2018-11-01 20:11:32 +01:00
parent e98a420d5d
commit 212460f676
3 changed files with 16 additions and 4 deletions

View File

@@ -347,12 +347,21 @@ namespace BlackSimPlugin
void CSimulatorFsxCommon::setFlightNetworkConnected(bool connected)
{
// toggled?
if (connected == !this->isFlightNetworkConnected())
{
// toggling, we trace for a while to better monitor those "critical" phases
this->triggerAutoTraceSendId();
}
// update SB area network connected
byte sbNetworkConnected = connected ? 1u : 0u;
HRESULT hr = SimConnect_SetClientData(m_hSimConnect, ClientAreaSquawkBox, CSimConnectDefinitions::DataClientAreaSbConnected, SIMCONNECT_CLIENT_DATA_REQUEST_FLAG_DEFAULT, 0, 1, &sbNetworkConnected);
if (isFailure(hr))
{
CLogMessage(this).warning("Setting network connected failed (SB offsets)");
}
ISimulator::setFlightNetworkConnected(connected);
}
@@ -418,7 +427,7 @@ namespace BlackSimPlugin
void CSimulatorFsxCommon::onSimRunningDeferred(qint64 referenceTs)
{
if (m_simSimulating) { return; }
if (m_simSimulating) { return; } // already simulatig
if (referenceTs != m_simulatingChangedTs) { return; } // changed, so no longer valid
m_simSimulating = true; // only place where this should be set to true
m_simConnected = true;
@@ -439,8 +448,8 @@ namespace BlackSimPlugin
SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_SECOND, SIMCONNECT_DATA_REQUEST_FLAG_CHANGED),
"Cannot request sim.env.", Q_FUNC_INFO, "SimConnect_RequestDataOnSimObject");
// Request the data from SB only when its changed and only ONCE so we don't have to run a 1sec event to get/set this info ;)
// there was a bug with SIMCONNECT_CLIENT_DATA_PERIOD_ON_SET, see https://www.prepar3d.com/forum/viewtopic.php?t=124789
HRESULT hr4 = this->logAndTraceSendId(
SimConnect_RequestClientData(m_hSimConnect, ClientAreaSquawkBox, CSimConnectDefinitions::RequestSbData,
CSimConnectDefinitions::DataClientAreaSb, SIMCONNECT_CLIENT_DATA_PERIOD_SECOND, SIMCONNECT_CLIENT_DATA_REQUEST_FLAG_CHANGED),
@@ -2194,7 +2203,8 @@ namespace BlackSimPlugin
m_simulatingChangedTs = -1;
m_simConnected = false;
m_simSimulating = false;
m_syncDeferredCounter = 0;
m_sbDataReceived = 0;
m_syncTimeDeferredCounter = 0;
m_skipCockpitUpdateCycles = 0;
m_ownAircraftUpdate = 0;
m_requestIdSimObjAircraft = static_cast<SIMCONNECT_DATA_REQUEST_ID>(RequestSimObjAircraftStart);

View File

@@ -556,7 +556,8 @@ namespace BlackSimPlugin
bool m_traceSendId = false; //!< trace the send ids, meant for debugging
qint64 m_traceAutoUntilTs = -1; //!< allows to automatically trace for some time
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_sbDataReceived = 0; //!< SB4 area data received
int m_syncTimeDeferredCounter = 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_ownAircraftUpdate = 0; //!< own aircraft update

View File

@@ -372,6 +372,7 @@ namespace BlackSimPlugin
case SIMCONNECT_RECV_ID_CLIENT_DATA:
{
if (!simulatorFsxP3D->m_useSbOffsets) { break; }
simulatorFsxP3D->m_sbDataReceived++;
const SIMCONNECT_RECV_CLIENT_DATA *clientData = static_cast<SIMCONNECT_RECV_CLIENT_DATA *>(pData);
if (clientData->dwRequestID == CSimConnectDefinitions::RequestSbData)
{