DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
hermes-make-dro-map.py
Go to the documentation of this file.
1#!/usr/bin/env python
2
3import re
4import json
5from rich import print
6import daqconf.detreadoutmap as dromap
7
8from crappyzcu.tx_endpoints import tx_endpoints
9from crappyzcu.rx_endpoints import rx_endpoints
10
11m = dromap.DetReadoutMapService()
12
13rx_host = 'np02-srv-002'
14det_id = 3
15crate_id = 4
16iface = 0
17
18rx_props = rx_endpoints[f'{rx_host}-100G']
19rx_mac = ':'.join([f"{s:02x}" for s in rx_props['mac'].to_bytes(6,'big')])
20
21
22
23rx = re.compile(r"np04-wib-(\d)0(\d)-d(\d)")
24
25
26for name, tx_props in tx_endpoints.items():
27 ma = rx.match(name)
28 if not ma:
29 continue
30 c, s, l = ma.groups()
31 if int(c) != crate_id:
32 continue
33
34
35 for i in range(4):
36 strm_id = int(l)*64+i
37
38 src_id = max(m.get())+1 if m.get() else 0
39
40 # print(f"Adding {src_id}")
41 tx_mac = ':'.join([f"{s:02x}" for s in tx_props['mac'].to_bytes(6,'big')])
42 # print(tx_mac)
43
44 m.add_srcid(
45 src_id,
46 dromap.GeoID(det_id, c, s, strm_id),
47 'eth',
48 protocol="udp",
49 mode="fix_rate",
50
51 rx_iface=iface,
52 rx_host=rx_host,
53 rx_mac=rx_mac,
54 rx_ip=rx_props['ip'],
55
56 tx_host=name,
57 tx_mac=tx_mac,
58 tx_ip=tx_props['ip'],
59
60 )
61
62print(m.as_table())
63outpath = f'apa{crate_id}_detreadout.json'
64with open(outpath,"w") as f:
65 json.dump(m.as_json(), f, indent=4)
66print(f"Map saved to '{outpath}'")
67
68import IPython
69IPython.embed(colors="neutral")