mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T436, allow to set a global offset altitude for testing (example: ".altos ? -10m")
This commit is contained in:
@@ -364,11 +364,20 @@ namespace BlackCore
|
||||
if (!m_airspace) { return false; }
|
||||
if (parser.countParts() < 2) { return false; }
|
||||
|
||||
const CCallsign cs(parser.part(1));
|
||||
if (!m_airspace->isAircraftInRange(cs))
|
||||
const QString csPart(parser.part(1));
|
||||
CCallsign cs;
|
||||
if (csPart.contains('?'))
|
||||
{
|
||||
CLogMessage(this).validationError("Altitude offset unknown callsign");
|
||||
return false;
|
||||
cs = IRemoteAircraftProvider::testAltitudeOffsetCallsign(); // wildcard
|
||||
}
|
||||
else
|
||||
{
|
||||
cs = CCallsign(csPart);
|
||||
if (!m_airspace->isAircraftInRange(cs))
|
||||
{
|
||||
CLogMessage(this).validationError("Altitude offset unknown callsign");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
CLength os(CLength::null());
|
||||
|
||||
@@ -223,7 +223,7 @@ namespace BlackCore
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".m", "alias: .msg"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".m message text", "send text message"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".m callsign message text", "send text message"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".altos callsign offsetvalue", "set altitude offset value (testing)"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".altos callsign|? offsetvalue", "set altitude offset value (testing)"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".watchdog on|off", "enable/disable network watchdog (testing)"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".wallop message", "send a wallop message"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".reinit", "re-initialize all aircraft"});
|
||||
|
||||
@@ -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