swift
ongroundinfo.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 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_ONGROUNDINFO_H
7 #define SWIFT_MISC_AVIATION_ONGROUNDINFO_H
8 
9 #include "misc/pq/length.h"
10 #include "misc/swiftmiscexport.h"
11 #include "misc/valueobject.h"
12 
13 SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::misc::Aviation, COnGroundInfo)
14 
15 namespace swift::misc::aviation
16 {
18  class SWIFT_MISC_EXPORT COnGroundInfo : public CValueObject<COnGroundInfo>
19  {
20  public:
23  {
24  NotOnGround,
25  OnGround,
26  OnGroundSituationUnknown
27  };
28 
31  {
33  // interpolated situation
35  OnGroundByElevationAndCG,
37  // received situation
40  // send information
41  OutOnGroundOwnAircraft
42  };
43 
46  {
47  IndexOnGroundFactor = CPropertyIndexRef::GlobalIndexCOnGroundInfo,
48  IndexOnGroundDetails,
49  };
50 
51  COnGroundInfo() = default;
52 
55  COnGroundInfo(IsOnGround onGround, OnGroundDetails details);
56 
59 
61  explicit COnGroundInfo(double interpolatedGndFactor);
62 
66  double getGroundFactor() const { return m_onGroundFactor; }
67 
70  {
71  // TODO Assert not by interpolation
72  m_onGroundDetails = static_cast<int>(details);
73  }
74 
77  IsOnGround getOnGround() const;
78 
81  OnGroundDetails getGroundDetails() const;
82 
84  QString convertToQString(bool i18n = false) const;
85 
87  QVariant propertyByIndex(CPropertyIndexRef index) const;
88 
90  void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant);
91 
93  static void registerMetadata();
94 
96  static const QString &isOnGroundToString(IsOnGround onGround);
97 
99  static const QString &onGroundDetailsToString(OnGroundDetails reliability);
100 
102  static const physical_quantities::CLength &deltaNearGround();
103 
104  private:
111  bool isOnGround() const;
112 
113  int m_onGroundDetails = static_cast<int>(OnGroundDetails::NotSetGroundDetails);
114  double m_onGroundFactor = -1.0;
115 
116  static constexpr double m_groundFactorThreshold =
117  0.95;
119 
122  SWIFT_METAMEMBER(onGroundDetails),
123  SWIFT_METAMEMBER(onGroundFactor));
124  };
125 
126 } // namespace swift::misc::aviation
127 
128 Q_DECLARE_METATYPE(swift::misc::aviation::COnGroundInfo)
131 
132 #endif // SWIFT_MISC_AVIATION_ONGROUNDINFO_H
Non-owning reference to a CPropertyIndex with a subset of its features.
Mix of the most commonly used mixin classes.
Definition: valueobject.h:114
Information about the ground status.
Definition: ongroundinfo.h:19
OnGroundDetails
Reliability of on ground information.
Definition: ongroundinfo.h:31
@ InFromParts
set from aircraft parts
Definition: ongroundinfo.h:39
@ InFromNetwork
received from network
Definition: ongroundinfo.h:38
@ OnGroundByInterpolation
strongest for remote aircraft
Definition: ongroundinfo.h:34
@ NotSetGroundDetails
not set or unknown if correct (e.g.
Definition: ongroundinfo.h:32
double getGroundFactor() const
Get the ground factor Use this for interpolation only!! For just checking if the info is OnGround or ...
Definition: ongroundinfo.h:66
void setOnGroundDetails(OnGroundDetails details)
When source of knowledge changes.
Definition: ongroundinfo.h:69
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
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