mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 02:55:44 +08:00
Ref T566, added "short log" parameter
This commit is contained in:
committed by
Mat Sutcliffe
parent
1dd6a0852d
commit
859a418691
@@ -105,7 +105,7 @@ namespace BlackCore
|
|||||||
return code;
|
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
|
CAircraftModelList modelSet(m_modelSet); // Models for this matching
|
||||||
const CAircraftMatcherSetup setup = m_setup;
|
const CAircraftMatcherSetup setup = m_setup;
|
||||||
@@ -202,15 +202,15 @@ namespace BlackCore
|
|||||||
switch (setup.getMatchingAlgorithm())
|
switch (setup.getMatchingAlgorithm())
|
||||||
{
|
{
|
||||||
case CAircraftMatcherSetup::MatchingStepwiseReduce:
|
case CAircraftMatcherSetup::MatchingStepwiseReduce:
|
||||||
candidates = CAircraftMatcher::getClosestMatchStepwiseReduceImplementation(modelSet, setup, remoteAircraft, log);
|
candidates = CAircraftMatcher::getClosestMatchStepwiseReduceImplementation(modelSet, setup, m_categoryMatcher, remoteAircraft, shortLog, log);
|
||||||
break;
|
break;
|
||||||
case CAircraftMatcherSetup::MatchingScoreBased:
|
case CAircraftMatcherSetup::MatchingScoreBased:
|
||||||
candidates = CAircraftMatcher::getClosestMatchScoreImplementation(modelSet, setup, remoteAircraft, maxScore, log);
|
candidates = CAircraftMatcher::getClosestMatchScoreImplementation(modelSet, setup, remoteAircraft, maxScore, shortLog, log);
|
||||||
break;
|
break;
|
||||||
case CAircraftMatcherSetup::MatchingStepwiseReducePlusScoreBased:
|
case CAircraftMatcherSetup::MatchingStepwiseReducePlusScoreBased:
|
||||||
default:
|
default:
|
||||||
candidates = CAircraftMatcher::getClosestMatchStepwiseReduceImplementation(modelSet, setup, remoteAircraft, log);
|
candidates = CAircraftMatcher::getClosestMatchStepwiseReduceImplementation(modelSet, setup, m_categoryMatcher, remoteAircraft, shortLog, log);
|
||||||
candidates = CAircraftMatcher::getClosestMatchScoreImplementation(candidates, setup, remoteAircraft, maxScore, log);
|
candidates = CAircraftMatcher::getClosestMatchScoreImplementation(candidates, setup, remoteAircraft, maxScore, shortLog, log);
|
||||||
break;
|
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, QStringLiteral("Picking among %1 by strategy '%2'").arg(candidates.size()).arg(CAircraftMatcherSetup::strategyToString(usedStrategy)));
|
||||||
CMatchingUtils::addLogDetailsToList(log, remoteAircraft,
|
CMatchingUtils::addLogDetailsToList(log, remoteAircraft,
|
||||||
summary.arg(
|
summary.arg(
|
||||||
remoteAircraft.getAircraftIcaoCode().getCombinedType(), matchedModel.getAircraftIcaoCode().getCombinedType(),
|
remoteAircraft.getAircraftIcaoCode().getCombinedType(), matchedModel.getAircraftIcaoCode().getCombinedType(),
|
||||||
remoteAircraft.getAircraftIcaoCode().getDesignatorDbKey(), matchedModel.getAircraftIcaoCode().getDesignatorDbKey(),
|
remoteAircraft.getAircraftIcaoCode().getDesignatorDbKey(), matchedModel.getAircraftIcaoCode().getDesignatorDbKey(),
|
||||||
remoteAircraft.getAirlineIcaoCode().getVDesignatorDbKey(), matchedModel.getAirlineIcaoCode().getVDesignatorDbKey(),
|
remoteAircraft.getAirlineIcaoCode().getVDesignatorDbKey(), matchedModel.getAirlineIcaoCode().getVDesignatorDbKey(),
|
||||||
remoteAircraft.getLivery().getCombinedCodePlusInfoAndId(), matchedModel.getLivery().getCombinedCodePlusInfoAndId()
|
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)));
|
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);
|
CAircraftModelList matchedModels(modelSet);
|
||||||
CAircraftModel matchedModel(remoteAircraft.getModel());
|
CAircraftModel matchedModel(remoteAircraft.getModel());
|
||||||
|
Q_UNUSED(shortLog);
|
||||||
|
|
||||||
const CAircraftMatcherSetup::MatchingMode mode = setup.getMatchingMode();
|
const CAircraftMatcherSetup::MatchingMode mode = setup.getMatchingMode();
|
||||||
bool reduced = false;
|
bool reduced = false;
|
||||||
@@ -932,11 +933,12 @@ namespace BlackCore
|
|||||||
return matchedModels;
|
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();
|
CAircraftMatcherSetup::MatchingMode mode = setup.getMatchingMode();
|
||||||
const bool noZeroScores = mode.testFlag(CAircraftMatcherSetup::ScoreIgnoreZeros);
|
const bool noZeroScores = mode.testFlag(CAircraftMatcherSetup::ScoreIgnoreZeros);
|
||||||
const bool preferColorLiveries = mode.testFlag(CAircraftMatcherSetup::ScorePreferColorLiveries);
|
const bool preferColorLiveries = mode.testFlag(CAircraftMatcherSetup::ScorePreferColorLiveries);
|
||||||
|
Q_UNUSED(shortLog);
|
||||||
|
|
||||||
// VTOL
|
// VTOL
|
||||||
ScoredModels map;
|
ScoredModels map;
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ namespace BlackCore
|
|||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
BlackMisc::Simulation::CAircraftModel getClosestMatch(
|
BlackMisc::Simulation::CAircraftModel getClosestMatch(
|
||||||
const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft,
|
const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft,
|
||||||
|
bool shortLog,
|
||||||
BlackMisc::CStatusMessageList *log = nullptr) const;
|
BlackMisc::CStatusMessageList *log = nullptr) const;
|
||||||
|
|
||||||
//! Return an valid airline ICAO code
|
//! Return an valid airline ICAO code
|
||||||
@@ -226,10 +227,13 @@ namespace BlackCore
|
|||||||
bool saveDisabledForMatchingModels();
|
bool saveDisabledForMatchingModels();
|
||||||
|
|
||||||
//! The search based implementation
|
//! 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
|
//! 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"
|
//! 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
|
//! \see BlackMisc::Simulation::CSimulatedAircraft::getAircraftIcaoCombinedType
|
||||||
|
|||||||
@@ -586,9 +586,10 @@ namespace BlackCore
|
|||||||
// here we find the best simulator model for a resolved model
|
// here we find the best simulator model for a resolved model
|
||||||
// in the first step we already tried to find accurate ICAO codes etc.
|
// in the first step we already tried to find accurate ICAO codes etc.
|
||||||
// coming from CAirspaceMonitor::sendReadyForModelMatching
|
// coming from CAirspaceMonitor::sendReadyForModelMatching
|
||||||
|
bool shortLog = false;
|
||||||
CStatusMessageList matchingMessages;
|
CStatusMessageList matchingMessages;
|
||||||
CStatusMessageList *pMatchingMessages = m_enableMatchingMessages ? &matchingMessages : nullptr;
|
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");
|
Q_ASSERT_X(remoteAircraft.getCallsign() == aircraftModel.getCallsign(), Q_FUNC_INFO, "Mismatching callsigns");
|
||||||
const CLength cg = m_simulatorPlugin.second->getCGPerModelString(aircraftModel.getModelString());
|
const CLength cg = m_simulatorPlugin.second->getCGPerModelString(aircraftModel.getModelString());
|
||||||
if (!cg.isNull()) { aircraftModel.setCG(cg); }
|
if (!cg.isNull()) { aircraftModel.setCG(cg); }
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_matcher.setDefaultModel(CModelMatcherComponent::defaultModel());
|
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->te_Results->setText(matched.toQString(true));
|
||||||
ui->tvp_ResultMessages->updateContainer(msgs);
|
ui->tvp_ResultMessages->updateContainer(msgs);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user