mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 19:35:32 +08:00
refs #827, moved matching utilities to blackmisc so it can be used also with score functions in blackmisc
This commit is contained in:
committed by
Mathew Sutcliffe
parent
5323491eb9
commit
8d198a9174
@@ -8,9 +8,10 @@
|
||||
*/
|
||||
|
||||
#include "blackcore/aircraftmatcher.h"
|
||||
#include "blackcore/matchingutils.h"
|
||||
#include "blackcore/application.h"
|
||||
#include "blackcore/webdataservices.h"
|
||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
||||
#include "blackmisc/simulation/matchingutils.h"
|
||||
#include "blackmisc/aviation/aircrafticaocode.h"
|
||||
#include "blackmisc/aviation/airlineicaocode.h"
|
||||
#include "blackmisc/aviation/callsign.h"
|
||||
@@ -18,7 +19,6 @@
|
||||
#include "blackmisc/logcategory.h"
|
||||
#include "blackmisc/logcategorylist.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
|
||||
#include <QList>
|
||||
@@ -30,7 +30,6 @@ using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackCore;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
@@ -54,7 +53,7 @@ namespace BlackCore
|
||||
const MatchingMode mode = this->m_matchingMode;
|
||||
|
||||
static const QString format("hh:mm:ss.zzz");
|
||||
CMatchingUtils::addLogDetailsToList(log, remoteAircraft, QString("--- Matching: %1 ---").arg(QDateTime::currentDateTimeUtc().toString(format)));
|
||||
CMatchingUtils::addLogDetailsToList(log, remoteAircraft, QString("--- Matching: UTC %1 ---").arg(QDateTime::currentDateTimeUtc().toString(format)));
|
||||
CMatchingUtils::addLogDetailsToList(log, remoteAircraft, QString("Matching uses model set of %1 models").arg(modelSet.size()), getLogCategories());
|
||||
CMatchingUtils::addLogDetailsToList(log, remoteAircraft, QString("Input model: '%1' '%2'").arg(remoteAircraft.getCallsignAsString(), remoteAircraft.getModel().toQString()), getLogCategories());
|
||||
|
||||
@@ -111,7 +110,7 @@ namespace BlackCore
|
||||
Q_ASSERT_X(matchedModel.hasModelString(), Q_FUNC_INFO, "Missing model string");
|
||||
Q_ASSERT_X(matchedModel.getModelType() != CAircraftModel::TypeUnknown, Q_FUNC_INFO, "Missing model type");
|
||||
|
||||
CMatchingUtils::addLogDetailsToList(log, remoteAircraft, QString("--- Matching end: %1 ---").arg(QDateTime::currentDateTimeUtc().toString(format)));
|
||||
CMatchingUtils::addLogDetailsToList(log, remoteAircraft, QString("--- Matching end: UTC %1 ---").arg(QDateTime::currentDateTimeUtc().toString(format)));
|
||||
return matchedModel;
|
||||
}
|
||||
|
||||
@@ -558,14 +557,16 @@ namespace BlackCore
|
||||
// first decide what set to use for scoring, it should not be too large
|
||||
if (remoteAircraft.hasAircraftAndAirlineDesignator() && usedModelSet.containsModelsWithAircraftAndAirlineIcaoDesignator(remoteAircraft.getAircraftIcaoCodeDesignator(), remoteAircraft.getAirlineIcaoCodeDesignator()))
|
||||
{
|
||||
// Aircraft and airline ICAO
|
||||
const CAircraftModelList byAircraftAndAirline(usedModelSet.findByIcaoDesignators(remoteAircraft.getAircraftIcaoCode(), remoteAircraft.getAirlineIcaoCode()));
|
||||
CMatchingUtils::addLogDetailsToList(log, remoteAircraft, QString("Using reduced set of %1 models by aircraft/airline ICAOs '%2'/'%3' for scoring").arg(byAircraftAndAirline.size()).arg(remoteAircraft.getAircraftIcaoCode().getDesignatorDbKey(), remoteAircraft.getAirlineIcaoCode().getVDesignatorDbKey()), getLogCategories());
|
||||
map = byAircraftAndAirline.scoreFull(remoteAircraft.getModel());
|
||||
}
|
||||
else if (remoteAircraft.hasAircraftDesignator() && usedModelSet.contains(&CAircraftModel::getAircraftIcaoCodeDesignator, remoteAircraft.getAircraftIcaoCodeDesignator()))
|
||||
{
|
||||
// Aircraft ICAO only
|
||||
const CAircraftModelList byAircraft(usedModelSet.findByIcaoDesignators(remoteAircraft.getAircraftIcaoCode(), CAirlineIcaoCode()));
|
||||
CMatchingUtils::addLogDetailsToList(log, remoteAircraft, QString("Using reduced set of %1 models by aircraft ICAO '%2' for scoring").arg(byAircraft.size()).arg(remoteAircraft.getAircraftIcaoCode().getDesignatorDbKey()), getLogCategories());
|
||||
CMatchingUtils::addLogDetailsToList(log, remoteAircraft, QString("Using reduced set of %1 models by aircraft ICAO '%2' (no airline) for scoring").arg(byAircraft.size()).arg(remoteAircraft.getAircraftIcaoCode().getDesignatorDbKey()), getLogCategories());
|
||||
map = byAircraft.scoreFull(remoteAircraft.getModel());
|
||||
}
|
||||
else if (remoteAircraft.getAircraftIcaoCode().hasValidCombinedType() && usedModelSet.containsCombinedType(remoteAircraft.getAircraftIcaoCode().getCombinedType()))
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
#include "blackcore/airspaceanalyzer.h"
|
||||
#include "blackcore/airspacemonitor.h"
|
||||
#include "blackcore/aircraftmatcher.h"
|
||||
#include "blackcore/matchingutils.h"
|
||||
#include "blackcore/application.h"
|
||||
#include "blackcore/vatsim/networkvatlib.h"
|
||||
#include "blackcore/vatsim/vatsimbookingreader.h"
|
||||
#include "blackcore/vatsim/vatsimdatafilereader.h"
|
||||
#include "blackcore/webdataservices.h"
|
||||
#include "blackmisc/audio/voiceroom.h"
|
||||
#include "blackmisc/simulation/matchingutils.h"
|
||||
#include "blackmisc/aviation/aircraftparts.h"
|
||||
#include "blackmisc/aviation/aircraftsituation.h"
|
||||
#include "blackmisc/aviation/comsystem.h"
|
||||
|
||||
@@ -14,11 +14,10 @@
|
||||
#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/verify.h"
|
||||
#include "blackmisc/simulation/matchingutils.h"
|
||||
#include "blackmisc/aviation/callsign.h"
|
||||
#include "blackmisc/compare.h"
|
||||
#include "blackmisc/dbusserver.h"
|
||||
@@ -30,6 +29,7 @@
|
||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include "blackmisc/threadutils.h"
|
||||
#include "blackmisc/verify.h"
|
||||
|
||||
#include <QMetaObject>
|
||||
#include <QStringList>
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
/* Copyright (C) 2016
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "blackcore/matchingutils.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackCore;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
void CMatchingUtils::addLogDetailsToList(CStatusMessageList *log, const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft, const QString &message, const CLogCategoryList &categories, CStatusMessage::StatusSeverity s)
|
||||
{
|
||||
CMatchingUtils::addLogDetailsToList(log, remoteAircraft.getCallsign(), message, categories, s);
|
||||
}
|
||||
|
||||
void CMatchingUtils::addLogDetailsToList(CStatusMessageList *log, const BlackMisc::Aviation::CCallsign &callsign, const QString &message, const CLogCategoryList &categories, CStatusMessage::StatusSeverity s)
|
||||
{
|
||||
if (!log) { return; }
|
||||
if (message.isEmpty()) { return; }
|
||||
log->push_back(CMatchingUtils::logMessage(callsign, message, categories, s));
|
||||
}
|
||||
|
||||
CStatusMessage CMatchingUtils::logMessage(const BlackMisc::Aviation::CCallsign &callsign, const QString &message, const CLogCategoryList &categories, CStatusMessage::StatusSeverity s)
|
||||
{
|
||||
const CStatusMessage m(categories, s, callsign.isEmpty() ? callsign.toQString() + ": " + message.trimmed() : message.trimmed());
|
||||
return m;
|
||||
}
|
||||
} // namespace
|
||||
@@ -1,51 +0,0 @@
|
||||
/* Copyright (C) 2016
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKCORE_MATCHINGUTILS_H
|
||||
#define BLACKCORE_MATCHINGUTILS_H
|
||||
|
||||
#include "blackcore/blackcoreexport.h"
|
||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
/*!
|
||||
* Matching utils
|
||||
*/
|
||||
class BLACKCORE_EXPORT CMatchingUtils
|
||||
{
|
||||
public:
|
||||
//! Specialized log for matching / reverse lookup
|
||||
//! \threadsafe
|
||||
static void addLogDetailsToList(
|
||||
BlackMisc::CStatusMessageList *log, const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft,
|
||||
const QString &message, const BlackMisc::CLogCategoryList &categories = {},
|
||||
BlackMisc::CStatusMessage::StatusSeverity s = BlackMisc::CStatusMessage::SeverityInfo);
|
||||
|
||||
//! Specialized log for matching / reverse lookup
|
||||
//! \threadsafe
|
||||
static void addLogDetailsToList(
|
||||
BlackMisc::CStatusMessageList *log, const BlackMisc::Aviation::CCallsign &callsign,
|
||||
const QString &message, const BlackMisc::CLogCategoryList &categories = {},
|
||||
BlackMisc::CStatusMessage::StatusSeverity s = BlackMisc::CStatusMessage::SeverityInfo);
|
||||
|
||||
|
||||
//! Specialized log message for matching / reverse lookup
|
||||
//! \threadsafe
|
||||
static BlackMisc::CStatusMessage logMessage(
|
||||
const BlackMisc::Aviation::CCallsign &callsign,
|
||||
const QString &message, const BlackMisc::CLogCategoryList &categories = {},
|
||||
BlackMisc::CStatusMessage::StatusSeverity s = BlackMisc::CStatusMessage::SeverityInfo);
|
||||
};
|
||||
} // namespace
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user