mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +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:
committed by
Mat Sutcliffe
parent
f40dbb6c81
commit
82812e6630
@@ -114,6 +114,10 @@ namespace BlackCore
|
||||
// Analyzer
|
||||
connect(m_analyzer, &CAirspaceAnalyzer::timeoutAircraft, this, &CAirspaceMonitor::onPilotDisconnected, 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)
|
||||
@@ -304,16 +308,20 @@ namespace BlackCore
|
||||
const CSimulatedAircraftList aircraftInRange(this->getAircraftInRange());
|
||||
for (const CSimulatedAircraft &aircraft : aircraftInRange)
|
||||
{
|
||||
// staggered version
|
||||
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
|
||||
// Important: this is only a workaround and must not replace a sendInitialPilotQueries
|
||||
/**
|
||||
m_network->sendFrequencyQuery(cs);
|
||||
if (!aircraft.hasAircraftDesignator())
|
||||
{
|
||||
m_network->sendIcaoCodesQuery(cs);
|
||||
}
|
||||
**/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,7 +332,13 @@ namespace BlackCore
|
||||
for (const CAtcStation &station : stations)
|
||||
{
|
||||
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(", ");
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::process()
|
||||
{
|
||||
if (this->isConnectedAndNotShuttingDown())
|
||||
{
|
||||
// only send one
|
||||
const bool send = this->sendNextStaggeredAtisQuery();
|
||||
if (!send) { this->sendNextStaggeredPilotDataQuery(); }
|
||||
}
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::clear()
|
||||
{
|
||||
m_flightPlanCache.clear();
|
||||
@@ -470,6 +494,7 @@ namespace BlackCore
|
||||
void CAirspaceMonitor::removeAllOnlineAtcStations()
|
||||
{
|
||||
m_atcStationsOnline.clear();
|
||||
m_queryAtis.clear();
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::removeAllAircraft()
|
||||
@@ -479,6 +504,7 @@ namespace BlackCore
|
||||
// non thread safe parts
|
||||
m_flightPlanCache.clear();
|
||||
m_readiness.clear();
|
||||
m_queryPilot.clear();
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::removeFromAircraftCachesAndLogs(const CCallsign &callsign)
|
||||
@@ -1348,6 +1374,16 @@ namespace BlackCore
|
||||
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)
|
||||
{
|
||||
if (!this->isConnectedAndNotShuttingDown()) { return; }
|
||||
@@ -1361,6 +1397,24 @@ namespace BlackCore
|
||||
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
|
||||
{
|
||||
return m_network && m_network->isConnected();
|
||||
@@ -1411,7 +1465,7 @@ namespace BlackCore
|
||||
// It is only relevant if we are logged in as observer
|
||||
if (sApp->getIContextNetwork()->getLoginMode() != INetwork::LoginAsObserver) { return false; }
|
||||
|
||||
const CCallsign ownCallsign = getOwnAircraft().getCallsign();
|
||||
const CCallsign ownCallsign = this->getOwnAircraft().getCallsign();
|
||||
return ownCallsign.isMaybeCopilotCallsign(callsign);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include <QString>
|
||||
#include <QTimer>
|
||||
#include <QtGlobal>
|
||||
#include <QQueue>
|
||||
#include <functional>
|
||||
|
||||
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, Readiness> m_readiness; //!< readiness
|
||||
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
|
||||
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
|
||||
QTimer m_processTimer;
|
||||
static constexpr int ProcessInterval = 50; // in ms
|
||||
|
||||
//! Processing by timer
|
||||
void process();
|
||||
|
||||
//! Remove ATC online stations
|
||||
void removeAllOnlineAtcStations();
|
||||
@@ -272,9 +279,15 @@ namespace BlackCore
|
||||
//! Network queries for ATC
|
||||
void sendInitialAtcQueries(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
//! Network queries for ATIS
|
||||
bool sendNextStaggeredAtisQuery();
|
||||
|
||||
//! Network queries for pilots
|
||||
void sendInitialPilotQueries(const BlackMisc::Aviation::CCallsign &callsign, bool withIcaoQuery, bool withFsInn);
|
||||
|
||||
//! Network queries for pilot
|
||||
bool sendNextStaggeredPilotDataQuery();
|
||||
|
||||
//! Connected with network?
|
||||
bool isConnected() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user