HLCC Documentation 3.0.1
Loading...
Searching...
No Matches
config.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2020-2025 European Southern Observatory (ESO)
2//
3// SPDX-License-Identifier: LGPL-3.0-only
4
13#ifndef HLCC_TELIF_TELIF_CONFIG_HPP
14#define HLCC_TELIF_TELIF_CONFIG_HPP
15
16#include <string>
17#include <config-ng/ciiConfigApi.hpp>
18#include <rad/config.hpp>
19
20#include "telif/logger.hpp"
21
22
23namespace hlcc::telif {
24
25/* hlcc config error class */
26class ConfigError : public std::runtime_error {
27public:
28 explicit ConfigError(const std::string& message)
29 : std::runtime_error(message)
30 {}
31};
32
33/*
34 * Type for the Telescope named position
35 * which will assign a name to an
36 * alt/az position.
37 */
39 std::string pos_string;
40 double alt_pos;
41 double az_pos;
42};
43struct LsvApp {
44 std::string name;
45 std::string oldb;
46 std::string cmds;
47};
48} // namespace hlcc::telif
49
50namespace elt::configng {
51
52// Implementation of converter between hlcc::telif::TelNamedPosition and CiiConfigInstanceNode hirearchy
53// Decode method: Extract node values into hlcc::telif::TelNamedPosition
54// Encode method: construct nodes from values of hlcc::telif::TelNamedPosition
55template<>
56struct CiiConfigValueConverter<hlcc::telif::TelNamedPosition, CiiConfigInstanceNode> {
57 static bool Decode(const CiiConfigInstanceNode& node, hlcc::telif::TelNamedPosition &target) {
58 if (node.GetKind() != CiiConfigNodeKind::MAP || node.GetDataTypeName() != "TelNamedPosition") {
59 std::cerr << "Conversion to TelNamedPosition not possible" << std::endl;
60 return false;
61 }
62 target.pos_string = node["pos_string"].As<std::string>();
63 target.alt_pos = node["alt_pos"].As<double>();
64 target.az_pos = node["az_pos"].As<double>();
65 return true;
66 }
67
68 static bool Encode(CiiConfigInstanceNode &node, const hlcc::telif::TelNamedPosition &source) {
69 if (node.GetKind() != elt::configng::CiiConfigNodeKind::MAP) {
70 return false;
71 }
72 node.Set("pos_string", elt::configng::CiiConfigInstanceNode::From(source.pos_string));
73 node.Set("alt_pos", elt::configng::CiiConfigInstanceNode::From(source.alt_pos));
74 node.Set("az_pos", elt::configng::CiiConfigInstanceNode::From(source.az_pos));
75 return true;
76 }
77};
78
79// Implementation of converter between hlcc::telif::LsvApp and CiiConfigInstanceNode hierarchy
80// Decode method: Extract node values into hlcc::telif::LsvApp
81// Encode method: construct nodes from values of hlcc::telif::LsvApp
82template<>
83struct CiiConfigValueConverter<hlcc::telif::LsvApp, CiiConfigInstanceNode> {
84 static bool Decode(const CiiConfigInstanceNode& node, hlcc::telif::LsvApp &target) {
85 if (node.GetKind() != CiiConfigNodeKind::MAP || node.GetDataTypeName() != "LsvApp") {
86 std::cerr << "Conversion to LsvApp not possible" << std::endl;
87 return false;
88 }
89 target.name = node["name"].As<std::string>();
90 target.oldb = node["oldb"].As<std::string>();
91 target.cmds = node["cmds"].As<std::string>();
92 return true;
93 }
94
95 static bool Encode(CiiConfigInstanceNode &node, const hlcc::telif::LsvApp &source) {
96 if (node.GetKind() != elt::configng::CiiConfigNodeKind::MAP) {
97 return false;
98 }
99 node.Set("name", elt::configng::CiiConfigInstanceNode::From(source.name));
100 node.Set("oldb", elt::configng::CiiConfigInstanceNode::From(source.oldb));
101 node.Set("cmds", elt::configng::CiiConfigInstanceNode::From(source.cmds));
102 return true;
103 }
104};
105
106} // namespace elt::configng
107
108namespace hlcc::telif {
109
111// const char KEY_SEPARATOR_CFG = '.';
112// const std::string CONFIG_ROOT_NODE = "app";
113
114
115/*
116 * Configuration OLDB Attributes.
117 * Note that CII OLDB convert all keys to lowercase.
118 *
119 * The following definitions are handled in rad/cpp/app/src/include/rad/config.hpp
120 * const std::string KEY_CONFIG = "cfg";
121 * const std::string KEY_CONFIG_VERSION = KEY_CONFIG + "version";
122 * const std::string KEY_CONFIG_MODNAME = KEY_CONFIG + "/" + "modname";
123 * const std::string KEY_CONFIG_PROCNAME = KEY_CONFIG + "/" + "procname";
124 * const std::string KEY_CONFIG_FILENAME = KEY_CONFIG + "/" + "filename";
125 * const std::string KEY_CONFIG_LOG_LEVEL = KEY_CONFIG + "/" + "log_level";
126 * const std::string KEY_CONFIG_LOG_PROPERTIES = KEY_CONFIG + "/" + "log_properties";
127 * const std::string KEY_CONFIG_SM_SCXML = KEY_CONFIG + "/" + "sm_scxml";
128 * const std::string KEY_CONFIG_SM_APPEND = KEY_CONFIG + "sm_scxml_append";
129 * const std::string KEY_CONFIG_REQ_ENDPOINT = KEY_CONFIG + "/" + "req_endpoint"; *
130 * const std::string KEY_CONFIG_OLDB_URI_PREFIX = KEY_CONFIG + "/" + "oldb_uri_prefix";
131 * const std::string KEY_CONFIG_OLDB_CONN_TIMEOUT = KEY_CONFIG + "oldb_conn_timeout";
132 * const std::string KEY_CONFIG_OLDB_ASYNC_PERIOD = KEY_CONFIG + "oldb_async_period";
133 * const std::string KEY_CONFIG_TRS_HEALTH_ENABLED = KEY_CONFIG + "trs_health_enabled";
134 */
135
136const std::string KEY_CONFIG = rad::KEY_CONFIG;
137const std::string KEY_CONFIG_REQ_ELTPK = KEY_CONFIG + "req_eltpk";
138const std::string KEY_CONFIG_REQ_TREX = KEY_CONFIG + "req_trex";
139const std::string KEY_CONFIG_LSVS = KEY_CONFIG + "lsvs";
140const std::string KEY_CONFIG_TRSHKS_CMDS = KEY_CONFIG + "trs-hks/cmds";
141
142const std::string KEY_CONFIG_PUB_DDS_PROFILE = KEY_CONFIG + "pub/dds/profile";
143const std::string KEY_CONFIG_PUB_DDS_NIC = KEY_CONFIG + "pub/dds/nic";
144const std::string KEY_CONFIG_PUB_DDS_FILE = KEY_CONFIG + "pub/dds/file";
145const std::string KEY_CONFIG_PUB_DDS_DOMAIN_ID_HLCC = KEY_CONFIG + "pub/dds/domain_id_hlcc";
146const std::string KEY_CONFIG_PUB_DDS_DOMAIN_ID_CCS_INS = KEY_CONFIG + "pub/dds/domain_id_ccs_ins";
147const std::string KEY_CONFIG_PUB_DDS_DOMAIN_ID_GENERAL = KEY_CONFIG + "pub/dds/domain_id_general";
148const std::string KEY_CONFIG_ALTAZ_ALT_UPPER_LIMIT_OP = KEY_CONFIG + "altaz/alt_upper_limit_op";
149const std::string KEY_CONFIG_ALTAZ_ALT_LOWER_LIMIT_OP = KEY_CONFIG + "altaz/alt_lower_limit_op";
150const std::string KEY_CONFIG_ALTAZ_AZ_UPPER_LIMIT_OP = KEY_CONFIG + "altaz/az_upper_limit_op";
151const std::string KEY_CONFIG_ALTAZ_AZ_LOWER_LIMIT_OP = KEY_CONFIG + "altaz/az_lower_limit_op";
152const std::string KEY_CONFIG_ALTAZ_ALT_UPPER_LIMIT_FCT = KEY_CONFIG + "altaz/alt_upper_limit_fct";
153const std::string KEY_CONFIG_ALTAZ_ALT_LOWER_LIMIT_FCT = KEY_CONFIG + "altaz/alt_lower_limit_fct";
154const std::string KEY_CONFIG_ALTAZ_AZ_UPPER_LIMIT_FCT = KEY_CONFIG + "altaz/az_upper_limit_fct";
155const std::string KEY_CONFIG_ALTAZ_AZ_LOWER_LIMIT_FCT = KEY_CONFIG + "altaz/az_lower_limit_fct";
156const std::string KEY_CONFIG_ROUS_TIMER_PERIOD_S = KEY_CONFIG + "rous/timer_period_s";
158 = KEY_CONFIG + "ready_for_handover/estimation_period_ms";
159const std::string KEY_CONFIG_NAMED_POS = KEY_CONFIG + "tel_named_pos";
160const std::string KEY_CONFIG_RTCTK_CCSSIM_UPD_IP = KEY_CONFIG + "rtctk_ccssim/udp_ip";
161const std::string KEY_CONFIG_RTCTK_CCSSIM_UPD_PORT = KEY_CONFIG + "rtctk_ccssim/udp_port";
162const std::string KEY_CONFIG_GS_TO_GP_MAPPING = KEY_CONFIG + "gs_to_gp_mapping";
163
164/*
165 * Map containing all the configuration paramenters to be configured
166 * in the Oldb and also the type that shoudl be used to publish.
167 */
176
185
196
200const std::string CONFIG_DEFAULT_VERSION = std::string(VERSION);
201const std::string CONFIG_DEFAULT_MODNAME = "telif";
202const std::string CONFIG_DEFAULT_PROCNAME = "telif";
203const std::string CONFIG_DEFAULT_FILENAME = "config/telif/definitions.yaml";
204const std::string CONFIG_DEFAULT_SCXML_FILENAME = "telif/sm.xml";
205const std::string CONFIG_DEFAULT_SCXML_APPEND = "";
206const std::string CONFIG_DEFAULT_LOG_LEVEL = "INFO";
207const std::string CONFIG_DEFAULT_LOG_PROPERTIES = "config/telif/log.properties";
208const std::string CONFIG_DEFAULT_REQ_ENDPOINT = "zpb.rr://127.0.0.1:12081/"; // the potentially unsafe zpb.rr://0.0.0.0:12081/ we use only in the yaml file.
209const std::string CONFIG_DEFAULT_REQ_ELTPK = "zpb.rr://localhost:11002/";
210const std::string CONFIG_DEFAULT_REQ_TREX = "zpb.rr://localhost:14001/";
211const std::string CONFIG_DEFAULT_OLDB_URI_PREFIX = "cii.oldb:///elt/cs/hlcc/";
212const uint32_t CONFIG_DEFAULT_OLDB_CONN_TIMEOUT = 1; // sec
213const uint32_t CONFIG_DEFAULT_OLDB_ASYNC_PERIOD = 0; // ms; we currently do not use RAD async OLDB writes, but still configure all standard attributes.
215const std::vector<LsvApp> CONFIG_DEFAULT_LSVS = {}; //[{name: \"msTrackCtr\", oldb: \"cii.oldb:///elt/tel/ms/lsv/trackctr\", stdcmds: \"zpb.rr://localhost:11001/TrackCmds\"}]";
216
217const std::string CONFIG_DEFAULT_PUB_DDS_PROFILE = "";
218const std::string CONFIG_DEFAULT_PUB_DDS_NIC = "";
219const std::string CONFIG_DEFAULT_PUB_DDS_FILE = "";
223const double CONFIG_DEFAULT_ALTAZ_ALT_UPPER_LIMIT_OP = 1.544616; // radians - double
224const double CONFIG_DEFAULT_ALTAZ_ALT_LOWER_LIMIT_OP = 0.349066; // radians - double
225const double CONFIG_DEFAULT_ALTAZ_AZ_UPPER_LIMIT_OP = 6.283185; // radians - double
226const double CONFIG_DEFAULT_ALTAZ_AZ_LOWER_LIMIT_OP = -3.141593; // radians - double
227const double CONFIG_DEFAULT_ALTAZ_ALT_UPPER_LIMIT_FCT = 1.570796; // radians - double
228const double CONFIG_DEFAULT_ALTAZ_ALT_LOWER_LIMIT_FCT = 0.0; // radians - double
229const double CONFIG_DEFAULT_ALTAZ_AZ_UPPER_LIMIT_FCT = 6.283185; // radians - double
230const double CONFIG_DEFAULT_ALTAZ_AZ_LOWER_LIMIT_FCT = -3.141593; // radians - double
231const double CONFIG_DEFAULT_ROUS_TIMER_PERIOD_S = 300; // seconds
232const uint32_t CONFIG_DEFAULT_READY_FOR_HANDOVER_ESTIMATION_PERIOD_MS = 1000; // milliseconds
233
234const TelNamedPosition park = {.pos_string = "PARK", .alt_pos = 0.0, .az_pos = 0.0};
235const TelNamedPosition zenith = {.pos_string = "ZENITH", .alt_pos = 1.570796, .az_pos = 0.0};
236const std::vector<TelNamedPosition> CONFIG_DEFAULT_CONFIG_NAMED_POS = {park, zenith};
237
238const std::string CONFIG_DEFAULT_RTCTK_CCSSIM_UDP_IP = "127.0.0.1";
240const std::vector<std::string> CONFIG_DEFAULT_GS_TO_GP_MAPPING = {"A", "B", "C"};
245class Config : public rad::Config {
246 public:
254 Config();
255
259 virtual ~Config();
260
261 Config(const Config&) = delete;
262 Config& operator=(const Config&) = delete;
263};
264
265} // namespace hlcc::telif
266
267#endif // HLCC_TELIF_TELIF_CONFIG_HPP
Default logger name.
ConfigError(const std::string &message)
Definition config.hpp:28
Config()
Definition config.cpp:19
Config & operator=(const Config &)=delete
Disable copy constructor.
virtual ~Config()
Definition config.cpp:63
Config(const Config &)=delete
Definition guideStarHelper.cpp:19
Definition configTest.cpp:22
const std::string KEY_CONFIG_ALTAZ_ALT_LOWER_LIMIT_FCT
Definition config.hpp:153
const double CONFIG_DEFAULT_ROUS_TIMER_PERIOD_S
Definition config.hpp:231
const double CONFIG_DEFAULT_ALTAZ_ALT_UPPER_LIMIT_FCT
Definition config.hpp:227
const std::vector< std::string > OLDB_CFG_KEYS_STRING
Definition config.hpp:168
const std::string KEY_CONFIG_ALTAZ_AZ_LOWER_LIMIT_FCT
Definition config.hpp:155
const std::string KEY_CONFIG_PUB_DDS_PROFILE
Definition config.hpp:142
const std::string KEY_CONFIG_REQ_TREX
Definition config.hpp:138
const std::string CONFIG_DEFAULT_REQ_ENDPOINT
Definition config.hpp:208
const std::string KEY_CONFIG_TRSHKS_CMDS
Definition config.hpp:140
const double CONFIG_DEFAULT_ALTAZ_ALT_LOWER_LIMIT_OP
Definition config.hpp:224
const std::string KEY_CONFIG_PUB_DDS_DOMAIN_ID_HLCC
Definition config.hpp:145
const std::string CONFIG_DEFAULT_PUB_DDS_PROFILE
Definition config.hpp:217
const std::vector< std::string > OLDB_CFG_KEYS_DOUBLE
Definition config.hpp:186
const std::string KEY_CONFIG_PUB_DDS_NIC
Definition config.hpp:143
const uint32_t CONFIG_DEFAULT_READY_FOR_HANDOVER_ESTIMATION_PERIOD_MS
Definition config.hpp:232
const uint32_t CONFIG_DEFAULT_PUB_DDS_DOMAIN_ID_GENERAL
Definition config.hpp:222
const std::string KEY_CONFIG_PUB_DDS_FILE
Definition config.hpp:144
const std::string KEY_CONFIG_ALTAZ_AZ_UPPER_LIMIT_FCT
Definition config.hpp:154
const std::vector< std::string > OLDB_CFG_KEYS_UINT32
Definition config.hpp:177
const std::vector< TelNamedPosition > CONFIG_DEFAULT_CONFIG_NAMED_POS
Definition config.hpp:236
const std::string KEY_CONFIG_RTCTK_CCSSIM_UPD_PORT
Definition config.hpp:161
const std::string KEY_CONFIG
Definition config.hpp:136
const std::string KEY_CONFIG_ALTAZ_ALT_LOWER_LIMIT_OP
Definition config.hpp:149
const std::string CONFIG_DEFAULT_OLDB_URI_PREFIX
Definition config.hpp:211
const std::string CONFIG_DEFAULT_VERSION
Definition config.hpp:200
const std::string CONFIG_DEFAULT_LOG_PROPERTIES
Definition config.hpp:207
const char CONFIG_KEY_SEPARATOR_OLDB
Definition config.hpp:110
const std::string KEY_CONFIG_GS_TO_GP_MAPPING
Definition config.hpp:162
const std::string KEY_CONFIG_ALTAZ_ALT_UPPER_LIMIT_OP
Definition config.hpp:148
const std::string CONFIG_DEFAULT_FILENAME
Definition config.hpp:203
const std::string KEY_CONFIG_REQ_ELTPK
Definition config.hpp:137
const std::string KEY_CONFIG_ALTAZ_AZ_LOWER_LIMIT_OP
Definition config.hpp:151
const std::string CONFIG_DEFAULT_SCXML_APPEND
Definition config.hpp:205
const std::string CONFIG_DEFAULT_PUB_DDS_FILE
Definition config.hpp:219
const std::string KEY_CONFIG_READY_FOR_HANDOVER_ESTIMATION_PERIOD_MS
Definition config.hpp:158
const double CONFIG_DEFAULT_ALTAZ_AZ_LOWER_LIMIT_OP
Definition config.hpp:226
const uint32_t CONFIG_DEFAULT_PUB_DDS_DOMAIN_ID_CCS_INS
Definition config.hpp:221
const uint32_t CONFIG_DEFAULT_OLDB_ASYNC_PERIOD
Definition config.hpp:213
const bool CONFIG_DEFAULT_TRS_HEALTH_ENABLED
Definition config.hpp:214
const std::string KEY_CONFIG_PUB_DDS_DOMAIN_ID_CCS_INS
Definition config.hpp:146
const double CONFIG_DEFAULT_ALTAZ_AZ_UPPER_LIMIT_FCT
Definition config.hpp:229
const uint32_t CONFIG_DEFAULT_PUB_DDS_DOMAIN_ID_HLCC
Definition config.hpp:220
const std::string CONFIG_DEFAULT_REQ_ELTPK
Definition config.hpp:209
const std::string KEY_CONFIG_ALTAZ_AZ_UPPER_LIMIT_OP
Definition config.hpp:150
const TelNamedPosition zenith
Definition config.hpp:235
const double CONFIG_DEFAULT_ALTAZ_ALT_UPPER_LIMIT_OP
Definition config.hpp:223
const std::string KEY_CONFIG_PUB_DDS_DOMAIN_ID_GENERAL
Definition config.hpp:147
const double CONFIG_DEFAULT_ALTAZ_AZ_LOWER_LIMIT_FCT
Definition config.hpp:230
const std::vector< std::string > CONFIG_DEFAULT_GS_TO_GP_MAPPING
Definition config.hpp:240
const std::string CONFIG_DEFAULT_MODNAME
Definition config.hpp:201
const std::string CONFIG_DEFAULT_REQ_TREX
Definition config.hpp:210
const std::string KEY_CONFIG_NAMED_POS
Definition config.hpp:159
const std::string CONFIG_DEFAULT_SCXML_FILENAME
Definition config.hpp:204
const double CONFIG_DEFAULT_ALTAZ_ALT_LOWER_LIMIT_FCT
Definition config.hpp:228
const std::string CONFIG_DEFAULT_PUB_DDS_NIC
Definition config.hpp:218
const TelNamedPosition park
Definition config.hpp:234
const std::string CONFIG_DEFAULT_PROCNAME
Definition config.hpp:202
const std::string KEY_CONFIG_ROUS_TIMER_PERIOD_S
Definition config.hpp:156
const std::string CONFIG_DEFAULT_RTCTK_CCSSIM_UDP_IP
Definition config.hpp:238
const std::string KEY_CONFIG_ALTAZ_ALT_UPPER_LIMIT_FCT
Definition config.hpp:152
const double CONFIG_DEFAULT_ALTAZ_AZ_UPPER_LIMIT_OP
Definition config.hpp:225
const uint32_t CONFIG_DEFAULT_RTCTK_CCSSIM_UDP_PORT
Definition config.hpp:239
const std::string KEY_CONFIG_RTCTK_CCSSIM_UPD_IP
Definition config.hpp:160
const std::string CONFIG_DEFAULT_LOG_LEVEL
Definition config.hpp:206
const std::vector< LsvApp > CONFIG_DEFAULT_LSVS
Definition config.hpp:215
const uint32_t CONFIG_DEFAULT_OLDB_CONN_TIMEOUT
Definition config.hpp:212
const std::string KEY_CONFIG_LSVS
Definition config.hpp:139
Definition ccsinsoldb.hpp:10
static bool Encode(CiiConfigInstanceNode &node, const hlcc::telif::LsvApp &source)
Definition config.hpp:95
static bool Decode(const CiiConfigInstanceNode &node, hlcc::telif::LsvApp &target)
Definition config.hpp:84
static bool Decode(const CiiConfigInstanceNode &node, hlcc::telif::TelNamedPosition &target)
Definition config.hpp:57
static bool Encode(CiiConfigInstanceNode &node, const hlcc::telif::TelNamedPosition &source)
Definition config.hpp:68
Definition config.hpp:43
std::string cmds
Definition config.hpp:46
std::string name
Definition config.hpp:44
std::string oldb
Definition config.hpp:45
Definition config.hpp:38
double alt_pos
Definition config.hpp:40
std::string pos_string
Definition config.hpp:39
double az_pos
Definition config.hpp:41