swift
Loading...
Searching...
No Matches
comsystem.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_COMSYSTEM_H
7#define SWIFT_MISC_AVIATION_COMSYSTEM_H
8
9#include <tuple>
10
11#include <QHash>
12#include <QJsonObject>
13#include <QMetaType>
14#include <QString>
15
17#include "misc/metaclass.h"
22#include "misc/pq/constants.h"
23#include "misc/pq/frequency.h"
25#include "misc/pq/pqstring.h"
26#include "misc/pq/units.h"
28
29namespace swift::misc::aviation
30{
33 public CModulator<CComSystem>,
34 public mixin::MetaType<CComSystem>,
35 public mixin::JsonOperators<CComSystem>,
36 public mixin::Index<CComSystem>
37 {
38 public:
41
44
45
52
55 {
56 Com1,
57 Com2
58 };
59
61 CComSystem() = default;
62
64 CComSystem(const QString &name, const physical_quantities::CFrequency &activeFrequency,
66 &standbyFrequency = { 0, physical_quantities::CFrequencyUnit::nullUnit() })
67 : CModulator(name, activeFrequency, standbyFrequency.isNull() ? activeFrequency : standbyFrequency)
68 {}
69
72 void setFrequencyActiveMHz(double frequencyMHz);
73
76 void setFrequencyStandbyMHz(double frequencyMHz);
77
80 void setFrequencyActive(const physical_quantities::CFrequency &frequency);
81
84 void setFrequencyStandby(const physical_quantities::CFrequency &frequency);
85
87 bool isActiveFrequencySameFrequency(const physical_quantities::CFrequency &comFrequency) const;
88
90 void setActiveUnicom();
91
93 ChannelSpacing getChannelSpacing() const { return m_channelSpacing; }
94
96 void setChannelSpacing(ChannelSpacing spacing) { m_channelSpacing = spacing; }
97
99 static CComSystem getCom1System(double activeFrequencyMHz, double standbyFrequencyMHz = -1);
100
102 static CComSystem getCom1System(const physical_quantities::CFrequency &activeFrequency,
103 const physical_quantities::CFrequency &standbyFrequency = {
106 static CComSystem getCom2System(double activeFrequencyMHz, double standbyFrequencyMHz = -1);
107
109 static CComSystem getCom2System(const physical_quantities::CFrequency &activeFrequency,
110 const physical_quantities::CFrequency &standbyFrequency = {
112
114 static bool isValidCivilAviationFrequency(const physical_quantities::CFrequency &f);
115
117 static bool isValidMilitaryFrequency(const physical_quantities::CFrequency &f);
118
120 static bool isValidComFrequency(const physical_quantities::CFrequency &f);
121
124 static void roundToChannelSpacing(physical_quantities::CFrequency &frequency, ChannelSpacing channelSpacing);
125
128 static bool isSameFrequency(const physical_quantities::CFrequency &freq1,
129 const physical_quantities::CFrequency &freq2);
130
133 static bool isValid8_33kHzChannel(int fKHz);
134
136 static int round8_33kHzChannel(int fKHz);
137
140 static bool isExclusiveWithin8_33kHzChannel(const physical_quantities::CFrequency &freq);
141
143 static bool isWithin25kHzChannel(const physical_quantities::CFrequency &freq);
144
146 static physical_quantities::CFrequency parseComFrequency(const QString &input,
147 physical_quantities::CPqString::SeparatorMode sep);
148
150 static void registerMetadata();
151
152 private:
153 ChannelSpacing m_channelSpacing = ChannelSpacing8_33KHz;
154
157 static double channelSpacingToFrequencyKHz(ChannelSpacing channelSpacing);
158
160 CComSystem,
161 SWIFT_METAMEMBER(channelSpacing));
162 };
163} // namespace swift::misc::aviation
164
165Q_DECLARE_METATYPE(swift::misc::aviation::CComSystem)
168
169#endif // SWIFT_MISC_AVIATION_COMSYSTEM_H
COM system (aka "radio").
Definition comsystem.h:37
CComSystem(const QString &name, const physical_quantities::CFrequency &activeFrequency, const physical_quantities::CFrequency &standbyFrequency={ 0, physical_quantities::CFrequencyUnit::nullUnit() })
Constructor.
Definition comsystem.h:64
CModulator< CComSystem > base_type
Base type.
Definition comsystem.h:40
void setChannelSpacing(ChannelSpacing spacing)
Set channel spacing.
Definition comsystem.h:96
ChannelSpacing getChannelSpacing() const
Get channel spacing.
Definition comsystem.h:93
ChannelSpacing
Channel spacing frequency.
Definition comsystem.h:47
CComSystem()=default
Default constructor.
Base class for COM, NAV, Squawk units.
Definition modulator.h:17
CRTP class template from which a derived class can inherit property indexing functions.
Definition mixinindex.h:40
CRTP class template which will generate marshalling operators for a derived class with its own marsha...
Definition mixinjson.h:37
CRTP class template from which a derived class can inherit common methods dealing with the metatype o...
static CFrequencyUnit nullUnit()
Null unit.
Definition units.h:356
#define SWIFT_METAMEMBER(MEMBER,...)
Macro to define an element within a metaclass.
Definition metaclass.h:72
#define SWIFT_METACLASS(CLASS,...)
Macro to define a nested metaclass that describes the attributes of its enclosing class.
Definition metaclass.h:52
#define SWIFT_MISC_DECLARE_USING_MIXIN_INDEX(DERIVED)
When a derived class and a base class both inherit from mixin::Index, the derived class uses this mac...
Definition mixinindex.h:159
#define SWIFT_MISC_DECLARE_USING_MIXIN_METATYPE(DERIVED)
When a derived class and a base class both inherit from mixin::MetaType, the derived class uses this ...
#define SWIFT_MISC_EXPORT
Export a class or function from the library.