mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:15:33 +08:00
refs #395, moved thread safe aircraft parts / situations (from interpolator) to airspace
* access via provider, access now possible also beyond the scope of interpolator * will be used in (to be written airpace analyzer) * renamed some member functions as required * fixed some asserts / Doxygen comments * adjusted unit tests * added vtolAircraft flag for interpolator, not fully used everywhere remarks: update signals for parts / situation still only needed in XP driver
This commit is contained in:
committed by
Mathew Sutcliffe
parent
32e65669a3
commit
48188dd28d
@@ -29,12 +29,6 @@ namespace BlackCore
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Situations per callsign
|
||||
typedef QHash<BlackMisc::Aviation::CCallsign, BlackMisc::Aviation::CAircraftSituationList> CSituationsPerCallsign;
|
||||
|
||||
//! Parts per callsign
|
||||
typedef QHash<BlackMisc::Aviation::CCallsign, BlackMisc::Aviation::CAircraftPartsList> CPartsPerCallsign;
|
||||
|
||||
//! Virtual destructor
|
||||
virtual ~IInterpolator() {}
|
||||
|
||||
@@ -70,79 +64,22 @@ namespace BlackCore
|
||||
//! Current interpolated situation
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
|
||||
const BlackMisc::Aviation::CCallsign &callsign, qint64 currentTimeSinceEpoc,
|
||||
InterpolationStatus &status, const CSituationsPerCallsign *situationsPerCallsign = nullptr) const = 0;
|
||||
|
||||
//! Do a complete calculation for all know callsigns.
|
||||
//! \param currentTimeMsSinceEpoch if no value is passed current time is used
|
||||
//! \threadsafe
|
||||
//!
|
||||
virtual BlackMisc::Aviation::CAircraftSituationList getInterpolatedSituations(qint64 currentTimeMsSinceEpoch = -1);
|
||||
|
||||
//! All situations for all callsigns (in map as per callsign)
|
||||
//! \threadsafe
|
||||
CSituationsPerCallsign getSituationsByCallsign() const;
|
||||
const BlackMisc::Aviation::CCallsign &callsign, qint64 currentTimeSinceEpoc, bool isVtolAircraft, InterpolationStatus &status) const = 0;
|
||||
|
||||
//! Parts before given offset time (aka pending parts)
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Aviation::CAircraftPartsList getAndRemovePartsBeforeTime(const BlackMisc::Aviation::CCallsign &callsign, qint64 cutoffTime, PartsStatus &partsStatus);
|
||||
|
||||
//! Clear all data
|
||||
//! \threadsafe
|
||||
virtual void clear();
|
||||
|
||||
//! Does know callsign?
|
||||
//! \threadsafe
|
||||
virtual bool hasDataForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const;
|
||||
|
||||
//! All situations for given callsign
|
||||
//! \threadsafe
|
||||
BlackMisc::Aviation::CAircraftSituationList getSituationsForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const;
|
||||
|
||||
//! All parts for given callsign
|
||||
//! \threadsafe
|
||||
BlackMisc::Aviation::CAircraftPartsList getPartsForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const;
|
||||
virtual BlackMisc::Aviation::CAircraftPartsList getPartsBeforeTime(const BlackMisc::Aviation::CCallsign &callsign, qint64 cutoffTime, PartsStatus &partsStatus);
|
||||
|
||||
//! Enable debug messages
|
||||
void enableDebugMessages(bool enabled);
|
||||
|
||||
//! Force sorting (latest first), not required if order can be guaranteed
|
||||
void forceSortingOfAddedValues(bool sort);
|
||||
|
||||
static const qint64 TimeOffsetMs = 6000; //!< offset for interpolation
|
||||
static const int MaxSituationsPerCallsign = 6; //!< How many situations per callsign
|
||||
static const int MaxPartsPerCallsign = 3; //!< How many parts per callsign
|
||||
static const int MaxKeptInterpolationRequests = 3; //!< How many requests are stored
|
||||
|
||||
private slots:
|
||||
//! New situation got added
|
||||
//! \threadsafe
|
||||
void ps_onAddedAircraftSituation(const BlackMisc::Aviation::CAircraftSituation &situation);
|
||||
|
||||
//! Added aircraft parts
|
||||
//! \threadsafe
|
||||
void ps_onAddedAircraftParts(const BlackMisc::Aviation::CAircraftParts &parts);
|
||||
|
||||
//! Removed aircraft
|
||||
//! \threadsafe
|
||||
void ps_onRemovedAircraft(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
IInterpolator(BlackMisc::Simulation::IRemoteAircraftProviderReadOnly *provider, const QString &workerName, QObject *parent = nullptr);
|
||||
|
||||
bool m_withDebugMsg = false; //!< allows to disable debug messages
|
||||
bool m_forceSortWhenAddingValues = false; //!< force sorting (latest first) when adding values
|
||||
BlackMisc::Aviation::CCallsignSet m_aircraftSupportingParts; //!< aircraft supporting parts
|
||||
|
||||
// hashs, because not sorted by key but keeping order
|
||||
CSituationsPerCallsign m_situationsByCallsign; //!< situations
|
||||
CPartsPerCallsign m_partsByCallsign; //!< parts
|
||||
|
||||
// locks
|
||||
mutable QReadWriteLock m_lockSituations; //!< lock for situations
|
||||
mutable QReadWriteLock m_lockParts; //!< lock for parts
|
||||
|
||||
bool m_withDebugMsg = false; //!< allows to disable debug messages
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user