mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
Make FSUIPC optional
Summary: If FSUIPC is configured, its support will be enabled in swift and disabled otherwise. Ref T91 Reviewers: #swift_pilot_client, msutcliffe Reviewed By: #swift_pilot_client, msutcliffe Subscribers: msutcliffe, jenkins, kbasan Maniphest Tasks: T91 Differential Revision: https://dev.swift-project.org/D28
This commit is contained in:
@@ -8,17 +8,19 @@ TEMPLATE = lib
|
||||
CONFIG += staticlib
|
||||
CONFIG += blackmisc
|
||||
|
||||
LIBS += -lFSUIPC_User
|
||||
|
||||
# required for FSUIPC
|
||||
win32:!win32-g++*: QMAKE_LFLAGS += /NODEFAULTLIB:LIBC.lib
|
||||
|
||||
DEPENDPATH += . $$SourceRoot/src
|
||||
INCLUDEPATH += . $$SourceRoot/src
|
||||
|
||||
SOURCES += *.cpp
|
||||
HEADERS += *.h
|
||||
|
||||
contains(BLACK_CONFIG, FSUIPC): DEFINES += SWIFT_USING_FSUIPC
|
||||
|
||||
LIBS += -lFSUIPC_User
|
||||
|
||||
# required for FSUIPC
|
||||
win32:!win32-g++*: QMAKE_LFLAGS += /NODEFAULTLIB:LIBC.lib
|
||||
|
||||
DESTDIR = $$DestRoot/lib
|
||||
|
||||
load(common_post)
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace BlackSimPlugin
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
CFsuipc();
|
||||
CFsuipc(QObject *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CFsuipc();
|
||||
@@ -39,10 +39,7 @@ namespace BlackSimPlugin
|
||||
void disconnect();
|
||||
|
||||
//! Is connected?
|
||||
bool isConnected() const { return m_connected; }
|
||||
|
||||
//! Process reading and writing variables
|
||||
void process(BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
||||
bool isConnected() const;
|
||||
|
||||
//! Write variables
|
||||
bool write(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
||||
@@ -51,7 +48,7 @@ namespace BlackSimPlugin
|
||||
bool write(const BlackMisc::Weather::CWeatherGrid &weatherGrid);
|
||||
|
||||
//! Get the version
|
||||
QString getVersion() const { return m_fsuipcVersion; }
|
||||
QString getVersion() const;
|
||||
|
||||
//! Read data from FSUIPC
|
||||
//! \param aircraft object to be updated
|
||||
@@ -102,19 +99,13 @@ namespace BlackSimPlugin
|
||||
//! Log message category
|
||||
static QString getLogCategory() { return "swift.fscommon.fsuipc"; }
|
||||
|
||||
|
||||
protected:
|
||||
//! \copydoc QObject::timerEvent
|
||||
void timerEvent(QTimerEvent *event);
|
||||
|
||||
private:
|
||||
struct FsuipcWeatherMessage
|
||||
{
|
||||
FsuipcWeatherMessage() = default;
|
||||
FsuipcWeatherMessage(unsigned int offset, const QByteArray &data, int leftTrials);
|
||||
int m_offset = 0;
|
||||
QByteArray m_messageData;
|
||||
int m_leftTrials = 0;
|
||||
};
|
||||
struct FsuipcWeatherMessage;
|
||||
|
||||
void clearAllWeather();
|
||||
void processWeatherMessages();
|
||||
|
||||
78
src/plugins/simulator/fscommon/fsuipcdummy.cpp
Normal file
78
src/plugins/simulator/fscommon/fsuipcdummy.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
/* Copyright (C) 2017
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SWIFT_USING_FSUIPC
|
||||
|
||||
#include "fsuipc.h"
|
||||
|
||||
using namespace BlackMisc::Simulation;
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace FsCommon
|
||||
{
|
||||
//! Dummy FsuipcWeatherMessage
|
||||
struct CFsuipc::FsuipcWeatherMessage
|
||||
{ };
|
||||
|
||||
CFsuipc::CFsuipc(QObject *parent)
|
||||
: QObject(parent)
|
||||
{ }
|
||||
|
||||
CFsuipc::~CFsuipc()
|
||||
{ }
|
||||
|
||||
bool CFsuipc::connect()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void CFsuipc::disconnect()
|
||||
{ }
|
||||
|
||||
bool CFsuipc::isConnected() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CFsuipc::write(const CSimulatedAircraft &aircraft)
|
||||
{
|
||||
Q_UNUSED(aircraft);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CFsuipc::write(const BlackMisc::Weather::CWeatherGrid &weatherGrid)
|
||||
{
|
||||
Q_UNUSED(weatherGrid);
|
||||
return false;
|
||||
}
|
||||
|
||||
QString CFsuipc::getVersion() const
|
||||
{
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
bool CFsuipc::read(CSimulatedAircraft &aircraft, bool cockpit, bool situation, bool aircraftParts)
|
||||
{
|
||||
Q_UNUSED(aircraft);
|
||||
Q_UNUSED(cockpit);
|
||||
Q_UNUSED(situation);
|
||||
Q_UNUSED(aircraftParts);
|
||||
return false;
|
||||
}
|
||||
|
||||
void CFsuipc::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
#endif //SWIFT_USING_FSUIPC
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2014
|
||||
/* Copyright (C) 2017
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
@@ -7,6 +7,8 @@
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifdef SWIFT_USING_FSUIPC
|
||||
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
@@ -36,7 +38,18 @@ namespace BlackSimPlugin
|
||||
{
|
||||
namespace FsCommon
|
||||
{
|
||||
CFsuipc::CFsuipc()
|
||||
//! Fsuipc weather message
|
||||
struct CFsuipc::FsuipcWeatherMessage
|
||||
{
|
||||
FsuipcWeatherMessage() = default;
|
||||
FsuipcWeatherMessage(unsigned int offset, const QByteArray &data, int leftTrials);
|
||||
int m_offset = 0;
|
||||
QByteArray m_messageData;
|
||||
int m_leftTrials = 0;
|
||||
};
|
||||
|
||||
CFsuipc::CFsuipc(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
startTimer(100);
|
||||
}
|
||||
@@ -84,6 +97,11 @@ namespace BlackSimPlugin
|
||||
this->m_connected = false;
|
||||
}
|
||||
|
||||
bool CFsuipc::isConnected() const
|
||||
{
|
||||
return m_connected;
|
||||
}
|
||||
|
||||
bool CFsuipc::write(const CSimulatedAircraft &aircraft)
|
||||
{
|
||||
if (!this->isConnected()) { return false; }
|
||||
@@ -224,6 +242,11 @@ namespace BlackSimPlugin
|
||||
return true;
|
||||
}
|
||||
|
||||
QString CFsuipc::getVersion() const
|
||||
{
|
||||
return m_fsuipcVersion;
|
||||
}
|
||||
|
||||
bool CFsuipc::read(CSimulatedAircraft &aircraft, bool cockpit, bool situation, bool aircraftParts)
|
||||
{
|
||||
DWORD dwResult;
|
||||
@@ -476,3 +499,5 @@ namespace BlackSimPlugin
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
#endif //SWIFT_USING_FSUIPC
|
||||
@@ -33,7 +33,7 @@ namespace BlackSimPlugin
|
||||
Weather::IWeatherGridProvider *weatherGridProvider,
|
||||
QObject *parent) :
|
||||
CSimulatorCommon(info, ownAircraftProvider, renderedAircraftProvider, weatherGridProvider, parent),
|
||||
m_fsuipc(new CFsuipc())
|
||||
m_fsuipc(std::make_unique<CFsuipc>(this))
|
||||
{
|
||||
CSimulatorFsCommon::registerHelp();
|
||||
}
|
||||
@@ -79,7 +79,7 @@ namespace BlackSimPlugin
|
||||
|
||||
bool CSimulatorFsCommon::isFsuipcConnected() const
|
||||
{
|
||||
return !m_fsuipc.isNull() && m_fsuipc->isConnected();
|
||||
return m_fsuipc && m_fsuipc->isConnected();
|
||||
}
|
||||
|
||||
bool CSimulatorFsCommon::useFsuipc(bool on)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "fsuipc.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <memory>
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
@@ -81,7 +82,7 @@ namespace BlackSimPlugin
|
||||
QString m_simulatorName; //!< name of simulator
|
||||
QString m_simulatorDetails; //!< describes version etc.
|
||||
QString m_simulatorVersion; //!< Simulator version
|
||||
QScopedPointer<FsCommon::CFsuipc> m_fsuipc; //!< FSUIPC
|
||||
std::unique_ptr<CFsuipc> m_fsuipc; //!< FSUIPC
|
||||
bool m_useFsuipc = true; //!< use FSUIPC
|
||||
bool m_simPaused = false; //!< Simulator paused?
|
||||
bool m_simTimeSynced = false; //!< Time synchronized?
|
||||
|
||||
Reference in New Issue
Block a user