mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-09 05:28:09 +08:00
Ref T706, staggered queires for ATC and aircraft
* avoid overlapping responses: https://discordapp.com/channels/539048679160676382/539925070550794240/603176348445442058 * potential: avoid traffic overload (forcible logoff)
This commit is contained in:
@@ -114,6 +114,10 @@ namespace BlackCore
|
|||||||
// Analyzer
|
// Analyzer
|
||||||
connect(m_analyzer, &CAirspaceAnalyzer::timeoutAircraft, this, &CAirspaceMonitor::onPilotDisconnected, Qt::QueuedConnection);
|
connect(m_analyzer, &CAirspaceAnalyzer::timeoutAircraft, this, &CAirspaceMonitor::onPilotDisconnected, Qt::QueuedConnection);
|
||||||
connect(m_analyzer, &CAirspaceAnalyzer::timeoutAtc, this, &CAirspaceMonitor::onAtcControllerDisconnected, Qt::QueuedConnection);
|
connect(m_analyzer, &CAirspaceAnalyzer::timeoutAtc, this, &CAirspaceMonitor::onAtcControllerDisconnected, Qt::QueuedConnection);
|
||||||
|
|
||||||
|
// timer
|
||||||
|
connect(&m_processTimer, &QTimer::timeout, this, &CAirspaceMonitor::process);
|
||||||
|
m_processTimer.start(ProcessInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CAirspaceMonitor::updateFastPositionEnabled(const CCallsign &callsign, bool enableFastPositonUpdates)
|
bool CAirspaceMonitor::updateFastPositionEnabled(const CCallsign &callsign, bool enableFastPositonUpdates)
|
||||||
@@ -304,16 +308,20 @@ namespace BlackCore
|
|||||||
const CSimulatedAircraftList aircraftInRange(this->getAircraftInRange());
|
const CSimulatedAircraftList aircraftInRange(this->getAircraftInRange());
|
||||||
for (const CSimulatedAircraft &aircraft : aircraftInRange)
|
for (const CSimulatedAircraft &aircraft : aircraftInRange)
|
||||||
{
|
{
|
||||||
|
// staggered version
|
||||||
const CCallsign cs(aircraft.getCallsign());
|
const CCallsign cs(aircraft.getCallsign());
|
||||||
m_network->sendFrequencyQuery(cs);
|
if (!m_queryPilot.contains(cs))
|
||||||
|
{
|
||||||
|
m_queryPilot.enqueue(aircraft.getCallsign());
|
||||||
|
}
|
||||||
|
|
||||||
// we only query ICAO if we have none yet
|
/**
|
||||||
// it happens sometimes with some FSD servers (e.g our testserver) a first query is skipped
|
m_network->sendFrequencyQuery(cs);
|
||||||
// Important: this is only a workaround and must not replace a sendInitialPilotQueries
|
|
||||||
if (!aircraft.hasAircraftDesignator())
|
if (!aircraft.hasAircraftDesignator())
|
||||||
{
|
{
|
||||||
m_network->sendIcaoCodesQuery(cs);
|
m_network->sendIcaoCodesQuery(cs);
|
||||||
}
|
}
|
||||||
|
**/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,7 +332,13 @@ namespace BlackCore
|
|||||||
for (const CAtcStation &station : stations)
|
for (const CAtcStation &station : stations)
|
||||||
{
|
{
|
||||||
const CCallsign cs = station.getCallsign();
|
const CCallsign cs = station.getCallsign();
|
||||||
m_network->sendAtisQuery(cs); // for each online station
|
|
||||||
|
// changed to staggered version
|
||||||
|
// m_network->sendAtisQuery(cs); // for each online station
|
||||||
|
if (!m_queryAtis.contains(cs))
|
||||||
|
{
|
||||||
|
m_queryAtis.enqueue(cs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,6 +401,16 @@ namespace BlackCore
|
|||||||
return s.join(", ");
|
return s.join(", ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CAirspaceMonitor::process()
|
||||||
|
{
|
||||||
|
if (this->isConnectedAndNotShuttingDown())
|
||||||
|
{
|
||||||
|
// only send one
|
||||||
|
const bool send = this->sendNextStaggeredAtisQuery();
|
||||||
|
if (!send) { this->sendNextStaggeredPilotDataQuery(); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CAirspaceMonitor::clear()
|
void CAirspaceMonitor::clear()
|
||||||
{
|
{
|
||||||
m_flightPlanCache.clear();
|
m_flightPlanCache.clear();
|
||||||
@@ -470,6 +494,7 @@ namespace BlackCore
|
|||||||
void CAirspaceMonitor::removeAllOnlineAtcStations()
|
void CAirspaceMonitor::removeAllOnlineAtcStations()
|
||||||
{
|
{
|
||||||
m_atcStationsOnline.clear();
|
m_atcStationsOnline.clear();
|
||||||
|
m_queryAtis.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAirspaceMonitor::removeAllAircraft()
|
void CAirspaceMonitor::removeAllAircraft()
|
||||||
@@ -479,6 +504,7 @@ namespace BlackCore
|
|||||||
// non thread safe parts
|
// non thread safe parts
|
||||||
m_flightPlanCache.clear();
|
m_flightPlanCache.clear();
|
||||||
m_readiness.clear();
|
m_readiness.clear();
|
||||||
|
m_queryPilot.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAirspaceMonitor::removeFromAircraftCachesAndLogs(const CCallsign &callsign)
|
void CAirspaceMonitor::removeFromAircraftCachesAndLogs(const CCallsign &callsign)
|
||||||
@@ -1348,6 +1374,16 @@ namespace BlackCore
|
|||||||
m_network->sendServerQuery(callsign);
|
m_network->sendServerQuery(callsign);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CAirspaceMonitor::sendNextStaggeredAtisQuery()
|
||||||
|
{
|
||||||
|
if (m_queryAtis.isEmpty()) { return false; }
|
||||||
|
if (!this->isConnectedAndNotShuttingDown()) { return false; }
|
||||||
|
const CCallsign cs = m_queryAtis.dequeue();
|
||||||
|
if (!m_atcStationsOnline.containsCallsign(cs)) { return false; }
|
||||||
|
m_network->sendAtisQuery(cs);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void CAirspaceMonitor::sendInitialPilotQueries(const CCallsign &callsign, bool withIcaoQuery, bool withFsInn)
|
void CAirspaceMonitor::sendInitialPilotQueries(const CCallsign &callsign, bool withIcaoQuery, bool withFsInn)
|
||||||
{
|
{
|
||||||
if (!this->isConnectedAndNotShuttingDown()) { return; }
|
if (!this->isConnectedAndNotShuttingDown()) { return; }
|
||||||
@@ -1361,6 +1397,24 @@ namespace BlackCore
|
|||||||
m_network->sendServerQuery(callsign);
|
m_network->sendServerQuery(callsign);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CAirspaceMonitor::sendNextStaggeredPilotDataQuery()
|
||||||
|
{
|
||||||
|
if (m_queryPilot.isEmpty()) { return false; }
|
||||||
|
if (!this->isConnectedAndNotShuttingDown()) { return false; }
|
||||||
|
const CCallsign cs = m_queryPilot.dequeue();
|
||||||
|
if (!this->isAircraftInRange(cs)) { return false; }
|
||||||
|
m_network->sendFrequencyQuery(cs);
|
||||||
|
|
||||||
|
// we only query ICAO if we have none yet
|
||||||
|
// it happens sometimes with some FSD servers (e.g our testserver) a first query is skipped
|
||||||
|
// Important: this is only a workaround and must not replace a sendInitialPilotQueries
|
||||||
|
if (!this->getAircraftInRangeForCallsign(cs).hasAircraftDesignator())
|
||||||
|
{
|
||||||
|
m_network->sendIcaoCodesQuery(cs);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool CAirspaceMonitor::isConnected() const
|
bool CAirspaceMonitor::isConnected() const
|
||||||
{
|
{
|
||||||
return m_network && m_network->isConnected();
|
return m_network && m_network->isConnected();
|
||||||
@@ -1411,7 +1465,7 @@ namespace BlackCore
|
|||||||
// It is only relevant if we are logged in as observer
|
// It is only relevant if we are logged in as observer
|
||||||
if (sApp->getIContextNetwork()->getLoginMode() != INetwork::LoginAsObserver) { return false; }
|
if (sApp->getIContextNetwork()->getLoginMode() != INetwork::LoginAsObserver) { return false; }
|
||||||
|
|
||||||
const CCallsign ownCallsign = getOwnAircraft().getCallsign();
|
const CCallsign ownCallsign = this->getOwnAircraft().getCallsign();
|
||||||
return ownCallsign.isMaybeCopilotCallsign(callsign);
|
return ownCallsign.isMaybeCopilotCallsign(callsign);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
#include <QQueue>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
@@ -253,10 +254,16 @@ namespace BlackCore
|
|||||||
QHash<BlackMisc::Aviation::CCallsign, BlackMisc::Aviation::CFlightPlan> m_flightPlanCache; //!< flight plan information retrieved from network and cached
|
QHash<BlackMisc::Aviation::CCallsign, BlackMisc::Aviation::CFlightPlan> m_flightPlanCache; //!< flight plan information retrieved from network and cached
|
||||||
QHash<BlackMisc::Aviation::CCallsign, Readiness> m_readiness; //!< readiness
|
QHash<BlackMisc::Aviation::CCallsign, Readiness> m_readiness; //!< readiness
|
||||||
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::Settings::TModelMatching> m_matchingSettings { this }; //!< settings
|
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::Settings::TModelMatching> m_matchingSettings { this }; //!< settings
|
||||||
|
QQueue<BlackMisc::Aviation::CCallsign> m_queryAtis; //!< query the ATIS
|
||||||
|
QQueue<BlackMisc::Aviation::CCallsign> m_queryPilot; //!< query the pilot data
|
||||||
INetwork *m_network = nullptr; //!< corresponding network interface
|
INetwork *m_network = nullptr; //!< corresponding network interface
|
||||||
CAirspaceAnalyzer *m_analyzer = nullptr; //!< owned analyzer
|
CAirspaceAnalyzer *m_analyzer = nullptr; //!< owned analyzer
|
||||||
bool m_bookingsRequested = false; //!< bookings have been requested, it can happen we receive an BlackCore::Vatsim::CVatsimBookingReader::atcBookingsReadUnchanged signal
|
bool m_bookingsRequested = false; //!< bookings have been requested, it can happen we receive an BlackCore::Vatsim::CVatsimBookingReader::atcBookingsReadUnchanged signal
|
||||||
|
QTimer m_processTimer;
|
||||||
|
static constexpr int ProcessInterval = 50; // in ms
|
||||||
|
|
||||||
|
//! Processing by timer
|
||||||
|
void process();
|
||||||
|
|
||||||
//! Remove ATC online stations
|
//! Remove ATC online stations
|
||||||
void removeAllOnlineAtcStations();
|
void removeAllOnlineAtcStations();
|
||||||
@@ -272,9 +279,15 @@ namespace BlackCore
|
|||||||
//! Network queries for ATC
|
//! Network queries for ATC
|
||||||
void sendInitialAtcQueries(const BlackMisc::Aviation::CCallsign &callsign);
|
void sendInitialAtcQueries(const BlackMisc::Aviation::CCallsign &callsign);
|
||||||
|
|
||||||
|
//! Network queries for ATIS
|
||||||
|
bool sendNextStaggeredAtisQuery();
|
||||||
|
|
||||||
//! Network queries for pilots
|
//! Network queries for pilots
|
||||||
void sendInitialPilotQueries(const BlackMisc::Aviation::CCallsign &callsign, bool withIcaoQuery, bool withFsInn);
|
void sendInitialPilotQueries(const BlackMisc::Aviation::CCallsign &callsign, bool withIcaoQuery, bool withFsInn);
|
||||||
|
|
||||||
|
//! Network queries for pilot
|
||||||
|
bool sendNextStaggeredPilotDataQuery();
|
||||||
|
|
||||||
//! Connected with network?
|
//! Connected with network?
|
||||||
bool isConnected() const;
|
bool isConnected() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user