mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 02:35:38 +08:00
Send distance if own aircraft has been moved
This commit is contained in:
committed by
Mat Sutcliffe
parent
8278a7d5e6
commit
668659248e
@@ -104,7 +104,7 @@ namespace BlackCore
|
|||||||
void changedPilot(const BlackMisc::Network::CUser &pilot);
|
void changedPilot(const BlackMisc::Network::CUser &pilot);
|
||||||
|
|
||||||
//! Aircraft has been moved from one location to another (changed scenery)
|
//! Aircraft has been moved from one location to another (changed scenery)
|
||||||
void movedAircraft();
|
void movedAircraft(const BlackMisc::PhysicalQuantities::CLength &distance);
|
||||||
|
|
||||||
//! Just airborne
|
//! Just airborne
|
||||||
void isTakingOff();
|
void isTakingOff();
|
||||||
|
|||||||
@@ -193,16 +193,20 @@ namespace BlackCore
|
|||||||
|
|
||||||
// using copy to minimize lock time
|
// using copy to minimize lock time
|
||||||
// 500km/h => 1sec: 0.1388 km
|
// 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());
|
static const CLength maxDistance(25, CLengthUnit::km());
|
||||||
|
const CAircraftSituation latest = situations.front();
|
||||||
const bool jumpDetected = situations.containsObjectOutsideRange(situations.front(), maxDistance);
|
const bool jumpDetected = situations.containsObjectOutsideRange(situations.front(), maxDistance);
|
||||||
|
|
||||||
if (jumpDetected)
|
if (jumpDetected)
|
||||||
{
|
{
|
||||||
|
const CAircraftSituationList ownDistances = situations.findFarthest(1, latest);
|
||||||
|
const CLength distance = ownDistances.front().calculateGreatCircleDistance(latest);
|
||||||
{
|
{
|
||||||
QWriteLocker wl(&m_lockAircraft);
|
QWriteLocker wl(&m_lockAircraft);
|
||||||
m_situationHistory.clear();
|
m_situationHistory.clear();
|
||||||
}
|
}
|
||||||
emit this->movedAircraft();
|
emit this->movedAircraft(distance);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace BlackCore
|
|||||||
"changedPilot", this, SIGNAL(changedPilot(BlackMisc::Network::CUser)));
|
"changedPilot", this, SIGNAL(changedPilot(BlackMisc::Network::CUser)));
|
||||||
Q_ASSERT(s);
|
Q_ASSERT(s);
|
||||||
s = connection.connect(serviceName, IContextOwnAircraft::ObjectPath(), IContextOwnAircraft::InterfaceName(),
|
s = connection.connect(serviceName, IContextOwnAircraft::ObjectPath(), IContextOwnAircraft::InterfaceName(),
|
||||||
"movedAircraft", this, SIGNAL(movedAircraft()));
|
"movedAircraft", this, SIGNAL(movedAircraft(BlackMisc::PhysicalQuantities::CLength)));
|
||||||
Q_ASSERT(s);
|
Q_ASSERT(s);
|
||||||
s = connection.connect(serviceName, IContextOwnAircraft::ObjectPath(), IContextOwnAircraft::InterfaceName(),
|
s = connection.connect(serviceName, IContextOwnAircraft::ObjectPath(), IContextOwnAircraft::InterfaceName(),
|
||||||
"isTakingOff", this, SIGNAL(isTakingOff()));
|
"isTakingOff", this, SIGNAL(isTakingOff()));
|
||||||
@@ -61,7 +61,7 @@ namespace BlackCore
|
|||||||
Q_ASSERT(s);
|
Q_ASSERT(s);
|
||||||
|
|
||||||
this->relayBaseClassSignals(serviceName, connection, IContextOwnAircraft::ObjectPath(), IContextOwnAircraft::InterfaceName());
|
this->relayBaseClassSignals(serviceName, connection, IContextOwnAircraft::ObjectPath(), IContextOwnAircraft::InterfaceName());
|
||||||
Q_UNUSED(s);
|
Q_UNUSED(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
void CContextOwnAircraftProxy::unitTestRelaySignals()
|
void CContextOwnAircraftProxy::unitTestRelaySignals()
|
||||||
@@ -69,7 +69,7 @@ namespace BlackCore
|
|||||||
// connect signals, asserts when failures
|
// connect signals, asserts when failures
|
||||||
QDBusConnection con = QDBusConnection::sessionBus();
|
QDBusConnection con = QDBusConnection::sessionBus();
|
||||||
CContextOwnAircraftProxy c(CDBusServer::coreServiceName(), con, CCoreFacadeConfig::Remote, nullptr);
|
CContextOwnAircraftProxy c(CDBusServer::coreServiceName(), con, CCoreFacadeConfig::Remote, nullptr);
|
||||||
Q_UNUSED(c);
|
Q_UNUSED(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
BlackMisc::Simulation::CSimulatedAircraft CContextOwnAircraftProxy::getOwnAircraft() const
|
BlackMisc::Simulation::CSimulatedAircraft CContextOwnAircraftProxy::getOwnAircraft() const
|
||||||
|
|||||||
@@ -187,8 +187,9 @@ namespace BlackGui
|
|||||||
m_updateTimer.setInterval(ms);
|
m_updateTimer.setInterval(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAircraftComponent::onOwnAircraftMoved()
|
void CAircraftComponent::onOwnAircraftMoved(const CLength &distance)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(distance)
|
||||||
this->updateViews();
|
this->updateViews();
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ namespace BlackGui
|
|||||||
void onSettingsChanged();
|
void onSettingsChanged();
|
||||||
|
|
||||||
//! Own aircraft has been moved
|
//! Own aircraft has been moved
|
||||||
void onOwnAircraftMoved();
|
void onOwnAircraftMoved(const BlackMisc::PhysicalQuantities::CLength &distance);
|
||||||
|
|
||||||
QScopedPointer<Ui::CAircraftComponent> ui;
|
QScopedPointer<Ui::CAircraftComponent> ui;
|
||||||
BlackMisc::CSettingReadOnly<BlackGui::Settings::TViewUpdateSettings> m_settings { this, &CAircraftComponent::onSettingsChanged }; //!< settings changed
|
BlackMisc::CSettingReadOnly<BlackGui::Settings::TViewUpdateSettings> m_settings { this, &CAircraftComponent::onSettingsChanged }; //!< settings changed
|
||||||
|
|||||||
@@ -197,6 +197,17 @@ namespace BlackMisc
|
|||||||
return closest;
|
return closest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class OBJ, class CONTAINER>
|
||||||
|
CONTAINER IGeoObjectList<OBJ, CONTAINER>::findFarthest(int number, const ICoordinateGeodetic &coordinate) const
|
||||||
|
{
|
||||||
|
CONTAINER farthest = this->container().partiallySorted(number, [ & ](const OBJ & a, const OBJ & b)
|
||||||
|
{
|
||||||
|
return calculateEuclideanDistanceSquared(a, coordinate) > calculateEuclideanDistanceSquared(b, coordinate);
|
||||||
|
});
|
||||||
|
farthest.truncate(number);
|
||||||
|
return farthest;
|
||||||
|
}
|
||||||
|
|
||||||
template<class OBJ, class CONTAINER>
|
template<class OBJ, class CONTAINER>
|
||||||
OBJ IGeoObjectList<OBJ, CONTAINER>::findClosestWithinRange(const ICoordinateGeodetic &coordinate, const CLength &range) const
|
OBJ IGeoObjectList<OBJ, CONTAINER>::findClosestWithinRange(const ICoordinateGeodetic &coordinate, const CLength &range) const
|
||||||
{
|
{
|
||||||
@@ -225,7 +236,7 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class OBJ, class CONTAINER>
|
template<class OBJ, class CONTAINER>
|
||||||
CONTAINER IGeoObjectList<OBJ, CONTAINER>::sortedByEuclideanDistanceSquared(const ICoordinateGeodetic &coordinate)
|
CONTAINER IGeoObjectList<OBJ, CONTAINER>::sortedByEuclideanDistanceSquared(const ICoordinateGeodetic &coordinate) const
|
||||||
{
|
{
|
||||||
CONTAINER copy(this->container());
|
CONTAINER copy(this->container());
|
||||||
copy.sortByEuclideanDistanceSquared(coordinate);
|
copy.sortByEuclideanDistanceSquared(coordinate);
|
||||||
|
|||||||
@@ -103,6 +103,9 @@ namespace BlackMisc
|
|||||||
//! Find 0..n objects closest to the given coordinate.
|
//! Find 0..n objects closest to the given coordinate.
|
||||||
CONTAINER findClosest(int number, const ICoordinateGeodetic &coordinate) const;
|
CONTAINER findClosest(int number, const ICoordinateGeodetic &coordinate) const;
|
||||||
|
|
||||||
|
//! Find 0..n objects farthest to the given coordinate.
|
||||||
|
CONTAINER findFarthest(int number, const ICoordinateGeodetic &coordinate) const;
|
||||||
|
|
||||||
//! Find closest within range to the given coordinate
|
//! Find closest within range to the given coordinate
|
||||||
OBJ findClosestWithinRange(const ICoordinateGeodetic &coordinate, const PhysicalQuantities::CLength &range) const;
|
OBJ findClosestWithinRange(const ICoordinateGeodetic &coordinate, const PhysicalQuantities::CLength &range) const;
|
||||||
|
|
||||||
@@ -110,7 +113,7 @@ namespace BlackMisc
|
|||||||
void sortByEuclideanDistanceSquared(const ICoordinateGeodetic &coordinate);
|
void sortByEuclideanDistanceSquared(const ICoordinateGeodetic &coordinate);
|
||||||
|
|
||||||
//! Sorted by distance
|
//! Sorted by distance
|
||||||
CONTAINER sortedByEuclideanDistanceSquared(const ICoordinateGeodetic &coordinate);
|
CONTAINER sortedByEuclideanDistanceSquared(const ICoordinateGeodetic &coordinate) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Constructor
|
//! Constructor
|
||||||
|
|||||||
Reference in New Issue
Block a user