80 TLOG_DEBUG(6) <<
"Generating modules for application " << this->
UID();
91 if (reader_conf == 0) {
92 throw(BadConf(
ERS_HERE,
"No DataReaderModule configuration given"));
94 std::string reader_class = reader_conf->get_template_for();
99 auto dlh_class = dlh_conf->get_template_for();
103 throw(BadConf(
ERS_HERE,
"TP generation is enabled but there is no TP data handler configuration"));
106 std::string tph_class =
"";
108 tph_class = tph_conf->get_template_for();
121 auto destination_class = rule->get_destination_class();
122 auto data_type = rule->get_descriptor()->get_data_type();
124 if (destination_class ==
"DataHandlerModule" || destination_class == dlh_class || destination_class == tph_class) {
125 if (data_type ==
"DataRequest") {
126 dlh_reqinput_qdesc = rule->get_descriptor();
128 tp_input_qdesc = rule->get_descriptor();
130 dlh_input_qdesc = rule->get_descriptor();
132 }
else if (destination_class ==
"FragmentAggregatorModule") {
133 fa_output_qdesc = rule->get_descriptor();
145 auto endpoint_class = rule->get_endpoint_class();
146 auto data_type = rule->get_descriptor()->get_data_type();
148 if (endpoint_class ==
"FragmentAggregatorModule") {
149 fa_net_desc = rule->get_descriptor();
150 }
else if (data_type ==
"TPSet") {
151 tp_net_desc = rule->get_descriptor();
152 }
else if (data_type ==
"TriggerActivity") {
153 ta_net_desc = rule->get_descriptor();
154 }
else if (data_type ==
"TimeSync") {
155 ts_net_desc = rule->get_descriptor();
161 if (fa_output_qdesc ==
nullptr) {
162 throw(BadConf(
ERS_HERE,
"No fragment output queue descriptor given"));
164 std::vector<const confmodel::Connection*> req_queues;
171 std::vector<const confmodel::DaqModule*> modules;
177 std::vector<const confmodel::DetectorStream*> all_enabled_det_streams;
178 std::map<uint32_t, const confmodel::Connection*> data_queues_by_sid;
181 uint16_t conn_idx = 0;
184 if (d2d_conn->is_disabled(*
session)) {
185 TLOG_DEBUG(7) <<
"Ignoring disabled DetectorToDaqConnection " << d2d_conn->UID();
189 TLOG_DEBUG(6) <<
"Processing DetectorToDaqConnection " << d2d_conn->UID();
193 if (d2d_conn->senders().empty()) {
194 throw(BadConf(
ERS_HERE,
"DetectorToDaqConnection does not contain senders"));
196 if (d2d_conn->receiver() ==
nullptr) {
197 throw(BadConf(
ERS_HERE,
"DetectorToDaqConnection does not contain a receiver"));
201 auto det_senders = d2d_conn->senders();
202 auto det_receiver = d2d_conn->receiver();
204 std::vector<const confmodel::DetectorStream*> enabled_det_streams;
206 for (
auto stream : d2d_conn->streams()) {
209 if (stream->is_disabled(*
session)) {
210 TLOG_DEBUG(7) <<
"Ignoring disabled DetectorStream " << stream->UID();
214 all_enabled_det_streams.push_back(stream);
215 enabled_det_streams.push_back(stream);
221 if (reader_class ==
"DPDKReaderModule" || reader_class ==
"SocketReaderModule") {
222 if (!d2d_conn->castable(
"NetworkDetectorToDaqConnection")) {
223 throw(BadConf(
ERS_HERE, fmt::format(
"{} requires NetworkDetectorToDaqConnection, found {} of class {}", reader_class, d2d_conn->UID(), d2d_conn->class_name())));
227 throw(BadConf(
ERS_HERE, fmt::format(
"{} requires NWDetDataReceiver, found {} of class {}", reader_class, det_receiver->UID(), det_receiver->class_name())));
230 else if (reader_class ==
"FelixReaderModule") {
231 if (!d2d_conn->castable(
"FelixDetectorToDaqConnection")) {
232 throw(BadConf(
ERS_HERE, fmt::format(
"{} requires FelixDetectorToDaqConnection, found {} of class {}", reader_class, d2d_conn->UID(), d2d_conn->class_name())));
235 throw(BadConf(
ERS_HERE, fmt::format(
"FelixReaderModule requires FelixDataReceiver, found {} of class {}", det_receiver->UID(), det_receiver->class_name())));
251 std::string reader_uid(fmt::format(
"datareader-{}-{}", this->
UID(), std::to_string(conn_idx++)));
252 TLOG_DEBUG(6) << fmt::format(
"creating OKS configuration object for Data reader class {} with id {}", reader_class, reader_uid);
253 auto reader_obj = obj_fac.
create(reader_class, reader_uid);
256 reader_obj.
set_obj(
"configuration", &reader_conf->config_object());
257 reader_obj.set_objs(
"connections", {&d2d_conn->config_object()});
260 std::vector<const conffwk::ConfigObject*> data_queue_objs;
264 for (
auto ds : enabled_det_streams) {
267 data_queue_objs.push_back(&data_queue->config_object());
268 data_queues_by_sid[ds->get_source_id()] = data_queue;
271 reader_obj.set_objs(
"outputs", data_queue_objs);
282 std::vector<const confmodel::Connection*> tp_queues;
286 auto tph_conf_obj = tph_conf->config_object();
289 for (
auto sid : tpsrc_ids) {
292 std::string tp_uid(
"tphandler-" + std::to_string(sid->get_sid()));
293 auto tph_obj = obj_fac.
create(tph_class, tp_uid);
294 tph_obj.
set_by_val<uint32_t>(
"source_id", sid->get_sid());
295 tph_obj.set_by_val<uint32_t>(
"detector_id", 1);
297 tph_obj.set_obj(
"module_configuration", &tph_conf_obj);
301 tp_queue_obj.
set_by_val<uint32_t>(
"recv_timeout_ms", 50);
302 tp_queue_obj.
set_by_val<uint32_t>(
"send_timeout_ms", 1);
316 tph_obj.
set_objs(
"inputs", { &tp_queue_obj, &tpreq_queue_obj });
317 tph_obj.set_objs(
"outputs", { &tp_net_obj, &ta_net_obj, &frag_queue_obj });
323 std::vector<const conffwk::ConfigObject*> tp_queue_objs;
324 for (
auto q : tp_queues) {
325 tp_queue_objs.push_back(&q->config_object());
333 auto emulation_mode = reader_conf->get_emulation_mode();
334 for (
auto ds : all_enabled_det_streams) {
336 uint32_t sid = ds->get_source_id();
337 TLOG_DEBUG(6) << fmt::format(
"Processing stream {}, id {}, det id {}", ds->UID(), ds->get_source_id(), ds->get_geo_id()->get_detector_id());
338 std::string uid(fmt::format(
"DLH-{}", sid));
339 TLOG_DEBUG(6) << fmt::format(
"creating OKS configuration object for Data Link Handler class {}, if {}", dlh_class, sid);
340 auto dlh_obj = obj_fac.
create(dlh_class, uid);
341 dlh_obj.
set_by_val<uint32_t>(
"source_id", sid);
342 dlh_obj.set_by_val<uint32_t>(
"detector_id", ds->get_geo_id()->get_detector_id());
344 dlh_obj.set_by_val<
bool>(
"emulation_mode", emulation_mode);
345 dlh_obj.set_obj(
"geo_id", &ds->get_geo_id()->config_object());
346 dlh_obj.set_obj(
"module_configuration", &dlh_conf->config_object());
348 std::vector<const conffwk::ConfigObject*> dlh_ins, dlh_outs;
351 dlh_ins.push_back(&data_queues_by_sid.at(sid)->config_object());
359 dlh_ins.push_back(&req_queue_obj);
360 dlh_outs.push_back(&frag_queue_obj);
364 if (dlh_conf->get_generate_timesync()) {
367 dlh_outs.push_back(&ts_net_obj);
370 for (
auto tpq : tp_queue_objs) {
371 dlh_outs.push_back(tpq);
373 dlh_obj.
set_objs(
"inputs", dlh_ins);
374 dlh_obj.set_objs(
"outputs", dlh_outs);
381 std::string faUid(
"fragmentaggregator-" +
UID());
383 TLOG_DEBUG(7) <<
"creating OKS configuration object for Fragment Aggregator class ";
384 auto frag_aggr = obj_fac.
create(
"FragmentAggregatorModule", faUid);
389 auto sessionApps =
session->enabled_applications();
390 std::vector<conffwk::ConfigObject> fragOutObjs;
391 for (
auto app : sessionApps) {
393 if (dfapp ==
nullptr)
397 for (
auto rule : dfNRules) {
398 auto descriptor = rule->get_descriptor();
399 auto data_type = descriptor->get_data_type();
400 if (data_type ==
"Fragment") {
401 std::string dreqNetUid(descriptor->get_uid_base() + dfapp->UID());
404 auto frag_conn = obj_fac.
create(
"NetworkConnection", dreqNetUid);
406 frag_conn.
set_by_val<std::string>(
"data_type", descriptor->get_data_type());
409 frag_conn.set_by_val<
int>(
"capacity", all_enabled_det_streams.size() * 2);
410 frag_conn.set_by_val<std::string>(
"connection_type", descriptor->get_connection_type());
412 auto serviceObj = descriptor->get_associated_service()->config_object();
413 frag_conn.set_obj(
"associated_service", &serviceObj);
414 fragOutObjs.push_back(frag_conn);
420 std::vector<const conffwk::ConfigObject*> fa_output_objs;
421 for (
auto& fNet : fragOutObjs) {
422 fa_output_objs.push_back(&fNet);
425 for (
auto& q : req_queues) {
426 fa_output_objs.push_back(&q->config_object());
429 frag_aggr.set_objs(
"inputs", { &fa_net_obj, &frag_queue_obj });
430 frag_aggr.set_objs(
"outputs", fa_output_objs);