mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-24 18:04:14 +08:00
refs #369, adjusted plugins
* common base class for FS drivers * moved mapper into common base class * reflect changes for own aircraft provider ** removed member functions ** removed unused members
This commit is contained in:
@@ -14,11 +14,10 @@
|
||||
|
||||
#include "simconnect_datadefinition.h"
|
||||
#include "simconnect_object.h"
|
||||
#include "../fscommon/fsuipc.h"
|
||||
#include "../fscommon/simulator_fscommon.h"
|
||||
#include "blackcore/simulator.h"
|
||||
#include "blackcore/interpolator_linear.h"
|
||||
#include "blacksim/simulatorinfo.h"
|
||||
#include "blacksim/fscommon/aircraftmapper.h"
|
||||
#include "blackmisc/simulation/aircraftmodel.h"
|
||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
||||
#include "blackmisc/avairportlist.h"
|
||||
@@ -67,13 +66,13 @@ namespace BlackSimPlugin
|
||||
};
|
||||
|
||||
//! FSX Simulator Implementation
|
||||
class CSimulatorFsx : public BlackCore::ISimulator
|
||||
class CSimulatorFsx : public BlackSimPlugin::FsCommon::CSimulatorFsCommon
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
CSimulatorFsx(QObject *parent = nullptr);
|
||||
CSimulatorFsx(BlackMisc::Simulation::IOwnAircraftProvider *ownAircraft, QObject *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CSimulatorFsx();
|
||||
@@ -84,9 +83,6 @@ namespace BlackSimPlugin
|
||||
//! \copydoc ISimulator::isSimulating
|
||||
virtual bool isSimulating() const override;
|
||||
|
||||
//! FSUIPC connected?
|
||||
bool isFsuipcConnected() const;
|
||||
|
||||
//! \copydoc ISimulator::canConnect()
|
||||
virtual bool canConnect() const override;
|
||||
|
||||
@@ -104,9 +100,6 @@ namespace BlackSimPlugin
|
||||
//! \copydoc ISimulator::disconnectFrom()
|
||||
virtual bool disconnectFrom() override;
|
||||
|
||||
//! \copydoc ISimulator::getOwnAircraft()
|
||||
virtual BlackMisc::Simulation::CSimulatedAircraft getOwnAircraft() const override { return m_ownAircraft; }
|
||||
|
||||
//! \copydoc ISimulator::addRemoteAircraft()
|
||||
virtual void addRemoteAircraft(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft) override;
|
||||
|
||||
@@ -119,11 +112,8 @@ namespace BlackSimPlugin
|
||||
//! \copydoc ISimulator::changeRemoteAircraft
|
||||
virtual int changeRemoteAircraft(const BlackMisc::Simulation::CSimulatedAircraft &toChangeAircraft, const BlackMisc::CPropertyIndexVariantMap &changeValues) override;
|
||||
|
||||
//! \copydoc ISimulator::getSimulatorInfo()
|
||||
virtual BlackSim::CSimulatorInfo getSimulatorInfo() const override;
|
||||
|
||||
//! \copydoc ISimulator::updateOwnCockpit
|
||||
virtual bool updateOwnSimulatorCockpit(const BlackMisc::Aviation::CAircraft &ownAircraft) override;
|
||||
virtual bool updateOwnSimulatorCockpit(const BlackMisc::Aviation::CAircraft &ownAircraft, const QString &originator) override;
|
||||
|
||||
//! \copydoc ISimulator::displayStatusMessage
|
||||
virtual void displayStatusMessage(const BlackMisc::CStatusMessage &message) const override;
|
||||
@@ -131,33 +121,6 @@ namespace BlackSimPlugin
|
||||
//! \copydoc ISimulator::displayTextMessage()
|
||||
virtual void displayTextMessage(const BlackMisc::Network::CTextMessage &message) const override;
|
||||
|
||||
//! \copydoc ISimulator::getAircraftModel()
|
||||
virtual BlackMisc::Simulation::CAircraftModel getOwnAircraftModel() const override { return m_ownAircraft.getModel(); }
|
||||
|
||||
//! \copydoc BlackCore::ISimulator::getInstalledModels
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getInstalledModels() const override;
|
||||
|
||||
//! \copydoc BlackCore::ISimulator::getRemoteAircraft
|
||||
virtual BlackMisc::Simulation::CSimulatedAircraftList getRemoteAircraft() const override;
|
||||
|
||||
//! \copydoc ISimulator::getAirportsInRange
|
||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override;
|
||||
|
||||
//! \copydoc ISimulator::setTimeSynchronization
|
||||
virtual void setTimeSynchronization(bool enable, BlackMisc::PhysicalQuantities::CTime offset) override;
|
||||
|
||||
//! \copydoc ISimulator::isTimeSynchronized
|
||||
virtual bool isTimeSynchronized() const override { return m_simTimeSynced; }
|
||||
|
||||
//! \copydoc ISimulator::getTimeSynchronizationOffset
|
||||
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const override { return m_syncTimeOffset; }
|
||||
|
||||
//! \copydoc ISimulator::isPaused
|
||||
virtual bool isPaused() const override { return m_simPaused; }
|
||||
|
||||
//! \copydoc IContextSimulator::iconForModel
|
||||
virtual BlackMisc::CPixmap iconForModel(const QString &modelString) const override;
|
||||
|
||||
//! Called when sim has started
|
||||
void onSimRunning();
|
||||
|
||||
@@ -168,10 +131,10 @@ namespace BlackSimPlugin
|
||||
void onSimFrame();
|
||||
|
||||
//! Called when data about our own aircraft are received
|
||||
void updateOwnAircraftFromSim(DataDefinitionOwnAircraft simulatorOwnAircraft);
|
||||
void updateOwnAircraftFromSimulator(DataDefinitionOwnAircraft simulatorOwnAircraft);
|
||||
|
||||
//! Update from SB client area
|
||||
void updateOwnAircraftFromSim(DataDefinitionClientAreaSb sbDataArea);
|
||||
void updateOwnAircraftFromSimulator(DataDefinitionClientAreaSb sbDataArea);
|
||||
|
||||
//! Set ID of a SimConnect object
|
||||
void setSimConnectObjectID(DWORD requestID, DWORD objectID);
|
||||
@@ -179,9 +142,6 @@ namespace BlackSimPlugin
|
||||
//! \private
|
||||
void onSimExit();
|
||||
|
||||
//! \private
|
||||
void setOwnAircraftModel(const BlackMisc::Simulation::CAircraftModel &model);
|
||||
|
||||
protected:
|
||||
//! Timer event
|
||||
virtual void timerEvent(QTimerEvent *event);
|
||||
@@ -194,9 +154,6 @@ namespace BlackSimPlugin
|
||||
//! Called when asynchronous connection to Simconnect has finished
|
||||
void ps_connectToFinished();
|
||||
|
||||
//! Mapper has been initialized
|
||||
void ps_mapperInitialized(bool success);
|
||||
|
||||
private:
|
||||
|
||||
//! Remove a remote aircraft
|
||||
@@ -220,36 +177,18 @@ namespace BlackSimPlugin
|
||||
//! Sync time with user's computer
|
||||
void synchronizeTime(const BlackMisc::PhysicalQuantities::CTime &zuluTimeSim, const BlackMisc::PhysicalQuantities::CTime &localTimeSim);
|
||||
|
||||
//! Get the mapper singleton
|
||||
static BlackSim::FsCommon::CAircraftMapper *mapperInstance();
|
||||
|
||||
//! Experimental model matching
|
||||
static BlackMisc::Simulation::CAircraftModel modelMatching(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft);
|
||||
|
||||
//! SimObjects directory
|
||||
static QString simObjectsDir();
|
||||
|
||||
static const int SkipUpdateCyclesForCockpit = 10; //!< skip x cycles before updating cockpit again
|
||||
bool m_simConnected = false; //!< Is simulator connected?
|
||||
bool m_simRunning = false; //!< Simulator running?
|
||||
bool m_simPaused = false; //!< Simulator paused?
|
||||
bool m_simTimeSynced = false; //!< Time synchronized?
|
||||
bool m_useSbOffsets = true; //!< with SB offsets
|
||||
int m_syncDeferredCounter = 0; //!< Set when synchronized, used to wait some time
|
||||
int m_simconnectTimerId = -1; //!< Timer identifier
|
||||
int m_skipCockpitUpdateCycles = 0; //!< Skip some update cycles to allow changes in simulator cockpit to be set
|
||||
HANDLE m_hSimConnect = nullptr; //!< Handle to SimConnect object
|
||||
uint m_nextObjID = 1; //!< object ID TODO: also used as request id, where to we place other request ids as for facilities
|
||||
BlackMisc::PhysicalQuantities::CTime m_syncTimeOffset; //!< Time offset (if synchronized)
|
||||
QString simulatorDetails; //!< describes version etc.
|
||||
BlackSim::CSimulatorInfo m_simulatorInfo; //!< about the simulator
|
||||
BlackMisc::Simulation::CSimulatedAircraft m_ownAircraft; //!< Object representing our own aircraft from simulator
|
||||
BlackMisc::Simulation::CSimulatedAircraftList m_remoteAircraft; //!< mapped models
|
||||
BlackMisc::Aviation::CAirportList m_airportsInRange; //!< airports in range
|
||||
|
||||
BlackMisc::PhysicalQuantities::CTime m_syncTimeOffset; //!< Time offset (if synchronized)
|
||||
QHash<BlackMisc::Aviation::CCallsign, CSimConnectObject> m_simConnectObjects;
|
||||
QFutureWatcher<bool> m_watcherConnect;
|
||||
QScopedPointer<FsCommon::CFsuipc> m_fsuipc;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user