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 TimeSystem.cpp | ||
10 | /// @brief Time | ||
11 | /// @author T. Topp (topp@ins.uni-stuttgart.de) | ||
12 | /// @date 2023-08-10 | ||
13 | |||
14 | #include "TimeSystem.hpp" | ||
15 | |||
16 | #include "internal/gui/widgets/EnumCombo.hpp" | ||
17 | |||
18 | namespace NAV | ||
19 | { | ||
20 | ✗ | TimeSystem::TimeSystemEnum TimeSystem::getEnumValue() const | |
21 | { | ||
22 | ✗ | if (value & TimeSys_None) { return TimeSystemEnum::TimeSys_None; } | |
23 | ✗ | if (value & UTC) { return TimeSystemEnum::UTC; } | |
24 | ✗ | if (value & GPST) { return TimeSystemEnum::GPST; } | |
25 | ✗ | if (value & GLNT) { return TimeSystemEnum::GLNT; } | |
26 | ✗ | if (value & GST) { return TimeSystemEnum::GST; } | |
27 | ✗ | if (value & BDT) { return TimeSystemEnum::BDT; } | |
28 | ✗ | if (value & QZSST) { return TimeSystemEnum::QZSST; } | |
29 | ✗ | if (value & IRNSST) { return TimeSystemEnum::IRNSST; } | |
30 | |||
31 | ✗ | return TimeSystemEnum::TimeSys_None; | |
32 | } | ||
33 | |||
34 | ✗ | void to_json(json& j, const TimeSystem& timeSystem) | |
35 | { | ||
36 | ✗ | j = std::string(timeSystem); | |
37 | ✗ | } | |
38 | |||
39 | 12 | void from_json(const json& j, TimeSystem& timeSystem) | |
40 | { | ||
41 |
2/4✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
|
12 | timeSystem = TimeSystem::fromString(j.get<std::string>()); |
42 | 12 | } | |
43 | |||
44 | ✗ | bool ComboTimeSystem(const char* label, TimeSystem& timeSystem) | |
45 | { | ||
46 | ✗ | auto enumeration = timeSystem.getEnumValue(); | |
47 | ✗ | bool changed = gui::widgets::EnumCombo(label, enumeration, 1); | |
48 | ✗ | if (changed) | |
49 | { | ||
50 | ✗ | timeSystem = TimeSystem(enumeration); | |
51 | } | ||
52 | ✗ | return changed; | |
53 | } | ||
54 | |||
55 | ✗ | const char* to_string(TimeSystem::TimeSystemEnum timeSystem) | |
56 | { | ||
57 | ✗ | return TimeSystem(timeSystem).toString(); | |
58 | } | ||
59 | |||
60 | } // namespace NAV | ||
61 | |||
62 | ✗ | std::ostream& operator<<(std::ostream& os, const NAV::TimeSystem& obj) | |
63 | { | ||
64 | ✗ | return os << fmt::format("{}", obj); | |
65 | } | ||
66 |