44 const std::string& uid,
45 const std::vector<uint32_t>& stream_source_ids,
46 const std::vector<const SourceIDConf*>& tp_source_ids,
48 std::vector<std::shared_ptr<conffwk::ConfigObject>> sidObjs)
50 sidNetObj.
set_obj(
"netconn", netConn);
52 std::vector<const conffwk::ConfigObject*> source_id_objs;
54 for (
auto& source_id : stream_source_ids) {
55 std::string streamSidUid(uid +
"SourceIDConf" + std::to_string(source_id));
56 auto stream_sid_obj = std::make_shared<conffwk::ConfigObject>(obj_fac.
create(
"SourceIDConf", streamSidUid));
57 stream_sid_obj->set_by_val<uint32_t>(
"sid", source_id);
58 stream_sid_obj->set_by_val<std::string>(
"subsystem",
"Detector_Readout");
59 sidObjs.push_back(stream_sid_obj);
60 source_id_objs.push_back(sidObjs.back().get());
63 for (
auto tp_sid : tp_source_ids) {
64 sidObjs.push_back(std::make_shared<conffwk::ConfigObject>(tp_sid->config_object()));
65 source_id_objs.push_back(sidObjs.back().get());
75 sidNetObj.
set_objs(
"source_ids", source_id_objs);
81 const std::string& uid,
82 const std::vector<const SourceIDConf*>& tp_source_ids,
83 std::vector<conffwk::ConfigObject>* netConn,
84 std::vector<conffwk::ConfigObject>* sidNetObj,
86 std::vector<std::shared_ptr<conffwk::ConfigObject>> sidObjs)
88 std::vector<const conffwk::ConfigObject*> source_id_objs;
90 for (
auto tp_sid : tp_source_ids) {
92 std::string name = tp_sid->UID();
93 size_t pos = name.find_last_of(
'-');
95 if (pos != std::string::npos) {
96 ext = name.substr(pos);
100 std::string dreqNetUid(uid + ext);
101 netConn->emplace_back(
103 netConn->back().set_by_val<std::string>(
"data_type", descriptor->get_data_type());
104 netConn->back().set_by_val<std::string>(
"connection_type", descriptor->get_connection_type());
105 auto serviceObj = descriptor->get_associated_service()->config_object();
106 netConn->back().set_obj(
"associated_service", &serviceObj);
109 std::string sidToNetUid(uid + ext +
"-sids");
110 sidNetObj->emplace_back(
111 obj_fac.
create(
"SourceIDToNetworkConnection", sidToNetUid));
112 sidNetObj->back().set_obj(
"netconn", &netConn->back());
115 sidObjs.push_back(std::make_shared<conffwk::ConfigObject>(tp_sid->config_object()));
116 sidNetObj->back().set_objs(
"source_ids", { sidObjs.back().get() });
124 std::shared_ptr<appmodel::ConfigurationHelper> helper)
const {
128 std::vector<const confmodel::DaqModule*> modules;
132 std::vector<const conffwk::ConfigObject*> trbInputObjs;
133 std::vector<const conffwk::ConfigObject*> trbOutputObjs;
134 std::vector<const conffwk::ConfigObject*> trbSidNetObjs;
141 auto destination_class = rule->get_destination_class();
142 if (destination_class ==
"DataWriterModule") {
143 trQDesc = rule->get_descriptor();
146 if (trQDesc ==
nullptr) {
147 throw(BadConf(
ERS_HERE,
"Could not find queue descriptor rule for TriggerRecords!"));
153 trbOutputObjs.push_back(&trQueueObj);
162 auto descriptor = rule->get_descriptor();
163 auto data_type = descriptor->get_data_type();
164 if (data_type ==
"Fragment") {
165 fragNetDesc = rule->get_descriptor();
166 }
else if (data_type ==
"TriggerDecision") {
167 trigdecNetDesc = rule->get_descriptor();
168 }
else if (data_type ==
"TriggerDecisionToken") {
169 tokenNetDesc = rule->get_descriptor();
170 }
else if (data_type ==
"TRMonRequest") {
171 trmonReqNetDesc = rule->get_descriptor();
172 }
else if (data_type ==
"TriggerRecord") {
173 trmonTRNetDesc = rule->get_descriptor();
176 if (fragNetDesc ==
nullptr) {
177 throw(BadConf(
ERS_HERE,
"Could not find network descriptor rule for input Fragments!"));
179 if (trigdecNetDesc ==
nullptr) {
180 throw(BadConf(
ERS_HERE,
"Could not find network descriptor rule for input TriggerDecisions!"));
182 if (tokenNetDesc ==
nullptr) {
183 throw(BadConf(
ERS_HERE,
"Could not find network descriptor rule for output TriggerDecisionTokens!"));
186 throw(BadConf(
ERS_HERE,
"Could not retrieve SourceIDConf"));
194 if (trmonReqNetDesc !=
nullptr) {
197 if (trmonTRNetDesc !=
nullptr) {
203 std::vector<conffwk::ConfigObject> dreqNetObjs;
204 std::vector<conffwk::ConfigObject> sidNetObjs;
205 std::vector<std::shared_ptr<conffwk::ConfigObject>> sidObjs;
206 std::set<std::string> processed_apps;
207 for (
auto uid: helper->get_app_uids(
"DFApplication")) {
208 processed_apps.insert(uid);
211 auto stream_src_ids = helper->get_stream_source_ids();
212 auto tp_src_ids = helper->get_tp_source_ids();
213 for (
auto [uid, descriptor]:
214 helper->get_netdescriptors(
"DataRequest",
"ReadoutApplication")) {
215 dreqNetObjs.emplace_back(obj_fac.
create_net_obj(descriptor, uid));
217 std::string sidToNetUid(descriptor->get_uid_base() + uid +
"-sids");
218 sidNetObjs.emplace_back(obj_fac.
create(
"SourceIDToNetworkConnection", sidToNetUid));
223 stream_src_ids.at(uid),
227 processed_apps.insert(uid);
230 for (
auto [uid, descriptor]:
231 helper->get_netdescriptors(
"DataRequest",
"TPReplayApplication")) {
239 processed_apps.insert(uid);
245 for (
auto [uid, descriptor]:
246 helper->get_netdescriptors(
"DataRequest",
"FakeDataApplication")) {
247 dreqNetObjs.emplace_back(obj_fac.
create_net_obj(descriptor, uid));
249 std::string sidToNetUid(descriptor->get_uid_base() + uid +
"-sids");
250 sidNetObjs.emplace_back(obj_fac.
create(
"SourceIDToNetworkConnection", sidToNetUid));
255 stream_src_ids.at(uid),
259 processed_apps.insert(uid);
263 const auto ctb_type =
"CTBApplication";
264 for (
auto [uid, descriptor]: helper->get_netdescriptors(
"DataRequest", ctb_type)) {
266 if (processed_apps.contains(uid)) {
270 for (
const auto & [uid, rel_sources] :
271 helper->get_all_app_source_ids(ctb_type) ) {
272 for (
auto [rel,
id] : rel_sources ) {
273 std::string local_uid = uid;
274 local_uid += rel.find(
"LLT")!=std::string::npos ?
"_LLT" :
"_HLT";
276 dreqNetObjs.emplace_back(obj_fac.
create_net_obj(descriptor, local_uid));
277 sidObjs.push_back(std::make_shared<conffwk::ConfigObject>(id->config_object()));
279 std::string sidToNetUid(descriptor->get_uid_base() + local_uid);
280 sidNetObjs.emplace_back(obj_fac.
create(
"SourceIDToNetworkConnection", sidToNetUid));
281 sidNetObjs.back().set_objs(
"source_ids", {sidObjs.back().get()});
282 sidNetObjs.back().set_obj(
"netconn", &dreqNetObjs.back());
286 processed_apps.insert(uid);
290 auto app_sources = helper->get_app_source_ids();
292 for (
auto [uid, descriptor]: helper->get_netdescriptors(
"DataRequest")) {
295 if (processed_apps.contains(uid)) {
298 if (app_sources.contains(uid)) {
299 dreqNetObjs.emplace_back(obj_fac.
create_net_obj(descriptor, uid));
301 sidObjs.push_back(std::make_shared<conffwk::ConfigObject>(
302 app_sources.at(uid)->config_object()));
304 std::string sidToNetUid(descriptor->get_uid_base() + uid +
"-sids");
305 sidNetObjs.emplace_back(obj_fac.
create(
"SourceIDToNetworkConnection", sidToNetUid));
306 sidNetObjs.back().set_objs(
"source_ids", {sidObjs.back().get()});
307 sidNetObjs.back().set_obj(
"netconn", &dreqNetObjs.back());
309 processed_apps.insert(uid);
315 for (
auto&
obj : dreqNetObjs) {
316 trbOutputObjs.push_back(&
obj);
318 for (
auto&
obj : sidNetObjs) {
319 trbSidNetObjs.push_back(&
obj);
327 if (trbConf ==
nullptr) {
328 throw(BadConf(
ERS_HERE,
"No DataWriterModule or TRB configuration given"));
330 auto trbConfObj = trbConf->config_object();
332 trbInputObjs = { &trigdecNetObj, &fragNetObj };
333 if (trmonReqNetDesc !=
nullptr) {
334 trbInputObjs.push_back(&trmonReqNetObj);
336 if (trmonTRNetDesc !=
nullptr) {
337 trbOutputObjs.push_back(&trmonTRNetObj);
340 std::string trbUid(
UID() +
"-trb");
342 trbObj.
set_obj(
"configuration", &trbConfObj);
343 trbObj.
set_objs(
"inputs", trbInputObjs);
344 trbObj.
set_objs(
"outputs", trbOutputObjs);
345 trbObj.
set_obj(
"trigger_record_output", &trQueueObj);
346 trbObj.
set_objs(
"request_connections", trbSidNetObjs);
352 if (dwrConfs.size() == 0) {
353 throw(BadConf(
ERS_HERE,
"No DataWriterModule or TRB configuration given"));
356 for (
auto dwrConf : dwrConfs) {
359 auto dwrConfObj = dwrConf->config_object();
362 std::string dwrUid(fmt::format(
"{}-dw-{}",
UID(), dw_idx));
364 dwrObj.
set_by_val(
"writer_identifier", fmt::format(
"{}_dw_{}",
UID(), dw_idx));
365 dwrObj.
set_obj(
"configuration", &dwrConfObj);
366 dwrObj.
set_objs(
"inputs", { &trQueueObj });
367 dwrObj.
set_objs(
"outputs", { &tokenNetObj });