mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
Ref T280, using the QHash<CCallsign, T> definitions to unify use cases
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QHash>
|
||||
#include <QMetaObject>
|
||||
#include <QObject>
|
||||
#include <QReadWriteLock>
|
||||
@@ -167,9 +167,8 @@ namespace BlackCore
|
||||
|
||||
BlackMisc::Aviation::CAtcStationList m_atcStationsOnline; //!< online ATC stations
|
||||
BlackMisc::Aviation::CAtcStationList m_atcStationsBooked; //!< booked ATC stations
|
||||
QMap<BlackMisc::Aviation::CCallsign, FsInnPacket> m_tempFsInnPackets;
|
||||
|
||||
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Aviation::CFlightPlan> m_flightPlanCache; //!< flight plan information retrieved from network and cached
|
||||
QHash<BlackMisc::Aviation::CCallsign, FsInnPacket> m_tempFsInnPackets;
|
||||
QHash<BlackMisc::Aviation::CCallsign, BlackMisc::Aviation::CFlightPlan> m_flightPlanCache; //!< flight plan information retrieved from network and cached
|
||||
|
||||
INetwork *m_network = nullptr; //!< corresponding network interface
|
||||
CAirspaceAnalyzer *m_analyzer = nullptr; //!< owned analyzer
|
||||
|
||||
@@ -739,9 +739,9 @@ namespace BlackCore
|
||||
bool CSimulatorCommon::isEqualLastSent(const CAircraftSituation &compare) const
|
||||
{
|
||||
Q_ASSERT_X(compare.hasCallsign(), Q_FUNC_INFO, "Need callsign");
|
||||
if (!m_lastSentSituation.contains(compare.getCallsign())) { return false; }
|
||||
if (!m_lastSentSituations.contains(compare.getCallsign())) { return false; }
|
||||
if (compare.isNull()) { return false; }
|
||||
return compare.equalPbhAndVector(m_lastSentSituation.value(compare.getCallsign()));
|
||||
return compare.equalPbhAndVector(m_lastSentSituations.value(compare.getCallsign()));
|
||||
}
|
||||
|
||||
bool CSimulatorCommon::isEqualLastSent(const CAircraftParts &compare, const CCallsign &callsign) const
|
||||
@@ -754,7 +754,7 @@ namespace BlackCore
|
||||
void CSimulatorCommon::rememberLastSent(const CAircraftSituation &sent)
|
||||
{
|
||||
Q_ASSERT_X(sent.hasCallsign(), Q_FUNC_INFO, "Need callsign");
|
||||
m_lastSentSituation.insert(sent.getCallsign(), sent);
|
||||
m_lastSentSituations.insert(sent.getCallsign(), sent);
|
||||
}
|
||||
|
||||
void CSimulatorCommon::rememberLastSent(const CAircraftParts &sent, const CCallsign &callsign)
|
||||
@@ -846,7 +846,7 @@ namespace BlackCore
|
||||
m_callsignsToBeRendered.clear();
|
||||
m_clampedLogMsg.clear();
|
||||
m_lastSentParts.clear();
|
||||
m_lastSentSituation.clear();
|
||||
m_lastSentSituations.clear();
|
||||
m_updateRemoteAircraftInProgress = false;
|
||||
|
||||
this->resetHighlighting();
|
||||
@@ -891,7 +891,7 @@ namespace BlackCore
|
||||
m_statsPhysicallyRemovedAircraft++;
|
||||
m_clampedLogMsg.clear();
|
||||
m_lastSentParts.remove(remoteCallsign);
|
||||
m_lastSentSituation.remove(remoteCallsign);
|
||||
m_lastSentSituations.remove(remoteCallsign);
|
||||
m_clampedLogMsg.remove(remoteCallsign);
|
||||
this->physicallyRemoveRemoteAircraft(remoteCallsign);
|
||||
}
|
||||
|
||||
@@ -283,9 +283,9 @@ namespace BlackCore
|
||||
|
||||
BlackMisc::Simulation::CSimulatorInternals m_simulatorInternals; //!< setup object
|
||||
BlackMisc::Simulation::CInterpolationLogger m_interpolationLogger; //!< log.interpolation
|
||||
QMap<BlackMisc::Aviation::CCallsign, qint64> m_clampedLogMsg; //!< when logged last for this callsign, can be used so there is no log message overflow
|
||||
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Aviation::CAircraftSituation> m_lastSentSituation; //!< last situation sent to simulator
|
||||
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Aviation::CAircraftParts> m_lastSentParts; //!< last parts sent to simulator
|
||||
BlackMisc::Aviation::CTimestampPerCallsign m_clampedLogMsg; //!< when logged last for this callsign, can be used so there is no log message overflow
|
||||
BlackMisc::Aviation::CAircraftSituationPerCallsign m_lastSentSituations; //!< last situation sent to simulator
|
||||
BlackMisc::Aviation::CAircraftPartsPerCallsign m_lastSentParts; //!< last parts sent to simulator
|
||||
|
||||
// some optional functionality which can be used by the simulators as needed
|
||||
BlackMisc::Simulation::CSimulatedAircraftList m_addAgainAircraftWhenRemoved; //!< add this model again when removed, normally used to change model
|
||||
|
||||
@@ -28,9 +28,9 @@ namespace BlackMisc
|
||||
|
||||
void CClientProvider::setClients(const CClientList &clients)
|
||||
{
|
||||
const QMap<CCallsign, CClient> map = clients.asMap();
|
||||
const CClientPerCallsign perCallsign(clients.asCallsignHash());
|
||||
QWriteLocker l(&m_lockClient);
|
||||
m_clients = map;
|
||||
m_clients = perCallsign;
|
||||
}
|
||||
|
||||
void CClientProvider::clearClients()
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace BlackMisc
|
||||
//! @}
|
||||
|
||||
private:
|
||||
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Network::CClient> m_clients;
|
||||
CClientPerCallsign m_clients;
|
||||
mutable QReadWriteLock m_lockClient; //!< lock clients: m_clients
|
||||
};
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "blackmisc/aviation/aircraftpartslist.h"
|
||||
#include "blackmisc/aviation/aircraftsituationlist.h"
|
||||
#include "blackmisc/aviation/aircraftsituationchange.h"
|
||||
#include "blackmisc/aviation/percallsign.h"
|
||||
#include "blackmisc/aviation/callsignset.h"
|
||||
#include "blackmisc/provider.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
@@ -50,12 +51,6 @@ namespace BlackMisc
|
||||
static constexpr int MaxPartsAgePerCallsignSecs = 60; //!< How many seconds to keep parts for interpolation
|
||||
static constexpr int DefaultOffsetTimeMs = 6000; //!< \fixme copied from CNetworkVatlib::c_positionTimeOffsetMsec
|
||||
|
||||
//! Situations per callsign
|
||||
using CSituationsPerCallsign = QHash<Aviation::CCallsign, Aviation::CAircraftSituationList>;
|
||||
|
||||
//! Parts per callsign
|
||||
using CPartsPerCallsign = QHash<Aviation::CCallsign, Aviation::CAircraftPartsList>;
|
||||
|
||||
//! All remote aircraft
|
||||
//! \threadsafe
|
||||
virtual CSimulatedAircraftList getAircraftInRange() const = 0;
|
||||
@@ -378,19 +373,18 @@ namespace BlackMisc
|
||||
Aviation::CAircraftSituation testAddAltitudeOffsetToSituation(const Aviation::CAircraftSituation &situation) const;
|
||||
|
||||
private:
|
||||
// hashs, because not sorted by key but keeping order
|
||||
CSituationsPerCallsign m_situationsByCallsign; //!< situations, for performance reasons per callsign, thread safe access required
|
||||
CPartsPerCallsign m_partsByCallsign; //!< parts, for performance reasons per callsign, thread safe access required
|
||||
Aviation::CCallsignSet m_aircraftWithParts; //!< aircraft supporting parts, thread safe access required
|
||||
Aviation::CAircraftSituationListPerCallsign m_situationsByCallsign; //!< situations, for performance reasons per callsign, thread safe access required
|
||||
Aviation::CAircraftPartsListPerCallsign m_partsByCallsign; //!< parts, for performance reasons per callsign, thread safe access required
|
||||
Aviation::CCallsignSet m_aircraftWithParts; //!< aircraft supporting parts, thread safe access required
|
||||
int m_situationsAdded = 0; //!< total number of situations added, thread safe access required
|
||||
int m_partsAdded = 0; //!< total number of parts added, thread safe access required
|
||||
|
||||
CSimulatedAircraftList m_aircraftInRange; //!< aircraft, thread safe access required
|
||||
QMap<Aviation::CCallsign, CStatusMessageList> m_reverseLookupMessages;
|
||||
QMap<Aviation::CCallsign, CStatusMessageList> m_aircraftPartsHistory; //!< JSON aircraft parts history
|
||||
QMap<Aviation::CCallsign, qint64> m_situationsLastModified;
|
||||
QMap<Aviation::CCallsign, qint64> m_partsLastModified;
|
||||
QMap<Aviation::CCallsign, PhysicalQuantities::CLength> m_testOffset;
|
||||
Aviation::CStatusMessageListPerCallsign m_reverseLookupMessages; //!< reverse lookup messages
|
||||
Aviation::CStatusMessageListPerCallsign m_aircraftPartsHistory; //!< status messages for parts history
|
||||
Aviation::CTimestampPerCallsign m_situationsLastModified; //!< when situations last modified
|
||||
Aviation::CTimestampPerCallsign m_partsLastModified; //!< when parts last modified
|
||||
QHash<Aviation::CCallsign, PhysicalQuantities::CLength> m_testOffset;
|
||||
|
||||
bool m_enableReverseLookupMsgs = false; //!< shall we log. information about the matching process
|
||||
bool m_enableAircraftPartsHistory = true; //!< shall we keep a history of aircraft parts
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace BlackMisc
|
||||
CElevationPlane ISimulationEnvironmentProvider::findClosestElevationWithinRange(const ICoordinateGeodetic &reference, const CLength &range) const
|
||||
{
|
||||
// for single point we use a slightly optimized version
|
||||
const bool singlePoint = (range <= CElevationPlane::singlePointRadius());
|
||||
const bool singlePoint = (&range == &CElevationPlane::singlePointRadius() || range <= CElevationPlane::singlePointRadius());
|
||||
const CCoordinateGeodetic coordinate = singlePoint ?
|
||||
this->getElevationCoordinates().findFirstWithinRangeOrDefault(reference, CElevationPlane::singlePointRadius()) :
|
||||
this->getElevationCoordinates().findClosestWithinRange(reference, range);
|
||||
|
||||
@@ -593,7 +593,7 @@ namespace BlackSimPlugin
|
||||
|
||||
// Near ground we use faster updates
|
||||
const CCallsign cs(simObject.getCallsign());
|
||||
const CAircraftSituation lastSituation = m_lastSentSituation[cs];
|
||||
const CAircraftSituation lastSituation = m_lastSentSituations[cs];
|
||||
const bool moving = lastSituation.isMoving();
|
||||
if (moving && remoteAircraftData.aboveGroundFt() <= 100.0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user