From 37c21b3dae5831adb77c83daa81a6c8a7a410036 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 7 Nov 2019 17:10:34 +0100 Subject: [PATCH] [FSD] Use correct signals for airspace analyzer The used ones used the CID, not the callsign --- src/blackcore/airspaceanalyzer.cpp | 37 ++++++++++++++++++++++++------ src/blackcore/airspaceanalyzer.h | 4 ++++ 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/blackcore/airspaceanalyzer.cpp b/src/blackcore/airspaceanalyzer.cpp index 944b5c4f7..0bdffedb9 100644 --- a/src/blackcore/airspaceanalyzer.cpp +++ b/src/blackcore/airspaceanalyzer.cpp @@ -41,17 +41,20 @@ namespace BlackCore Q_ASSERT_X(fsdClient, Q_FUNC_INFO, "Network object required to connect"); // all in new thread from here on - this->setObjectName(getName()); + this->setObjectName(this->getName()); m_updateTimer.start(7500); m_lastWatchdogCallMsSinceEpoch = QDateTime::currentMSecsSinceEpoch(); bool c = connect(&m_updateTimer, &QTimer::timeout, this, &CAirspaceAnalyzer::onTimeout); Q_ASSERT(c); // network connected - c = connect(fsdClient, &CFSDClient::deletePilotReceived, this, &CAirspaceAnalyzer::watchdogRemoveAircraftCallsign, Qt::QueuedConnection); - Q_ASSERT(c); - c = connect(fsdClient, &CFSDClient::deleteAtcReceived, this, &CAirspaceAnalyzer::watchdogRemoveAtcCallsign, Qt::QueuedConnection); - Q_ASSERT(c); + + // those are CID and not callsign related + // c = connect(fsdClient, &CFSDClient::deletePilotReceived, this, &CAirspaceAnalyzer::watchdogRemoveAircraftCallsign, Qt::QueuedConnection); + // Q_ASSERT(c); + // c = connect(fsdClient, &CFSDClient::deleteAtcReceived, this, &CAirspaceAnalyzer::watchdogRemoveAtcCallsign, Qt::QueuedConnection); + // Q_ASSERT(c); + c = connect(fsdClient, &CFSDClient::connectionStatusChanged, this, &CAirspaceAnalyzer::onConnectionStatusChanged, Qt::QueuedConnection); Q_ASSERT(c); @@ -64,6 +67,12 @@ namespace BlackCore // Monitor c = connect(airspaceMonitorParent, &CAirspaceMonitor::addedAircraftSituation, this, &CAirspaceAnalyzer::watchdogTouchAircraftCallsign); Q_ASSERT(c); + c = connect(airspaceMonitorParent, &CAirspaceMonitor::removedAircraft, this, &CAirspaceAnalyzer::watchdogRemoveAircraftCallsign); + Q_ASSERT(c); + c = connect(airspaceMonitorParent, &CAirspaceMonitor::changedAtcStationOnlineConnectionStatus, this, &CAirspaceAnalyzer::onChangedAtcStationOnlineConnectionStatus); + Q_ASSERT(c); + + // -------------------- Q_UNUSED(c) // start in own thread @@ -94,10 +103,24 @@ namespace BlackCore this->watchdogTouchAircraftCallsign(situation); } + void CAirspaceAnalyzer::onChangedAtcStationOnlineConnectionStatus(const CAtcStation &station, bool isConnected) + { + const CCallsign cs = station.getCallsign(); + if (isConnected) + { + m_atcCallsignTimestamps[cs] = QDateTime::currentMSecsSinceEpoch(); + } + else + { + this->watchdogRemoveAtcCallsign(cs); + } + } + void CAirspaceAnalyzer::watchdogTouchAircraftCallsign(const CAircraftSituation &situation) { - Q_ASSERT_X(!situation.getCallsign().isEmpty(), Q_FUNC_INFO, "No callsign in situaton"); - m_aircraftCallsignTimestamps[situation.getCallsign()] = QDateTime::currentMSecsSinceEpoch(); + const CCallsign cs = situation.getCallsign(); + Q_ASSERT_X(!cs.isEmpty(), Q_FUNC_INFO, "No callsign in situaton"); + m_aircraftCallsignTimestamps[cs] = QDateTime::currentMSecsSinceEpoch(); } void CAirspaceAnalyzer::watchdogTouchAtcCallsign(const CCallsign &callsign, const CFrequency &frequency, const CCoordinateGeodetic &position, const CLength &range) diff --git a/src/blackcore/airspaceanalyzer.h b/src/blackcore/airspaceanalyzer.h index a975084fa..82726a826 100644 --- a/src/blackcore/airspaceanalyzer.h +++ b/src/blackcore/airspaceanalyzer.h @@ -17,6 +17,7 @@ #include "blackmisc/simulation/airspaceaircraftsnapshot.h" #include "blackmisc/simulation/ownaircraftprovider.h" #include "blackmisc/simulation/remoteaircraftprovider.h" +#include "blackmisc/aviation/atcstation.h" #include "blackmisc/geo/coordinategeodetic.h" #include "blackmisc/pq/frequency.h" #include "blackmisc/pq/length.h" @@ -115,6 +116,9 @@ namespace BlackCore //! Network position update void onNetworkPositionUpdate(const BlackMisc::Aviation::CAircraftSituation &situation, const BlackMisc::Aviation::CTransponder &transponder); + //! ATC stations online + void onChangedAtcStationOnlineConnectionStatus(const BlackMisc::Aviation::CAtcStation &station, bool isConnected); + //! Run a check void onTimeout();