DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
generate Namespace Reference

Functions

 generate_dataflow (oksfile, include, n_dfapps, tpwriting_enabled, generate_segment, n_data_writers=1)
 
 generate_hsi (oksfile, include, generate_segment)
 
 generate_readout (readoutmap, oksfile, include, generate_segment, emulated_file_name="asset://?checksum=e96fd6efd3f98a9a3bfaba32975b476e", tpg_enabled=True, hosts_to_use=[])
 
 generate_fakedata (oksfile, include, generate_segment, n_streams, n_apps, det_id)
 
 generate_trigger (oksfile, include, generate_segment, tpg_enabled=True, hsi_enabled=False)
 
 generate_session (oksfile, include, session_name, op_env, connectivity_service_is_infrastructure_app=True, disable_connectivity_service=False)
 

Function Documentation

◆ generate_dataflow()

generate.generate_dataflow ( oksfile,
include,
n_dfapps,
tpwriting_enabled,
generate_segment,
n_data_writers = 1 )
Simple script to create an OKS configuration file for a dataflow segment.

  The file will automatically include the relevant schema files and
any other OKS files you specify.

Definition at line 9 of file generate.py.

16):
17 """Simple script to create an OKS configuration file for a dataflow segment.
18
19 The file will automatically include the relevant schema files and
20 any other OKS files you specify.
21 """
22
23 includefiles = [
24 "schema/confmodel/dunedaq.schema.xml",
25 "schema/appmodel/application.schema.xml",
26 ]
27
28 res, extra_includes = find_oksincludes(include, os.path.dirname(oksfile))
29 if res:
30 includefiles += extra_includes
31 else:
32 return
33
34 dal = conffwk.dal.module("generated", includefiles)
35 db = conffwk.Configuration("oksconflibs")
36 if not oksfile.endswith(".data.xml"):
37 oksfile = oksfile + ".data.xml"
38 print(f"Creating OKS database file {oksfile}")
39 db.create_db(oksfile, includefiles)
40 db.set_active(oksfile)
41
42 hosts = []
43 for vhost in db.get_dals(class_name="VirtualHost"):
44 hosts.append(vhost.id)
45 if vhost.id == "vlocalhost":
46 host = vhost
47 if "vlocalhost" not in hosts:
48 cpus = dal.ProcessingResource("cpus", cpu_cores=[0, 1, 2, 3])
49 db.update_dal(cpus)
50 phdal = dal.PhysicalHost("localhost", contains=[cpus])
51 db.update_dal(phdal)
52 host = dal.VirtualHost("vlocalhost", runs_on=phdal, uses=[cpus])
53 db.update_dal(host)
54 hosts.append("vlocalhost")
55
56 # Services
57 daqapp_control = db.get_dal(class_name="Service", uid="daqapp_control")
58 rccontroller_control = db.get_dal(class_name="Service", uid="rccontroller_control")
59
60 # Source IDs
61 tpw_source_id = db.get_dal("SourceIDConf", uid="srcid-tp-stream-writer")
62
63 # Queue Rules
64 trigger_record_q_rule = db.get_dal(
65 class_name="QueueConnectionRule", uid="trigger-record-q-rule"
66 )
67 dfapp_qrules = [trigger_record_q_rule]
68
69 # Net Rules
70 frag_net_rule = db.get_dal(class_name="NetworkConnectionRule", uid="frag-net-rule")
71 df_token_net_rule = db.get_dal(
72 class_name="NetworkConnectionRule", uid="df-token-net-rule"
73 )
74 tpset_net_rule = db.get_dal(
75 class_name="NetworkConnectionRule", uid="tpset-net-rule"
76 )
77 ti_net_rule = db.get_dal(class_name="NetworkConnectionRule", uid="ti-net-rule")
78 td_dfo_net_rule = db.get_dal(
79 class_name="NetworkConnectionRule", uid="td-dfo-net-rule"
80 )
81 td_trb_net_rule = db.get_dal(
82 class_name="NetworkConnectionRule", uid="td-trb-net-rule"
83 )
84 data_req_trig_net_rule = db.get_dal(
85 class_name="NetworkConnectionRule", uid="data-req-trig-net-rule"
86 )
87 data_req_hsi_net_rule = db.get_dal(
88 class_name="NetworkConnectionRule", uid="data-req-hsi-net-rule"
89 )
90 data_req_readout_net_rule = db.get_dal(
91 class_name="NetworkConnectionRule", uid="data-req-readout-net-rule"
92 )
93 dfapp_netrules = [
94 td_trb_net_rule,
95 frag_net_rule,
96 df_token_net_rule,
97 data_req_hsi_net_rule,
98 data_req_readout_net_rule,
99 data_req_trig_net_rule,
100 ]
101 dfo_netrules = [td_dfo_net_rule, ti_net_rule, df_token_net_rule]
102 tpw_netrules = [tpset_net_rule]
103
104 opmon_conf = db.get_dal(class_name="OpMonConf", uid="slow-all-monitoring")
105
106 dfo_conf = db.get_dal(class_name="DFOConf", uid="dfoconf-01")
107 dfo = dal.DFOApplication(
108 "dfo-01",
109 runs_on=host,
110 application_name="daq_application",
111 exposes_service=[daqapp_control],
112 network_rules=dfo_netrules,
113 opmon_conf=opmon_conf,
114 dfo=dfo_conf,
115 )
116 db.update_dal(dfo)
117
118 trb_conf = db.get_dal(class_name="TRBConf", uid="trb-01")
119 dw_conf = db.get_dal(class_name="DataWriterConf", uid="dw-01")
120 dfhw = db.get_dal(class_name="DFHWConf", uid="dfhw-01")
121 dfapps = []
122 for dfapp_idx in range(n_dfapps):
123 dfapp_id = dfapp_idx + 1
124
125 # Offset sids by one so that TPW sourceID can stay at 1
126 dfapp_source_id = dal.SourceIDConf(
127 f"srcid-df-{dfapp_id:02}", sid=dfapp_id + 1, subsystem="TR_Builder"
128 )
129 db.update_dal(dfapp_source_id)
130
131 dfapp = dal.DFApplication(
132 f"df-{dfapp_id:02}",
133 runs_on=host,
134 application_name="daq_application",
135 exposes_service=[daqapp_control],
136 source_id=dfapp_source_id,
137 queue_rules=dfapp_qrules,
138 network_rules=dfapp_netrules,
139 opmon_conf=opmon_conf,
140 trb=trb_conf,
141 data_writers=[dw_conf] * n_data_writers,
142 uses=dfhw,
143 )
144 db.update_dal(dfapp)
145 dfapps.append(dfapp)
146
147 tpwapps = []
148 if tpwriting_enabled:
149 tpw_writer_conf = db.get_dal(
150 class_name="TPStreamWriterConf", uid="tp-stream-writer-conf"
151 )
152
153 tpwapp = dal.TPStreamWriterApplication(
154 "tp-stream-writer",
155 runs_on=host,
156 application_name="daq_application",
157 exposes_service=[daqapp_control],
158 source_id=tpw_source_id,
159 network_rules=tpw_netrules,
160 opmon_conf=opmon_conf,
161 tp_writer=tpw_writer_conf,
162 )
163 db.update_dal(tpwapp)
164 tpwapps.append(tpwapp)
165
166 if generate_segment:
167 fsm = db.get_dal(class_name="FSMconfiguration", uid="FSMconfiguration_noAction")
168 controller = dal.RCApplication(
169 "df-controller",
170 application_name="drunc-controller",
171 runs_on=host,
172 fsm=fsm,
173 opmon_conf=opmon_conf,
174 exposes_service=[rccontroller_control],
175 )
176 db.update_dal(controller)
177
178 seg = dal.Segment(
179 f"df-segment", controller=controller, applications=[dfo] + dfapps + tpwapps
180 )
181 db.update_dal(seg)
182
183 db.commit()
184 return
185
186
module(name, schema, other_dals=[], backend='oksconflibs', db=None)
Definition dal.py:673

◆ generate_fakedata()

generate.generate_fakedata ( oksfile,
include,
generate_segment,
n_streams,
n_apps,
det_id )
Simple script to create an OKS configuration file for a FakeDataProd-based readout segment.

  The file will automatically include the relevant schema files and
any other OKS files you specify.

Definition at line 695 of file generate.py.

697):
698 """Simple script to create an OKS configuration file for a FakeDataProd-based readout segment.
699
700 The file will automatically include the relevant schema files and
701 any other OKS files you specify.
702
703 """
704
705 includefiles = [
706 "schema/confmodel/dunedaq.schema.xml",
707 "schema/appmodel/application.schema.xml",
708 ]
709
710 res, extra_includes = find_oksincludes(include, os.path.dirname(oksfile))
711 if res:
712 includefiles += extra_includes
713 else:
714 return
715
716 dal = conffwk.dal.module("generated", includefiles)
717 db = conffwk.Configuration("oksconflibs")
718 if not oksfile.endswith(".data.xml"):
719 oksfile = oksfile + ".data.xml"
720 print(f"Creating OKS database file {oksfile}")
721 db.create_db(oksfile, includefiles)
722 db.set_active(oksfile)
723
724 hosts = []
725 for vhost in db.get_dals(class_name="VirtualHost"):
726 hosts.append(vhost.id)
727 if vhost.id == "vlocalhost":
728 host = vhost
729 if "vlocalhost" not in hosts:
730 cpus = dal.ProcessingResource("cpus", cpu_cores=[0, 1, 2, 3])
731 db.update_dal(cpus)
732 phdal = dal.PhysicalHost("localhost", contains=[cpus])
733 db.update_dal(phdal)
734 host = dal.VirtualHost("vlocalhost", runs_on=phdal, uses=[cpus])
735 db.update_dal(host)
736 hosts.append("vlocalhost")
737
738 source_id = 0
739 fakeapps = []
740 # Services
741 daqapp_control = db.get_dal(class_name="Service", uid="daqapp_control")
742 rccontroller_control = db.get_dal(class_name="Service", uid="rccontroller_control")
743 dataRequests = db.get_dal(class_name="Service", uid="dataRequests")
744 timeSyncs = db.get_dal(class_name="Service", uid="timeSyncs")
745 opmon_conf = db.get_dal(class_name="OpMonConf", uid="slow-all-monitoring")
746
747 rule = db.get_dal(
748 class_name="NetworkConnectionRule", uid="data-req-readout-net-rule"
749 )
750 netrules = [rule]
751 for rule in ["ts-fdp-net-rule"]:
752 netrules.append(db.get_dal(class_name="NetworkConnectionRule", uid=rule))
753
754 try:
755 rule = db.get_dal(
756 class_name="QueueConnectionRule", uid="fpdm-data-requests-queue-rule"
757 )
758 except:
759 print(
760 'Expected QueueConnectionRule "fpdm-data-requests-queue-rule" not found in input databases!'
761 )
762 else:
763 qrules = [rule]
764 for rule in [
765 "fa-queue-rule",
766 ]:
767 qrules.append(db.get_dal(class_name="QueueConnectionRule", uid=rule))
768
769 frame_size=0
770 fragment_type=""
771 if det_id == 3:
772 frame_size=7200
773 time_tick_diff=32*64
774 response_delay=0
775 fragment_type="WIBEth"
776 else:
777 raise Exception(f"FakeDataProd parameters not configured for detector ID {det_id}")
778
779 for appidx in range(n_apps):
780
781 fakeapp = dal.FakeDataApplication(f"fakedata_{appidx}",
782 runs_on=host,
783 application_name="daq_application",
784 exposes_service=[daqapp_control, dataRequests, timeSyncs],
785 queue_rules=qrules,
786 network_rules=netrules,
787 opmon_conf=opmon_conf,)
788
789 for streamidx in range(n_streams):
790 stream = dal.FakeDataProdConf(
791 f"fakedata_{appidx}_stream_{streamidx}",
792 system_type="Detector_Readout",
793 source_id=source_id,
794 time_tick_diff=time_tick_diff,
795 frame_size=frame_size,
796 response_delay=response_delay,
797 fragment_type=fragment_type,
798 )
799 db.update_dal(stream)
800 fakeapp.contains.append(stream)
801 source_id = source_id + 1
802
803 db.update_dal(fakeapp)
804 fakeapps.append(fakeapp)
805
806
807 if generate_segment:
808 fsm = db.get_dal(class_name="FSMconfiguration", uid="FSMconfiguration_noAction")
809 controller = dal.RCApplication(
810 "ru-controller",
811 application_name="drunc-controller",
812 opmon_conf=opmon_conf,
813 runs_on=host,
814 fsm=fsm,
815 exposes_service=[rccontroller_control],
816 )
817 db.update_dal(controller)
818
819 seg = dal.Segment(
820 f"ru-segment",
821 controller=controller,
822 applications=fakeapps,
823 )
824 db.update_dal(seg)
825
826 db.commit()
827 return
828
829

◆ generate_hsi()

generate.generate_hsi ( oksfile,
include,
generate_segment )
Simple script to create an OKS configuration file for a FakeHSI segment.

  The file will automatically include the relevant schema files and
any other OKS files you specify.

Definition at line 187 of file generate.py.

191):
192 """Simple script to create an OKS configuration file for a FakeHSI segment.
193
194 The file will automatically include the relevant schema files and
195 any other OKS files you specify.
196
197
198 """
199
200 includefiles = [
201 "schema/confmodel/dunedaq.schema.xml",
202 "schema/appmodel/application.schema.xml",
203 "schema/appmodel/trigger.schema.xml",
204 ]
205
206 res, extra_includes = find_oksincludes(include, os.path.dirname(oksfile))
207 if res:
208 includefiles += extra_includes
209 else:
210 return
211
212 dal = conffwk.dal.module("generated", includefiles)
213 db = conffwk.Configuration("oksconflibs")
214 if not oksfile.endswith(".data.xml"):
215 oksfile = oksfile + ".data.xml"
216 print(f"Creating OKS database file {oksfile}")
217 db.create_db(oksfile, includefiles)
218 db.set_active(oksfile)
219
220 hosts = []
221 for vhost in db.get_dals(class_name="VirtualHost"):
222 hosts.append(vhost.id)
223 if vhost.id == "vlocalhost":
224 host = vhost
225 if "vlocalhost" not in hosts:
226 cpus = dal.ProcessingResource("cpus", cpu_cores=[0, 1, 2, 3])
227 db.update_dal(cpus)
228 phdal = dal.PhysicalHost("localhost", contains=[cpus])
229 db.update_dal(phdal)
230 host = dal.VirtualHost("vlocalhost", runs_on=phdal, uses=[cpus])
231 db.update_dal(host)
232 hosts.append("vlocalhost")
233
234 # Services
235 daqapp_control = db.get_dal(class_name="Service", uid="daqapp_control")
236 rccontroller_control = db.get_dal(class_name="Service", uid="rccontroller_control")
237 dataRequests = db.get_dal(class_name="Service", uid="dataRequests")
238 hsievents = db.get_dal(class_name="Service", uid="HSIEvents")
239
240 # Source IDs
241 hsi_source_id = db.get_dal(class_name="SourceIDConf", uid="hsi-srcid-01")
242 hsi_tc_source_id = db.get_dal(class_name="SourceIDConf", uid="hsi-tc-srcid-1")
243
244 # Queue Rules
245 hsi_dlh_queue_rule = db.get_dal(
246 class_name="QueueConnectionRule", uid="hsi-dlh-data-requests-queue-rule"
247 )
248 hsi_qrules = [hsi_dlh_queue_rule]
249
250 # Net Rules
251 tc_net_rule = db.get_dal(class_name="NetworkConnectionRule", uid="tc-net-rule")
252 hsi_rule = db.get_dal(class_name="NetworkConnectionRule", uid="hsi-rule")
253 ts_hsi_net_rule = db.get_dal(
254 class_name="NetworkConnectionRule", uid="ts-hsi-net-rule"
255 )
256 data_req_hsi_net_rule = db.get_dal(
257 class_name="NetworkConnectionRule", uid="data-req-hsi-net-rule"
258 )
259 hsi_netrules = [hsi_rule, data_req_hsi_net_rule, ts_hsi_net_rule]
260 tc_netrules = [hsi_rule, tc_net_rule]
261
262 opmon_conf = db.get_dal(class_name="OpMonConf", uid="slow-all-monitoring")
263 hsi_handler = db.get_dal(class_name="DataHandlerConf", uid="def-hsi-handler")
264 fakehsi = db.get_dal(class_name="FakeHSIEventGeneratorConf", uid="fakehsi")
265
266 hsi = dal.FakeHSIApplication(
267 "hsi-01",
268 runs_on=host,
269 application_name="daq_application",
270 exposes_service=[daqapp_control],
271 source_id=hsi_source_id,
272 queue_rules=hsi_qrules,
273 network_rules=hsi_netrules,
274 opmon_conf=opmon_conf,
275 link_handler=hsi_handler,
276 generator=fakehsi,
277 )
278 db.update_dal(hsi)
279
280 hsi_to_tc_conf = db.get_dal(class_name="HSI2TCTranslatorConf", uid="hsi-to-tc-conf")
281
282 hsi_to_tc = dal.HSIEventToTCApplication(
283 "hsi-to-tc-app",
284 runs_on=host,
285 application_name="daq_application",
286 exposes_service=[dataRequests, hsievents, daqapp_control],
287 source_id=hsi_tc_source_id,
288 network_rules=tc_netrules,
289 opmon_conf=opmon_conf,
290 hsevent_to_tc_conf=hsi_to_tc_conf,
291 )
292 db.update_dal(hsi_to_tc)
293
294 if generate_segment:
295 fsm = db.get_dal(class_name="FSMconfiguration", uid="FSMconfiguration_noAction")
296 controller = dal.RCApplication(
297 "hsi-controller",
298 application_name="drunc-controller",
299 runs_on=host,
300 fsm=fsm,
301 opmon_conf=opmon_conf,
302 exposes_service=[rccontroller_control],
303 )
304 db.update_dal(controller)
305
306 seg = dal.Segment(
307 f"hsi-segment", controller=controller, applications=[hsi, hsi_to_tc]
308 )
309 db.update_dal(seg)
310
311 db.commit()
312 return
313
314

◆ generate_readout()

generate.generate_readout ( readoutmap,
oksfile,
include,
generate_segment,
emulated_file_name = "asset://?checksum=e96fd6efd3f98a9a3bfaba32975b476e",
tpg_enabled = True,
hosts_to_use = [] )
Simple script to create an OKS configuration file for all
ReadoutApplications defined in a readout map.

The file will automatically include the relevant schema files and
any other OKS files you specify.

Example:
 generate_readoutOKS -i hosts \
   -i appmodel/connections.data.xml -i appmodel/moduleconfs \
   config/np04readoutmap.data.xml readoutApps.data.xml

Will load hosts, connections and moduleconfs data files as well as
the readoutmap (config/np04readoutmap.data.xml) and write the
generated apps to readoutApps.data.xml.

 generate_readoutOKS --session --segment \
   -i appmodel/fsm -i hosts \
   -i appmodel/connections.data.xml -i appmodel/moduleconfs  \
   config/np04readoutmap.data.xml np04readout-session.data.xml

Will do the same but in addition it will generate a containing
Segment for the apps and a containing Session for the Segment.

NB: Currently FSM generation is not implemented so you must include
an fsm file in order to generate a Segment

Definition at line 315 of file generate.py.

323):
324 """Simple script to create an OKS configuration file for all
325 ReadoutApplications defined in a readout map.
326
327 The file will automatically include the relevant schema files and
328 any other OKS files you specify.
329
330 Example:
331 generate_readoutOKS -i hosts \
332 -i appmodel/connections.data.xml -i appmodel/moduleconfs \
333 config/np04readoutmap.data.xml readoutApps.data.xml
334
335 Will load hosts, connections and moduleconfs data files as well as
336 the readoutmap (config/np04readoutmap.data.xml) and write the
337 generated apps to readoutApps.data.xml.
338
339 generate_readoutOKS --session --segment \
340 -i appmodel/fsm -i hosts \
341 -i appmodel/connections.data.xml -i appmodel/moduleconfs \
342 config/np04readoutmap.data.xml np04readout-session.data.xml
343
344 Will do the same but in addition it will generate a containing
345 Segment for the apps and a containing Session for the Segment.
346
347 NB: Currently FSM generation is not implemented so you must include
348 an fsm file in order to generate a Segment
349
350 """
351
352 if not readoutmap.endswith(".data.xml"):
353 readoutmap = readoutmap + ".data.xml"
354
355 print(f"Readout map file {readoutmap}")
356
357 includefiles = [
358 "schema/confmodel/dunedaq.schema.xml",
359 "schema/appmodel/application.schema.xml",
360 "schema/appmodel/trigger.schema.xml",
361 "schema/appmodel/fdmodules.schema.xml",
362 "schema/appmodel/wiec.schema.xml",
363 readoutmap,
364 ]
365
366 searchdirs = [path for path in os.environ["DUNEDAQ_DB_PATH"].split(":")]
367 searchdirs.append(os.path.dirname(oksfile))
368 for inc in include:
369 # print (f"Searching for {inc}")
370 match = False
371 inc = inc.removesuffix(".xml")
372 if inc.endswith(".data"):
373 sub_dirs = ["config", "data"]
374 elif inc.endswith(".schema"):
375 sub_dirs = ["schema"]
376 else:
377 sub_dirs = ["*"]
378 inc = inc + "*"
379 for path in searchdirs:
380 # print (f" {path}/{inc}.xml")
381 matches = glob.glob(f"{inc}.xml", root_dir=path)
382 if len(matches) == 0:
383 for search_dir in sub_dirs:
384 # print (f" {path}/{search_dir}/{inc}.xml")
385 matches = glob.glob(f"{search_dir}/{inc}.xml", root_dir=path)
386 for filename in matches:
387 if filename not in includefiles:
388 print(f"Adding {filename} to include list")
389 includefiles.append(filename)
390 else:
391 print(f"{filename} already in include list")
392 match = True
393 break
394 if match:
395 break
396 if match:
397 break
398 else:
399 for filename in matches:
400 if filename not in includefiles:
401 print(f"Adding {filename} to include list")
402 includefiles.append(filename)
403 else:
404 print(f"{filename} already in include list")
405 match = True
406 break
407
408 if not match:
409 print(f"Error could not find include file for {inc}")
410 return
411
412 dal = conffwk.dal.module("generated", includefiles)
413 db = conffwk.Configuration("oksconflibs")
414 if not oksfile.endswith(".data.xml"):
415 oksfile = oksfile + ".data.xml"
416 print(f"Creating OKS database file {oksfile}")
417 db.create_db(oksfile, includefiles)
418 db.set_active(oksfile)
419
420 detector_connections = db.get_dals(class_name="DetectorToDaqConnection")
421 daqapp_control = db.get_dal(class_name="Service", uid="daqapp_control")
422 rccontroller_control = db.get_dal(class_name="Service", uid="rccontroller_control")
423
424 try:
425 rule = db.get_dal(
426 class_name="NetworkConnectionRule", uid="data-req-readout-net-rule"
427 )
428 except:
429 print(
430 'Expected NetworkConnectionRule "data-req-readout-net-rule" not found in input databases!'
431 )
432 else:
433 netrules = [rule]
434 # Assume we have all the other rules we need
435 for rule in ["tpset-net-rule", "ts-net-rule", "ta-net-rule"]:
436 netrules.append(db.get_dal(class_name="NetworkConnectionRule", uid=rule))
437
438 try:
439 rule = db.get_dal(
440 class_name="QueueConnectionRule", uid="fd-dlh-data-requests-queue-rule"
441 )
442 except:
443 print(
444 'Expected QueueConnectionRule "fd-dlh-data-requests-queue-rule" not found in input databases!'
445 )
446 else:
447 qrules = [rule]
448 for rule in [
449 "fa-queue-rule",
450 "tp-queue-rule",
451 ]:
452 qrules.append(db.get_dal(class_name="QueueConnectionRule", uid=rule))
453
454 hosts = []
455 if len(hosts_to_use) == 0:
456 for vhost in db.get_dals(class_name="VirtualHost"):
457 if vhost.id == "vlocalhost":
458 hosts.append(vhost.id)
459 if "vlocalhost" not in hosts:
460 cpus = dal.ProcessingResource("cpus", cpu_cores=[0, 1, 2, 3])
461 db.update_dal(cpus)
462 phdal = dal.PhysicalHost("localhost", contains=[cpus])
463 db.update_dal(phdal)
464 host = dal.VirtualHost("vlocalhost", runs_on=phdal, uses=[cpus])
465 db.update_dal(host)
466 hosts.append("vlocalhost")
467 else:
468 for vhost in db.get_dals(class_name="VirtualHost"):
469 if vhost.id in hosts_to_use:
470 hosts.append(vhost.id)
471 assert len(hosts) > 0
472
473 rohw = dal.RoHwConfig(f"rohw-{detector_connections[0].id}")
474 db.update_dal(rohw)
475
476 opmon_conf = db.get_dal(class_name="OpMonConf", uid="slow-all-monitoring")
477
478 appnum = 0
479 nicrec = None
480 flxcard = None
481 wm_conf = None
482 hermes_conf = None
483 ruapps = []
484 for connection in detector_connections:
485
486 det_id = 0
487 for resource in connection.contains:
488 if "ResourceSetAND" in resource.oksTypes():
489 for stream in resource.contains:
490 det_id = stream.contains[0].geo_id.detector_id
491 break
492 break
493
494 if det_id == 0:
495 raise Exception(f"Unable to determine detector ID from Hardware Map!")
496
497 tphandler = db.get_dal(class_name="DataHandlerConf", uid="def-tp-handler")
498
499 if det_id == 2:
500 if "DAPHNEStream" in emulated_file_name:
501 linkhandler = db.get_dal(
502 class_name="DataHandlerConf", uid="def-pds-stream-link-handler"
503 )
504 det_q = db.get_dal(
505 class_name="QueueConnectionRule", uid="pds-stream-raw-data-rule"
506 )
507 else:
508 linkhandler = db.get_dal(
509 class_name="DataHandlerConf", uid="def-pds-link-handler"
510 )
511 det_q = db.get_dal(
512 class_name="QueueConnectionRule", uid="pds-raw-data-rule"
513 )
514
515 elif det_id == 3:
516 linkhandler = db.get_dal(
517 class_name="DataHandlerConf", uid="def-link-handler"
518 )
519 det_q = db.get_dal(
520 class_name="QueueConnectionRule", uid="wib-eth-raw-data-rule"
521 )
522 elif det_id == 11:
523 linkhandler = db.get_dal(
524 class_name="DataHandlerConf", uid="def-tde-link-handler"
525 )
526 det_q = db.get_dal(
527 class_name="QueueConnectionRule", uid="tde-raw-data-rule"
528 )
529
530 hostnum = appnum % len(hosts)
531 # print(f"Looking up host[{hostnum}] ({hosts[hostnum]})")
532 host = db.get_dal(class_name="VirtualHost", uid=hosts[hostnum])
533
534 # Find which type of DataReceiver we need for this connection
535 for resource in connection.contains:
536 if "DetDataReceiver" in resource.oksTypes():
537 receiver = resource
538 break
539 # Emulated stream
540 if type(receiver).__name__ == "FakeDataReceiver":
541 if nicrec == None:
542 try:
543 stream_emu = db.get_dal(
544 class_name="StreamEmulationParameters", uid="stream-emu"
545 )
546 stream_emu.data_file_name = resolve_asset_file(emulated_file_name)
547 db.update_dal(stream_emu)
548 except:
549 stream_emu = dal.StreamEmulationParameters(
550 "stream-emu",
551 data_file_name=resolve_asset_file(emulated_file_name),
552 input_file_size_limit=5777280,
553 set_t0=True,
554 random_population_size=100000,
555 frame_error_rate_hz=0,
556 generate_periodic_adc_pattern=True,
557 TP_rate_per_channel=1,
558 )
559 db.update_dal(stream_emu)
560
561 print("Generating fake DataReaderConf")
562 nicrec = dal.DPDKReaderConf(
563 f"nicrcvr-fake-gen",
564 template_for="FDFakeReaderModule",
565 emulation_mode=1,
566 emulation_conf=stream_emu,
567 )
568 db.update_dal(nicrec)
569 datareader = nicrec
570 elif type(receiver).__name__ == "DPDKReceiver":
571 if nicrec == None:
572 print("Generating DPDKReaderConf")
573 nicrec = dal.DPDKReaderConf(
574 f"nicrcvr-dpdk-gen", template_for="DPDKReaderModule"
575 )
576 db.update_dal(nicrec)
577 if wm_conf == None:
578 try:
579 wm_conf = db.get_dal("WIBModuleConf", "def-wib-conf")
580 except:
581 print(
582 'Expected WIBModuleConf "def-wib-conf" not found in input databases!'
583 )
584 if hermes_conf == None:
585 try:
586 hermes_conf = db.get_dal("HermesModuleConf", "def-hermes-conf")
587 except:
588 print(
589 'Expected HermesModuleConf "def-hermes-conf" not found in input databases!'
590 )
591
592 datareader = nicrec
593
594 wiec_app = dal.WIECApplication(
595 f"wiec-{connection.id}",
596 application_name="daq_application",
597 runs_on=host,
598 contains=[connection],
599 wib_module_conf=wm_conf,
600 hermes_module_conf=hermes_conf,
601 exposes_service=[daqapp_control],
602 )
603 db.update_dal(wiec_app)
604
605 elif type(receiver).__name__ == "FelixInterface":
606 if flxcard == None:
607 print("Generating Felix DataReaderConf")
608 flxcard = dal.DataReaderConf(
609 f"flxConf-1", template_for="FelixReaderModule"
610 )
611 db.update_dal(flxcard)
612 datareader = flxcard
613 else:
614 print(
615 f"ReadoutGroup contains unknown interface type {type(receiver).__name__}"
616 )
617 continue
618
619 db.commit()
620
621 # Services
622 dataRequests = db.get_dal(class_name="Service", uid="dataRequests")
623 timeSyncs = db.get_dal(class_name="Service", uid="timeSyncs")
624 triggerActivities = db.get_dal(class_name="Service", uid="triggerActivities")
625 triggerPrimitives = db.get_dal(class_name="Service", uid="triggerPrimitives")
626
627 # Action Plans
628 readout_start = db.get_dal(class_name="ActionPlan", uid="readout-start")
629 readout_stop = db.get_dal(class_name="ActionPlan", uid="readout-stop")
630
631 ru = dal.ReadoutApplication(
632 f"ru-{connection.id}",
633 application_name="daq_application",
634 runs_on=host,
635 contains=[connection],
636 network_rules=netrules,
637 queue_rules=qrules + [det_q],
638 link_handler=linkhandler,
639 data_reader=datareader,
640 opmon_conf=opmon_conf,
641 tp_generation_enabled=tpg_enabled,
642 ta_generation_enabled=tpg_enabled,
643 uses=rohw,
644 exposes_service=[daqapp_control, dataRequests, timeSyncs],
645 action_plans=[readout_start, readout_stop],
646 )
647 if tpg_enabled:
648 ru.tp_handler = tphandler
649 tp_sources = []
650 tpbaseid = (appnum * 3) + 100
651 # 30-Apr-2025, KAB: added support for 1 "plane" of non-TPC TPs (e.g. PDS).
652 # That is compared with the usual 3 planes of TPs for TPC detectors.
653 for plane in range(1 if det_id not in [3, 10, 11] else 3):
654 s_id = tpbaseid + plane
655 tps_dal = dal.SourceIDConf(
656 f"tp-srcid-{s_id}", sid=s_id, subsystem="Trigger"
657 )
658 db.update_dal(tps_dal)
659 tp_sources.append(tps_dal)
660 ru.tp_source_ids = tp_sources
661 ru.exposes_service += [triggerActivities, triggerPrimitives]
662 appnum = appnum + 1
663 print(f"{ru=}")
664 db.update_dal(ru)
665 db.commit()
666 ruapps.append(ru)
667 if appnum == 0:
668 print(f"No ReadoutApplications generated\n")
669 return
670
671 db.commit()
672
673 if generate_segment:
674 # fsm = db.get_dal(class_name="FSMconfiguration", uid="fsmConf-test")
675 fsm = db.get_dal(class_name="FSMconfiguration", uid="FSMconfiguration_noAction")
676 controller = dal.RCApplication(
677 "ru-controller",
678 application_name="drunc-controller",
679 runs_on=host,
680 fsm=fsm,
681 opmon_conf=opmon_conf,
682 exposes_service=[rccontroller_control],
683 )
684 db.update_dal(controller)
685 db.commit()
686
687 seg = dal.Segment(f"ru-segment", controller=controller, applications=ruapps)
688 db.update_dal(seg)
689 db.commit()
690
691 db.commit()
692 return
693
694

◆ generate_session()

generate.generate_session ( oksfile,
include,
session_name,
op_env,
connectivity_service_is_infrastructure_app = True,
disable_connectivity_service = False )
Simple script to create an OKS configuration file for a session.

  The file will automatically include the relevant schema files and
any other OKS files you specify.

Definition at line 987 of file generate.py.

994):
995 """Simple script to create an OKS configuration file for a session.
996
997 The file will automatically include the relevant schema files and
998 any other OKS files you specify.
999
1000 """
1001
1002 includefiles = [
1003 "schema/confmodel/dunedaq.schema.xml",
1004 "schema/appmodel/application.schema.xml",
1005 ]
1006 res, extra_includes = find_oksincludes(include, os.path.dirname(oksfile))
1007 if res:
1008 includefiles += extra_includes
1009 else:
1010 return
1011
1012 dal = conffwk.dal.module("generated", includefiles)
1013 db = conffwk.Configuration("oksconflibs")
1014 if not oksfile.endswith(".data.xml"):
1015 oksfile = oksfile + ".data.xml"
1016 print(f"Creating OKS database file {oksfile} with includes {includefiles}")
1017 db.create_db(oksfile, includefiles)
1018 db.set_active(oksfile)
1019
1020 hosts = []
1021 for vhost in db.get_dals(class_name="VirtualHost"):
1022 hosts.append(vhost.id)
1023 if vhost.id == "vlocalhost":
1024 host = vhost
1025 if "vlocalhost" not in hosts:
1026 cpus = dal.ProcessingResource("cpus", cpu_cores=[0, 1, 2, 3])
1027 db.update_dal(cpus)
1028 phdal = dal.PhysicalHost("localhost", contains=[cpus])
1029 db.update_dal(phdal)
1030 host = dal.VirtualHost("vlocalhost", runs_on=phdal, uses=[cpus])
1031 db.update_dal(host)
1032 hosts.append("vlocalhost")
1033
1034 fsm = db.get_dal(class_name="FSMconfiguration", uid="fsmConf-test")
1035 rccontroller_control = db.get_dal(class_name="Service", uid="rccontroller_control")
1036 controller = dal.RCApplication(
1037 "root-controller",
1038 application_name="drunc-controller",
1039 runs_on=host,
1040 fsm=fsm,
1041 exposes_service=[rccontroller_control],
1042 )
1043 db.update_dal(controller)
1044
1045 segments = db.get_dals(class_name="Segment")
1046
1047 seg = dal.Segment(f"root-segment", controller=controller, segments=segments)
1048 db.update_dal(seg)
1049
1050 detconf = db.get_dal(class_name="DetectorConfig", uid="dummy-detector")
1051
1052 detconf.op_env = op_env
1053 db.update_dal(detconf)
1054
1055 opmon_svc = db.get_dal(class_name="OpMonURI", uid="local-opmon-uri")
1056
1057 trace_file_var = None
1058 TRACE_FILE = os.getenv("TRACE_FILE")
1059 if TRACE_FILE is not None:
1060 trace_file_var = dal.Variable(
1061 "session-env-trace-file", name="TRACE_FILE", value=TRACE_FILE
1062 )
1063 db.update_dal(trace_file_var)
1064
1065 infrastructure_applications = []
1066 if connectivity_service_is_infrastructure_app:
1067 conn_svc = db.get_dal(
1068 class_name="ConnectionService", uid="local-connection-server"
1069 )
1070 infrastructure_applications.append(conn_svc)
1071
1072 env_vars_for_local_running = db.get_dal(
1073 class_name="VariableSet", uid="local-variables"
1074 ).contains
1075 if trace_file_var is not None:
1076 env_vars_for_local_running.append(trace_file_var)
1077
1078 sessiondal = dal.Session(
1079 session_name,
1080 environment=env_vars_for_local_running,
1081 segment=seg,
1082 detector_configuration=detconf,
1083 infrastructure_applications=infrastructure_applications,
1084 opmon_uri=opmon_svc,
1085 )
1086
1087 if not disable_connectivity_service:
1088 conn_svc_cfg = db.get_dal(
1089 class_name="ConnectivityService", uid="local-connectivity-service-config"
1090 )
1091 sessiondal.connectivity_service = conn_svc_cfg
1092
1093 db.update_dal(sessiondal)
1094
1095 db.commit()
1096 return

◆ generate_trigger()

generate.generate_trigger ( oksfile,
include,
generate_segment,
tpg_enabled = True,
hsi_enabled = False )
Simple script to create an OKS configuration file for a trigger segment.

  The file will automatically include the relevant schema files and
any other OKS files you specify.

Definition at line 830 of file generate.py.

836):
837 """Simple script to create an OKS configuration file for a trigger segment.
838
839 The file will automatically include the relevant schema files and
840 any other OKS files you specify.
841
842 """
843
844 includefiles = [
845 "schema/confmodel/dunedaq.schema.xml",
846 "schema/appmodel/application.schema.xml",
847 "schema/appmodel/trigger.schema.xml",
848 ]
849
850 res, extra_includes = find_oksincludes(include, os.path.dirname(oksfile))
851 if res:
852 includefiles += extra_includes
853 else:
854 return
855
856 dal = conffwk.dal.module("generated", includefiles)
857 db = conffwk.Configuration("oksconflibs")
858 if not oksfile.endswith(".data.xml"):
859 oksfile = oksfile + ".data.xml"
860 print(f"Creating OKS database file {oksfile}")
861 db.create_db(oksfile, includefiles)
862 db.set_active(oksfile)
863
864 hosts = []
865 for vhost in db.get_dals(class_name="VirtualHost"):
866 hosts.append(vhost.id)
867 if vhost.id == "vlocalhost":
868 host = vhost
869 if "vlocalhost" not in hosts:
870 cpus = dal.ProcessingResource("cpus", cpu_cores=[0, 1, 2, 3])
871 db.update_dal(cpus)
872 phdal = dal.PhysicalHost("localhost", contains=[cpus])
873 db.update_dal(phdal)
874 host = dal.VirtualHost("vlocalhost", runs_on=phdal, uses=[cpus])
875 db.update_dal(host)
876 hosts.append("vlocalhost")
877
878 # Services
879 daqapp_control = db.get_dal(class_name="Service", uid="daqapp_control")
880 rccontroller_control = db.get_dal(class_name="Service", uid="rccontroller_control")
881 dataRequests = db.get_dal(class_name="Service", uid="dataRequests")
882 triggerActivities = db.get_dal(class_name="Service", uid="triggerActivities")
883 triggerCandidates = db.get_dal(class_name="Service", uid="triggerCandidates")
884 triggerInhibits = db.get_dal(class_name="Service", uid="triggerInhibits")
885
886 # Source IDs
887 mlt_source_id = db.get_dal(class_name="SourceIDConf", uid="tc-srcid-1")
888 tc_source_id = db.get_dal(class_name="SourceIDConf", uid="ta-srcid-1")
889
890 # Queue Rules
891 tc_queue_rule = db.get_dal(class_name="QueueConnectionRule", uid="tc-queue-rule")
892 td_queue_rule = db.get_dal(class_name="QueueConnectionRule", uid="td-queue-rule")
893 ta_queue_rule = db.get_dal(class_name="QueueConnectionRule", uid="ta-queue-rule")
894 mlt_qrules = [tc_queue_rule, td_queue_rule]
895 tapp_qrules = [ta_queue_rule]
896
897 # Net Rules
898 tc_net_rule = db.get_dal(class_name="NetworkConnectionRule", uid="tc-net-rule")
899 ta_net_rule = db.get_dal(class_name="NetworkConnectionRule", uid="ta-net-rule")
900 ts_net_rule = db.get_dal(class_name="NetworkConnectionRule", uid="ts-net-rule")
901 ti_net_rule = db.get_dal(class_name="NetworkConnectionRule", uid="ti-net-rule")
902 td_dfo_net_rule = db.get_dal(
903 class_name="NetworkConnectionRule", uid="td-dfo-net-rule"
904 )
905 data_req_trig_net_rule = db.get_dal(
906 class_name="NetworkConnectionRule", uid="data-req-trig-net-rule"
907 )
908 mlt_netrules = [
909 tc_net_rule,
910 ti_net_rule,
911 td_dfo_net_rule,
912 data_req_trig_net_rule,
913 ts_net_rule,
914 ]
915 tapp_netrules = [ta_net_rule, tc_net_rule, data_req_trig_net_rule]
916
917 opmon_conf = db.get_dal(class_name="OpMonConf", uid="slow-all-monitoring")
918 tc_subscriber = db.get_dal(class_name="DataReaderConf", uid="tc-subscriber-1")
919 tc_handler = db.get_dal(class_name="DataHandlerConf", uid="def-tc-handler")
920 mlt_conf = db.get_dal(class_name="MLTConf", uid="def-mlt-conf")
921 random_tc_generator = db.get_dal(
922 class_name="RandomTCMakerConf", uid="random-tc-generator"
923 )
924 tc_confs = [] if hsi_enabled else [random_tc_generator]
925
926 mlt = dal.MLTApplication(
927 "mlt",
928 runs_on=host,
929 application_name="daq_application",
930 exposes_service=[daqapp_control, triggerCandidates, triggerInhibits, dataRequests],
931 source_id=mlt_source_id,
932 queue_rules=mlt_qrules,
933 network_rules=mlt_netrules,
934 opmon_conf=opmon_conf,
935 data_subscriber=tc_subscriber,
936 trigger_inputs_handler=tc_handler,
937 mlt_conf=mlt_conf,
938 standalone_candidate_maker_confs=tc_confs,
939 )
940 db.update_dal(mlt)
941
942 if tpg_enabled:
943 ta_subscriber = db.get_dal(class_name="DataReaderConf", uid="ta-subscriber-1")
944 ta_handler = db.get_dal(class_name="DataHandlerConf", uid="def-ta-handler")
945
946 # Action Plans
947 tc_maker_start = db.get_dal(class_name="ActionPlan", uid="tc-maker-start")
948
949 tcmaker = dal.TriggerApplication(
950 "tc-maker-1",
951 runs_on=host,
952 application_name="daq_application",
953 exposes_service=[daqapp_control, triggerActivities, dataRequests],
954 source_id=tc_source_id,
955 queue_rules=tapp_qrules,
956 network_rules=tapp_netrules,
957 opmon_conf=opmon_conf,
958 data_subscriber=ta_subscriber,
959 trigger_inputs_handler=ta_handler,
960 action_plans=[tc_maker_start],
961 )
962 db.update_dal(tcmaker)
963
964 if generate_segment:
965 fsm = db.get_dal(class_name="FSMconfiguration", uid="FSMconfiguration_noAction")
966 controller = dal.RCApplication(
967 "trg-controller",
968 application_name="drunc-controller",
969 opmon_conf=opmon_conf,
970 runs_on=host,
971 fsm=fsm,
972 exposes_service=[rccontroller_control],
973 )
974 db.update_dal(controller)
975
976 seg = dal.Segment(
977 f"trg-segment",
978 controller=controller,
979 applications=[mlt] + ([tcmaker] if tpg_enabled else []),
980 )
981 db.update_dal(seg)
982
983 db.commit()
984 return
985
986