mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-05 09:45:44 +08:00
refs #865, added ternary ground flag
* also add reliablity for ground flag * default elevation null * added missing property indexes
This commit is contained in:
committed by
Mathew Sutcliffe
parent
301db27945
commit
c84bf93862
@@ -11,9 +11,10 @@
|
|||||||
#include "blackmisc/pq/physicalquantity.h"
|
#include "blackmisc/pq/physicalquantity.h"
|
||||||
#include "blackmisc/pq/units.h"
|
#include "blackmisc/pq/units.h"
|
||||||
#include "blackmisc/propertyindex.h"
|
#include "blackmisc/propertyindex.h"
|
||||||
|
#include "blackmisc/comparefunctions.h"
|
||||||
#include "blackmisc/variant.h"
|
#include "blackmisc/variant.h"
|
||||||
#include "blackmisc/verify.h"
|
#include "blackmisc/verify.h"
|
||||||
|
#include "QStringBuilder"
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
@@ -41,16 +42,52 @@ namespace BlackMisc
|
|||||||
|
|
||||||
QString CAircraftSituation::convertToQString(bool i18n) const
|
QString CAircraftSituation::convertToQString(bool i18n) const
|
||||||
{
|
{
|
||||||
QString s(this->m_position.toQString(i18n));
|
const QString s = (this->m_position.toQString(i18n)) %
|
||||||
s.append(" bank: ").append(this->m_bank.toQString(i18n));
|
QLatin1Literal(" bank: ") % (this->m_bank.toQString(i18n)) %
|
||||||
s.append(" pitch: ").append(this->m_pitch.toQString(i18n));
|
QLatin1Literal(" pitch: ") % (this->m_pitch.toQString(i18n)) %
|
||||||
s.append(" gs: ").append(this->m_groundSpeed.toQString(i18n));
|
QLatin1Literal(" gs: ") % (this->m_groundSpeed.toQString(i18n)) %
|
||||||
s.append(" elevation: ").append(this->m_groundElevation.toQString(i18n));
|
QLatin1Literal(" elevation: ") % (this->m_groundElevation.toQString(i18n)) %
|
||||||
s.append(" heading: ").append(this->m_heading.toQString(i18n));
|
QLatin1Literal(" heading: ") % (this->m_heading.toQString(i18n)) %
|
||||||
s.append(" timestamp: ").append(this->getFormattedUtcTimestampDhms());
|
QLatin1Literal(" timestamp: ") % (this->getFormattedUtcTimestampDhms());
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString &CAircraftSituation::isOnGroundToString(CAircraftSituation::IsOnGround onGround)
|
||||||
|
{
|
||||||
|
static const QString notog("not on ground");
|
||||||
|
static const QString og("on ground");
|
||||||
|
static const QString unknown("unknown");
|
||||||
|
|
||||||
|
switch (onGround)
|
||||||
|
{
|
||||||
|
case CAircraftSituation::NotOnGround: return notog;
|
||||||
|
case CAircraftSituation::OnGround: return og;
|
||||||
|
case CAircraftSituation::OnGroundSituationUnknown:
|
||||||
|
default:
|
||||||
|
return unknown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &CAircraftSituation::onGroundReliabilityToString(CAircraftSituation::OnGroundReliability reliability)
|
||||||
|
{
|
||||||
|
static const QString elv("by elevation");
|
||||||
|
static const QString elvCg("by elevation/CG");
|
||||||
|
static const QString inter("by interpolation");
|
||||||
|
static const QString guess("guessing");
|
||||||
|
static const QString unknown("unknown");
|
||||||
|
|
||||||
|
switch (reliability)
|
||||||
|
{
|
||||||
|
case CAircraftSituation::OnGroundByElevation: return elv;
|
||||||
|
case CAircraftSituation::OnGroundByElevationAndCG: return elvCg;
|
||||||
|
case CAircraftSituation::OnGroundByGuessing: return guess;
|
||||||
|
case CAircraftSituation::OnGroundByInterpolation: return inter;
|
||||||
|
case CAircraftSituation::OnGroundReliabilityNoSet:
|
||||||
|
default:
|
||||||
|
return unknown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CVariant CAircraftSituation::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
CVariant CAircraftSituation::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||||
{
|
{
|
||||||
if (index.isMyself()) { return CVariant::from(*this); }
|
if (index.isMyself()) { return CVariant::from(*this); }
|
||||||
@@ -80,6 +117,14 @@ namespace BlackMisc
|
|||||||
return this->m_groundElevation.propertyByIndex(index.copyFrontRemoved());
|
return this->m_groundElevation.propertyByIndex(index.copyFrontRemoved());
|
||||||
case IndexCallsign:
|
case IndexCallsign:
|
||||||
return this->m_correspondingCallsign.propertyByIndex(index.copyFrontRemoved());
|
return this->m_correspondingCallsign.propertyByIndex(index.copyFrontRemoved());
|
||||||
|
case IndexIsOnGround:
|
||||||
|
return CVariant::fromValue(m_isOnGround);
|
||||||
|
case IndexIsOnGroundString:
|
||||||
|
return CVariant::fromValue(this->isOnGroundAsString());
|
||||||
|
case IndexOnGroundReliability:
|
||||||
|
return CVariant::fromValue(m_onGroundReliability);
|
||||||
|
case IndexOnGroundReliabilityString:
|
||||||
|
return CVariant::fromValue(this->getOnGroundReliabilityAsString());
|
||||||
default:
|
default:
|
||||||
return CValueObject::propertyByIndex(index);
|
return CValueObject::propertyByIndex(index);
|
||||||
}
|
}
|
||||||
@@ -115,6 +160,12 @@ namespace BlackMisc
|
|||||||
case IndexCallsign:
|
case IndexCallsign:
|
||||||
this->m_correspondingCallsign.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
this->m_correspondingCallsign.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||||
break;
|
break;
|
||||||
|
case IndexIsOnGround:
|
||||||
|
this->m_isOnGround = variant.toInt();
|
||||||
|
break;
|
||||||
|
case IndexOnGroundReliability:
|
||||||
|
this->m_onGroundReliability = variant.toInt();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
CValueObject::setPropertyByIndex(index, variant);
|
CValueObject::setPropertyByIndex(index, variant);
|
||||||
break;
|
break;
|
||||||
@@ -130,25 +181,24 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
case IndexPosition:
|
case IndexPosition:
|
||||||
return this->m_position.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getPosition());
|
return this->m_position.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getPosition());
|
||||||
break;
|
|
||||||
case IndexAltitude:
|
case IndexAltitude:
|
||||||
return this->getAltitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getAltitude());
|
return this->getAltitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getAltitude());
|
||||||
break;
|
|
||||||
case IndexPitch:
|
case IndexPitch:
|
||||||
return this->m_pitch.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getPitch());
|
return this->m_pitch.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getPitch());
|
||||||
break;
|
|
||||||
case IndexBank:
|
case IndexBank:
|
||||||
return this->m_bank.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getBank());
|
return this->m_bank.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getBank());
|
||||||
break;
|
|
||||||
case IndexGroundSpeed:
|
case IndexGroundSpeed:
|
||||||
return this->m_groundSpeed.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getGroundSpeed());
|
return this->m_groundSpeed.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getGroundSpeed());
|
||||||
break;
|
|
||||||
case IndexGroundElevation:
|
case IndexGroundElevation:
|
||||||
return this->m_groundElevation.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getGroundElevation());
|
return this->m_groundElevation.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getGroundElevation());
|
||||||
break;
|
|
||||||
case IndexCallsign:
|
case IndexCallsign:
|
||||||
return this->m_correspondingCallsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
|
return this->m_correspondingCallsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
|
||||||
break;
|
case IndexIsOnGround:
|
||||||
|
case IndexIsOnGroundString:
|
||||||
|
return Compare::compare(this->m_isOnGround, compareValue.m_isOnGround);
|
||||||
|
case IndexOnGroundReliability:
|
||||||
|
case IndexOnGroundReliabilityString:
|
||||||
|
return Compare::compare(this->m_onGroundReliability, compareValue.m_onGroundReliability);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -157,6 +207,11 @@ namespace BlackMisc
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString &CAircraftSituation::isOnGroundAsString() const
|
||||||
|
{
|
||||||
|
return CAircraftSituation::isOnGroundToString(this->isOnGround());
|
||||||
|
}
|
||||||
|
|
||||||
bool CAircraftSituation::isOnGroundInfoAvailable() const
|
bool CAircraftSituation::isOnGroundInfoAvailable() const
|
||||||
{
|
{
|
||||||
return this->isOnGround() != CAircraftSituation::OnGroundSituationUnknown &&
|
return this->isOnGround() != CAircraftSituation::OnGroundSituationUnknown &&
|
||||||
@@ -169,6 +224,16 @@ namespace BlackMisc
|
|||||||
this->setOnGroundReliabiliy(reliability);
|
this->setOnGroundReliabiliy(reliability);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString &CAircraftSituation::getOnGroundReliabilityAsString() const
|
||||||
|
{
|
||||||
|
return CAircraftSituation::onGroundReliabilityToString(this->getOnGroundReliability());
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CAircraftSituation::getOnGroundInfo() const
|
||||||
|
{
|
||||||
|
return this->isOnGroundAsString() % QLatin1Char(' ') % this->getOnGroundReliabilityAsString();
|
||||||
|
}
|
||||||
|
|
||||||
bool CAircraftSituation::hasGroundElevation() const
|
bool CAircraftSituation::hasGroundElevation() const
|
||||||
{
|
{
|
||||||
return !this->getGroundElevation().isNull();
|
return !this->getGroundElevation().isNull();
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ namespace BlackMisc
|
|||||||
IndexAltitude,
|
IndexAltitude,
|
||||||
IndexHeading,
|
IndexHeading,
|
||||||
IndexBank,
|
IndexBank,
|
||||||
|
IndexIsOnGround,
|
||||||
|
IndexIsOnGroundString,
|
||||||
|
IndexOnGroundReliability,
|
||||||
|
IndexOnGroundReliabilityString,
|
||||||
IndexPitch,
|
IndexPitch,
|
||||||
IndexGroundSpeed,
|
IndexGroundSpeed,
|
||||||
IndexGroundElevation,
|
IndexGroundElevation,
|
||||||
@@ -119,6 +123,9 @@ namespace BlackMisc
|
|||||||
//! On ground?
|
//! On ground?
|
||||||
IsOnGround isOnGround() const { return static_cast<CAircraftSituation::IsOnGround>(m_isOnGround); }
|
IsOnGround isOnGround() const { return static_cast<CAircraftSituation::IsOnGround>(m_isOnGround); }
|
||||||
|
|
||||||
|
//! On ground?
|
||||||
|
const QString &isOnGroundAsString() const;
|
||||||
|
|
||||||
//! On ground info available?
|
//! On ground info available?
|
||||||
bool isOnGroundInfoAvailable() const;
|
bool isOnGroundInfoAvailable() const;
|
||||||
|
|
||||||
@@ -131,9 +138,15 @@ namespace BlackMisc
|
|||||||
//! On ground reliability
|
//! On ground reliability
|
||||||
OnGroundReliability getOnGroundReliability() const { return static_cast<CAircraftSituation::OnGroundReliability>(m_onGroundReliability); }
|
OnGroundReliability getOnGroundReliability() const { return static_cast<CAircraftSituation::OnGroundReliability>(m_onGroundReliability); }
|
||||||
|
|
||||||
|
//! On ground reliability as string
|
||||||
|
const QString &getOnGroundReliabilityAsString() const;
|
||||||
|
|
||||||
//! Reliability
|
//! Reliability
|
||||||
void setOnGroundReliabiliy(CAircraftSituation::OnGroundReliability onGroundReliability) { m_onGroundReliability = static_cast<int>(onGroundReliability); }
|
void setOnGroundReliabiliy(CAircraftSituation::OnGroundReliability onGroundReliability) { m_onGroundReliability = static_cast<int>(onGroundReliability); }
|
||||||
|
|
||||||
|
//! On ground info as string
|
||||||
|
QString getOnGroundInfo() const;
|
||||||
|
|
||||||
//! \copydoc Geo::ICoordinateGeodetic::geodeticHeight
|
//! \copydoc Geo::ICoordinateGeodetic::geodeticHeight
|
||||||
const BlackMisc::Aviation::CAltitude &geodeticHeight() const override { return this->m_position.geodeticHeight(); }
|
const BlackMisc::Aviation::CAltitude &geodeticHeight() const override { return this->m_position.geodeticHeight(); }
|
||||||
|
|
||||||
@@ -212,6 +225,12 @@ namespace BlackMisc
|
|||||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||||
QString convertToQString(bool i18n = false) const;
|
QString convertToQString(bool i18n = false) const;
|
||||||
|
|
||||||
|
//! Enum to string
|
||||||
|
static const QString &isOnGroundToString(IsOnGround onGround);
|
||||||
|
|
||||||
|
//! Enum to string
|
||||||
|
static const QString &onGroundReliabilityToString(OnGroundReliability reliability);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CCallsign m_correspondingCallsign;
|
CCallsign m_correspondingCallsign;
|
||||||
BlackMisc::Geo::CCoordinateGeodetic m_position;
|
BlackMisc::Geo::CCoordinateGeodetic m_position;
|
||||||
@@ -219,7 +238,7 @@ namespace BlackMisc
|
|||||||
BlackMisc::PhysicalQuantities::CAngle m_pitch;
|
BlackMisc::PhysicalQuantities::CAngle m_pitch;
|
||||||
BlackMisc::PhysicalQuantities::CAngle m_bank;
|
BlackMisc::PhysicalQuantities::CAngle m_bank;
|
||||||
BlackMisc::PhysicalQuantities::CSpeed m_groundSpeed;
|
BlackMisc::PhysicalQuantities::CSpeed m_groundSpeed;
|
||||||
BlackMisc::Aviation::CAltitude m_groundElevation;
|
BlackMisc::Aviation::CAltitude m_groundElevation{0, BlackMisc::Aviation::CAltitude::MeanSeaLevel, BlackMisc::PhysicalQuantities::CLengthUnit::nullUnit()};
|
||||||
int m_isOnGround = static_cast<int>(CAircraftSituation::OnGroundSituationUnknown);
|
int m_isOnGround = static_cast<int>(CAircraftSituation::OnGroundSituationUnknown);
|
||||||
int m_onGroundReliability = static_cast<int>(CAircraftSituation::OnGroundReliabilityNoSet);
|
int m_onGroundReliability = static_cast<int>(CAircraftSituation::OnGroundReliabilityNoSet);
|
||||||
qint64 m_timeOffsetMs = 0;
|
qint64 m_timeOffsetMs = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user