mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-10 14:07:35 +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());
|
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)
|
bool CAircraftSituation::setOnGroundFromGroundFactorFromInterpolation(double threshold)
|
||||||
{
|
{
|
||||||
this->setOnGroundDetails(OnGroundByInterpolation);
|
this->setOnGroundDetails(OnGroundByInterpolation);
|
||||||
@@ -512,12 +523,14 @@ namespace BlackMisc
|
|||||||
m_correspondingCallsign.setTypeHint(CCallsign::Aircraft);
|
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");
|
Q_ASSERT_X(timeDeviationFactor >= 0 && timeDeviationFactor <= 1.0, Q_FUNC_INFO, "Expect 0..1");
|
||||||
static const qint64 Max = std::numeric_limits<qint64>::max();
|
static const qint64 Max = std::numeric_limits<qint64>::max();
|
||||||
if (differenceMs) { *differenceMs = Max; }
|
if (differenceMs) { *differenceMs = Max; }
|
||||||
|
|
||||||
if (this->getOnGroundDetails() == CAircraftSituation::InFromNetwork) { return false; }
|
if (this->getOnGroundDetails() == CAircraftSituation::InFromNetwork) { return false; }
|
||||||
|
if (alwaysSetDetails) { this->setOnGroundDetails(InFromParts); }
|
||||||
const qint64 d = this->getAdjustedTimeDifferenceMs(parts.getAdjustedMSecsSinceEpoch());
|
const qint64 d = this->getAdjustedTimeDifferenceMs(parts.getAdjustedMSecsSinceEpoch());
|
||||||
const bool adjust = (d >= 0) || qAbs(d) < (timeDeviationFactor * parts.getTimeOffsetMs()); // future or past within deviation range
|
const bool adjust = (d >= 0) || qAbs(d) < (timeDeviationFactor * parts.getTimeOffsetMs()); // future or past within deviation range
|
||||||
if (!adjust) { return false; }
|
if (!adjust) { return false; }
|
||||||
@@ -527,14 +540,16 @@ namespace BlackMisc
|
|||||||
return true;
|
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");
|
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();
|
static const qint64 Max = std::numeric_limits<qint64>::max();
|
||||||
if (differenceMs) { *differenceMs = Max; }
|
if (differenceMs) { *differenceMs = Max; }
|
||||||
|
|
||||||
|
if (this->getOnGroundDetails() == CAircraftSituation::InFromNetwork) { return false; }
|
||||||
|
if (alwaysSetDetails) { this->setOnGroundDetails(InFromParts); }
|
||||||
|
if (partsList.isEmpty()) { return false; }
|
||||||
|
|
||||||
CAircraftParts bestParts;
|
CAircraftParts bestParts;
|
||||||
bool adjust = false;
|
bool adjust = false;
|
||||||
qint64 bestDistance = Max;
|
qint64 bestDistance = Max;
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ namespace BlackMisc
|
|||||||
const QString &getOnDetailsAsString() const;
|
const QString &getOnDetailsAsString() const;
|
||||||
|
|
||||||
//! On ground details
|
//! 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
|
//! Set on ground as interpolated from ground fatcor
|
||||||
bool setOnGroundFromGroundFactorFromInterpolation(double threshold = 0.5);
|
bool setOnGroundFromGroundFactorFromInterpolation(double threshold = 0.5);
|
||||||
@@ -320,14 +320,14 @@ namespace BlackMisc
|
|||||||
//! \param alwaysSetDetails mark as CAircraftSituation::InFromParts regardless of parts
|
//! \param alwaysSetDetails mark as CAircraftSituation::InFromParts regardless of parts
|
||||||
//! \param timeDeviationFactor 0..1 (of offset time) small deviations from time are accepted
|
//! \param timeDeviationFactor 0..1 (of offset time) small deviations from time are accepted
|
||||||
//! \param differenceMs returns time difference
|
//! \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
|
//! Transfer ground flag from parts list
|
||||||
//! \param partsList containing the gnd flag
|
//! \param partsList containing the gnd flag
|
||||||
//! \param alwaysSetDetails mark as CAircraftSituation::InFromParts regardless of parts
|
//! \param alwaysSetDetails mark as CAircraftSituation::InFromParts regardless of parts
|
||||||
//! \param timeDeviationFactor 0..1 (of offset time) small deviations from time are accepted
|
//! \param timeDeviationFactor 0..1 (of offset time) small deviations from time are accepted
|
||||||
//! \param differenceMs returns time difference
|
//! \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
|
//! Get flag indicating this is an interim position update
|
||||||
bool isInterim() const { return m_isInterim; }
|
bool isInterim() const { return m_isInterim; }
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ namespace BlackMisc
|
|||||||
int c = 0;
|
int c = 0;
|
||||||
for (CAircraftSituation &situation : *this)
|
for (CAircraftSituation &situation : *this)
|
||||||
{
|
{
|
||||||
|
situation.setOnGroundDetails(CAircraftSituation::InFromParts);
|
||||||
if (situation.adjustGroundFlag(parts, timeDeviationFactor)) { c++; };
|
if (situation.adjustGroundFlag(parts, timeDeviationFactor)) { c++; };
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
@@ -92,5 +93,29 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
return false;
|
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
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -68,6 +68,15 @@ namespace BlackMisc
|
|||||||
|
|
||||||
//! Any situation outside range
|
//! Any situation outside range
|
||||||
bool hasGroundElevationOutsideRange(const PhysicalQuantities::CLength &range) const;
|
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
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
Reference in New Issue
Block a user