mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 11:25:33 +08:00
Ref T524, use pseudo family in matcher
This commit is contained in:
committed by
Mat Sutcliffe
parent
509a60d06f
commit
49b89ab0a4
@@ -874,7 +874,7 @@ namespace BlackCore
|
|||||||
if (mode.testFlag(CAircraftMatcherSetup::ByFamily))
|
if (mode.testFlag(CAircraftMatcherSetup::ByFamily))
|
||||||
{
|
{
|
||||||
QString usedFamily;
|
QString usedFamily;
|
||||||
matchedModels = ifPossibleReduceByFamily(remoteAircraft, matchedModels, reduced, usedFamily, log);
|
matchedModels = ifPossibleReduceByFamily(remoteAircraft, UsePseudoFamily, matchedModels, reduced, usedFamily, log);
|
||||||
if (reduced) { break; }
|
if (reduced) { break; }
|
||||||
}
|
}
|
||||||
else if (log)
|
else if (log)
|
||||||
@@ -1045,7 +1045,7 @@ namespace BlackCore
|
|||||||
bool r1 = false;
|
bool r1 = false;
|
||||||
bool r2 = false;
|
bool r2 = false;
|
||||||
CAircraftModelList models = ifPossibleReduceByAirline(remoteAircraft, inList, QStringLiteral("Reduce by airline first."), r1, log);
|
CAircraftModelList models = ifPossibleReduceByAirline(remoteAircraft, inList, QStringLiteral("Reduce by airline first."), r1, log);
|
||||||
models = ifPossibleReduceByAircraftOrFamily(remoteAircraft, models, setup, QStringLiteral("Reduce by aircraft ICAO second."), r2, log);
|
models = ifPossibleReduceByAircraftOrFamily(remoteAircraft, UsePseudoFamily, models, setup, QStringLiteral("Reduce by aircraft ICAO second."), r2, log);
|
||||||
reduced = r1 || r2;
|
reduced = r1 || r2;
|
||||||
if (reduced) { return models; }
|
if (reduced) { return models; }
|
||||||
}
|
}
|
||||||
@@ -1053,7 +1053,7 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
bool r1 = false;
|
bool r1 = false;
|
||||||
bool r2 = false;
|
bool r2 = false;
|
||||||
CAircraftModelList models = ifPossibleReduceByAircraftOrFamily(remoteAircraft, inList, setup, QStringLiteral("Reduce by aircraft ICAO first."), r1, log);
|
CAircraftModelList models = ifPossibleReduceByAircraftOrFamily(remoteAircraft, UsePseudoFamily, inList, setup, QStringLiteral("Reduce by aircraft ICAO first."), r1, log);
|
||||||
models = ifPossibleReduceByAirline(remoteAircraft, models, QStringLiteral("Reduce aircraft ICAO by airline second."), r2, log);
|
models = ifPossibleReduceByAirline(remoteAircraft, models, QStringLiteral("Reduce aircraft ICAO by airline second."), r2, log);
|
||||||
|
|
||||||
// not finding anything so far means we have no valid aircraft/airline ICAO combination
|
// not finding anything so far means we have no valid aircraft/airline ICAO combination
|
||||||
@@ -1064,7 +1064,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
bool r3 = false;
|
bool r3 = false;
|
||||||
QString usedFamily;
|
QString usedFamily;
|
||||||
CAircraftModelList models2nd = ifPossibleReduceByFamily(remoteAircraft, inList, r3, usedFamily, log);
|
CAircraftModelList models2nd = ifPossibleReduceByFamily(remoteAircraft, UsePseudoFamily, inList, r3, usedFamily, log);
|
||||||
models2nd = ifPossibleReduceByAirline(remoteAircraft, models2nd, "Reduce family by airline second.", r3, log);
|
models2nd = ifPossibleReduceByAirline(remoteAircraft, models2nd, "Reduce family by airline second.", r3, log);
|
||||||
if (r3)
|
if (r3)
|
||||||
{
|
{
|
||||||
@@ -1086,22 +1086,22 @@ namespace BlackCore
|
|||||||
return inList;
|
return inList;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAircraftModelList CAircraftMatcher::ifPossibleReduceByFamily(const CSimulatedAircraft &remoteAircraft, const CAircraftModelList &inList, bool &reduced, QString &usedFamily, CStatusMessageList *log)
|
CAircraftModelList CAircraftMatcher::ifPossibleReduceByFamily(const CSimulatedAircraft &remoteAircraft, bool allowPseudoFamily, const CAircraftModelList &inList, bool &reduced, QString &usedFamily, CStatusMessageList *log)
|
||||||
{
|
{
|
||||||
reduced = false;
|
reduced = false;
|
||||||
usedFamily = remoteAircraft.getAircraftIcaoCode().getFamily();
|
usedFamily = remoteAircraft.getAircraftIcaoCode().getFamily();
|
||||||
if (!usedFamily.isEmpty())
|
if (!usedFamily.isEmpty())
|
||||||
{
|
{
|
||||||
CAircraftModelList matchedModels = ifPossibleReduceByFamily(remoteAircraft, usedFamily, inList, QStringLiteral("real family"), reduced, log);
|
CAircraftModelList matchedModels = ifPossibleReduceByFamily(remoteAircraft, usedFamily, allowPseudoFamily, inList, QStringLiteral("real family"), reduced, log);
|
||||||
if (reduced) { return matchedModels; }
|
if (reduced) { return matchedModels; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// scenario: the ICAO actually is the family
|
// scenario: the ICAO actually is the family
|
||||||
usedFamily = remoteAircraft.getAircraftIcaoCodeDesignator();
|
usedFamily = remoteAircraft.getAircraftIcaoCodeDesignator();
|
||||||
return ifPossibleReduceByFamily(remoteAircraft, usedFamily, inList, QStringLiteral("ICAO treated as family"), reduced, log);
|
return ifPossibleReduceByFamily(remoteAircraft, usedFamily, allowPseudoFamily, inList, QStringLiteral("ICAO treated as family"), reduced, log);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAircraftModelList CAircraftMatcher::ifPossibleReduceByFamily(const CSimulatedAircraft &remoteAircraft, const QString &family, const CAircraftModelList &inList, const QString &hint, bool &reduced, CStatusMessageList *log)
|
CAircraftModelList CAircraftMatcher::ifPossibleReduceByFamily(const CSimulatedAircraft &remoteAircraft, const QString &family, bool allowPseudoFamily, const CAircraftModelList &inList, const QString &hint, bool &reduced, CStatusMessageList *log)
|
||||||
{
|
{
|
||||||
// Use an algorithm to find the best match
|
// Use an algorithm to find the best match
|
||||||
reduced = false;
|
reduced = false;
|
||||||
@@ -1110,6 +1110,7 @@ namespace BlackCore
|
|||||||
if (log) { CMatchingUtils::addLogDetailsToList(log, remoteAircraft, u"No family, skipping step (" % hint % u")", getLogCategories()); }
|
if (log) { CMatchingUtils::addLogDetailsToList(log, remoteAircraft, u"No family, skipping step (" % hint % u")", getLogCategories()); }
|
||||||
return inList;
|
return inList;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inList.isEmpty())
|
if (inList.isEmpty())
|
||||||
{
|
{
|
||||||
if (log) { CMatchingUtils::addLogDetailsToList(log, remoteAircraft, u"No models for family match (" % hint % u")", getLogCategories()); }
|
if (log) { CMatchingUtils::addLogDetailsToList(log, remoteAircraft, u"No models for family match (" % hint % u")", getLogCategories()); }
|
||||||
@@ -1120,7 +1121,19 @@ namespace BlackCore
|
|||||||
if (found.isEmpty())
|
if (found.isEmpty())
|
||||||
{
|
{
|
||||||
if (log) { CMatchingUtils::addLogDetailsToList(log, remoteAircraft, u"Not found by family '" % family % u"' (" % hint % ")"); }
|
if (log) { CMatchingUtils::addLogDetailsToList(log, remoteAircraft, u"Not found by family '" % family % u"' (" % hint % ")"); }
|
||||||
return inList;
|
if (!allowPseudoFamily) { return inList; }
|
||||||
|
// fallthru
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allowPseudoFamily)
|
||||||
|
{
|
||||||
|
found = inList.findByCombinedAndManufacturer(remoteAircraft.getAircraftIcaoCode());
|
||||||
|
if (found.isEmpty())
|
||||||
|
{
|
||||||
|
const QString pseudo = remoteAircraft.getAircraftIcaoCode().getCombinedType() % "/" % remoteAircraft.getAircraftIcaoCode().getManufacturer();
|
||||||
|
if (log) { CMatchingUtils::addLogDetailsToList(log, remoteAircraft, u"Not found by pseudo family '" % pseudo % u"' (" % hint % ")"); }
|
||||||
|
return inList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reduced = true;
|
reduced = true;
|
||||||
@@ -1211,13 +1224,13 @@ namespace BlackCore
|
|||||||
return outList;
|
return outList;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAircraftModelList CAircraftMatcher::ifPossibleReduceByAircraftOrFamily(const CSimulatedAircraft &remoteAircraft, const CAircraftModelList &inList, const CAircraftMatcherSetup &setup, const QString &info, bool &reduced, CStatusMessageList *log)
|
CAircraftModelList CAircraftMatcher::ifPossibleReduceByAircraftOrFamily(const CSimulatedAircraft &remoteAircraft, bool allowPseudoFamily, const CAircraftModelList &inList, const CAircraftMatcherSetup &setup, const QString &info, bool &reduced, CStatusMessageList *log)
|
||||||
{
|
{
|
||||||
reduced = false;
|
reduced = false;
|
||||||
const CAircraftModelList outList = ifPossibleReduceByAircraft(remoteAircraft, inList, info, reduced, log);
|
const CAircraftModelList outList = ifPossibleReduceByAircraft(remoteAircraft, inList, info, reduced, log);
|
||||||
if (reduced || !setup.getMatchingMode().testFlag(CAircraftMatcherSetup::ByFamily)) { return outList; }
|
if (reduced || !setup.getMatchingMode().testFlag(CAircraftMatcherSetup::ByFamily)) { return outList; }
|
||||||
QString family;
|
QString family;
|
||||||
return ifPossibleReduceByFamily(remoteAircraft, inList, reduced, family, log);
|
return ifPossibleReduceByFamily(remoteAircraft, allowPseudoFamily, inList, reduced, family, log);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAircraftModelList CAircraftMatcher::ifPossibleReduceByAirline(const CSimulatedAircraft &remoteAircraft, const CAircraftModelList &inList, const QString &info, bool &reduced, CStatusMessageList *log)
|
CAircraftModelList CAircraftMatcher::ifPossibleReduceByAirline(const CSimulatedAircraft &remoteAircraft, const CAircraftModelList &inList, const QString &info, bool &reduced, CStatusMessageList *log)
|
||||||
|
|||||||
@@ -246,11 +246,12 @@ namespace BlackCore
|
|||||||
|
|
||||||
//! Find model by aircraft family
|
//! Find model by aircraft family
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
static BlackMisc::Simulation::CAircraftModelList ifPossibleReduceByFamily(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft, const BlackMisc::Simulation::CAircraftModelList &inList, bool &reduced, QString &usedFamily, BlackMisc::CStatusMessageList *log);
|
static BlackMisc::Simulation::CAircraftModelList ifPossibleReduceByFamily(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft, bool allowPseudoFamily, const BlackMisc::Simulation::CAircraftModelList &inList, bool &reduced, QString &usedFamily, BlackMisc::CStatusMessageList *log);
|
||||||
|
|
||||||
//! Find model by aircraft family
|
//! Find model by aircraft family
|
||||||
|
//! \remark pseudo family searches for same combined type and manufacturer
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
static BlackMisc::Simulation::CAircraftModelList ifPossibleReduceByFamily(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft, const QString &family, const BlackMisc::Simulation::CAircraftModelList &inList, const QString &hint, bool &reduced, BlackMisc::CStatusMessageList *log);
|
static BlackMisc::Simulation::CAircraftModelList ifPossibleReduceByFamily(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft, const QString &family, bool allowPseudoFamily, const BlackMisc::Simulation::CAircraftModelList &inList, const QString &hint, bool &reduced, BlackMisc::CStatusMessageList *log);
|
||||||
|
|
||||||
//! Search for exact livery and aircraft ICAO code
|
//! Search for exact livery and aircraft ICAO code
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
@@ -270,7 +271,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
//! Reduce by aircraft ICAO or family
|
//! Reduce by aircraft ICAO or family
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
static BlackMisc::Simulation::CAircraftModelList ifPossibleReduceByAircraftOrFamily(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft, const BlackMisc::Simulation::CAircraftModelList &inList, const BlackMisc::Simulation::CAircraftMatcherSetup &setup, const QString &info, bool &reduced, BlackMisc::CStatusMessageList *log);
|
static BlackMisc::Simulation::CAircraftModelList ifPossibleReduceByAircraftOrFamily(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft, bool allowPseudoFamily, const BlackMisc::Simulation::CAircraftModelList &inList, const BlackMisc::Simulation::CAircraftMatcherSetup &setup, const QString &info, bool &reduced, BlackMisc::CStatusMessageList *log);
|
||||||
|
|
||||||
//! Reduce by airline ICAO
|
//! Reduce by airline ICAO
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
@@ -300,6 +301,9 @@ namespace BlackCore
|
|||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
static bool isValidAirlineIcaoDesignator(const QString &designator, bool checkAgainstSwiftDb);
|
static bool isValidAirlineIcaoDesignator(const QString &designator, bool checkAgainstSwiftDb);
|
||||||
|
|
||||||
|
//! Use pseudo family
|
||||||
|
static bool constexpr UsePseudoFamily = true;
|
||||||
|
|
||||||
BlackMisc::Simulation::CAircraftMatcherSetup m_setup; //!< setup
|
BlackMisc::Simulation::CAircraftMatcherSetup m_setup; //!< setup
|
||||||
BlackMisc::Simulation::CAircraftModel m_defaultModel; //!< model to be used as default model
|
BlackMisc::Simulation::CAircraftModel m_defaultModel; //!< model to be used as default model
|
||||||
BlackMisc::Simulation::CAircraftModelList m_modelSet; //!< models used for model matching
|
BlackMisc::Simulation::CAircraftModelList m_modelSet; //!< models used for model matching
|
||||||
|
|||||||
Reference in New Issue
Block a user