0.3.0
Loading...
Searching...
No Matches
Temperature.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 <cstdint>
17#include <fmt/format.h>
18#include <nlohmann/json.hpp>
19using json = nlohmann::json;
20
21namespace NAV
22{
23
26{
27 public:
29 enum Model : uint8_t
30 {
37 };
38
41 TemperatureModel(Model model) : _model(model) {} // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
42
46 [[nodiscard]] double calcAbsoluteTemperature(double altitudeMSL) const;
47
51 friend bool ComboTemperatureModel(const char* label, TemperatureModel& temperatureModel);
52
53 private:
56
58 double _constantTemperature = 290.0;
59
60 friend constexpr bool operator==(const TemperatureModel& lhs, const TemperatureModel& rhs);
61 friend constexpr bool operator==(const TemperatureModel& lhs, const TemperatureModel::Model& rhs);
62 friend constexpr bool operator==(const TemperatureModel::Model& lhs, const TemperatureModel& rhs);
63 friend bool ComboTemperatureModel(const char* label, TemperatureModel& temperatureModel);
64 friend const char* to_string(const TemperatureModel& temperatureModel);
65 friend void to_json(json& j, const TemperatureModel& obj);
66 friend void from_json(const json& j, TemperatureModel& obj);
67};
68
73constexpr bool operator==(const TemperatureModel& lhs, const TemperatureModel& rhs)
74{
75 if (lhs._model == rhs._model)
76 {
78 return true;
79 }
80 return false;
81}
82
87constexpr bool operator==(const TemperatureModel& lhs, const TemperatureModel::Model& rhs) { return lhs._model == rhs; }
92constexpr bool operator==(const TemperatureModel::Model& lhs, const TemperatureModel& rhs) { return lhs == rhs._model; }
93
97bool ComboTemperatureModel(const char* label, TemperatureModel& temperatureModel);
98
102const char* to_string(const TemperatureModel& temperatureModel);
106const char* to_string(TemperatureModel::Model temperatureModel);
107
111void to_json(json& j, const TemperatureModel& obj);
115void from_json(const json& j, TemperatureModel& obj);
116
117} // namespace NAV
118
119#ifndef DOXYGEN_IGNORE
120
122template<>
123struct fmt::formatter<NAV::TemperatureModel> : fmt::formatter<std::string>
124{
129 template<typename FormatContext>
130 auto format(const NAV::TemperatureModel& data, FormatContext& ctx) const
131 {
132 return fmt::formatter<std::string>::format(NAV::to_string(data), ctx);
133 }
134};
135
136#endif
nlohmann::json json
json namespace
Definition FlowManager.hpp:21
const char * to_string(gui::widgets::PositionWithFrame::ReferenceFrame refFrame)
Converts the enum to a string.
bool ComboTemperatureModel(const char *label, TemperatureModel &temperatureModel)
Shows a ComboBox to select the temperature model.
Temperature Model parameters.
Definition Temperature.hpp:26
double _constantTemperature
Temperature for the constant temperature model [K].
Definition Temperature.hpp:58
friend const char * to_string(const TemperatureModel &temperatureModel)
Converts the enum to a string.
friend bool ComboTemperatureModel(const char *label, TemperatureModel &temperatureModel)
Shows a ComboBox to select the temperature model.
TemperatureModel(Model model)
Constructor.
Definition Temperature.hpp:41
friend void from_json(const json &j, TemperatureModel &obj)
Converts the provided json object into a node object.
friend void to_json(json &j, const TemperatureModel &obj)
Converts the provided object into json.
double calcAbsoluteTemperature(double altitudeMSL) const
Calculates the absolute temperature.
Model
Available temperature Models.
Definition Temperature.hpp:30
@ None
No temperature model.
Definition Temperature.hpp:31
@ ISA
ICAO Standard Atmosphere.
Definition Temperature.hpp:33
@ GPT2
GPT2.
Definition Temperature.hpp:34
@ GPT3
GPT3.
Definition Temperature.hpp:35
@ Const
Constant value.
Definition Temperature.hpp:32
@ COUNT
Amount of items in the enum.
Definition Temperature.hpp:36
friend constexpr bool operator==(const TemperatureModel &lhs, const TemperatureModel &rhs)
Equal compares Pin::Kind values.
Definition Temperature.hpp:73
Model _model
Selected model.
Definition Temperature.hpp:55
bool operator==(const ImVec4 &lhs, const ImVec4 &rhs)
Equal comparison operator.