mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
Ref T231, Ref T236, Ref T238 improvements based on Unit test
* check for a correct callsign (assert) * set callsign if missing (fallback) * resetLastInterpolation - null last inperpolation
This commit is contained in:
@@ -29,6 +29,10 @@ namespace BlackMisc
|
||||
CAircraftSituation::CAircraftSituation()
|
||||
: m_groundElevation( { 0, nullptr }, CAltitude::MeanSeaLevel) {}
|
||||
|
||||
CAircraftSituation::CAircraftSituation(const CCallsign &correspondingCallsign)
|
||||
: m_correspondingCallsign(correspondingCallsign), m_groundElevation( { 0, nullptr }, CAltitude::MeanSeaLevel)
|
||||
{}
|
||||
|
||||
CAircraftSituation::CAircraftSituation(const CCoordinateGeodetic &position, const CHeading &heading, const CAngle &pitch, const CAngle &bank, const CSpeed &gs, const CAltitude &groundElevation)
|
||||
: m_position(position), m_heading(heading), m_pitch(pitch),
|
||||
m_bank(bank), m_groundSpeed(gs), m_groundElevation(groundElevation)
|
||||
@@ -167,6 +171,23 @@ namespace BlackMisc
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CAircraftSituation::isNull() const
|
||||
{
|
||||
return this->isPositionNull();
|
||||
}
|
||||
|
||||
void CAircraftSituation::setNull()
|
||||
{
|
||||
m_position.setNull();
|
||||
m_pressureAltitude.setNull();
|
||||
m_heading.setNull();
|
||||
m_pitch.setNull();
|
||||
m_bank.setNull();
|
||||
m_groundElevation.setNull();
|
||||
m_groundSpeed.setNull();
|
||||
m_onGroundReliability = CAircraftSituation::OnGroundReliabilityNoSet;
|
||||
}
|
||||
|
||||
const QString &CAircraftSituation::isOnGroundAsString() const
|
||||
{
|
||||
return CAircraftSituation::isOnGroundToString(this->isOnGround());
|
||||
|
||||
@@ -85,6 +85,9 @@ namespace BlackMisc
|
||||
//! Default constructor.
|
||||
CAircraftSituation();
|
||||
|
||||
//! Constructor with callsign
|
||||
CAircraftSituation(const CCallsign &correspondingCallsign);
|
||||
|
||||
//! Comprehensive constructor
|
||||
CAircraftSituation(const Geo::CCoordinateGeodetic &position,
|
||||
const CHeading &heading = {},
|
||||
@@ -117,6 +120,12 @@ namespace BlackMisc
|
||||
//! Position null?
|
||||
bool isPositionNull() const { return m_position.isNull(); }
|
||||
|
||||
//! Null situation
|
||||
virtual bool isNull() const override;
|
||||
|
||||
//! Set to null
|
||||
void setNull();
|
||||
|
||||
//! Set position
|
||||
void setPosition(const Geo::CCoordinateGeodetic &position) { m_position = position; }
|
||||
|
||||
|
||||
@@ -57,13 +57,20 @@ namespace BlackMisc
|
||||
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints,
|
||||
CInterpolationStatus &status)
|
||||
{
|
||||
Q_ASSERT_X(!m_callsign.isEmpty(), Q_FUNC_INFO, "Missing callsign");
|
||||
|
||||
// this code is used by linear and spline interpolator
|
||||
status.reset();
|
||||
CInterpolationLogger::SituationLog log;
|
||||
|
||||
// any data at all?
|
||||
if (m_aircraftSituations.isEmpty()) { return {}; }
|
||||
if (m_aircraftSituations.isEmpty()) { return CAircraftSituation(m_callsign); }
|
||||
CAircraftSituation currentSituation = m_lastInterpolation.isNull() ? m_aircraftSituations.front() : m_lastInterpolation;
|
||||
if (currentSituation.getCallsign() != m_callsign)
|
||||
{
|
||||
BLACK_VERIFY_X(false, Q_FUNC_INFO, "Wrong callsign");
|
||||
currentSituation.setCallsign(m_callsign);
|
||||
}
|
||||
|
||||
// Update current position by hints' elevation
|
||||
// * for XP provided by hints.getElevationProvider at current position
|
||||
@@ -296,8 +303,12 @@ namespace BlackMisc
|
||||
template <typename Derived>
|
||||
void CInterpolator<Derived>::addAircraftSituation(const CAircraftSituation &situation)
|
||||
{
|
||||
Q_ASSERT_X(!m_callsign.isEmpty(), Q_FUNC_INFO, "Empty callsign");
|
||||
Q_ASSERT_X(situation.getCallsign() == m_callsign, Q_FUNC_INFO, "Wrong callsign");
|
||||
if (m_aircraftSituations.isEmpty())
|
||||
{
|
||||
this->resetLastInterpolation(); // delete any leftover
|
||||
|
||||
// make sure we have enough situations to do start interpolating immediately without waiting for more updates
|
||||
m_aircraftSituations = { situation, situation };
|
||||
m_aircraftSituations.back().addMsecs(-10000); // number here does
|
||||
@@ -337,6 +348,12 @@ namespace BlackMisc
|
||||
boolToYesNo(m_lastInterpolation.isNull());
|
||||
}
|
||||
|
||||
template<typename Derived>
|
||||
void CInterpolator<Derived>::resetLastInterpolation()
|
||||
{
|
||||
m_lastInterpolation.setNull();
|
||||
}
|
||||
|
||||
template <typename Derived>
|
||||
void CInterpolator<Derived>::setGroundElevationFromHint(const CInterpolationHints &hints, CAircraftSituation &situation, bool override)
|
||||
{
|
||||
|
||||
@@ -82,6 +82,10 @@ namespace BlackMisc
|
||||
//! Get an interpolator info string (for debug info)
|
||||
QString getInterpolatorInfo() const;
|
||||
|
||||
//! Reset last interpolation to null
|
||||
//! \remark mainly needed in UNIT tests
|
||||
void resetLastInterpolation();
|
||||
|
||||
protected:
|
||||
Aviation::CAircraftSituationList m_aircraftSituations; //!< recent situations for one aircraft
|
||||
Aviation::CAircraftPartsList m_aircraftParts; //!< recent parts for one aircraft
|
||||
|
||||
Reference in New Issue
Block a user