| Line | Branch | Exec | Source |
|---|---|---|---|
| 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 | |||
| 9 | /// @file Frequency.hpp | ||
| 10 | /// @brief Frequency definition for different satellite systems | ||
| 11 | /// @author T. Topp (topp@ins.uni-stuttgart.de) | ||
| 12 | /// @date 2022-04-26 | ||
| 13 | |||
| 14 | #pragma once | ||
| 15 | |||
| 16 | #include <string> | ||
| 17 | #include <fmt/format.h> | ||
| 18 | |||
| 19 | #include "Navigation/GNSS/Core/SatelliteSystem.hpp" | ||
| 20 | |||
| 21 | namespace NAV | ||
| 22 | { | ||
| 23 | |||
| 24 | /// Enumerate for GNSS frequencies | ||
| 25 | enum Frequency_ : uint64_t | ||
| 26 | { // clang-format off | ||
| 27 | Freq_None = 0x0000'0000'0000'0000, ///< None | ||
| 28 | G01 = 0x0000'0000'0000'0001, ///< GPS L1 (1575.42 MHz). | ||
| 29 | G02 = 0x0000'0000'0000'0002, ///< GPS L2 (1227.6 MHz). | ||
| 30 | G05 = 0x0000'0000'0000'0004, ///< GPS L5 (1176.45 MHz). | ||
| 31 | E01 = 0x0000'0000'0000'0100, ///< Galileo, "E1" (1575.42 MHz). | ||
| 32 | E05 = 0x0000'0000'0000'0200, ///< Galileo E5a (1176.45 MHz). | ||
| 33 | E06 = 0x0000'0000'0000'0400, ///< Galileo E6 (1278.75 MHz). | ||
| 34 | E07 = 0x0000'0000'0000'0800, ///< Galileo E5b (1207.14 MHz). | ||
| 35 | E08 = 0x0000'0000'0000'1000, ///< Galileo E5 (E5a + E5b) (1191.795MHz). | ||
| 36 | R01 = 0x0000'0000'0001'0000, ///< GLONASS, "G1" (1602 MHZ). | ||
| 37 | R02 = 0x0000'0000'0002'0000, ///< GLONASS, "G2" (1246 MHz). | ||
| 38 | R03 = 0x0000'0000'0004'0000, ///< GLONASS, "G3" (1202.025 MHz). | ||
| 39 | R04 = 0x0000'0000'0008'0000, ///< GLONASS, "G1a" (1600.995 MHZ). | ||
| 40 | R06 = 0x0000'0000'0010'0000, ///< GLONASS, "G2a" (1248.06 MHz). | ||
| 41 | B01 = 0x0000'0000'0100'0000, ///< Beidou B1 (1575.42 MHz). | ||
| 42 | B02 = 0x0000'0000'0200'0000, ///< Beidou B1-2 (B1I) (1561.098 MHz). | ||
| 43 | B05 = 0x0000'0000'0400'0000, ///< Beidou B2a (1176.45 MHz). | ||
| 44 | B06 = 0x0000'0000'0800'0000, ///< Beidou B3 (1268.52 MHz). | ||
| 45 | B07 = 0x0000'0000'1000'0000, ///< Beidou B2b (B2I) (1207.14 MHz). | ||
| 46 | B08 = 0x0000'0000'2000'0000, ///< Beidou B2 (B2a + B2b) (1191.795MHz). | ||
| 47 | J01 = 0x0000'0001'0000'0000, ///< QZSS L1 (1575.42 MHz). | ||
| 48 | J02 = 0x0000'0002'0000'0000, ///< QZSS L2 (1227.6 MHz). | ||
| 49 | J05 = 0x0000'0004'0000'0000, ///< QZSS L5 (1176.45 MHz). | ||
| 50 | J06 = 0x0000'0008'0000'0000, ///< QZSS L6 / LEX (1278.75 MHz). | ||
| 51 | I05 = 0x0000'0100'0000'0000, ///< IRNSS L5 (1176.45 MHz). | ||
| 52 | I09 = 0x0000'0200'0000'0000, ///< IRNSS S (2492.028 MHz). | ||
| 53 | S01 = 0x0001'0000'0000'0000, ///< SBAS L1 (1575.42 MHz). | ||
| 54 | S05 = 0x0002'0000'0000'0000, ///< SBAS L5 (1176.45 MHz). | ||
| 55 | }; // clang-format on | ||
| 56 | |||
| 57 | /// @brief Frequency definition for different satellite systems | ||
| 58 | class Frequency | ||
| 59 | { | ||
| 60 | public: | ||
| 61 | /// @brief Satellite System enumeration with continuous range. Not usable as a mask | ||
| 62 | enum Enum : uint8_t | ||
| 63 | { | ||
| 64 | Enum_G01, ///< GPS L1 (1575.42 MHz). | ||
| 65 | Enum_G02, ///< GPS L2 (1227.6 MHz). | ||
| 66 | Enum_G05, ///< GPS L5 (1176.45 MHz). | ||
| 67 | Enum_E01, ///< Galileo, "E1" (1575.42 MHz). | ||
| 68 | Enum_E05, ///< Galileo E5a (1176.45 MHz). | ||
| 69 | Enum_E06, ///< Galileo E6 (1278.75 MHz). | ||
| 70 | Enum_E07, ///< Galileo E5b (1207.14 MHz). | ||
| 71 | Enum_E08, ///< Galileo E5 (E5a + E5b) (1191.795MHz). | ||
| 72 | Enum_R01, ///< GLONASS, "G1" (1602 MHZ). | ||
| 73 | Enum_R02, ///< GLONASS, "G2" (1246 MHz). | ||
| 74 | Enum_R03, ///< GLONASS, "G3" (1202.025 MHz). | ||
| 75 | Enum_R04, ///< GLONASS, "G1a" (1600.995 MHZ). | ||
| 76 | Enum_R06, ///< GLONASS, "G2a" (1248.06 MHz). | ||
| 77 | Enum_B01, ///< Beidou B1 (1575.42 MHz). | ||
| 78 | Enum_B02, ///< Beidou B1-2 (1561.098 MHz). | ||
| 79 | Enum_B05, ///< Beidou B2a (1176.45 MHz). | ||
| 80 | Enum_B06, ///< Beidou B3 (1268.52 MHz). | ||
| 81 | Enum_B07, ///< Beidou B2b (1207.14 MHz). | ||
| 82 | Enum_B08, ///< Beidou B2 (B2a + B2b) (1191.795MHz). | ||
| 83 | Enum_J01, ///< QZSS L1 (1575.42 MHz). | ||
| 84 | Enum_J02, ///< QZSS L2 (1227.6 MHz). | ||
| 85 | Enum_J05, ///< QZSS L5 (1176.45 MHz). | ||
| 86 | Enum_J06, ///< QZSS L6 / LEX (1278.75 MHz). | ||
| 87 | Enum_I05, ///< IRNSS L5 (1176.45 MHz). | ||
| 88 | Enum_I09, ///< IRNSS S (2492.028 MHz). | ||
| 89 | Enum_S01, ///< SBAS L1 (1575.42 MHz). | ||
| 90 | Enum_S05, ///< SBAS L5 (1176.45 MHz). | ||
| 91 | Enum_COUNT, ///< Count variable | ||
| 92 | Enum_None, ///< No Frequency | ||
| 93 | }; | ||
| 94 | |||
| 95 | /// @brief Default Constructor | ||
| 96 | constexpr Frequency() = default; | ||
| 97 | |||
| 98 | /// @brief Implicit Constructor from Value type | ||
| 99 | /// @param[in] type Value type to construct from | ||
| 100 | 32866503 | constexpr Frequency(Frequency_ type) // NOLINT(hicpp-explicit-conversions, google-explicit-constructor) | |
| 101 | 32866503 | : value(type) | |
| 102 | 32866503 | {} | |
| 103 | |||
| 104 | /// @brief Implicit Constructor from Enum type | ||
| 105 | /// @param[in] enumeration Enum type to construct from | ||
| 106 | Frequency(Enum enumeration) // NOLINT(hicpp-explicit-conversions, google-explicit-constructor) | ||
| 107 | : value(Frequency::fromEnum(enumeration)) | ||
| 108 | {} | ||
| 109 | |||
| 110 | /// @brief Construct new object from std::string | ||
| 111 | /// @param[in] typeString String representation of the frequency | ||
| 112 | static Frequency fromString(const std::string& typeString); | ||
| 113 | |||
| 114 | /// @brief Constructs a new object from continuous enumeration | ||
| 115 | /// @param[in] enumeration Continuous enumeration of the frequency | ||
| 116 | static Frequency fromEnum(Enum enumeration); | ||
| 117 | |||
| 118 | /// @brief Assignment operator from Value type | ||
| 119 | /// @param[in] v Value type to construct from | ||
| 120 | /// @return The Type type from the value type | ||
| 121 | 2455190 | constexpr Frequency& operator=(Frequency_ v) | |
| 122 | { | ||
| 123 | 2455190 | value = v; | |
| 124 | 2455190 | return *this; | |
| 125 | } | ||
| 126 | |||
| 127 | friend constexpr bool operator==(const Frequency& lhs, const Frequency& rhs); | ||
| 128 | |||
| 129 | /// @brief Less than comparison (needed for map) | ||
| 130 | /// @param[in] rhs Right hand side of the operator | ||
| 131 | /// @return True if lhs < rhs | ||
| 132 | 347304 | constexpr bool operator<(const Frequency& rhs) const { return value < rhs.value; } | |
| 133 | |||
| 134 | /// @brief Allow switch(Frequency_(type)) and comparisons | ||
| 135 | 9373696 | constexpr explicit operator Frequency_() const { return value; } | |
| 136 | /// @brief Prevent usage: if(...) | ||
| 137 | constexpr explicit operator bool() = delete; | ||
| 138 | |||
| 139 | /// @brief int conversion operator | ||
| 140 | /// @return A int representation of the type | ||
| 141 | 86676619 | constexpr explicit operator uint64_t() const { return uint64_t(value); } | |
| 142 | |||
| 143 | /// @brief std::string conversion operator | ||
| 144 | /// @return A std::string representation of the type | ||
| 145 | explicit operator std::string() const; | ||
| 146 | |||
| 147 | /// @brief Get the Time System of the specified Frequency | ||
| 148 | /// @param[in] freq Frequency to get the satellite system for | ||
| 149 | static SatelliteSystem GetSatelliteSystemForFrequency(Frequency freq); | ||
| 150 | |||
| 151 | /// @brief Get the satellite system for which this frequency is defined | ||
| 152 | 12391031 | [[nodiscard]] SatelliteSystem getSatSys() const | |
| 153 | { | ||
| 154 |
1/2✓ Branch 2 taken 12390346 times.
✗ Branch 3 not taken.
|
12391031 | return GetSatelliteSystemForFrequency(value); |
| 155 | } | ||
| 156 | |||
| 157 | /// @brief Get the frequency in [Hz] | ||
| 158 | /// @param[in] freq Frequency to get the value for | ||
| 159 | /// @param[in] num Frequency number. Only used for GLONASS G1 and G2 | ||
| 160 | static double GetFrequency(Frequency freq, int8_t num); | ||
| 161 | |||
| 162 | /// @brief Get the frequency in [Hz] | ||
| 163 | /// @param[in] num Frequency number. Only used for GLONASS G1 and G2 | ||
| 164 | 2068432 | [[nodiscard]] double getFrequency(int8_t num) const | |
| 165 | { | ||
| 166 |
1/2✓ Branch 2 taken 2068377 times.
✗ Branch 3 not taken.
|
2068432 | return GetFrequency(value, num); |
| 167 | } | ||
| 168 | |||
| 169 | /// @brief Returns the L1 Frequency for each constellation | ||
| 170 | /// @param[in] freq Frequency to get the value for | ||
| 171 | static Frequency GetL1(Frequency freq); | ||
| 172 | |||
| 173 | /// @brief Returns the L1 Frequency for each constellation | ||
| 174 | 104891 | [[nodiscard]] Frequency getL1() const | |
| 175 | { | ||
| 176 |
1/2✓ Branch 2 taken 104891 times.
✗ Branch 3 not taken.
|
104891 | return GetL1(value); |
| 177 | } | ||
| 178 | |||
| 179 | /// Counts the amount of frequencies contained | ||
| 180 | [[nodiscard]] size_t count() const; | ||
| 181 | |||
| 182 | /// @brief Returns a list with all possible frequencies | ||
| 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 | |||
| 194 | /// @brief Get the continuous enumeration of the specified frequency | ||
| 195 | /// @param[in] freq Frequency to get the continuous enumeration for | ||
| 196 | static Enum ToEnumeration(Frequency freq); | ||
| 197 | |||
| 198 | /// @brief Returns a continuous enumeration of the object | ||
| 199 | [[nodiscard]] Enum toEnumeration() const; | ||
| 200 | |||
| 201 | /// @brief Get a vector representation of the specified Frequency | ||
| 202 | /// @param[in] freq Frequency to get the vector for | ||
| 203 | static std::vector<Frequency> ToVector(Frequency freq); | ||
| 204 | |||
| 205 | /// @brief Get a vector representation of the specified Frequency | ||
| 206 | [[nodiscard]] std::vector<Frequency> toVector() const; | ||
| 207 | |||
| 208 | /// @brief Checks wether the given frequency is the first in the filter (per system) | ||
| 209 | /// @param[in] freq Single Frequency | ||
| 210 | /// @param[in] filter Filter of multiple frequencies | ||
| 211 | static bool IsFirstFrequency(const Frequency& freq, const Frequency& filter); | ||
| 212 | |||
| 213 | /// @brief Checks wether the frequency is the first in the filter (per system) | ||
| 214 | /// @param[in] filter Filter of multiple frequencies | ||
| 215 | [[nodiscard]] bool isFirstFrequency(const Frequency& filter) const; | ||
| 216 | |||
| 217 | private: | ||
| 218 | /// @brief Internal value | ||
| 219 | Frequency_ value = Frequency_::Freq_None; | ||
| 220 | }; | ||
| 221 | |||
| 222 | // ######################################################################################################################################### | ||
| 223 | |||
| 224 | /// @brief Converts the provided link into a json object | ||
| 225 | /// @param[out] j Json object which gets filled with the info | ||
| 226 | /// @param[in] data Data to convert into json | ||
| 227 | void to_json(json& j, const Frequency& data); | ||
| 228 | /// @brief Converts the provided json object into a link object | ||
| 229 | /// @param[in] j Json object with the needed values | ||
| 230 | /// @param[out] data Object to fill from the json | ||
| 231 | void from_json(const json& j, Frequency& data); | ||
| 232 | |||
| 233 | // ######################################################################################################################################### | ||
| 234 | |||
| 235 | /// @brief Allows combining flags of the Frequency enum. | ||
| 236 | /// @param[in] lhs Left-hand side enum value. | ||
| 237 | /// @param[in] rhs Right-hand side enum value. | ||
| 238 | /// @return The binary ORed value. | ||
| 239 | 2813603 | constexpr Frequency_ operator|(Frequency_ lhs, Frequency_ rhs) | |
| 240 | { | ||
| 241 | 2813603 | return Frequency_(uint64_t(lhs) | uint64_t(rhs)); | |
| 242 | } | ||
| 243 | /// @brief Allows combining flags of the Frequency enum. | ||
| 244 | /// @param[in] lhs Left-hand side enum value. | ||
| 245 | /// @param[in] rhs Right-hand side enum value. | ||
| 246 | /// @return The binary ORed value. | ||
| 247 | 2454971 | constexpr Frequency_ operator|(Frequency lhs, Frequency rhs) | |
| 248 | { | ||
| 249 | 2454971 | return Frequency_(lhs) | Frequency_(rhs); | |
| 250 | } | ||
| 251 | /// @brief Allows combining flags of the Frequency enum. | ||
| 252 | /// @param[in] lhs Left-hand side enum value. | ||
| 253 | /// @param[in] rhs Right-hand side enum value. | ||
| 254 | /// @return The binary ORed value. | ||
| 255 | constexpr Frequency_ operator|(Frequency_ lhs, Frequency rhs) | ||
| 256 | { | ||
| 257 | return lhs | Frequency_(rhs); | ||
| 258 | } | ||
| 259 | /// @brief Allows combining flags of the Frequency enum. | ||
| 260 | /// @param[in] lhs Left-hand side enum value. | ||
| 261 | /// @param[in] rhs Right-hand side enum value. | ||
| 262 | /// @return The binary ORed value. | ||
| 263 | constexpr Frequency_ operator|(Frequency lhs, Frequency_ rhs) | ||
| 264 | { | ||
| 265 | return Frequency_(lhs) | rhs; | ||
| 266 | } | ||
| 267 | |||
| 268 | /// @brief Allows combining flags of the Frequency enum. | ||
| 269 | /// @param[in] lhs Left-hand side enum value. | ||
| 270 | /// @param[in] rhs Right-hand side enum value. | ||
| 271 | /// @return The binary ORed value. | ||
| 272 | constexpr Frequency_& operator|=(Frequency_& lhs, const Frequency_& rhs) | ||
| 273 | { | ||
| 274 | lhs = lhs | rhs; | ||
| 275 | return lhs; | ||
| 276 | } | ||
| 277 | /// @brief Allows combining flags of the Frequency enum. | ||
| 278 | /// @param[in] lhs Left-hand side enum value. | ||
| 279 | /// @param[in] rhs Right-hand side enum value. | ||
| 280 | /// @return The binary ORed value. | ||
| 281 | 2455010 | constexpr Frequency& operator|=(Frequency& lhs, const Frequency& rhs) | |
| 282 | { | ||
| 283 | 2455010 | lhs = lhs | rhs; | |
| 284 | 2455027 | return lhs; | |
| 285 | } | ||
| 286 | /// @brief Allows combining flags of the Frequency enum. | ||
| 287 | /// @param[in] lhs Left-hand side enum value. | ||
| 288 | /// @param[in] rhs Right-hand side enum value. | ||
| 289 | /// @return The binary ORed value. | ||
| 290 | constexpr Frequency_& operator|=(Frequency_& lhs, const Frequency& rhs) | ||
| 291 | { | ||
| 292 | lhs = lhs | Frequency_(rhs); | ||
| 293 | return lhs; | ||
| 294 | } | ||
| 295 | /// @brief Allows combining flags of the Frequency enum. | ||
| 296 | /// @param[in] lhs Left-hand side enum value. | ||
| 297 | /// @param[in] rhs Right-hand side enum value. | ||
| 298 | /// @return The binary ORed value. | ||
| 299 | constexpr Frequency& operator|=(Frequency& lhs, const Frequency_& rhs) | ||
| 300 | { | ||
| 301 | lhs = lhs | rhs; | ||
| 302 | return lhs; | ||
| 303 | } | ||
| 304 | |||
| 305 | /// @brief Allows combining flags of the Frequency enum. | ||
| 306 | /// @param[in] lhs Left-hand side enum value. | ||
| 307 | /// @param[in] rhs Right-hand side enum value. | ||
| 308 | /// @return The binary ANDed value. | ||
| 309 | 7265717 | constexpr Frequency_ operator&(Frequency_ lhs, Frequency_ rhs) | |
| 310 | { | ||
| 311 | 7265717 | return Frequency_(uint64_t(lhs) & uint64_t(rhs)); | |
| 312 | } | ||
| 313 | /// @brief Allows combining flags of the Frequency enum. | ||
| 314 | /// @param[in] lhs Left-hand side enum value. | ||
| 315 | /// @param[in] rhs Right-hand side enum value. | ||
| 316 | /// @return The binary ANDed value. | ||
| 317 | 450630 | constexpr Frequency_ operator&(Frequency lhs, Frequency rhs) | |
| 318 | { | ||
| 319 | 450630 | return Frequency_(lhs) & Frequency_(rhs); | |
| 320 | } | ||
| 321 | /// @brief Allows combining flags of the Frequency enum. | ||
| 322 | /// @param[in] lhs Left-hand side enum value. | ||
| 323 | /// @param[in] rhs Right-hand side enum value. | ||
| 324 | /// @return The binary ANDed value. | ||
| 325 | 351948 | constexpr Frequency_ operator&(Frequency lhs, Frequency_ rhs) | |
| 326 | { | ||
| 327 | 351948 | return Frequency_(lhs) & rhs; | |
| 328 | } | ||
| 329 | /// @brief Allows combining flags of the Frequency enum. | ||
| 330 | /// @param[in] lhs Left-hand side enum value. | ||
| 331 | /// @param[in] rhs Right-hand side enum value. | ||
| 332 | /// @return The binary ANDed value. | ||
| 333 | constexpr Frequency_ operator&(Frequency_ lhs, Frequency rhs) | ||
| 334 | { | ||
| 335 | return lhs & Frequency_(rhs); | ||
| 336 | } | ||
| 337 | |||
| 338 | /// @brief Allows combining flags of the Frequency enum. | ||
| 339 | /// @param[in] lhs Left-hand side enum value. | ||
| 340 | /// @param[in] rhs Right-hand side enum value. | ||
| 341 | /// @return The binary ANDed value. | ||
| 342 | constexpr Frequency_& operator&=(Frequency_& lhs, const Frequency_& rhs) | ||
| 343 | { | ||
| 344 | lhs = lhs & rhs; | ||
| 345 | return lhs; | ||
| 346 | } | ||
| 347 | /// @brief Allows combining flags of the Frequency enum. | ||
| 348 | /// @param[in] lhs Left-hand side enum value. | ||
| 349 | /// @param[in] rhs Right-hand side enum value. | ||
| 350 | /// @return The binary ANDed value. | ||
| 351 | constexpr Frequency& operator&=(Frequency& lhs, const Frequency& rhs) | ||
| 352 | { | ||
| 353 | lhs = lhs & rhs; | ||
| 354 | return lhs; | ||
| 355 | } | ||
| 356 | /// @brief Allows combining flags of the Frequency enum. | ||
| 357 | /// @param[in] lhs Left-hand side enum value. | ||
| 358 | /// @param[in] rhs Right-hand side enum value. | ||
| 359 | /// @return The binary ANDed value. | ||
| 360 | constexpr Frequency_& operator&=(Frequency_& lhs, const Frequency& rhs) | ||
| 361 | { | ||
| 362 | lhs = lhs & Frequency_(rhs); | ||
| 363 | return lhs; | ||
| 364 | } | ||
| 365 | /// @brief Allows combining flags of the Frequency enum. | ||
| 366 | /// @param[in] lhs Left-hand side enum value. | ||
| 367 | /// @param[in] rhs Right-hand side enum value. | ||
| 368 | /// @return The binary ANDed value. | ||
| 369 | constexpr Frequency& operator&=(Frequency& lhs, const Frequency_& rhs) | ||
| 370 | { | ||
| 371 | lhs = lhs & rhs; | ||
| 372 | return lhs; | ||
| 373 | } | ||
| 374 | |||
| 375 | /// @brief Allows negating flags of the Frequency enum. | ||
| 376 | /// @param[in] rhs Right-hand side enum value. | ||
| 377 | /// @return The binary NEGed value. | ||
| 378 | constexpr Frequency_ operator~(Frequency_ rhs) | ||
| 379 | { | ||
| 380 | return Frequency_(~uint64_t(rhs)); | ||
| 381 | } | ||
| 382 | /// @brief Allows negating flags of the Frequency enum. | ||
| 383 | /// @param[in] rhs Right-hand side enum value. | ||
| 384 | /// @return The binary NEGed value. | ||
| 385 | constexpr Frequency_ operator~(Frequency rhs) | ||
| 386 | { | ||
| 387 | return Frequency_(~uint64_t(rhs)); | ||
| 388 | } | ||
| 389 | |||
| 390 | /// @brief Equal compares values | ||
| 391 | /// @param[in] lhs Left-hand side of the operator | ||
| 392 | /// @param[in] rhs Right-hand side of the operator | ||
| 393 | /// @return Whether the comparison was successful | ||
| 394 | 1601803 | constexpr bool operator==(const Frequency& lhs, const Frequency& rhs) { return lhs.value == rhs.value; } | |
| 395 | /// @brief Equal compares values | ||
| 396 | /// @param[in] lhs Left-hand side of the operator | ||
| 397 | /// @param[in] rhs Right-hand side of the operator | ||
| 398 | /// @return Whether the comparison was successful | ||
| 399 | 255645 | constexpr bool operator==(const Frequency& lhs, const Frequency_& rhs) { return lhs == Frequency(rhs); } | |
| 400 | /// @brief Equal compares values | ||
| 401 | /// @param[in] lhs Left-hand side of the operator | ||
| 402 | /// @param[in] rhs Right-hand side of the operator | ||
| 403 | /// @return Whether the comparison was successful | ||
| 404 | constexpr bool operator==(const Frequency_& lhs, const Frequency& rhs) { return Frequency(lhs) == rhs; } | ||
| 405 | |||
| 406 | /// @brief Inequal compares values | ||
| 407 | /// @param[in] lhs Left-hand side of the operator | ||
| 408 | /// @param[in] rhs Right-hand side of the operator | ||
| 409 | /// @return Whether the comparison was successful | ||
| 410 | ✗ | constexpr bool operator!=(const Frequency& lhs, const Frequency& rhs) { return !(lhs == rhs); } | |
| 411 | /// @brief Inequal compares values | ||
| 412 | /// @param[in] lhs Left-hand side of the operator | ||
| 413 | /// @param[in] rhs Right-hand side of the operator | ||
| 414 | /// @return Whether the comparison was successful | ||
| 415 | ✗ | constexpr bool operator!=(const Frequency& lhs, const Frequency_& rhs) { return !(lhs == rhs); } | |
| 416 | /// @brief Inequal compares values | ||
| 417 | /// @param[in] lhs Left-hand side of the operator | ||
| 418 | /// @param[in] rhs Right-hand side of the operator | ||
| 419 | /// @return Whether the comparison was successful | ||
| 420 | constexpr bool operator!=(const Frequency_& lhs, const Frequency& rhs) { return !(lhs == rhs); } | ||
| 421 | |||
| 422 | // ######################################################################################################################################### | ||
| 423 | |||
| 424 | /// @brief Allows filtering Frequency with SatelliteSystem. | ||
| 425 | /// @param[in] lhs Left-hand side enum value. | ||
| 426 | /// @param[in] rhs Right-hand side enum value. | ||
| 427 | /// @return The binary ANDed value. | ||
| 428 | constexpr Frequency_ operator&(Frequency_ lhs, SatelliteSystem_ rhs) | ||
| 429 | { | ||
| 430 | return Frequency_(uint64_t(lhs) & uint64_t(rhs)); | ||
| 431 | } | ||
| 432 | /// @brief Allows filtering Frequency with SatelliteSystem. | ||
| 433 | /// @param[in] lhs Left-hand side enum value. | ||
| 434 | /// @param[in] rhs Right-hand side enum value. | ||
| 435 | /// @return The binary ANDed value. | ||
| 436 | constexpr Frequency_ operator&(SatelliteSystem_ lhs, Frequency_ rhs) | ||
| 437 | { | ||
| 438 | return Frequency_(uint64_t(lhs) & uint64_t(rhs)); | ||
| 439 | } | ||
| 440 | /// @brief Allows filtering Frequency with SatelliteSystem. | ||
| 441 | /// @param[in] lhs Left-hand side enum value. | ||
| 442 | /// @param[in] rhs Right-hand side enum value. | ||
| 443 | /// @return The binary ANDed value. | ||
| 444 | constexpr Frequency_& operator&=(Frequency_& lhs, const SatelliteSystem_& rhs) | ||
| 445 | { | ||
| 446 | lhs = lhs & rhs; | ||
| 447 | return lhs; | ||
| 448 | } | ||
| 449 | |||
| 450 | /// @brief Allows filtering Frequency with SatelliteSystem. | ||
| 451 | /// @param[in] lhs Left-hand side enum value. | ||
| 452 | /// @param[in] rhs Right-hand side enum value. | ||
| 453 | /// @return The binary ANDed value. | ||
| 454 | constexpr Frequency_ operator&(Frequency_ lhs, SatelliteSystem rhs) | ||
| 455 | { | ||
| 456 | return Frequency_(uint64_t(lhs) & uint64_t(rhs)); | ||
| 457 | } | ||
| 458 | /// @brief Allows filtering Frequency with SatelliteSystem. | ||
| 459 | /// @param[in] lhs Left-hand side enum value. | ||
| 460 | /// @param[in] rhs Right-hand side enum value. | ||
| 461 | /// @return The binary ANDed value. | ||
| 462 | constexpr Frequency_ operator&(SatelliteSystem lhs, Frequency_ rhs) | ||
| 463 | { | ||
| 464 | return Frequency_(uint64_t(lhs) & uint64_t(rhs)); | ||
| 465 | } | ||
| 466 | /// @brief Allows filtering Frequency with SatelliteSystem. | ||
| 467 | /// @param[in] lhs Left-hand side enum value. | ||
| 468 | /// @param[in] rhs Right-hand side enum value. | ||
| 469 | /// @return The binary ANDed value. | ||
| 470 | constexpr Frequency_& operator&=(Frequency_& lhs, const SatelliteSystem& rhs) | ||
| 471 | { | ||
| 472 | lhs = lhs & rhs; | ||
| 473 | return lhs; | ||
| 474 | } | ||
| 475 | |||
| 476 | /// @brief Allows filtering Frequency with SatelliteSystem. | ||
| 477 | /// @param[in] lhs Left-hand side enum value. | ||
| 478 | /// @param[in] rhs Right-hand side enum value. | ||
| 479 | /// @return The binary ANDed value. | ||
| 480 | constexpr Frequency_ operator&(Frequency lhs, SatelliteSystem_ rhs) | ||
| 481 | { | ||
| 482 | return Frequency_(uint64_t(lhs) & uint64_t(rhs)); | ||
| 483 | } | ||
| 484 | /// @brief Allows filtering Frequency with SatelliteSystem. | ||
| 485 | /// @param[in] lhs Left-hand side enum value. | ||
| 486 | /// @param[in] rhs Right-hand side enum value. | ||
| 487 | /// @return The binary ANDed value. | ||
| 488 | constexpr Frequency_ operator&(SatelliteSystem_ lhs, Frequency rhs) | ||
| 489 | { | ||
| 490 | return Frequency_(uint64_t(lhs) & uint64_t(rhs)); | ||
| 491 | } | ||
| 492 | /// @brief Allows filtering Frequency with SatelliteSystem. | ||
| 493 | /// @param[in] lhs Left-hand side enum value. | ||
| 494 | /// @param[in] rhs Right-hand side enum value. | ||
| 495 | /// @return The binary ANDed value. | ||
| 496 | constexpr Frequency& operator&=(Frequency& lhs, const SatelliteSystem_& rhs) | ||
| 497 | { | ||
| 498 | lhs = lhs & rhs; | ||
| 499 | return lhs; | ||
| 500 | } | ||
| 501 | |||
| 502 | /// @brief Allows filtering Frequency with SatelliteSystem. | ||
| 503 | /// @param[in] lhs Left-hand side enum value. | ||
| 504 | /// @param[in] rhs Right-hand side enum value. | ||
| 505 | /// @return The binary ANDed value. | ||
| 506 | 86683007 | constexpr Frequency_ operator&(Frequency lhs, SatelliteSystem rhs) | |
| 507 | { | ||
| 508 | 86683007 | return Frequency_(uint64_t(lhs) & uint64_t(rhs)); | |
| 509 | } | ||
| 510 | /// @brief Allows filtering Frequency with SatelliteSystem. | ||
| 511 | /// @param[in] lhs Left-hand side enum value. | ||
| 512 | /// @param[in] rhs Right-hand side enum value. | ||
| 513 | /// @return The binary ANDed value. | ||
| 514 | ✗ | constexpr Frequency_ operator&(SatelliteSystem lhs, Frequency rhs) | |
| 515 | { | ||
| 516 | ✗ | return Frequency_(uint64_t(lhs) & uint64_t(rhs)); | |
| 517 | } | ||
| 518 | /// @brief Allows filtering Frequency with SatelliteSystem. | ||
| 519 | /// @param[in] lhs Left-hand side enum value. | ||
| 520 | /// @param[in] rhs Right-hand side enum value. | ||
| 521 | /// @return The binary ANDed value. | ||
| 522 | constexpr Frequency& operator&=(Frequency& lhs, const SatelliteSystem& rhs) | ||
| 523 | { | ||
| 524 | lhs = lhs & rhs; | ||
| 525 | return lhs; | ||
| 526 | } | ||
| 527 | |||
| 528 | /// All Frequencies | ||
| 529 | constexpr Frequency_ Freq_All = G01 | G02 | G05 | ||
| 530 | | E01 | E05 | E06 | E07 | E08 | ||
| 531 | | R01 | R02 | R03 | R04 | R06 | ||
| 532 | | B01 | B02 | B05 | B06 | B07 | B08 | ||
| 533 | | J01 | J02 | J05 | J06 | ||
| 534 | | I05 | I09 | ||
| 535 | | S01 | S05; | ||
| 536 | |||
| 537 | /// @brief Shows a ComboBox to select GNSS frequencies | ||
| 538 | /// @param[in] label Label to show beside the combo box. This has to be a unique id for ImGui. | ||
| 539 | /// @param[in, out] frequency Reference to the frequency object to select | ||
| 540 | /// @param[in] singleSelect If true, only one code can be selected at a time | ||
| 541 | bool ShowFrequencySelector(const char* label, Frequency& frequency, bool singleSelect = false); | ||
| 542 | |||
| 543 | } // namespace NAV | ||
| 544 | |||
| 545 | /// @brief Stream insertion operator overload | ||
| 546 | /// @param[in, out] os Output stream object to stream the time into | ||
| 547 | /// @param[in] obj Object to print | ||
| 548 | /// @return Returns the output stream object in order to chain stream insertions | ||
| 549 | std::ostream& operator<<(std::ostream& os, const NAV::Frequency& obj); | ||
| 550 | |||
| 551 | namespace std | ||
| 552 | { | ||
| 553 | /// @brief Hash function for Frequency (needed for unordered_map) | ||
| 554 | template<> | ||
| 555 | struct hash<NAV::Frequency_> | ||
| 556 | { | ||
| 557 | /// @brief Hash function for Frequency | ||
| 558 | /// @param[in] f Satellite frequency | ||
| 559 | /// @return Has value for the frequency | ||
| 560 | 24870665 | std::size_t operator()(const NAV::Frequency_& f) const | |
| 561 | { | ||
| 562 | using namespace NAV; // NOLINT(google-build-using-namespace) | ||
| 563 |
28/29✗ Branch 0 not taken.
✓ Branch 1 taken 2536242 times.
✓ Branch 2 taken 2638669 times.
✓ Branch 3 taken 897303 times.
✓ Branch 4 taken 1090423 times.
✓ Branch 5 taken 1116902 times.
✓ Branch 6 taken 959574 times.
✓ Branch 7 taken 1070387 times.
✓ Branch 8 taken 1013843 times.
✓ Branch 9 taken 2024982 times.
✓ Branch 10 taken 2023215 times.
✓ Branch 11 taken 42408 times.
✓ Branch 12 taken 325128 times.
✓ Branch 13 taken 325128 times.
✓ Branch 14 taken 799986 times.
✓ Branch 15 taken 745395 times.
✓ Branch 16 taken 341403 times.
✓ Branch 17 taken 705405 times.
✓ Branch 18 taken 719541 times.
✓ Branch 19 taken 228315 times.
✓ Branch 20 taken 813378 times.
✓ Branch 21 taken 813843 times.
✓ Branch 22 taken 785571 times.
✓ Branch 23 taken 644211 times.
✓ Branch 24 taken 644866 times.
✓ Branch 25 taken 2513 times.
✓ Branch 26 taken 791616 times.
✓ Branch 27 taken 770412 times.
✓ Branch 28 taken 6 times.
|
24870665 | switch (f) |
| 564 | { | ||
| 565 | ✗ | case Freq_None: | |
| 566 | ✗ | return 2; | |
| 567 | 2536242 | case G01: | |
| 568 | 2536242 | return 101; | |
| 569 | 2638669 | case G02: | |
| 570 | 2638669 | return 102; | |
| 571 | 897303 | case G05: | |
| 572 | 897303 | return 103; | |
| 573 | 1090423 | case E01: | |
| 574 | 1090423 | return 201; | |
| 575 | 1116902 | case E05: | |
| 576 | 1116902 | return 202; | |
| 577 | 959574 | case E06: | |
| 578 | 959574 | return 203; | |
| 579 | 1070387 | case E07: | |
| 580 | 1070387 | return 204; | |
| 581 | 1013843 | case E08: | |
| 582 | 1013843 | return 205; | |
| 583 | 2024982 | case R01: | |
| 584 | 2024982 | return 301; | |
| 585 | 2023215 | case R02: | |
| 586 | 2023215 | return 302; | |
| 587 | 42408 | case R03: | |
| 588 | 42408 | return 303; | |
| 589 | 325128 | case R04: | |
| 590 | 325128 | return 304; | |
| 591 | 325128 | case R06: | |
| 592 | 325128 | return 305; | |
| 593 | 799986 | case B01: | |
| 594 | 799986 | return 401; | |
| 595 | 745395 | case B02: | |
| 596 | 745395 | return 402; | |
| 597 | 341403 | case B05: | |
| 598 | 341403 | return 403; | |
| 599 | 705405 | case B06: | |
| 600 | 705405 | return 404; | |
| 601 | 719541 | case B07: | |
| 602 | 719541 | return 405; | |
| 603 | 228315 | case B08: | |
| 604 | 228315 | return 406; | |
| 605 | 813378 | case J01: | |
| 606 | 813378 | return 501; | |
| 607 | 813843 | case J02: | |
| 608 | 813843 | return 502; | |
| 609 | 785571 | case J05: | |
| 610 | 785571 | return 503; | |
| 611 | 644211 | case J06: | |
| 612 | 644211 | return 504; | |
| 613 | 644866 | case I05: | |
| 614 | 644866 | return 601; | |
| 615 | 2513 | case I09: | |
| 616 | 2513 | return 602; | |
| 617 | 791616 | case S01: | |
| 618 | 791616 | return 701; | |
| 619 | 770412 | case S05: | |
| 620 | 770412 | return 702; | |
| 621 | } | ||
| 622 | |||
| 623 | 6 | return 0; | |
| 624 | } | ||
| 625 | }; | ||
| 626 | /// @brief Hash function for Frequency (needed for unordered_map) | ||
| 627 | template<> | ||
| 628 | struct hash<NAV::Frequency> | ||
| 629 | { | ||
| 630 | /// @brief Hash function for Frequency | ||
| 631 | /// @param[in] f Satellite frequency | ||
| 632 | /// @return Has value for the frequency | ||
| 633 | 522158 | std::size_t operator()(const NAV::Frequency& f) const | |
| 634 | { | ||
| 635 | 522158 | return std::hash<NAV::Frequency_>()(NAV::Frequency_(f)); | |
| 636 | } | ||
| 637 | }; | ||
| 638 | } // namespace std | ||
| 639 | |||
| 640 | #ifndef DOXYGEN_IGNORE | ||
| 641 | |||
| 642 | /// @brief Formatter for Frequency | ||
| 643 | template<> | ||
| 644 | struct fmt::formatter<NAV::Frequency> : fmt::formatter<std::string> | ||
| 645 | { | ||
| 646 | /// @brief Defines how to format Frequency structs | ||
| 647 | /// @param[in] freq Struct to format | ||
| 648 | /// @param[in, out] ctx Format context | ||
| 649 | /// @return Output iterator | ||
| 650 | template<typename FormatContext> | ||
| 651 | 227553 | auto format(const NAV::Frequency& freq, FormatContext& ctx) const | |
| 652 | { | ||
| 653 |
2/4✓ Branch 1 taken 227566 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 227548 times.
✗ Branch 6 not taken.
|
227553 | return fmt::formatter<std::string>::format(std::string(freq), ctx); |
| 654 | } | ||
| 655 | }; | ||
| 656 | |||
| 657 | #endif | ||
| 658 |