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*> trbOutputObjs;
203 std::vector<const conffwk::ConfigObject*> trbSidNetObjs;
210 auto destination_class = rule->get_destination_class();
211 if (destination_class ==
"DataWriterModule") {
212 trQDesc = rule->get_descriptor();
215 if (trQDesc ==
nullptr) {
216 throw(BadConf(
ERS_HERE,
"Could not find queue descriptor rule for TriggerRecords!"));
222 trbOutputObjs.push_back(&trQueueObj);
229 auto descriptor = rule->get_descriptor();
230 auto data_type = descriptor->get_data_type();
231 if (data_type ==
"Fragment") {
232 fragNetDesc = rule->get_descriptor();
233 }
else if (data_type ==
"TriggerDecision") {
234 trigdecNetDesc = rule->get_descriptor();
235 }
else if (data_type ==
"TriggerDecisionToken") {
236 tokenNetDesc = rule->get_descriptor();
239 if (fragNetDesc ==
nullptr) {
240 throw(BadConf(
ERS_HERE,
"Could not find network descriptor rule for input Fragments!"));
242 if (trigdecNetDesc ==
nullptr) {
243 throw(BadConf(
ERS_HERE,
"Could not find network descriptor rule for input TriggerDecisions!"));
245 if (tokenNetDesc ==
nullptr) {
246 throw(BadConf(
ERS_HERE,
"Could not find network descriptor rule for output TriggerDecisionTokens!"));
249 throw(BadConf(
ERS_HERE,
"Could not retrieve SourceIDConf"));
258 auto sessionApps =
session->enabled_applications();
259 std::vector<conffwk::ConfigObject> dreqNetObjs;
260 std::vector<conffwk::ConfigObject> sidNetObjs;
261 std::vector<std::shared_ptr<conffwk::ConfigObject>> sidObjs;
262 for (
auto app : sessionApps) {
269 if (smartapp ==
nullptr || dfapp !=
nullptr) {
275 && src_id_check ==
nullptr
277 && ctbapp ==
nullptr) {
281 auto roQRules = smartapp->get_network_rules();
282 for (
auto rule : roQRules) {
283 auto descriptor = rule->get_descriptor();
284 auto data_type = descriptor->get_data_type();
285 if (data_type ==
"DataRequest") {
286 if (rapp !=
nullptr) {
292 auto sources = ctbapp->get_sources();
293 for (
const auto & s : sources ) {
294 std::string dreqNetUid(descriptor->get_uid_base() + smartapp->UID()+
'_' + s.first);
295 dreqNetObjs.emplace_back( obj_fac.
create_net_obj(descriptor, dreqNetUid) );
297 std::string sidToNetUid(descriptor->get_uid_base() + smartapp->UID() +
"_" + s.first);
298 sidNetObjs.emplace_back( obj_fac.
create(
"SourceIDToNetworkConnection", sidToNetUid ) );
299 sidNetObjs.back().set_obj(
"netconn", & dreqNetObjs.back());
300 sidNetObjs.back().set_objs(
"source_ids", { & s.second->config_object() });
304 dreqNetObjs.emplace_back(obj_fac.
create_net_obj(descriptor, smartapp->UID()));
306 std::string sidToNetUid(descriptor->get_uid_base() + smartapp->UID() +
"-sids");
307 sidNetObjs.emplace_back(
308 obj_fac.
create(
"SourceIDToNetworkConnection", sidToNetUid));
309 if (roapp !=
nullptr) {
311 }
else if (fdapp !=
nullptr) {
322 for (
auto&
obj : dreqNetObjs) {
323 trbOutputObjs.push_back(&
obj);
325 for (
auto&
obj : sidNetObjs) {
326 trbSidNetObjs.push_back(&
obj);
334 if (trbConf ==
nullptr) {
335 throw(BadConf(
ERS_HERE,
"No DataWriterModule or TRB configuration given"));
337 auto trbConfObj = trbConf->config_object();
340 std::string trbUid(
UID() +
"-trb");
342 trbObj.
set_obj(
"configuration", &trbConfObj);
343 trbObj.
set_objs(
"inputs", { &trigdecNetObj, &fragNetObj });
344 trbObj.
set_objs(
"outputs", trbOutputObjs);
345 trbObj.
set_objs(
"request_connections", trbSidNetObjs);
351 if (dwrConfs.size() == 0) {
352 throw(BadConf(
ERS_HERE,
"No DataWriterModule or TRB configuration given"));
355 for (
auto dwrConf : dwrConfs) {
358 auto dwrConfObj = dwrConf->config_object();
361 std::string dwrUid(fmt::format(
"{}-dw-{}",
UID(), dw_idx));
363 dwrObj.
set_by_val(
"writer_identifier", fmt::format(
"{}_dw_{}",
UID(), dw_idx));
364 dwrObj.
set_obj(
"configuration", &dwrConfObj);
365 dwrObj.
set_objs(
"inputs", { &trQueueObj });
366 dwrObj.
set_objs(
"outputs", { &tokenNetObj });