mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 20:40:29 +08:00
Ref T26, 1st implementation using flight plan remarks
This commit is contained in:
committed by
Mathew Sutcliffe
parent
ae2eb66721
commit
e3fd0e20c1
@@ -605,7 +605,7 @@ namespace BlackCore
|
|||||||
{ QWriteLocker l(&m_lockParts); m_partsByCallsign.clear(); m_aircraftSupportingParts.clear(); }
|
{ QWriteLocker l(&m_lockParts); m_partsByCallsign.clear(); m_aircraftSupportingParts.clear(); }
|
||||||
{ QWriteLocker l(&m_lockSituations); m_situationsByCallsign.clear(); }
|
{ QWriteLocker l(&m_lockSituations); m_situationsByCallsign.clear(); }
|
||||||
{ QWriteLocker l(&m_lockMessages); m_reverseLookupMessages.clear(); }
|
{ QWriteLocker l(&m_lockMessages); m_reverseLookupMessages.clear(); }
|
||||||
{ QWriteLocker l(&m_lockAircraft); m_aircraftInRange.clear(); }
|
{ QWriteLocker l(&m_lockAircraft); m_aircraftInRange.clear(); }
|
||||||
|
|
||||||
// non thread safe parts
|
// non thread safe parts
|
||||||
m_flightPlanCache.clear();
|
m_flightPlanCache.clear();
|
||||||
@@ -915,12 +915,30 @@ namespace BlackCore
|
|||||||
this->addReverseLookupMessage(callsign, m);
|
this->addReverseLookupMessage(callsign, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAircraftModel CAirspaceMonitor::reverseLookupModelWithFlightplanData(const CCallsign &callsign, const QString &aircraftIcao, const QString &airlineIcao, const QString &livery, const QString &modelString, CAircraftModel::ModelType type, CStatusMessageList *log) const
|
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 QString fpRemarks = this->tryToGetFlightPlanRemarks(callsign);
|
||||||
|
CAircraftIcaoCode aircraftIcao(aircraftIcaoString);
|
||||||
|
CAirlineIcaoCode airlineIcao(airlineIcaoString);
|
||||||
if (!fpRemarks.isEmpty())
|
if (!fpRemarks.isEmpty())
|
||||||
{
|
{
|
||||||
CFlightPlanUtils::parseFlightPlanRemarks(fpRemarks);
|
const CFlightPlanUtils::AirlineRemarks ar = CFlightPlanUtils::parseFlightPlanAirlineRemarks(fpRemarks);
|
||||||
|
if (ar.hasAnyRemarks())
|
||||||
|
{
|
||||||
|
const QString airlineName = CAircraftMatcher::reverseLookupAirlineName(ar.flightOperator, callsign, log);
|
||||||
|
if (!airlineName.isEmpty())
|
||||||
|
{
|
||||||
|
airlineIcao.setName(airlineName);
|
||||||
|
this->addReverseLookupMessage(callsign, QString("Setting airline name '%1'").arg(airlineName));
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString telephony = CAircraftMatcher::reverseLookupTelephonyDesignator(ar.radioTelephony, callsign, log);
|
||||||
|
if (!telephony.isEmpty())
|
||||||
|
{
|
||||||
|
airlineIcao.setTelephonyDesignator(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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -364,7 +364,7 @@ namespace BlackCore
|
|||||||
BlackMisc::Simulation::CAircraftModel reverseLookupModelWithFlightplanData(
|
BlackMisc::Simulation::CAircraftModel reverseLookupModelWithFlightplanData(
|
||||||
const BlackMisc::Aviation::CCallsign &callsign, const QString &aircraftIcao,
|
const BlackMisc::Aviation::CCallsign &callsign, const QString &aircraftIcao,
|
||||||
const QString &airlineIcao, const QString &livery, const QString &modelString,
|
const QString &airlineIcao, const QString &livery, const QString &modelString,
|
||||||
BlackMisc::Simulation::CAircraftModel::ModelType type, BlackMisc::CStatusMessageList *log) const;
|
BlackMisc::Simulation::CAircraftModel::ModelType type, BlackMisc::CStatusMessageList *log);
|
||||||
|
|
||||||
//! Create aircraft in range, this is the only place where a new aircraft should be added
|
//! Create aircraft in range, this is the only place where a new aircraft should be added
|
||||||
void onAircraftUpdateReceived(const BlackMisc::Aviation::CAircraftSituation &situation, const BlackMisc::Aviation::CTransponder &transponder);
|
void onAircraftUpdateReceived(const BlackMisc::Aviation::CAircraftSituation &situation, const BlackMisc::Aviation::CTransponder &transponder);
|
||||||
|
|||||||
@@ -14,9 +14,45 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
namespace Aviation
|
namespace Aviation
|
||||||
{
|
{
|
||||||
void CFlightPlanUtils::parseFlightPlanRemarks(const QString &remarks)
|
CFlightPlanUtils::AirlineRemarks CFlightPlanUtils::parseFlightPlanAirlineRemarks(const QString &remarks)
|
||||||
{
|
{
|
||||||
if (remarks.isEmpty()) { return; }
|
AirlineRemarks ar;
|
||||||
|
if (remarks.isEmpty()) { return ar; }
|
||||||
|
const QString r = remarks.toUpper();
|
||||||
|
if (r.contains("/CALLSIGN"))
|
||||||
|
{
|
||||||
|
// used similar to radio telephony
|
||||||
|
ar.radioTelephony = cut(r, "/CALLSIGN");
|
||||||
|
}
|
||||||
|
else if (r.contains("/RT"))
|
||||||
|
{
|
||||||
|
// radio telephony designator
|
||||||
|
ar.radioTelephony = cut(r, "/RT");
|
||||||
|
}
|
||||||
|
if (r.contains("/OPR"))
|
||||||
|
{
|
||||||
|
// operator, e.g. British airways
|
||||||
|
ar.flightOperator = cut(r, "/OPR");
|
||||||
|
}
|
||||||
|
return ar;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CFlightPlanUtils::cut(const QString &remarks, const QString &marker)
|
||||||
|
{
|
||||||
|
const int maxIndex = remarks.size() - 1;
|
||||||
|
int f = remarks.indexOf(marker);
|
||||||
|
if (f < 0) { return ""; }
|
||||||
|
f += marker.length();
|
||||||
|
if (maxIndex <= f) { return ""; }
|
||||||
|
int to = remarks.indexOf(' ', f + 1);
|
||||||
|
if (to < 0) { to = maxIndex; } // no more spaces
|
||||||
|
const QString cut = remarks.mid(f, to - f).replace('/', ' '); // variations like /OPR/EASYJET/
|
||||||
|
// problem is that this cuts something like "Uzbekistan airways"
|
||||||
|
return cut;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
// RT/KESTREL OPR/MYTRAVEL REG/G-DAJC SEL/FP-ES PER/C NAV/RNP10
|
||||||
|
// VFPS = VATSIM Flightplan Prefile System
|
||||||
|
// OPR/UAL CALLSIGN/UNITED
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#define BLACKMISC_AVIATION_FLIGHTPLANUTILS_H
|
#define BLACKMISC_AVIATION_FLIGHTPLANUTILS_H
|
||||||
|
|
||||||
#include "blackmisc/blackmiscexport.h"
|
#include "blackmisc/blackmiscexport.h"
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
{
|
{
|
||||||
@@ -22,11 +23,28 @@ namespace BlackMisc
|
|||||||
class BLACKMISC_EXPORT CFlightPlanUtils
|
class BLACKMISC_EXPORT CFlightPlanUtils
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
//! Useful value in flight plan remarks
|
||||||
|
struct AirlineRemarks
|
||||||
|
{
|
||||||
|
QString radioTelephony; //!< radio telephony designator
|
||||||
|
QString flightOperator; //!< operator, i.e. normally the airline name
|
||||||
|
|
||||||
|
//! Any remarks available
|
||||||
|
bool hasAnyRemarks() const
|
||||||
|
{
|
||||||
|
return !radioTelephony.isEmpty() || !flightOperator.isEmpty();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
CFlightPlanUtils() = delete;
|
CFlightPlanUtils() = delete;
|
||||||
|
|
||||||
//! Parse remarks from a flight plan
|
//! Parse remarks from a flight plan
|
||||||
static void parseFlightPlanRemarks(const QString &remarks);
|
static AirlineRemarks parseFlightPlanAirlineRemarks(const QString &remarks);
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! Cut the remarks part
|
||||||
|
static QString cut(const QString &remarks, const QString &marker);
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
Reference in New Issue
Block a user