19 """Simple script to create an OKS configuration file for a dataflow segment.
21 The file will automatically include the relevant schema files and
22 any other OKS files you specify.
26 "schema/confmodel/dunedaq.schema.xml",
27 "schema/appmodel/application.schema.xml",
30 res, extra_includes = find_oksincludes(include, os.path.dirname(oksfile))
32 includefiles += extra_includes
38 if not oksfile.endswith(
".data.xml"):
39 oksfile = oksfile +
".data.xml"
40 print(f
"Creating OKS database file {oksfile}")
41 db.create_db(oksfile, includefiles)
42 db.set_active(oksfile)
45 for vhost
in db.get_dals(class_name=
"VirtualHost"):
46 hosts.append(vhost.id)
47 if vhost.id ==
"vlocalhost":
49 if "vlocalhost" not in hosts:
50 cpus = dal.ProcessingResource(
"cpus", cpu_cores=[0, 1, 2, 3])
52 phdal = dal.PhysicalHost(
"localhost", contains=[cpus])
54 host = dal.VirtualHost(
"vlocalhost", runs_on=phdal, uses=[cpus])
56 hosts.append(
"vlocalhost")
59 daqapp_control = db.get_dal(class_name=
"Service", uid=
"daqapp_control")
60 rccontroller_control = db.get_dal(class_name=
"Service", uid=
"rccontroller_control")
63 tpw_source_id = db.get_dal(
"SourceIDConf", uid=
"srcid-tp-stream-writer")
66 trigger_record_q_rule = db.get_dal(
67 class_name=
"QueueConnectionRule", uid=
"trigger-record-q-rule"
69 dfapp_qrules = [trigger_record_q_rule]
72 frag_net_rule = db.get_dal(class_name=
"NetworkConnectionRule", uid=
"frag-net-rule")
73 df_token_net_rule = db.get_dal(
74 class_name=
"NetworkConnectionRule", uid=
"df-token-net-rule"
76 tpset_net_rule = db.get_dal(
77 class_name=
"NetworkConnectionRule", uid=
"tpset-net-rule"
79 ti_net_rule = db.get_dal(class_name=
"NetworkConnectionRule", uid=
"ti-net-rule")
80 td_dfo_net_rule = db.get_dal(
81 class_name=
"NetworkConnectionRule", uid=
"td-dfo-net-rule"
83 td_trb_net_rule = db.get_dal(
84 class_name=
"NetworkConnectionRule", uid=
"td-trb-net-rule"
86 data_req_trig_net_rule = db.get_dal(
87 class_name=
"NetworkConnectionRule", uid=
"data-req-trig-net-rule"
89 data_req_hsi_net_rule = db.get_dal(
90 class_name=
"NetworkConnectionRule", uid=
"data-req-hsi-net-rule"
92 data_req_readout_net_rule = db.get_dal(
93 class_name=
"NetworkConnectionRule", uid=
"data-req-readout-net-rule"
99 data_req_hsi_net_rule,
100 data_req_readout_net_rule,
101 data_req_trig_net_rule,
107 trmon_req_net_rule = db.get_dal(
108 class_name=
"NetworkConnectionRule", uid=
"trmon-req-net-rule"
110 trigger_record_net_rule = db.get_dal(
111 class_name=
"NetworkConnectionRule", uid=
"trigger-record-net-rule"
113 dfapp_netrules.append(trmon_req_net_rule)
114 dfapp_netrules.append(trigger_record_net_rule)
116 trmon_netrules.append(trigger_record_net_rule)
117 trigger_decision_token_q_rule = db.get_dal(
118 class_name=
"QueueConnectionRule", uid=
"trigger-decision-token-q-rule"
120 trmon_qrules.append(trigger_decision_token_q_rule)
122 dfo_netrules = [td_dfo_net_rule, ti_net_rule, df_token_net_rule]
123 tpw_netrules = [tpset_net_rule]
125 opmon_conf = db.get_dal(class_name=
"OpMonConf", uid=
"slow-all-monitoring")
127 dfo_conf = db.get_dal(class_name=
"DFOConf", uid=
"dfoconf-01")
128 dfo = dal.DFOApplication(
131 application_name=
"daq_application",
132 exposes_service=[daqapp_control],
133 network_rules=dfo_netrules,
134 opmon_conf=opmon_conf,
139 trb_conf = db.get_dal(class_name=
"TRBConf", uid=
"trb-01")
140 dw_conf = db.get_dal(class_name=
"DataWriterConf", uid=
"dw-01")
141 dfhw = db.get_dal(class_name=
"DFHWConf", uid=
"dfhw-01")
143 for dfapp_idx
in range(n_dfapps):
144 dfapp_id = dfapp_idx + 1
147 dfapp_source_id = dal.SourceIDConf(
148 f
"srcid-df-{dfapp_id:02}", sid=dfapp_id + 1, subsystem=
"TR_Builder"
150 db.update_dal(dfapp_source_id)
152 dfapp = dal.DFApplication(
155 application_name=
"daq_application",
156 exposes_service=[daqapp_control],
157 source_id=dfapp_source_id,
158 queue_rules=dfapp_qrules,
159 network_rules=dfapp_netrules,
160 opmon_conf=opmon_conf,
162 data_writers=[dw_conf] * n_data_writers,
169 if tpwriting_enabled:
170 tpw_writer_conf = db.get_dal(
171 class_name=
"TPStreamWriterConf", uid=
"tp-stream-writer-conf"
174 tpwapp = dal.TPStreamWriterApplication(
177 application_name=
"daq_application",
178 exposes_service=[daqapp_control],
179 source_id=tpw_source_id,
180 network_rules=tpw_netrules,
181 opmon_conf=opmon_conf,
182 tp_writer=tpw_writer_conf,
184 db.update_dal(tpwapp)
185 tpwapps.append(tpwapp)
189 trmonconf = db.get_dal(class_name=
"TRMonRequestorConf", uid=
"trmr-01")
190 trmondwconf = db.get_dal(class_name=
"DataWriterConf", uid=
"tr_mon_dw-01")
192 trmonapp = dal.TRMonReqApplication(
195 application_name=
"daq_application",
196 exposes_service=[daqapp_control],
197 network_rules=trmon_netrules,
198 queue_rules=trmon_qrules,
199 opmon_conf=opmon_conf,
201 data_writer=trmondwconf,
204 db.update_dal(trmonapp)
205 trmonapps.append(trmonapp)
208 fsm = db.get_dal(class_name=
"FSMconfiguration", uid=
"FSMconfiguration_noAction")
209 controller = dal.RCApplication(
211 application_name=
"drunc-controller",
214 opmon_conf=opmon_conf,
215 exposes_service=[rccontroller_control],
217 db.update_dal(controller)
221 controller=controller,
222 applications=[dfo] + dfapps + tpwapps + trmonapps,
228 except RuntimeError
as err:
229 print(
"Failed to commit Dataflow DB!")
230 print(traceback.format_exc())
240 """Simple script to create an OKS configuration file for a FakeHSI segment.
242 The file will automatically include the relevant schema files and
243 any other OKS files you specify.
249 "schema/confmodel/dunedaq.schema.xml",
250 "schema/appmodel/application.schema.xml",
251 "schema/appmodel/trigger.schema.xml",
254 res, extra_includes = find_oksincludes(include, os.path.dirname(oksfile))
256 includefiles += extra_includes
262 if not oksfile.endswith(
".data.xml"):
263 oksfile = oksfile +
".data.xml"
264 print(f
"Creating OKS database file {oksfile}")
265 db.create_db(oksfile, includefiles)
266 db.set_active(oksfile)
269 for vhost
in db.get_dals(class_name=
"VirtualHost"):
270 hosts.append(vhost.id)
271 if vhost.id ==
"vlocalhost":
273 if "vlocalhost" not in hosts:
274 cpus = dal.ProcessingResource(
"cpus", cpu_cores=[0, 1, 2, 3])
276 phdal = dal.PhysicalHost(
"localhost", contains=[cpus])
278 host = dal.VirtualHost(
"vlocalhost", runs_on=phdal, uses=[cpus])
280 hosts.append(
"vlocalhost")
283 daqapp_control = db.get_dal(class_name=
"Service", uid=
"daqapp_control")
284 rccontroller_control = db.get_dal(class_name=
"Service", uid=
"rccontroller_control")
285 dataRequests = db.get_dal(class_name=
"Service", uid=
"dataRequests")
286 hsievents = db.get_dal(class_name=
"Service", uid=
"HSIEvents")
289 hsi_source_id = db.get_dal(class_name=
"SourceIDConf", uid=
"hsi-srcid-01")
290 hsi_tc_source_id = db.get_dal(class_name=
"SourceIDConf", uid=
"hsi-tc-srcid-1")
293 hsi_dlh_queue_rule = db.get_dal(
294 class_name=
"QueueConnectionRule", uid=
"hsi-dlh-data-requests-queue-rule"
296 hsi_qrules = [hsi_dlh_queue_rule]
299 tc_net_rule = db.get_dal(class_name=
"NetworkConnectionRule", uid=
"tc-net-rule")
300 hsi_rule = db.get_dal(class_name=
"NetworkConnectionRule", uid=
"hsi-rule")
301 ts_hsi_net_rule = db.get_dal(
302 class_name=
"NetworkConnectionRule", uid=
"ts-hsi-net-rule"
304 data_req_hsi_net_rule = db.get_dal(
305 class_name=
"NetworkConnectionRule", uid=
"data-req-hsi-net-rule"
307 hsi_netrules = [hsi_rule, data_req_hsi_net_rule, ts_hsi_net_rule]
308 tc_netrules = [hsi_rule, tc_net_rule]
310 opmon_conf = db.get_dal(class_name=
"OpMonConf", uid=
"slow-all-monitoring")
311 hsi_handler = db.get_dal(class_name=
"DataHandlerConf", uid=
"def-hsi-handler")
312 fakehsi = db.get_dal(class_name=
"FakeHSIEventGeneratorConf", uid=
"fakehsi")
314 hsi = dal.FakeHSIApplication(
317 application_name=
"daq_application",
318 exposes_service=[daqapp_control],
319 source_id=hsi_source_id,
320 queue_rules=hsi_qrules,
321 network_rules=hsi_netrules,
322 opmon_conf=opmon_conf,
323 link_handler=hsi_handler,
328 hsi_to_tc_conf = db.get_dal(class_name=
"HSI2TCTranslatorConf", uid=
"hsi-to-tc-conf")
330 hsi_to_tc = dal.HSIEventToTCApplication(
333 application_name=
"daq_application",
334 exposes_service=[dataRequests, hsievents, daqapp_control],
335 source_id=hsi_tc_source_id,
336 network_rules=tc_netrules,
337 opmon_conf=opmon_conf,
338 hsevent_to_tc_conf=hsi_to_tc_conf,
340 db.update_dal(hsi_to_tc)
343 fsm = db.get_dal(class_name=
"FSMconfiguration", uid=
"FSMconfiguration_noAction")
344 controller = dal.RCApplication(
346 application_name=
"drunc-controller",
349 opmon_conf=opmon_conf,
350 exposes_service=[rccontroller_control],
352 db.update_dal(controller)
355 f
"hsi-segment", controller=controller, applications=[hsi, hsi_to_tc]
372 """Simple script to create an OKS configuration file for all
373 ReadoutApplications defined in a readout map.
375 The file will automatically include the relevant schema files and
376 any other OKS files you specify.
379 generate_readoutOKS -i hosts \
380 -i appmodel/connections.data.xml -i appmodel/moduleconfs \
381 config/np04readoutmap.data.xml readoutApps.data.xml
383 Will load hosts, connections and moduleconfs data files as well as
384 the readoutmap (config/np04readoutmap.data.xml) and write the
385 generated apps to readoutApps.data.xml.
387 generate_readoutOKS --session --segment \
388 -i appmodel/fsm -i hosts \
389 -i appmodel/connections.data.xml -i appmodel/moduleconfs \
390 config/np04readoutmap.data.xml np04readout-session.data.xml
392 Will do the same but in addition it will generate a containing
393 Segment for the apps and a containing Session for the Segment.
395 NB: Currently FSM generation is not implemented so you must include
396 an fsm file in order to generate a Segment
400 if not readoutmap.endswith(
".data.xml"):
401 readoutmap = readoutmap +
".data.xml"
403 print(f
"Readout map file {readoutmap}")
407 "schema/confmodel/dunedaq.schema.xml",
408 "schema/appmodel/application.schema.xml",
409 "schema/appmodel/trigger.schema.xml",
410 "schema/appmodel/fdmodules.schema.xml",
411 "schema/appmodel/wiec.schema.xml",
414 if os.path.exists(readoutmap)
418 searchdirs = [path
for path
in os.environ[
"DUNEDAQ_DB_PATH"].split(
":")]
419 searchdirs.append(os.path.dirname(oksfile))
423 inc = inc.removesuffix(
".xml")
424 if inc.endswith(
".data"):
425 sub_dirs = [
"config",
"data"]
426 elif inc.endswith(
".schema"):
427 sub_dirs = [
"schema"]
431 for path
in searchdirs:
433 matches = glob.glob(f
"{inc}.xml", root_dir=path)
434 if len(matches) == 0:
435 for search_dir
in sub_dirs:
437 matches = glob.glob(f
"{search_dir}/{inc}.xml", root_dir=path)
438 for filename
in matches:
439 if filename
not in includefiles:
440 print(f
"Adding {filename} to include list")
441 includefiles.append(filename)
443 print(f
"{filename} already in include list")
451 for filename
in matches:
452 if filename
not in includefiles:
453 print(f
"Adding {filename} to include list")
454 includefiles.append(filename)
456 print(f
"{filename} already in include list")
461 print(f
"Error could not find include file for {inc}")
466 if not oksfile.endswith(
".data.xml"):
467 oksfile = oksfile +
".data.xml"
468 print(f
"Creating OKS database file {oksfile}")
469 db.create_db(oksfile, includefiles)
470 db.set_active(oksfile)
472 detector_connections = db.get_dals(class_name=
"DetectorToDaqConnection")
473 daqapp_control = db.get_dal(class_name=
"Service", uid=
"daqapp_control")
474 rccontroller_control = db.get_dal(class_name=
"Service", uid=
"rccontroller_control")
478 class_name=
"NetworkConnectionRule", uid=
"data-req-readout-net-rule"
482 'Expected NetworkConnectionRule "data-req-readout-net-rule" not found in input databases!'
487 for rule
in [
"tpset-net-rule",
"ts-net-rule",
"ta-net-rule"]:
488 netrules.append(db.get_dal(class_name=
"NetworkConnectionRule", uid=rule))
492 class_name=
"QueueConnectionRule", uid=
"fd-dlh-data-requests-queue-rule"
496 'Expected QueueConnectionRule "fd-dlh-data-requests-queue-rule" not found in input databases!'
504 qrules.append(db.get_dal(class_name=
"QueueConnectionRule", uid=rule))
507 if len(hosts_to_use) == 0:
508 for vhost
in db.get_dals(class_name=
"VirtualHost"):
509 if vhost.id ==
"vlocalhost":
510 hosts.append(vhost.id)
511 if "vlocalhost" not in hosts:
512 cpus = dal.ProcessingResource(
"cpus", cpu_cores=[0, 1, 2, 3])
514 phdal = dal.PhysicalHost(
"localhost", contains=[cpus])
516 host = dal.VirtualHost(
"vlocalhost", runs_on=phdal, uses=[cpus])
518 hosts.append(
"vlocalhost")
520 for vhost
in db.get_dals(class_name=
"VirtualHost"):
521 if vhost.id
in hosts_to_use:
522 hosts.append(vhost.id)
523 assert len(hosts) > 0
525 rohw = dal.RoHwConfig(f
"rohw-{detector_connections[0].id}")
528 opmon_conf = db.get_dal(class_name=
"OpMonConf", uid=
"slow-all-monitoring")
529 fragagg = db.get_dal(class_name=
"FragmentAggregatorConf", uid=
"frag-agg-01")
537 for connection
in detector_connections:
539 geo_id = connection.get(
"GeoId")
540 det_id = geo_id[0].detector_id
542 raise Exception(f
"Unable to determine detector ID from Hardware Map!")
544 tphandler = db.get_dal(class_name=
"DataHandlerConf", uid=
"def-tp-handler")
547 if "DAPHNEStream" in emulated_file_name:
548 linkhandler = db.get_dal(
549 class_name=
"DataHandlerConf", uid=
"def-pds-stream-link-handler"
551 cb_desc = db.get_dal(
552 class_name=
"DataMoveCallbackDescriptor", uid=
"pds-stream-raw-input"
555 linkhandler = db.get_dal(
556 class_name=
"DataHandlerConf", uid=
"def-pds-link-handler"
558 cb_desc = db.get_dal(
559 class_name=
"DataMoveCallbackDescriptor", uid=
"pds-raw-input"
562 elif det_id == 3
or det_id == 10:
563 linkhandler = db.get_dal(
564 class_name=
"DataHandlerConf", uid=
"def-link-handler"
566 cb_desc = db.get_dal(
567 class_name=
"DataMoveCallbackDescriptor", uid=
"wib-eth-raw-input"
570 linkhandler = db.get_dal(
571 class_name=
"DataHandlerConf", uid=
"def-tde-link-handler"
573 cb_desc = db.get_dal(
574 class_name=
"DataMoveCallbackDescriptor", uid=
"tde-raw-input"
577 linkhandler = db.get_dal(
578 class_name=
"DataHandlerConf", uid=
"def-crt-bern-link-handler"
580 cb_desc = db.get_dal(
581 class_name=
"DataMoveCallbackDescriptor", uid=
"crt-bern-raw-input"
584 linkhandler = db.get_dal(
585 class_name=
"DataHandlerConf", uid=
"def-crt-grenoble-link-handler"
587 cb_desc = db.get_dal(
588 class_name=
"DataMoveCallbackDescriptor", uid=
"crt-grenoble-raw-input"
591 hostnum = appnum % len(hosts)
593 host = db.get_dal(class_name=
"VirtualHost", uid=hosts[hostnum])
596 if connection.className() ==
"NetworkDetectorToDaqConnection":
597 receiver = connection.net_receiver
598 elif connection.className() ==
"FelixDetectorToDaqConnection":
599 receiver = connection.felix_receiver
602 readout_start = db.get_dal(class_name=
"ActionPlan", uid=
"readout-start")
603 readout_stop = db.get_dal(class_name=
"ActionPlan", uid=
"readout-stop")
606 if type(receiver).__name__ ==
"FakeDataReceiver":
609 stream_emu = db.get_dal(
610 class_name=
"StreamEmulationParameters", uid=
"stream-emu"
612 stream_emu.data_file_name = resolve_asset_file(emulated_file_name)
613 db.update_dal(stream_emu)
615 stream_emu = dal.StreamEmulationParameters(
617 data_file_name=resolve_asset_file(emulated_file_name),
618 input_file_size_limit=5777280,
620 random_population_size=100000,
621 frame_error_rate_hz=0,
622 generate_periodic_adc_pattern=
True,
623 TP_rate_per_channel=1,
625 db.update_dal(stream_emu)
627 print(
"Generating fake DataReaderConf")
628 nicrec = dal.DPDKReaderConf(
630 template_for=
"FDFakeReaderModule",
632 emulation_conf=stream_emu,
634 db.update_dal(nicrec)
636 elif type(receiver).__name__ ==
"DPDKReceiver":
638 print(
"Generating DPDKReaderConf")
639 nicrec = dal.DPDKReaderConf(
640 f
"nicrcvr-dpdk-gen", template_for=
"DPDKReaderModule"
642 db.update_dal(nicrec)
645 wm_conf = db.get_dal(
"WIBModuleConf",
"def-wib-conf")
648 'Expected WIBModuleConf "def-wib-conf" not found in input databases!'
650 if hermes_conf ==
None:
652 hermes_conf = db.get_dal(
"HermesModuleConf",
"def-hermes-conf")
655 'Expected HermesModuleConf "def-hermes-conf" not found in input databases!'
660 wiec_app = dal.WIECApplication(
661 f
"wiec-{connection.id}",
662 application_name=
"daq_application",
664 detector_connections=[connection],
665 wib_module_conf=wm_conf,
666 hermes_module_conf=hermes_conf,
667 exposes_service=[daqapp_control],
669 db.update_dal(wiec_app)
671 elif type(receiver).__name__ ==
"FelixInterface":
673 print(
"Generating Felix DataReaderConf")
674 flxcard = dal.DataReaderConf(
675 f
"flxConf-1", template_for=
"FelixReaderModule"
677 db.update_dal(flxcard)
679 elif type(receiver).__name__ ==
"FileReaderReceiver":
682 snb_files = db.get_dal(
683 class_name=
"SNBFileSourceParameters", uid=f
"snb-files-{connection.id}"
685 snb_files.data_files = [resolve_asset_file(emulated_file_name)]
686 db.update_dal(snb_files)
688 snb_files = dal.SNBFileSourceParameters(
690 data_files=[resolve_asset_file(emulated_file_name)],
691 input_buffer_size=5777280,
692 file_compression_algorithm=
"None",
694 db.update_dal(snb_files)
696 print(
"Generating fake DataReaderConf")
697 nicrec = dal.SNBFileReaderConf(
698 f
"nicrcvr-file-reader",
699 template_for=
"SNBFileReaderModule",
703 db.update_dal(nicrec)
706 print(f
"Using SNB DataHandler")
707 linkhandler.template_for =
"SNBDataHandlerModule"
708 db.update_dal(linkhandler)
710 readout_start = db.get_dal(class_name=
"ActionPlan", uid=
"snb-readout-start")
711 readout_stop = db.get_dal(class_name=
"ActionPlan", uid=
"snb-readout-stop")
714 f
"ReadoutGroup contains unknown interface type {type(receiver).__name__}"
721 dataRequests = db.get_dal(class_name=
"Service", uid=
"dataRequests")
722 timeSyncs = db.get_dal(class_name=
"Service", uid=
"timeSyncs")
723 triggerActivities = db.get_dal(class_name=
"Service", uid=
"triggerActivities")
724 triggerPrimitives = db.get_dal(class_name=
"Service", uid=
"triggerPrimitives")
726 ru = dal.ReadoutApplication(
727 f
"ru-{connection.id}",
728 application_name=
"daq_application",
730 detector_connections=[connection],
731 network_rules=netrules,
733 link_handler=linkhandler,
734 data_reader=datareader,
735 fragment_aggregator=fragagg,
736 opmon_conf=opmon_conf,
737 tp_generation_enabled=tpg_enabled,
738 ta_generation_enabled=tpg_enabled,
740 exposes_service=[daqapp_control, dataRequests, timeSyncs],
741 action_plans=[readout_start, readout_stop],
742 callback_desc=cb_desc,
745 ru.tp_handler = tphandler
747 tpbaseid = (appnum * 3) + 100
750 for plane
in range(1
if det_id
not in [3, 10, 11]
else 3):
751 s_id = tpbaseid + plane
752 tps_dal = dal.SourceIDConf(
753 f
"tp-srcid-{s_id}", sid=s_id, subsystem=
"Trigger"
755 db.update_dal(tps_dal)
756 tp_sources.append(tps_dal)
757 ru.tp_source_ids = tp_sources
758 ru.exposes_service += [triggerActivities, triggerPrimitives]
765 print(f
"No ReadoutApplications generated\n")
772 fsm = db.get_dal(class_name=
"FSMconfiguration", uid=
"FSMconfiguration_noAction")
773 controller = dal.RCApplication(
775 application_name=
"drunc-controller",
778 opmon_conf=opmon_conf,
779 exposes_service=[rccontroller_control],
781 db.update_dal(controller)
784 seg = dal.Segment(f
"ru-segment", controller=controller, applications=ruapps)
792def generate_fakedata(oksfile, include, generate_segment, n_streams, n_apps, det_id, fragment_type=None):
793 """Simple script to create an OKS configuration file for a FakeDataProd-based readout segment.
795 The file will automatically include the relevant schema files and
796 any other OKS files you specify.
801 "schema/confmodel/dunedaq.schema.xml",
802 "schema/appmodel/application.schema.xml",
805 res, extra_includes = find_oksincludes(include, os.path.dirname(oksfile))
807 includefiles += extra_includes
813 if not oksfile.endswith(
".data.xml"):
814 oksfile = oksfile +
".data.xml"
815 print(f
"Creating OKS database file {oksfile}")
816 db.create_db(oksfile, includefiles)
817 db.set_active(oksfile)
820 for vhost
in db.get_dals(class_name=
"VirtualHost"):
821 hosts.append(vhost.id)
822 if vhost.id ==
"vlocalhost":
824 if "vlocalhost" not in hosts:
825 cpus = dal.ProcessingResource(
"cpus", cpu_cores=[0, 1, 2, 3])
827 phdal = dal.PhysicalHost(
"localhost", contains=[cpus])
829 host = dal.VirtualHost(
"vlocalhost", runs_on=phdal, uses=[cpus])
831 hosts.append(
"vlocalhost")
836 daqapp_control = db.get_dal(class_name=
"Service", uid=
"daqapp_control")
837 rccontroller_control = db.get_dal(class_name=
"Service", uid=
"rccontroller_control")
838 dataRequests = db.get_dal(class_name=
"Service", uid=
"dataRequests")
839 timeSyncs = db.get_dal(class_name=
"Service", uid=
"timeSyncs")
840 opmon_conf = db.get_dal(class_name=
"OpMonConf", uid=
"slow-all-monitoring")
841 fragagg = db.get_dal(class_name=
"FragmentAggregatorConf", uid=
"frag-agg-01")
844 class_name=
"NetworkConnectionRule", uid=
"data-req-readout-net-rule"
847 for rule
in [
"ts-fdp-net-rule"]:
848 netrules.append(db.get_dal(class_name=
"NetworkConnectionRule", uid=rule))
852 class_name=
"QueueConnectionRule", uid=
"fpdm-data-requests-queue-rule"
856 'Expected QueueConnectionRule "fpdm-data-requests-queue-rule" not found in input databases!'
863 qrules.append(db.get_dal(class_name=
"QueueConnectionRule", uid=rule))
868 time_tick_diff = 32 * 64
870 fragment_type =
"WIBEth"
872 if fragment_type ==
"DAPHNEEthStream":
876 elif fragment_type ==
"DAPHNEEth":
878 time_tick_diff = 1024
882 f
"FakeDataProd fragment_type '{fragment_type}' not recognized for detector ID {det_id}; "
883 f
"expected 'DAPHNEEthStream' or 'DAPHNEEth'"
887 f
"FakeDataProd parameters not configured for detector ID {det_id}"
890 for appidx
in range(n_apps):
892 fakeapp = dal.FakeDataApplication(f
"fakedata_{appidx}",
894 application_name=
"daq_application",
895 exposes_service=[daqapp_control, dataRequests, timeSyncs],
897 network_rules=netrules,
898 fragment_aggregator=fragagg,
899 opmon_conf=opmon_conf,)
901 for streamidx
in range(n_streams):
902 stream = dal.FakeDataProdConf(
903 f
"fakedata_{appidx}_stream_{streamidx}",
904 system_type=
"Detector_Readout",
906 time_tick_diff=time_tick_diff,
907 frame_size=frame_size,
908 response_delay=response_delay,
909 fragment_type=fragment_type,
911 db.update_dal(stream)
912 fakeapp.producers.append(stream)
913 source_id = source_id + 1
915 db.update_dal(fakeapp)
916 fakeapps.append(fakeapp)
919 fsm = db.get_dal(class_name=
"FSMconfiguration", uid=
"FSMconfiguration_noAction")
920 controller = dal.RCApplication(
922 application_name=
"drunc-controller",
923 opmon_conf=opmon_conf,
926 exposes_service=[rccontroller_control],
928 db.update_dal(controller)
932 controller=controller,
933 applications=fakeapps,
948 """Simple script to create an OKS configuration file for a trigger segment.
950 The file will automatically include the relevant schema files and
951 any other OKS files you specify.
956 "schema/confmodel/dunedaq.schema.xml",
957 "schema/appmodel/application.schema.xml",
958 "schema/appmodel/trigger.schema.xml",
961 res, extra_includes = find_oksincludes(include, os.path.dirname(oksfile))
963 includefiles += extra_includes
969 if not oksfile.endswith(
".data.xml"):
970 oksfile = oksfile +
".data.xml"
971 print(f
"Creating OKS database file {oksfile}")
972 db.create_db(oksfile, includefiles)
973 db.set_active(oksfile)
976 for vhost
in db.get_dals(class_name=
"VirtualHost"):
977 hosts.append(vhost.id)
978 if vhost.id ==
"vlocalhost":
980 if "vlocalhost" not in hosts:
981 cpus = dal.ProcessingResource(
"cpus", cpu_cores=[0, 1, 2, 3])
983 phdal = dal.PhysicalHost(
"localhost", contains=[cpus])
985 host = dal.VirtualHost(
"vlocalhost", runs_on=phdal, uses=[cpus])
987 hosts.append(
"vlocalhost")
990 daqapp_control = db.get_dal(class_name=
"Service", uid=
"daqapp_control")
991 rccontroller_control = db.get_dal(class_name=
"Service", uid=
"rccontroller_control")
992 dataRequests = db.get_dal(class_name=
"Service", uid=
"dataRequests")
993 triggerActivities = db.get_dal(class_name=
"Service", uid=
"triggerActivities")
994 triggerCandidates = db.get_dal(class_name=
"Service", uid=
"triggerCandidates")
995 triggerInhibits = db.get_dal(class_name=
"Service", uid=
"triggerInhibits")
998 mlt_source_id = db.get_dal(class_name=
"SourceIDConf", uid=
"tc-srcid-1")
999 tc_source_id = db.get_dal(class_name=
"SourceIDConf", uid=
"ta-srcid-1")
1002 tc_queue_rule = db.get_dal(class_name=
"QueueConnectionRule", uid=
"tc-queue-rule")
1003 td_queue_rule = db.get_dal(class_name=
"QueueConnectionRule", uid=
"td-queue-rule")
1004 ta_queue_rule = db.get_dal(class_name=
"QueueConnectionRule", uid=
"ta-queue-rule")
1005 mlt_qrules = [tc_queue_rule, td_queue_rule]
1006 tapp_qrules = [ta_queue_rule]
1009 tc_net_rule = db.get_dal(class_name=
"NetworkConnectionRule", uid=
"tc-net-rule")
1010 ta_net_rule = db.get_dal(class_name=
"NetworkConnectionRule", uid=
"ta-net-rule")
1011 ts_net_rule = db.get_dal(class_name=
"NetworkConnectionRule", uid=
"ts-net-rule")
1012 ti_net_rule = db.get_dal(class_name=
"NetworkConnectionRule", uid=
"ti-net-rule")
1013 td_dfo_net_rule = db.get_dal(
1014 class_name=
"NetworkConnectionRule", uid=
"td-dfo-net-rule"
1016 data_req_trig_net_rule = db.get_dal(
1017 class_name=
"NetworkConnectionRule", uid=
"data-req-trig-net-rule"
1023 data_req_trig_net_rule,
1026 tapp_netrules = [ta_net_rule, tc_net_rule, data_req_trig_net_rule]
1028 opmon_conf = db.get_dal(class_name=
"OpMonConf", uid=
"slow-all-monitoring")
1029 tc_subscriber = db.get_dal(class_name=
"DataReaderConf", uid=
"tc-subscriber-1")
1030 tc_handler = db.get_dal(class_name=
"DataHandlerConf", uid=
"def-tc-handler")
1031 mlt_conf = db.get_dal(class_name=
"MLTConf", uid=
"def-mlt-conf")
1032 random_tc_generator = db.get_dal(
1033 class_name=
"RandomTCMakerConf", uid=
"random-tc-generator"
1038 fixedtime_tc_generator = db.get_dal(
1039 class_name=
"FixedTimeTCMakerModuleConf",
1042 print(f
"FixedTimeTCMakerModule has been configured, disabling random triggers and HSI")
1043 tc_confs = [fixedtime_tc_generator]
1046 if not hsi_enabled
and len(tc_confs) == 0:
1047 tc_confs = [random_tc_generator]
1049 mlt = dal.MLTApplication(
1052 application_name=
"daq_application",
1059 source_id=mlt_source_id,
1060 queue_rules=mlt_qrules,
1061 network_rules=mlt_netrules,
1062 opmon_conf=opmon_conf,
1063 data_subscriber=tc_subscriber,
1064 trigger_inputs_handler=tc_handler,
1066 standalone_candidate_maker_confs=tc_confs,
1071 ta_subscriber = db.get_dal(class_name=
"DataReaderConf", uid=
"ta-subscriber-1")
1072 ta_handler = db.get_dal(class_name=
"DataHandlerConf", uid=
"def-ta-handler")
1075 tc_maker_start = db.get_dal(class_name=
"ActionPlan", uid=
"tc-maker-start")
1077 tcmaker = dal.TriggerApplication(
1080 application_name=
"daq_application",
1081 exposes_service=[daqapp_control, triggerActivities, dataRequests],
1082 source_id=tc_source_id,
1083 queue_rules=tapp_qrules,
1084 network_rules=tapp_netrules,
1085 opmon_conf=opmon_conf,
1086 data_subscriber=ta_subscriber,
1087 trigger_inputs_handler=ta_handler,
1088 action_plans=[tc_maker_start],
1090 db.update_dal(tcmaker)
1092 if generate_segment:
1093 fsm = db.get_dal(class_name=
"FSMconfiguration", uid=
"FSMconfiguration_noAction")
1094 controller = dal.RCApplication(
1096 application_name=
"drunc-controller",
1097 opmon_conf=opmon_conf,
1100 exposes_service=[rccontroller_control],
1102 db.update_dal(controller)
1106 controller=controller,
1107 applications=[mlt] + ([tcmaker]
if tpg_enabled
else []),
1120 connectivity_service_is_infrastructure_app=True,
1121 disable_connectivity_service=False,
1123 """Simple script to create an OKS configuration file for a session.
1125 The file will automatically include the relevant schema files and
1126 any other OKS files you specify.
1131 "schema/confmodel/dunedaq.schema.xml",
1132 "schema/appmodel/application.schema.xml",
1134 res, extra_includes = find_oksincludes(include, os.path.dirname(oksfile))
1136 includefiles += extra_includes
1142 if not oksfile.endswith(
".data.xml"):
1143 oksfile = oksfile +
".data.xml"
1144 print(f
"Creating OKS database file {oksfile} with includes {includefiles}")
1145 db.create_db(oksfile, includefiles)
1146 db.set_active(oksfile)
1149 for vhost
in db.get_dals(class_name=
"VirtualHost"):
1150 hosts.append(vhost.id)
1151 if vhost.id ==
"vlocalhost":
1153 if "vlocalhost" not in hosts:
1154 cpus = dal.ProcessingResource(
"cpus", cpu_cores=[0, 1, 2, 3])
1156 phdal = dal.PhysicalHost(
"localhost", contains=[cpus])
1157 db.update_dal(phdal)
1158 host = dal.VirtualHost(
"vlocalhost", runs_on=phdal, uses=[cpus])
1160 hosts.append(
"vlocalhost")
1162 fsm = db.get_dal(class_name=
"FSMconfiguration", uid=
"fsmConf-test")
1163 rccontroller_control = db.get_dal(class_name=
"Service", uid=
"rccontroller_control")
1164 controller = dal.RCApplication(
1166 application_name=
"drunc-controller",
1169 exposes_service=[rccontroller_control],
1171 db.update_dal(controller)
1173 segments = db.get_dals(class_name=
"Segment")
1175 seg = dal.Segment(f
"root-segment", controller=controller, segments=segments)
1178 detconf = db.get_dal(class_name=
"DetectorConfig", uid=
"dummy-detector")
1180 detconf.op_env = op_env
1181 db.update_dal(detconf)
1183 opmon_svc = db.get_dal(class_name=
"OpMonURI", uid=
"local-opmon-uri")
1185 trace_file_var =
None
1186 TRACE_FILE = os.getenv(
"TRACE_FILE")
1187 if TRACE_FILE
is not None:
1188 trace_file_var = dal.Variable(
1189 "session-env-trace-file", name=
"TRACE_FILE", value=TRACE_FILE
1191 db.update_dal(trace_file_var)
1193 infrastructure_applications = []
1194 if connectivity_service_is_infrastructure_app:
1195 conn_svc = db.get_dal(
1196 class_name=
"ConnectionService", uid=
"local-connection-server"
1198 infrastructure_applications.append(conn_svc)
1200 env_vars_for_local_running = db.get_dal(
1201 class_name=
"VariableSet", uid=
"local-variables"
1203 if trace_file_var
is not None:
1204 env_vars_for_local_running.append(trace_file_var)
1206 sessiondal = dal.Session(
1208 environment=env_vars_for_local_running,
1210 detector_configuration=detconf,
1211 infrastructure_applications=infrastructure_applications,
1212 opmon_uri=opmon_svc,
1215 if not disable_connectivity_service:
1216 conn_svc_cfg = db.get_dal(
1217 class_name=
"ConnectivityService", uid=
"local-connectivity-service-config"
1219 sessiondal.connectivity_service = conn_svc_cfg
1221 db.update_dal(sessiondal)