mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 15:45:46 +08:00
refs #844, react on unchanged bookings in airspace monitor
* renamed functions for consistency * fixed typos/docu
This commit is contained in:
committed by
Mathew Sutcliffe
parent
85ca3b7a1a
commit
82ab88b5a8
@@ -93,7 +93,8 @@ namespace BlackCore
|
||||
|
||||
// AutoConnection: this should also avoid race conditions by updating the bookings
|
||||
Q_ASSERT_X(sApp->getWebDataServices(), Q_FUNC_INFO, "Missing data reader");
|
||||
this->connect(sApp->getWebDataServices()->getBookingReader(), &CVatsimBookingReader::atcBookingsRead, this, &CAirspaceMonitor::ps_receivedBookings);
|
||||
this->connect(sApp->getWebDataServices()->getBookingReader(), &CVatsimBookingReader::atcBookingsRead, this, &CAirspaceMonitor::ps_receivedAtcBookings);
|
||||
this->connect(sApp->getWebDataServices()->getBookingReader(), &CVatsimBookingReader::atcBookingsReadUnchanged, this, &CAirspaceMonitor::ps_readUnchangedAtcBookings);
|
||||
this->connect(sApp->getWebDataServices()->getVatsimDataFileReader(), &CVatsimDataFileReader::dataFileRead, this, &CAirspaceMonitor::ps_receivedDataFile);
|
||||
|
||||
// Force snapshot in the main event loop
|
||||
@@ -468,6 +469,13 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::requestAtcBookingsUpdate()
|
||||
{
|
||||
Q_ASSERT_X(sApp->getWebDataServices(), Q_FUNC_INFO, "missing reader");
|
||||
sApp->getWebDataServices()->readInBackground(BlackMisc::Network::CEntityFlags::BookingEntity);
|
||||
this->m_bookingsRequested = true;
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::testCreateDummyOnlineAtcStations(int number)
|
||||
{
|
||||
if (number < 1) { return; }
|
||||
@@ -508,8 +516,8 @@ namespace BlackCore
|
||||
{
|
||||
// very likely and ATC callsign
|
||||
vm = CPropertyIndexVariantMap({CAtcStation::IndexController, CUser::IndexRealName}, realname);
|
||||
const int c1 = this->updateOnlineStations(callsign, vm, false, true);
|
||||
const int c2 = this->updateBookedStations(callsign, vm, false, true);
|
||||
const int c1 = this->updateOnlineStation(callsign, vm, false, true);
|
||||
const int c2 = this->updateBookedStation(callsign, vm, false, true);
|
||||
wasAtc = c1 > 0 || c2 > 0;
|
||||
}
|
||||
|
||||
@@ -596,7 +604,7 @@ namespace BlackCore
|
||||
this->m_reverseLookupMessages.remove(callsign);
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::ps_receivedBookings(const CAtcStationList &bookedStations)
|
||||
void CAirspaceMonitor::ps_receivedAtcBookings(const CAtcStationList &bookedStations)
|
||||
{
|
||||
Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this));
|
||||
if (bookedStations.isEmpty())
|
||||
@@ -613,9 +621,17 @@ namespace BlackCore
|
||||
}
|
||||
this->m_atcStationsBooked = newBookedStations;
|
||||
}
|
||||
this->m_bookingsRequested = false; // we already emit here
|
||||
emit this->changedAtcStationsBooked(); // all booked stations reloaded
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::ps_readUnchangedAtcBookings()
|
||||
{
|
||||
if (!this->m_bookingsRequested) { return; }
|
||||
this->m_bookingsRequested = false;
|
||||
emit this->changedAtcStationsBooked(); // treat as stations were changed
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::ps_receivedDataFile()
|
||||
{
|
||||
Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this));
|
||||
@@ -728,7 +744,7 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
// booked
|
||||
this->updateBookedStations(callsign, CPropertyIndexVariantMap(CAtcStation::IndexIsOnline, CVariant::from(false)), true, false);
|
||||
this->updateBookedStation(callsign, CPropertyIndexVariantMap(CAtcStation::IndexIsOnline, CVariant::from(false)), true, false);
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::ps_atisReceived(const CCallsign &callsign, const CInformationMessage &atisMessage)
|
||||
@@ -736,11 +752,11 @@ namespace BlackCore
|
||||
Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this));
|
||||
if (!this->isConnected() || callsign.isEmpty()) return;
|
||||
CPropertyIndexVariantMap vm(CAtcStation::IndexAtis, CVariant::from(atisMessage));
|
||||
this->updateOnlineStations(callsign, vm);
|
||||
this->updateOnlineStation(callsign, vm);
|
||||
|
||||
// receiving an ATIS means station is online, update in bookings
|
||||
vm.addValue(CAtcStation::IndexIsOnline, true);
|
||||
this->updateBookedStations(callsign, vm);
|
||||
this->updateBookedStation(callsign, vm);
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::ps_atisVoiceRoomReceived(const CCallsign &callsign, const QString &url)
|
||||
@@ -749,7 +765,7 @@ namespace BlackCore
|
||||
if (!this->isConnected()) { return; }
|
||||
const QString trimmedUrl = url.trimmed();
|
||||
CPropertyIndexVariantMap vm({ CAtcStation::IndexVoiceRoom, CVoiceRoom::IndexUrl }, trimmedUrl);
|
||||
const int changedOnline = this->updateOnlineStations(callsign, vm, true, true);
|
||||
const int changedOnline = this->updateOnlineStation(callsign, vm, true, true);
|
||||
if (changedOnline < 1) { return; }
|
||||
|
||||
Q_ASSERT(changedOnline == 1);
|
||||
@@ -757,7 +773,7 @@ namespace BlackCore
|
||||
emit this->changedAtcStationOnlineConnectionStatus(station, true); // send when voice room url is available
|
||||
|
||||
vm.addValue(CAtcStation::IndexIsOnline, true); // with voice room ATC is online
|
||||
this->updateBookedStations(callsign, vm);
|
||||
this->updateBookedStation(callsign, vm);
|
||||
|
||||
// receiving voice room means ATC has voice
|
||||
vm = CPropertyIndexVariantMap(CClient::IndexVoiceCapabilities, CVariant::from(CVoiceCapabilities::fromVoiceCapabilities(CVoiceCapabilities::Voice)));
|
||||
@@ -780,8 +796,8 @@ namespace BlackCore
|
||||
logoffDateTime.setTime(QTime(h, m));
|
||||
|
||||
const CPropertyIndexVariantMap vm(CAtcStation::IndexBookedUntil, CVariant(logoffDateTime));
|
||||
this->updateOnlineStations(callsign, vm);
|
||||
this->updateBookedStations(callsign, vm);
|
||||
this->updateOnlineStation(callsign, vm);
|
||||
this->updateBookedStation(callsign, vm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -876,7 +892,7 @@ namespace BlackCore
|
||||
this->addReverseLookupMessage(callsign, m);
|
||||
}
|
||||
|
||||
bool CAirspaceMonitor::addNewAircraftinRange(const CSimulatedAircraft &aircraft)
|
||||
bool CAirspaceMonitor::addNewAircraftInRange(const CSimulatedAircraft &aircraft)
|
||||
{
|
||||
const CCallsign callsign = aircraft.getCallsign();
|
||||
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "Missing callsign");
|
||||
@@ -939,7 +955,7 @@ namespace BlackCore
|
||||
return c;
|
||||
}
|
||||
|
||||
int CAirspaceMonitor::updateOnlineStations(const CCallsign &callsign, const CPropertyIndexVariantMap &vm, bool skipEqualValues, bool sendSignal)
|
||||
int CAirspaceMonitor::updateOnlineStation(const CCallsign &callsign, const CPropertyIndexVariantMap &vm, bool skipEqualValues, bool sendSignal)
|
||||
{
|
||||
const int c = this->m_atcStationsOnline.applyIfCallsign(callsign, vm, skipEqualValues);
|
||||
if (c > 0 && sendSignal)
|
||||
@@ -949,7 +965,7 @@ namespace BlackCore
|
||||
return c;
|
||||
}
|
||||
|
||||
int CAirspaceMonitor::updateBookedStations(const CCallsign &callsign, const CPropertyIndexVariantMap &vm, bool skipEqualValues, bool sendSignal)
|
||||
int CAirspaceMonitor::updateBookedStation(const CCallsign &callsign, const CPropertyIndexVariantMap &vm, bool skipEqualValues, bool sendSignal)
|
||||
{
|
||||
// do not used applyFirst here, more stations wit callsign at a time
|
||||
const int c = this->m_atcStationsBooked.applyIfCallsign(callsign, vm, skipEqualValues);
|
||||
@@ -983,7 +999,7 @@ namespace BlackCore
|
||||
else
|
||||
{
|
||||
aircraft = CAirspaceMonitor::initNewAircraft(callsign, aircraftIcao, airlineIcao, livery, modelString, type, log);
|
||||
this->addNewAircraftinRange(aircraft);
|
||||
this->addNewAircraftInRange(aircraft);
|
||||
}
|
||||
return aircraft;
|
||||
}
|
||||
@@ -1016,7 +1032,7 @@ namespace BlackCore
|
||||
aircraft.setCallsign(callsign);
|
||||
aircraft.setSituation(situation);
|
||||
aircraft.setTransponder(transponder);
|
||||
this->addNewAircraftinRange(aircraft);
|
||||
this->addNewAircraftInRange(aircraft);
|
||||
this->sendInitialPilotQueries(callsign, !hasFsInnPacket);
|
||||
|
||||
// new client, there is a chance it has been already created by custom packet
|
||||
|
||||
@@ -140,10 +140,10 @@ namespace BlackCore
|
||||
//! \threadsafe
|
||||
bool isAircraftInRange(const BlackMisc::Aviation::CCallsign &callsign) const;
|
||||
|
||||
//! Returns the current online ATC stations
|
||||
//! Returns the current online ATC stations (consolidated with booked stations)
|
||||
BlackMisc::Aviation::CAtcStationList getAtcStationsOnline() const { return m_atcStationsOnline; }
|
||||
|
||||
//! Returns the current booked ATC stations
|
||||
//! Returns the current booked ATC stations (consolidated with online stations)
|
||||
BlackMisc::Aviation::CAtcStationList getAtcStationsBooked() const { return m_atcStationsBooked; }
|
||||
|
||||
//! Returns the closest ATC station operating on the given frequency, if any
|
||||
@@ -158,6 +158,9 @@ namespace BlackCore
|
||||
//! Request to update ATC stations' ATIS data from the network
|
||||
void requestAtisUpdates();
|
||||
|
||||
//! Request updates of bookings
|
||||
void requestAtcBookingsUpdate();
|
||||
|
||||
//! Create dummy entries for performance tests
|
||||
void testCreateDummyOnlineAtcStations(int number);
|
||||
|
||||
@@ -246,8 +249,9 @@ namespace BlackCore
|
||||
|
||||
INetwork *m_network = nullptr; //!< corresponding network interface
|
||||
CAirspaceAnalyzer *m_analyzer = nullptr; //!< owned analyzer
|
||||
bool m_enableReverseLookupMsgs = false; //!< shall we log. information about the matching process
|
||||
bool m_enableAircraftPartsHistory = true; //!< shall we keep a history of aircraft parts
|
||||
bool m_enableReverseLookupMsgs = false; //!< shall we log. information about the matching process
|
||||
bool m_enableAircraftPartsHistory = true; //!< shall we keep a history of aircraft parts
|
||||
bool m_bookingsRequested = false; //!< bookings have been requested, it can happen we receive an BlackCore::Vatsim::CVatsimBookingReader::atcBookingsReadUnchanged signal
|
||||
|
||||
// locks
|
||||
mutable QReadWriteLock m_lockSituations; //!< lock for situations: m_situationsByCallsign
|
||||
@@ -298,7 +302,7 @@ namespace BlackCore
|
||||
//! Add new aircraft, ignored if aircraft already exists
|
||||
//! \remark position to own aircraft set, VATSIM data file data considered
|
||||
//! \threadsafe
|
||||
bool addNewAircraftinRange(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
||||
bool addNewAircraftInRange(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
||||
|
||||
//! Init a new aircraft and add it or update model of existing aircraft
|
||||
//! \threadsafe
|
||||
@@ -316,15 +320,15 @@ namespace BlackCore
|
||||
//! \threadsafe
|
||||
bool addNewClient(const BlackMisc::Network::CClient &client);
|
||||
|
||||
//! Update client
|
||||
//! Update client by callsign
|
||||
//! \threadsafe
|
||||
int updateOrAddClient(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::CPropertyIndexVariantMap &vm, bool skipEqualValues = true);
|
||||
|
||||
//! Update online stations
|
||||
int updateOnlineStations(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::CPropertyIndexVariantMap &vm, bool skipEqualValues = true, bool sendSignal = true);
|
||||
//! Update online stations by callsign
|
||||
int updateOnlineStation(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::CPropertyIndexVariantMap &vm, bool skipEqualValues = true, bool sendSignal = true);
|
||||
|
||||
//! Update booked stations
|
||||
int updateBookedStations(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::CPropertyIndexVariantMap &vm, bool skipEqualValues = true, bool sendSignal = true);
|
||||
//! Update booked station by callsign
|
||||
int updateBookedStation(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::CPropertyIndexVariantMap &vm, bool skipEqualValues = true, bool sendSignal = true);
|
||||
|
||||
//! Call ps_customFSInnPacketReceived with stored packet
|
||||
void recallFsInnPacket(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
@@ -376,7 +380,8 @@ namespace BlackCore
|
||||
void ps_icaoCodesReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &aircraftIcaoDesignator, const QString &airlineIcaoDesignator, const QString &livery);
|
||||
void ps_pilotDisconnected(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
void ps_frequencyReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &frequency);
|
||||
void ps_receivedBookings(const BlackMisc::Aviation::CAtcStationList &bookedStations);
|
||||
void ps_receivedAtcBookings(const BlackMisc::Aviation::CAtcStationList &bookedStations);
|
||||
void ps_readUnchangedAtcBookings();
|
||||
void ps_receivedDataFile();
|
||||
void ps_aircraftConfigReceived(const BlackMisc::Aviation::CCallsign &callsign, const QJsonObject &jsonObject, bool isFull);
|
||||
void ps_aircraftInterimUpdateReceived(const BlackMisc::Aviation::CAircraftSituation &situation);
|
||||
|
||||
Reference in New Issue
Block a user