mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
CContextNetwork builds up an ATIS as it is received, line-by-line
refs #81
This commit is contained in:
committed by
Mathew Sutcliffe
parent
37d1466a83
commit
f3758e5609
@@ -152,12 +152,75 @@ namespace BlackCore
|
|||||||
/*
|
/*
|
||||||
* ATIS received
|
* ATIS received
|
||||||
*/
|
*/
|
||||||
void CContextNetwork::psFsdAtisQueryReceived(const CCallsign &callsign, const QString &atisMessage)
|
void CContextNetwork::psFsdAtisQueryReceived(const CCallsign &callsign, Cvatlib_Network::atisLineType lineType, const QString &atisMessage)
|
||||||
{
|
{
|
||||||
this->log(Q_FUNC_INFO, callsign.toQString(), atisMessage);
|
// this->log(Q_FUNC_INFO, callsign.toQString(), atisMessage);
|
||||||
CValueMap vm(CAtcStation::IndexAtisMessage, atisMessage);
|
|
||||||
this->m_atcStationsOnline.applyIf(&CAtcStation::getCallsign, callsign, vm);
|
// The ATIS consists of several lines, so the complete
|
||||||
this->m_atcStationsBooked.applyIf(&CAtcStation::getCallsign, callsign, vm);
|
// message needs to be build up before it can be set
|
||||||
|
// :V -> voice room address.
|
||||||
|
// :T Controller atis message
|
||||||
|
// :E Zulu logoff time
|
||||||
|
// :Z atis line count including this one
|
||||||
|
|
||||||
|
QString currentAtisMessage = this->m_atisMessageBuilder.contains(callsign.asString()) ?
|
||||||
|
this->m_atisMessageBuilder[callsign.asString()] : "";
|
||||||
|
switch (lineType)
|
||||||
|
{
|
||||||
|
case Cvatlib_Network::atisLineType_LineCount:
|
||||||
|
{
|
||||||
|
// line count denotes end of ATIS
|
||||||
|
CValueMap vm(CAtcStation::IndexAtisMessage, currentAtisMessage);
|
||||||
|
this->m_atcStationsOnline.applyIf(&CAtcStation::getCallsign, callsign, vm);
|
||||||
|
this->m_atcStationsBooked.applyIf(&CAtcStation::getCallsign, callsign, vm);
|
||||||
|
this->m_atisMessageBuilder.remove(callsign.asString());
|
||||||
|
return; // ignore, nothing to do
|
||||||
|
}
|
||||||
|
case Cvatlib_Network::atisLineType_VoiceRoom:
|
||||||
|
{
|
||||||
|
QString voiceRoomUrl = atisMessage.trimmed();
|
||||||
|
CValueMap vm(CAtcStation::IndexVoiceRoomUrl, voiceRoomUrl);
|
||||||
|
this->m_atcStationsOnline.applyIf(&CAtcStation::getCallsign, callsign, vm);
|
||||||
|
this->m_atcStationsBooked.applyIf(&CAtcStation::getCallsign, callsign, vm);
|
||||||
|
break; // voice room set, but also add to message
|
||||||
|
}
|
||||||
|
case Cvatlib_Network::atisLineType_ZuluLogoff:
|
||||||
|
{
|
||||||
|
if (atisMessage.length() == 4)
|
||||||
|
{
|
||||||
|
// Logic to set logoff time
|
||||||
|
bool ok;
|
||||||
|
int h = atisMessage.left(2).toInt(&ok);
|
||||||
|
if (!ok) break;
|
||||||
|
int m = atisMessage.right(2).toInt(&ok);
|
||||||
|
if (!ok) break;
|
||||||
|
QDateTime zuluLogoff = QDateTime::currentDateTimeUtc();
|
||||||
|
zuluLogoff.setTime(QTime(h, m));
|
||||||
|
CValueMap vm(CAtcStation::IndexBookedUntil, zuluLogoff);
|
||||||
|
this->m_atcStationsOnline.applyIf(&CAtcStation::getCallsign, callsign, vm);
|
||||||
|
this->m_atcStationsBooked.applyIf(&CAtcStation::getCallsign, callsign, vm);
|
||||||
|
}
|
||||||
|
break; // ZULU time set, but also add to message
|
||||||
|
}
|
||||||
|
case Cvatlib_Network::atisLineType_TextMessage:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString fixedAtisMessage = atisMessage.trimmed();
|
||||||
|
if (fixedAtisMessage.isEmpty()) return;
|
||||||
|
|
||||||
|
// detect the stupid z1, z2, z3 placeholders
|
||||||
|
// TODO: Anything better as this stupid code here?
|
||||||
|
const QString atisTest = fixedAtisMessage.toLower().remove(QRegExp("[\\n\\t\\r]"));
|
||||||
|
if (atisTest == "z") return;
|
||||||
|
if (atisTest.startsWith("z") && atisTest.length() == 2) return; // z1, z2, ..
|
||||||
|
if (atisTest.length() == 1) return; // sometimes just z
|
||||||
|
|
||||||
|
if (!currentAtisMessage.isEmpty()) currentAtisMessage.append("\n");
|
||||||
|
currentAtisMessage.append(fixedAtisMessage);
|
||||||
|
this->m_atisMessageBuilder[callsign.asString()] = currentAtisMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user