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->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;
177 app_source_ids.push_back(fdpc->get_source_id());
180 for (
auto& source_id : app_source_ids) {
181 std::string streamSidUid(fdapp->
UID() +
"SourceIDConf" + std::to_string(source_id));
182 auto stream_sid_obj = std::make_shared<conffwk::ConfigObject>(obj_fac.
create(
"SourceIDConf", streamSidUid));
183 stream_sid_obj->set_by_val<uint32_t>(
"sid", source_id);
184 stream_sid_obj->set_by_val<std::string>(
"subsystem",
"Detector_Readout");
185 sidObjs.push_back(stream_sid_obj);
186 source_id_objs.push_back(sidObjs.back().get());
189 sidNetObj.
set_objs(
"source_ids", source_id_objs);
198 std::vector<const confmodel::DaqModule*> modules;
202 std::vector<const conffwk::ConfigObject*> trbInputObjs;
203 std::vector<const conffwk::ConfigObject*> trbOutputObjs;
204 std::vector<const conffwk::ConfigObject*> trbSidNetObjs;
211 auto destination_class = rule->get_destination_class();
212 if (destination_class ==
"DataWriterModule") {
213 trQDesc = rule->get_descriptor();
216 if (trQDesc ==
nullptr) {
217 throw(BadConf(
ERS_HERE,
"Could not find queue descriptor rule for TriggerRecords!"));
223 trbOutputObjs.push_back(&trQueueObj);
232 auto descriptor = rule->get_descriptor();
233 auto data_type = descriptor->get_data_type();
234 if (data_type ==
"Fragment") {
235 fragNetDesc = rule->get_descriptor();
236 }
else if (data_type ==
"TriggerDecision") {
237 trigdecNetDesc = rule->get_descriptor();
238 }
else if (data_type ==
"TriggerDecisionToken") {
239 tokenNetDesc = rule->get_descriptor();
240 }
else if (data_type ==
"TRMonRequest") {
241 trmonReqNetDesc = rule->get_descriptor();
242 }
else if (data_type ==
"TriggerRecord") {
243 trmonTRNetDesc = rule->get_descriptor();
246 if (fragNetDesc ==
nullptr) {
247 throw(BadConf(
ERS_HERE,
"Could not find network descriptor rule for input Fragments!"));
249 if (trigdecNetDesc ==
nullptr) {
250 throw(BadConf(
ERS_HERE,
"Could not find network descriptor rule for input TriggerDecisions!"));
252 if (tokenNetDesc ==
nullptr) {
253 throw(BadConf(
ERS_HERE,
"Could not find network descriptor rule for output TriggerDecisionTokens!"));
256 throw(BadConf(
ERS_HERE,
"Could not retrieve SourceIDConf"));
264 if (trmonReqNetDesc !=
nullptr) {
267 if (trmonTRNetDesc !=
nullptr) {
273 auto sessionApps =
session->enabled_applications();
274 std::vector<conffwk::ConfigObject> dreqNetObjs;
275 std::vector<conffwk::ConfigObject> sidNetObjs;
276 std::vector<std::shared_ptr<conffwk::ConfigObject>> sidObjs;
277 for (
auto app : sessionApps) {
284 if (smartapp ==
nullptr || dfapp !=
nullptr) {
290 && src_id_check ==
nullptr
292 && ctbapp ==
nullptr) {
296 auto roQRules = smartapp->get_network_rules();
297 for (
auto rule : roQRules) {
298 auto descriptor = rule->get_descriptor();
299 auto data_type = descriptor->get_data_type();
300 if (data_type ==
"DataRequest") {
301 if (rapp !=
nullptr) {
307 auto sources = ctbapp->get_sources();
308 for (
const auto & s : sources ) {
309 std::string dreqNetUid(descriptor->get_uid_base() + smartapp->UID()+
'_' + s.first);
310 dreqNetObjs.emplace_back( obj_fac.
create_net_obj(descriptor, dreqNetUid) );
312 std::string sidToNetUid(descriptor->get_uid_base() + smartapp->UID() +
"_" + s.first);
313 sidNetObjs.emplace_back( obj_fac.
create(
"SourceIDToNetworkConnection", sidToNetUid ) );
314 sidNetObjs.back().set_obj(
"netconn", & dreqNetObjs.back());
315 sidNetObjs.back().set_objs(
"source_ids", { & s.second->config_object() });
319 dreqNetObjs.emplace_back(obj_fac.
create_net_obj(descriptor, smartapp->UID()));
321 std::string sidToNetUid(descriptor->get_uid_base() + smartapp->UID() +
"-sids");
322 sidNetObjs.emplace_back(
323 obj_fac.
create(
"SourceIDToNetworkConnection", sidToNetUid));
324 if (roapp !=
nullptr) {
326 }
else if (fdapp !=
nullptr) {
337 for (
auto&
obj : dreqNetObjs) {
338 trbOutputObjs.push_back(&
obj);
340 for (
auto&
obj : sidNetObjs) {
341 trbSidNetObjs.push_back(&
obj);
349 if (trbConf ==
nullptr) {
350 throw(BadConf(
ERS_HERE,
"No DataWriterModule or TRB configuration given"));
352 auto trbConfObj = trbConf->config_object();
354 trbInputObjs = { &trigdecNetObj, &fragNetObj };
355 if (trmonReqNetDesc !=
nullptr) {
356 trbInputObjs.push_back(&trmonReqNetObj);
358 if (trmonTRNetDesc !=
nullptr) {
359 trbOutputObjs.push_back(&trmonTRNetObj);
362 std::string trbUid(
UID() +
"-trb");
364 trbObj.
set_obj(
"configuration", &trbConfObj);
365 trbObj.
set_objs(
"inputs", trbInputObjs);
366 trbObj.
set_objs(
"outputs", trbOutputObjs);
367 trbObj.
set_obj(
"trigger_record_output", &trQueueObj);
368 trbObj.
set_objs(
"request_connections", trbSidNetObjs);
374 if (dwrConfs.size() == 0) {
375 throw(BadConf(
ERS_HERE,
"No DataWriterModule or TRB configuration given"));
378 for (
auto dwrConf : dwrConfs) {
381 auto dwrConfObj = dwrConf->config_object();
384 std::string dwrUid(fmt::format(
"{}-dw-{}",
UID(), dw_idx));
386 dwrObj.
set_by_val(
"writer_identifier", fmt::format(
"{}_dw_{}",
UID(), dw_idx));
387 dwrObj.
set_obj(
"configuration", &dwrConfObj);
388 dwrObj.
set_objs(
"inputs", { &trQueueObj });
389 dwrObj.
set_objs(
"outputs", { &tokenNetObj });