From 53d637acb007a4d9296615fa4962dd0ce71fd323 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 11 Jul 2019 21:00:58 +0200 Subject: [PATCH] Ref T701, use modelset and improved matcher functions in airspace monitor --- src/blackcore/airspacemonitor.cpp | 42 ++++++++++++++++++++----------- src/blackcore/airspacemonitor.h | 9 +++++-- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/blackcore/airspacemonitor.cpp b/src/blackcore/airspacemonitor.cpp index d2d3d6805..8128836ac 100644 --- a/src/blackcore/airspacemonitor.cpp +++ b/src/blackcore/airspacemonitor.cpp @@ -65,9 +65,10 @@ using namespace BlackCore::Vatsim; namespace BlackCore { - CAirspaceMonitor::CAirspaceMonitor(IOwnAircraftProvider *ownAircraftProvider, INetwork *network, QObject *parent) + CAirspaceMonitor::CAirspaceMonitor(IOwnAircraftProvider *ownAircraftProvider, IAircraftModelSetProvider *modelSetProvider, INetwork *network, QObject *parent) : CRemoteAircraftProvider(parent), COwnAircraftAware(ownAircraftProvider), + CAircraftModelSetAware(modelSetProvider), m_network(network), m_analyzer(new CAirspaceAnalyzer(ownAircraftProvider, network, this)) { @@ -168,10 +169,10 @@ namespace BlackCore m_flightPlanCache.remove(callsign); m_network->sendFlightPlanQuery(callsign); - // with this little trick we try to make an asynchronous signal / slot - // based approach a synchronous return value + // with this little trick we try to make an asynchronous signal / slot based approach + // a synchronous return value const QTime waitForFlightPlan = QTime::currentTime().addMSecs(1500); - while (sApp && QTime::currentTime() < waitForFlightPlan) + while (sApp && !sApp->isShuttingDown() && QTime::currentTime() < waitForFlightPlan) { // process some other events and hope network answer is received already // CEventLoop::processEventsUntil cannot be used, as a received flight plan might be for another callsign @@ -539,7 +540,7 @@ namespace BlackCore // some checks for special conditions, e.g. logout -> empty list, but still signals pending if (validCs) { - static const QString readyForMatching("Ready for matching '%1' with model type '%2'"); + static const QString readyForMatching("Ready for matching callsign '%1' with model type '%2'"); const QString readyMsg = readyForMatching.arg(callsign.toQString(), remoteAircraft.getModel().getModelTypeAsString()); const CStatusMessage m = CMatchingUtils::logMessage(callsign, readyMsg, getLogCategories()); this->addReverseLookupMessage(callsign, m); @@ -752,6 +753,9 @@ namespace BlackCore const QString &airlineIcaoString, const QString &liveryString, const QString &modelString, CAircraftModel::ModelType type, CStatusMessageList *log, bool runMatchinScript) { + const int modelSetCount = this->getModelSetCount(); + CMatchingUtils::addLogDetailsToList(log, callsign, QStringLiteral("Reverse lookup (with FP data) model set: %1").arg(modelSetCount), CAirspaceMonitor::getLogCategories()); + const DBTripleIds ids = CAircraftModel::parseNetworkLiveryString(liveryString); const bool hasAnyId = ids.hasAnyId(); if (hasAnyId) { this->markAsSwiftClient(callsign); } @@ -819,23 +823,31 @@ namespace BlackCore CMatchingUtils::addLogDetailsToList(log, callsign, QStringLiteral("FP rem.parsed: '%1'").arg(fpRemarks.toQString(true))); } - airlineIcao = CAircraftMatcher::failoverValidAirlineIcaoDesignator(callsign, airlineIcaoString, fpRemarks.getAirlineIcao().getDesignator(), true, true, log); + + // FP data if any + const QString telephonyFromFp = CAircraftMatcher::reverseLookupTelephonyDesignator(fpRemarks.getRadioTelephony(), callsign, log); + const QString airlineNameFromFp = CAircraftMatcher::reverseLookupAirlineName(fpRemarks.getFlightOperator(), callsign, log); + const QString airlineIcaoFromFp = fpRemarks.getAirlineIcao().getDesignator(); + + // INFO: CModelMatcherComponent::reverseLookup() contains the simulated lookup + // version without model set, changed with T701 + // airlineIcao = CAircraftMatcher::failoverValidAirlineIcaoDesignator(callsign, airlineIcaoString, fpRemarks.getAirlineIcao().getDesignator(), true, true, log); + + airlineIcao = CAircraftMatcher::failoverValidAirlineIcaoDesignatorModelsFirst(callsign, airlineIcaoString, airlineIcaoFromFp, true, airlineNameFromFp, telephonyFromFp, this->getModelSet(), log); if (!airlineIcao.isLoadedFromDb() && fpRemarks.hasParsedAirlineRemarks()) { - const QString airlineName = CAircraftMatcher::reverseLookupAirlineName(fpRemarks.getFlightOperator(), callsign, log); - if (!airlineName.isEmpty()) + if (!airlineNameFromFp.isEmpty()) { - const QString resolvedAirlineName = CAircraftMatcher::reverseLookupAirlineName(airlineName); + const QString resolvedAirlineName = CAircraftMatcher::reverseLookupAirlineName(airlineNameFromFp); airlineIcao.setName(resolvedAirlineName); - CMatchingUtils::addLogDetailsToList(log, callsign, QStringLiteral("Setting resolved airline name '%1' from '%2'").arg(resolvedAirlineName, airlineName), CAirspaceMonitor::getLogCategories()); + CMatchingUtils::addLogDetailsToList(log, callsign, QStringLiteral("Setting resolved airline name '%1' from '%2'").arg(resolvedAirlineName, airlineNameFromFp), CAirspaceMonitor::getLogCategories()); } - const QString telephony = CAircraftMatcher::reverseLookupTelephonyDesignator(fpRemarks.getRadioTelephony(), callsign, log); - if (!telephony.isEmpty()) + if (!telephonyFromFp.isEmpty()) { - const QString resolvedTelephony = CAircraftMatcher::reverseLookupTelephonyDesignator(telephony); + const QString resolvedTelephony = CAircraftMatcher::reverseLookupTelephonyDesignator(telephonyFromFp); airlineIcao.setTelephonyDesignator(resolvedTelephony); - CMatchingUtils::addLogDetailsToList(log, callsign, QStringLiteral("Setting resolved telephony designator '%1' from '%2'").arg(resolvedTelephony, telephony), CAirspaceMonitor::getLogCategories()); + CMatchingUtils::addLogDetailsToList(log, callsign, QStringLiteral("Setting resolved telephony designator '%1' from '%2'").arg(resolvedTelephony, telephonyFromFp), CAirspaceMonitor::getLogCategories()); } } @@ -848,6 +860,8 @@ namespace BlackCore CMatchingUtils::addLogDetailsToList(log, callsign, QStringLiteral("Used aircraft ICAO: '%1'").arg(aircraftIcao.toQString(true)), CAirspaceMonitor::getLogCategories()); CMatchingUtils::addLogDetailsToList(log, callsign, QStringLiteral("Used airline ICAO: '%1'").arg(airlineIcao.toQString(true)), CAirspaceMonitor::getLogCategories()); + + // matching script is used below lookupModel = CAircraftMatcher::reverseLookupModel(callsign, aircraftIcao, airlineIcao, liveryString, modelString, setup, type, log); } while (false); diff --git a/src/blackcore/airspacemonitor.h b/src/blackcore/airspacemonitor.h index 3d37b2df4..38f311b78 100644 --- a/src/blackcore/airspacemonitor.h +++ b/src/blackcore/airspacemonitor.h @@ -14,6 +14,7 @@ #include "blackcore/network.h" #include "blackcore/blackcoreexport.h" #include "blackmisc/simulation/settings/modelmatchersettings.h" +#include "blackmisc/simulation/aircraftmodelsetprovider.h" #include "blackmisc/simulation/aircraftmodel.h" #include "blackmisc/simulation/airspaceaircraftsnapshot.h" #include "blackmisc/simulation/matchinglog.h" @@ -55,9 +56,10 @@ namespace BlackCore //! Central instance of data for \sa IRemoteAircraftProvider. class BLACKCORE_EXPORT CAirspaceMonitor : public BlackMisc::Simulation::CRemoteAircraftProvider, // those data will be provided from the class CAirspaceMonitor + public BlackMisc::Network::CClientProvider, // those data will be provided from the class CAirspaceMonitor public BlackMisc::Simulation::COwnAircraftAware, // used to obtain in memory information about own aircraft public BlackMisc::Simulation::CSimulationEnvironmentAware, // elevation info etc. from simulator - public BlackMisc::Network::CClientProvider // those data will be provided from the class CAirspaceMonitor + public BlackMisc::Simulation::CAircraftModelSetAware // model set for reverse lookup { // CRemoteAircraftProvider is QObject Q_OBJECT @@ -69,7 +71,10 @@ namespace BlackCore static const BlackMisc::CLogCategoryList &getLogCategories(); //! Constructor - CAirspaceMonitor(BlackMisc::Simulation::IOwnAircraftProvider *ownAircraft, INetwork *network, QObject *parent); + CAirspaceMonitor(BlackMisc::Simulation::IOwnAircraftProvider *ownAircraft, + BlackMisc::Simulation::IAircraftModelSetProvider *modelSetProvider, + INetwork *network, + QObject *parent); //! Members not implenented or fully implenented by CRemoteAircraftProvider //! \ingroup remoteaircraftprovider