From f2f9ffafa5d5253b35fb1a0047739389faead6ac Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 14 Apr 2014 12:13:32 +0200 Subject: [PATCH] refs #207, added simulator info to interface, plugin --- src/blackcore/simulator.h | 40 ++++++++++-------------------- src/blacksim/fsx/plugin_fsx.pro | 12 +++++---- src/blacksim/fsx/simulator_fsx.cpp | 5 +++- src/blacksim/fsx/simulator_fsx.h | 15 ++++++----- 4 files changed, 33 insertions(+), 39 deletions(-) diff --git a/src/blackcore/simulator.h b/src/blackcore/simulator.h index 3168503c3..0882f3a5f 100644 --- a/src/blackcore/simulator.h +++ b/src/blackcore/simulator.h @@ -6,7 +6,8 @@ #ifndef BLACKCORE_SIMULATOR_H #define BLACKCORE_SIMULATOR_H -#include +#include "blacksim/simulatorinfo.h" +#include "blackmisc/avaircraft.h" #include namespace BlackCore @@ -41,45 +42,30 @@ namespace BlackCore virtual bool isConnected() const = 0; public slots: - /*! - * \brief Return user aircraft object - * \return - */ + //! Return user aircraft object virtual BlackMisc::Aviation::CAircraft getOwnAircraft() const = 0; - /*! - * \brief Add new remote aircraft to the simulator - * \param callsign - * \param type - * \param initialSituation - */ + //! Add new remote aircraft to the simulator virtual void addRemoteAircraft(const BlackMisc::Aviation::CCallsign &callsign, const QString &type, const BlackMisc::Aviation::CAircraftSituation &initialSituation) = 0; - /*! - * \brief Add new aircraft situation - * \param callsign - * \param initialSituation - */ + //! Add new aircraft situation virtual void addAircraftSituation(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftSituation &initialSituation) = 0; - /*! - * \brief Remove remote aircraft from simulator - * \param callsign - */ + //! Remove remote aircraft from simulator virtual void removeRemoteAircraft(const BlackMisc::Aviation::CCallsign &callsign) = 0; + //! Simulator info + virtual BlackSim::CSimulatorInfo getSimulatorInfo() const = 0; + signals: - //! \brief Emitted when the connection status has changed + //! Emitted when the connection status has changed void connectionChanged(bool value); - /*! - * \brief Emitted when new a new data object of the user aircraft is received - * \param aircraft - */ + //! Emitted when new a new data object of the user aircraft is received 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 { public: @@ -92,7 +78,7 @@ namespace BlackCore * \param parent * \return */ - virtual ISimulator* create(QObject *parent = nullptr) = 0; + virtual ISimulator *create(QObject *parent = nullptr) = 0; }; } // namespace BlackCore diff --git a/src/blacksim/fsx/plugin_fsx.pro b/src/blacksim/fsx/plugin_fsx.pro index ddb9655af..0fb65eeab 100644 --- a/src/blacksim/fsx/plugin_fsx.pro +++ b/src/blacksim/fsx/plugin_fsx.pro @@ -7,20 +7,22 @@ TARGET = simulator_fsx TEMPLATE = lib CONFIG += plugin shared -CONFIG += blackmisc blackcore +CONFIG += blackmisc blackcore blacksim LIBS += -lSimConnect - DEPENDPATH += . ../../../src INCLUDEPATH += . ../../../src SOURCES += *.cpp HEADERS += *.h -win32:!win32-g++*: PRE_TARGETDEPS += ../../../lib/blackmisc.lib -win32:!win32-g++*: PRE_TARGETDEPS += ../../../lib/blackcore.lib +win32:!win32-g++*: PRE_TARGETDEPS += ../../../lib/blackmisc.lib \ + ../../../lib/blacksim.lib \ + ../../../lib/blackcore.lib +else: PRE_TARGETDEPS += ../../../lib/libblackmisc.a \ + ../../../lib/libblacksim.a \ + ../../../lib/libblackcore.a DESTDIR = ../../../bin/plugins - include (../../../libraries.pri) diff --git a/src/blacksim/fsx/simulator_fsx.cpp b/src/blacksim/fsx/simulator_fsx.cpp index dc0f003ca..d6c1505cd 100644 --- a/src/blacksim/fsx/simulator_fsx.cpp +++ b/src/blacksim/fsx/simulator_fsx.cpp @@ -3,6 +3,7 @@ * 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/. */ +#include "blacksim/fsx/fsxsimulatorsetup.h" #include "simulator_fsx.h" #include "simconnect_datadefinition.h" #include "simconnect_exception.h" @@ -12,6 +13,8 @@ using namespace BlackMisc::Aviation; using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::Geo; +using namespace BlackSim; +using namespace BlackSim::Fsx; namespace BlackSimPlugin { @@ -258,7 +261,7 @@ namespace BlackSimPlugin { if (FAILED(SimConnect_Open(&m_hSimConnect, "BlackBox", nullptr, 0, 0, 0))) { - QTimer::singleShot(5000, this, SLOT(checkConnection())); + // QTimer::singleShot(5000, this, SLOT(checkConnection())); return; } diff --git a/src/blacksim/fsx/simulator_fsx.h b/src/blacksim/fsx/simulator_fsx.h index 81bc2e4bb..05350650d 100644 --- a/src/blacksim/fsx/simulator_fsx.h +++ b/src/blacksim/fsx/simulator_fsx.h @@ -31,13 +31,15 @@ namespace BlackSimPlugin Q_OBJECT Q_PLUGIN_METADATA(IID "net.vatsim.PilotClient.BlackCore.SimulatorInterface") Q_INTERFACES(BlackCore::ISimulatorFactory) + public: //! \copydoc BlackCore::ISimulatorFactory::create() - virtual BlackCore::ISimulator* create(QObject *parent) override; + virtual BlackCore::ISimulator *create(QObject *parent) override; }; //! \brief SimConnect Event ID's - enum EVENT_ID { + enum EVENT_ID + { EVENT_SIM_STATUS, EVENT_OBJECT_ADDED, EVENT_OBJECT_REMOVED, @@ -71,13 +73,16 @@ namespace BlackSimPlugin //! \copydoc ISimulator::removeRemoteAircraft() virtual void removeRemoteAircraft(const BlackMisc::Aviation::CCallsign &callsign) override; + //! \copydoc ISimulator::getSimulatorInfo() + virtual BlackSim::CSimulatorInfo getSimulatorInfo() const override; + /*! * \brief SimConnect Callback * \param pData * \param cbData * \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 void onSimRunning(); @@ -143,11 +148,9 @@ namespace BlackSimPlugin bool m_simRunning; //!< Sim running. HANDLE m_hSimConnect; //!< Handle to SimConnect object uint m_nextObjID; - + BlackSim::CSimulatorInfo m_simulatorInfo; BlackMisc::Aviation::CAircraft m_ownAircraft; //!< Object representing our own aircraft from simulator - QHash m_simConnectObjects; - }; }