DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
util.hpp
Go to the documentation of this file.
1#ifndef _dal_util_H_
2#define _dal_util_H_
3
4#include <exception>
5
7// #include "conffwk/DalObject.hpp"
8#include "nlohmann/json.hpp"
9#include "logging/Logging.hpp" // NOTE: if ISSUES ARE DECLARED BEFORE include logging/Logging.hpp, TLOG_DEBUG<<issue wont work.
10
13#include "confmodel/Segment.hpp"
14#include "confmodel/Service.hpp"
15#include "confmodel/Session.hpp"
17
18namespace dunedaq {
19
20ERS_DECLARE_ISSUE(confmodel, InvalidOpMonFile,
21 file_name << " is an invalid name for the opmon output",
22 ((std::string)file_name))
23
25
28 "The opmon infrastructure has not been set up in the configuration", , )
29
31 confmodel, NoControlServiceDefined, ConfigurationError,
32 "The control service has not been set up for the application " + app_name +
33 " you need to define a service called which has a name finishing with \'_control\'",
34 , ((std::string)app_name)
35)
36
39 "The control service has been defined multiple times for the application " +
40 app_name + " you need to define only one service called control",
41 , ((std::string)app_name)
42
43)
44
45
46
47namespace confmodel {
48
81get_session(dunedaq::conffwk::Configuration &conf, const std::string &name,
82 unsigned long rlevel = 10,
83 const std::vector<std::string> *rclasses = nullptr);
84
85template <typename T>
86void add_json_value(conffwk::ConfigObject &obj, std::string &name,
87 bool multi_value, nlohmann::json &attributes) {
88 if (!multi_value) {
89 T value;
90 obj.get(name, value);
91 attributes[name] = value;
92 } else {
93 std::vector<T> value_vector;
94 obj.get(name, value_vector);
95 attributes[name] = nlohmann::json(value_vector);
96 }
97}
98
99template <typename T>
100const std::vector<std::string> construct_commandline_parameters_appfwk(
101 const T *app, const conffwk::Configuration &confdb,
103
104 const dunedaq::confmodel::Service *control_service = nullptr;
105
106 for (auto const *as : app->get_exposes_service()) {
107 if (as->UID().ends_with("_control")) {
108 if (control_service)
109 throw DuplicatedControlService(ERS_HERE, as->UID());
110 control_service = as;
111 }
112 }
113
114 if (control_service == nullptr)
115 throw NoControlServiceDefined(ERS_HERE, app->UID());
116
117 const std::string control_uri = control_service->get_protocol() + "://" +
118 app->get_runs_on()->get_runs_on()->UID() +
119 ":" +
120 std::to_string(control_service->get_port());
121
122 const std::string configuration_uri = confdb.get_impl_spec();
123
124 return {
125 "-s",
126 session->UID(),
127 "--name",
128 app->UID(),
129 "-c",
130 control_uri,
131 "--configurationService",
132 configuration_uri,
133 };
134}
135
136} // namespace confmodel
137
139
140ERS_DECLARE_ISSUE_BASE(confmodel, BadVariableUsage, AlgorithmError, message, ,
141 ((std::string)message))
142
144 "Failed to retrieve information for Application \'"
145 << app_id << "\' from the database: " << message,
146 , ((std::string)app_id)((std::string)message))
147
149 "There is no session object with UID = \"" << name
150 << '\"',
151 , ((std::string)name))
152
154 confmodel, SegmentDisabled, AlgorithmError,
155 "Cannot get information about applications because the segment is disabled",
156 , )
157
159 "Failed to retrieve information for Program \'"
160 << prog_id << "\' from the database: " << message,
161 , ((std::string)prog_id)((std::string)message))
162
164 "Failed to retrieve application \'"
165 << app_id << "\' from the database: " << message,
166 , ((std::string)app_id)((std::string)message))
167
169 "Failed to find default host for segment \'"
170 << seg_id << "\' " << message,
171 , ((std::string)seg_id)((std::string)message))
172
174 confmodel, NoTemplateAppHost, AlgorithmError,
175 "Both session default and segment default hosts are not defined for "
176 "template application \'"
177 << app_id << "\' from segment \'" << seg_id
178 << "\' (will use localhost, that may cause problems presenting info in "
179 "IGUI for distributed session).",
180 , ((std::string)app_id)((std::string)seg_id))
181
183 "Failed to use tag \'" << tag_id
184 << "\' because: " << message,
185 , ((std::string)tag_id)((std::string)message))
186
188 "Invalid Segment \'" << seg_id
189 << "\' because: " << message,
190 , ((std::string)seg_id)((std::string)message))
191
192ERS_DECLARE_ISSUE_BASE(confmodel, GetTemplateApplicationsOfSegmentError,
194 "Failed to get template applications of \'"
195 << name << "\' segment" << message,
196 , ((std::string)name)((std::string)message))
197
198ERS_DECLARE_ISSUE_BASE(confmodel, BadTemplateSegmentDescription, AlgorithmError,
199 "Bad configuration description of template segment \'"
200 << name << "\': " << message,
201 , ((std::string)name)((std::string)message))
202
203ERS_DECLARE_ISSUE_BASE(confmodel, CannotGetApplicationObject, AlgorithmError,
204 "Failed to get application object from name: " << reason,
205 , ((std::string)reason))
206
207ERS_DECLARE_ISSUE_BASE(confmodel, CannotFindSegmentByName, AlgorithmError,
208 "Failed to find segment object \'" << name
209 << "\': " << reason,
210 , ((std::string)name)((std::string)reason))
211
213 "The " << item << " object " << obj
214 << " was not initialized",
215 , ((const char *)item)((void *)obj))
216
217ERS_DECLARE_ISSUE_BASE(confmodel, NotInitedByDalAlgorithm, AlgorithmError,
218 "The " << obj_id << '@' << obj_class << " object "
219 << address
220 << " was not initialized by DAL algorithm "
221 << algo,
222 ,
223 ((std::string)obj_id)((std::string)obj_class)(
224 (void *)address)((const char *)algo))
225
226ERS_DECLARE_ISSUE_BASE(confmodel, CannotCreateSegConfig, AlgorithmError,
227 "Failed to create config for segment \'"
228 << name << "\': " << reason,
229 , ((std::string)name)((std::string)reason))
230
232 "Failed to get parents of \'" << object << '\'', ,
233 ((std::string)object))
234
237 "Reach maximum allowed recursion ("
238 << limit << ") during calculation of " << goal
239 << "; possibly there is circular dependency between these objects: "
240 << objects,
241 , ((unsigned int)limit)((const char *)goal)((std::string)objects))
242
244 confmodel, NoJarFile, AlgorithmError,
245 "Cannot find jar file \'" << file << "\' described by \'" << obj_id << '@'
246 << obj_class << "\' that is part of \'" << rep_id
247 << '@' << rep_class << '\'',
248 ,
249 ((std::string)file)((std::string)obj_id)((std::string)obj_class)(
250 (std::string)rep_id)((std::string)rep_class))
251
252ERS_DECLARE_ISSUE_BASE(confmodel, DuplicatedApplicationID, AlgorithmError,
253 "Two applications have equal IDs:\n 1) "
254 << first << "\n 2) " << second,
255 , ((std::string)first)((std::string)second))
256
258 confmodel, SegmentIncludedMultipleTimes, AlgorithmError,
259 "The segment \"" << segment << "\" is included by:\n 1) " << first
260 << "\n 2) " << second,
261 , ((std::string)segment)((std::string)first)((std::string)second))
262
263} // namespace dunedaq
264
265#endif
#define ERS_DECLARE_ISSUE_BASE(namespace_name, class_name, base_class_name, message, base_attributes, attributes)
#define ERS_DECLARE_ISSUE(namespace_name, class_name, message, attributes)
#define ERS_HERE
Defines base class for cache of template objects.
const std::string & get_impl_spec() const noexcept
const std::string & get_protocol() const
Get "protocol" attribute value.
Definition Service.hpp:99
uint16_t get_port() const
Get "port" attribute value.
Definition Service.hpp:130
conffwk entry point
const std::vector< std::string > construct_commandline_parameters_appfwk(const T *app, const conffwk::Configuration &confdb, const dunedaq::confmodel::Session *session)
Definition util.hpp:100
const dunedaq::confmodel::Session * get_session(dunedaq::conffwk::Configuration &conf, const std::string &name, unsigned long rlevel=10, const std::vector< std::string > *rclasses=nullptr)
Get session object.
void add_json_value(conffwk::ConfigObject &obj, std::string &name, bool multi_value, nlohmann::json &attributes)
Definition util.hpp:86
Including Qt Headers.
The opmon infrastructure has not been set up in the DuplicatedControlService
Definition util.hpp:38
ConfigurationError
Definition util.hpp:27
AlgorithmError
Definition util.hpp:143
init Command received when already initialized
The opmon infrastructure has not been set up in the The control service has been defined multiple times for the application app_name you need to define only one service called control
Definition util.hpp:40
Monitoring thread not set
NoOpmonInfrastructure
Definition util.hpp:27
The opmon infrastructure has not been set up in the configuration
Definition util.hpp:28
BadApplicationInfo
Definition util.hpp:143
Factory couldn t find
Definition Issues.hpp:24