mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 23:25:53 +08:00
Emit takeoff/touchdown signals in own aircraft context
This commit is contained in:
committed by
Mat Sutcliffe
parent
892b5919f7
commit
a91d7cb852
@@ -203,30 +203,41 @@ namespace BlackCore
|
||||
{
|
||||
if (!m_history) { return; }
|
||||
if (!this->getIContextSimulator()) { return; }
|
||||
if (!this->getIContextSimulator()->isSimulatorSimulating()) { return; }
|
||||
|
||||
if (this->getIContextSimulator()->isSimulatorSimulating())
|
||||
QReadLocker rl(&m_lockAircraft);
|
||||
const CAircraftSituationList situations = m_situationHistory; // latest first
|
||||
rl.unlock();
|
||||
|
||||
constexpr int minElements = qRound(MaxHistoryElements * 0.75);
|
||||
if (m_situationHistory.size() < minElements) { return; }
|
||||
|
||||
// using copy to minimize lock time
|
||||
// 500km/h => 1sec: 0.1388 km
|
||||
static const CLength maxDistance(25, CLengthUnit::km());
|
||||
const bool jumpDetected = situations.containsObjectOutsideRange(situations.front(), maxDistance);
|
||||
|
||||
if (jumpDetected)
|
||||
{
|
||||
if (!m_situationHistory.isEmpty())
|
||||
{
|
||||
QReadLocker rl(&m_lockAircraft);
|
||||
const CAircraftSituationList situations = m_situationHistory;
|
||||
rl.unlock();
|
||||
|
||||
// using copy to minimize lock time
|
||||
// 500km/h => 1sec: 0.1388 km
|
||||
static const CLength maxDistance(25, CLengthUnit::km());
|
||||
const bool jumpDetected = situations.containsObjectOutsideRange(situations.front(), maxDistance);
|
||||
|
||||
if (jumpDetected)
|
||||
{
|
||||
{
|
||||
QWriteLocker wl(&m_lockAircraft);
|
||||
m_situationHistory.clear();
|
||||
}
|
||||
emit this->movedAircraft();
|
||||
}
|
||||
QWriteLocker wl(&m_lockAircraft);
|
||||
m_situationHistory.clear();
|
||||
}
|
||||
} // only if simulating
|
||||
emit this->movedAircraft();
|
||||
}
|
||||
else
|
||||
{
|
||||
const bool to = situations.isTakingOff(true);
|
||||
if (to)
|
||||
{
|
||||
emit this->isTakingOff();
|
||||
}
|
||||
else
|
||||
{
|
||||
const bool td = situations.isTouchingDown(true);
|
||||
if (td) { emit this->isTouchingDown(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CAircraftModel CContextOwnAircraft::reverseLookupModel(const CAircraftModel &model)
|
||||
|
||||
Reference in New Issue
Block a user