mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-28 11:45:40 +08:00
refs #207, added simulator info to interface, plugin
This commit is contained in:
@@ -6,7 +6,8 @@
|
|||||||
#ifndef BLACKCORE_SIMULATOR_H
|
#ifndef BLACKCORE_SIMULATOR_H
|
||||||
#define BLACKCORE_SIMULATOR_H
|
#define BLACKCORE_SIMULATOR_H
|
||||||
|
|
||||||
#include <blackmisc/avaircraft.h>
|
#include "blacksim/simulatorinfo.h"
|
||||||
|
#include "blackmisc/avaircraft.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
@@ -41,45 +42,30 @@ namespace BlackCore
|
|||||||
virtual bool isConnected() const = 0;
|
virtual bool isConnected() const = 0;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/*!
|
//! Return user aircraft object
|
||||||
* \brief Return user aircraft object
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
virtual BlackMisc::Aviation::CAircraft getOwnAircraft() const = 0;
|
virtual BlackMisc::Aviation::CAircraft getOwnAircraft() const = 0;
|
||||||
|
|
||||||
/*!
|
//! Add new remote aircraft to the simulator
|
||||||
* \brief Add new remote aircraft to the simulator
|
|
||||||
* \param callsign
|
|
||||||
* \param type
|
|
||||||
* \param initialSituation
|
|
||||||
*/
|
|
||||||
virtual void addRemoteAircraft(const BlackMisc::Aviation::CCallsign &callsign, const QString &type, const BlackMisc::Aviation::CAircraftSituation &initialSituation) = 0;
|
virtual void addRemoteAircraft(const BlackMisc::Aviation::CCallsign &callsign, const QString &type, const BlackMisc::Aviation::CAircraftSituation &initialSituation) = 0;
|
||||||
|
|
||||||
/*!
|
//! Add new aircraft situation
|
||||||
* \brief Add new aircraft situation
|
|
||||||
* \param callsign
|
|
||||||
* \param initialSituation
|
|
||||||
*/
|
|
||||||
virtual void addAircraftSituation(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftSituation &initialSituation) = 0;
|
virtual void addAircraftSituation(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftSituation &initialSituation) = 0;
|
||||||
|
|
||||||
/*!
|
//! Remove remote aircraft from simulator
|
||||||
* \brief Remove remote aircraft from simulator
|
|
||||||
* \param callsign
|
|
||||||
*/
|
|
||||||
virtual void removeRemoteAircraft(const BlackMisc::Aviation::CCallsign &callsign) = 0;
|
virtual void removeRemoteAircraft(const BlackMisc::Aviation::CCallsign &callsign) = 0;
|
||||||
|
|
||||||
|
//! Simulator info
|
||||||
|
virtual BlackSim::CSimulatorInfo getSimulatorInfo() const = 0;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! \brief Emitted when the connection status has changed
|
//! Emitted when the connection status has changed
|
||||||
void connectionChanged(bool value);
|
void connectionChanged(bool value);
|
||||||
|
|
||||||
/*!
|
//! Emitted when new a new data object of the user aircraft is received
|
||||||
* \brief Emitted when new a new data object of the user aircraft is received
|
|
||||||
* \param aircraft
|
|
||||||
*/
|
|
||||||
void ownAircraftReceived(BlackMisc::Aviation::CAircraft aircraft);
|
void ownAircraftReceived(BlackMisc::Aviation::CAircraft aircraft);
|
||||||
};
|
};
|
||||||
|
|
||||||
//! \brief Factory pattern class to create instances of ISimulator
|
//! Factory pattern class to create instances of ISimulator
|
||||||
class ISimulatorFactory
|
class ISimulatorFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -92,7 +78,7 @@ namespace BlackCore
|
|||||||
* \param parent
|
* \param parent
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
virtual ISimulator* create(QObject *parent = nullptr) = 0;
|
virtual ISimulator *create(QObject *parent = nullptr) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace BlackCore
|
} // namespace BlackCore
|
||||||
|
|||||||
@@ -7,20 +7,22 @@ TARGET = simulator_fsx
|
|||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
|
|
||||||
CONFIG += plugin shared
|
CONFIG += plugin shared
|
||||||
CONFIG += blackmisc blackcore
|
CONFIG += blackmisc blackcore blacksim
|
||||||
|
|
||||||
LIBS += -lSimConnect
|
LIBS += -lSimConnect
|
||||||
|
|
||||||
|
|
||||||
DEPENDPATH += . ../../../src
|
DEPENDPATH += . ../../../src
|
||||||
INCLUDEPATH += . ../../../src
|
INCLUDEPATH += . ../../../src
|
||||||
|
|
||||||
SOURCES += *.cpp
|
SOURCES += *.cpp
|
||||||
HEADERS += *.h
|
HEADERS += *.h
|
||||||
|
|
||||||
win32:!win32-g++*: PRE_TARGETDEPS += ../../../lib/blackmisc.lib
|
win32:!win32-g++*: PRE_TARGETDEPS += ../../../lib/blackmisc.lib \
|
||||||
win32:!win32-g++*: PRE_TARGETDEPS += ../../../lib/blackcore.lib
|
../../../lib/blacksim.lib \
|
||||||
|
../../../lib/blackcore.lib
|
||||||
|
else: PRE_TARGETDEPS += ../../../lib/libblackmisc.a \
|
||||||
|
../../../lib/libblacksim.a \
|
||||||
|
../../../lib/libblackcore.a
|
||||||
|
|
||||||
DESTDIR = ../../../bin/plugins
|
DESTDIR = ../../../bin/plugins
|
||||||
|
|
||||||
include (../../../libraries.pri)
|
include (../../../libraries.pri)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#include "blacksim/fsx/fsxsimulatorsetup.h"
|
||||||
#include "simulator_fsx.h"
|
#include "simulator_fsx.h"
|
||||||
#include "simconnect_datadefinition.h"
|
#include "simconnect_datadefinition.h"
|
||||||
#include "simconnect_exception.h"
|
#include "simconnect_exception.h"
|
||||||
@@ -12,6 +13,8 @@
|
|||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
using namespace BlackMisc::PhysicalQuantities;
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
using namespace BlackMisc::Geo;
|
using namespace BlackMisc::Geo;
|
||||||
|
using namespace BlackSim;
|
||||||
|
using namespace BlackSim::Fsx;
|
||||||
|
|
||||||
namespace BlackSimPlugin
|
namespace BlackSimPlugin
|
||||||
{
|
{
|
||||||
@@ -258,7 +261,7 @@ namespace BlackSimPlugin
|
|||||||
{
|
{
|
||||||
if (FAILED(SimConnect_Open(&m_hSimConnect, "BlackBox", nullptr, 0, 0, 0)))
|
if (FAILED(SimConnect_Open(&m_hSimConnect, "BlackBox", nullptr, 0, 0, 0)))
|
||||||
{
|
{
|
||||||
QTimer::singleShot(5000, this, SLOT(checkConnection()));
|
// QTimer::singleShot(5000, this, SLOT(checkConnection()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,13 +31,15 @@ namespace BlackSimPlugin
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PLUGIN_METADATA(IID "net.vatsim.PilotClient.BlackCore.SimulatorInterface")
|
Q_PLUGIN_METADATA(IID "net.vatsim.PilotClient.BlackCore.SimulatorInterface")
|
||||||
Q_INTERFACES(BlackCore::ISimulatorFactory)
|
Q_INTERFACES(BlackCore::ISimulatorFactory)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! \copydoc BlackCore::ISimulatorFactory::create()
|
//! \copydoc BlackCore::ISimulatorFactory::create()
|
||||||
virtual BlackCore::ISimulator* create(QObject *parent) override;
|
virtual BlackCore::ISimulator *create(QObject *parent) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! \brief SimConnect Event ID's
|
//! \brief SimConnect Event ID's
|
||||||
enum EVENT_ID {
|
enum EVENT_ID
|
||||||
|
{
|
||||||
EVENT_SIM_STATUS,
|
EVENT_SIM_STATUS,
|
||||||
EVENT_OBJECT_ADDED,
|
EVENT_OBJECT_ADDED,
|
||||||
EVENT_OBJECT_REMOVED,
|
EVENT_OBJECT_REMOVED,
|
||||||
@@ -71,13 +73,16 @@ namespace BlackSimPlugin
|
|||||||
//! \copydoc ISimulator::removeRemoteAircraft()
|
//! \copydoc ISimulator::removeRemoteAircraft()
|
||||||
virtual void removeRemoteAircraft(const BlackMisc::Aviation::CCallsign &callsign) override;
|
virtual void removeRemoteAircraft(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||||
|
|
||||||
|
//! \copydoc ISimulator::getSimulatorInfo()
|
||||||
|
virtual BlackSim::CSimulatorInfo getSimulatorInfo() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief SimConnect Callback
|
* \brief SimConnect Callback
|
||||||
* \param pData
|
* \param pData
|
||||||
* \param cbData
|
* \param cbData
|
||||||
* \param pContext
|
* \param pContext
|
||||||
*/
|
*/
|
||||||
static void CALLBACK SimConnectProc(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext);
|
static void CALLBACK SimConnectProc(SIMCONNECT_RECV *pData, DWORD cbData, void *pContext);
|
||||||
|
|
||||||
//! \brief Called when sim has started
|
//! \brief Called when sim has started
|
||||||
void onSimRunning();
|
void onSimRunning();
|
||||||
@@ -143,11 +148,9 @@ namespace BlackSimPlugin
|
|||||||
bool m_simRunning; //!< Sim running.
|
bool m_simRunning; //!< Sim running.
|
||||||
HANDLE m_hSimConnect; //!< Handle to SimConnect object
|
HANDLE m_hSimConnect; //!< Handle to SimConnect object
|
||||||
uint m_nextObjID;
|
uint m_nextObjID;
|
||||||
|
BlackSim::CSimulatorInfo m_simulatorInfo;
|
||||||
BlackMisc::Aviation::CAircraft m_ownAircraft; //!< Object representing our own aircraft from simulator
|
BlackMisc::Aviation::CAircraft m_ownAircraft; //!< Object representing our own aircraft from simulator
|
||||||
|
|
||||||
QHash<BlackMisc::Aviation::CCallsign, SimConnectObject> m_simConnectObjects;
|
QHash<BlackMisc::Aviation::CCallsign, SimConnectObject> m_simConnectObjects;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user