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 "logging/Logging.hpp" // NOTE: if ISSUES ARE DECLARED BEFORE include logging/Logging.hpp, TLOG_DEBUG<<issue wont work.
9#include "nlohmann/json.hpp"
10
13#include "confmodel/Segment.hpp"
14#include "confmodel/Service.hpp"
15#include "confmodel/Session.hpp"
18
19namespace dunedaq {
20
21namespace confmodel {
22
53
54const dunedaq::confmodel::Session*
56 const std::string& name,
57 unsigned long rlevel = 10,
58 const std::vector<std::string>* rclasses = nullptr);
59
60template<typename T>
61void
62add_json_value(conffwk::ConfigObject& obj, std::string& name, bool multi_value, nlohmann::json& attributes)
63{
64 if (!multi_value) {
65 T value;
66 obj.get(name, value);
67 attributes[name] = value;
68 } else {
69 std::vector<T> value_vector;
70 obj.get(name, value_vector);
71 attributes[name] = nlohmann::json(value_vector);
72 }
73}
74
75template<typename T>
76const std::vector<std::string>
78 const conffwk::Configuration& confdb,
80{
81
82 const dunedaq::confmodel::Service* control_service = nullptr;
83
84 for (auto const* as : app->get_exposes_service()) {
85 if (as->UID().ends_with("_control")) {
86 if (control_service)
87 throw DuplicatedControlService(ERS_HERE, as->UID());
88 control_service = as;
89 }
90 }
91
92 if (control_service == nullptr)
93 throw NoControlServiceDefined(ERS_HERE, app->UID());
94
95 const std::string control_uri = control_service->get_protocol() + "://" + app->get_runs_on()->get_runs_on()->UID() +
96 ":" + std::to_string(control_service->get_port());
97
98 const std::string configuration_uri = confdb.get_impl_spec();
99
100 return {
101 "-s", session->UID(), "--name", app->UID(), "-c", control_uri, "--configurationService", configuration_uri,
102 };
103}
104
105} // namespace confmodel
106
107} // namespace dunedaq
108
109#endif
#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:77
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:62
The DUNE-DAQ namespace.
msgpack::object obj