mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
Ref T259, Ref T243 adjusted providers to use common base classes
This commit is contained in:
@@ -190,7 +190,7 @@ namespace BlackCore
|
||||
// remark for simulation snapshot is used when there are restrictions
|
||||
// nevertheless we calculate all the time as the snapshot could be used in other scenarios
|
||||
|
||||
CSimulatedAircraftList aircraftInRange(getAircraftInRange()); // thread safe copy from provider
|
||||
CSimulatedAircraftList aircraftInRange(this->getAircraftInRange()); // thread safe copy from provider
|
||||
CAirspaceAircraftSnapshot snapshot(
|
||||
aircraftInRange,
|
||||
restricted, enabled,
|
||||
|
||||
@@ -121,6 +121,9 @@ namespace BlackCore
|
||||
virtual BlackMisc::CStatusMessageList getReverseLookupMessages(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||
//! @}
|
||||
|
||||
//! \copydoc BlackMisc::IProvider::asQObject
|
||||
virtual QObject *asQObject() override { return this; }
|
||||
|
||||
//! Returns the list of users we know about
|
||||
BlackMisc::Network::CUserList getUsers() const;
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ namespace BlackCore
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTOWNAIRCRAFT_INTERFACENAME)
|
||||
Q_INTERFACES(BlackMisc::Simulation::IOwnAircraftProvider)
|
||||
Q_INTERFACES(BlackMisc::IProvider)
|
||||
friend class BlackCore::CCoreFacade;
|
||||
friend class IContextOwnAircraft;
|
||||
|
||||
@@ -106,6 +107,9 @@ namespace BlackCore
|
||||
//! \ingroup ownaircraftprovider
|
||||
virtual bool updateOwnParts(const BlackMisc::Aviation::CAircraftParts &parts) override;
|
||||
|
||||
//! \copydoc BlackMisc::IProvider::asQObject
|
||||
virtual QObject *asQObject() override { return this; }
|
||||
|
||||
public slots:
|
||||
//! \copydoc IContextOwnAircraft::getOwnAircraft()
|
||||
//! \ingroup ownaircraftprovider
|
||||
|
||||
@@ -34,11 +34,6 @@ namespace BlackCore
|
||||
return status;
|
||||
}
|
||||
|
||||
const CSimulatorInfo &ISimulator::getSimulatorInfo() const
|
||||
{
|
||||
return this->getSimulatorPluginInfo().getSimulatorInfo();
|
||||
}
|
||||
|
||||
void ISimulator::registerHelp()
|
||||
{
|
||||
if (CSimpleCommandParser::registered("BlackCore::ISimulator")) { return; }
|
||||
@@ -61,11 +56,14 @@ namespace BlackCore
|
||||
return s.join(", ");
|
||||
}
|
||||
|
||||
ISimulator::ISimulator(IOwnAircraftProvider *ownAircraftProvider, IRemoteAircraftProvider *remoteAircraftProvider, IWeatherGridProvider *weatherGridProvider, QObject *parent) :
|
||||
ISimulator::ISimulator(
|
||||
const CSimulatorPluginInfo &pluginInfo, IOwnAircraftProvider *ownAircraftProvider,
|
||||
IRemoteAircraftProvider *remoteAircraftProvider, IWeatherGridProvider *weatherGridProvider, QObject *parent) :
|
||||
QObject(parent),
|
||||
COwnAircraftAware(ownAircraftProvider),
|
||||
CRemoteAircraftAware(remoteAircraftProvider),
|
||||
CWeatherGridAware(weatherGridProvider),
|
||||
ISimulationEnvironmentProvider(pluginInfo),
|
||||
CIdentifiable(this)
|
||||
{
|
||||
ISimulator::registerHelp();
|
||||
|
||||
@@ -57,6 +57,7 @@ namespace BlackCore
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(BlackMisc::Simulation::ISimulationEnvironmentProvider)
|
||||
Q_INTERFACES(BlackMisc::IProvider)
|
||||
|
||||
public:
|
||||
//! ISimulator status
|
||||
@@ -83,12 +84,6 @@ namespace BlackCore
|
||||
//! Is time synchronization on?
|
||||
virtual bool isTimeSynchronized() const = 0;
|
||||
|
||||
//! Get the simulator info (metadata of plugin)
|
||||
virtual const BlackMisc::Simulation::CSimulatorPluginInfo &getSimulatorPluginInfo() const = 0;
|
||||
|
||||
//! Get simulator info (default implementation)
|
||||
const BlackMisc::Simulation::CSimulatorInfo &getSimulatorInfo() const;
|
||||
|
||||
//! Get the setup (simulator environemnt)
|
||||
virtual const BlackMisc::Simulation::CSimulatorInternals &getSimulatorInternals() const = 0;
|
||||
|
||||
@@ -98,9 +93,6 @@ namespace BlackCore
|
||||
//! Disconnect from simulator
|
||||
virtual bool disconnectFrom() = 0;
|
||||
|
||||
//! Get default aircraft model
|
||||
virtual BlackMisc::Simulation::CAircraftModel getDefaultModel() const = 0;
|
||||
|
||||
//! Logically add a new aircraft. Depending on max. aircraft, enabled status etc.
|
||||
//! it will physically added to the simulator.
|
||||
//! \sa physicallyAddRemoteAircraft
|
||||
@@ -184,6 +176,9 @@ namespace BlackCore
|
||||
//! Is overall (swift) application shutting down
|
||||
virtual bool isShuttingDown() const = 0;
|
||||
|
||||
//! \copydoc BlackMisc::IProvider::asQObject
|
||||
virtual QObject *asQObject() override { return this; }
|
||||
|
||||
//! Set interpolation mode, empty callsign applies to all know callsigns
|
||||
//! \return Returns true if the mode changed, otherwise false. Note that some implementations always return true.
|
||||
virtual bool setInterpolatorMode(BlackMisc::Simulation::CInterpolatorMulti::Mode mode, const BlackMisc::Aviation::CCallsign &callsign) = 0;
|
||||
@@ -231,7 +226,8 @@ namespace BlackCore
|
||||
|
||||
protected:
|
||||
//! Default constructor
|
||||
ISimulator(BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider,
|
||||
ISimulator(const BlackMisc::Simulation::CSimulatorPluginInfo &pluginInfo,
|
||||
BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider,
|
||||
BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider,
|
||||
BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
@@ -52,15 +52,14 @@ namespace BlackCore
|
||||
IRemoteAircraftProvider *remoteAircraftProvider,
|
||||
IWeatherGridProvider *weatherGridProvider,
|
||||
QObject *parent)
|
||||
: ISimulator(ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, parent),
|
||||
m_simulatorPluginInfo(info)
|
||||
: ISimulator(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, parent)
|
||||
{
|
||||
this->setObjectName("Simulator: " + info.getIdentifier());
|
||||
CSimulatorCommon::registerHelp();
|
||||
|
||||
// provider signals, hook up with remote aircraft provider
|
||||
m_remoteAircraftProviderConnections.append(
|
||||
m_remoteAircraftProvider->connectRemoteAircraftProviderSignals(
|
||||
CRemoteAircraftAware::provider()->connectRemoteAircraftProviderSignals(
|
||||
this, // receiver must match object in bind
|
||||
std::bind(&CSimulatorCommon::rapOnRemoteProviderAddedAircraftSituation, this, std::placeholders::_1),
|
||||
std::bind(&CSimulatorCommon::rapOnRemoteProviderAddedAircraftParts, this, std::placeholders::_1, std::placeholders::_2),
|
||||
@@ -82,7 +81,7 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
// info
|
||||
CLogMessage(this).info("Initialized simulator driver: '%1'") << m_simulatorPluginInfo.toQString();
|
||||
CLogMessage(this).info("Initialized simulator driver: '%1'") << this->getSimulatorInfo().toQString();
|
||||
}
|
||||
|
||||
CSimulatorCommon::~CSimulatorCommon()
|
||||
@@ -125,12 +124,6 @@ namespace BlackCore
|
||||
return false;
|
||||
}
|
||||
|
||||
void CSimulatorCommon::setNewPluginInfo(const CSimulatorPluginInfo &info, const CAircraftModel &defaultModel)
|
||||
{
|
||||
m_simulatorPluginInfo = info;
|
||||
m_defaultModel = defaultModel;
|
||||
}
|
||||
|
||||
int CSimulatorCommon::maxAirportsInRange() const
|
||||
{
|
||||
// might change in future or become a setting or such
|
||||
@@ -302,16 +295,6 @@ namespace BlackCore
|
||||
// void, can be overridden in specialized drivers
|
||||
}
|
||||
|
||||
CAircraftModel CSimulatorCommon::getDefaultModel() const
|
||||
{
|
||||
return m_defaultModel;
|
||||
}
|
||||
|
||||
const CSimulatorPluginInfo &CSimulatorCommon::getSimulatorPluginInfo() const
|
||||
{
|
||||
return m_simulatorPluginInfo;
|
||||
}
|
||||
|
||||
const CSimulatorInternals &CSimulatorCommon::getSimulatorInternals() const
|
||||
{
|
||||
return m_simulatorInternals;
|
||||
|
||||
@@ -55,7 +55,8 @@ namespace BlackMisc
|
||||
namespace BlackCore
|
||||
{
|
||||
//! Common base class with providers, interface and some base functionality
|
||||
class BLACKCORE_EXPORT CSimulatorCommon : public BlackCore::ISimulator {
|
||||
class BLACKCORE_EXPORT CSimulatorCommon : public ISimulator
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@@ -66,11 +67,9 @@ namespace BlackCore
|
||||
virtual ~CSimulatorCommon();
|
||||
|
||||
// --------- ISimulator implementations ------------
|
||||
virtual BlackMisc::Simulation::CAircraftModel getDefaultModel() const override;
|
||||
virtual void setInterpolationAndRenderingSetup(const BlackMisc::Simulation::CInterpolationAndRenderingSetup &setup) override;
|
||||
virtual BlackMisc::Simulation::CInterpolationAndRenderingSetup getInterpolationAndRenderingSetup() const override;
|
||||
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) override;
|
||||
virtual const BlackMisc::Simulation::CSimulatorPluginInfo &getSimulatorPluginInfo() const override;
|
||||
virtual const BlackMisc::Simulation::CSimulatorInternals &getSimulatorInternals() const override;
|
||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override;
|
||||
virtual void setWeatherActivated(bool activated) override;
|
||||
@@ -154,10 +153,6 @@ namespace BlackCore
|
||||
virtual void onRemoteProviderAddedAircraftParts(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftParts &parts);
|
||||
//! @}
|
||||
|
||||
//! New plugin info
|
||||
//! \remark normally only used by
|
||||
void setNewPluginInfo(const BlackMisc::Simulation::CSimulatorPluginInfo &info, const BlackMisc::Simulation::CAircraftModel &defaultModel);
|
||||
|
||||
//! Max.airports in range
|
||||
int maxAirportsInRange() const;
|
||||
|
||||
@@ -222,8 +217,7 @@ namespace BlackCore
|
||||
int m_statsUpdateAircraftCountMs = 0; //!< statistics update count
|
||||
qint64 m_statsUpdateAircraftTimeTotalMs = 0; //!< statistics update time
|
||||
qint64 m_statsUpdateAircraftTimeAvgMs = 0; //!< statistics update time
|
||||
BlackMisc::Simulation::CAircraftModel m_defaultModel; //!< default model
|
||||
BlackMisc::Simulation::CSimulatorInternals m_simulatorInternals; //!< setup object
|
||||
BlackMisc::Simulation::CSimulatorInternals m_simulatorInternals; //!< setup object
|
||||
BlackMisc::Simulation::CInterpolationLogger m_interpolationLogger; //!< log interpolation
|
||||
|
||||
// setup for logging etc.
|
||||
@@ -260,10 +254,9 @@ namespace BlackCore
|
||||
qint64 m_highlightEndTimeMsEpoch = 0; //!< end highlighting
|
||||
int m_timerCounter = 0; //!< allows to calculate n seconds
|
||||
QTimer m_oneSecondTimer; //!< multi purpose timer
|
||||
BlackMisc::Simulation::CSimulatorPluginInfo m_simulatorPluginInfo; //!< info object
|
||||
BlackMisc::Simulation::CSimulatedAircraftList m_highlightedAircraft; //!< all other aircraft are to be ignored
|
||||
BlackMisc::Aviation::CCallsignSet m_callsignsToBeRendered; //!< callsigns which will be rendered
|
||||
BlackMisc::CConnectionGuard m_remoteAircraftProviderConnections; //!< connected signal/slots
|
||||
BlackMisc::Simulation::CSimulatedAircraftList m_highlightedAircraft; //!< all other aircraft are to be ignored
|
||||
BlackMisc::Aviation::CCallsignSet m_callsignsToBeRendered; //!< callsigns which will be rendered
|
||||
BlackMisc::CConnectionGuard m_remoteAircraftProviderConnections; //!< connected signal/slots
|
||||
|
||||
// statistics values of how often those functions are called
|
||||
// those are the added counters, overflow will not be an issue here (discussed in T171 review)
|
||||
|
||||
@@ -85,37 +85,37 @@ namespace BlackMisc
|
||||
|
||||
CClientList CClientAware::getClients() const
|
||||
{
|
||||
if (m_clientProvider) { return m_clientProvider->getClients(); }
|
||||
if (this->provider()) { return this->provider()->getClients(); }
|
||||
return CClientList();
|
||||
}
|
||||
|
||||
CClient CClientAware::getClientOrDefaultForCallsign(const Aviation::CCallsign &callsign) const
|
||||
{
|
||||
if (m_clientProvider) { return m_clientProvider->getClientOrDefaultForCallsign(callsign); }
|
||||
if (this->provider()) { return this->provider()->getClientOrDefaultForCallsign(callsign); }
|
||||
return CClient();
|
||||
}
|
||||
|
||||
bool CClientAware::hasClientInfo(const CCallsign &callsign) const
|
||||
{
|
||||
if (m_clientProvider) { return m_clientProvider->hasClientInfo(callsign); }
|
||||
if (this->provider()) { return this->provider()->hasClientInfo(callsign); }
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CClientAware::addNewClient(const CClient &client)
|
||||
{
|
||||
if (m_clientProvider) { return m_clientProvider->addNewClient(client); }
|
||||
if (this->provider()) { return this->provider()->addNewClient(client); }
|
||||
return false;
|
||||
}
|
||||
|
||||
int CClientAware::updateOrAddClient(const CCallsign &callsign, const CPropertyIndexVariantMap &vm, bool skipEqualValues)
|
||||
{
|
||||
if (m_clientProvider) { return m_clientProvider->updateOrAddClient(callsign, vm, skipEqualValues); }
|
||||
if (this->provider()) { return this->provider()->updateOrAddClient(callsign, vm, skipEqualValues); }
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CClientAware::removeClient(const CCallsign &callsign)
|
||||
{
|
||||
if (m_clientProvider) { return m_clientProvider->removeClient(callsign); }
|
||||
if (this->provider()) { return this->provider()->removeClient(callsign); }
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -105,8 +105,7 @@ namespace BlackMisc
|
||||
CClientAware() {}
|
||||
|
||||
//! Constructor
|
||||
CClientAware(IClientProvider *clientProvider) : m_clientProvider(clientProvider) { }
|
||||
IClientProvider *m_clientProvider = nullptr; //!< access to object
|
||||
CClientAware(IClientProvider *clientProvider) : IProviderAware(clientProvider) { }
|
||||
};
|
||||
|
||||
//! Client provider dummy for testing
|
||||
|
||||
@@ -26,92 +26,92 @@ namespace BlackMisc
|
||||
|
||||
CSimulatedAircraft COwnAircraftAware::getOwnAircraft() const
|
||||
{
|
||||
Q_ASSERT_X(m_ownAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_ownAircraftProvider->getOwnAircraft();
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->getOwnAircraft();
|
||||
}
|
||||
|
||||
CCoordinateGeodetic COwnAircraftAware::getOwnAircraftPosition() const
|
||||
{
|
||||
Q_ASSERT_X(m_ownAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_ownAircraftProvider->getOwnAircraftPosition();
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->getOwnAircraftPosition();
|
||||
}
|
||||
|
||||
CAircraftSituation COwnAircraftAware::getOwnAircraftSituation() const
|
||||
{
|
||||
Q_ASSERT_X(m_ownAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_ownAircraftProvider->getOwnAircraftSituation();
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->getOwnAircraftSituation();
|
||||
}
|
||||
|
||||
CAircraftParts COwnAircraftAware::getOwnAircraftParts() const
|
||||
{
|
||||
Q_ASSERT_X(m_ownAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_ownAircraftProvider->getOwnAircraftParts();
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->getOwnAircraftParts();
|
||||
}
|
||||
|
||||
CAircraftModel COwnAircraftAware::getOwnAircraftModel() const
|
||||
{
|
||||
Q_ASSERT_X(m_ownAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_ownAircraftProvider->getOwnAircraftModel();
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->getOwnAircraftModel();
|
||||
}
|
||||
|
||||
CLength COwnAircraftAware::getDistanceToOwnAircraft(const Geo::ICoordinateGeodetic &position) const
|
||||
{
|
||||
Q_ASSERT_X(m_ownAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_ownAircraftProvider->getDistanceToOwnAircraft(position);
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->getDistanceToOwnAircraft(position);
|
||||
}
|
||||
|
||||
bool COwnAircraftAware::updateCockpit(const CSimulatedAircraft &aircraft, const CIdentifier &originator)
|
||||
{
|
||||
Q_ASSERT_X(m_ownAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_ownAircraftProvider->updateCockpit(aircraft, originator);
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->updateCockpit(aircraft, originator);
|
||||
}
|
||||
|
||||
bool COwnAircraftAware::updateCockpit(const CComSystem &com1, const CComSystem &com2, const CTransponder &transponder, const CIdentifier &originator)
|
||||
{
|
||||
Q_ASSERT_X(m_ownAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_ownAircraftProvider->updateCockpit(com1, com2, transponder, originator);
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->updateCockpit(com1, com2, transponder, originator);
|
||||
}
|
||||
|
||||
bool COwnAircraftAware::updateActiveComFrequency(const CFrequency &frequency, CComSystem::ComUnit comUnit, const CIdentifier &originator)
|
||||
{
|
||||
Q_ASSERT_X(m_ownAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_ownAircraftProvider->updateActiveComFrequency(frequency, comUnit, originator);
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->updateActiveComFrequency(frequency, comUnit, originator);
|
||||
}
|
||||
|
||||
bool COwnAircraftAware::updateSelcal(const CSelcal &selcal, const CIdentifier &originator)
|
||||
{
|
||||
Q_ASSERT_X(m_ownAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_ownAircraftProvider->updateSelcal(selcal, originator);
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->updateSelcal(selcal, originator);
|
||||
}
|
||||
|
||||
bool COwnAircraftAware::updateOwnModel(const CAircraftModel &model)
|
||||
{
|
||||
Q_ASSERT_X(m_ownAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_ownAircraftProvider->updateOwnModel(model);
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->updateOwnModel(model);
|
||||
}
|
||||
|
||||
bool COwnAircraftAware::updateOwnSituation(const CAircraftSituation &situation)
|
||||
{
|
||||
Q_ASSERT_X(m_ownAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_ownAircraftProvider->updateOwnSituation(situation);
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->updateOwnSituation(situation);
|
||||
}
|
||||
|
||||
bool COwnAircraftAware::updateOwnParts(const CAircraftParts &parts)
|
||||
{
|
||||
Q_ASSERT_X(m_ownAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_ownAircraftProvider->updateOwnParts(parts);
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->updateOwnParts(parts);
|
||||
}
|
||||
|
||||
bool COwnAircraftAware::updateOwnCallsign(const CCallsign &callsign)
|
||||
{
|
||||
Q_ASSERT_X(m_ownAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_ownAircraftProvider->updateOwnCallsign(callsign);
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->updateOwnCallsign(callsign);
|
||||
}
|
||||
|
||||
bool COwnAircraftAware::updateOwnIcaoCodes(const CAircraftIcaoCode &aircraftIcaoData, const CAirlineIcaoCode &airlineIcaoCode)
|
||||
{
|
||||
Q_ASSERT_X(m_ownAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_ownAircraftProvider->updateOwnIcaoCodes(aircraftIcaoData, airlineIcaoCode);
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->updateOwnIcaoCodes(aircraftIcaoData, airlineIcaoCode);
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -12,17 +12,18 @@
|
||||
#ifndef BLACKMISC_SIMULATION_OWNAIRCRAFTPROVIDER_H
|
||||
#define BLACKMISC_SIMULATION_OWNAIRCRAFTPROVIDER_H
|
||||
|
||||
#include "blackmisc/simulation/aircraftmodel.h"
|
||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
||||
#include "blackmisc/aviation/aircraftparts.h"
|
||||
#include "blackmisc/aviation/airlineicaocode.h"
|
||||
#include "blackmisc/aviation/comsystem.h"
|
||||
#include "blackmisc/aviation/selcal.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/geo/coordinategeodetic.h"
|
||||
#include "blackmisc/identifier.h"
|
||||
#include "blackmisc/pq/frequency.h"
|
||||
#include "blackmisc/pq/length.h"
|
||||
#include "blackmisc/simulation/aircraftmodel.h"
|
||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
||||
#include "blackmisc/provider.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/identifier.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QtGlobal>
|
||||
@@ -40,7 +41,7 @@ namespace BlackMisc
|
||||
namespace Simulation
|
||||
{
|
||||
//! Direct threadsafe in memory access to own aircraft
|
||||
class BLACKMISC_EXPORT IOwnAircraftProvider
|
||||
class BLACKMISC_EXPORT IOwnAircraftProvider : public IProvider
|
||||
{
|
||||
public:
|
||||
//! Own aircraft
|
||||
@@ -108,9 +109,12 @@ namespace BlackMisc
|
||||
};
|
||||
|
||||
//! Delegating class which can be directly used to access an \sa IOwnAircraftProvider instance
|
||||
class BLACKMISC_EXPORT COwnAircraftAware
|
||||
class BLACKMISC_EXPORT COwnAircraftAware : public IProviderAware<IOwnAircraftProvider>
|
||||
{
|
||||
public:
|
||||
//! Set the provider
|
||||
void setOwnAircraftProvider(IOwnAircraftProvider *provider) { this->setProvider(provider); }
|
||||
|
||||
//! \copydoc IOwnAircraftProvider::getOwnAircraft
|
||||
CSimulatedAircraft getOwnAircraft() const;
|
||||
|
||||
@@ -158,8 +162,7 @@ namespace BlackMisc
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
COwnAircraftAware(IOwnAircraftProvider *ownAircraftProvider) : m_ownAircraftProvider(ownAircraftProvider) { Q_ASSERT(ownAircraftProvider); }
|
||||
IOwnAircraftProvider *m_ownAircraftProvider = nullptr; //!< access to object
|
||||
COwnAircraftAware(IOwnAircraftProvider *ownAircraftProvider) : IProviderAware(ownAircraftProvider) { Q_ASSERT(ownAircraftProvider); }
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -18,116 +18,116 @@ namespace BlackMisc
|
||||
{
|
||||
CSimulatedAircraftList CRemoteAircraftAware::getAircraftInRange() const
|
||||
{
|
||||
Q_ASSERT_X(m_remoteAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_remoteAircraftProvider->getAircraftInRange();
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->getAircraftInRange();
|
||||
}
|
||||
|
||||
bool CRemoteAircraftAware::isAircraftInRange(const CCallsign &callsign) const
|
||||
{
|
||||
Q_ASSERT_X(m_remoteAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_remoteAircraftProvider->isAircraftInRange(callsign);
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->isAircraftInRange(callsign);
|
||||
}
|
||||
|
||||
int CRemoteAircraftAware::getAircraftInRangeCount() const
|
||||
{
|
||||
Q_ASSERT_X(m_remoteAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_remoteAircraftProvider->getAircraftInRangeCount();
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->getAircraftInRangeCount();
|
||||
}
|
||||
|
||||
CCallsignSet CRemoteAircraftAware::getAircraftInRangeCallsigns() const
|
||||
{
|
||||
Q_ASSERT_X(m_remoteAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_remoteAircraftProvider->getAircraftInRangeCallsigns();
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->getAircraftInRangeCallsigns();
|
||||
}
|
||||
|
||||
CSimulatedAircraft CRemoteAircraftAware::getAircraftInRangeForCallsign(const CCallsign &callsign) const
|
||||
{
|
||||
Q_ASSERT_X(m_remoteAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_remoteAircraftProvider->getAircraftInRangeForCallsign(callsign);
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->getAircraftInRangeForCallsign(callsign);
|
||||
}
|
||||
|
||||
CAircraftModel CRemoteAircraftAware::getAircraftInRangeModelForCallsign(const CCallsign &callsign) const
|
||||
{
|
||||
Q_ASSERT_X(m_remoteAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_remoteAircraftProvider->getAircraftInRangeModelForCallsign(callsign);
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->getAircraftInRangeModelForCallsign(callsign);
|
||||
}
|
||||
|
||||
CAirspaceAircraftSnapshot CRemoteAircraftAware::getLatestAirspaceAircraftSnapshot() const
|
||||
{
|
||||
Q_ASSERT_X(m_remoteAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_remoteAircraftProvider->getLatestAirspaceAircraftSnapshot();
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->getLatestAirspaceAircraftSnapshot();
|
||||
}
|
||||
|
||||
CAircraftSituationList CRemoteAircraftAware::remoteAircraftSituations(const BlackMisc::Aviation::CCallsign &callsign) const
|
||||
{
|
||||
Q_ASSERT_X(m_remoteAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_remoteAircraftProvider->remoteAircraftSituations(callsign);
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->remoteAircraftSituations(callsign);
|
||||
}
|
||||
|
||||
CAircraftPartsList CRemoteAircraftAware::remoteAircraftParts(const CCallsign &callsign, qint64 cutoffTimeBefore) const
|
||||
{
|
||||
Q_ASSERT_X(m_remoteAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_remoteAircraftProvider->remoteAircraftParts(callsign, cutoffTimeBefore);
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->remoteAircraftParts(callsign, cutoffTimeBefore);
|
||||
}
|
||||
|
||||
CCallsignSet CRemoteAircraftAware::remoteAircraftSupportingParts() const
|
||||
{
|
||||
Q_ASSERT_X(m_remoteAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_remoteAircraftProvider->remoteAircraftSupportingParts();
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->remoteAircraftSupportingParts();
|
||||
}
|
||||
|
||||
int CRemoteAircraftAware::remoteAircraftSituationsCount(const CCallsign &callsign) const
|
||||
{
|
||||
Q_ASSERT_X(m_remoteAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_remoteAircraftProvider->remoteAircraftSituationsCount(callsign);
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->remoteAircraftSituationsCount(callsign);
|
||||
}
|
||||
|
||||
bool CRemoteAircraftAware::updateAircraftModel(const Aviation::CCallsign &callsign, const CAircraftModel &model, const CIdentifier &originator)
|
||||
{
|
||||
Q_ASSERT_X(m_remoteAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_remoteAircraftProvider->updateAircraftModel(callsign, model, originator);
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->updateAircraftModel(callsign, model, originator);
|
||||
}
|
||||
|
||||
bool CRemoteAircraftAware::updateAircraftNetworkModel(const CCallsign &callsign, const CAircraftModel &model, const CIdentifier &originator)
|
||||
{
|
||||
Q_ASSERT_X(m_remoteAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_remoteAircraftProvider->updateAircraftNetworkModel(callsign, model, originator);
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->updateAircraftNetworkModel(callsign, model, originator);
|
||||
}
|
||||
|
||||
bool CRemoteAircraftAware::updateAircraftRendered(const CCallsign &callsign, bool rendered)
|
||||
{
|
||||
Q_ASSERT_X(m_remoteAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_remoteAircraftProvider->updateAircraftRendered(callsign, rendered);
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->updateAircraftRendered(callsign, rendered);
|
||||
}
|
||||
|
||||
bool CRemoteAircraftAware::updateAircraftGroundElevation(const CCallsign &callsign, const CElevationPlane &elevation)
|
||||
{
|
||||
Q_ASSERT_X(m_remoteAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_remoteAircraftProvider->updateAircraftGroundElevation(callsign, elevation);
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->updateAircraftGroundElevation(callsign, elevation);
|
||||
}
|
||||
|
||||
void CRemoteAircraftAware::updateMarkAllAsNotRendered()
|
||||
{
|
||||
Q_ASSERT_X(m_remoteAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
m_remoteAircraftProvider->updateMarkAllAsNotRendered();
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
this->provider()->updateMarkAllAsNotRendered();
|
||||
}
|
||||
|
||||
bool CRemoteAircraftAware::isRemoteAircraftSupportingParts(const CCallsign &callsign) const
|
||||
{
|
||||
Q_ASSERT_X(m_remoteAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_remoteAircraftProvider->isRemoteAircraftSupportingParts(callsign);
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->isRemoteAircraftSupportingParts(callsign);
|
||||
}
|
||||
|
||||
int CRemoteAircraftAware::getRemoteAircraftSupportingPartsCount() const
|
||||
{
|
||||
Q_ASSERT_X(m_remoteAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_remoteAircraftProvider->getRemoteAircraftSupportingPartsCount();
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->getRemoteAircraftSupportingPartsCount();
|
||||
}
|
||||
|
||||
bool CRemoteAircraftAware::updateAircraftEnabled(const CCallsign &callsign, bool enabledForRedering)
|
||||
{
|
||||
Q_ASSERT_X(m_remoteAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||
return m_remoteAircraftProvider->updateAircraftEnabled(callsign, enabledForRedering);
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->updateAircraftEnabled(callsign, enabledForRedering);
|
||||
}
|
||||
|
||||
CAircraftParts IRemoteAircraftProvider::getLatestAircraftParts(const CCallsign &callsign) const
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "blackmisc/aviation/aircraftpartslist.h"
|
||||
#include "blackmisc/aviation/aircraftsituationlist.h"
|
||||
#include "blackmisc/aviation/callsignset.h"
|
||||
#include "blackmisc/provider.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/identifier.h"
|
||||
|
||||
@@ -44,7 +45,7 @@ namespace BlackMisc
|
||||
//! \note Can not be derived from QObject (as for the signals), as this would create multiple
|
||||
//! inheritance. Hence Q_DECLARE_INTERFACE is used.
|
||||
//! \ingroup remoteaircraftprovider
|
||||
class BLACKMISC_EXPORT IRemoteAircraftProvider
|
||||
class BLACKMISC_EXPORT IRemoteAircraftProvider : public IProvider
|
||||
{
|
||||
public:
|
||||
static constexpr int MaxSituationsPerCallsign = 6; //!< How many situations we keep per callsign
|
||||
@@ -185,7 +186,7 @@ namespace BlackMisc
|
||||
};
|
||||
|
||||
//! Class which can be directly used to access an \sa IRemoteAircraftProvider object
|
||||
class BLACKMISC_EXPORT CRemoteAircraftAware
|
||||
class BLACKMISC_EXPORT CRemoteAircraftAware : public IProviderAware<IRemoteAircraftProvider>
|
||||
{
|
||||
public:
|
||||
//! \copydoc IRemoteAircraftProvider::getAircraftInRange
|
||||
@@ -246,15 +247,14 @@ namespace BlackMisc
|
||||
void updateMarkAllAsNotRendered();
|
||||
|
||||
//! Set remote aircraft provider
|
||||
void setRemoteAircraftProvider(IRemoteAircraftProvider *remoteAircraftProvider) { m_remoteAircraftProvider = remoteAircraftProvider; }
|
||||
void setRemoteAircraftProvider(IRemoteAircraftProvider *remoteAircraftProvider) { this->setProvider(remoteAircraftProvider); }
|
||||
|
||||
protected:
|
||||
//! Default constructor
|
||||
CRemoteAircraftAware() {}
|
||||
|
||||
//! Constructor
|
||||
CRemoteAircraftAware(IRemoteAircraftProvider *remoteAircraftProvider) : m_remoteAircraftProvider(remoteAircraftProvider) { Q_ASSERT(remoteAircraftProvider); }
|
||||
IRemoteAircraftProvider *m_remoteAircraftProvider = nullptr; //!< access to object
|
||||
CRemoteAircraftAware(IRemoteAircraftProvider *remoteAircraftProvider) : IProviderAware(remoteAircraftProvider) { Q_ASSERT(remoteAircraftProvider); }
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
|
||||
#include "simulationenvironmentprovider.h"
|
||||
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Geo;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -34,6 +36,28 @@ namespace BlackMisc
|
||||
return this->rememberGroundElevation(elevationPlane, elevationPlane.getRadius());
|
||||
}
|
||||
|
||||
bool ISimulationEnvironmentProvider::insertCG(const CLength &cg, const Aviation::CCallsign &cs)
|
||||
{
|
||||
if (cs.isEmpty()) { return false; }
|
||||
const bool remove = cg.isNull();
|
||||
QWriteLocker l(&m_lockCG);
|
||||
if (remove)
|
||||
{
|
||||
m_cgs.remove(cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_cgs[cs] = cg;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int ISimulationEnvironmentProvider::removeCG(const CCallsign &cs)
|
||||
{
|
||||
QWriteLocker l(&m_lockCG);
|
||||
return m_cgs.remove(cs);
|
||||
}
|
||||
|
||||
CCoordinateGeodeticList ISimulationEnvironmentProvider::getElevationCoordinates() const
|
||||
{
|
||||
QReadLocker l(&m_lockElvCoordinates);
|
||||
@@ -58,16 +82,105 @@ namespace BlackMisc
|
||||
return this->getElevationCoordinates().findClosestWithinRange(reference, range);
|
||||
}
|
||||
|
||||
void ISimulationEnvironmentProvider::clearSimulationEnvironmentData()
|
||||
CSimulatorPluginInfo ISimulationEnvironmentProvider::getSimulatorPluginInfo() const
|
||||
{
|
||||
QReadLocker l(&m_lockModel);
|
||||
return m_simulatorPluginInfo;
|
||||
}
|
||||
|
||||
CSimulatorInfo ISimulationEnvironmentProvider::getSimulatorInfo() const
|
||||
{
|
||||
return this->getSimulatorPluginInfo().getSimulatorInfo();
|
||||
}
|
||||
|
||||
CAircraftModel ISimulationEnvironmentProvider::getDefaultModel() const
|
||||
{
|
||||
QReadLocker l(&m_lockModel);
|
||||
return m_defaultModel;
|
||||
}
|
||||
|
||||
CLength ISimulationEnvironmentProvider::getCG(const Aviation::CCallsign &callsign) const
|
||||
{
|
||||
QReadLocker l(&m_lockCG);
|
||||
if (!m_cgs.contains(callsign)) { return CLength::null(); }
|
||||
return m_cgs.value(callsign);
|
||||
}
|
||||
|
||||
bool ISimulationEnvironmentProvider::hasCG(const Aviation::CCallsign &callsign) const
|
||||
{
|
||||
QReadLocker l(&m_lockCG);
|
||||
return m_cgs.contains(callsign);
|
||||
}
|
||||
|
||||
ISimulationEnvironmentProvider::ISimulationEnvironmentProvider(const CSimulatorPluginInfo &pluginInfo) : m_simulatorPluginInfo(pluginInfo)
|
||||
{ }
|
||||
|
||||
void ISimulationEnvironmentProvider::setNewPluginInfo(const CSimulatorPluginInfo &info, const CAircraftModel &defaultModel)
|
||||
{
|
||||
QWriteLocker l(&m_lockModel);
|
||||
m_simulatorPluginInfo = info;
|
||||
m_defaultModel = defaultModel;
|
||||
}
|
||||
|
||||
void ISimulationEnvironmentProvider::setDefaultModel(const CAircraftModel &defaultModel)
|
||||
{
|
||||
QWriteLocker l(&m_lockModel);
|
||||
m_defaultModel = defaultModel;
|
||||
}
|
||||
|
||||
void ISimulationEnvironmentProvider::clearDefaultModel()
|
||||
{
|
||||
QWriteLocker l(&m_lockModel);
|
||||
m_defaultModel = CAircraftModel();
|
||||
}
|
||||
|
||||
void ISimulationEnvironmentProvider::clearElevations()
|
||||
{
|
||||
QWriteLocker l(&m_lockElvCoordinates);
|
||||
m_elvCoordinates.clear();
|
||||
}
|
||||
|
||||
void ISimulationEnvironmentProvider::clearCGs()
|
||||
{
|
||||
QWriteLocker l(&m_lockCG);
|
||||
m_cgs.clear();
|
||||
}
|
||||
|
||||
void ISimulationEnvironmentProvider::clearSimulationEnvironmentData()
|
||||
{
|
||||
this->clearDefaultModel();
|
||||
this->clearElevations();
|
||||
this->clearCGs();
|
||||
}
|
||||
|
||||
CElevationPlane CSimulationEnvironmentAware::findClosestElevationWithinRange(const ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range)
|
||||
{
|
||||
if (!m_simEnvironmentProvider) { return CElevationPlane::null(); }
|
||||
return m_simEnvironmentProvider->findClosestElevationWithinRange(reference, range);
|
||||
if (!this->hasProvider()) { return CElevationPlane::null(); }
|
||||
return this->provider()->findClosestElevationWithinRange(reference, range);
|
||||
}
|
||||
|
||||
CSimulatorPluginInfo CSimulationEnvironmentAware::getSimulatorPluginInfo() const
|
||||
{
|
||||
if (!this->hasProvider()) { return CSimulatorPluginInfo(); }
|
||||
return this->provider()->getSimulatorPluginInfo();
|
||||
}
|
||||
|
||||
CSimulatorInfo CSimulationEnvironmentAware::getSimulatorInfo() const
|
||||
{
|
||||
if (!this->hasProvider()) { return CSimulatorInfo(); }
|
||||
return this->provider()->getSimulatorInfo();
|
||||
}
|
||||
|
||||
CAircraftModel CSimulationEnvironmentAware::getDefaultModel() const
|
||||
{
|
||||
if (!this->hasProvider()) { return CAircraftModel(); }
|
||||
return this->provider()->getDefaultModel();
|
||||
}
|
||||
|
||||
bool CSimulationEnvironmentAware::hasCG(const CCallsign &callsign) const
|
||||
{
|
||||
if (!this->hasProvider()) { return false; }
|
||||
return this->provider()->hasCG(callsign);
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -12,16 +12,22 @@
|
||||
#ifndef BLACKMISC_SIMULATION_SIMULATIONENVIRONMENTPROVIDER_H
|
||||
#define BLACKMISC_SIMULATION_SIMULATIONENVIRONMENTPROVIDER_H
|
||||
|
||||
#include "simulatorplugininfo.h"
|
||||
#include "aircraftmodel.h"
|
||||
#include "blackmisc/provider.h"
|
||||
#include "blackmisc/geo/coordinategeodeticlist.h"
|
||||
#include "blackmisc/geo/elevationplane.h"
|
||||
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
//! Direct in memory access to elevation data
|
||||
//! \remark we are interested in elevations of airports
|
||||
class BLACKMISC_EXPORT ISimulationEnvironmentProvider
|
||||
class BLACKMISC_EXPORT ISimulationEnvironmentProvider : public IProvider
|
||||
{
|
||||
public:
|
||||
//! All remembered coordiantes
|
||||
@@ -29,20 +35,55 @@ namespace BlackMisc
|
||||
//! \threadsafe
|
||||
Geo::CCoordinateGeodeticList getElevationCoordinates() const;
|
||||
|
||||
//! Only keep closest ones
|
||||
//! \threadsafe
|
||||
int cleanUpElevations(const Geo::ICoordinateGeodetic &referenceCoordinate, int maxNumber = MaxElevations);
|
||||
|
||||
//! Find closest elevation
|
||||
//! \threadsafe
|
||||
Geo::CElevationPlane findClosestElevationWithinRange(const Geo::ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range);
|
||||
|
||||
//! Get the represented plugin
|
||||
//! \threadsafe
|
||||
CSimulatorPluginInfo getSimulatorPluginInfo() const;
|
||||
|
||||
//! Get the represented simulator
|
||||
//! \threadsafe
|
||||
CSimulatorInfo getSimulatorInfo() const;
|
||||
|
||||
//! Default model
|
||||
//! \threadsafe
|
||||
CAircraftModel getDefaultModel() const;
|
||||
|
||||
//! Get CG per callsign, NULL if not found
|
||||
PhysicalQuantities::CLength getCG(const Aviation::CCallsign &callsign) const;
|
||||
|
||||
//! Has a CG?
|
||||
bool hasCG(const Aviation::CCallsign &callsign) const;
|
||||
|
||||
protected:
|
||||
//! Ctor
|
||||
ISimulationEnvironmentProvider(const CSimulatorPluginInfo &pluginInfo);
|
||||
|
||||
//! New plugin info and default model
|
||||
//! \remark normally only used by emulated driver
|
||||
void setNewPluginInfo(const CSimulatorPluginInfo &info, const CAircraftModel &defaultModel);
|
||||
|
||||
//! Default model
|
||||
void setDefaultModel(const CAircraftModel &defaultModel);
|
||||
|
||||
//! Clear default model
|
||||
void clearDefaultModel();
|
||||
|
||||
//! Clear elevations
|
||||
void clearElevations();
|
||||
|
||||
//! Clear CGs
|
||||
void clearCGs();
|
||||
|
||||
//! Clear data
|
||||
//! \threadsafe
|
||||
void clearSimulationEnvironmentData();
|
||||
|
||||
protected:
|
||||
static constexpr int MaxElevations = 1000; //!< How many elevations we keep
|
||||
//! Only keep closest ones
|
||||
//! \threadsafe
|
||||
int cleanUpElevations(const Geo::ICoordinateGeodetic &referenceCoordinate, int maxNumber = MaxElevations);
|
||||
|
||||
//! Remember a given elevation
|
||||
//! \threadsafe
|
||||
@@ -52,28 +93,58 @@ namespace BlackMisc
|
||||
//! \threadsafe
|
||||
bool rememberGroundElevation(const Geo::CElevationPlane &elevationPlane) ;
|
||||
|
||||
//! Insert or replace a CG
|
||||
//! \remark passing a NULL value will remove the CG
|
||||
//! \threadsafe
|
||||
bool insertCG(const PhysicalQuantities::CLength &cg, const Aviation::CCallsign &cs);
|
||||
|
||||
//! Remove a CG
|
||||
//! \threadsafe
|
||||
int removeCG(const Aviation::CCallsign &cs);
|
||||
|
||||
static constexpr int MaxElevations = 1000; //!< How many elevations we keep
|
||||
|
||||
private:
|
||||
CAircraftModel m_defaultModel; //!< default model
|
||||
CSimulatorPluginInfo m_simulatorPluginInfo; //!< info object
|
||||
Geo::CCoordinateGeodeticList m_elvCoordinates;
|
||||
QMap<Aviation::CCallsign, PhysicalQuantities::CLength> m_cgs; //! CGs
|
||||
mutable QReadWriteLock m_lockElvCoordinates; //!< lock m_coordinates
|
||||
mutable QReadWriteLock m_lockCG; //!< lock CGs
|
||||
mutable QReadWriteLock m_lockModel; //!< lock models
|
||||
};
|
||||
|
||||
//! Class which can be directly used to access an \sa ISimulationEnvironmentProvider object
|
||||
class BLACKMISC_EXPORT CSimulationEnvironmentAware
|
||||
class BLACKMISC_EXPORT CSimulationEnvironmentAware : public IProviderAware<ISimulationEnvironmentProvider>
|
||||
{
|
||||
public:
|
||||
//! Elevations, can be changed over time as it comes from simulator
|
||||
void setSimulationEnvironmentProvider(ISimulationEnvironmentProvider *provider) { m_simEnvironmentProvider = provider; }
|
||||
//! Set the provider
|
||||
void setSimulationEnvironmentProvider(ISimulationEnvironmentProvider *provider) { this->setProvider(provider); }
|
||||
|
||||
//! Find closest elevation
|
||||
//! \copydoc ISimulationEnvironmentProvider::findClosestElevationWithinRange
|
||||
Geo::CElevationPlane findClosestElevationWithinRange(const Geo::ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range);
|
||||
|
||||
//! \copydoc ISimulationEnvironmentProvider::getSimulatorPluginInfo
|
||||
CSimulatorPluginInfo getSimulatorPluginInfo() const;
|
||||
|
||||
//! \copydoc ISimulationEnvironmentProvider::getSimulatorPluginInfo
|
||||
CSimulatorInfo getSimulatorInfo() const;
|
||||
|
||||
//! \copydoc ISimulationEnvironmentProvider::getDefaultModel
|
||||
CAircraftModel getDefaultModel() const;
|
||||
|
||||
//! \copydoc ISimulationEnvironmentProvider::getCG
|
||||
PhysicalQuantities::CLength getCG(const Aviation::CCallsign &callsign) const;
|
||||
|
||||
//! \copydoc ISimulationEnvironmentProvider::hasCG
|
||||
bool hasCG(const Aviation::CCallsign &callsign) const;
|
||||
|
||||
protected:
|
||||
//! Default constructor
|
||||
CSimulationEnvironmentAware() {}
|
||||
|
||||
//! Constructor
|
||||
CSimulationEnvironmentAware(ISimulationEnvironmentProvider *simEnvProvider) : m_simEnvironmentProvider(simEnvProvider) { Q_ASSERT(simEnvProvider); }
|
||||
ISimulationEnvironmentProvider *m_simEnvironmentProvider = nullptr; //!< access to object
|
||||
CSimulationEnvironmentAware(ISimulationEnvironmentProvider *simEnvProvider) : IProviderAware(simEnvProvider) { Q_ASSERT(simEnvProvider); }
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -9,19 +9,16 @@
|
||||
|
||||
#include "blackmisc/weather/weathergridprovider.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Weather
|
||||
{
|
||||
|
||||
void CWeatherGridAware::requestWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid,
|
||||
const BlackMisc::CSlot<void(const BlackMisc::Weather::CWeatherGrid &)> &callback)
|
||||
void CWeatherGridAware::requestWeatherGrid(
|
||||
const CWeatherGrid &weatherGrid,
|
||||
const CSlot<void(const CWeatherGrid &)> &callback)
|
||||
{
|
||||
Q_ASSERT_X(this->m_weatherGridProvider, Q_FUNC_INFO, "No object available");
|
||||
this->m_weatherGridProvider->requestWeatherGrid(weatherGrid, callback);
|
||||
Q_ASSERT_X(this->hasProvider(), Q_FUNC_INFO, "No object available");
|
||||
this->provider()->requestWeatherGrid(weatherGrid, callback);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -12,16 +12,16 @@
|
||||
#ifndef BLACKMISC_WEATHER_WEATHERGRIDPROVIDER_H
|
||||
#define BLACKMISC_WEATHER_WEATHERGRIDPROVIDER_H
|
||||
|
||||
#include "blackmisc/weather/weathergrid.h"
|
||||
#include "blackmisc/provider.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/slot.h"
|
||||
#include "blackmisc/weather/weathergrid.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QtGlobal>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
|
||||
namespace Weather
|
||||
{
|
||||
//! Direct threadsafe in memory access to weather grid
|
||||
@@ -29,24 +29,22 @@ namespace BlackMisc
|
||||
{
|
||||
public:
|
||||
//! Request weather grid
|
||||
virtual void requestWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid,
|
||||
const BlackMisc::CSlot<void(const BlackMisc::Weather::CWeatherGrid &)> &callback) = 0;
|
||||
virtual void requestWeatherGrid(const CWeatherGrid &weatherGrid,
|
||||
const CSlot<void(const CWeatherGrid &)> &callback) = 0;
|
||||
};
|
||||
|
||||
//! Delegating class which can be directly used to access an \sa IWeatherGridProvider instance
|
||||
class BLACKMISC_EXPORT CWeatherGridAware
|
||||
class BLACKMISC_EXPORT CWeatherGridAware : public IProviderAware<IWeatherGridProvider>
|
||||
{
|
||||
public:
|
||||
//! \copydoc IWeatherGridProvider::requestWeatherGrid
|
||||
virtual void requestWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid,
|
||||
const BlackMisc::CSlot<void(const BlackMisc::Weather::CWeatherGrid &)> &callback);
|
||||
virtual void requestWeatherGrid(const CWeatherGrid &weatherGrid,
|
||||
const CSlot<void(const CWeatherGrid &)> &callback);
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CWeatherGridAware(IWeatherGridProvider *weatherGridProvider) : m_weatherGridProvider(weatherGridProvider) { Q_ASSERT(weatherGridProvider); }
|
||||
IWeatherGridProvider *m_weatherGridProvider = nullptr; //!< access to object
|
||||
CWeatherGridAware(IWeatherGridProvider *weatherGridProvider) : IProviderAware(weatherGridProvider) { Q_ASSERT(weatherGridProvider); }
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -117,13 +117,11 @@ namespace BlackSimPlugin
|
||||
emit this->simulatorStatusChanged(ISimulator::Disconnected);
|
||||
});
|
||||
|
||||
m_defaultModel =
|
||||
this->setDefaultModel(
|
||||
{
|
||||
"Boeing 737-400",
|
||||
CAircraftModel::TypeModelMatchingDefaultModel,
|
||||
"B737-400 default model",
|
||||
CAircraftIcaoCode("B734", "L2J")
|
||||
};
|
||||
"Boeing 737-400", CAircraftModel::TypeModelMatchingDefaultModel,
|
||||
"B737-400 default model", CAircraftIcaoCode("B734", "L2J")
|
||||
});
|
||||
}
|
||||
|
||||
bool CSimulatorFs9::isConnected() const
|
||||
|
||||
@@ -30,13 +30,13 @@ namespace BlackSimPlugin
|
||||
QObject *parent) :
|
||||
CSimulatorFsxCommon(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, parent)
|
||||
{
|
||||
m_defaultModel =
|
||||
this->setDefaultModel(
|
||||
{
|
||||
"Boeing 737-800 Paint1",
|
||||
CAircraftModel::TypeModelMatchingDefaultModel,
|
||||
"B737-800 default model",
|
||||
CAircraftIcaoCode("B738", "L2J")
|
||||
};
|
||||
});
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -32,13 +32,8 @@ namespace BlackSimPlugin
|
||||
QObject *parent) :
|
||||
CSimulatorFsxCommon(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, parent)
|
||||
{
|
||||
m_defaultModel =
|
||||
{
|
||||
"LOCKHEED L049_2",
|
||||
CAircraftModel::TypeModelMatchingDefaultModel,
|
||||
"Constellation in TWA livery",
|
||||
CAircraftIcaoCode("CONI", "L4P")
|
||||
};
|
||||
this->setDefaultModel(CAircraftModel("LOCKHEED L049_2", CAircraftModel::TypeModelMatchingDefaultModel,
|
||||
"Constellation in TWA livery", CAircraftIcaoCode("CONI", "L4P")));
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -100,14 +100,8 @@ namespace BlackSimPlugin
|
||||
m_fastTimer.start(100);
|
||||
m_slowTimer.start(1000);
|
||||
|
||||
m_defaultModel =
|
||||
{
|
||||
"Jets A320_a A320_a_Austrian_Airlines A320_a_Austrian_Airlines",
|
||||
CAircraftModel::TypeModelMatchingDefaultModel,
|
||||
"A320 AUA",
|
||||
CAircraftIcaoCode("A320", "L2J")
|
||||
};
|
||||
|
||||
this->setDefaultModel({ "Jets A320_a A320_a_Austrian_Airlines A320_a_Austrian_Airlines", CAircraftModel::TypeModelMatchingDefaultModel,
|
||||
"A320 AUA", CAircraftIcaoCode("A320", "L2J")});
|
||||
this->resetXPlaneData();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user