0.3.0
Loading...
Searching...
No Matches
TimeSystem.cpp
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
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
17
18namespace NAV
19{
21{
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
32}
33
34void to_json(json& j, const TimeSystem& timeSystem)
35{
36 j = std::string(timeSystem);
37}
38
39void from_json(const json& j, TimeSystem& timeSystem)
40{
41 timeSystem = TimeSystem::fromString(j.get<std::string>());
42}
43
44bool 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
56{
57 return TimeSystem(timeSystem).toString();
58}
59
60} // namespace NAV
61
62std::ostream& operator<<(std::ostream& os, const NAV::TimeSystem& obj)
63{
64 return os << fmt::format("{}", obj);
65}
Combo representing an enumeration.
nlohmann::json json
json namespace
std::ostream & operator<<(std::ostream &os, const NAV::TimeSystem &obj)
Stream insertion operator overload.
Time System defintions.
Time System defintions.
TimeSystemEnum
Continuous enum for the time systems.
@ IRNSST
Indian Regional Navigation Satellite System Time.
@ GST
Galileo System Time.
@ UTC
Coordinated Universal Time.
@ GLNT
GLONASS Time (GLONASST)
@ QZSST
Quasi-Zenith Satellite System Time.
static TimeSystem fromString(const std::string &typeString)
Construct new object from std::string.
TimeSystem_ value
Internal value.
TimeSystemEnum getEnumValue() const
Returns the enum value (only one must be set)
constexpr const char * toString() const
Converts the time system into a string.
bool EnumCombo(const char *label, T &enumeration, size_t startIdx=0)
Combo representing an enumeration.
Definition EnumCombo.hpp:30
void to_json(json &j, const Node &node)
Converts the provided node into a json object.
Definition Node.cpp:990
const char * to_string(gui::widgets::PositionWithFrame::ReferenceFrame refFrame)
Converts the enum to a string.
void from_json(const json &j, Node &node)
Converts the provided json object into a node object.
Definition Node.cpp:1007
bool ComboTimeSystem(const char *label, TimeSystem &timeSystem)
Shows a ComboBox to select the time system.