DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
utils.py
Go to the documentation of this file.
1import moo.otypes
2
3from dunedaq.env import get_moo_model_path
4moo.otypes.load_types('appfwk/cmd.jsonnet', get_moo_model_path())
5moo.otypes.load_types('appfwk/app.jsonnet', get_moo_model_path())
6moo.otypes.load_types('rcif/cmd.jsonnet', get_moo_model_path())
7moo.otypes.load_types('cmdlib/cmd.jsonnet', get_moo_model_path())
8
9import dunedaq.appfwk.cmd as cmd
10import dunedaq.appfwk.app as app
11import dunedaq.rcif.cmd as rccmd
12import dunedaq.cmdlib.cmd as ccmd
13
14
15def mspec(inst, plugin, conn_refs):
16 """
17 Helper function to create Module Specification objects
18
19 :param inst: Instance
20 :type inst: str
21 :param plugin: Appfwk Module Plugin name
22 :type plugin: str
23 :param cinfos: List of dunedaq.iomanager.ConnectionRef objects
24 :type cinfos: list
25
26 :returns: A constructed ModSpec object
27 :rtype: dunedaq.appfwk.app.ModSpec
28 """
29 return app.ModSpec(inst=inst, plugin=plugin,
30 data=app.ModInit(
31 conn_refs=app.ConnectionReferences_t(conn_refs)
32 )
33 )
34
35def acmd(mods: list):
36 """
37 Helper function to create appfwk's CmdObj of Addressed module commands.
38
39 :param cmdid: The coommand id
40 :type cmdid: str
41 :param mods: List of module name/data structures
42 :type mods: list
43
44 :returns: A constructed Command object
45 :rtype: dunedaq.appfwk.cmd.Command
46 """
47 return cmd.CmdObj(
48 modules=cmd.AddressedCmds(
49 cmd.AddressedCmd(match=m, data=o)
50 for m,o in mods
51 )
52 )
53
54def mcmd(cmdid: str, mods: list):
55 """
56 Helper function to create appfwk's Commands addressed to modules.
57
58 :param cmdid: The coommand id
59 :type cmdid: str
60 :param mods: List of module name/data structures
61 :type mods: list
62
63 :returns: A constructed Command object
64 :rtype: dunedaq.appfwk.cmd.Command
65 """
66 return ccmd.Command(
67 id=ccmd.CmdId(cmdid),
68 data=acmd(mods)
69 )
70
71def mrccmd(cmdid, instate, outstate, mods):
72 """
73 Helper function to create appfwk's Commands addressed to modules.
74
75 :param cmdid: The coommand id
76 :type cmdid: str
77 :param instate: The state before command execution
78 :type instate: str
79 :param outstate: The state after command execution
80 :type outstate: str
81 :param mods: List of module name/data structures
82 :type mods: list
83
84 :returns: A constructed Command object
85 :rtype: dunedaq.rcif.cmd.RCCommand
86 """
87 return rccmd.RCCommand(
88 id=ccmd.CmdId(cmdid),
89 entry_state=rccmd.State(instate),
90 exit_state=rccmd.State(outstate),
91 data=cmd.CmdObj(
92 modules=cmd.AddressedCmds(
93 cmd.AddressedCmd(match=m, data=o)
94 for m,o in mods
95 )
96 )
97 )
98
mcmd(str cmdid, list mods)
Definition utils.py:54
acmd(list mods)
Definition utils.py:35
mrccmd(cmdid, instate, outstate, mods)
Definition utils.py:71
mspec(inst, plugin, conn_refs)
Definition utils.py:15