mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 21:56:43 +08:00
Ref T260, function to add an offset to received situations for testing
* "dot" command * context function * provider functions
This commit is contained in:
committed by
Roland Winklmeier
parent
456cb5d1ea
commit
eb0fa92e7e
@@ -164,21 +164,26 @@ namespace BlackMisc
|
||||
|
||||
void CRemoteAircraftProvider::storeAircraftSituation(const CAircraftSituation &situation)
|
||||
{
|
||||
if (situation.getCallsign().isEmpty()) { return; }
|
||||
const CCallsign cs = situation.getCallsign();
|
||||
if (cs.isEmpty()) { return; }
|
||||
const qint64 ts = QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
// for testing only
|
||||
CAircraftSituation situationOs(situation);
|
||||
this->testAddAltitudeOffsetToSituation(situationOs);
|
||||
|
||||
// list from new to old
|
||||
QWriteLocker lock(&m_lockSituations);
|
||||
m_situationsAdded++;
|
||||
m_situationsLastModified[situation.getCallsign()] = ts;
|
||||
CAircraftSituationList &situationList = m_situationsByCallsign[situation.getCallsign()];
|
||||
m_situationsLastModified[cs] = ts;
|
||||
CAircraftSituationList &situationList = m_situationsByCallsign[cs];
|
||||
if (situationList.isEmpty())
|
||||
{
|
||||
situationList.prefillLatestAdjustedFirst(situation, IRemoteAircraftProvider::MaxSituationsPerCallsign);
|
||||
situationList.prefillLatestAdjustedFirst(situationOs, IRemoteAircraftProvider::MaxSituationsPerCallsign);
|
||||
}
|
||||
else
|
||||
{
|
||||
situationList.push_frontKeepLatestFirstAdjustOffset(situation, IRemoteAircraftProvider::MaxSituationsPerCallsign);
|
||||
situationList.push_frontKeepLatestFirstAdjustOffset(situationOs, IRemoteAircraftProvider::MaxSituationsPerCallsign);
|
||||
}
|
||||
|
||||
// unify all inbound ground information
|
||||
@@ -420,6 +425,28 @@ namespace BlackMisc
|
||||
this->removeAllAircraft();
|
||||
}
|
||||
|
||||
bool CRemoteAircraftProvider::hasTestAltitudeOffset(const CCallsign &callsign) const
|
||||
{
|
||||
if (callsign.isEmpty()) { return false; }
|
||||
QReadLocker l(&m_lockSituations);
|
||||
return m_testOffset.contains(callsign);
|
||||
}
|
||||
|
||||
bool CRemoteAircraftProvider::testAddAltitudeOffsetToSituation(CAircraftSituation &situation) const
|
||||
{
|
||||
if (!this->hasTestAltitudeOffset(situation.getCallsign())) { return false; }
|
||||
const CCallsign cs(situation.getCallsign());
|
||||
|
||||
CLength os;
|
||||
{
|
||||
QReadLocker l(&m_lockSituations);
|
||||
os = m_testOffset.value(cs);
|
||||
}
|
||||
const CAltitude newAlt = situation.getAltitude().withOffset(os);
|
||||
situation.setAltitude(newAlt);
|
||||
return true;
|
||||
}
|
||||
|
||||
CStatusMessageList CRemoteAircraftProvider::getAircraftPartsHistory(const CCallsign &callsign) const
|
||||
{
|
||||
QReadLocker l(&m_lockPartsHistory);
|
||||
@@ -456,6 +483,20 @@ namespace BlackMisc
|
||||
return m_partsLastModified.value(callsign, -1);
|
||||
}
|
||||
|
||||
bool CRemoteAircraftProvider::testAddAltitudeOffset(const CCallsign &callsign, const CLength &offset)
|
||||
{
|
||||
const bool remove = offset.isNull() || offset.isZeroEpsilonConsidered();
|
||||
QWriteLocker l(&m_lockSituations);
|
||||
if (remove)
|
||||
{
|
||||
m_testOffset.remove(callsign);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_testOffset[callsign] = offset;
|
||||
return true;
|
||||
}
|
||||
|
||||
int CRemoteAircraftProvider::aircraftPartsAdded() const
|
||||
{
|
||||
QReadLocker l(&m_lockParts);
|
||||
|
||||
@@ -295,6 +295,14 @@ namespace BlackMisc
|
||||
//! Clear all data
|
||||
void clear();
|
||||
|
||||
// ------------------- testing ---------------
|
||||
|
||||
//! Has test offset value?
|
||||
bool hasTestAltitudeOffset(const Aviation::CCallsign &callsign) const;
|
||||
|
||||
//! Offset for callsign
|
||||
bool testAddAltitudeOffset(const Aviation::CCallsign &callsign, const PhysicalQuantities::CLength &offset);
|
||||
|
||||
signals:
|
||||
//! A new aircraft appeared
|
||||
void addedAircraft(const CSimulatedAircraft &remoteAircraft);
|
||||
@@ -356,6 +364,9 @@ namespace BlackMisc
|
||||
void storeAircraftParts(const Aviation::CCallsign &callsign, const QJsonObject &jsonObject, int currentOffset);
|
||||
//! @}
|
||||
|
||||
//! Add an offset for testing
|
||||
bool testAddAltitudeOffsetToSituation(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
|
||||
@@ -369,6 +380,7 @@ namespace BlackMisc
|
||||
QMap<Aviation::CCallsign, CStatusMessageList> m_aircraftPartsHistory;
|
||||
QMap<Aviation::CCallsign, qint64> m_situationsLastModified;
|
||||
QMap<Aviation::CCallsign, qint64> m_partsLastModified;
|
||||
QMap<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
|
||||
|
||||
Reference in New Issue
Block a user