Handled performance issues and bugs noticed during testing of refs #319 / refs #322

* discussion: https://dev.vatsim-germany.org/boards/22/topics/2027?r=2040#message-2040
* fixed bug with ATC station component, wrong signals for booked stations
* booked stations loading to frequently (for each minor change such as online), changed to timestamp based concept
* update booked stations with receiving ATIS/voiceroom to online
* CDigestSignal class: new class and methods for collecting signals, avoiding too many signals - one of the cures for the performance issues
* fixed bug found during testing, missing start for timers when connecting to network
This commit is contained in:
Klaus Basan
2014-08-31 15:54:19 +02:00
parent 538cee89b2
commit fc84673bb9
12 changed files with 209 additions and 63 deletions

View File

@@ -248,7 +248,7 @@ namespace BlackCore
if (callsign.isEmpty() || model.isEmpty()) return;
// Request of other client, I can get the other's model from that
CIndexVariantMap vm( { CClient::IndexModel, CAircraftModel::IndexModelString }, QVariant(model));
CIndexVariantMap vm({ CClient::IndexModel, CAircraftModel::IndexModelString }, QVariant(model));
vm.addValue({ CClient::IndexModel, CAircraftModel::IndexIsQueriedModelString }, QVariant(true));
if (!this->m_otherClients.contains(&CClient::getCallsign, callsign))
{
@@ -280,8 +280,8 @@ namespace BlackCore
this->m_atcStationsOnline.applyIf(&CAtcStation::getCallsign, callsignTower, vm);
this->m_atcStationsBooked.applyIf(&CAtcStation::getCallsign, callsignTower, vm);
this->m_metarCache.insert(icaoCode, metar);
if (this->m_atcStationsOnline.contains(&CAtcStation::getCallsign, callsignTower)) emit this->changedAtcStationsOnline();
if (this->m_atcStationsBooked.contains(&CAtcStation::getCallsign, callsignTower)) emit this->changedAtcStationsBooked();
if (this->m_atcStationsOnline.contains(&CAtcStation::getCallsign, callsignTower)) { emit this->changedAtcStationsOnline(); }
if (this->m_atcStationsBooked.contains(&CAtcStation::getCallsign, callsignTower)) { emit this->changedAtcStationsBooked(); }
}
void CAirspaceMonitor::ps_flightplanReceived(const CCallsign &callsign, const CFlightPlan &flightPlan)
@@ -322,6 +322,7 @@ namespace BlackCore
// into list
this->m_atcStationsBooked.push_back(bookedStation);
}
emit this->changedAtcStationsBooked(); // all booked stations reloaded
}
void CAirspaceMonitor::ps_atcPositionUpdate(const CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &frequency, const CCoordinateGeodetic &position, const BlackMisc::PhysicalQuantities::CLength &range)
@@ -385,9 +386,12 @@ namespace BlackCore
if (callsign.isEmpty()) return;
CIndexVariantMap vm(CAtcStation::IndexAtis, atisMessage.toQVariant());
this->m_atcStationsOnline.applyIf(&CAtcStation::getCallsign, callsign, vm);
// receiving an ATIS means station is online, update in bookings
vm.addValue(CAtcStation::IndexIsOnline, true);
this->m_atcStationsBooked.applyIf(&CAtcStation::getCallsign, callsign, vm);
if (this->m_atcStationsOnline.contains(&CAtcStation::getCallsign, callsign)) emit this->changedAtcStationsBooked();
if (this->m_atcStationsBooked.contains(&CAtcStation::getCallsign, callsign)) emit this->changedAtcStationsBooked();
if (this->m_atcStationsOnline.contains(&CAtcStation::getCallsign, callsign)) { emit this->changedAtcStationsOnline(); }
if (this->m_atcStationsBooked.contains(&CAtcStation::getCallsign, callsign)) { emit this->changedAtcStationsBooked(); }
}
void CAirspaceMonitor::ps_atisVoiceRoomReceived(const CCallsign &callsign, const QString &url)
@@ -395,18 +399,20 @@ namespace BlackCore
Q_ASSERT(BlackCore::isCurrentThreadCreatingThread(this));
QString trimmedUrl = url.trimmed();
CIndexVariantMap vm({ CAtcStation::IndexVoiceRoom, CVoiceRoom::IndexUrl }, trimmedUrl);
if (this->m_atcStationsBooked.contains(&CAtcStation::getCallsign, callsign))
{
this->m_atcStationsBooked.applyIf(&CAtcStation::getCallsign, callsign, vm);
emit this->changedAtcStationsBooked();
}
if (this->m_atcStationsOnline.contains(&CAtcStation::getCallsign, callsign))
{
this->m_atcStationsOnline.applyIf(&CAtcStation::getCallsign, callsign, vm);
CAtcStation station = this->m_atcStationsOnline.findFirstByCallsign(callsign);
emit this->changedAtcStationsBooked();
emit this->changedAtcStationsOnline(); // single ATIS received
emit this->changedAtcStationOnlineConnectionStatus(station, true);
}
if (this->m_atcStationsBooked.contains(&CAtcStation::getCallsign, callsign))
{
// receiving a voice room means station is online, update in bookings
vm.addValue(CAtcStation::IndexIsOnline, true);
this->m_atcStationsBooked.applyIf(&CAtcStation::getCallsign, callsign, vm);
emit this->changedAtcStationsBooked(); // single ATIS received
}
vm = CIndexVariantMap(CClient::IndexVoiceCapabilities, CVoiceCapabilities(CVoiceCapabilities::Voice).toQVariant());
this->m_otherClients.applyIf(&CClient::getCallsign, callsign, vm);
}
@@ -427,8 +433,8 @@ namespace BlackCore
CIndexVariantMap vm(CAtcStation::IndexBookedUntil, logoffDateTime);
this->m_atcStationsOnline.applyIf(&CAtcStation::getCallsign, callsign, vm);
this->m_atcStationsBooked.applyIf(&CAtcStation::getCallsign, callsign, vm);
if (this->m_atcStationsOnline.contains(&CAtcStation::getCallsign, callsign)) emit this->changedAtcStationsBooked();
if (this->m_atcStationsBooked.contains(&CAtcStation::getCallsign, callsign)) emit this->changedAtcStationsBooked();
if (this->m_atcStationsOnline.contains(&CAtcStation::getCallsign, callsign)) { emit this->changedAtcStationsOnline(); }
if (this->m_atcStationsBooked.contains(&CAtcStation::getCallsign, callsign)) { emit this->changedAtcStationsBooked(); }
}
}

View File

@@ -66,18 +66,27 @@ namespace BlackCore
//! ATC station (online) list has been changed
void changedAtcStationsOnline();
//! Digest signal changedAtcStationsOnline()
void changedAtcStationsOnlineDigest();
//! ATC station (booked) list has been changed
void changedAtcStationsBooked();
//! Connection status changed for online station
void changedAtcStationOnlineConnectionStatus(const BlackMisc::Aviation::CAtcStation &atcStation, bool connected);
//! Digest signal changedAtcStationsBooked()
void changedAtcStationsBookedDigest();
//! Aircraft list has been changed
void changedAircraftsInRange();
//! Digest signal changedAircraftsInRange()
void changedAircraftsInRangeDigest();
//! Aircraft situation update
void changedAircraftSituation(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftSituation &situation);
//! Connection status changed for online station
void changedAtcStationOnlineConnectionStatus(const BlackMisc::Aviation::CAtcStation &atcStation, bool connected);
//! Terminated connection
void connectionTerminated();

View File

@@ -21,6 +21,7 @@
#include "blackmisc/avatcstationlist.h"
#include "blackmisc/setnetwork.h"
#include "blackmisc/nwclientlist.h"
#include "blackmisc/digestsignal.h"
#include <QMap>
@@ -46,7 +47,7 @@ namespace BlackCore
//! Airspace monitor accessible to other contexts
CAirspaceMonitor *getAirspaceMonitor() const { return m_airspace; }
public slots: // IContextNetwork overrides
public slots:
//! \copydoc IContextNetwork::readAtcBookingsFromSource()
virtual void readAtcBookingsFromSource() const override;
@@ -145,12 +146,16 @@ namespace BlackCore
private:
static const auto c_logContext = CRuntime::LogForNetwork;
CAirspaceMonitor *m_airspace;
CAirspaceMonitor *m_airspace;
BlackCore::INetwork *m_network;
INetwork::ConnectionStatus m_currentStatus; //!< used to detect pending connections
BlackMisc::CDigestSignal m_dsAtcStationsBookedChanged { this, &IContextNetwork::changedAtcStationsBooked, &IContextNetwork::changedAtcStationsBookedDigest, 750, 2 };
BlackMisc::CDigestSignal m_dsAtcStationsOnlineChanged { this, &IContextNetwork::changedAtcStationsOnline, &IContextNetwork::changedAtcStationsOnlineDigest, 750, 2 };
BlackMisc::CDigestSignal m_dsAircraftsInRangeChanged { this, &IContextNetwork::changedAircraftsInRange, &IContextNetwork::changedAircraftsInRangeDigest, 750, 2 };
// for reading XML and VATSIM data files
CVatsimBookingReader *m_vatsimBookingReader;
CVatsimBookingReader *m_vatsimBookingReader;
CVatsimDataFileReader *m_vatsimDataFileReader;
QTimer *m_dataUpdateTimer; //!< general updates such as ATIS, frequencies, see requestDataUpdates()

View File

@@ -37,9 +37,21 @@ namespace BlackCore
s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
"changedAtcStationsOnline", this, SIGNAL(changedAtcStationsOnline()));
Q_ASSERT(s);
s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
"changedAtcStationsBookedDigest", this, SIGNAL(changedAtcStationsBookedDigest()));
Q_ASSERT(s);
s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
"changedAtcStationsOnlineDigest", this, SIGNAL(changedAtcStationsOnlineDigest()));
Q_ASSERT(s);
s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
"changedAircraftsInRange", this, SIGNAL(changedAircraftsInRange()));
Q_ASSERT(s);
s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
"changedAtcStationOnlineConnectionStatus", this, SIGNAL(changedAtcStationOnlineConnectionStatus(BlackMisc::Aviation::CAtcStation, bool)));
Q_ASSERT(s);
s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
"changedAircraftsInRangeDigest", this, SIGNAL(changedAircraftsInRangeDigest()));
Q_ASSERT(s);
s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
"connectionTerminated", this, SIGNAL(connectionTerminated()));
Q_ASSERT(s);