Ref T437, renamed CFsuipc functions to align with FSUIPC code

This commit is contained in:
Klaus Basan
2018-11-22 19:07:00 +01:00
parent 410d77330f
commit d6fad99474
8 changed files with 42 additions and 40 deletions

View File

@@ -140,7 +140,7 @@ namespace BlackSimPlugin
if (m_useFsuipc)
{
m_fsuipc->connect(); // connect FSUIPC too
m_fsuipc->open(); // connect FSUIPC too
}
this->initSimulatorInternals();
m_timerId = startTimer(50);
@@ -305,7 +305,7 @@ namespace BlackSimPlugin
void CSimulatorFs9::dispatch()
{
if (m_useFsuipc && m_fsuipc && m_fsuipc->isConnected())
if (m_useFsuipc && m_fsuipc && m_fsuipc->isOpened())
{
CSimulatedAircraft fsuipcAircraft(getOwnAircraft());
const bool ok = m_fsuipc->read(fsuipcAircraft, true, true, true);
@@ -394,7 +394,7 @@ namespace BlackSimPlugin
void CSimulatorFs9::injectWeatherGrid(const Weather::CWeatherGrid &weatherGrid)
{
if (!m_useFsuipc || !m_fsuipc) { return; }
if (!m_fsuipc->isConnected()) { return; }
if (!m_fsuipc->isOpened()) { return; }
m_fsuipc->write(weatherGrid);
}

View File

@@ -33,13 +33,13 @@ namespace BlackSimPlugin
virtual ~CFsuipc() override;
//! Open conenction with FSUIPC
bool connect(bool force = false);
bool open(bool force = false);
//! Disconnect
void disconnect();
void close();
//! Is connected?
bool isConnected() const;
//! Is opened?
bool isOpened() const;
//! Really open, means connected and data can be sent
bool isOpen() const;
@@ -119,16 +119,18 @@ namespace BlackSimPlugin
void timerEvent(QTimerEvent *event) override;
private:
struct FsuipcWeatherMessage;
//! Clear weather
void clearAllWeather();
//! Process weather
void processWeatherMessages();
bool m_connected = false;
bool m_opened = false;
int m_lastErrorIndex = 0;
QString m_lastErrorMessage;
QString m_fsuipcVersion;
struct FsuipcWeatherMessage;
QVector<FsuipcWeatherMessage> m_weatherMessageQueue;
unsigned int m_lastTimestamp = 0;

View File

@@ -30,16 +30,16 @@ namespace BlackSimPlugin
CFsuipc::~CFsuipc()
{ }
bool CFsuipc::connect(bool force)
bool CFsuipc::open(bool force)
{
Q_UNUSED(force);
return false;
}
void CFsuipc::disconnect()
void CFsuipc::close()
{ }
bool CFsuipc::isConnected() const
bool CFsuipc::isOpened() const
{
return false;
}

View File

@@ -67,18 +67,18 @@ namespace BlackSimPlugin
CFsuipc::~CFsuipc()
{
this->disconnect();
this->close();
}
bool CFsuipc::connect(bool force)
bool CFsuipc::open(bool force)
{
DWORD result;
m_lastErrorMessage = "";
m_lastErrorIndex = 0;
if (!force && m_connected) { return m_connected; } // already connected
if (!force && m_opened) { return m_opened; } // already connected
if (FSUIPC_Open(SIM_ANY, &result))
{
m_connected = true; // temp status
m_opened = true; // temp status
if (this->isOpen())
{
const int simIndex = static_cast<int>(FSUIPC_FS_Version);
@@ -94,7 +94,7 @@ namespace BlackSimPlugin
else
{
CLogMessage(this).warning("FSUIPC opened, but verification failed");
m_connected = false;
m_opened = false;
FSUIPC_Close(); // under any circumstances close
}
}
@@ -104,31 +104,31 @@ namespace BlackSimPlugin
m_lastErrorIndex = index;
m_lastErrorMessage = CFsuipc::errorMessages().at(index);
CLogMessage(this).warning("FSUIPC not connected: %1") << m_lastErrorMessage;
m_connected = false;
m_opened = false;
FSUIPC_Close(); // under any circumstances close
}
return m_connected;
return m_opened;
}
void CFsuipc::disconnect()
void CFsuipc::close()
{
if (m_connected)
if (m_opened)
{
CLogMessage(this).info("Closing FSUIPC: %1") << m_fsuipcVersion;
}
FSUIPC_Close(); // Closing when it wasn't open is okay, so this is safe here
m_connected = false;
m_opened = false;
}
bool CFsuipc::isConnected() const
bool CFsuipc::isOpened() const
{
return m_connected;
return m_opened;
}
bool CFsuipc::isOpen() const
{
if (!this->isConnected()) { return false; }
if (!this->isOpened()) { return false; }
// test read
DWORD dwResult;
@@ -142,7 +142,7 @@ namespace BlackSimPlugin
bool CFsuipc::write(const CTransponder &xpdr)
{
if (!this->isConnected()) { return false; }
if (!this->isOpened()) { return false; }
// should be the same as writing via SimConnect data area
DWORD dwResult;
@@ -157,7 +157,7 @@ namespace BlackSimPlugin
bool CFsuipc::write(const CWeatherGrid &weatherGrid)
{
if (!this->isConnected()) { return false; }
if (!this->isOpened()) { return false; }
this->clearAllWeather();
CGridPoint gridPoint = weatherGrid.front();
@@ -316,7 +316,7 @@ namespace BlackSimPlugin
// https://www.ivao.aero/softdev/ivap/fsuipc_sdk.asp
// http://squawkbox.ca/doc/sdk/fsuipc.php
if (!this->isConnected()) { return false; }
if (!this->isOpened()) { return false; }
if (!(aircraftParts || situation || cockpit)) { return false; }
bool read = false;
@@ -504,7 +504,7 @@ namespace BlackSimPlugin
void CFsuipc::clearAllWeather()
{
if (!this->isConnected()) { return; }
if (!this->isOpened()) { return; }
// clear all weather
NewWeather nw;
@@ -530,7 +530,7 @@ namespace BlackSimPlugin
void CFsuipc::processWeatherMessages()
{
if (m_weatherMessageQueue.empty()) { return; }
if (!m_connected) { return; }
if (!m_opened) { return; }
FsuipcWeatherMessage &weatherMessage = m_weatherMessageQueue.first();
DWORD dwResult;

View File

@@ -52,7 +52,7 @@ namespace BlackSimPlugin
{
const QString v(m_fsuipc->getVersion());
if (!v.isEmpty()) { m_simulatorInternals.setValue("fscommon/fsuipcversion", v); }
m_simulatorInternals.setValue("fscommon/fsuipcconnect", boolToYesNo(m_fsuipc->isConnected()));
m_simulatorInternals.setValue("fscommon/fsuipcopen", boolToYesNo(m_fsuipc->isOpened()));
}
}
@@ -78,7 +78,7 @@ namespace BlackSimPlugin
bool CSimulatorFsCommon::disconnectFrom()
{
if (m_fsuipc) { m_fsuipc->disconnect(); }
if (m_fsuipc) { m_fsuipc->close(); }
// reset flags
m_simPaused = false;
@@ -86,9 +86,9 @@ namespace BlackSimPlugin
return CSimulatorPluginCommon::disconnectFrom();
}
bool CSimulatorFsCommon::isFsuipcConnected() const
bool CSimulatorFsCommon::isFsuipcOpened() const
{
return m_fsuipc && m_fsuipc->isConnected();
return m_fsuipc && m_fsuipc->isOpened();
}
bool CSimulatorFsCommon::useFsuipc(bool on)
@@ -98,11 +98,11 @@ namespace BlackSimPlugin
m_useFsuipc = on;
if (on)
{
m_useFsuipc = m_fsuipc->connect();
m_useFsuipc = m_fsuipc->open();
}
else
{
m_fsuipc->disconnect();
m_fsuipc->close();
}
this->initSimulatorInternals(); // update internals

View File

@@ -37,7 +37,7 @@ namespace BlackSimPlugin
virtual ~CSimulatorFsCommon() override;
//! FSUIPC connected?
bool isFsuipcConnected() const;
bool isFsuipcOpened() const;
//! FSUIPC on/off, correctly disconnecting/connecting
bool useFsuipc(bool on);

View File

@@ -74,7 +74,7 @@ namespace BlackSimPlugin
ui->cb_TraceSimConnectCalls->setChecked(fsxOrP3D->isTracingSendId());
ui->cb_EnableTerrainProbe->setChecked(fsxOrP3D->isUsingFsxTerrainProbe());
ui->cb_SBOffsets->setChecked(fsxOrP3D->isUsingSbOffsetValues());
ui->cb_UseFsuipc->setChecked(fsxOrP3D->isFsuipcConnected());
ui->cb_UseFsuipc->setChecked(fsxOrP3D->isFsuipcOpened());
}
const bool terrainProbe = CBuildConfig::isRunningOnWindowsNtPlatform() && (CBuildConfig::buildWordSize() == 32);

View File

@@ -106,7 +106,7 @@ namespace BlackSimPlugin
// FSUIPC too
if (m_useFsuipc)
{
m_fsuipc->connect();
m_fsuipc->open();
}
// set structures and move on