mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Ref T259, Ref T243 functions to set/get ground details (situation)
This commit is contained in:
@@ -310,6 +310,17 @@ namespace BlackMisc
|
||||
return CAircraftSituation::onGroundDetailsToString(this->getOnGroundDetails());
|
||||
}
|
||||
|
||||
bool CAircraftSituation::setOnGroundDetails(CAircraftSituation::OnGroundDetails details)
|
||||
{
|
||||
if (details != OnGroundByGuessing)
|
||||
{
|
||||
m_onGroundGuessingDetails.clear();
|
||||
}
|
||||
if (this->getOnGroundDetails() == details) { return false; }
|
||||
m_onGroundDetails = static_cast<int>(details);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CAircraftSituation::setOnGroundFromGroundFactorFromInterpolation(double threshold)
|
||||
{
|
||||
this->setOnGroundDetails(OnGroundByInterpolation);
|
||||
@@ -512,12 +523,14 @@ namespace BlackMisc
|
||||
m_correspondingCallsign.setTypeHint(CCallsign::Aircraft);
|
||||
}
|
||||
|
||||
bool CAircraftSituation::adjustGroundFlag(const CAircraftParts &parts, double timeDeviationFactor, qint64 *differenceMs)
|
||||
bool CAircraftSituation::adjustGroundFlag(const CAircraftParts &parts, bool alwaysSetDetails, double timeDeviationFactor, qint64 *differenceMs)
|
||||
{
|
||||
Q_ASSERT_X(timeDeviationFactor >= 0 && timeDeviationFactor <= 1.0, Q_FUNC_INFO, "Expect 0..1");
|
||||
static const qint64 Max = std::numeric_limits<qint64>::max();
|
||||
if (differenceMs) { *differenceMs = Max; }
|
||||
|
||||
if (this->getOnGroundDetails() == CAircraftSituation::InFromNetwork) { return false; }
|
||||
if (alwaysSetDetails) { this->setOnGroundDetails(InFromParts); }
|
||||
const qint64 d = this->getAdjustedTimeDifferenceMs(parts.getAdjustedMSecsSinceEpoch());
|
||||
const bool adjust = (d >= 0) || qAbs(d) < (timeDeviationFactor * parts.getTimeOffsetMs()); // future or past within deviation range
|
||||
if (!adjust) { return false; }
|
||||
@@ -527,14 +540,16 @@ namespace BlackMisc
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CAircraftSituation::adjustGroundFlag(const CAircraftPartsList &partsList, double timeDeviationFactor, qint64 *differenceMs)
|
||||
bool CAircraftSituation::adjustGroundFlag(const CAircraftPartsList &partsList, bool alwaysSetDetails, double timeDeviationFactor, qint64 *differenceMs)
|
||||
{
|
||||
Q_ASSERT_X(timeDeviationFactor >= 0 && timeDeviationFactor <= 1.0, Q_FUNC_INFO, "Expect 0..1");
|
||||
if (this->getOnGroundDetails() == CAircraftSituation::InFromNetwork) { return false; }
|
||||
if (partsList.isEmpty()) { return false; }
|
||||
|
||||
static const qint64 Max = std::numeric_limits<qint64>::max();
|
||||
if (differenceMs) { *differenceMs = Max; }
|
||||
|
||||
if (this->getOnGroundDetails() == CAircraftSituation::InFromNetwork) { return false; }
|
||||
if (alwaysSetDetails) { this->setOnGroundDetails(InFromParts); }
|
||||
if (partsList.isEmpty()) { return false; }
|
||||
|
||||
CAircraftParts bestParts;
|
||||
bool adjust = false;
|
||||
qint64 bestDistance = Max;
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace BlackMisc
|
||||
const QString &getOnDetailsAsString() const;
|
||||
|
||||
//! On ground details
|
||||
void setOnGroundDetails(CAircraftSituation::OnGroundDetails details) { m_onGroundDetails = static_cast<int>(details); }
|
||||
bool setOnGroundDetails(CAircraftSituation::OnGroundDetails details);
|
||||
|
||||
//! Set on ground as interpolated from ground fatcor
|
||||
bool setOnGroundFromGroundFactorFromInterpolation(double threshold = 0.5);
|
||||
@@ -320,14 +320,14 @@ namespace BlackMisc
|
||||
//! \param alwaysSetDetails mark as CAircraftSituation::InFromParts regardless of parts
|
||||
//! \param timeDeviationFactor 0..1 (of offset time) small deviations from time are accepted
|
||||
//! \param differenceMs returns time difference
|
||||
bool adjustGroundFlag(const CAircraftParts &parts, double timeDeviationFactor = 0.1, qint64 *differenceMs = nullptr);
|
||||
bool adjustGroundFlag(const CAircraftParts &parts, bool alwaysSetDetails, double timeDeviationFactor = 0.1, qint64 *differenceMs = nullptr);
|
||||
|
||||
//! Transfer ground flag from parts list
|
||||
//! \param partsList containing the gnd flag
|
||||
//! \param alwaysSetDetails mark as CAircraftSituation::InFromParts regardless of parts
|
||||
//! \param timeDeviationFactor 0..1 (of offset time) small deviations from time are accepted
|
||||
//! \param differenceMs returns time difference
|
||||
bool adjustGroundFlag(const CAircraftPartsList &partsList, double timeDeviationFactor = 0.1, qint64 *differenceMs = nullptr);
|
||||
bool adjustGroundFlag(const CAircraftPartsList &partsList, bool alwaysSetDetails, double timeDeviationFactor = 0.1, qint64 *differenceMs = nullptr);
|
||||
|
||||
//! Get flag indicating this is an interim position update
|
||||
bool isInterim() const { return m_isInterim; }
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace BlackMisc
|
||||
int c = 0;
|
||||
for (CAircraftSituation &situation : *this)
|
||||
{
|
||||
situation.setOnGroundDetails(CAircraftSituation::InFromParts);
|
||||
if (situation.adjustGroundFlag(parts, timeDeviationFactor)) { c++; };
|
||||
}
|
||||
return c;
|
||||
@@ -92,5 +93,29 @@ namespace BlackMisc
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CAircraftSituationList::containsOnGroundDetails(CAircraftSituation::OnGroundDetails details) const
|
||||
{
|
||||
return this->contains(&CAircraftSituation::getOnGroundDetails, details);
|
||||
}
|
||||
|
||||
bool CAircraftSituationList::areAllOnGroundDetailsSame(CAircraftSituation::OnGroundDetails details) const
|
||||
{
|
||||
for (const CAircraftSituation &situation : *this)
|
||||
{
|
||||
if (situation.getOnGroundDetails() != details) { return false; }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int CAircraftSituationList::setOnGroundDetails(CAircraftSituation::OnGroundDetails details)
|
||||
{
|
||||
int c = 0;
|
||||
for (CAircraftSituation &situation : *this)
|
||||
{
|
||||
if (situation.setOnGroundDetails(details)) { c++; }
|
||||
}
|
||||
return c;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -68,6 +68,15 @@ namespace BlackMisc
|
||||
|
||||
//! Any situation outside range
|
||||
bool hasGroundElevationOutsideRange(const PhysicalQuantities::CLength &range) const;
|
||||
|
||||
//! Contains on ground details
|
||||
bool containsOnGroundDetails(CAircraftSituation::OnGroundDetails details) const;
|
||||
|
||||
//! Are all on ground details the same
|
||||
bool areAllOnGroundDetailsSame(CAircraftSituation::OnGroundDetails details) const;
|
||||
|
||||
//! Set on ground details for all situations
|
||||
int setOnGroundDetails(CAircraftSituation::OnGroundDetails details);
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user