43 const std::string& uid,
44 const std::vector<uint32_t>& stream_source_ids,
45 const std::vector<const SourceIDConf*>& tp_source_ids,
47 std::vector<std::shared_ptr<conffwk::ConfigObject>> sidObjs)
49 sidNetObj.
set_obj(
"netconn", netConn);
51 std::vector<const conffwk::ConfigObject*> source_id_objs;
53 for (
auto& source_id : stream_source_ids) {
54 std::string streamSidUid(uid +
"SourceIDConf" + std::to_string(source_id));
55 auto stream_sid_obj = std::make_shared<conffwk::ConfigObject>(obj_fac.
create(
"SourceIDConf", streamSidUid));
56 stream_sid_obj->set_by_val<uint32_t>(
"sid", source_id);
57 stream_sid_obj->set_by_val<std::string>(
"subsystem",
"Detector_Readout");
58 sidObjs.push_back(stream_sid_obj);
59 source_id_objs.push_back(sidObjs.back().get());
62 for (
auto tp_sid : tp_source_ids) {
63 sidObjs.push_back(std::make_shared<conffwk::ConfigObject>(tp_sid->config_object()));
64 source_id_objs.push_back(sidObjs.back().get());
74 sidNetObj.
set_objs(
"source_ids", source_id_objs);
79 const std::string& uid,
80 const std::vector<const SourceIDConf*>& tp_source_ids,
81 std::vector<conffwk::ConfigObject>* netConn,
82 std::vector<conffwk::ConfigObject>* sidNetObj,
84 std::vector<std::shared_ptr<conffwk::ConfigObject>> sidObjs)
86 std::vector<const conffwk::ConfigObject*> source_id_objs;
88 for (
auto tp_sid : tp_source_ids) {
90 std::string name = tp_sid->UID();
91 size_t pos = name.find_last_of(
'-');
93 if (pos != std::string::npos) {
94 ext = name.substr(pos);
98 std::string dreqNetUid(uid + ext);
100 netConn->back().set_by_val<std::string>(
"data_type",
descriptor->get_data_type());
101 netConn->back().set_by_val<std::string>(
"connection_type",
descriptor->get_connection_type());
102 auto serviceObj =
descriptor->get_associated_service()->config_object();
103 netConn->back().set_obj(
"associated_service", &serviceObj);
106 std::string sidToNetUid(uid + ext +
"-sids");
107 sidNetObj->emplace_back(obj_fac.
create(
"SourceIDToNetworkConnection", sidToNetUid));
108 sidNetObj->back().set_obj(
"netconn", &netConn->back());
111 sidObjs.push_back(std::make_shared<conffwk::ConfigObject>(tp_sid->config_object()));
112 sidNetObj->back().set_objs(
"source_ids", { sidObjs.back().get() });
122 std::vector<const confmodel::DaqModule*> modules;
126 std::vector<const conffwk::ConfigObject*> trbInputObjs;
127 std::vector<const conffwk::ConfigObject*> trbOutputObjs;
128 std::vector<const conffwk::ConfigObject*> trbSidNetObjs;
135 auto destination_class = rule->get_destination_class();
136 if (destination_class ==
"DataWriterModule") {
137 trQDesc = rule->get_descriptor();
140 if (trQDesc ==
nullptr) {
141 throw(BadConf(
ERS_HERE,
"Could not find queue descriptor rule for TriggerRecords!"));
147 trbOutputObjs.push_back(&trQueueObj);
158 if (data_type ==
"Fragment") {
159 fragNetDesc = rule->get_descriptor();
160 }
else if (data_type ==
"TriggerDecision") {
161 trigdecNetDesc = rule->get_descriptor();
162 }
else if (data_type ==
"TriggerDecisionToken") {
163 tokenNetDesc = rule->get_descriptor();
164 }
else if (data_type ==
"TRMonRequest") {
165 trmonReqNetDesc = rule->get_descriptor();
166 }
else if (data_type ==
"TriggerRecord") {
167 trmonTRNetDesc = rule->get_descriptor();
170 if (fragNetDesc ==
nullptr) {
171 throw(BadConf(
ERS_HERE,
"Could not find network descriptor rule for input Fragments!"));
173 if (trigdecNetDesc ==
nullptr) {
174 throw(BadConf(
ERS_HERE,
"Could not find network descriptor rule for input TriggerDecisions!"));
176 if (tokenNetDesc ==
nullptr) {
177 throw(BadConf(
ERS_HERE,
"Could not find network descriptor rule for output TriggerDecisionTokens!"));
180 throw(BadConf(
ERS_HERE,
"Could not retrieve SourceIDConf"));
188 if (trmonReqNetDesc !=
nullptr) {
191 if (trmonTRNetDesc !=
nullptr) {
197 std::vector<conffwk::ConfigObject> dreqNetObjs;
198 std::vector<conffwk::ConfigObject> sidNetObjs;
199 std::vector<std::shared_ptr<conffwk::ConfigObject>> sidObjs;
200 std::set<std::string> processed_apps;
201 for (
auto uid : helper->get_app_uids(
"DFApplication")) {
202 processed_apps.insert(uid);
205 auto stream_src_ids = helper->get_stream_source_ids();
206 auto tp_src_ids = helper->get_tp_source_ids();
207 for (
auto [uid,
descriptor] : helper->get_netdescriptors(
"DataRequest",
"ReadoutApplication")) {
210 std::string sidToNetUid(
descriptor->get_uid_base() + uid +
"-sids");
211 sidNetObjs.emplace_back(obj_fac.
create(
"SourceIDToNetworkConnection", sidToNetUid));
214 obj_fac, &dreqNetObjs.back(), uid, stream_src_ids.at(uid), tp_src_ids.at(uid), sidNetObjs.back(), sidObjs);
215 processed_apps.insert(uid);
218 for (
auto [uid,
descriptor] : helper->get_netdescriptors(
"DataRequest",
"TPReplayApplication")) {
220 processed_apps.insert(uid);
223 for (
auto [uid,
descriptor] : helper->get_netdescriptors(
"DataRequest",
"FakeDataApplication")) {
226 std::string sidToNetUid(
descriptor->get_uid_base() + uid +
"-sids");
227 sidNetObjs.emplace_back(obj_fac.
create(
"SourceIDToNetworkConnection", sidToNetUid));
232 stream_src_ids.at(uid),
236 processed_apps.insert(uid);
240 const auto ctb_type =
"CTBApplication";
241 for (
auto [uid,
descriptor] : helper->get_netdescriptors(
"DataRequest", ctb_type)) {
243 if (processed_apps.contains(uid)) {
247 for (
const auto& [uid, rel_sources] : helper->get_all_app_source_ids(ctb_type)) {
248 for (
auto [rel,
id] : rel_sources) {
249 std::string local_uid = uid;
250 local_uid += rel.find(
"LLT") != std::string::npos ?
"_LLT" :
"_HLT";
253 sidObjs.push_back(std::make_shared<conffwk::ConfigObject>(id->config_object()));
255 std::string sidToNetUid(
descriptor->get_uid_base() + local_uid);
256 sidNetObjs.emplace_back(obj_fac.
create(
"SourceIDToNetworkConnection", sidToNetUid));
257 sidNetObjs.back().set_objs(
"source_ids", { sidObjs.back().get() });
258 sidNetObjs.back().set_obj(
"netconn", &dreqNetObjs.back());
262 processed_apps.insert(uid);
266 auto app_sources = helper->get_app_source_ids();
268 for (
auto [uid,
descriptor] : helper->get_netdescriptors(
"DataRequest")) {
270 if (processed_apps.contains(uid)) {
273 if (app_sources.contains(uid)) {
276 sidObjs.push_back(std::make_shared<conffwk::ConfigObject>(app_sources.at(uid)->config_object()));
278 std::string sidToNetUid(
descriptor->get_uid_base() + uid +
"-sids");
279 sidNetObjs.emplace_back(obj_fac.
create(
"SourceIDToNetworkConnection", sidToNetUid));
280 sidNetObjs.back().set_objs(
"source_ids", { sidObjs.back().get() });
281 sidNetObjs.back().set_obj(
"netconn", &dreqNetObjs.back());
283 processed_apps.insert(uid);
288 for (
auto&
obj : dreqNetObjs) {
289 trbOutputObjs.push_back(&
obj);
291 for (
auto&
obj : sidNetObjs) {
292 trbSidNetObjs.push_back(&
obj);
300 if (trbConf ==
nullptr) {
301 throw(BadConf(
ERS_HERE,
"No DataWriterModule or TRB configuration given"));
303 auto trbConfObj = trbConf->config_object();
305 trbInputObjs = { &trigdecNetObj, &fragNetObj };
306 if (trmonReqNetDesc !=
nullptr) {
307 trbInputObjs.push_back(&trmonReqNetObj);
309 if (trmonTRNetDesc !=
nullptr) {
310 trbOutputObjs.push_back(&trmonTRNetObj);
313 std::string trbUid(
UID() +
"-trb");
315 trbObj.
set_obj(
"configuration", &trbConfObj);
316 trbObj.
set_objs(
"inputs", trbInputObjs);
317 trbObj.
set_objs(
"outputs", trbOutputObjs);
318 trbObj.
set_obj(
"trigger_record_output", &trQueueObj);
319 trbObj.
set_objs(
"request_connections", trbSidNetObjs);
325 if (dwrConfs.size() == 0) {
326 throw(BadConf(
ERS_HERE,
"No DataWriterModule or TRB configuration given"));
329 for (
auto dwrConf : dwrConfs) {
332 auto dwrConfObj = dwrConf->config_object();
335 std::string dwrUid(fmt::format(
"{}-dw-{}",
UID(), dw_idx));
337 dwrObj.
set_by_val(
"writer_identifier", fmt::format(
"{}_dw_{}",
UID(), dw_idx));
338 dwrObj.
set_obj(
"configuration", &dwrConfObj);
339 dwrObj.
set_objs(
"inputs", { &trQueueObj });
340 dwrObj.
set_objs(
"outputs", { &tokenNetObj });