DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
snbmodules_gen.py
Go to the documentation of this file.
2# Set moo schema search path
3from dunedaq.env import get_moo_model_path
4import moo.io
5moo.io.default_load_path = get_moo_model_path()
6
7# Load configuration types
8import moo.otypes
9moo.otypes.load_types('rcif/cmd.jsonnet')
10moo.otypes.load_types('appfwk/cmd.jsonnet')
11moo.otypes.load_types('appfwk/app.jsonnet')
12
13# Import new types
14moo.otypes.load_types('snbmodules/snbfiletransfer.jsonnet')
15import dunedaq.snbmodules.snbfiletransfer as snbfiletransfer
16moo.otypes.load_types('snbmodules/snbtransferbookkeeper.jsonnet')
17import dunedaq.snbmodules.snbtransferbookkeeper as snbtransferbookkeeper
18
19from daqconf.core.app import App, ModuleGraph
20from daqconf.core.daqmodule import DAQModule
21from daqconf.core.conf_utils import Direction
22
23import socket
24
25# Time to wait on pop()
26QUEUE_POP_WAIT_MS = 100
27
29 snbmodules,
30 SNB_CONNECTION_PREFIX="snbmodules",
31 SNB_TIMEOUT_SEND=10,
32 SNB_TIMEOUT_RECEIVE=100,
33 DEBUG=False
34 ):
35 """
36 Here the configuration for an entire daq_application instance using DAQModules from snbmodules is generated.
37 """
38 HOST=snbmodules.host
39 HOST2 = HOST.replace("-", "")
40 INTERFACE=snbmodules.interface
41 CLIENT_NUM=snbmodules.client_num
42 CLIENT_NAME=snbmodules.client_name
43 CLIENT_STARTING_PORT=snbmodules.client_starting_port
44 CLIENTS_ROOT_DIR = snbmodules.clients_root_dir
45
46 modules = []
47
48 # Adding the modules
49 for i in range(CLIENT_NUM):
50 RESOLVED_INTERFACE = INTERFACE
51 if RESOLVED_INTERFACE == "0.0.0.0":
52 RESOLVED_INTERFACE = socket.gethostbyname(HOST)
53
54 if CLIENT_STARTING_PORT == 0:
55 client_ip = RESOLVED_INTERFACE
56 else:
57 client_ip = RESOLVED_INTERFACE + ":" + str(CLIENT_STARTING_PORT + i)
58
59 modules += [DAQModule(name = HOST2+CLIENT_NAME + str(i), # Adding host in the client name to avoid name clashes
60 plugin = "SNBFileTransfer",
61 conf = snbfiletransfer.ConfParams(
62 client_ip = client_ip,
63 work_dir = CLIENTS_ROOT_DIR + HOST2 + CLIENT_NAME + str(i) + "/",
64 connection_prefix = SNB_CONNECTION_PREFIX,
65 timeout_send = SNB_TIMEOUT_SEND,
66 timeout_receive = SNB_TIMEOUT_RECEIVE,
67 )
68 )]
69
70 # Adding the endpoints
71 mgraph = ModuleGraph(modules)
72
73 for i in range(CLIENT_NUM):
74 mgraph.add_endpoint(SNB_CONNECTION_PREFIX+"_client_" + HOST2 + CLIENT_NAME + str(i) + "_notifications", HOST2 + CLIENT_NAME + str(i) + ".notifications", "notification_t", Direction.IN, check_endpoints=False)
75
76 snbmodules_app = App(modulegraph = mgraph, host = HOST, name = HOST+CLIENT_NAME)
77
78 return snbmodules_app
79
81 HOST,
82 BOOKKEEPER_PORT=0,
83 BOOKKEEPER_REFRESH_RATE=1,
84 BOOKKEEPER_NAME="bookkeeper",
85 BOOKKEEPER_LOG_PATH="./",
86 SNB_CONNECTION_PREFIX="snbmodules",
87 SNB_TIMEOUT_SEND=10,
88 SNB_TIMEOUT_RECEIVE=100,
89 DEBUG=False
90 ):
91 """
92 Here the configuration for an entire daq_application instance using DAQModules from snbmodules is generated.
93 """
94
95 modules = []
96
97 if BOOKKEEPER_PORT == 0:
98 bookkeeper_ip = socket.gethostbyname(HOST)
99 else:
100 bookkeeper_ip = socket.gethostbyname(HOST) + ":" + str(BOOKKEEPER_PORT)
101
102 HOST2 = HOST.replace("-", "")
103 modules += [DAQModule(name = HOST2+BOOKKEEPER_NAME,
104 plugin = "SNBTransferBookkeeper",
105 conf = snbtransferbookkeeper.ConfParams(
106 bookkeeper_ip = bookkeeper_ip,
107 bookkeeper_log_path = BOOKKEEPER_LOG_PATH,
108 refresh_rate = BOOKKEEPER_REFRESH_RATE,
109 connection_prefix = SNB_CONNECTION_PREFIX,
110 timeout_send = SNB_TIMEOUT_SEND,
111 timeout_receive = SNB_TIMEOUT_RECEIVE,
112 )
113 )]
114
115 # Adding the endpoints
116 mgraph = ModuleGraph(modules)
117
118 mgraph.add_endpoint(SNB_CONNECTION_PREFIX + "_bookkeeper_" + HOST2 + BOOKKEEPER_NAME+"_notifications", HOST2 + BOOKKEEPER_NAME + ".notifications", "notification_t", Direction.IN, check_endpoints=False)
119
120 snbmodules_app = App(modulegraph = mgraph, host = HOST, name = HOST+BOOKKEEPER_NAME)
121
122 return snbmodules_app
get_snbmodules_bookkeeper_app(HOST, BOOKKEEPER_PORT=0, BOOKKEEPER_REFRESH_RATE=1, BOOKKEEPER_NAME="bookkeeper", BOOKKEEPER_LOG_PATH="./", SNB_CONNECTION_PREFIX="snbmodules", SNB_TIMEOUT_SEND=10, SNB_TIMEOUT_RECEIVE=100, DEBUG=False)
get_snbmodules_client_app(snbmodules, SNB_CONNECTION_PREFIX="snbmodules", SNB_TIMEOUT_SEND=10, SNB_TIMEOUT_RECEIVE=100, DEBUG=False)