DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
hermescoreapp_gen.py
Go to the documentation of this file.
1# This module facilitates the generation of hermesmodules DAQModules within hermesmodules apps
2
3
4# Set moo schema search path
5from dunedaq.env import get_moo_model_path
6import moo.io
7moo.io.default_load_path = get_moo_model_path()
8
9# Load configuration types
10import moo.otypes
11moo.otypes.load_types("hermesmodules/hermescontroller.jsonnet")
12
13import dunedaq.hermesmodules.hermescontroller as hermescontroller
14
15from daqconf.core.app import App, ModuleGraph
16from daqconf.core.daqmodule import DAQModule
17#from daqconf.core.conf_utils import Endpoint, Direction
18
19from itertools import groupby
20
21
22def group_by_key(coll, key):
23 """
24 """
25 m = {}
26 s = sorted(coll, key=key)
27 for k, g in groupby(s, key):
28 m[k] = list(g)
29 return m
30
31
32
34 name,
35 host,
36 addrtab,
37 dro_map,
38 ):
39 """
40 Here the configuration for an entire daq_application instance using DAQModules from hermesmodules is generated.
41 """
42
43 # UDP port - hardocoded for now
44 UDP_PORT=0x4444
45
46 # addrtab = "file://${HERMESMODULES_SHARE}/config/hermes_wib_v0.9.1/tx_mux_wib.xml"
47
48 # Crete a list of relevant stream parameters only
49 tx_infos = list(set([
50 (
51 s.geo_id.det_id,
52 s.geo_id.crate_id,
53 s.geo_id.slot_id,
54 s.parameters.tx_host,
55 int(s.geo_id.stream_id > 63), # hack
56 s.parameters.tx_ip,
57 s.parameters.tx_mac,
58 s.parameters.rx_ip,
59 s.parameters.rx_mac
60 ) for s in dro_map.streams if s.kind == 'eth'
61 ]))
62
63 # group the by actual cores using geoid and host
64 hermes_cores = group_by_key(tx_infos, lambda x: (x[0], x[1], x[2], x[3]))
65
66 modules = []
67 for (det, crate, slot, ctrl_ept), links in hermes_cores.items():
68 d = hermescontroller.Device(name=f"hermes_{det}_{crate}_{slot}", uri=f"ipbusudp-2.0://{ctrl_ept}:50001", addrtab=addrtab)
69 g = hermescontroller.GeoInfo(det_id=det, crate_id=crate, slot_id=slot)
70 lm = hermescontroller.LinkConfMap(
71 [hermescontroller.LinkConf(
72 id=link,
73 src_mac = tx_mac,
74 src_ip = tx_ip,
75 dst_mac = rx_mac,
76 dst_ip= rx_ip
77 ) for _,_,_,_,link,tx_ip,tx_mac,rx_ip,rx_mac in links]
78 )
79
80 modules += [DAQModule(name = f"hermes_{det}_{crate}_{slot}",
81 plugin = "HermesModule",
82 conf = hermescontroller.Conf(
83 device = d,
84 geo_info = g,
85 port = UDP_PORT,
86 links = lm
87 )
88 )]
89
90 mgraph = ModuleGraph(modules)
91 hermesmodules_app = App(modulegraph = mgraph, host = host, name = name)
92
93 return hermesmodules_app
group_by_key(coll, key)
Move to utility module.
get_hermescore_app(name, host, addrtab, dro_map)