mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 19:35:32 +08:00
Emit takeoff/touchdown signals in own aircraft context
This commit is contained in:
committed by
Mat Sutcliffe
parent
892b5919f7
commit
a91d7cb852
@@ -107,10 +107,10 @@ namespace BlackCore
|
||||
void movedAircraft();
|
||||
|
||||
//! Just airborne
|
||||
void airborne();
|
||||
void isTakingOff();
|
||||
|
||||
//! Just landed
|
||||
void touchdown();
|
||||
void isTouchingDown();
|
||||
|
||||
public slots:
|
||||
//! Get own aircraft
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -54,10 +54,10 @@ namespace BlackCore
|
||||
"movedAircraft", this, SIGNAL(movedAircraft()));
|
||||
Q_ASSERT(s);
|
||||
s = connection.connect(serviceName, IContextOwnAircraft::ObjectPath(), IContextOwnAircraft::InterfaceName(),
|
||||
"airborne", this, SIGNAL(airborne()));
|
||||
"isTakingOff", this, SIGNAL(isTakingOff()));
|
||||
Q_ASSERT(s);
|
||||
s = connection.connect(serviceName, IContextOwnAircraft::ObjectPath(), IContextOwnAircraft::InterfaceName(),
|
||||
"touchdown", this, SIGNAL(touchdown()));
|
||||
"isTouchingDown", this, SIGNAL(isTouchingDown()));
|
||||
Q_ASSERT(s);
|
||||
|
||||
this->relayBaseClassSignals(serviceName, connection, IContextOwnAircraft::ObjectPath(), IContextOwnAircraft::InterfaceName());
|
||||
|
||||
Reference in New Issue
Block a user