mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 05:26:45 +08:00
Ref T436, allow to set a global offset altitude for testing (example: ".altos ? -10m")
This commit is contained in:
@@ -671,24 +671,20 @@ namespace BlackMisc
|
||||
return m_testOffset.contains(callsign);
|
||||
}
|
||||
|
||||
bool CRemoteAircraftProvider::hasTestAltitudeOffsetGlobalValue() const
|
||||
{
|
||||
QReadLocker l(&m_lockSituations);
|
||||
return m_testOffset.contains(testAltitudeOffsetCallsign());
|
||||
}
|
||||
|
||||
CAircraftSituation CRemoteAircraftProvider::addTestAltitudeOffsetToSituation(const CAircraftSituation &situation) const
|
||||
{
|
||||
// for global offset testing set "true"
|
||||
constexpr bool globalOffsetTest = false;
|
||||
|
||||
const CCallsign cs(situation.getCallsign());
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (!globalOffsetTest && !this->hasTestAltitudeOffset(cs)) { return situation; }
|
||||
CLength os;
|
||||
if (globalOffsetTest)
|
||||
{
|
||||
os = CLength(100, CLengthUnit::ft());
|
||||
}
|
||||
else
|
||||
{
|
||||
QReadLocker l(&m_lockSituations);
|
||||
os = m_testOffset.value(cs);
|
||||
}
|
||||
const bool globalOffset = this->hasTestAltitudeOffsetGlobalValue();
|
||||
if (!globalOffset && !this->hasTestAltitudeOffset(cs)) { return situation; }
|
||||
|
||||
QReadLocker l(&m_lockSituations);
|
||||
const CLength os = m_testOffset.contains(cs) ? m_testOffset.value(cs) : m_testOffset.value(testAltitudeOffsetCallsign());
|
||||
if (os.isNull() || os.isZeroEpsilonConsidered()) { return situation; }
|
||||
return situation.withAltitudeOffset(os);
|
||||
}
|
||||
@@ -1047,5 +1043,11 @@ namespace BlackMisc
|
||||
partsList.removeBefore(ts);
|
||||
Q_ASSERT_X(partsList.size() >= 1, Q_FUNC_INFO, "Need at least 1 value");
|
||||
}
|
||||
|
||||
const CCallsign &IRemoteAircraftProvider::testAltitudeOffsetCallsign()
|
||||
{
|
||||
static const CCallsign wildcard("ZZZZ");
|
||||
return wildcard;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -259,6 +259,9 @@ namespace BlackMisc
|
||||
//! Remove outdated aircraft parts, but never the most recent one
|
||||
static void removeOutdatedParts(Aviation::CAircraftPartsList &partsList);
|
||||
|
||||
//! Wildcard callsign
|
||||
static const Aviation::CCallsign &testAltitudeOffsetCallsign();
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
IRemoteAircraftProvider();
|
||||
@@ -369,6 +372,9 @@ namespace BlackMisc
|
||||
//! Has test offset value?
|
||||
bool hasTestAltitudeOffset(const Aviation::CCallsign &callsign) const;
|
||||
|
||||
//! Has test offset value?
|
||||
bool hasTestAltitudeOffsetGlobalValue() const;
|
||||
|
||||
//! Offset for callsign
|
||||
bool testAddAltitudeOffset(const Aviation::CCallsign &callsign, const PhysicalQuantities::CLength &offset);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user