DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
generate_hwmap.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2
3import conffwk
4import os
5import json
6import sys
7
8def generate_hwmap(oksfile, n_streams, n_apps = 1, det_id = 3, app_host = "localhost",
9 eth_protocol = "udp", flx_mode = "fix_rate"):
10
11 schemafiles = [
12 "schema/confmodel/dunedaq.schema.xml",
13 "schema/appmodel/application.schema.xml",
14 "schema/appmodel/fdmodules.schema.xml",
15 "schema/appmodel/wiec.schema.xml",
16 ]
17 dal = conffwk.dal.module("generated", schemafiles[-1])
18 db = conffwk.Configuration("oksconflibs")
19 db.create_db(oksfile, schemafiles)
20
21 group_name = os.path.basename(oksfile).removesuffix(".data.xml")
22 groups = []
23 streams = []
24 senders = []
25 source_id = 0
26
27 for app in range(n_apps):
28 print (f"Generating {app=}")
29 print(f"New nic adding nic with id nic-{app}")
30 nic_dal = dal.NetworkInterface(f"nic-{app}")
31 db.update_dal(nic_dal)
32
33 for stream_no in range(n_streams):
34 print (f"Generating {stream_no=}")
35
36 # 28-May-2025, KAB: hack(?) to get DAPHNE TPs to have unique channel numbers
37 # within a single ReadoutApp. This involves setting DAPHNE slot numbers to
38 # unique values. There is probably more work to be done to get the DAPHNE
39 # and WIBEth crate/slot/stream numbers that we use in fake-data-playback and
40 # integration tests to better match real electronics, but hopefully this is
41 # sufficient for now.
42 if det_id in [2, 8, 9]:
43 geo_dal = dal.GeoId(
44 f"geioId-{source_id}",
45 detector_id=det_id,
46 crate_id=app+1,
47 slot_id=stream_no,
48 stream_id=1,
49 )
50 else:
51 geo_dal = dal.GeoId(
52 f"geioId-{source_id}",
53 detector_id=det_id,
54 crate_id=app+1,
55 slot_id=0,
56 stream_id=stream_no,
57 )
58 db.update_dal(geo_dal)
59 stream = dal.DetectorStream(
60 f"stream-{source_id}",
61 source_id=source_id,
62 geo_id=geo_dal,
63 )
64 db.update_dal(stream)
65 streams.append(stream)
66 db.commit()
67
68 sender_dal = dal.FakeDataSender(
69 f"sender-{source_id}",
70 streams=[stream],
71 uses=nic_dal
72 )
73 db.update_dal(sender_dal)
74 senders.append(sender_dal)
75 db.commit()
76
77 source_id = source_id + 1
78
79 rec_dal = dal.FakeDataReceiver(
80 f"dataRec-{app}",
81 uses=nic_dal
82 )
83 db.update_dal(rec_dal)
84 detconn_dal = dal.NetworkDetectorToDaqConnection(
85 f"det-conn-{app}",
86 net_receiver=rec_dal,
87 net_senders=senders
88 )
89 db.update_dal(detconn_dal)
90 groups.append(detconn_dal)
91 senders = []
92
93 db.commit()
94
95if __name__ == "__main__":
96 generate_hwmap("xxx.data.xml", 4, n_apps=2)
module(name, schema, other_dals=[], backend='oksconflibs', db=None)
Definition dal.py:673