From 859a4186913f5674e1369d2f4f575734ab210ccd Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 8 Mar 2019 00:44:20 +0100 Subject: [PATCH] Ref T566, added "short log" parameter --- src/blackcore/aircraftmatcher.cpp | 18 ++++++++++-------- src/blackcore/aircraftmatcher.h | 8 ++++++-- src/blackcore/context/contextsimulatorimpl.cpp | 3 ++- .../components/modelmatchercomponent.cpp | 2 +- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/blackcore/aircraftmatcher.cpp b/src/blackcore/aircraftmatcher.cpp index 5be0c23ef..cad4f1b8f 100644 --- a/src/blackcore/aircraftmatcher.cpp +++ b/src/blackcore/aircraftmatcher.cpp @@ -105,7 +105,7 @@ namespace BlackCore return code; } - CAircraftModel CAircraftMatcher::getClosestMatch(const CSimulatedAircraft &remoteAircraft, CStatusMessageList *log) const + CAircraftModel CAircraftMatcher::getClosestMatch(const CSimulatedAircraft &remoteAircraft, bool shortLog, CStatusMessageList *log) const { CAircraftModelList modelSet(m_modelSet); // Models for this matching const CAircraftMatcherSetup setup = m_setup; @@ -202,15 +202,15 @@ namespace BlackCore switch (setup.getMatchingAlgorithm()) { case CAircraftMatcherSetup::MatchingStepwiseReduce: - candidates = CAircraftMatcher::getClosestMatchStepwiseReduceImplementation(modelSet, setup, remoteAircraft, log); + candidates = CAircraftMatcher::getClosestMatchStepwiseReduceImplementation(modelSet, setup, m_categoryMatcher, remoteAircraft, shortLog, log); break; case CAircraftMatcherSetup::MatchingScoreBased: - candidates = CAircraftMatcher::getClosestMatchScoreImplementation(modelSet, setup, remoteAircraft, maxScore, log); + candidates = CAircraftMatcher::getClosestMatchScoreImplementation(modelSet, setup, remoteAircraft, maxScore, shortLog, log); break; case CAircraftMatcherSetup::MatchingStepwiseReducePlusScoreBased: default: - candidates = CAircraftMatcher::getClosestMatchStepwiseReduceImplementation(modelSet, setup, remoteAircraft, log); - candidates = CAircraftMatcher::getClosestMatchScoreImplementation(candidates, setup, remoteAircraft, maxScore, log); + candidates = CAircraftMatcher::getClosestMatchStepwiseReduceImplementation(modelSet, setup, m_categoryMatcher, remoteAircraft, shortLog, log); + candidates = CAircraftMatcher::getClosestMatchScoreImplementation(candidates, setup, remoteAircraft, maxScore, shortLog, log); break; } @@ -245,7 +245,7 @@ namespace BlackCore CMatchingUtils::addLogDetailsToList(log, remoteAircraft, QStringLiteral("Picking among %1 by strategy '%2'").arg(candidates.size()).arg(CAircraftMatcherSetup::strategyToString(usedStrategy))); CMatchingUtils::addLogDetailsToList(log, remoteAircraft, summary.arg( - remoteAircraft.getAircraftIcaoCode().getCombinedType(), matchedModel.getAircraftIcaoCode().getCombinedType(), + remoteAircraft.getAircraftIcaoCode().getCombinedType(), matchedModel.getAircraftIcaoCode().getCombinedType(), remoteAircraft.getAircraftIcaoCode().getDesignatorDbKey(), matchedModel.getAircraftIcaoCode().getDesignatorDbKey(), remoteAircraft.getAirlineIcaoCode().getVDesignatorDbKey(), matchedModel.getAirlineIcaoCode().getVDesignatorDbKey(), remoteAircraft.getLivery().getCombinedCodePlusInfoAndId(), matchedModel.getLivery().getCombinedCodePlusInfoAndId() @@ -848,10 +848,11 @@ namespace BlackCore return CFileUtils::writeStringToFile(json, CFileUtils::appendFilePathsAndFixUnc(CDirectoryUtils::logDirectory(), QStringLiteral("removed models %1.json").arg(ts))); } - CAircraftModelList CAircraftMatcher::getClosestMatchStepwiseReduceImplementation(const CAircraftModelList &modelSet, const CAircraftMatcherSetup &setup, const CSimulatedAircraft &remoteAircraft, CStatusMessageList *log) + CAircraftModelList CAircraftMatcher::getClosestMatchStepwiseReduceImplementation(const CAircraftModelList &modelSet, const CAircraftMatcherSetup &setup, const CCategoryMatcher &categoryMatcher, const CSimulatedAircraft &remoteAircraft, bool shortLog, CStatusMessageList *log) { CAircraftModelList matchedModels(modelSet); CAircraftModel matchedModel(remoteAircraft.getModel()); + Q_UNUSED(shortLog); const CAircraftMatcherSetup::MatchingMode mode = setup.getMatchingMode(); bool reduced = false; @@ -932,11 +933,12 @@ namespace BlackCore return matchedModels; } - CAircraftModelList CAircraftMatcher::getClosestMatchScoreImplementation(const CAircraftModelList &modelSet, const CAircraftMatcherSetup &setup, const CSimulatedAircraft &remoteAircraft, int &maxScore, CStatusMessageList *log) + CAircraftModelList CAircraftMatcher::getClosestMatchScoreImplementation(const CAircraftModelList &modelSet, const CAircraftMatcherSetup &setup, const CSimulatedAircraft &remoteAircraft, int &maxScore, bool shortLog, CStatusMessageList *log) { CAircraftMatcherSetup::MatchingMode mode = setup.getMatchingMode(); const bool noZeroScores = mode.testFlag(CAircraftMatcherSetup::ScoreIgnoreZeros); const bool preferColorLiveries = mode.testFlag(CAircraftMatcherSetup::ScorePreferColorLiveries); + Q_UNUSED(shortLog); // VTOL ScoredModels map; diff --git a/src/blackcore/aircraftmatcher.h b/src/blackcore/aircraftmatcher.h index 9f67139ca..963d92da2 100644 --- a/src/blackcore/aircraftmatcher.h +++ b/src/blackcore/aircraftmatcher.h @@ -69,6 +69,7 @@ namespace BlackCore //! \threadsafe BlackMisc::Simulation::CAircraftModel getClosestMatch( const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft, + bool shortLog, BlackMisc::CStatusMessageList *log = nullptr) const; //! Return an valid airline ICAO code @@ -226,10 +227,13 @@ namespace BlackCore bool saveDisabledForMatchingModels(); //! The search based implementation - static BlackMisc::Simulation::CAircraftModelList getClosestMatchStepwiseReduceImplementation(const BlackMisc::Simulation::CAircraftModelList &modelSet, const BlackMisc::Simulation::CAircraftMatcherSetup &setup, const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft, BlackMisc::CStatusMessageList *log = nullptr); + static BlackMisc::Simulation::CAircraftModelList getClosestMatchStepwiseReduceImplementation( + const BlackMisc::Simulation::CAircraftModelList &modelSet, const BlackMisc::Simulation::CAircraftMatcherSetup &setup, + const BlackMisc::Simulation::CCategoryMatcher &categoryMatcher, const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft, + bool shortLog, BlackMisc::CStatusMessageList *log = nullptr); //! The score based implementation - static BlackMisc::Simulation::CAircraftModelList getClosestMatchScoreImplementation(const BlackMisc::Simulation::CAircraftModelList &modelSet, const BlackMisc::Simulation::CAircraftMatcherSetup &setup, const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft, int &maxScore, BlackMisc::CStatusMessageList *log = nullptr); + static BlackMisc::Simulation::CAircraftModelList getClosestMatchScoreImplementation(const BlackMisc::Simulation::CAircraftModelList &modelSet, const BlackMisc::Simulation::CAircraftMatcherSetup &setup, const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft, int &maxScore, bool shortLog, BlackMisc::CStatusMessageList *log = nullptr); //! Get combined type default model, i.e. get a default model under consideration of the combined code such as "L2J" //! \see BlackMisc::Simulation::CSimulatedAircraft::getAircraftIcaoCombinedType diff --git a/src/blackcore/context/contextsimulatorimpl.cpp b/src/blackcore/context/contextsimulatorimpl.cpp index 14e8aa32b..286af24a7 100644 --- a/src/blackcore/context/contextsimulatorimpl.cpp +++ b/src/blackcore/context/contextsimulatorimpl.cpp @@ -586,9 +586,10 @@ 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 + bool shortLog = false; CStatusMessageList matchingMessages; CStatusMessageList *pMatchingMessages = m_enableMatchingMessages ? &matchingMessages : nullptr; - CAircraftModel aircraftModel = m_aircraftMatcher.getClosestMatch(remoteAircraft, pMatchingMessages); + CAircraftModel aircraftModel = m_aircraftMatcher.getClosestMatch(remoteAircraft, shortLog, pMatchingMessages); Q_ASSERT_X(remoteAircraft.getCallsign() == aircraftModel.getCallsign(), Q_FUNC_INFO, "Mismatching callsigns"); const CLength cg = m_simulatorPlugin.second->getCGPerModelString(aircraftModel.getModelString()); if (!cg.isNull()) { aircraftModel.setCG(cg); } diff --git a/src/blackgui/components/modelmatchercomponent.cpp b/src/blackgui/components/modelmatchercomponent.cpp index 437c0c393..9370e21af 100644 --- a/src/blackgui/components/modelmatchercomponent.cpp +++ b/src/blackgui/components/modelmatchercomponent.cpp @@ -122,7 +122,7 @@ namespace BlackGui } m_matcher.setDefaultModel(CModelMatcherComponent::defaultModel()); - const CAircraftModel matched = m_matcher.getClosestMatch(remoteAircraft, &msgs); // test model matching + const CAircraftModel matched = m_matcher.getClosestMatch(remoteAircraft, false, &msgs); // test model matching ui->te_Results->setText(matched.toQString(true)); ui->tvp_ResultMessages->updateContainer(msgs); }