mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Ref T298, improved matching log messages
This commit is contained in:
@@ -107,11 +107,14 @@ namespace BlackCore
|
||||
static const QString m2("Input model: '%1' '%2'");
|
||||
static const QString m3("Matching uses model set of %1 models\n%2");
|
||||
static const QString m4("Setup %1");
|
||||
static const QString summary = QStringLiteral("\n-----------------------------------------\n") %
|
||||
QStringLiteral("- Combined: %1 -> %2\n") %
|
||||
QStringLiteral("- Aircraft: %3 -> %4\n") %
|
||||
QStringLiteral("- Airline: %5 -> %6\n") %
|
||||
QStringLiteral("-----------------------------------------\n");
|
||||
static const QString summary =
|
||||
QStringLiteral("\n") %
|
||||
QStringLiteral("-----------------------------------------\n") %
|
||||
QStringLiteral("- Combined: %1 -> %2\n") %
|
||||
QStringLiteral("- Aircraft: %3 -> %4\n") %
|
||||
QStringLiteral("- Airline: %5 -> %6\n") %
|
||||
QStringLiteral("- Livery: %7 -> %8\n") %
|
||||
QStringLiteral("-----------------------------------------\n");
|
||||
|
||||
const QDateTime startTime = QDateTime::currentDateTimeUtc();
|
||||
if (log) { log->clear(); }
|
||||
@@ -214,7 +217,8 @@ namespace BlackCore
|
||||
summary.arg(
|
||||
remoteAircraft.getAircraftIcaoCode().getCombinedType(), matchedModel.getAircraftIcaoCode().getCombinedType(),
|
||||
remoteAircraft.getAircraftIcaoCode().getDesignatorDbKey(), matchedModel.getAircraftIcaoCode().getDesignatorDbKey(),
|
||||
remoteAircraft.getAirlineIcaoCode().getVDesignatorDbKey(), matchedModel.getAirlineIcaoCode().getVDesignatorDbKey()
|
||||
remoteAircraft.getAirlineIcaoCode().getVDesignatorDbKey(), matchedModel.getAirlineIcaoCode().getVDesignatorDbKey(),
|
||||
remoteAircraft.getLivery().getCombinedCodePlusInfoAndId(), matchedModel.getLivery().getCombinedCodePlusInfoAndId()
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -668,7 +672,8 @@ namespace BlackCore
|
||||
// family only because aircraft ICAO is not used
|
||||
if (mode.testFlag(CAircraftMatcherSetup::ByFamily))
|
||||
{
|
||||
matchedModels = ifPossibleReduceByFamily(remoteAircraft, matchedModels, reduced, log);
|
||||
QString usedFamily;
|
||||
matchedModels = ifPossibleReduceByFamily(remoteAircraft, matchedModels, reduced, usedFamily, log);
|
||||
if (reduced) { break; }
|
||||
}
|
||||
else if (log)
|
||||
@@ -849,18 +854,17 @@ namespace BlackCore
|
||||
if (log) { CMatchingUtils::addLogDetailsToList(log, remoteAircraft, QStringLiteral("No exact ICAO match of '") % remoteAircraft.getAirlineAndAircraftIcaoCodeDesignators() % QStringLiteral("', will try family combination"), getLogCategories()); }
|
||||
|
||||
bool r3 = false;
|
||||
CAircraftModelList models2nd = ifPossibleReduceByFamily(remoteAircraft, inList, r3, log);
|
||||
QString usedFamily;
|
||||
CAircraftModelList models2nd = ifPossibleReduceByFamily(remoteAircraft, inList, r3, usedFamily, log);
|
||||
models2nd = ifPossibleReduceByAirline(remoteAircraft, models2nd, "Reduce family by airline second.", r3, log);
|
||||
if (r3)
|
||||
{
|
||||
// we found family / airline combination
|
||||
if (log) { CMatchingUtils::addLogDetailsToList(log, remoteAircraft, QStringLiteral("Found aircraft family/airline '") % QStringLiteral("'combination"), getLogCategories()); }
|
||||
if (log) { CMatchingUtils::addLogDetailsToList(log, remoteAircraft, QStringLiteral("Found aircraft family/airline '") % QStringLiteral("' combination"), getLogCategories()); }
|
||||
return models;
|
||||
}
|
||||
}
|
||||
|
||||
if (log) { CMatchingUtils::addLogDetailsToList(log, remoteAircraft, QStringLiteral("Found aircraft family/airline '") % remoteAircraft.getAircraftIcaoCode().getFamily() % QStringLiteral("/") % remoteAircraft.getAirlineIcaoCodeDesignator() % QStringLiteral("'combination"), getLogCategories()); }
|
||||
|
||||
reduced = r1 || r2;
|
||||
if (reduced)
|
||||
{
|
||||
@@ -873,16 +877,19 @@ namespace BlackCore
|
||||
return inList;
|
||||
}
|
||||
|
||||
CAircraftModelList CAircraftMatcher::ifPossibleReduceByFamily(const CSimulatedAircraft &remoteAircraft, const CAircraftModelList &inList, bool &reduced, CStatusMessageList *log)
|
||||
CAircraftModelList CAircraftMatcher::ifPossibleReduceByFamily(const CSimulatedAircraft &remoteAircraft, const CAircraftModelList &inList, bool &reduced, QString &usedFamily, CStatusMessageList *log)
|
||||
{
|
||||
reduced = false;
|
||||
QString family = remoteAircraft.getAircraftIcaoCode().getFamily();
|
||||
CAircraftModelList matchedModels = ifPossibleReduceByFamily(remoteAircraft, family, inList, "real family", reduced, log);
|
||||
if (reduced) { return matchedModels; }
|
||||
usedFamily = remoteAircraft.getAircraftIcaoCode().getFamily();
|
||||
if (!usedFamily.isEmpty())
|
||||
{
|
||||
CAircraftModelList matchedModels = ifPossibleReduceByFamily(remoteAircraft, usedFamily, inList, "real family", reduced, log);
|
||||
if (reduced) { return matchedModels; }
|
||||
}
|
||||
|
||||
// scenario: the ICAO actually is the family
|
||||
family = remoteAircraft.getAircraftIcaoCodeDesignator();
|
||||
return ifPossibleReduceByFamily(remoteAircraft, family, inList, "ICAO treated as family", reduced, log);
|
||||
usedFamily = remoteAircraft.getAircraftIcaoCodeDesignator();
|
||||
return ifPossibleReduceByFamily(remoteAircraft, usedFamily, inList, "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)
|
||||
@@ -1000,7 +1007,8 @@ namespace BlackCore
|
||||
reduced = false;
|
||||
const CAircraftModelList outList = ifPossibleReduceByAircraft(remoteAircraft, inList, info, reduced, log);
|
||||
if (reduced || !setup.getMatchingMode().testFlag(CAircraftMatcherSetup::ByFamily)) { return outList; }
|
||||
return ifPossibleReduceByFamily(remoteAircraft, inList, reduced, log);
|
||||
QString family;
|
||||
return ifPossibleReduceByFamily(remoteAircraft, inList, reduced, family, log);
|
||||
}
|
||||
|
||||
CAircraftModelList CAircraftMatcher::ifPossibleReduceByAirline(const CSimulatedAircraft &remoteAircraft, const CAircraftModelList &inList, const QString &info, bool &reduced, CStatusMessageList *log)
|
||||
|
||||
@@ -201,7 +201,7 @@ namespace BlackCore
|
||||
|
||||
//! Find model by aircraft family
|
||||
//! \threadsafe
|
||||
static BlackMisc::Simulation::CAircraftModelList ifPossibleReduceByFamily(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft, const BlackMisc::Simulation::CAircraftModelList &inList, bool &reduced, BlackMisc::CStatusMessageList *log);
|
||||
static BlackMisc::Simulation::CAircraftModelList ifPossibleReduceByFamily(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft, const BlackMisc::Simulation::CAircraftModelList &inList, bool &reduced, QString &usedFamily, BlackMisc::CStatusMessageList *log);
|
||||
|
||||
//! Find model by aircraft family
|
||||
//! \threadsafe
|
||||
|
||||
@@ -69,20 +69,17 @@ namespace BlackMisc
|
||||
|
||||
QString CLivery::getCombinedCodePlusInfo() const
|
||||
{
|
||||
QString s = this->getCombinedCode();
|
||||
if (!this->getDescription().isEmpty())
|
||||
{
|
||||
s += " ";
|
||||
s += this->getDescription();
|
||||
}
|
||||
return s;
|
||||
return this->getCombinedCode() % (
|
||||
this->getDescription().isEmpty() ?
|
||||
QStringLiteral("") :
|
||||
(QStringLiteral(" ") % this->getDescription())
|
||||
);
|
||||
}
|
||||
|
||||
QString CLivery::getCombinedCodePlusInfoAndId() const
|
||||
{
|
||||
QString s = this->getCombinedCodePlusInfo();
|
||||
s += this->getDbKeyAsStringInParentheses(" ");
|
||||
return s;
|
||||
return this->getCombinedCodePlusInfo() %
|
||||
this->getDbKeyAsStringInParentheses(" ");
|
||||
}
|
||||
|
||||
bool CLivery::isContainedInSimplifiedAirlineName(const QString &candidate) const
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QtGlobal>
|
||||
#include <QStringBuilder>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -21,14 +22,14 @@ namespace BlackMisc
|
||||
{
|
||||
QString IDatastoreObjectWithIntegerKey::getDbKeyAsString() const
|
||||
{
|
||||
if (m_dbKey < 0) { return ""; }
|
||||
if (m_dbKey < 0) { return QStringLiteral(""); }
|
||||
return QString::number(m_dbKey);
|
||||
}
|
||||
|
||||
QString IDatastoreObjectWithIntegerKey::getDbKeyAsStringInParentheses(const QString &prefix) const
|
||||
{
|
||||
if (m_dbKey < 0) { return ""; }
|
||||
return prefix + "(" + QString::number(m_dbKey) + ")";
|
||||
if (m_dbKey < 0) { return QStringLiteral(""); }
|
||||
return prefix % QStringLiteral("(") % QString::number(m_dbKey) % QStringLiteral(")");
|
||||
}
|
||||
|
||||
void IDatastoreObjectWithIntegerKey::setDbKey(const QString &key)
|
||||
@@ -74,19 +75,19 @@ namespace BlackMisc
|
||||
|
||||
void IDatastoreObjectWithIntegerKey::setKeyAndTimestampFromDatabaseJson(const QJsonObject &json, const QString &prefix)
|
||||
{
|
||||
const int dbKey = json.value(prefix + "id").toInt(-1);
|
||||
const int dbKey = json.value(prefix % QStringLiteral("id")).toInt(-1);
|
||||
this->setDbKey(dbKey);
|
||||
|
||||
// we check 2 formats, the DB format and the backend object format
|
||||
QString timestampString(json.value(prefix + "lastupdated").toString());
|
||||
if (timestampString.isEmpty()) { timestampString = json.value(prefix + "tsLastUpdated").toString(); }
|
||||
QString timestampString(json.value(prefix % QStringLiteral("lastupdated")).toString());
|
||||
if (timestampString.isEmpty()) { timestampString = json.value(prefix % QStringLiteral("tsLastUpdated")).toString(); }
|
||||
const QDateTime ts(CDatastoreUtility::parseTimestamp(timestampString));
|
||||
this->setUtcTimestamp(ts);
|
||||
}
|
||||
|
||||
bool IDatastoreObjectWithIntegerKey::existsKey(const QJsonObject &json, const QString &prefix)
|
||||
{
|
||||
const QJsonValue jv(json.value(prefix + "id"));
|
||||
const QJsonValue jv(json.value(prefix % QStringLiteral("id")));
|
||||
return !(jv.isNull() || jv.isUndefined());
|
||||
}
|
||||
|
||||
@@ -111,13 +112,9 @@ namespace BlackMisc
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexDbIntegerKey:
|
||||
m_dbKey = variant.toInt();
|
||||
break;
|
||||
case IndexDbKeyAsString:
|
||||
m_dbKey = stringToDbKey(variant.toQString());
|
||||
default:
|
||||
break;
|
||||
case IndexDbIntegerKey: m_dbKey = variant.toInt(); break;
|
||||
case IndexDbKeyAsString: m_dbKey = stringToDbKey(variant.toQString()); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +135,7 @@ namespace BlackMisc
|
||||
|
||||
bool IDatastoreObjectWithIntegerKey::canHandleIndex(const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (ITimestampBased::canHandleIndex(index)) { return true;}
|
||||
if (ITimestampBased::canHandleIndex(index)) { return true; }
|
||||
const int i = index.frontCasted<int>();
|
||||
return (i >= static_cast<int>(IndexDbIntegerKey)) && (i <= static_cast<int>(IndexDatabaseIcon));
|
||||
}
|
||||
@@ -153,7 +150,7 @@ namespace BlackMisc
|
||||
QString IDatastoreObjectWithStringKey::getDbKeyAsStringInParentheses(const QString &prefix) const
|
||||
{
|
||||
if (m_dbKey.isEmpty()) { return ""; }
|
||||
return prefix + "(" + m_dbKey + ")";
|
||||
return prefix % QStringLiteral("(") % m_dbKey % QStringLiteral(")");
|
||||
}
|
||||
|
||||
bool IDatastoreObjectWithStringKey::matchesDbKeyState(Db::DbKeyStateFilter filter) const
|
||||
@@ -171,7 +168,7 @@ namespace BlackMisc
|
||||
|
||||
void IDatastoreObjectWithStringKey::setKeyAndTimestampFromDatabaseJson(const QJsonObject &json, const QString &prefix)
|
||||
{
|
||||
QString dbKey = json.value(prefix + "id").toString();
|
||||
QString dbKey = json.value(prefix % QStringLiteral("id")).toString();
|
||||
QDateTime ts(CDatastoreUtility::parseTimestamp(json.value(prefix + "lastupdated").toString()));
|
||||
this->setDbKey(dbKey);
|
||||
this->setUtcTimestamp(ts);
|
||||
@@ -179,7 +176,7 @@ namespace BlackMisc
|
||||
|
||||
bool IDatastoreObjectWithStringKey::existsKey(const QJsonObject &json, const QString &prefix)
|
||||
{
|
||||
const QJsonValue jv(json.value(prefix + "id"));
|
||||
const QJsonValue jv(json.value(prefix % QStringLiteral("id")));
|
||||
return !(jv.isNull() || jv.isUndefined());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user