mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 23:25:53 +08:00
Ref T180, interpolator status can check validity of situation and provide an info string
This commit is contained in:
@@ -64,7 +64,11 @@ namespace BlackMisc
|
||||
const auto interpolant = derived()->getInterpolant(currentTimeMsSinceEpoc, setup, hints, status, log);
|
||||
|
||||
// succeeded so far?
|
||||
if (!status.didInterpolationSucceed()) { return currentSituation; }
|
||||
if (!status.didInterpolationSucceed())
|
||||
{
|
||||
status.setValidSituation(currentSituation);
|
||||
return currentSituation;
|
||||
}
|
||||
|
||||
// use derived interpolant function
|
||||
currentSituation.setPosition(interpolant.interpolatePosition(setup, hints));
|
||||
@@ -112,7 +116,7 @@ namespace BlackMisc
|
||||
currentSituation.setGroundSpeed(pbh.getGroundSpeed());
|
||||
status.setChangedPosition(true);
|
||||
}
|
||||
status.setInterpolationSucceeded(true);
|
||||
status.setInterpolationSucceeded(true, currentSituation);
|
||||
m_isFirstInterpolation = false;
|
||||
|
||||
if (m_logger && hints.isLoggingInterpolation())
|
||||
@@ -348,17 +352,41 @@ namespace BlackMisc
|
||||
situation.setOnGround(CAircraftSituation::OnGround, CAircraftSituation::OnGroundByGuessing);
|
||||
}
|
||||
|
||||
bool CInterpolationStatus::allTrue() const
|
||||
void CInterpolationStatus::setInterpolationSucceeded(bool succeeded, const CAircraftSituation &situation)
|
||||
{
|
||||
return m_interpolationSucceeded && m_changedPosition;
|
||||
m_interpolationSucceeded = succeeded;
|
||||
this->setValidSituation(situation);
|
||||
}
|
||||
|
||||
void CInterpolationStatus::setValidSituation(const CAircraftSituation &situation)
|
||||
{
|
||||
m_validSituation = !situation.isGeodeticHeightNull() && !situation.isPositionNull();
|
||||
}
|
||||
|
||||
bool CInterpolationStatus::validAndChangedInterpolatedSituation() const
|
||||
{
|
||||
return m_interpolationSucceeded && m_changedPosition && m_validSituation;
|
||||
}
|
||||
|
||||
bool CInterpolationStatus::validInterpolatedSituation() const
|
||||
{
|
||||
return m_interpolationSucceeded && m_validSituation;
|
||||
}
|
||||
|
||||
void CInterpolationStatus::reset()
|
||||
{
|
||||
m_validSituation = false;
|
||||
m_changedPosition = false;
|
||||
m_interpolationSucceeded = false;
|
||||
}
|
||||
|
||||
QString CInterpolationStatus::toQString() const
|
||||
{
|
||||
return "Interpolation: " % boolToYesNo(m_interpolationSucceeded) %
|
||||
" situation valid: " % boolToYesNo(m_interpolationSucceeded) %
|
||||
" changed pos.: " % boolToYesNo(m_changedPosition);
|
||||
}
|
||||
|
||||
bool CPartsStatus::allTrue() const
|
||||
{
|
||||
return m_supportsParts;
|
||||
|
||||
@@ -151,21 +151,37 @@ namespace BlackMisc
|
||||
//! Set succeeded
|
||||
void setInterpolationSucceeded(bool succeeded) { m_interpolationSucceeded = succeeded; }
|
||||
|
||||
//! Set succeeded
|
||||
void setInterpolationSucceeded(bool succeeded, const Aviation::CAircraftSituation &situation);
|
||||
|
||||
//! Changed position?
|
||||
bool hasChangedPosition() const { return m_changedPosition; }
|
||||
|
||||
//! Is the corresponding position valid?
|
||||
bool hasValidSituation() const { return m_validSituation; }
|
||||
|
||||
//! Is that a valid position?
|
||||
void setValidSituation(const Aviation::CAircraftSituation &situation);
|
||||
|
||||
//! Set as changed
|
||||
void setChangedPosition(bool changed) { m_changedPosition = changed; }
|
||||
|
||||
//! all OK
|
||||
bool allTrue() const;
|
||||
//! Valid interpolated situation which also changed
|
||||
bool validAndChangedInterpolatedSituation() const;
|
||||
|
||||
//! Valid interpolated situation
|
||||
bool validInterpolatedSituation() const;
|
||||
|
||||
//! Reset to default values
|
||||
void reset();
|
||||
|
||||
//! Info string
|
||||
QString toQString() const;
|
||||
|
||||
private:
|
||||
bool m_changedPosition = false; //!< position was changed
|
||||
bool m_interpolationSucceeded = false; //!< interpolation succeeded (means enough values, etc.)
|
||||
bool m_validSituation = false; //!< is valid situation
|
||||
};
|
||||
|
||||
//! Status regarding parts
|
||||
|
||||
@@ -69,10 +69,20 @@ namespace BlackMisc
|
||||
if (situationsOlder.isEmpty() || situationsNewer.isEmpty())
|
||||
{
|
||||
// no before situations
|
||||
if (situationsOlder.isEmpty()) { return *(situationsNewer.end() - 1); } // oldest newest
|
||||
if (situationsOlder.isEmpty())
|
||||
{
|
||||
const CAircraftSituation currentSituation(*(situationsNewer.end() - 1)); // oldest newest
|
||||
status.setInterpolationSucceeded(false, currentSituation);
|
||||
return currentSituation;
|
||||
}
|
||||
|
||||
// only one before situation
|
||||
if (situationsOlder.size() < 2) { return situationsOlder.front(); } // latest older
|
||||
if (situationsOlder.size() < 2)
|
||||
{
|
||||
const CAircraftSituation currentSituation(situationsOlder.front()); // latest oldest
|
||||
status.setInterpolationSucceeded(false, currentSituation);
|
||||
return currentSituation;
|
||||
}
|
||||
|
||||
// extrapolate from two before situations
|
||||
oldSituation = *(situationsOlder.begin() + 1); // before newest
|
||||
@@ -115,7 +125,7 @@ namespace BlackMisc
|
||||
currentSituation.setMSecsSinceEpoch(oldSituation.getMSecsSinceEpoch() + deltaTimeFractionMs);
|
||||
|
||||
status.setChangedPosition(m_isFirstInterpolation || oldSituation.getPosition() != newSituation.getPosition() || oldSituation.getAltitude() != newSituation.getAltitude());
|
||||
status.setInterpolationSucceeded(true);
|
||||
status.setInterpolationSucceeded(true, currentSituation);
|
||||
|
||||
log.oldSituation = oldSituation;
|
||||
log.newSituation = newSituation;
|
||||
|
||||
Reference in New Issue
Block a user