DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
hermesmodules
scripts
hermes-make-dro-map.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
3
import
re
4
import
json
5
from
rich
import
print
6
import
daqconf.detreadoutmap
as
dromap
7
8
from
crappyzcu.tx_endpoints
import
tx_endpoints
9
from
crappyzcu.rx_endpoints
import
rx_endpoints
10
11
m = dromap.DetReadoutMapService()
12
13
rx_host =
'np02-srv-002'
14
det_id = 3
15
crate_id = 4
16
iface = 0
17
18
rx_props = rx_endpoints[f
'{rx_host}-100G'
]
19
rx_mac =
':'
.join([f
"{s:02x}"
for
s
in
rx_props[
'mac'
].to_bytes(6,
'big'
)])
20
21
22
23
rx = re.compile(
r"np04-wib-(\d)0(\d)-d(\d)"
)
24
25
26
for
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
62
print(m.as_table())
63
outpath = f
'apa{crate_id}_detreadout.json'
64
with
open(outpath,
"w"
)
as
f:
65
json.dump(m.as_json(), f, indent=4)
66
print(f
"Map saved to '{outpath}'"
)
67
68
import
IPython
69
IPython.embed(colors=
"neutral"
)
Generated on
for DUNE-DAQ by
1.17.0