Send distance if own aircraft has been moved

This commit is contained in:
Klaus Basan
2020-04-16 23:46:40 +02:00
committed by Mat Sutcliffe
parent 8278a7d5e6
commit 668659248e
7 changed files with 32 additions and 13 deletions

View File

@@ -104,7 +104,7 @@ namespace BlackCore
void changedPilot(const BlackMisc::Network::CUser &pilot);
//! Aircraft has been moved from one location to another (changed scenery)
void movedAircraft();
void movedAircraft(const BlackMisc::PhysicalQuantities::CLength &distance);
//! Just airborne
void isTakingOff();

View File

@@ -193,16 +193,20 @@ namespace BlackCore
// using copy to minimize lock time
// 500km/h => 1sec: 0.1388 km
// we check if there are situation for own aircraft outside the max.distance
static const CLength maxDistance(25, CLengthUnit::km());
const CAircraftSituation latest = situations.front();
const bool jumpDetected = situations.containsObjectOutsideRange(situations.front(), maxDistance);
if (jumpDetected)
{
const CAircraftSituationList ownDistances = situations.findFarthest(1, latest);
const CLength distance = ownDistances.front().calculateGreatCircleDistance(latest);
{
QWriteLocker wl(&m_lockAircraft);
m_situationHistory.clear();
}
emit this->movedAircraft();
emit this->movedAircraft(distance);
}
else
{

View File

@@ -51,7 +51,7 @@ namespace BlackCore
"changedPilot", this, SIGNAL(changedPilot(BlackMisc::Network::CUser)));
Q_ASSERT(s);
s = connection.connect(serviceName, IContextOwnAircraft::ObjectPath(), IContextOwnAircraft::InterfaceName(),
"movedAircraft", this, SIGNAL(movedAircraft()));
"movedAircraft", this, SIGNAL(movedAircraft(BlackMisc::PhysicalQuantities::CLength)));
Q_ASSERT(s);
s = connection.connect(serviceName, IContextOwnAircraft::ObjectPath(), IContextOwnAircraft::InterfaceName(),
"isTakingOff", this, SIGNAL(isTakingOff()));
@@ -61,7 +61,7 @@ namespace BlackCore
Q_ASSERT(s);
this->relayBaseClassSignals(serviceName, connection, IContextOwnAircraft::ObjectPath(), IContextOwnAircraft::InterfaceName());
Q_UNUSED(s);
Q_UNUSED(s)
}
void CContextOwnAircraftProxy::unitTestRelaySignals()
@@ -69,7 +69,7 @@ namespace BlackCore
// connect signals, asserts when failures
QDBusConnection con = QDBusConnection::sessionBus();
CContextOwnAircraftProxy c(CDBusServer::coreServiceName(), con, CCoreFacadeConfig::Remote, nullptr);
Q_UNUSED(c);
Q_UNUSED(c)
}
BlackMisc::Simulation::CSimulatedAircraft CContextOwnAircraftProxy::getOwnAircraft() const