mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
refs #786, prepare contexts for matching messages
In same step cleaned up contexts a bit * added function for model set strings * renamed functions to getModelSet... instead of installed models (the set is smaller and is what we want to use with DBus) * signal when debug/log flags changed * removed some \copydoc * allow to enable/disable rev.lookup/matching messages * removed reload model function (dangling)
This commit is contained in:
@@ -69,7 +69,8 @@ namespace BlackCore
|
||||
|
||||
void CContext::setDebugEnabled(bool debug)
|
||||
{
|
||||
this->m_debugEnabled = debug;
|
||||
if (this->m_debugEnabled == debug) { return; }
|
||||
emit this->changedLogOrDebugSettings();
|
||||
}
|
||||
|
||||
bool CContext::isDebugEnabled() const
|
||||
@@ -77,6 +78,13 @@ namespace BlackCore
|
||||
return this->m_debugEnabled;
|
||||
}
|
||||
|
||||
void CContext::relayBaseClassSignals(const QString &serviceName, QDBusConnection &connection, const QString &objectPath, const QString &interfaceName)
|
||||
{
|
||||
bool s = connection.connect(serviceName, objectPath, interfaceName,
|
||||
"changedLogOrDebugSettings", this, SIGNAL(changedLogOrDebugSettings()));
|
||||
Q_ASSERT(s);
|
||||
}
|
||||
|
||||
const IContextSimulator *CContext::getIContextSimulator() const
|
||||
{
|
||||
return this->getRuntime()->getIContextSimulator();
|
||||
|
||||
@@ -38,6 +38,8 @@ namespace BlackCore
|
||||
//! Base for all context classes
|
||||
class BLACKCORE_EXPORT CContext : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Destructor
|
||||
virtual ~CContext() {}
|
||||
@@ -83,9 +85,9 @@ namespace BlackCore
|
||||
//! Unique id
|
||||
qint64 getUniqueId() const { return this->m_contextId; }
|
||||
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
// cross context access
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
//! Context for application
|
||||
const IContextApplication *getIContextApplication() const;
|
||||
@@ -126,6 +128,10 @@ namespace BlackCore
|
||||
//! Id and path name for round trip protection
|
||||
virtual QString getPathAndContextId() const = 0;
|
||||
|
||||
signals:
|
||||
//! Log or debug values changed
|
||||
void changedLogOrDebugSettings();
|
||||
|
||||
protected:
|
||||
CCoreFacadeConfig::ContextMode m_mode; //!< How context is used
|
||||
qint64 m_contextId; //!< unique identifer, avoid redirection rountrips
|
||||
@@ -142,6 +148,9 @@ namespace BlackCore
|
||||
return QString(path) + ":" + QString::number(this->getUniqueId());
|
||||
}
|
||||
|
||||
//! Relay signals from this class
|
||||
void relayBaseClassSignals(const QString &serviceName, QDBusConnection &connection, const QString &objectPath, const QString &interfaceName);
|
||||
|
||||
//! Empty context called
|
||||
void logEmptyContextWarning(const QString &functionName) const
|
||||
{
|
||||
|
||||
@@ -62,6 +62,7 @@ namespace BlackCore
|
||||
s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(),
|
||||
"hotkeyActionsRegistered", this, SIGNAL(hotkeyActionsRegistered(QStringList, BlackMisc::CIdentifier)));
|
||||
Q_UNUSED(s);
|
||||
this->relayBaseClassSignals(serviceName, connection, IContextApplication::ObjectPath(), IContextApplication::InterfaceName());
|
||||
}
|
||||
|
||||
void CContextApplicationProxy::logMessage(const CStatusMessage &message, const CIdentifier &origin)
|
||||
|
||||
@@ -48,6 +48,8 @@ namespace BlackCore
|
||||
"changedMute", this, SIGNAL(changedMute(bool)));
|
||||
Q_ASSERT(s);
|
||||
Q_UNUSED(s);
|
||||
|
||||
this->relayBaseClassSignals(serviceName, connection, IContextAudio::ObjectPath(), IContextAudio::InterfaceName());
|
||||
}
|
||||
|
||||
void CContextAudioProxy::leaveAllVoiceRooms()
|
||||
|
||||
@@ -263,7 +263,7 @@ namespace BlackCore
|
||||
//! Change fast position updates
|
||||
virtual bool updateFastPositionEnabled(const BlackMisc::Aviation::CCallsign &callsign, bool enableFastPositionSending) = 0;
|
||||
|
||||
//! Get reverse lookup meesages
|
||||
//! Get reverse lookup messages
|
||||
virtual BlackMisc::CStatusMessageList getReverseLookupMessages(const BlackMisc::Aviation::CCallsign &callsign) const = 0;
|
||||
|
||||
//! Enabled reverse lookup logging?
|
||||
@@ -272,6 +272,8 @@ namespace BlackCore
|
||||
//! Enable reverse lookup logging
|
||||
virtual void enableReverseLookupMessages(bool enabled) = 0;
|
||||
|
||||
// ------------------------ testing ------------------------
|
||||
|
||||
//! Create dummy ATC stations for performance tests etc.
|
||||
virtual void testCreateDummyOnlineAtcStations(int number) = 0;
|
||||
|
||||
|
||||
@@ -522,7 +522,9 @@ namespace BlackCore
|
||||
void CContextNetwork::enableReverseLookupMessages(bool enabled)
|
||||
{
|
||||
if (this->isDebugEnabled()) { BlackMisc::CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << enabled; }
|
||||
return this->m_airspace->enableReverseLookupMessages(enabled);
|
||||
if (this->m_airspace->isReverseLookupMessagesEnabled() == enabled) { return; }
|
||||
this->m_airspace->enableReverseLookupMessages(enabled);
|
||||
emit CContext::changedLogOrDebugSettings();
|
||||
}
|
||||
|
||||
CAtcStation CContextNetwork::getOnlineStationForCallsign(const CCallsign &callsign) const
|
||||
|
||||
@@ -142,12 +142,6 @@ namespace BlackCore
|
||||
//! \ingroup remoteaircraftprovider
|
||||
virtual bool updateFastPositionEnabled(const BlackMisc::Aviation::CCallsign &callsign, bool enableFastPositonUpdates) override;
|
||||
|
||||
//! \copydoc IContextNetwork::readAtcBookingsFromSource()
|
||||
virtual void readAtcBookingsFromSource() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::getAtcStationsOnline()
|
||||
virtual BlackMisc::Aviation::CAtcStationList getAtcStationsOnline() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::getAtcStationsBooked()
|
||||
virtual BlackMisc::Aviation::CAtcStationList getAtcStationsBooked() const override;
|
||||
|
||||
@@ -183,6 +177,26 @@ namespace BlackCore
|
||||
//! \ingroup remoteaircraftprovider
|
||||
virtual void enableReverseLookupMessages(bool enabled) override;
|
||||
|
||||
//! In transition state, e.g. connecting, disconnecting.
|
||||
//! \details In such a state it is advisable to wait until an end state (connected/disconnected) is reached
|
||||
//! \remarks Intentionally only running locally, not in interface
|
||||
bool isPendingConnection() const;
|
||||
|
||||
//! \ingroup commandline
|
||||
//! @{
|
||||
//! <pre>
|
||||
//! .m .msg message text
|
||||
//! </pre>
|
||||
//! @}
|
||||
//! \copydoc IContextNetwork::parseCommandLine
|
||||
virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override;
|
||||
|
||||
//! \copydoc IContextNetwork::readAtcBookingsFromSource()
|
||||
virtual void readAtcBookingsFromSource() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::getAtcStationsOnline()
|
||||
virtual BlackMisc::Aviation::CAtcStationList getAtcStationsOnline() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::getOnlineStationForCallsign
|
||||
virtual BlackMisc::Aviation::CAtcStation getOnlineStationForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||
|
||||
@@ -198,20 +212,6 @@ namespace BlackCore
|
||||
//! \copydoc IContextNetwork::isConnected()
|
||||
virtual bool isConnected() const override;
|
||||
|
||||
//! In transition state, e.g. connecting, disconnecting.
|
||||
//! \details In such a state it is advisable to wait until an end state (connected/disconnected) is reached
|
||||
//! \remarks Intentionally only running locally, not in interface
|
||||
bool isPendingConnection() const;
|
||||
|
||||
//! \ingroup commandline
|
||||
//! @{
|
||||
//! <pre>
|
||||
//! .m .msg message text
|
||||
//! </pre>
|
||||
//! @}
|
||||
//! \copydoc IContextNetwork::parseCommandLine
|
||||
virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override;
|
||||
|
||||
//! \copydoc IContextNetwork::sendTextMessages()
|
||||
virtual void sendTextMessages(const BlackMisc::Network::CTextMessageList &textMessages) override;
|
||||
|
||||
|
||||
@@ -88,6 +88,7 @@ namespace BlackCore
|
||||
"removedAircraft", this, SIGNAL(removedAircraft(BlackMisc::Aviation::CCallsign)));
|
||||
Q_ASSERT(s);
|
||||
Q_UNUSED(s);
|
||||
this->relayBaseClassSignals(serviceName, connection, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName());
|
||||
}
|
||||
|
||||
void CContextNetworkProxy::readAtcBookingsFromSource() const
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace BlackCore
|
||||
"changedAircraftCockpit", this, SIGNAL(changedAircraftCockpit(BlackMisc::Simulation::CSimulatedAircraft, BlackMisc::CIdentifier)));
|
||||
Q_ASSERT(s);
|
||||
Q_UNUSED(s);
|
||||
this->relayBaseClassSignals(serviceName, connection, IContextOwnAircraft::ObjectPath(), IContextOwnAircraft::InterfaceName());
|
||||
}
|
||||
|
||||
BlackMisc::Simulation::CSimulatedAircraft CContextOwnAircraftProxy::getOwnAircraft() const
|
||||
|
||||
@@ -134,17 +134,18 @@ namespace BlackCore
|
||||
//! Airports in range
|
||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const = 0;
|
||||
|
||||
//! Reload models from disk
|
||||
virtual void reloadInstalledModels() = 0;
|
||||
|
||||
//! Installed models in simulator eco system
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getInstalledModels() const = 0;
|
||||
//! \note might be slow since list can be big
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getModelSet() const = 0;
|
||||
|
||||
//! Number of installed models in simulator eco system
|
||||
virtual int getInstalledModelsCount() const = 0;
|
||||
virtual int getModelSetCount() const = 0;
|
||||
|
||||
//! Model for model string
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getInstalledModelsStartingWith(const QString modelString) const = 0;
|
||||
//! Models for model string
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getModelSetModelsStartingWith(const QString modelString) const = 0;
|
||||
|
||||
//! Model strings
|
||||
virtual QStringList getModelSetStrings() const = 0;
|
||||
|
||||
//! Set time synchronization between simulator and user's computer time
|
||||
//! \remarks not all drivers implement this, e.g. if it is an intrinsic simulator feature
|
||||
@@ -195,6 +196,15 @@ namespace BlackCore
|
||||
//! Enable debugging
|
||||
virtual void enableDebugMessages(bool driver, bool interpolator) = 0;
|
||||
|
||||
//! Get mapping messages
|
||||
virtual BlackMisc::CStatusMessageList getMatchingMessages(const BlackMisc::Aviation::CCallsign &callsign) const = 0;
|
||||
|
||||
//! Enabled mapping logging?
|
||||
virtual bool isMatchingMessagesEnabled() const = 0;
|
||||
|
||||
//! Enable mapping logging
|
||||
virtual void enableMatchingMessages(bool enabled) = 0;
|
||||
|
||||
//! Highlight aircraft in simulator
|
||||
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) = 0;
|
||||
|
||||
|
||||
@@ -59,48 +59,49 @@ namespace BlackCore
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::stopSimulatorPlugin()
|
||||
//! \copydoc IContextSimulator::stopSimulatorPlugin
|
||||
virtual void stopSimulatorPlugin(const BlackMisc::Simulation::CSimulatorPluginInfo &simulatorInfo) override
|
||||
{
|
||||
Q_UNUSED(simulatorInfo);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::getAirportsInRange()
|
||||
//! \copydoc IContextSimulator::getAirportsInRange
|
||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Aviation::CAirportList();
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::getInstalledModels()
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getInstalledModels() const override
|
||||
//! \copydoc IContextSimulator::getModelSet
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getModelSet() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Simulation::CAircraftModelList();
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::getInstalledModelsStartingWith
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getInstalledModelsStartingWith(const QString modelString) const override
|
||||
//! \copydoc IContextSimulator::getModelSetStrings
|
||||
virtual QStringList getModelSetStrings() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::getModelSetModelsStartingWith
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getModelSetModelsStartingWith(const QString modelString) const override
|
||||
{
|
||||
Q_UNUSED(modelString);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Simulation::CAircraftModelList();
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::getInstalledModelsCount
|
||||
virtual int getInstalledModelsCount() const override
|
||||
//! \copydoc IContextSimulator::getModelSetCount
|
||||
virtual int getModelSetCount() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::reloadInstalledModels
|
||||
virtual void reloadInstalledModels() override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::getSimulatorSetup
|
||||
virtual BlackMisc::Simulation::CSimulatorSetup getSimulatorSetup() const override
|
||||
{
|
||||
@@ -225,6 +226,28 @@ namespace BlackCore
|
||||
Q_UNUSED(interpolator);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::getMatchingMessages
|
||||
virtual BlackMisc::CStatusMessageList getMatchingMessages(const BlackMisc::Aviation::CCallsign &callsign) const override
|
||||
{
|
||||
Q_UNUSED(callsign);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::CStatusMessageList();
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::enableMatchingMessages
|
||||
virtual void enableMatchingMessages(bool enable) override
|
||||
{
|
||||
Q_UNUSED(enable);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::isMatchingMessagesEnabled
|
||||
virtual bool isMatchingMessagesEnabled() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
#include "blackcore/context/contextownaircraftimpl.h"
|
||||
#include "blackcore/context/contextsimulatorimpl.h"
|
||||
#include "blackcore/corefacade.h"
|
||||
#include "blackcore/matchingutils.h"
|
||||
#include "blackcore/application.h"
|
||||
#include "blackcore/pluginmanagersimulator.h"
|
||||
#include "blackcore/simulator.h"
|
||||
#include "blackmisc/aviation/callsign.h"
|
||||
@@ -50,7 +52,8 @@ namespace BlackCore
|
||||
CIdentifiable(this),
|
||||
m_plugins(new CPluginManagerSimulator(this))
|
||||
{
|
||||
this->setObjectName("CContextSimulator");
|
||||
setObjectName("CContextSimulator");
|
||||
m_enableMatchingMessages = sApp->isRunningInDeveloperEnvironment();
|
||||
connect(&m_weatherManager, &CWeatherManager::weatherGridReceived, this, &CContextSimulator::weatherGridReceived);
|
||||
m_plugins->collectPlugins();
|
||||
restoreSimulatorPlugins();
|
||||
@@ -139,29 +142,33 @@ namespace BlackCore
|
||||
return m_simulatorPlugin.second->getAirportsInRange();
|
||||
}
|
||||
|
||||
CAircraftModelList CContextSimulator::getInstalledModels() const
|
||||
CAircraftModelList CContextSimulator::getModelSet() const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
|
||||
// If no ISimulator object is available, return a dummy.
|
||||
if (m_simulatorPlugin.first.isUnspecified())
|
||||
{
|
||||
return CAircraftModelList();
|
||||
}
|
||||
if (m_simulatorPlugin.first.isUnspecified()) { return CAircraftModelList(); }
|
||||
|
||||
Q_ASSERT(m_simulatorPlugin.second);
|
||||
return m_modelMatcher.getModelSet();
|
||||
}
|
||||
|
||||
int CContextSimulator::getInstalledModelsCount() const
|
||||
QStringList CContextSimulator::getModelSetStrings() const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
return this->getModelSet().getModelStringList(false);
|
||||
}
|
||||
|
||||
int CContextSimulator::getModelSetCount() const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (m_simulatorPlugin.first.isUnspecified()) { return 0; }
|
||||
|
||||
Q_ASSERT(m_simulatorPlugin.second);
|
||||
return getInstalledModels().size();
|
||||
return getModelSet().size();
|
||||
}
|
||||
|
||||
CAircraftModelList CContextSimulator::getInstalledModelsStartingWith(const QString modelString) const
|
||||
CAircraftModelList CContextSimulator::getModelSetModelsStartingWith(const QString modelString) const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << modelString; }
|
||||
if (m_simulatorPlugin.first.isUnspecified())
|
||||
@@ -170,18 +177,7 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
Q_ASSERT(m_simulatorPlugin.second);
|
||||
return getInstalledModels().findModelsStartingWith(modelString);
|
||||
}
|
||||
|
||||
void CContextSimulator::reloadInstalledModels()
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (m_simulatorPlugin.first.isUnspecified())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Q_ASSERT(m_simulatorPlugin.second);
|
||||
m_simulatorPlugin.second->reloadInstalledModels();
|
||||
return getModelSet().findModelsStartingWith(modelString);
|
||||
}
|
||||
|
||||
bool CContextSimulator::setTimeSynchronization(bool enable, const CTime &offset)
|
||||
@@ -376,7 +372,7 @@ namespace BlackCore
|
||||
Q_ASSERT(c);
|
||||
Q_UNUSED(c);
|
||||
|
||||
// Once the simulator signaled it is ready to simulate, add all known aircrafts.
|
||||
// Once the simulator signaled it is ready to simulate, add all known aircraft
|
||||
m_initallyAddAircrafts = true;
|
||||
// try to connect to simulator
|
||||
simulator->connectTo();
|
||||
@@ -387,6 +383,7 @@ namespace BlackCore
|
||||
emit simulatorPluginChanged(simulatorPluginInfo);
|
||||
CLogMessage(this).info("Simulator plugin loaded: %1") << simulatorPluginInfo.toQString(true);
|
||||
|
||||
m_matchingMessages.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -442,7 +439,7 @@ namespace BlackCore
|
||||
|
||||
void CContextSimulator::listenForAllSimulators()
|
||||
{
|
||||
auto plugins = getAvailableSimulatorPlugins();
|
||||
const auto plugins = getAvailableSimulatorPlugins();
|
||||
for (const CSimulatorPluginInfo &p : plugins)
|
||||
{
|
||||
Q_ASSERT(!p.isUnspecified());
|
||||
@@ -482,11 +479,15 @@ namespace BlackCore
|
||||
if (!isSimulatorSimulating()) { return; }
|
||||
Q_ASSERT(!remoteAircraft.getCallsign().isEmpty());
|
||||
|
||||
CCallsign callsign = remoteAircraft.getCallsign();
|
||||
CAircraftModel aircraftModel = m_modelMatcher.getClosestMatch(remoteAircraft);
|
||||
const CCallsign callsign = remoteAircraft.getCallsign();
|
||||
CStatusMessageList matchingMessages;
|
||||
CStatusMessageList *pMatchingMessages = m_enableMatchingMessages ? &matchingMessages : nullptr;
|
||||
CMatchingUtils::addLogDetailsToList(pMatchingMessages, callsign, QString("Matching remote Aircraft"));
|
||||
const CAircraftModel aircraftModel = m_modelMatcher.getClosestMatch(remoteAircraft, pMatchingMessages);
|
||||
addMatchingMessages(callsign, matchingMessages);
|
||||
Q_ASSERT_X(remoteAircraft.getCallsign() == aircraftModel.getCallsign(), Q_FUNC_INFO, "mismatching callsigns");
|
||||
updateAircraftModel(callsign, aircraftModel, identifier());
|
||||
CSimulatedAircraft aircraftAfterModelApplied = getAircraftInRangeForCallsign(remoteAircraft.getCallsign());
|
||||
const CSimulatedAircraft aircraftAfterModelApplied = getAircraftInRangeForCallsign(remoteAircraft.getCallsign());
|
||||
m_simulatorPlugin.second->logicallyAddRemoteAircraft(aircraftAfterModelApplied);
|
||||
emit modelMatchingCompleted(remoteAircraft);
|
||||
}
|
||||
@@ -597,14 +598,36 @@ namespace BlackCore
|
||||
return m_simulatorPlugin.second->enableDebugMessages(driver, interpolator);
|
||||
}
|
||||
|
||||
CStatusMessageList CContextSimulator::getMatchingMessages(const CCallsign &callsign) const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; }
|
||||
return m_matchingMessages[callsign];
|
||||
}
|
||||
|
||||
bool CContextSimulator::isMatchingMessagesEnabled() const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
return m_enableMatchingMessages;
|
||||
}
|
||||
|
||||
void CContextSimulator::enableMatchingMessages(bool enabled)
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << enabled; }
|
||||
if (m_enableMatchingMessages == enabled) { return; }
|
||||
m_enableMatchingMessages = enabled;
|
||||
emit CContext::changedLogOrDebugSettings();
|
||||
}
|
||||
|
||||
void CContextSimulator::highlightAircraft(const CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const CTime &displayTime)
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << aircraftToHighlight << enableHighlight << displayTime; }
|
||||
Q_ASSERT(m_simulatorPlugin.second);
|
||||
m_simulatorPlugin.second->highlightAircraft(aircraftToHighlight, enableHighlight, displayTime);
|
||||
}
|
||||
|
||||
void CContextSimulator::requestWeatherGrid(const Weather::CWeatherGrid &weatherGrid, const CIdentifier &identifier)
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << identifier; }
|
||||
m_weatherManager.requestWeatherGrid(weatherGrid, identifier);
|
||||
}
|
||||
|
||||
@@ -622,5 +645,21 @@ namespace BlackCore
|
||||
if (listener) { QMetaObject::invokeMethod(listener, "stop"); }
|
||||
}
|
||||
}
|
||||
|
||||
void CContextSimulator::addMatchingMessages(const CCallsign &callsign, const CStatusMessageList &messages)
|
||||
{
|
||||
if (callsign.isEmpty()) { return; }
|
||||
if (messages.isEmpty()) { return; }
|
||||
if (!this->m_enableMatchingMessages) { return; }
|
||||
if (this->m_matchingMessages.contains(callsign))
|
||||
{
|
||||
CStatusMessageList &msgs = this->m_matchingMessages[callsign];
|
||||
msgs.push_back(messages);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->m_matchingMessages.insert(callsign, messages);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -54,9 +54,9 @@ namespace BlackCore
|
||||
{
|
||||
//! Network simulator concrete implementation
|
||||
class BLACKCORE_EXPORT CContextSimulator :
|
||||
public IContextSimulator,
|
||||
public BlackMisc::Simulation::CRemoteAircraftAware, // gain access to in memory remote aircraft data
|
||||
public BlackMisc::CIdentifiable
|
||||
public IContextSimulator,
|
||||
public BlackMisc::Simulation::CRemoteAircraftAware, // gain access to in memory remote aircraft data
|
||||
public BlackMisc::CIdentifiable
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTSIMULATOR_INTERFACENAME)
|
||||
@@ -71,86 +71,39 @@ namespace BlackCore
|
||||
void gracefulShutdown();
|
||||
|
||||
public slots:
|
||||
//! \copydoc IContextSimulator::getSimulatorPluginInfo()
|
||||
//! \name Interface overrides
|
||||
//! @{
|
||||
virtual BlackMisc::Simulation::CSimulatorPluginInfo getSimulatorPluginInfo() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getAvailableSimulatorPlugins()
|
||||
virtual BlackMisc::Simulation::CSimulatorPluginInfoList getAvailableSimulatorPlugins() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::startSimulatorPlugin()
|
||||
virtual bool startSimulatorPlugin(const BlackMisc::Simulation::CSimulatorPluginInfo &simulatorInfo) override;
|
||||
|
||||
//! \copydoc IContextSimulator::stopSimulatorPlugin()
|
||||
virtual void stopSimulatorPlugin(const BlackMisc::Simulation::CSimulatorPluginInfo &simulatorInfo) override;
|
||||
|
||||
//! \copydoc IContextSimulator::getSimulatorStatus()
|
||||
virtual int getSimulatorStatus() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getSimulatorSetup()
|
||||
virtual BlackMisc::Simulation::CSimulatorSetup getSimulatorSetup() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getAirportsInRange
|
||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getInstalledModels
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getInstalledModels() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getInstalledModelsCount
|
||||
virtual int getInstalledModelsCount() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getInstalledModelsStartingWith
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getInstalledModelsStartingWith(const QString modelString) const override;
|
||||
|
||||
//! \copydoc IContextSimulator::reloadInstalledModels
|
||||
virtual void reloadInstalledModels() override;
|
||||
|
||||
//! \copydoc IContextSimulator::setTimeSynchronization
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getModelSet() const override;
|
||||
virtual QStringList getModelSetStrings() const override;
|
||||
virtual int getModelSetCount() const override;
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getModelSetModelsStartingWith(const QString modelString) const override;
|
||||
virtual bool setTimeSynchronization(bool enable, const BlackMisc::PhysicalQuantities::CTime &offset) override;
|
||||
|
||||
//! \copydoc IContextSimulator::isTimeSynchronized
|
||||
virtual bool isTimeSynchronized() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getMaxRenderedAircraft
|
||||
virtual int getMaxRenderedAircraft() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::setMaxRenderedAircraft
|
||||
virtual void setMaxRenderedAircraft(int number) override;
|
||||
|
||||
//! \copydoc IContextSimulator::getMaxRenderedDistance
|
||||
virtual BlackMisc::PhysicalQuantities::CLength getMaxRenderedDistance() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::setMaxRenderedDistance
|
||||
virtual void setMaxRenderedDistance(const BlackMisc::PhysicalQuantities::CLength &distance) override;
|
||||
|
||||
//! \copydoc IContextSimulator::getRenderRestrictionText
|
||||
virtual QString getRenderRestrictionText() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getRenderedDistanceBoundary
|
||||
virtual BlackMisc::PhysicalQuantities::CLength getRenderedDistanceBoundary() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::setMaxRenderedDistance
|
||||
virtual void deleteAllRenderingRestrictions() override;
|
||||
|
||||
//! \copydoc IContextSimulator::isRenderingRestricted
|
||||
virtual bool isRenderingRestricted() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::isRenderingEnabled
|
||||
virtual bool isRenderingEnabled() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getTimeSynchronizationOffset
|
||||
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::iconForModel
|
||||
virtual BlackMisc::CPixmap iconForModel(const QString &modelString) const override;
|
||||
|
||||
//! \copydoc ISimulator::enableDebugMessages
|
||||
virtual void enableDebugMessages(bool driver, bool interpolator) override;
|
||||
|
||||
//! \copydoc IContextSimulator::highlightAircraft
|
||||
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) override;
|
||||
|
||||
//! \copydoc IContextSimulator::requestWeatherGrid
|
||||
virtual void requestWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid, const BlackMisc::CIdentifier &identifier) override;
|
||||
virtual void enableDebugMessages(bool driver, bool interpolator) override;
|
||||
virtual BlackMisc::CStatusMessageList getMatchingMessages(const BlackMisc::Aviation::CCallsign &callsign) const;
|
||||
virtual bool isMatchingMessagesEnabled() const;
|
||||
virtual void enableMatchingMessages(bool enabled);
|
||||
//! @}
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
@@ -207,15 +160,19 @@ namespace BlackCore
|
||||
//! Call stop() on all loaded listeners
|
||||
void stopSimulatorListeners();
|
||||
|
||||
//! Add to message list for matching
|
||||
void addMatchingMessages(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::CStatusMessageList &messages);
|
||||
|
||||
QPair<BlackMisc::Simulation::CSimulatorPluginInfo, ISimulator *> m_simulatorPlugin; //!< Currently loaded simulator plugin
|
||||
CPluginManagerSimulator *m_plugins = nullptr;
|
||||
BlackMisc::CRegularThread m_listenersThread;
|
||||
BlackMisc::CRegularThread m_listenersThread; //!< waiting for plugin
|
||||
BlackCore::CWeatherManager m_weatherManager { this };
|
||||
BlackMisc::CSetting<BlackCore::Application::TEnabledSimulators> m_enabledSimulators { this, &CContextSimulator::restoreSimulatorPlugins };
|
||||
bool m_initallyAddAircrafts = false;
|
||||
|
||||
BlackCore::CAircraftMatcher m_modelMatcher; //!< Model matcher
|
||||
BlackCore::CAircraftMatcher m_modelMatcher; //!< Model matcher
|
||||
BlackMisc::Simulation::CAircraftModelSetLoader m_modelSetLoader { this }; //!< load model set from caches
|
||||
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::CStatusMessageList> m_matchingMessages;
|
||||
bool m_initallyAddAircrafts = false;
|
||||
bool m_enableMatchingMessages = true;
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -63,6 +63,7 @@ namespace BlackCore
|
||||
"weatherGridReceived", this, SIGNAL(weatherGridReceived(BlackMisc::Weather::CWeatherGrid, BlackMisc::CIdentifier)));
|
||||
Q_ASSERT(s);
|
||||
Q_UNUSED(s);
|
||||
this->relayBaseClassSignals(serviceName, connection, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName());
|
||||
}
|
||||
|
||||
CSimulatorPluginInfoList CContextSimulatorProxy::getAvailableSimulatorPlugins() const
|
||||
@@ -80,24 +81,24 @@ namespace BlackCore
|
||||
return m_dBusInterface->callDBusRet<BlackMisc::Aviation::CAirportList>(QLatin1Literal("getAirportsInRange"));
|
||||
}
|
||||
|
||||
CAircraftModelList CContextSimulatorProxy::getInstalledModels() const
|
||||
CAircraftModelList CContextSimulatorProxy::getModelSet() const
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<BlackMisc::Simulation::CAircraftModelList>(QLatin1Literal("getInstalledModels"));
|
||||
return m_dBusInterface->callDBusRet<BlackMisc::Simulation::CAircraftModelList>(QLatin1Literal("getModelSet"));
|
||||
}
|
||||
|
||||
CAircraftModelList CContextSimulatorProxy::getInstalledModelsStartingWith(const QString modelString) const
|
||||
QStringList CContextSimulatorProxy::getModelSetStrings() const
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<BlackMisc::Simulation::CAircraftModelList>(QLatin1Literal("getInstalledModelsStartingWith"), modelString);
|
||||
return m_dBusInterface->callDBusRet<QStringList>(QLatin1Literal("getModelSetStrings"));
|
||||
}
|
||||
|
||||
int CContextSimulatorProxy::getInstalledModelsCount() const
|
||||
CAircraftModelList CContextSimulatorProxy::getModelSetModelsStartingWith(const QString modelString) const
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<int>(QLatin1Literal("getInstalledModelsCount"));
|
||||
return m_dBusInterface->callDBusRet<BlackMisc::Simulation::CAircraftModelList>(QLatin1Literal("getModelSetModelsStartingWith"), modelString);
|
||||
}
|
||||
|
||||
void CContextSimulatorProxy::reloadInstalledModels()
|
||||
int CContextSimulatorProxy::getModelSetCount() const
|
||||
{
|
||||
m_dBusInterface->callDBus(QLatin1Literal("reloadInstalledModels"));
|
||||
return m_dBusInterface->callDBusRet<int>(QLatin1Literal("getModelSetCount"));
|
||||
}
|
||||
|
||||
BlackMisc::Simulation::CSimulatorPluginInfo CContextSimulatorProxy::getSimulatorPluginInfo() const
|
||||
@@ -199,5 +200,20 @@ namespace BlackCore
|
||||
{
|
||||
m_dBusInterface->callDBus(QLatin1Literal("enableDebugMessages"), driver, interpolator);
|
||||
}
|
||||
|
||||
CStatusMessageList CContextSimulatorProxy::getMatchingMessages(const BlackMisc::Aviation::CCallsign &callsign) const
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<BlackMisc::CStatusMessageList>(QLatin1Literal("getMatchingMessages"), callsign);
|
||||
}
|
||||
|
||||
bool CContextSimulatorProxy::isMatchingMessagesEnabled() const
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<bool>(QLatin1Literal("isMatchingMessagesEnabled"));
|
||||
}
|
||||
|
||||
void CContextSimulatorProxy::enableMatchingMessages(bool enabled)
|
||||
{
|
||||
m_dBusInterface->callDBus(QLatin1Literal("enableMatchingMessages"), enabled);
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -51,86 +51,39 @@ namespace BlackCore
|
||||
~CContextSimulatorProxy() {}
|
||||
|
||||
public slots:
|
||||
//! \copydoc IContextSimulator::getSimulatorPluginInfo()
|
||||
//! \name Interface overrides
|
||||
//! @{
|
||||
virtual BlackMisc::Simulation::CSimulatorPluginInfo getSimulatorPluginInfo() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getAvailableSimulatorPlugins()
|
||||
virtual BlackMisc::Simulation::CSimulatorPluginInfoList getAvailableSimulatorPlugins() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::startSimulatorPlugin()
|
||||
virtual bool startSimulatorPlugin(const BlackMisc::Simulation::CSimulatorPluginInfo &simulatorInfo) override;
|
||||
|
||||
//! \copydoc IContextSimulator::stopSimulatorPlugin()
|
||||
virtual void stopSimulatorPlugin(const BlackMisc::Simulation::CSimulatorPluginInfo &simulatorInfo) override;
|
||||
|
||||
//! \copydoc IContextSimulator::getSimulatorStatus()
|
||||
virtual int getSimulatorStatus() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getAirportsInRange()
|
||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getInstalledModels()
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getInstalledModels() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getInstalledModelsStartingWith
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getInstalledModelsStartingWith(const QString modelString) const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getInstalledModelsCount
|
||||
virtual int getInstalledModelsCount() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::reloadInstalledModels
|
||||
virtual void reloadInstalledModels() override;
|
||||
|
||||
//! \copydoc IContextSimulator::getSimulatorSetup
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getModelSet() const override;
|
||||
virtual QStringList getModelSetStrings() const override;
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getModelSetModelsStartingWith(const QString modelString) const override;
|
||||
virtual int getModelSetCount() const override;
|
||||
virtual BlackMisc::Simulation::CSimulatorSetup getSimulatorSetup() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::setTimeSynchronization
|
||||
virtual bool setTimeSynchronization(bool enable, const BlackMisc::PhysicalQuantities::CTime &offset) override;
|
||||
|
||||
//! \copydoc IContextSimulator::isTimeSynchronized
|
||||
virtual bool isTimeSynchronized() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getMaxRenderedAircraft
|
||||
virtual int getMaxRenderedAircraft() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::setMaxRenderedAircraft
|
||||
virtual void setMaxRenderedAircraft(int number) override;
|
||||
|
||||
//! \copydoc IContextSimulator::setMaxRenderedDistance
|
||||
virtual void setMaxRenderedDistance(const BlackMisc::PhysicalQuantities::CLength &distance) override;
|
||||
|
||||
//! \copydoc IContextSimulator::setMaxRenderedDistance
|
||||
virtual void deleteAllRenderingRestrictions() override;
|
||||
|
||||
//! \copydoc IContextSimulator::isRenderingRestricted
|
||||
virtual bool isRenderingRestricted() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::isRenderingEnabled
|
||||
virtual bool isRenderingEnabled() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getMaxRenderedDistance
|
||||
virtual BlackMisc::PhysicalQuantities::CLength getMaxRenderedDistance() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getRenderedDistanceBoundary
|
||||
virtual BlackMisc::PhysicalQuantities::CLength getRenderedDistanceBoundary() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getRenderRestrictionText
|
||||
virtual QString getRenderRestrictionText() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getTimeSynchronizationOffset
|
||||
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::iconForModel
|
||||
virtual BlackMisc::CPixmap iconForModel(const QString &modelString) const override;
|
||||
|
||||
//! \copydoc IContextSimulator::highlightAircraft
|
||||
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) override;
|
||||
|
||||
//! \copydoc IContextSimulator::requestWeatherGrid
|
||||
virtual void requestWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid, const BlackMisc::CIdentifier &identifier) override;
|
||||
|
||||
//! \copydoc ISimulator::enableDebugMessages
|
||||
virtual void enableDebugMessages(bool driver, bool interpolator) override;
|
||||
virtual BlackMisc::CStatusMessageList getMatchingMessages(const BlackMisc::Aviation::CCallsign &callsign) const;
|
||||
virtual bool isMatchingMessagesEnabled() const;
|
||||
virtual void enableMatchingMessages(bool enabled);
|
||||
//! @}
|
||||
|
||||
private:
|
||||
BlackMisc::CGenericDBusInterface *m_dBusInterface;
|
||||
|
||||
Reference in New Issue
Block a user