mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-12 07:15:34 +08:00
Ref T566, configurable matching log in matcher/simulator components
* log flag/enum in own file * pass "what to log" as parameter
This commit is contained in:
committed by
Mat Sutcliffe
parent
991c7d59ef
commit
0d2e6dd997
@@ -11,16 +11,16 @@
|
||||
#ifndef BLACKCORE_CONTEXTSIMULATOR_H
|
||||
#define BLACKCORE_CONTEXTSIMULATOR_H
|
||||
|
||||
#include "blackconfig/buildconfig.h"
|
||||
#include "blackcore/blackcoreexport.h"
|
||||
#include "blackcore/context/context.h"
|
||||
#include "blackcore/corefacade.h"
|
||||
#include "blackcore/corefacadeconfig.h"
|
||||
#include "blackcore/simulator.h"
|
||||
#include "blackcore/blackcoreexport.h"
|
||||
#include "blackmisc/weather/weathergrid.h"
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include "blackmisc/simulation/aircraftmatchersetup.h"
|
||||
#include "blackmisc/simulation/matchingstatistics.h"
|
||||
#include "blackmisc/simulation/matchinglog.h"
|
||||
#include "blackmisc/simulation/simulatorplugininfo.h"
|
||||
#include "blackmisc/simulation/simulatorplugininfolist.h"
|
||||
#include "blackmisc/simulation/simulatorinternals.h"
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "blackmisc/pq/time.h"
|
||||
#include "blackmisc/identifier.h"
|
||||
#include "blackmisc/pixmap.h"
|
||||
#include "blackconfig/buildconfig.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
@@ -261,10 +262,10 @@ namespace BlackCore
|
||||
virtual BlackMisc::CStatusMessageList getMatchingMessages(const BlackMisc::Aviation::CCallsign &callsign) const = 0;
|
||||
|
||||
//! Enabled mapping logging?
|
||||
virtual bool isMatchingMessagesEnabled() const = 0;
|
||||
virtual BlackMisc::Simulation::MatchingLog isMatchingMessagesEnabled() const = 0;
|
||||
|
||||
//! Enable mapping logging
|
||||
virtual void enableMatchingMessages(bool enabled) = 0;
|
||||
virtual void enableMatchingMessages(BlackMisc::Simulation::MatchingLog enabled) = 0;
|
||||
|
||||
//! Highlight aircraft in simulator
|
||||
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) = 0;
|
||||
|
||||
@@ -349,17 +349,17 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::enableMatchingMessages
|
||||
virtual void enableMatchingMessages(bool enable) override
|
||||
virtual void enableMatchingMessages(BlackMisc::Simulation::MatchingLog enable) override
|
||||
{
|
||||
Q_UNUSED(enable);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::isMatchingMessagesEnabled
|
||||
virtual bool isMatchingMessagesEnabled() const override
|
||||
virtual BlackMisc::Simulation::MatchingLog isMatchingMessagesEnabled() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
return BlackMisc::Simulation::MatchingLogNothing;
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::parseCommandLine
|
||||
|
||||
@@ -70,7 +70,8 @@ namespace BlackCore
|
||||
CContextSimulator::registerHelp();
|
||||
|
||||
Q_ASSERT_X(sApp, Q_FUNC_INFO, "Need sApp");
|
||||
m_enableMatchingMessages = CBuildConfig::isLocalDeveloperDebugBuild(); // can be slow with huge model sets
|
||||
MatchingLog logMatchingMessages = CBuildConfig::isLocalDeveloperDebugBuild() ? MatchingLogAll : MatchingLogSimplified;
|
||||
m_logMatchingMessages = logMatchingMessages;
|
||||
m_plugins->collectPlugins();
|
||||
this->restoreSimulatorPlugins();
|
||||
|
||||
@@ -87,7 +88,7 @@ namespace BlackCore
|
||||
m_aircraftMatcher.setSetup(m_matchingSettings.get());
|
||||
if (m_aircraftMatcher.getModelSetCount() <= MatchingLogMaxModelSetSize)
|
||||
{
|
||||
this->enableMatchingMessages(true);
|
||||
this->enableMatchingMessages(logMatchingMessages);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -586,9 +587,9 @@ namespace BlackCore
|
||||
// here we find the best simulator model for a resolved model
|
||||
// in the first step we already tried to find accurate ICAO codes etc.
|
||||
// coming from CAirspaceMonitor::sendReadyForModelMatching
|
||||
CAircraftMatcher::MatchingLog whatToLog = CAircraftMatcher::LogAll;
|
||||
MatchingLog whatToLog = m_logMatchingMessages;
|
||||
CStatusMessageList matchingMessages;
|
||||
CStatusMessageList *pMatchingMessages = m_enableMatchingMessages ? &matchingMessages : nullptr;
|
||||
CStatusMessageList *pMatchingMessages = m_logMatchingMessages > 0 ? &matchingMessages : nullptr;
|
||||
CAircraftModel aircraftModel = m_aircraftMatcher.getClosestMatch(remoteAircraft, whatToLog, pMatchingMessages);
|
||||
Q_ASSERT_X(remoteAircraft.getCallsign() == aircraftModel.getCallsign(), Q_FUNC_INFO, "Mismatching callsigns");
|
||||
const CLength cg = m_simulatorPlugin.second->getCGPerModelString(aircraftModel.getModelString());
|
||||
@@ -837,17 +838,17 @@ namespace BlackCore
|
||||
return m_matchingMessages[callsign];
|
||||
}
|
||||
|
||||
bool CContextSimulator::isMatchingMessagesEnabled() const
|
||||
MatchingLog CContextSimulator::isMatchingMessagesEnabled() const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
return m_enableMatchingMessages;
|
||||
return m_logMatchingMessages;
|
||||
}
|
||||
|
||||
void CContextSimulator::enableMatchingMessages(bool enabled)
|
||||
void CContextSimulator::enableMatchingMessages(MatchingLog enabled)
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << enabled; }
|
||||
if (m_enableMatchingMessages == enabled) { return; }
|
||||
m_enableMatchingMessages = enabled;
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << matchingLogToString(enabled); }
|
||||
if (m_logMatchingMessages == enabled) { return; }
|
||||
m_logMatchingMessages = enabled;
|
||||
emit CContext::changedLogOrDebugSettings();
|
||||
}
|
||||
|
||||
@@ -1045,7 +1046,7 @@ namespace BlackCore
|
||||
this->loadSimulatorPlugin(info);
|
||||
|
||||
// if we have enabled messages, we will disable if size getting too high
|
||||
if (m_enableMatchingMessages)
|
||||
if (m_logMatchingMessages)
|
||||
{
|
||||
const QPointer<CContextSimulator> myself(this);
|
||||
QTimer::singleShot(5000, this, [ = ]
|
||||
@@ -1087,7 +1088,7 @@ namespace BlackCore
|
||||
{
|
||||
if (callsign.isEmpty()) { return; }
|
||||
if (messages.isEmpty()) { return; }
|
||||
if (!m_enableMatchingMessages) { return; }
|
||||
if (!m_logMatchingMessages) { return; }
|
||||
if (m_matchingMessages.contains(callsign))
|
||||
{
|
||||
CStatusMessageList &msgs = m_matchingMessages[callsign];
|
||||
|
||||
@@ -117,8 +117,8 @@ namespace BlackCore
|
||||
virtual int doMatchingsAgain() override;
|
||||
virtual bool doMatchingAgain(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
virtual BlackMisc::CStatusMessageList getMatchingMessages(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||
virtual bool isMatchingMessagesEnabled() const override;
|
||||
virtual void enableMatchingMessages(bool enabled) override;
|
||||
virtual BlackMisc::Simulation::MatchingLog isMatchingMessagesEnabled() const override;
|
||||
virtual void enableMatchingMessages(BlackMisc::Simulation::MatchingLog enabled) override;
|
||||
virtual BlackMisc::Simulation::CMatchingStatistics getCurrentMatchingStatistics(bool missingOnly) const override;
|
||||
virtual void setMatchingSetup(const BlackMisc::Simulation::CAircraftMatcherSetup &setup) override;
|
||||
virtual BlackMisc::Simulation::CAircraftMatcherSetup getMatchingSetup() const override;
|
||||
@@ -267,8 +267,8 @@ namespace BlackCore
|
||||
|
||||
bool m_wasSimulating = false;
|
||||
bool m_initallyAddAircraft = false;
|
||||
bool m_enableMatchingMessages = true;
|
||||
bool m_isWeatherActivated = false; // used to activate after plugin is loaded
|
||||
BlackMisc::Simulation::MatchingLog m_logMatchingMessages = BlackMisc::Simulation::MatchingLogSimplified;
|
||||
|
||||
QString m_networkSessionId; //!< Network session of CServer::getServerSessionId, if not connected empty (for statistics, ..)
|
||||
BlackMisc::Simulation::CBackgroundValidation *m_validator = nullptr;
|
||||
|
||||
@@ -307,12 +307,14 @@ namespace BlackCore
|
||||
return m_dBusInterface->callDBusRet<BlackMisc::CStatusMessageList>(QLatin1String("getMatchingMessages"), callsign);
|
||||
}
|
||||
|
||||
bool CContextSimulatorProxy::isMatchingMessagesEnabled() const
|
||||
MatchingLog CContextSimulatorProxy::isMatchingMessagesEnabled() const
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<bool>(QLatin1String("isMatchingMessagesEnabled"));
|
||||
//! \fixme KB 2019-04 directly return MatchingLog causes issues with QDbusArgument
|
||||
const int r = m_dBusInterface->callDBusRet<int>(QLatin1String("isMatchingMessagesEnabled"));
|
||||
return static_cast<MatchingLog>(r);
|
||||
}
|
||||
|
||||
void CContextSimulatorProxy::enableMatchingMessages(bool enabled)
|
||||
void CContextSimulatorProxy::enableMatchingMessages(MatchingLog enabled)
|
||||
{
|
||||
m_dBusInterface->callDBus(QLatin1String("enableMatchingMessages"), enabled);
|
||||
}
|
||||
|
||||
@@ -98,8 +98,8 @@ namespace BlackCore
|
||||
virtual void setWeatherActivated(bool activated) override;
|
||||
virtual void requestWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid, const BlackMisc::CIdentifier &identifier) override;
|
||||
virtual BlackMisc::CStatusMessageList getMatchingMessages(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||
virtual bool isMatchingMessagesEnabled() const override;
|
||||
virtual void enableMatchingMessages(bool enabled) override;
|
||||
virtual BlackMisc::Simulation::MatchingLog isMatchingMessagesEnabled() const override;
|
||||
virtual void enableMatchingMessages(BlackMisc::Simulation::MatchingLog enabled) override;
|
||||
virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override;
|
||||
virtual int doMatchingsAgain() override;
|
||||
virtual bool doMatchingAgain(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
|
||||
Reference in New Issue
Block a user