74 TLOG_DEBUG(6) <<
"Generating modules for application " << this->
UID();
85 if (reader_conf == 0) {
86 throw(BadConf(
ERS_HERE,
"No DataReaderModule configuration given"));
88 std::string reader_class = reader_conf->get_template_for();
93 auto dlh_class = dlh_conf->get_template_for();
97 throw(BadConf(
ERS_HERE,
"TP generation is enabled but there is no TP data handler configuration"));
100 std::string tph_class =
"";
102 tph_class = tph_conf->get_template_for();
115 auto destination_class = rule->get_destination_class();
116 auto data_type = rule->get_descriptor()->get_data_type();
118 if (destination_class ==
"DataHandlerModule" || destination_class == dlh_class || destination_class == tph_class) {
119 if (data_type ==
"DataRequest") {
120 dlh_reqinput_qdesc = rule->get_descriptor();
122 tp_input_qdesc = rule->get_descriptor();
124 dlh_input_qdesc = rule->get_descriptor();
126 }
else if (destination_class ==
"FragmentAggregatorModule") {
127 fa_output_qdesc = rule->get_descriptor();
139 auto endpoint_class = rule->get_endpoint_class();
140 auto data_type = rule->get_descriptor()->get_data_type();
142 if (endpoint_class ==
"FragmentAggregatorModule") {
143 fa_net_desc = rule->get_descriptor();
144 }
else if (data_type ==
"TPSet") {
145 tp_net_desc = rule->get_descriptor();
146 }
else if (data_type ==
"TriggerActivity") {
147 ta_net_desc = rule->get_descriptor();
148 }
else if (data_type ==
"TimeSync") {
149 ts_net_desc = rule->get_descriptor();
155 if (fa_output_qdesc ==
nullptr) {
156 throw(BadConf(
ERS_HERE,
"No fragment output queue descriptor given"));
158 std::vector<const confmodel::Connection*> req_queues;
165 std::vector<const confmodel::DaqModule*> modules;
171 std::vector<const confmodel::DetectorStream*> all_enabled_det_streams;
172 std::map<uint32_t, const confmodel::Connection*> data_queues_by_sid;
175 uint16_t conn_idx = 0;
180 if (d2d_conn_res->disabled(*
session)) {
181 TLOG_DEBUG(7) <<
"Ignoring disabled DetectorToDaqConnection " << d2d_conn_res->UID();
187 TLOG_DEBUG(6) <<
"Processing DetectorToDaqConnection " << d2d_conn_res->UID();
192 throw(BadConf(
ERS_HERE,
"ReadoutApplication contains something other than DetectorToDaqConnection"));
195 if (d2d_conn->get_contains().empty()) {
196 throw(BadConf(
ERS_HERE,
"DetectorToDaqConnection does not contain sebders or receivers"));
201 auto det_receiver = d2d_conn->get_receiver();
203 std::vector<const confmodel::DetectorStream*> enabled_det_streams;
205 for (
auto stream : d2d_conn->get_streams()) {
208 if (stream->disabled(*
session)) {
209 TLOG_DEBUG(7) <<
"Ignoring disabled DetectorStream " << stream->UID();
214 all_enabled_det_streams.push_back(stream);
215 enabled_det_streams.push_back(stream);
222 if (reader_class ==
"DPDKReaderModule" || reader_class ==
"SocketReaderModule") {
225 throw(BadConf(
ERS_HERE, fmt::format(
"{} requires NWDetDataReceiver, found {} of class {}", reader_class, det_receiver->UID(), det_receiver->class_name())));
228 bool all_nw_senders =
true;
229 for (
auto s : det_senders) {
234 if (!all_nw_senders) {
235 throw(BadConf(
ERS_HERE,
"Non-network DetDataSener found with NWreceiver"));
238 else if (reader_class ==
"FelixReaderModule") {
240 throw(BadConf(
ERS_HERE, fmt::format(
"FelixReaderModule requires FelixDataReceiver, found {} of class {}", det_receiver->UID(), det_receiver->class_name())));
243 bool all_flx_senders =
true;
244 for (
auto s : det_senders) {
249 if (!all_flx_senders) {
250 throw(BadConf(
ERS_HERE,
"Non-felix DetDataSener found with FelixDataReceiver"));
266 std::string reader_uid(fmt::format(
"datareader-{}-{}", this->
UID(), std::to_string(conn_idx++)));
267 TLOG_DEBUG(6) << fmt::format(
"creating OKS configuration object for Data reader class {} with id {}", reader_class, reader_uid);
268 auto reader_obj = obj_fac.
create(reader_class, reader_uid);
271 reader_obj.
set_obj(
"configuration", &reader_conf->config_object());
272 reader_obj.set_objs(
"connections", {&d2d_conn_res->config_object()});
275 std::vector<const conffwk::ConfigObject*> data_queue_objs;
279 for (
auto ds : enabled_det_streams) {
282 data_queue_objs.push_back(&data_queue->config_object());
283 data_queues_by_sid[ds->get_source_id()] = data_queue;
286 reader_obj.set_objs(
"outputs", data_queue_objs);
297 std::vector<const confmodel::Connection*> tp_queues;
301 auto tph_conf_obj = tph_conf->config_object();
304 for (
auto sid : tpsrc_ids) {
307 std::string tp_uid(
"tphandler-" + std::to_string(sid->get_sid()));
308 auto tph_obj = obj_fac.
create(tph_class, tp_uid);
309 tph_obj.
set_by_val<uint32_t>(
"source_id", sid->get_sid());
310 tph_obj.set_by_val<uint32_t>(
"detector_id", 1);
312 tph_obj.set_obj(
"module_configuration", &tph_conf_obj);
316 tp_queue_obj.
set_by_val<uint32_t>(
"recv_timeout_ms", 50);
317 tp_queue_obj.
set_by_val<uint32_t>(
"send_timeout_ms", 1);
331 tph_obj.
set_objs(
"inputs", { &tp_queue_obj, &tpreq_queue_obj });
332 tph_obj.set_objs(
"outputs", { &tp_net_obj, &ta_net_obj, &frag_queue_obj });
338 std::vector<const conffwk::ConfigObject*> tp_queue_objs;
339 for (
auto q : tp_queues) {
340 tp_queue_objs.push_back(&q->config_object());
348 auto emulation_mode = reader_conf->get_emulation_mode();
349 for (
auto ds : all_enabled_det_streams) {
351 uint32_t sid = ds->get_source_id();
352 TLOG_DEBUG(6) << fmt::format(
"Processing stream {}, id {}, det id {}", ds->UID(), ds->get_source_id(), ds->get_geo_id()->get_detector_id());
353 std::string uid(fmt::format(
"DLH-{}", sid));
354 TLOG_DEBUG(6) << fmt::format(
"creating OKS configuration object for Data Link Handler class {}, if {}", dlh_class, sid);
355 auto dlh_obj = obj_fac.
create(dlh_class, uid);
356 dlh_obj.
set_by_val<uint32_t>(
"source_id", sid);
357 dlh_obj.set_by_val<uint32_t>(
"detector_id", ds->get_geo_id()->get_detector_id());
359 dlh_obj.set_by_val<
bool>(
"emulation_mode", emulation_mode);
360 dlh_obj.set_obj(
"geo_id", &ds->get_geo_id()->config_object());
361 dlh_obj.set_obj(
"module_configuration", &dlh_conf->config_object());
363 std::vector<const conffwk::ConfigObject*> dlh_ins, dlh_outs;
366 dlh_ins.push_back(&data_queues_by_sid.at(sid)->config_object());
374 dlh_ins.push_back(&req_queue_obj);
375 dlh_outs.push_back(&frag_queue_obj);
379 if (dlh_conf->get_generate_timesync()) {
382 dlh_outs.push_back(&ts_net_obj);
385 for (
auto tpq : tp_queue_objs) {
386 dlh_outs.push_back(tpq);
388 dlh_obj.
set_objs(
"inputs", dlh_ins);
389 dlh_obj.set_objs(
"outputs", dlh_outs);
396 std::string faUid(
"fragmentaggregator-" +
UID());
398 TLOG_DEBUG(7) <<
"creating OKS configuration object for Fragment Aggregator class ";
399 auto frag_aggr = obj_fac.
create(
"FragmentAggregatorModule", faUid);
404 auto sessionApps =
session->get_enabled_applications();
405 std::vector<conffwk::ConfigObject> fragOutObjs;
406 for (
auto app : sessionApps) {
408 if (dfapp ==
nullptr)
412 for (
auto rule : dfNRules) {
413 auto descriptor = rule->get_descriptor();
414 auto data_type = descriptor->get_data_type();
415 if (data_type ==
"Fragment") {
416 std::string dreqNetUid(descriptor->get_uid_base() + dfapp->UID());
419 auto frag_conn = obj_fac.
create(
"NetworkConnection", dreqNetUid);
421 frag_conn.
set_by_val<std::string>(
"data_type", descriptor->get_data_type());
422 frag_conn.set_by_val<std::string>(
"connection_type", descriptor->get_connection_type());
424 auto serviceObj = descriptor->get_associated_service()->config_object();
425 frag_conn.set_obj(
"associated_service", &serviceObj);
426 fragOutObjs.push_back(frag_conn);
432 std::vector<const conffwk::ConfigObject*> fa_output_objs;
433 for (
auto& fNet : fragOutObjs) {
434 fa_output_objs.push_back(&fNet);
437 for (
auto& q : req_queues) {
438 fa_output_objs.push_back(&q->config_object());
441 frag_aggr.set_objs(
"inputs", { &fa_net_obj, &frag_queue_obj });
442 frag_aggr.set_objs(
"outputs", fa_output_objs);