swift
atcstation.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_MISC_AVIATION_ATCSTATION_H
7 #define SWIFT_MISC_AVIATION_ATCSTATION_H
8 
9 #include <array>
10 #include <tuple>
11 
12 #include <QDateTime>
13 #include <QMetaType>
14 #include <QString>
15 #include <QVector3D>
16 
17 #include "misc/aviation/callsign.h"
21 #include "misc/geo/latitude.h"
22 #include "misc/geo/longitude.h"
23 #include "misc/metaclass.h"
24 #include "misc/network/user.h"
25 #include "misc/pq/frequency.h"
26 #include "misc/pq/length.h"
27 #include "misc/pq/time.h"
28 #include "misc/propertyindexref.h"
29 #include "misc/swiftmiscexport.h"
30 #include "misc/valueobject.h"
31 
32 SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::misc::aviation, CAtcStation)
33 
34 namespace swift::misc::aviation
35 {
38  {
39  public:
42  {
43  IndexCallsign = CPropertyIndexRef::GlobalIndexCAtcStation,
44  IndexCallsignString,
45  IndexCallsignStringCrossCopuled,
46  IndexController,
47  IndexFrequency,
48  IndexPosition,
49  IndexRange,
50  IndexIsInRange,
51  IndexIsOnline,
52  IndexIsAfvCrossCoupled,
53  IndexLogoffTime,
54  IndexLatitude,
55  IndexLongitude,
56  IndexAtis,
57  IndexMetar
58  };
59 
61  CAtcStation();
62 
64  CAtcStation(const QString &callsign);
65 
67  CAtcStation(const CCallsign &callsign, const network::CUser &controller,
68  const physical_quantities::CFrequency &frequency, const geo::CCoordinateGeodetic &pos,
69  const physical_quantities::CLength &range, bool isOnline = false,
70  const QDateTime &logoffTimeUtc = QDateTime(),
71  const CInformationMessage &atis = CInformationMessage(CInformationMessage::ATIS),
72  const CInformationMessage &metar = CInformationMessage(CInformationMessage::METAR));
73 
75  bool hasLogoffTimeUtc() const;
76 
78  bool hasAtis() const { return m_atis.hasMessage(); }
79 
81  bool hasMetar() const;
82 
84  const CCallsign &getCallsign() const { return m_callsign; }
85 
87  bool hasCallsign() const { return !m_callsign.isEmpty(); }
88 
90  QString getCallsignAsString() const { return m_callsign.asString(); }
91 
93  QString getCallsignAsStringCrossCoupled() const;
94 
96  QString getCallsignSuffix() const;
97 
99  int getSuffixSortOrder() const;
100 
102  void setCallsign(const CCallsign &callsign);
103 
105  const swift::misc::network::CUser &getController() const { return m_controller; }
106 
108  QString getControllerRealName() const { return m_controller.getRealName(); }
109 
111  QString getCallsignAndControllerRealName() const;
112 
114  QString getControllerId() const { return m_controller.getId(); }
115 
117  void setController(const network::CUser &controller);
118 
120  void setControllerRealName(const QString &controllerName) { m_controller.setRealName(controllerName); }
121 
123  void setControllerId(const QString &controllerId) { m_controller.setId(controllerId); }
124 
126  bool hasRealName() const { return m_controller.hasRealName(); }
127 
129  bool hasId() const { return m_controller.hasId(); }
130 
132  bool hasValidFrequency() const { return CComSystem::isValidCivilAviationFrequency(this->getFrequency()); }
133 
135  const physical_quantities::CFrequency &getFrequency() const { return m_frequency; }
136 
138  void setFrequency(const swift::misc::physical_quantities::CFrequency &frequency);
139 
141  const geo::CCoordinateGeodetic &getPosition() const { return m_position; }
142 
144  void setPosition(const swift::misc::geo::CCoordinateGeodetic &position) { m_position = position; }
145 
147  const physical_quantities::CLength &getRange() const { return m_range; }
148 
150  void setRange(const physical_quantities::CLength &range) { m_range = range; }
151 
153  bool isInRange() const;
154 
156  bool isOnline() const { return m_isOnline; }
157 
159  bool setOnline(bool online);
160 
162  bool isAfvCrossCoupled() const { return m_isAfvCrossCoupled; }
163 
165  void setAfvCrossCoupled(bool coupled) { m_isAfvCrossCoupled = coupled; }
166 
169  const QDateTime &getLogoffTimeUtc() const { return m_logoffTimeUtc; }
170 
172  bool isComUnitTunedToFrequency(const aviation::CComSystem &comUnit) const;
173 
175  bool isAtcStationFrequency(const physical_quantities::CFrequency &frequency) const;
176 
178  const CInformationMessage &getAtis() const { return m_atis; }
179 
181  void setAtis(const CInformationMessage &atis) { m_atis = atis; }
182 
184  void setAtisMessage(const QString &atis) { m_atis.setMessage(atis); }
185 
187  const CInformationMessage &getMetar() const { return m_metar; }
188 
190  const CInformationMessage &getInformationMessage(CInformationMessage::InformationType type) const;
191 
193  void setMetar(const CInformationMessage &metar) { m_metar = metar; }
194 
196  void setMetarMessage(const QString &metar) { m_metar.setMessage(metar); }
197 
199  bool setMessage(const CInformationMessage &message);
200 
202  void setLogoffTimeUtc(const QDateTime &logoffTimeUtc) { m_logoffTimeUtc = logoffTimeUtc; }
203 
205  virtual geo::CLatitude latitude() const override;
206 
208  virtual geo::CLongitude longitude() const override;
209 
211  const aviation::CAltitude &geodeticHeight() const override;
212 
214  virtual QVector3D normalVector() const override;
215 
217  virtual std::array<double, 3> normalVectorDouble() const override;
218 
220  QVariant propertyByIndex(CPropertyIndexRef index) const;
221 
223  void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant);
224 
226  int comparePropertyByIndex(CPropertyIndexRef index, const CAtcStation &compareValue) const;
227 
229  QString convertToQString(bool i18n = false) const;
230 
232  swift::misc::CIcons::IconIndex toIcon() const { return m_callsign.toIcon(); }
233 
234  private:
235  CCallsign m_callsign;
236  network::CUser m_controller;
238  geo::CCoordinateGeodetic m_position;
240  bool m_isOnline = false;
241  bool m_isAfvCrossCoupled = false;
242  QDateTime m_logoffTimeUtc;
243  CInformationMessage m_atis { CInformationMessage::ATIS };
244  CInformationMessage m_metar { CInformationMessage::METAR };
245 
247  CAtcStation,
248  SWIFT_METAMEMBER(callsign),
249  SWIFT_METAMEMBER(controller),
250  SWIFT_METAMEMBER(frequency),
251  SWIFT_METAMEMBER(position),
252  SWIFT_METAMEMBER(range),
253  SWIFT_METAMEMBER(isOnline),
254  SWIFT_METAMEMBER(isAfvCrossCoupled),
255  SWIFT_METAMEMBER(logoffTimeUtc),
256  SWIFT_METAMEMBER(atis),
257  SWIFT_METAMEMBER(metar),
258  SWIFT_METAMEMBER(relativeDistance),
259  SWIFT_METAMEMBER(relativeBearing));
260  };
261 } // namespace swift::misc::aviation
262 
263 Q_DECLARE_METATYPE(swift::misc::aviation::CAtcStation)
264 
265 #endif // SWIFT_MISC_AVIATION_ATCSTATION_H
IconIndex
Index for each icon, allows to send them via DBus, efficiently store them, etc.
Definition: icons.h:32
Non-owning reference to a CPropertyIndex with a subset of its features.
Mix of the most commonly used mixin classes.
Definition: valueobject.h:114
Altitude as used in aviation, can be AGL or MSL altitude.
Definition: altitude.h:52
Value object encapsulating information about an ATC station.
Definition: atcstation.h:38
void setControllerId(const QString &controllerId)
Set controller's id.
Definition: atcstation.h:123
void setAfvCrossCoupled(bool coupled)
Set AFV cross coupled.
Definition: atcstation.h:165
ColumnIndex
Properties by index.
Definition: atcstation.h:42
bool isOnline() const
Is station online?
Definition: atcstation.h:156
const CCallsign & getCallsign() const
Get callsign.
Definition: atcstation.h:84
bool hasValidFrequency() const
Valid COM frequency.
Definition: atcstation.h:132
void setMetar(const CInformationMessage &metar)
Set METAR.
Definition: atcstation.h:193
bool hasAtis() const
Has ATIS?
Definition: atcstation.h:78
const geo::CCoordinateGeodetic & getPosition() const
Get the position of the center of the controller's area of visibility.
Definition: atcstation.h:141
const CInformationMessage & getMetar() const
Get METAR.
Definition: atcstation.h:187
QString getCallsignAsString() const
Get callsign as string.
Definition: atcstation.h:90
QString getControllerId() const
Get controller name.
Definition: atcstation.h:114
void setPosition(const swift::misc::geo::CCoordinateGeodetic &position)
Set position.
Definition: atcstation.h:144
void setControllerRealName(const QString &controllerName)
Set controller's name.
Definition: atcstation.h:120
bool hasRealName() const
Has valid realname?
Definition: atcstation.h:126
QString getControllerRealName() const
Get controller name.
Definition: atcstation.h:108
bool hasId() const
Has valid id?
Definition: atcstation.h:129
const CInformationMessage & getAtis() const
Get ATIS.
Definition: atcstation.h:178
swift::misc::CIcons::IconIndex toIcon() const
As icon, not implemented by all classes.
Definition: atcstation.h:232
const physical_quantities::CFrequency & getFrequency() const
Get frequency.
Definition: atcstation.h:135
void setAtisMessage(const QString &atis)
Set ATIS Message.
Definition: atcstation.h:184
bool isAfvCrossCoupled() const
Is AFV cross coupled?
Definition: atcstation.h:162
void setRange(const physical_quantities::CLength &range)
Set range.
Definition: atcstation.h:150
const swift::misc::network::CUser & getController() const
Get controller.
Definition: atcstation.h:105
const QDateTime & getLogoffTimeUtc() const
Return the expected logoff time (UTC). This data comes from the controller through its ATIS line.
Definition: atcstation.h:169
void setMetarMessage(const QString &metar)
Set METAR Message.
Definition: atcstation.h:196
const physical_quantities::CLength & getRange() const
Get the radius of the controller's area of visibility.
Definition: atcstation.h:147
bool hasCallsign() const
Has callsign?
Definition: atcstation.h:87
void setAtis(const CInformationMessage &atis)
Set ATIS.
Definition: atcstation.h:181
void setLogoffTimeUtc(const QDateTime &logoffTimeUtc)
Set expected logoff time (UTC)
Definition: atcstation.h:202
Value object encapsulating information of a callsign.
Definition: callsign.h:30
COM system (aka "radio")
Definition: comsystem.h:37
static bool isValidCivilAviationFrequency(const physical_quantities::CFrequency &f)
Valid civil aviation frequency?
Definition: comsystem.cpp:94
Value object encapsulating information message (ATIS, METAR, TAF)
Interface (actually more an abstract class) of coordinates and relative position to something (normal...
Value object encapsulating information of a user.
Definition: user.h:28
Physical unit length (length)
Definition: length.h:18
#define SWIFT_METAMEMBER(MEMBER,...)
Macro to define an element within a metaclass.
Definition: metaclass.h:73
#define SWIFT_METACLASS(CLASS,...)
Macro to define a nested metaclass that describes the attributes of its enclosing class.
Definition: metaclass.h:53
#define SWIFT_MISC_EXPORT
Export a class or function from the library.
#define SWIFT_DECLARE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template declaration of mixins for a CValueObject subclass to be placed near the top of the ...
Definition: valueobject.h:65