Ref T684, better detection of callsign type for ATC stations

* detection in "CCallsign::unifyCallsign"
* force ATC callsign in nAtisReplyReceived
This commit is contained in:
Klaus Basan
2019-06-16 20:23:04 +02:00
committed by Mat Sutcliffe
parent 5da74faad0
commit f6d078de34
3 changed files with 40 additions and 12 deletions

View File

@@ -1389,8 +1389,9 @@ namespace BlackCore
void CNetworkVatlib::onAtisReplyReceived(VatFsdClient *, const char *callsign, const VatControllerAtis *atis, void *cbvar) void CNetworkVatlib::onAtisReplyReceived(VatFsdClient *, const char *callsign, const VatControllerAtis *atis, void *cbvar)
{ {
auto *self = cbvar_cast(cbvar); auto *self = cbvar_cast(cbvar);
emit self->atisVoiceRoomReplyReceived(self->fromFSD(callsign), self->fromFSD(atis->voiceRoom)); const CCallsign cs(self->fromFSD(callsign), CCallsign::Atc);
emit self->atisLogoffTimeReplyReceived(self->fromFSD(callsign), self->fromFSD(atis->zuluLogoff)); emit self->atisVoiceRoomReplyReceived(cs, self->fromFSD(atis->voiceRoom));
emit self->atisLogoffTimeReplyReceived(cs, self->fromFSD(atis->zuluLogoff));
CInformationMessage atisMessage; CInformationMessage atisMessage;
atisMessage.setType(CInformationMessage::ATIS); atisMessage.setType(CInformationMessage::ATIS);
@@ -1413,7 +1414,7 @@ namespace BlackCore
} }
} }
emit self->atisReplyReceived(CCallsign(self->fromFSD(callsign), CCallsign::Atc), atisMessage); emit self->atisReplyReceived(cs, atisMessage);
} }
void CNetworkVatlib::onFlightPlanReceived(VatFsdClient *, const char *callsignChar, const VatFlightPlan *fp, void *cbvar) void CNetworkVatlib::onFlightPlanReceived(VatFsdClient *, const char *callsignChar, const VatFlightPlan *fp, void *cbvar)

View File

@@ -73,23 +73,29 @@ namespace BlackMisc
// Ref T664, allow ATC with hyphen, such as Ml-SNO_CTR // Ref T664, allow ATC with hyphen, such as Ml-SNO_CTR
switch (hint) switch (hint)
{ {
case Atc: return removeChars(callsign.toUpper().trimmed(), [](QChar c) { return !c.isLetterOrNumber() && c != '_' && c != '-'; }); // ATC allows "-", aircraft not
case Atc: return removeChars(callsign.toUpper().trimmed(), [](QChar c) { return !c.isLetterOrNumber() && c != '_' && c != '-'; });
case Aircraft: return removeChars(callsign.toUpper().trimmed(), [](QChar c) { return !c.isLetterOrNumber() && c != '_'; });
default: break; default: break;
} }
// no hint
if (CCallsign::looksLikeAtcCallsign(callsign))
{
return removeChars(callsign.toUpper().trimmed(), [](QChar c) { return !c.isLetterOrNumber() && c != '_' && c != '-'; });
}
// strict check
return removeChars(callsign.toUpper().trimmed(), [](QChar c) { return !c.isLetterOrNumber() && c != '_'; }); return removeChars(callsign.toUpper().trimmed(), [](QChar c) { return !c.isLetterOrNumber() && c != '_'; });
} }
const CIcon &CCallsign::convertToIcon(const CCallsign &callsign) const CIcon &CCallsign::convertToIcon(const CCallsign &callsign)
{ {
if (callsign.m_callsign.startsWith(QStringView(u"VATGOV"))) { return CIcon::iconByIndex(CIcons::NetworkRolePilot); } if (callsign.m_callsign.startsWith(QStringView(u"VATGOV"))) { return CIcon::iconByIndex(CIcons::NetworkRolePilot); }
if (callsign.getTypeHint() == CCallsign::Aircraft || !callsign.hasSuffix()) const bool pilot = callsign.getTypeHint() == CCallsign::Aircraft || !callsign.hasSuffix();
{ return pilot ?
return CIcon::iconByIndex(CIcons::NetworkRolePilot); CIcon::iconByIndex(CIcons::NetworkRolePilot) :
} CCallsign::atcSuffixToIcon(callsign.getSuffix());
else
{
return atcSuffixToIcon(callsign.getSuffix());
}
} }
const CIcon &CCallsign::atcSuffixToIcon(const QString &suffix) const CIcon &CCallsign::atcSuffixToIcon(const QString &suffix)
@@ -133,6 +139,11 @@ namespace BlackMisc
m_callsign.at(m_callsign.size() - 1) >= 'A' && m_callsign.at(m_callsign.size() - 1) <= 'Z'; m_callsign.at(m_callsign.size() - 1) >= 'A' && m_callsign.at(m_callsign.size() - 1) <= 'Z';
} }
bool CCallsign::isSameAsSet() const
{
return m_callsign == m_callsignAsSet;
}
QString CCallsign::getIcaoCode() const QString CCallsign::getIcaoCode() const
{ {
if (this->isAtcCallsign()) if (this->isAtcCallsign())
@@ -333,5 +344,15 @@ namespace BlackMisc
static const QStringList a({ "ATIS", "APP", "GND", "OBS", "TWR", "DEL", "CTR", "SUP", "FSS", "INS" }); static const QStringList a({ "ATIS", "APP", "GND", "OBS", "TWR", "DEL", "CTR", "SUP", "FSS", "INS" });
return a; return a;
} }
bool CCallsign::looksLikeAtcCallsign(const QString &callsign)
{
if (!callsign.contains("_")) { return false; }
for (const QString &r : CCallsign::atcAlikeCallsignSuffixes())
{
if (callsign.endsWith(r)) { return true; }
}
return false;
}
} // namespace } // namespace
} // namespace } // namespace

View File

@@ -89,6 +89,9 @@ namespace BlackMisc
//! Get callsign. //! Get callsign.
const QString &getStringAsSet() const { return m_callsignAsSet; } const QString &getStringAsSet() const { return m_callsignAsSet; }
//! Same as set callsign?
bool isSameAsSet() const;
//! Get callsign telephony designator (how callsign is pronounced) //! Get callsign telephony designator (how callsign is pronounced)
const QString &getTelephonyDesignator() const { return m_telephonyDesignator; } const QString &getTelephonyDesignator() const { return m_telephonyDesignator; }
@@ -175,6 +178,9 @@ namespace BlackMisc
//! List of real ("TWR") and treated like ATC suffixes (e.g. OBS); //! List of real ("TWR") and treated like ATC suffixes (e.g. OBS);
static const QStringList &atcAlikeCallsignSuffixes(); static const QStringList &atcAlikeCallsignSuffixes();
//! Does this look like an ATC callsign
static bool looksLikeAtcCallsign(const QString &callsign);
//! Suffix to icon //! Suffix to icon
static const CIcon &atcSuffixToIcon(const QString &suffix); static const CIcon &atcSuffixToIcon(const QString &suffix);