0.2.0
Loading...
Searching...
No Matches
Frequency.hpp
Go to the documentation of this file.
1// This file is part of INSTINCT, the INS Toolkit for Integrated
2// Navigation Concepts and Training by the Institute of Navigation of
3// the University of Stuttgart, Germany.
4//
5// This Source Code Form is subject to the terms of the Mozilla Public
6// License, v. 2.0. If a copy of the MPL was not distributed with this
7// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
13
14#pragma once
15
16#include <string>
17#include <fmt/format.h>
18
20
21namespace NAV
22{
23
25enum Frequency_ : uint64_t
26{ // clang-format off
27 Freq_None = 0x0000'0000'0000'0000,
28 G01 = 0x0000'0000'0000'0001,
29 G02 = 0x0000'0000'0000'0002,
30 G05 = 0x0000'0000'0000'0004,
31 E01 = 0x0000'0000'0000'0100,
32 E05 = 0x0000'0000'0000'0200,
33 E06 = 0x0000'0000'0000'0400,
34 E07 = 0x0000'0000'0000'0800,
35 E08 = 0x0000'0000'0000'1000,
36 R01 = 0x0000'0000'0001'0000,
37 R02 = 0x0000'0000'0002'0000,
38 R03 = 0x0000'0000'0004'0000,
39 R04 = 0x0000'0000'0008'0000,
40 R06 = 0x0000'0000'0010'0000,
41 B01 = 0x0000'0000'0100'0000,
42 B02 = 0x0000'0000'0200'0000,
43 B05 = 0x0000'0000'0400'0000,
44 B06 = 0x0000'0000'0800'0000,
45 B07 = 0x0000'0000'1000'0000,
46 B08 = 0x0000'0000'2000'0000,
47 J01 = 0x0000'0001'0000'0000,
48 J02 = 0x0000'0002'0000'0000,
49 J05 = 0x0000'0004'0000'0000,
50 J06 = 0x0000'0008'0000'0000,
51 I05 = 0x0000'0100'0000'0000,
52 I09 = 0x0000'0200'0000'0000,
53 S01 = 0x0001'0000'0000'0000,
54 S05 = 0x0002'0000'0000'0000,
55}; // clang-format on
56
59{
60 public:
94
96 constexpr Frequency() = default;
97
100 constexpr Frequency(Frequency_ type) // NOLINT(hicpp-explicit-conversions, google-explicit-constructor)
101 : value(type)
102 {}
103
106 Frequency(Enum enumeration) // NOLINT(hicpp-explicit-conversions, google-explicit-constructor)
107 : value(Frequency::fromEnum(enumeration))
108 {}
109
112 static Frequency fromString(const std::string& typeString);
113
116 static Frequency fromEnum(Enum enumeration);
117
122 {
123 value = v;
124 return *this;
125 }
126
127 friend constexpr bool operator==(const Frequency& lhs, const Frequency& rhs);
128
132 constexpr bool operator<(const Frequency& rhs) const { return value < rhs.value; }
133
135 constexpr explicit operator Frequency_() const { return value; }
137 constexpr explicit operator bool() = delete;
138
141 constexpr explicit operator uint64_t() const { return uint64_t(value); }
142
145 explicit operator std::string() const;
146
150
152 [[nodiscard]] SatelliteSystem getSatSys() const
153 {
154 return GetSatelliteSystemForFrequency(value);
155 }
156
160 static double GetFrequency(Frequency freq, int8_t num);
161
164 [[nodiscard]] double getFrequency(int8_t num) const
165 {
166 return GetFrequency(value, num);
167 }
168
172
174 [[nodiscard]] Frequency getL1() const
175 {
176 return GetL1(value);
177 }
178
180 [[nodiscard]] size_t count() const;
181
183 constexpr static std::array<Frequency, 27> GetAll()
184 {
185 return { G01, G02, G05,
186 E01, E05, E06, E07, E08,
187 R01, R02, R03, R04, R06,
188 B01, B02, B05, B06, B07, B08,
189 J01, J02, J05, J06,
190 I05, I09,
191 S01, S05 };
192 }
193
197
199 [[nodiscard]] Enum toEnumeration() const;
200
201 private:
203 Frequency_ value = Frequency_::Freq_None;
204};
205
206// #########################################################################################################################################
207
211void to_json(json& j, const Frequency& data);
215void from_json(const json& j, Frequency& data);
216
217// #########################################################################################################################################
218
224{
225 return Frequency_(uint64_t(lhs) | uint64_t(rhs));
226}
232{
233 return Frequency_(lhs) | Frequency_(rhs);
234}
240{
241 return lhs | Frequency_(rhs);
242}
248{
249 return Frequency_(lhs) | rhs;
250}
251
256constexpr Frequency_& operator|=(Frequency_& lhs, const Frequency_& rhs)
257{
258 lhs = lhs | rhs;
259 return lhs;
260}
265constexpr Frequency& operator|=(Frequency& lhs, const Frequency& rhs)
266{
267 lhs = lhs | rhs;
268 return lhs;
269}
274constexpr Frequency_& operator|=(Frequency_& lhs, const Frequency& rhs)
275{
276 lhs = lhs | Frequency_(rhs);
277 return lhs;
278}
283constexpr Frequency& operator|=(Frequency& lhs, const Frequency_& rhs)
284{
285 lhs = lhs | rhs;
286 return lhs;
287}
288
294{
295 return Frequency_(uint64_t(lhs) & uint64_t(rhs));
296}
302{
303 return Frequency_(lhs) & Frequency_(rhs);
304}
310{
311 return Frequency_(lhs) & rhs;
312}
318{
319 return lhs & Frequency_(rhs);
320}
321
326constexpr Frequency_& operator&=(Frequency_& lhs, const Frequency_& rhs)
327{
328 lhs = lhs & rhs;
329 return lhs;
330}
335constexpr Frequency& operator&=(Frequency& lhs, const Frequency& rhs)
336{
337 lhs = lhs & rhs;
338 return lhs;
339}
344constexpr Frequency_& operator&=(Frequency_& lhs, const Frequency& rhs)
345{
346 lhs = lhs & Frequency_(rhs);
347 return lhs;
348}
353constexpr Frequency& operator&=(Frequency& lhs, const Frequency_& rhs)
354{
355 lhs = lhs & rhs;
356 return lhs;
357}
358
363{
364 return Frequency_(~uint64_t(rhs));
365}
370{
371 return Frequency_(~uint64_t(rhs));
372}
373
378constexpr bool operator==(const Frequency& lhs, const Frequency& rhs) { return lhs.value == rhs.value; }
383constexpr bool operator==(const Frequency& lhs, const Frequency_& rhs) { return lhs == Frequency(rhs); }
388constexpr bool operator==(const Frequency_& lhs, const Frequency& rhs) { return Frequency(lhs) == rhs; }
389
394constexpr bool operator!=(const Frequency& lhs, const Frequency& rhs) { return !(lhs == rhs); }
399constexpr bool operator!=(const Frequency& lhs, const Frequency_& rhs) { return !(lhs == rhs); }
404constexpr bool operator!=(const Frequency_& lhs, const Frequency& rhs) { return !(lhs == rhs); }
405
406// #########################################################################################################################################
407
413{
414 return Frequency_(uint64_t(lhs) & uint64_t(rhs));
415}
421{
422 return Frequency_(uint64_t(lhs) & uint64_t(rhs));
423}
429{
430 lhs = lhs & rhs;
431 return lhs;
432}
433
439{
440 return Frequency_(uint64_t(lhs) & uint64_t(rhs));
441}
447{
448 return Frequency_(uint64_t(lhs) & uint64_t(rhs));
449}
455{
456 lhs = lhs & rhs;
457 return lhs;
458}
459
465{
466 return Frequency_(uint64_t(lhs) & uint64_t(rhs));
467}
473{
474 return Frequency_(uint64_t(lhs) & uint64_t(rhs));
475}
480constexpr Frequency& operator&=(Frequency& lhs, const SatelliteSystem_& rhs)
481{
482 lhs = lhs & rhs;
483 return lhs;
484}
485
491{
492 return Frequency_(uint64_t(lhs) & uint64_t(rhs));
493}
499{
500 return Frequency_(uint64_t(lhs) & uint64_t(rhs));
501}
506constexpr Frequency& operator&=(Frequency& lhs, const SatelliteSystem& rhs)
507{
508 lhs = lhs & rhs;
509 return lhs;
510}
511
514 | E01 | E05 | E06 | E07 | E08
515 | R01 | R02 | R03 | R04 | R06
516 | B01 | B02 | B05 | B06 | B07 | B08
517 | J01 | J02 | J05 | J06
518 | I05 | I09
519 | S01 | S05;
520
525bool ShowFrequencySelector(const char* label, Frequency& frequency, bool singleSelect = false);
526
527} // namespace NAV
528
533std::ostream& operator<<(std::ostream& os, const NAV::Frequency& obj);
534
535namespace std
536{
538template<>
539struct hash<NAV::Frequency_>
540{
544 std::size_t operator()(const NAV::Frequency_& f) const
545 {
546 using namespace NAV; // NOLINT(google-build-using-namespace)
547 switch (f)
548 {
549 case Freq_None:
550 return 2;
551 case G01:
552 return 101;
553 case G02:
554 return 102;
555 case G05:
556 return 103;
557 case E01:
558 return 201;
559 case E05:
560 return 202;
561 case E06:
562 return 203;
563 case E07:
564 return 204;
565 case E08:
566 return 205;
567 case R01:
568 return 301;
569 case R02:
570 return 302;
571 case R03:
572 return 303;
573 case R04:
574 return 304;
575 case R06:
576 return 305;
577 case B01:
578 return 401;
579 case B02:
580 return 402;
581 case B05:
582 return 403;
583 case B06:
584 return 404;
585 case B07:
586 return 405;
587 case B08:
588 return 406;
589 case J01:
590 return 501;
591 case J02:
592 return 502;
593 case J05:
594 return 503;
595 case J06:
596 return 504;
597 case I05:
598 return 601;
599 case I09:
600 return 602;
601 case S01:
602 return 701;
603 case S05:
604 return 702;
605 }
606
607 return 0;
608 }
609};
611template<>
612struct hash<NAV::Frequency>
613{
617 std::size_t operator()(const NAV::Frequency& f) const
618 {
619 return std::hash<NAV::Frequency_>()(NAV::Frequency_(f));
620 }
621};
622} // namespace std
623
624#ifndef DOXYGEN_IGNORE
625
627template<>
628struct fmt::formatter<NAV::Frequency> : fmt::formatter<std::string>
629{
634 template<typename FormatContext>
635 auto format(const NAV::Frequency& freq, FormatContext& ctx)
636 {
637 return fmt::formatter<std::string>::format(std::string(freq), ctx);
638 }
639};
640
641#endif
Code operator|(const Code::Enum &lhs, const Code::Enum &rhs)
Allows combining flags of the Code enum.
Code operator&(const Code::Enum &lhs, const Code::Enum &rhs)
Allows combining flags of the Code enum.
nlohmann::json json
json namespace
Definition FlowManager.hpp:21
constexpr Frequency_ Freq_All
All Frequencies.
Definition Frequency.hpp:513
Frequency_
Enumerate for GNSS frequencies.
Definition Frequency.hpp:26
@ E07
Galileo E5b (1207.14 MHz).
Definition Frequency.hpp:34
@ R03
GLONASS, "G3" (1202.025 MHz).
Definition Frequency.hpp:38
@ J01
QZSS L1 (1575.42 MHz).
Definition Frequency.hpp:47
@ B02
Beidou B1-2 (1561.098 MHz).
Definition Frequency.hpp:42
@ S01
SBAS L1 (1575.42 MHz).
Definition Frequency.hpp:53
@ E06
Galileo E6 (1278.75 MHz).
Definition Frequency.hpp:33
@ Freq_None
None.
Definition Frequency.hpp:27
@ I09
IRNSS S (2492.028 MHz).
Definition Frequency.hpp:52
@ B05
Beidou B2a (1176.45 MHz).
Definition Frequency.hpp:43
@ I05
IRNSS L5 (1176.45 MHz).
Definition Frequency.hpp:51
@ R02
GLONASS, "G2" (1246 MHz).
Definition Frequency.hpp:37
@ B08
Beidou B2 (B2a + B2b) (1191.795MHz).
Definition Frequency.hpp:46
@ R06
GLONASS, "G2a" (1248.06 MHz).
Definition Frequency.hpp:40
@ E01
Galileo, "E1" (1575.42 MHz).
Definition Frequency.hpp:31
@ B06
Beidou B3 (1268.52 MHz).
Definition Frequency.hpp:44
@ E05
Galileo E5a (1176.45 MHz).
Definition Frequency.hpp:32
@ S05
SBAS L5 (1176.45 MHz).
Definition Frequency.hpp:54
@ G02
GPS L2 (1227.6 MHz).
Definition Frequency.hpp:29
@ R01
GLONASS, "G1" (1602 MHZ).
Definition Frequency.hpp:36
@ G01
GPS L1 (1575.42 MHz).
Definition Frequency.hpp:28
@ B01
Beidou B1 (1575.42 MHz).
Definition Frequency.hpp:41
@ J05
QZSS L5 (1176.45 MHz).
Definition Frequency.hpp:49
@ J02
QZSS L2 (1227.6 MHz).
Definition Frequency.hpp:48
@ B07
Beidou B2b (1207.14 MHz).
Definition Frequency.hpp:45
@ R04
GLONASS, "G1a" (1600.995 MHZ).
Definition Frequency.hpp:39
@ E08
Galileo E5 (E5a + E5b) (1191.795MHz).
Definition Frequency.hpp:35
@ J06
QZSS L6 / LEX (1278.75 MHz).
Definition Frequency.hpp:50
@ G05
GPS L5 (1176.45 MHz).
Definition Frequency.hpp:30
bool ShowFrequencySelector(const char *label, Frequency &frequency, bool singleSelect=false)
Shows a ComboBox to select GNSS frequencies.
constexpr Frequency_ operator~(Frequency_ rhs)
Allows negating flags of the Frequency enum.
Definition Frequency.hpp:362
constexpr Frequency_ & operator&=(Frequency_ &lhs, const Frequency_ &rhs)
Allows combining flags of the Frequency enum.
Definition Frequency.hpp:326
std::ostream & operator<<(std::ostream &os, const NAV::Frequency &obj)
Stream insertion operator overload.
constexpr Frequency_ & operator|=(Frequency_ &lhs, const Frequency_ &rhs)
Allows combining flags of the Frequency enum.
Definition Frequency.hpp:256
GNSS Satellite System.
SatelliteSystem_
Satellite System enumeration.
Definition SatelliteSystem.hpp:30
Frequency definition for different satellite systems.
Definition Frequency.hpp:59
constexpr Frequency & operator=(Frequency_ v)
Assignment operator from Value type.
Definition Frequency.hpp:121
static constexpr std::array< Frequency, 27 > GetAll()
Returns a list with all possible frequencies.
Definition Frequency.hpp:183
SatelliteSystem getSatSys() const
Get the satellite system for which this frequency is defined.
Definition Frequency.hpp:152
static Frequency fromString(const std::string &typeString)
Construct new object from std::string.
constexpr Frequency(Frequency_ type)
Implicit Constructor from Value type.
Definition Frequency.hpp:100
Frequency getL1() const
Returns the L1 Frequency for each constellation.
Definition Frequency.hpp:174
static Enum ToEnumeration(Frequency freq)
Get the continuous enumeration of the specified frequency.
Enum toEnumeration() const
Returns a continuous enumeration of the object.
static Frequency GetL1(Frequency freq)
Returns the L1 Frequency for each constellation.
Enum
Satellite System enumeration with continuous range. Not usable as a mask.
Definition Frequency.hpp:63
@ Enum_R02
GLONASS, "G2" (1246 MHz).
Definition Frequency.hpp:73
@ Enum_R03
GLONASS, "G3" (1202.025 MHz).
Definition Frequency.hpp:74
@ Enum_None
No Frequency.
Definition Frequency.hpp:92
@ Enum_B08
Beidou B2 (B2a + B2b) (1191.795MHz).
Definition Frequency.hpp:82
@ Enum_J05
QZSS L5 (1176.45 MHz).
Definition Frequency.hpp:85
@ Enum_COUNT
Count variable.
Definition Frequency.hpp:91
@ Enum_E08
Galileo E5 (E5a + E5b) (1191.795MHz).
Definition Frequency.hpp:71
@ Enum_E01
Galileo, "E1" (1575.42 MHz).
Definition Frequency.hpp:67
@ Enum_B05
Beidou B2a (1176.45 MHz).
Definition Frequency.hpp:79
@ Enum_B07
Beidou B2b (1207.14 MHz).
Definition Frequency.hpp:81
@ Enum_R06
GLONASS, "G2a" (1248.06 MHz).
Definition Frequency.hpp:76
@ Enum_R01
GLONASS, "G1" (1602 MHZ).
Definition Frequency.hpp:72
@ Enum_R04
GLONASS, "G1a" (1600.995 MHZ).
Definition Frequency.hpp:75
@ Enum_S01
SBAS L1 (1575.42 MHz).
Definition Frequency.hpp:89
@ Enum_G05
GPS L5 (1176.45 MHz).
Definition Frequency.hpp:66
@ Enum_E07
Galileo E5b (1207.14 MHz).
Definition Frequency.hpp:70
@ Enum_G02
GPS L2 (1227.6 MHz).
Definition Frequency.hpp:65
@ Enum_G01
GPS L1 (1575.42 MHz).
Definition Frequency.hpp:64
@ Enum_I05
IRNSS L5 (1176.45 MHz).
Definition Frequency.hpp:87
@ Enum_I09
IRNSS S (2492.028 MHz).
Definition Frequency.hpp:88
@ Enum_S05
SBAS L5 (1176.45 MHz).
Definition Frequency.hpp:90
@ Enum_B02
Beidou B1-2 (1561.098 MHz).
Definition Frequency.hpp:78
@ Enum_J02
QZSS L2 (1227.6 MHz).
Definition Frequency.hpp:84
@ Enum_J06
QZSS L6 / LEX (1278.75 MHz).
Definition Frequency.hpp:86
@ Enum_E05
Galileo E5a (1176.45 MHz).
Definition Frequency.hpp:68
@ Enum_E06
Galileo E6 (1278.75 MHz).
Definition Frequency.hpp:69
@ Enum_J01
QZSS L1 (1575.42 MHz).
Definition Frequency.hpp:83
@ Enum_B06
Beidou B3 (1268.52 MHz).
Definition Frequency.hpp:80
@ Enum_B01
Beidou B1 (1575.42 MHz).
Definition Frequency.hpp:77
Frequency(Enum enumeration)
Implicit Constructor from Enum type.
Definition Frequency.hpp:106
static Frequency fromEnum(Enum enumeration)
Constructs a new object from continuous enumeration.
static SatelliteSystem GetSatelliteSystemForFrequency(Frequency freq)
Get the Time System of the specified Frequency.
static double GetFrequency(Frequency freq, int8_t num)
Get the frequency in [Hz].
friend constexpr bool operator==(const Frequency &lhs, const Frequency &rhs)
Equal compares values.
Definition Frequency.hpp:378
constexpr Frequency()=default
Default Constructor.
double getFrequency(int8_t num) const
Get the frequency in [Hz].
Definition Frequency.hpp:164
size_t count() const
Counts the amount of frequencies contained.
constexpr bool operator<(const Frequency &rhs) const
Less than comparison (needed for map)
Definition Frequency.hpp:132
bool operator==(const ImVec4 &lhs, const ImVec4 &rhs)
Equal comparison operator.
bool operator!=(const ImVec4 &lhs, const ImVec4 &rhs)
Unequal comparison operator.
Satellite System type.
Definition SatelliteSystem.hpp:43
std::size_t operator()(const NAV::Frequency &f) const
Hash function for Frequency.
Definition Frequency.hpp:617
std::size_t operator()(const NAV::Frequency_ &f) const
Hash function for Frequency.
Definition Frequency.hpp:544