mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 06:35:52 +08:00
Ref T412, Ref T227, lists/parts improvements
* Ctor with timestamp * detect/improved state detection (e.g. "takeoff") * objects outside range
This commit is contained in:
@@ -35,6 +35,13 @@ namespace BlackMisc
|
||||
m_spoilersOut(spoilersOut), m_isOnGround(onGround)
|
||||
{}
|
||||
|
||||
CAircraftParts::CAircraftParts(const CAircraftLights &lights, bool gearDown, int flapsPercent, bool spoilersOut, const CAircraftEngineList &engines, bool onGround, qint64 timestamp)
|
||||
: m_lights(lights), m_engines(engines), m_flapsPercentage(flapsPercent), m_gearDown(gearDown),
|
||||
m_spoilersOut(spoilersOut), m_isOnGround(onGround)
|
||||
{
|
||||
this->setMSecsSinceEpoch(timestamp);
|
||||
}
|
||||
|
||||
QString CAircraftParts::convertToQString(bool i18n) const
|
||||
{
|
||||
return QStringLiteral("ts: ") % this->getFormattedTimestampAndOffset(true) %
|
||||
|
||||
@@ -68,13 +68,17 @@ namespace BlackMisc
|
||||
CAircraftParts(const CAircraftLights &lights, bool gearDown, int flapsPercent, bool spoilersOut,
|
||||
const CAircraftEngineList &engines, bool onGround);
|
||||
|
||||
//! Constructor
|
||||
CAircraftParts(const CAircraftLights &lights, bool gearDown, int flapsPercent, bool spoilersOut,
|
||||
const CAircraftEngineList &engines, bool onGround, qint64 timestamp);
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
|
||||
|
||||
//! Compare for index
|
||||
//! \copydoc BlackMisc::Mixin::Index::comparePropertyByIndex
|
||||
int comparePropertyByIndex(const CPropertyIndex &index, const CAircraftParts &compareValue) const;
|
||||
|
||||
//! Get aircraft lights
|
||||
|
||||
@@ -278,35 +278,60 @@ namespace BlackMisc
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CAircraftSituationList::isGndFlagChanging(bool alreadySortedLatestFirst) const
|
||||
QPair<bool, CAircraftSituation::IsOnGround> CAircraftSituationList::isGndFlagStableChanging(bool alreadySortedLatestFirst) const
|
||||
{
|
||||
if (this->size() < 2) { return false; }
|
||||
if (this->size() < 2) { return QPair<bool, CAircraftSituation::IsOnGround>(false, CAircraftSituation::OnGroundSituationUnknown); }
|
||||
|
||||
const CAircraftSituationList sorted(this->getLatestAdjustedTwoObjects(alreadySortedLatestFirst));
|
||||
const CAircraftSituation s1 = sorted.front();
|
||||
const CAircraftSituation s2 = sorted.back();
|
||||
return (s1.getOnGround() == CAircraftSituation::OnGround && s2.getOnGround() == CAircraftSituation::NotOnGround) ||
|
||||
(s2.getOnGround() == CAircraftSituation::OnGround && s1.getOnGround() == CAircraftSituation::NotOnGround);
|
||||
const CAircraftSituationList sorted(alreadySortedLatestFirst ? (*this) : this->getSortedAdjustedLatestFirst());
|
||||
const CAircraftSituation::IsOnGround f = sorted.front().getOnGround();
|
||||
const CAircraftSituation::IsOnGround t = sorted.back().getOnGround();
|
||||
QPair<bool, CAircraftSituation::IsOnGround> ret(false, f); // changing to front (latest)
|
||||
if (f == t) { return ret; }
|
||||
|
||||
bool changed = false;
|
||||
|
||||
for (const CAircraftSituation &s : sorted)
|
||||
{
|
||||
if (!changed && s.getOnGround() == f) { continue; } // find 1st changing
|
||||
if (!changed) { changed = true; continue; } // just changed
|
||||
if (s.getOnGround() != t) { return ret; } // jitter, something like gnd, no gnd, gnd
|
||||
}
|
||||
ret.first = changed;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool CAircraftSituationList::isJustTakingOff(bool alreadySortedLatestFirst) const
|
||||
{
|
||||
if (this->size() < 2) { return false; }
|
||||
|
||||
const CAircraftSituationList sorted(this->getLatestAdjustedTwoObjects(alreadySortedLatestFirst));
|
||||
const CAircraftSituationList sorted(alreadySortedLatestFirst ? (*this) : this->getSortedAdjustedLatestFirst());
|
||||
const CAircraftSituation latest = sorted.front();
|
||||
const CAircraftSituation oldest = sorted.back();
|
||||
return (latest.getOnGround() == CAircraftSituation::NotOnGround && oldest.getOnGround() == CAircraftSituation::OnGround);
|
||||
if (latest.getOnGround() != CAircraftSituation::NotOnGround) { return false; }
|
||||
const int c = this->countOnGround(CAircraftSituation::OnGround);
|
||||
return this->size() - 1 == c; // all others on ground
|
||||
}
|
||||
|
||||
bool CAircraftSituationList::isJustTouchingDown(bool alreadySortedLatestFirst) const
|
||||
{
|
||||
if (this->size() < 2) { return false; }
|
||||
|
||||
const CAircraftSituationList sorted(this->getLatestAdjustedTwoObjects(alreadySortedLatestFirst));
|
||||
const CAircraftSituationList sorted(alreadySortedLatestFirst ? (*this) : this->getSortedAdjustedLatestFirst());
|
||||
const CAircraftSituation latest = sorted.front();
|
||||
const CAircraftSituation oldest = sorted.back();
|
||||
return (latest.getOnGround() == CAircraftSituation::OnGround && oldest.getOnGround() == CAircraftSituation::NotOnGround);
|
||||
if (latest.getOnGround() != CAircraftSituation::OnGround) { return false; }
|
||||
const int c = this->countOnGround(CAircraftSituation::NotOnGround);
|
||||
return this->size() - 1 == c; // all others not on ground
|
||||
}
|
||||
|
||||
bool CAircraftSituationList::isTakingOff(bool alreadySortedLatestFirst) const
|
||||
{
|
||||
const QPair<bool, CAircraftSituation::IsOnGround> r = this->isGndFlagStableChanging(alreadySortedLatestFirst);
|
||||
return r.first && r.second == CAircraftSituation::NotOnGround;
|
||||
}
|
||||
|
||||
bool CAircraftSituationList::isTouchingDown(bool alreadySortedLatestFirst) const
|
||||
{
|
||||
const QPair<bool, CAircraftSituation::IsOnGround> r = this->isGndFlagStableChanging(alreadySortedLatestFirst);
|
||||
return r.first && r.second == CAircraftSituation::OnGround;
|
||||
}
|
||||
|
||||
bool CAircraftSituationList::isRotatingUp(bool alreadySortedLatestFirst) const
|
||||
|
||||
@@ -123,15 +123,21 @@ namespace BlackMisc
|
||||
//! Constantly decelarating?
|
||||
bool isConstDecelarating(bool alreadySortedLatestFirst = false) const;
|
||||
|
||||
//! Is the ground flag changing for the recent situations
|
||||
bool isGndFlagChanging(bool alreadySortedLatestFirst = false) const;
|
||||
//! Is the ground flag changing for the situations
|
||||
QPair<bool, CAircraftSituation::IsOnGround> isGndFlagStableChanging(bool alreadySortedLatestFirst = false) const;
|
||||
|
||||
//! Is just taking off?
|
||||
bool isJustTakingOff(bool alreadySortedLatestFirst = false) const;
|
||||
|
||||
//! Is just touch down?
|
||||
//! Is just touching down?
|
||||
bool isJustTouchingDown(bool alreadySortedLatestFirst = false) const;
|
||||
|
||||
//! Is taking off?
|
||||
bool isTakingOff(bool alreadySortedLatestFirst = false) const;
|
||||
|
||||
//! Is touching down?
|
||||
bool isTouchingDown(bool alreadySortedLatestFirst = false) const;
|
||||
|
||||
//! Is rotating up?
|
||||
bool isRotatingUp(bool alreadySortedLatestFirst = false) const;
|
||||
|
||||
|
||||
@@ -78,6 +78,16 @@ namespace BlackMisc
|
||||
});
|
||||
}
|
||||
|
||||
template<class OBJ, class CONTAINER>
|
||||
bool IGeoObjectList<OBJ, CONTAINER>::containsObjectOutsideRange(const ICoordinateGeodetic &coordinate, const CLength &range) const
|
||||
{
|
||||
return this->container().containsBy([&](const OBJ & geoObj)
|
||||
{
|
||||
const CLength d = coordinate.calculateGreatCircleDistance(geoObj);
|
||||
return d > range;
|
||||
});
|
||||
}
|
||||
|
||||
template<class OBJ, class CONTAINER>
|
||||
bool IGeoObjectList<OBJ, CONTAINER>::containsNullPosition() const
|
||||
{
|
||||
|
||||
@@ -72,6 +72,9 @@ namespace BlackMisc
|
||||
//! Any object in range?
|
||||
bool containsObjectInRange(const ICoordinateGeodetic &coordinate, const PhysicalQuantities::CLength &range) const;
|
||||
|
||||
//! Any object in range?
|
||||
bool containsObjectOutsideRange(const ICoordinateGeodetic &coordinate, const PhysicalQuantities::CLength &range) const;
|
||||
|
||||
//! Any NULL position?
|
||||
bool containsNullPosition() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user