mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-28 03:35:38 +08:00
Ref T129, return CFlightPlanRemarks from CAirspaceMonitor::tryToGetFlightPlanRemarks, not only string
Uses utility function in CAircraftMatcher
This commit is contained in:
committed by
Mathew Sutcliffe
parent
3de7d66e65
commit
3c9d454638
@@ -47,6 +47,27 @@ namespace BlackCore
|
|||||||
CAircraftMatcher::~CAircraftMatcher()
|
CAircraftMatcher::~CAircraftMatcher()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
CAirlineIcaoCode CAircraftMatcher::failoverValidAirlineIcao(const CCallsign &callsign, const QString &primaryIcao, const QString &secondaryIcao, bool airlineFromCallsign, CStatusMessageList *log)
|
||||||
|
{
|
||||||
|
if (CAirlineIcaoCode::isValidAirlineDesignator(primaryIcao)) { return CAirlineIcaoCode(primaryIcao); }
|
||||||
|
if (CAirlineIcaoCode::isValidAirlineDesignator(secondaryIcao))
|
||||||
|
{
|
||||||
|
CMatchingUtils::addLogDetailsToList(log, callsign, QString("Using secondary airline ICAO '%1', primary '%2' not valid").arg(secondaryIcao, primaryIcao), getLogCategories());
|
||||||
|
return CAirlineIcaoCode(secondaryIcao);
|
||||||
|
}
|
||||||
|
if (airlineFromCallsign)
|
||||||
|
{
|
||||||
|
const QString airlineSuffix = callsign.getAirlineSuffix();
|
||||||
|
if (CAirlineIcaoCode::isValidAirlineDesignator(airlineSuffix))
|
||||||
|
{
|
||||||
|
CMatchingUtils::addLogDetailsToList(log, callsign, QString("Using airline from callsign '%1', suffix: '%2'").arg(callsign.toQString(), airlineSuffix), getLogCategories());
|
||||||
|
return CAirlineIcaoCode(airlineSuffix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CMatchingUtils::addLogDetailsToList(log, callsign, QString("Two invalid airline ICAO codes '%1', '%2'").arg(primaryIcao, secondaryIcao), getLogCategories());
|
||||||
|
return CAirlineIcaoCode();
|
||||||
|
}
|
||||||
|
|
||||||
CAircraftModel CAircraftMatcher::getClosestMatch(const CSimulatedAircraft &remoteAircraft, CStatusMessageList *log) const
|
CAircraftModel CAircraftMatcher::getClosestMatch(const CSimulatedAircraft &remoteAircraft, CStatusMessageList *log) const
|
||||||
{
|
{
|
||||||
const CAircraftModelList modelSet(m_modelSet); // Models for this matching
|
const CAircraftModelList modelSet(m_modelSet); // Models for this matching
|
||||||
|
|||||||
@@ -69,7 +69,16 @@ namespace BlackCore
|
|||||||
//! Result depends on enabled modes.
|
//! Result depends on enabled modes.
|
||||||
//! \sa MatchingModeFlag
|
//! \sa MatchingModeFlag
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
BlackMisc::Simulation::CAircraftModel getClosestMatch(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft, BlackMisc::CStatusMessageList *log = nullptr) const;
|
BlackMisc::Simulation::CAircraftModel getClosestMatch(
|
||||||
|
const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft,
|
||||||
|
BlackMisc::CStatusMessageList *log = nullptr) const;
|
||||||
|
|
||||||
|
//! Return the airline ICAO being valid
|
||||||
|
//! \threadsafe
|
||||||
|
static BlackMisc::Aviation::CAirlineIcaoCode failoverValidAirlineIcao(
|
||||||
|
const BlackMisc::Aviation::CCallsign &callsign,
|
||||||
|
const QString &primaryIcao, const QString &secondaryIcao,
|
||||||
|
bool airlineFromCallsign, BlackMisc::CStatusMessageList *log = nullptr);
|
||||||
|
|
||||||
//! Try to find the corresponding data in DB and get best information for given data
|
//! Try to find the corresponding data in DB and get best information for given data
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
|
|||||||
@@ -306,12 +306,18 @@ namespace BlackCore
|
|||||||
return plan;
|
return plan;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CAirspaceMonitor::tryToGetFlightPlanRemarks(const CCallsign &callsign) const
|
CFlightPlanRemarks CAirspaceMonitor::tryToGetFlightPlanRemarks(const CCallsign &callsign) const
|
||||||
{
|
{
|
||||||
if (callsign.isEmpty()) { return ""; }
|
if (callsign.isEmpty()) { return CFlightPlanRemarks(); }
|
||||||
if (m_flightPlanCache.contains(callsign)) { return m_flightPlanCache[callsign].getRemarks(); }
|
|
||||||
|
// full flight plan's remarks
|
||||||
|
if (m_flightPlanCache.contains(callsign)) { return m_flightPlanCache[callsign].getFlightPlanRemarks(); }
|
||||||
|
|
||||||
|
// remarks only
|
||||||
if (this->supportsVatsimDataFile()) { return sApp->getWebDataServices()->getVatsimDataFileReader()->getFlightPlanRemarksForCallsign(callsign); }
|
if (this->supportsVatsimDataFile()) { return sApp->getWebDataServices()->getVatsimDataFileReader()->getFlightPlanRemarksForCallsign(callsign); }
|
||||||
return "";
|
|
||||||
|
// unsupported
|
||||||
|
return CFlightPlanRemarks();
|
||||||
}
|
}
|
||||||
|
|
||||||
CUserList CAirspaceMonitor::getUsers() const
|
CUserList CAirspaceMonitor::getUsers() const
|
||||||
@@ -915,29 +921,28 @@ namespace BlackCore
|
|||||||
this->addReverseLookupMessage(callsign, m);
|
this->addReverseLookupMessage(callsign, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAircraftModel CAirspaceMonitor::reverseLookupModelWithFlightplanData(const CCallsign &callsign, const QString &aircraftIcaoString, const QString &airlineIcaoString, const QString &livery, const QString &modelString, CAircraftModel::ModelType type, CStatusMessageList *log)
|
CAircraftModel CAirspaceMonitor::reverseLookupModelWithFlightplanData(
|
||||||
|
const CCallsign &callsign, const QString &aircraftIcaoString,
|
||||||
|
const QString &airlineIcaoString, const QString &livery, const QString &modelString,
|
||||||
|
CAircraftModel::ModelType type, CStatusMessageList *log)
|
||||||
{
|
{
|
||||||
const QString fpRemarks = this->tryToGetFlightPlanRemarks(callsign);
|
const CFlightPlanRemarks fpRemarks = this->tryToGetFlightPlanRemarks(callsign);
|
||||||
|
CAirlineIcaoCode airlineIcao = CAircraftMatcher::failoverValidAirlineIcao(callsign, airlineIcaoString, fpRemarks.getAirlineIcao(), true, log);
|
||||||
CAircraftIcaoCode aircraftIcao(aircraftIcaoString);
|
CAircraftIcaoCode aircraftIcao(aircraftIcaoString);
|
||||||
CAirlineIcaoCode airlineIcao(airlineIcaoString);
|
if (fpRemarks.hasParsedAirlineRemarks())
|
||||||
if (!fpRemarks.isEmpty())
|
|
||||||
{
|
{
|
||||||
const CFlightPlanRemarks ar(fpRemarks);
|
const QString airlineName = CAircraftMatcher::reverseLookupAirlineName(fpRemarks.getFlightOperator(), callsign, log);
|
||||||
if (ar.hasParsedAirlineRemarks())
|
if (!airlineName.isEmpty())
|
||||||
{
|
{
|
||||||
const QString airlineName = CAircraftMatcher::reverseLookupAirlineName(ar.getFlightOperator(), callsign, log);
|
airlineIcao.setName(airlineName);
|
||||||
if (!airlineName.isEmpty())
|
this->addReverseLookupMessage(callsign, QString("Setting airline name '%1'").arg(airlineName));
|
||||||
{
|
}
|
||||||
airlineIcao.setName(airlineName);
|
|
||||||
this->addReverseLookupMessage(callsign, QString("Setting airline name '%1'").arg(airlineName));
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString telephony = CAircraftMatcher::reverseLookupTelephonyDesignator(ar.getRadioTelephony(), callsign, log);
|
const QString telephony = CAircraftMatcher::reverseLookupTelephonyDesignator(fpRemarks.getRadioTelephony(), callsign, log);
|
||||||
if (!telephony.isEmpty())
|
if (!telephony.isEmpty())
|
||||||
{
|
{
|
||||||
airlineIcao.setTelephonyDesignator(telephony);
|
airlineIcao.setTelephonyDesignator(telephony);
|
||||||
this->addReverseLookupMessage(callsign, QString("Setting telephoy designator '%1'").arg(telephony));
|
this->addReverseLookupMessage(callsign, QString("Setting telephoy designator '%1'").arg(telephony));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return CAircraftMatcher::reverselLookupModel(callsign, aircraftIcao, airlineIcao, livery, modelString, type, log);
|
return CAircraftMatcher::reverselLookupModel(callsign, aircraftIcao, airlineIcao, livery, modelString, type, log);
|
||||||
|
|||||||
@@ -123,9 +123,9 @@ namespace BlackCore
|
|||||||
BlackMisc::Aviation::CFlightPlan loadFlightPlanFromNetwork(const BlackMisc::Aviation::CCallsign &callsign);
|
BlackMisc::Aviation::CFlightPlan loadFlightPlanFromNetwork(const BlackMisc::Aviation::CCallsign &callsign);
|
||||||
|
|
||||||
//! Try to get flight plan remarks
|
//! Try to get flight plan remarks
|
||||||
//! \remarks returns a value only if the flight plan is already cached
|
//! \remarks returns a value only if the flight plan is already cached or can be obtained from VATSIM reader
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
QString tryToGetFlightPlanRemarks(const BlackMisc::Aviation::CCallsign &callsign) const;
|
BlackMisc::Aviation::CFlightPlanRemarks tryToGetFlightPlanRemarks(const BlackMisc::Aviation::CCallsign &callsign) const;
|
||||||
|
|
||||||
//! Returns this list of other clients we know about
|
//! Returns this list of other clients we know about
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
@@ -220,7 +220,7 @@ namespace BlackCore
|
|||||||
void airspaceAircraftSnapshot(const BlackMisc::Simulation::CAirspaceAircraftSnapshot &snapshot);
|
void airspaceAircraftSnapshot(const BlackMisc::Simulation::CAirspaceAircraftSnapshot &snapshot);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! Used to temp store FsInn data
|
//! Used to temporary store FsInn data
|
||||||
struct FsInnPacket
|
struct FsInnPacket
|
||||||
{
|
{
|
||||||
//! Default ctor
|
//! Default ctor
|
||||||
@@ -250,7 +250,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Aviation::CFlightPlan> m_flightPlanCache; //!< flight plan information retrieved from network and cached
|
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Aviation::CFlightPlan> m_flightPlanCache; //!< flight plan information retrieved from network and cached
|
||||||
|
|
||||||
INetwork *m_network = nullptr; //!< corresponding network interface
|
INetwork *m_network = nullptr; //!< corresponding network interface
|
||||||
CAirspaceAnalyzer *m_analyzer = nullptr; //!< owned analyzer
|
CAirspaceAnalyzer *m_analyzer = nullptr; //!< owned analyzer
|
||||||
bool m_enableReverseLookupMsgs = false; //!< shall we log. information about the matching process
|
bool m_enableReverseLookupMsgs = false; //!< shall we log. information about the matching process
|
||||||
bool m_enableAircraftPartsHistory = true; //!< shall we keep a history of aircraft parts
|
bool m_enableAircraftPartsHistory = true; //!< shall we keep a history of aircraft parts
|
||||||
|
|||||||
Reference in New Issue
Block a user