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 for stream_no in range(n_streams):
30 print (f"Generating {stream_no=}")
31
32 # 28-May-2025, KAB: hack(?) to get DAPHNE TPs to have unique channel numbers
33 # within a single ReadoutApp. This involves setting DAPHNE slot numbers to
34 # unique values. There is probably more work to be done to get the DAPHNE
35 # and WIBEth crate/slot/stream numbers that we use in fake-data-playback and
36 # integration tests to better match real electronics, but hopefully this is
37 # sufficient for now.
38 if det_id in [2, 8, 9]:
39 geo_dal = dal.GeoId(
40 f"geioId-{source_id}",
41 detector_id=det_id,
42 crate_id=app+1,
43 slot_id=stream_no,
44 stream_id=1,
45 )
46 else:
47 geo_dal = dal.GeoId(
48 f"geioId-{source_id}",
49 detector_id=det_id,
50 crate_id=app+1,
51 slot_id=0,
52 stream_id=stream_no,
53 )
54 db.update_dal(geo_dal)
55 stream = dal.DetectorStream(
56 f"stream-{source_id}",
57 source_id=source_id,
58 geo_id=geo_dal,
59 )
60 db.update_dal(stream)
61 streams.append(stream)
62 db.commit()
63
64 sender_dal = dal.FakeDataSender(
65 f"sender-{source_id}",
66 contains=[stream]
67 )
68 db.update_dal(sender_dal)
69 senders.append(sender_dal)
70 db.commit()
71
72 source_id = source_id + 1
73
74 sender_set = dal.ResourceSetAND(f"senders-{app}", contains=senders)
75 db.update_dal(sender_set)
76
77 print(f"New nic adding nic with id nic-{app}")
78 nic_dal = dal.FakeDataReceiver(
79 f"ROInterface-{app}"
80 )
81 db.update_dal(nic_dal)
82 detconn_dal = dal.DetectorToDaqConnection(
83 f"det-conn-{app}",
84 contains=[nic_dal, sender_set])
85 db.update_dal(detconn_dal)
86 groups.append(detconn_dal)
87 senders = []
88
89 db.commit()
90
91if __name__ == "__main__":
92 generate_hwmap("xxx.data.xml", 4, n_apps=2)
module(name, schema, other_dals=[], backend='oksconflibs', db=None)
Definition dal.py:673