From ec32e3163b98fa9e3fa8247f74d5358497343b37 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 2 Oct 2018 02:21:28 +0200 Subject: [PATCH] Ref T380, test function and UI (internals) to test ATIS --- src/blackcore/context/contextnetwork.h | 3 + src/blackcore/context/contextnetworkempty.h | 9 +++ src/blackcore/context/contextnetworkimpl.cpp | 9 +++ src/blackcore/context/contextnetworkimpl.h | 1 + src/blackcore/context/contextnetworkproxy.cpp | 5 ++ src/blackcore/context/contextnetworkproxy.h | 1 + .../components/internalscomponent.cpp | 15 ++++ src/blackgui/components/internalscomponent.h | 3 + src/blackgui/components/internalscomponent.ui | 71 +++++++++++++++---- 9 files changed, 105 insertions(+), 12 deletions(-) diff --git a/src/blackcore/context/contextnetwork.h b/src/blackcore/context/contextnetwork.h index 12b7d1663..3ef6a7d57 100644 --- a/src/blackcore/context/contextnetwork.h +++ b/src/blackcore/context/contextnetwork.h @@ -322,6 +322,9 @@ namespace BlackCore //! Inject a text message as received virtual void testReceivedTextMessages(const BlackMisc::Network::CTextMessageList &textMessages) = 0; + //! Inject an ATIS + virtual void testReceivedAtisMessage(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CInformationMessage &msg) = 0; + //! Request parts for callsign (from another client) virtual void testRequestAircraftConfig(const BlackMisc::Aviation::CCallsign &callsign) = 0; diff --git a/src/blackcore/context/contextnetworkempty.h b/src/blackcore/context/contextnetworkempty.h index ae509b384..8a48f272a 100644 --- a/src/blackcore/context/contextnetworkempty.h +++ b/src/blackcore/context/contextnetworkempty.h @@ -284,6 +284,15 @@ namespace BlackCore return false; } + + //! \copydoc IContextNetwork::testReceivedAtisMessage + virtual void testReceivedAtisMessage(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CInformationMessage &msg) override + { + Q_UNUSED(callsign); + Q_UNUSED(msg); + logEmptyContextWarning(Q_FUNC_INFO); + } + //! \copydoc IContextNetwork::parseCommandLine virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override { diff --git a/src/blackcore/context/contextnetworkimpl.cpp b/src/blackcore/context/contextnetworkimpl.cpp index ae19890c0..1a62905b3 100644 --- a/src/blackcore/context/contextnetworkimpl.cpp +++ b/src/blackcore/context/contextnetworkimpl.cpp @@ -972,6 +972,15 @@ namespace BlackCore m_airspace->testAddAircraftParts(callsign, parts, incremental); } + void CContextNetwork::testReceivedAtisMessage(const CCallsign &callsign, const CInformationMessage &msg) + { + if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign.asString(); } + if (this->network()) + { + emit this->network()->atisReplyReceived(callsign, msg); + } + } + void CContextNetwork::testReceivedTextMessages(const CTextMessageList &textMessages) { if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << textMessages.toQString(); } diff --git a/src/blackcore/context/contextnetworkimpl.h b/src/blackcore/context/contextnetworkimpl.h index 056afeb48..1bbdb1d5f 100644 --- a/src/blackcore/context/contextnetworkimpl.h +++ b/src/blackcore/context/contextnetworkimpl.h @@ -255,6 +255,7 @@ namespace BlackCore virtual QString getLibraryInfo(bool detailed) const override; virtual void testCreateDummyOnlineAtcStations(int number) override; virtual void testAddAircraftParts(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftParts &parts, bool incremental) override; + virtual void testReceivedAtisMessage(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CInformationMessage &msg) override; virtual void testReceivedTextMessages(const BlackMisc::Network::CTextMessageList &textMessages) override; virtual void testRequestAircraftConfig(const BlackMisc::Aviation::CCallsign &callsign) override; //! @} diff --git a/src/blackcore/context/contextnetworkproxy.cpp b/src/blackcore/context/contextnetworkproxy.cpp index 2a4adafee..15abccd09 100644 --- a/src/blackcore/context/contextnetworkproxy.cpp +++ b/src/blackcore/context/contextnetworkproxy.cpp @@ -308,6 +308,11 @@ namespace BlackCore m_dBusInterface->callDBus(QLatin1String("testReceivedTextMessages"), textMessages); } + void CContextNetworkProxy::testReceivedAtisMessage(const CCallsign &callsign, const CInformationMessage &msg) + { + m_dBusInterface->callDBus(QLatin1String("testReceivedAtisMessage"), callsign, msg); + } + void CContextNetworkProxy::testRequestAircraftConfig(const CCallsign &callsign) { m_dBusInterface->callDBus(QLatin1String("testRequestAircraftConfig"), callsign); diff --git a/src/blackcore/context/contextnetworkproxy.h b/src/blackcore/context/contextnetworkproxy.h index fc09d8a6e..205bde0c1 100644 --- a/src/blackcore/context/contextnetworkproxy.h +++ b/src/blackcore/context/contextnetworkproxy.h @@ -126,6 +126,7 @@ namespace BlackCore virtual void testCreateDummyOnlineAtcStations(int number) override; virtual void testAddAircraftParts(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftParts &parts, bool incremental) override; virtual void testReceivedTextMessages(const BlackMisc::Network::CTextMessageList &textMessages) override; + virtual void testReceivedAtisMessage(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CInformationMessage &msg) override; virtual void testRequestAircraftConfig(const BlackMisc::Aviation::CCallsign &callsign) override; virtual bool testAddAltitudeOffset(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::PhysicalQuantities::CLength &offset = BlackMisc::PhysicalQuantities::CLength::null()) override; //! @} diff --git a/src/blackgui/components/internalscomponent.cpp b/src/blackgui/components/internalscomponent.cpp index 5a305c295..60108acd7 100644 --- a/src/blackgui/components/internalscomponent.cpp +++ b/src/blackgui/components/internalscomponent.cpp @@ -63,6 +63,7 @@ namespace BlackGui ui->le_TxtMsgFrom->setValidator(new CUpperCaseValidator(ui->le_TxtMsgFrom)); ui->le_TxtMsgTo->setValidator(new CUpperCaseValidator(ui->le_TxtMsgFrom)); + ui->le_AtisCallsign->setValidator(new CUpperCaseValidator(ui->le_AtisCallsign)); connect(ui->pb_SendAircraftPartsGui, &QPushButton::pressed, this, &CInternalsComponent::sendAircraftParts); connect(ui->pb_SendAircraftPartsJson, &QPushButton::pressed, this, &CInternalsComponent::sendAircraftParts); @@ -83,6 +84,8 @@ namespace BlackGui connect(ui->pb_RequestFromNetwork, &QPushButton::pressed, this, &CInternalsComponent::requestPartsFromNetwork); connect(ui->pb_DisplayLog, &QPushButton::pressed, this, &CInternalsComponent::displayLogInSimulator); + connect(ui->pb_SendAtis, &QPushButton::pressed, this, &CInternalsComponent::sendAtis); + connect(ui->comp_RemoteAircraftSelector, &CRemoteAircraftSelector::changedCallsign, this, &CInternalsComponent::selectorChanged); this->contextFlagsToGui(); } @@ -204,6 +207,18 @@ namespace BlackGui sGui->getIContextNetwork()->testReceivedTextMessages(CTextMessageList({ tm })); } + void CInternalsComponent::sendAtis() + { + if (!sGui || !sGui->getIContextNetwork()) { return; } + if (ui->le_AtisCallsign->text().isEmpty()) { return; } + if (ui->pte_Atis->toPlainText().isEmpty()) { return; } + const CCallsign cs(ui->le_AtisCallsign->text()); + const QString text(ui->pte_Atis->toPlainText()); + + const CInformationMessage im(CInformationMessage::ATIS, text); + sGui->getIContextNetwork()->testReceivedAtisMessage(cs, im); + } + void CInternalsComponent::logStatusMessage() { if (ui->le_StatusMessage->text().isEmpty()) { return; } diff --git a/src/blackgui/components/internalscomponent.h b/src/blackgui/components/internalscomponent.h index dee047b19..03900bee0 100644 --- a/src/blackgui/components/internalscomponent.h +++ b/src/blackgui/components/internalscomponent.h @@ -56,6 +56,9 @@ namespace BlackGui //! Send the text message void sendTextMessage(); + //! Send ATIS + void sendAtis(); + //! Send a dummy status message void logStatusMessage(); diff --git a/src/blackgui/components/internalscomponent.ui b/src/blackgui/components/internalscomponent.ui index 6a820afaf..b6f6ff986 100644 --- a/src/blackgui/components/internalscomponent.ui +++ b/src/blackgui/components/internalscomponent.ui @@ -6,8 +6,8 @@ 0 0 - 360 - 590 + 306 + 690 @@ -239,17 +239,34 @@ - - - Qt::Vertical + + + ATIS - - - 20 - 40 - - - + + + + + send + + + + + + + callsign + + + + + + + ATIS + + + + + @@ -597,6 +614,36 @@ 1 + + tw_Internals + cb_DebugContextAudio + cb_DebugContextNetwork + cb_DebugContextOwnAircraft + cb_DebugContextSimulator + cb_DebugContextApplication + le_StatusMessage + tb_LogStatusMessage + rb_StatusMessageInfo + rb_StatusMessageWarning + rb_StatusMessageError + le_TxtMsgFrom + le_TxtMsgTo + dsb_TxtMsgFrequency + pb_SendTextMessage + pte_TxtMsg + le_AtisCallsign + pb_SendAtis + pte_Atis + pb_LatestInterpolationLog + pb_LatestPartsLog + pb_DisplayLog + pb_RequestFromNetwork + tb_History + pb_SendAircraftPartsGui + cb_AircraftPartsIncremental + pb_SendAircraftPartsJson + pb_CurrentParts +