mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 19:05:31 +08:00
Ref T437, some FSUIPC style/message adjustments
This commit is contained in:
@@ -126,6 +126,8 @@ namespace BlackSimPlugin
|
|||||||
void processWeatherMessages();
|
void processWeatherMessages();
|
||||||
|
|
||||||
bool m_opened = false;
|
bool m_opened = false;
|
||||||
|
int m_openCount = 0; //!< statistics
|
||||||
|
int m_closeCount = 0; //!< statistics
|
||||||
int m_lastErrorIndex = 0;
|
int m_lastErrorIndex = 0;
|
||||||
QString m_lastErrorMessage;
|
QString m_lastErrorMessage;
|
||||||
QString m_fsuipcVersion;
|
QString m_fsuipcVersion;
|
||||||
|
|||||||
@@ -75,13 +75,16 @@ namespace BlackSimPlugin
|
|||||||
bool CFsuipc::open(bool force)
|
bool CFsuipc::open(bool force)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Open not threadsafe");
|
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Open not threadsafe");
|
||||||
DWORD result;
|
DWORD dwResult;
|
||||||
m_lastErrorMessage = "";
|
m_lastErrorMessage = "";
|
||||||
m_lastErrorIndex = 0;
|
m_lastErrorIndex = 0;
|
||||||
if (!force && m_opened) { return m_opened; } // already connected
|
if (!force && m_opened) { return m_opened; } // already connected
|
||||||
if (FSUIPC_Open(SIM_ANY, &result))
|
|
||||||
|
if (FSUIPC_Open(SIM_ANY, &dwResult))
|
||||||
{
|
{
|
||||||
m_opened = true; // temp status
|
m_opened = true; // temp status
|
||||||
|
m_openCount++;
|
||||||
|
|
||||||
if (this->isOpen())
|
if (this->isOpen())
|
||||||
{
|
{
|
||||||
const int simIndex = static_cast<int>(FSUIPC_FS_Version);
|
const int simIndex = static_cast<int>(FSUIPC_FS_Version);
|
||||||
@@ -103,7 +106,7 @@ namespace BlackSimPlugin
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const int index = static_cast<int>(result);
|
const int index = static_cast<int>(dwResult);
|
||||||
m_lastErrorIndex = index;
|
m_lastErrorIndex = index;
|
||||||
m_lastErrorMessage = CFsuipc::errorMessages().at(index);
|
m_lastErrorMessage = CFsuipc::errorMessages().at(index);
|
||||||
CLogMessage(this).warning("FSUIPC not connected: %1") << m_lastErrorMessage;
|
CLogMessage(this).warning("FSUIPC not connected: %1") << m_lastErrorMessage;
|
||||||
@@ -122,6 +125,7 @@ namespace BlackSimPlugin
|
|||||||
CLogMessage(this).info("Closing FSUIPC: %1") << m_fsuipcVersion;
|
CLogMessage(this).info("Closing FSUIPC: %1") << m_fsuipcVersion;
|
||||||
}
|
}
|
||||||
FSUIPC_Close(); // Closing when it wasn't open is okay, so this is safe here
|
FSUIPC_Close(); // Closing when it wasn't open is okay, so this is safe here
|
||||||
|
m_closeCount++;
|
||||||
m_opened = false;
|
m_opened = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,10 +336,16 @@ namespace BlackSimPlugin
|
|||||||
bool aircraftPartsN = !aircraftParts;
|
bool aircraftPartsN = !aircraftParts;
|
||||||
|
|
||||||
//! \todo KB 2018-11 BUG fix for broken connection, needs to go as soon as issue is fixed
|
//! \todo KB 2018-11 BUG fix for broken connection, needs to go as soon as issue is fixed
|
||||||
if (!FSUIPC_Read(0x0238, 3, localFsTimeRaw, &dwResult))
|
if (!(FSUIPC_Read(0x0238, 3, localFsTimeRaw, &dwResult) && FSUIPC_Process(&dwResult)))
|
||||||
{
|
{
|
||||||
FSUIPC_Close();
|
FSUIPC_Close();
|
||||||
FSUIPC_Open(SIM_ANY, &dwResult);
|
FSUIPC_Open(SIM_ANY, &dwResult);
|
||||||
|
m_closeCount++;
|
||||||
|
m_openCount++;
|
||||||
|
if (m_openCount < 10)
|
||||||
|
{
|
||||||
|
CLogMessage(this).warning("Used FSUIPC open/close workaround");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -492,7 +502,7 @@ namespace BlackSimPlugin
|
|||||||
if (m_lastErrorIndex != result && result > 0)
|
if (m_lastErrorIndex != result && result > 0)
|
||||||
{
|
{
|
||||||
m_lastErrorIndex = result;
|
m_lastErrorIndex = result;
|
||||||
m_lastErrorMessage = CFsuipc::errorMessages().at(result);
|
m_lastErrorMessage = CFsuipc::errorMessage(result);
|
||||||
CLogMessage(this).warning("FSUIPC read error '%1'") << m_lastErrorMessage;
|
CLogMessage(this).warning("FSUIPC read error '%1'") << m_lastErrorMessage;
|
||||||
}
|
}
|
||||||
return read;
|
return read;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include <windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
#include "FSUIPC_User.h"
|
#include "FSUIPC_User.h"
|
||||||
|
|
||||||
|
|||||||
@@ -236,6 +236,7 @@ namespace BlackSimPlugin
|
|||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// data definitions
|
||||||
hr += SimConnect_AddToClientDataDefinition(hSimConnect, CSimConnectDefinitions::DataClientAreaSb, 0, sbSize); // whole area
|
hr += SimConnect_AddToClientDataDefinition(hSimConnect, CSimConnectDefinitions::DataClientAreaSb, 0, sbSize); // whole area
|
||||||
hr += SimConnect_AddToClientDataDefinition(hSimConnect, CSimConnectDefinitions::DataClientAreaSbStandby, 17, 1); // standby
|
hr += SimConnect_AddToClientDataDefinition(hSimConnect, CSimConnectDefinitions::DataClientAreaSbStandby, 17, 1); // standby
|
||||||
hr += SimConnect_AddToClientDataDefinition(hSimConnect, CSimConnectDefinitions::DataClientAreaSbIdent, 19, 1); // ident
|
hr += SimConnect_AddToClientDataDefinition(hSimConnect, CSimConnectDefinitions::DataClientAreaSbIdent, 19, 1); // ident
|
||||||
|
|||||||
Reference in New Issue
Block a user