66 std::vector<conffwk::ConfigObject>* netConn,
67 std::vector<conffwk::ConfigObject>* sidNetObj,
68 std::vector<std::shared_ptr<conffwk::ConfigObject>> sidObjs,
70 std::string smartapp_uid)
72 std::vector<const conffwk::ConfigObject*> source_id_objs;
76 std::string name = tp_sid->UID();
77 size_t pos = name.find_last_of(
'-');
79 if (pos != std::string::npos) {
80 ext = name.substr(pos);
84 std::string dreqNetUid(smartapp_uid + ext);
85 netConn->emplace_back(
87 netConn->back().set_by_val<std::string>(
"data_type", descriptor->get_data_type());
88 netConn->back().set_by_val<std::string>(
"connection_type", descriptor->get_connection_type());
89 auto serviceObj = descriptor->get_associated_service()->config_object();
90 netConn->back().set_obj(
"associated_service", &serviceObj);
93 std::string sidToNetUid(smartapp_uid + ext +
"-sids");
94 sidNetObj->emplace_back(
95 obj_fac.
create(
"SourceIDToNetworkConnection", sidToNetUid));
96 sidNetObj->back().set_obj(
"netconn", &netConn->back());
99 sidObjs.push_back(std::make_shared<conffwk::ConfigObject>(tp_sid->config_object()));
100 sidNetObj->back().set_objs(
"source_ids", { sidObjs.back().get() });
109 std::vector<std::shared_ptr<conffwk::ConfigObject>> sidObjs)
111 sidNetObj.
set_obj(
"netconn", netConn);
113 std::vector<const conffwk::ConfigObject*> source_id_objs;
114 std::vector<uint32_t> app_source_ids;
127 for (
auto dros : d2d_conn->get_streams()) {
132 app_source_ids.push_back(stream->get_source_id());
136 for (
auto& source_id : app_source_ids) {
137 std::string streamSidUid(roapp->
UID() +
"SourceIDConf" + std::to_string(source_id));
138 auto stream_sid_obj = std::make_shared<conffwk::ConfigObject>(obj_fac.
create(
"SourceIDConf", streamSidUid));
139 stream_sid_obj->set_by_val<uint32_t>(
"sid", source_id);
140 stream_sid_obj->set_by_val<std::string>(
"subsystem",
"Detector_Readout");
141 sidObjs.push_back(stream_sid_obj);
142 source_id_objs.push_back(sidObjs.back().get());
146 sidObjs.push_back(std::make_shared<conffwk::ConfigObject>(tp_sid->config_object()));
147 source_id_objs.push_back(sidObjs.back().get());
157 sidNetObj.
set_objs(
"source_ids", source_id_objs);
165 std::vector<std::shared_ptr<conffwk::ConfigObject>> sidObjs)
167 sidNetObj.
set_obj(
"netconn", netConn);
169 std::vector<const conffwk::ConfigObject*> source_id_objs;
170 std::vector<uint32_t> app_source_ids;
182 app_source_ids.push_back(fdpc->get_source_id());
185 for (
auto& source_id : app_source_ids) {
186 std::string streamSidUid(fdapp->
UID() +
"SourceIDConf" + std::to_string(source_id));
187 auto stream_sid_obj = std::make_shared<conffwk::ConfigObject>(obj_fac.
create(
"SourceIDConf", streamSidUid));
188 stream_sid_obj->set_by_val<uint32_t>(
"sid", source_id);
189 stream_sid_obj->set_by_val<std::string>(
"subsystem",
"Detector_Readout");
190 sidObjs.push_back(stream_sid_obj);
191 source_id_objs.push_back(sidObjs.back().get());
194 sidNetObj.
set_objs(
"source_ids", source_id_objs);
203 std::vector<const confmodel::DaqModule*> modules;
207 std::vector<const conffwk::ConfigObject*> trbOutputObjs;
208 std::vector<const conffwk::ConfigObject*> trbSidNetObjs;
215 auto destination_class = rule->get_destination_class();
216 if (destination_class ==
"DataWriterModule") {
217 trQDesc = rule->get_descriptor();
220 if (trQDesc ==
nullptr) {
221 throw(BadConf(
ERS_HERE,
"Could not find queue descriptor rule for TriggerRecords!"));
227 trbOutputObjs.push_back(&trQueueObj);
234 auto descriptor = rule->get_descriptor();
235 auto data_type = descriptor->get_data_type();
236 if (data_type ==
"Fragment") {
237 fragNetDesc = rule->get_descriptor();
238 }
else if (data_type ==
"TriggerDecision") {
239 trigdecNetDesc = rule->get_descriptor();
240 }
else if (data_type ==
"TriggerDecisionToken") {
241 tokenNetDesc = rule->get_descriptor();
244 if (fragNetDesc ==
nullptr) {
245 throw(BadConf(
ERS_HERE,
"Could not find network descriptor rule for input Fragments!"));
247 if (trigdecNetDesc ==
nullptr) {
248 throw(BadConf(
ERS_HERE,
"Could not find network descriptor rule for input TriggerDecisions!"));
250 if (tokenNetDesc ==
nullptr) {
251 throw(BadConf(
ERS_HERE,
"Could not find network descriptor rule for output TriggerDecisionTokens!"));
254 throw(BadConf(
ERS_HERE,
"Could not retrieve SourceIDConf"));
263 auto sessionApps =
session->get_enabled_applications();
264 std::vector<conffwk::ConfigObject> dreqNetObjs;
265 std::vector<conffwk::ConfigObject> sidNetObjs;
266 std::vector<std::shared_ptr<conffwk::ConfigObject>> sidObjs;
267 for (
auto app : sessionApps) {
274 if (smartapp ==
nullptr || dfapp !=
nullptr) {
280 && src_id_check ==
nullptr
282 && ctbapp ==
nullptr) {
286 auto roQRules = smartapp->get_network_rules();
287 for (
auto rule : roQRules) {
288 auto descriptor = rule->get_descriptor();
289 auto data_type = descriptor->get_data_type();
290 if (data_type ==
"DataRequest") {
291 if (rapp !=
nullptr) {
297 auto sources = ctbapp->get_sources();
298 for (
const auto & s : sources ) {
299 std::string dreqNetUid(descriptor->get_uid_base() + smartapp->UID()+
'_' + s.first);
300 dreqNetObjs.emplace_back( obj_fac.
create_net_obj(descriptor, dreqNetUid) );
302 std::string sidToNetUid(descriptor->get_uid_base() + smartapp->UID() +
"_" + s.first);
303 sidNetObjs.emplace_back( obj_fac.
create(
"SourceIDToNetworkConnection", sidToNetUid ) );
304 sidNetObjs.back().set_obj(
"netconn", & dreqNetObjs.back());
305 sidNetObjs.back().set_objs(
"source_ids", { & s.second->config_object() });
309 dreqNetObjs.emplace_back(obj_fac.
create_net_obj(descriptor, smartapp->UID()));
311 std::string sidToNetUid(descriptor->get_uid_base() + smartapp->UID() +
"-sids");
312 sidNetObjs.emplace_back(
313 obj_fac.
create(
"SourceIDToNetworkConnection", sidToNetUid));
314 if (roapp !=
nullptr) {
316 }
else if (fdapp !=
nullptr) {
327 for (
auto& obj : dreqNetObjs) {
328 trbOutputObjs.push_back(&obj);
330 for (
auto& obj : sidNetObjs) {
331 trbSidNetObjs.push_back(&obj);
339 if (trbConf ==
nullptr) {
340 throw(BadConf(
ERS_HERE,
"No DataWriterModule or TRB configuration given"));
342 auto trbConfObj = trbConf->config_object();
345 std::string trbUid(
UID() +
"-trb");
347 trbObj.
set_obj(
"configuration", &trbConfObj);
348 trbObj.
set_objs(
"inputs", { &trigdecNetObj, &fragNetObj });
349 trbObj.
set_objs(
"outputs", trbOutputObjs);
350 trbObj.
set_objs(
"request_connections", trbSidNetObjs);
356 if (dwrConfs.size() == 0) {
357 throw(BadConf(
ERS_HERE,
"No DataWriterModule or TRB configuration given"));
360 for (
auto dwrConf : dwrConfs) {
363 auto dwrConfObj = dwrConf->config_object();
366 std::string dwrUid(fmt::format(
"{}-dw-{}",
UID(), dw_idx));
368 dwrObj.
set_by_val(
"writer_identifier", fmt::format(
"{}_dw_{}",
UID(), dw_idx));
369 dwrObj.
set_obj(
"configuration", &dwrConfObj);
370 dwrObj.
set_objs(
"inputs", { &trQueueObj });
371 dwrObj.
set_objs(
"outputs", { &tokenNetObj });