6#include <QCoreApplication>
7#include <QStringBuilder>
20using namespace swift::misc::physical_quantities;
21using namespace swift::misc::geo;
22using namespace swift::misc::network;
26namespace swift::misc::aviation
34 : m_callsign(callsign), m_controller(controller), m_frequency(frequency), m_position(pos), m_range(range),
35 m_isOnline(
isOnline), m_logoffTimeUtc(logoffTimeUtc), m_atis(atis), m_metar(metar)
38 m_callsign.setTypeHint(CCallsign::Atc);
39 if (!m_controller.hasCallsign() && !callsign.
isEmpty())
41 m_controller.setCallsign(m_callsign);
64 m_callsign = callsign;
65 m_controller.setCallsign(callsign);
71 if (m_callsign.isEmpty())
75 if (!m_controller.hasRealName())
77 return m_callsign.asString();
84 m_controller = controller;
95 const QString s = (i18n ? atcI18n : QStringLiteral(
"ATC station")) % u
' ' % m_callsign.toQString(i18n) % u
' ' %
96 m_position.toQString(i18n) % u
" online: " %
boolToYesNo(m_isOnline) %
99 (m_controller.isNull() ?
QString() : u
' ' % m_controller.toQString(i18n)) %
102 u
' ' % m_frequency.valueRoundedWithUnit(3, i18n) %
111 u
' ' % (i18n ? rangeI18n : QStringLiteral(
"range")) % u
' ' % m_range.toQString(i18n) %
121 m_frequency = frequency;
136 if (online == m_isOnline)
158 case CInformationMessage::ATIS:
return this->
getAtis();
159 case CInformationMessage::METAR:
return this->
getMetar();
169 case CInformationMessage::ATIS: this->
setAtis(message);
return true;
170 case CInformationMessage::METAR: this->
setMetar(message);
return true;
196 case IndexCallsign:
return m_callsign.propertyByIndex(index.
copyFrontRemoved());
199 case IndexController:
return m_controller.propertyByIndex(index.
copyFrontRemoved());
200 case IndexFrequency:
return m_frequency.propertyByIndex(index.
copyFrontRemoved());
204 case IndexPosition:
return m_position.propertyByIndex(index.
copyFrontRemoved());
228 case IndexCallsign: m_callsign.setPropertyByIndex(index.
copyFrontRemoved(), variant);
break;
229 case IndexController: m_controller.setPropertyByIndex(index.
copyFrontRemoved(), variant);
break;
230 case IndexFrequency: m_frequency.setPropertyByIndex(index.
copyFrontRemoved(), variant);
break;
231 case IndexIsOnline: this->
setOnline(variant.
value<
bool>());
break;
232 case IndexPosition: m_position.setPropertyByIndex(index.
copyFrontRemoved(), variant);
break;
233 case IndexRange: m_range.setPropertyByIndex(index.
copyFrontRemoved(), variant);
break;
234 case IndexAtis: m_atis.setPropertyByIndex(index.
copyFrontRemoved(), variant);
break;
235 case IndexMetar: m_metar.setPropertyByIndex(index.
copyFrontRemoved(), variant);
break;
237 case IndexCallsignString:
238 case IndexCallsignStringCrossCopuled:
268 case IndexCallsignString:
269 case IndexCallsignStringCrossCopuled:
273 case IndexController:
288 case IndexIsAfvCrossCoupled:
297 Q_ASSERT_X(
false, Q_FUNC_INFO,
"Compare failed");
static CFrequencyUnit MHz()
Megahertz.
Non-owning reference to a CPropertyIndex with a subset of its features.
Q_REQUIRED_RESULT CPropertyIndexRef copyFrontRemoved() const
Copy with first element removed.
static CPropertyIndexRef empty()
an empty property index
CastType frontCasted() const
First element casted to given type, usually the PropertIndex enum.
bool isMyself() const
Myself index, used with nesting.
Altitude as used in aviation, can be AGL or MSL altitude.
void setController(const network::CUser &controller)
Set controller.
geo::CLatitude latitude() const
Latitude.
const physical_quantities::CFrequency & getFrequency() const
Get frequency.
void setFrequency(const swift::misc::physical_quantities::CFrequency &frequency)
Set frequency.
const geo::CCoordinateGeodetic & getPosition() const
Get the position of the center of the controller's area of visibility.
void setAfvCrossCoupled(bool coupled)
Set AFV cross coupled.
ColumnIndex
Properties by index.
bool isOnline() const
Is station online?
const CInformationMessage & getMetar() const
Get METAR.
void setMetar(const CInformationMessage &metar)
Set METAR.
geo::CLongitude longitude() const
Longitude.
bool hasAtis() const
Has ATIS?
QString getCallsignSuffix() const
Callsign suffix (e.g. TWR).
void setCallsign(const CCallsign &callsign)
Set callsign.
const aviation::CAltitude & geodeticHeight() const
Height, ellipsoidal or geodetic height (used in GPS).
QString getCallsignAsString() const
Get callsign as string.
bool isComUnitTunedToFrequency(const aviation::CComSystem &comUnit) const
Is Com unit tuned to this stations frequency.
const CInformationMessage & getInformationMessage(CInformationMessage::InformationType type) const
Message per type.
QString getCallsignAsStringCrossCoupled() const
Get callsign.
QString getCallsignAndControllerRealName() const
Callsign and controller's name if available.
std::array< double, 3 > normalVectorDouble() const
Normal vector with double precision.
CAtcStation()=default
Default constructor.
bool setOnline(bool online)
Set online.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
const CCallsign & getCallsign() const
Get callsign.
const CInformationMessage & getAtis() const
Get ATIS.
bool isAtcStationFrequency(const physical_quantities::CFrequency &frequency) const
Is passed frequency the frequency of this station.
QString getControllerRealName() const
Get controller name.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
const physical_quantities::CLength & getRange() const
Get the radius of the controller's area of visibility.
bool setMessage(const CInformationMessage &message)
Set given message.
int getSuffixSortOrder() const
Callsign suffix sort order.
bool isAfvCrossCoupled() const
Is AFV cross coupled?
const swift::misc::network::CUser & getController() const
Get controller.
bool hasMetar() const
Has METAR?
QVector3D normalVector() const
Normal vector.
const QDateTime & getLogoffTimeUtc() const
Return the expected logoff time (UTC). This data comes from the controller through its ATIS line.
bool isInRange() const
In range? If range and distance to own aircraft are not available false.
bool hasLogoffTimeUtc() const
Has expected logoff time?
void setAtis(const CInformationMessage &atis)
Set ATIS.
QString convertToQString(bool i18n=false) const
Cast as QString.
int comparePropertyByIndex(CPropertyIndexRef index, const CAtcStation &compareValue) const
Compare for index.
void setLogoffTimeUtc(const QDateTime &logoffTimeUtc)
Set expected logoff time (UTC).
Value object encapsulating information of a callsign.
int comparePropertyByIndex(CPropertyIndexRef index, const CCallsign &compareValue) const
Compare for index.
const QString & getStringAsSet() const
Get callsign.
bool isEmpty() const
Is empty?
COM system (aka "radio").
static bool isSameFrequency(const physical_quantities::CFrequency &freq1, const physical_quantities::CFrequency &freq2)
Compare frequencies under consideration that on VATSIM frequencies .x20/.x25 and ....
bool isActiveFrequencySameFrequency(const physical_quantities::CFrequency &comFrequency) const
Is active frequency the same frequency.
CLatitude latitude() const
Latitude.
CLongitude longitude() const
Longitude.
static bool canHandleIndex(CPropertyIndexRef index)
Can given index be handled?
const physical_quantities::CLength & getRelativeDistance() const
Get the distance.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
int comparePropertyByIndex(CPropertyIndexRef index, const ICoordinateWithRelativePosition &compareValue) const
Compare for index.
bool hasValidRelativeDistance() const
Valid distance?
QString convertToQString(bool i18n=false) const
Cast as QString.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
int comparePropertyByIndex(CPropertyIndexRef index, const Derived &compareValue) const
Compare for index.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
Value object encapsulating information of a user.
bool setCallsign(const aviation::CCallsign &callsign)
Set associated callsign.
Physical unit length (length).
void setUnit(const MU &unit)
Simply set unit, do no calclulate conversion.
int compare(T a, T b)
Compare arithmetic values.
Free functions in swift::misc.
SWIFT_MISC_EXPORT const QString & boolToYesNo(bool v)
Bool to yes/no.
QString translate(const char *context, const char *sourceText, const char *disambiguation, int n)
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
QVariant fromValue(T &&value)
QString toString() const const
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.