swift
aircraftsituationchange.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2018 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_AIRCRAFTSITUATIONCHANGE_H
7 #define SWIFT_MISC_AVIATION_AIRCRAFTSITUATIONCHANGE_H
8 
10 #include "misc/aviation/callsign.h"
11 #include "misc/metaclass.h"
12 #include "misc/pq/angle.h"
13 #include "misc/pq/speed.h"
14 #include "misc/propertyindexref.h"
15 #include "misc/swiftmiscexport.h"
16 #include "misc/timestampbased.h"
17 #include "misc/valueobject.h"
18 
19 SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::misc::aviation, CAircraftSituationChange)
20 
21 namespace swift::misc
22 {
23  namespace simulation
24  {
25  class CAircraftModel;
26  }
27  namespace aviation
28  {
29  class CAircraftSituation;
30  class CAircraftSituationList;
31 
34  public CValueObject<CAircraftSituationChange>,
36  {
37  public:
40  {
41  IndexCallsign = CPropertyIndexRef::GlobalIndexCAircraftSituationChange,
42  IndexIsNull,
43  IndexSituationsCount,
44  IndexConstAscending,
45  IndexConstDescending,
46  IndexConstOnGround,
47  IndexConstNotOnGround,
48  IndexJustTakingOff,
49  IndexJustTouchingDown,
50  IndexRotatingUp,
51  IndexContainsPushBack,
52  IndexAltitudeMean,
53  IndexAltitudeStdDev,
54  IndexElevationMean,
55  IndexElevationStdDev,
56  };
57 
60  {
61  NoDeviationInfo,
64  SmallAGLDeviationNearGround
65  };
66 
69 
73  bool isVtol, bool alreadySortedLatestFirst = false,
74  bool calcStdDeviations = false);
75 
77  const CCallsign &getCallsign() const { return m_correspondingCallsign; }
78 
80  bool isNull() const { return m_situationsCount < 2; } // we need at least 2 situations
81 
83  int getSituationsCount() const { return m_situationsCount; }
84 
86  bool isConstAscending() const { return m_constAscending; }
87 
89  bool isConstDescending() const { return m_constDescending; }
90 
92  bool isConstOnGround() const { return m_constOnGround; }
93 
95  bool wasConstOnGround() const { return m_wasOnGround; }
96 
98  bool isConstNotOnGround() const { return m_constNotOnGround; }
99 
101  bool wasConstNotOnGround() const { return m_wasNotOnGround; }
102 
104  bool isConstAccelerating() const { return m_constAccelerating; }
105 
107  bool isConstDecelarating() const { return m_constAccelerating; }
108 
110  bool isJustTakingOff() const { return m_justTakeoff; }
111 
113  bool isJustTouchingDown() const { return m_justTouchdown; }
114 
116  bool isRotatingUp() const { return m_rotateUp; }
117 
119  bool containsPushBack() const { return m_containsPushBack; }
120 
122  CAltitudePair getElevationStdDevAndMean() const { return CAltitudePair(m_elvStdDev, m_elvMean); }
123 
125  bool guessOnGround(CAircraftSituation &situation, const simulation::CAircraftModel &model) const;
126 
129  const physical_quantities::CLength &getGuessedSceneryDeviation() const { return m_guessedSceneryDeviation; }
130 
132  physical_quantities::CLength getGuessedSceneryDeviationCG() const { return m_guessedSceneryDeviationCG; }
133 
136  {
137  return static_cast<GuessedSceneryDeviation>(m_guessedSceneryDeviationHint);
138  }
139 
141  const QString &getSceneryDeviationHintAsString() const
142  {
143  return guessedSceneryDeviationToString(this->getSceneryDeviationHint());
144  }
145 
147  bool hasSceneryDeviation() const;
148 
150  bool hasElevationDevWithinAllowedRange() const;
151 
153  bool hasAltitudeDevWithinAllowedRange() const;
154 
156  QString convertToQString(bool i18n = false) const;
157 
159  QVariant propertyByIndex(CPropertyIndexRef index) const;
160 
162  void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant);
163 
165  int comparePropertyByIndex(CPropertyIndexRef index, const CAircraftSituationChange &compareValue) const;
166 
168  bool calculateStdDeviations(const CAircraftSituationList &situations,
169  const physical_quantities::CLength &cg);
170 
172  static const CAircraftSituationChange &null();
173 
175  static const QString &guessedSceneryDeviationToString(GuessedSceneryDeviation hint);
176 
178  static void registerMetadata();
179 
180  private:
182  void setSceneryDeviationHint(GuessedSceneryDeviation hint)
183  {
184  m_guessedSceneryDeviationHint = static_cast<int>(hint);
185  }
186 
188  void setSceneryDeviation(const physical_quantities::CLength &deviation,
189  const physical_quantities::CLength &cg, GuessedSceneryDeviation hint);
190 
192  void guessSceneryDeviation(const physical_quantities::CLength &cg);
193 
194  int m_situationsCount = -1;
195  CCallsign m_correspondingCallsign;
196  // latest -> m_timestampMSecsSinceEpoch
197  qint64 m_oldestTimestampMSecsSinceEpoch = -1;
198  qint64 m_oldestAdjustedTimestampMSecsSinceEpoch = -1;
199  qint64 m_latestAdjustedTimestampMSecsSinceEpoch = -1;
200  bool m_constAscending = false;
201  bool m_constDescending = false;
202  bool m_constOnGround = false;
203  bool m_wasOnGround = false;
204  bool m_constNotOnGround = false;
205  bool m_wasNotOnGround = false;
206  bool m_justTakeoff = false;
207  bool m_justTouchdown = false;
208  bool m_rotateUp = false;
209  bool m_constAccelerating = false;
210  bool m_constDecelerating = false;
211  bool m_containsPushBack = false;
212  int m_guessedSceneryDeviationHint = static_cast<int>(NoDeviationInfo);
213  CAltitude m_altStdDev = CAltitude::null();
214  CAltitude m_altMean = CAltitude::null();
215  CAltitude m_elvStdDev = CAltitude::null();
216  CAltitude m_elvMean = CAltitude::null();
227 
229  CAircraftSituationChange,
230  SWIFT_METAMEMBER(situationsCount),
231  SWIFT_METAMEMBER(correspondingCallsign),
232  SWIFT_METAMEMBER(constAscending),
233  SWIFT_METAMEMBER(constDescending),
234  SWIFT_METAMEMBER(constOnGround),
235  SWIFT_METAMEMBER(constNotOnGround),
236  SWIFT_METAMEMBER(justTakeoff),
237  SWIFT_METAMEMBER(justTouchdown),
238  SWIFT_METAMEMBER(containsPushBack),
239  SWIFT_METAMEMBER(rotateUp),
240  SWIFT_METAMEMBER(altStdDev),
241  SWIFT_METAMEMBER(altMean),
242  SWIFT_METAMEMBER(elvStdDev),
243  SWIFT_METAMEMBER(elvMean),
244  SWIFT_METAMEMBER(gsStdDev),
245  SWIFT_METAMEMBER(gsMean),
246  SWIFT_METAMEMBER(gndDistStdDev),
247  SWIFT_METAMEMBER(gndDistMean),
248  SWIFT_METAMEMBER(pitchStdDev),
249  SWIFT_METAMEMBER(pitchMean),
250  SWIFT_METAMEMBER(guessedSceneryDeviation),
251  SWIFT_METAMEMBER(guessedSceneryDeviationCG),
252  SWIFT_METAMEMBER(guessedSceneryDeviationHint),
253  SWIFT_METAMEMBER(timestampMSecsSinceEpoch),
254  SWIFT_METAMEMBER(oldestTimestampMSecsSinceEpoch),
255  SWIFT_METAMEMBER(oldestAdjustedTimestampMSecsSinceEpoch),
256  SWIFT_METAMEMBER(latestAdjustedTimestampMSecsSinceEpoch));
257  };
258  } // namespace aviation
259 } // namespace swift::misc
260 
263 
264 #endif // SWIFT_MISC_AVIATION_AIRCRAFTSITUATIONCHANGE_H
QPair< CAltitude, CAltitude > CAltitudePair
Pair of altitude.
Definition: altitude.h:251
Non-owning reference to a CPropertyIndex with a subset of its features.
Mix of the most commonly used mixin classes.
Definition: valueobject.h:114
Value object about changes in situations.
int getSituationsCount() const
Basend on n situations.
const physical_quantities::CLength & getGuessedSceneryDeviation() const
Scnenery deviation (if it can be calculated, otherwise physical_quantities::CLength::null)
bool containsPushBack() const
Contains any push back?
const QString & getSceneryDeviationHintAsString() const
Scenery deviation hint hint as string.
bool isConstDescending() const
Constantly descending?
bool isConstAscending() const
Constantly ascending?
CAltitudePair getElevationStdDevAndMean() const
Elevation standard deviation and mean.
bool wasConstNotOnGround() const
Was not on ground (without latest situation)?
bool isConstAccelerating() const
Constantly accelerating?
CAircraftSituationChange()=default
Default constructor.
const CCallsign & getCallsign() const
Get callsign.
GuessedSceneryDeviation
Hint about the guessed scenery deviation.
@ WasOnGround
was on ground except last situation
bool isConstDecelarating() const
Constantly decelarating?
bool isJustTouchingDown() const
Is just touching down?
bool isConstOnGround() const
Are all situations on ground?
bool isConstNotOnGround() const
Are all situations not on ground?
GuessedSceneryDeviation getSceneryDeviationHint() const
Scenery deviation hint.
physical_quantities::CLength getGuessedSceneryDeviationCG() const
Get scenery deviation under consideration of CG.
bool wasConstOnGround() const
Was on ground (without latest situation)?
Value object encapsulating information of an aircraft's situation.
static const CAltitude & null()
Null altitude (MSL)
Definition: altitude.cpp:439
Value object encapsulating information of a callsign.
Definition: callsign.h:30
Physical unit angle (radians, degrees)
Definition: angle.h:23
Physical unit length (length)
Definition: length.h:18
Aircraft model (used by another pilot, my models on disk)
Definition: aircraftmodel.h:71
#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
Free functions in swift::misc.
void registerMetadata()
Register all relevant metadata in Misc.
#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