76 ):
77 """Generate the json configuration for the readout and DF process"""
78
79 trigger_interval_ticks = math.floor((1/TRIGGER_RATE_HZ) * CLOCK_SPEED_HZ/DATA_RATE_SLOWDOWN_FACTOR)
80
81
82 queue_bare_specs = [
83 app.QueueSpec(inst="time_sync_to_netq", kind='FollyMPMCQueue', capacity=100),
84 app.QueueSpec(inst="token_to_netq", kind='FollySPSCQueue', capacity=20),
85 app.QueueSpec(inst="trigger_decision_from_netq", kind='FollySPSCQueue', capacity=20),
86 app.QueueSpec(inst="trigger_decision_copy_for_bookkeeping", kind='FollySPSCQueue', capacity=20),
87 app.QueueSpec(inst="trigger_record_q", kind='FollySPSCQueue', capacity=20),
88 app.QueueSpec(inst="data_fragments_q", kind='FollyMPMCQueue', capacity=100),
89 ] + [
90 app.QueueSpec(inst=f"data_requests_{idx}", kind='FollySPSCQueue', capacity=20)
91 for idx in range(NUMBER_OF_DATA_PRODUCERS)
92 ]
93
94
95
96 queue_specs = app.QueueSpecs(sorted(queue_bare_specs, key=lambda x: x.inst))
97
98
99 mod_specs = [
100 mspec("ntoq_trigdec", "NetworkToQueue", [
101 app.QueueInfo(name="output", inst="trigger_decision_from_netq", dir="output")
102 ]),
103
104 mspec("qton_token", "QueueToNetwork", [
105 app.QueueInfo(name="input", inst="token_to_netq", dir="input")
106 ]),
107
108 mspec("qton_timesync", "QueueToNetwork", [
109 app.QueueInfo(name="input", inst="time_sync_to_netq", dir="input")
110 ]),
111
112 mspec("rqg", "RequestGenerator", [
113 app.QueueInfo(name="trigger_decision_input_queue", inst="trigger_decision_from_netq", dir="input"),
114 app.QueueInfo(name="trigger_decision_for_event_building", inst="trigger_decision_copy_for_bookkeeping", dir="output"),
115 ] + [
116 app.QueueInfo(name=f"data_request_{idx}_output_queue", inst=f"data_requests_{idx}", dir="output")
117 for idx in range(NUMBER_OF_DATA_PRODUCERS)
118 ]),
119
120 mspec("ffr", "FragmentReceiver", [
121 app.QueueInfo(name="trigger_decision_input_queue", inst="trigger_decision_copy_for_bookkeeping", dir="input"),
122 app.QueueInfo(name="trigger_record_output_queue", inst="trigger_record_q", dir="output"),
123 app.QueueInfo(name="data_fragment_input_queue", inst="data_fragments_q", dir="input"),
124 ]),
125
126 mspec("datawriter", "DataWriterModule", [
127 app.QueueInfo(name="trigger_record_input_queue", inst="trigger_record_q", dir="input"),
128 app.QueueInfo(name="token_output_queue", inst="token_to_netq", dir="output"),
129 ]),
130
131 mspec("fake_timesync_source", "FakeTimeSyncSource", [
132 app.QueueInfo(name="time_sync_sink", inst="time_sync_to_netq", dir="output"),
133 ]),
134
135 ] + [
136
137 mspec(f"fakedataprod_{idx}", "FakeDataProdModule", [
138 app.QueueInfo(name="data_request_input_queue", inst=f"data_requests_{idx}", dir="input"),
139 app.QueueInfo(name="data_fragment_output_queue", inst="data_fragments_q", dir="output"),
140 ]) for idx in range(NUMBER_OF_DATA_PRODUCERS)
141 ]
142
143 init_specs = app.Init(queues=queue_specs, modules=mod_specs)
144
145 initcmd = rccmd.RCCommand(
146 id=basecmd.CmdId("init"),
147 entry_state="NONE",
148 exit_state="INITIAL",
149 data=init_specs
150 )
151
152 confcmd = mrccmd("conf", "INITIAL", "CONFIGURED",[
153 ("ntoq_trigdec", ntoq.Conf(msg_type="dunedaq::dfmessages::TriggerDecision",
154 msg_module_name="TriggerDecisionNQ",
155 receiver_config=nor.Conf(ipm_plugin_type="ZmqReceiver",
156 address=network_endpoints["trigdec"])
157 )
158 ),
159
160 ("qton_token", qton.Conf(msg_type="dunedaq::dfmessages::TriggerDecisionToken",
161 msg_module_name="TriggerDecisionTokenNQ",
162 sender_config=nos.Conf(ipm_plugin_type="ZmqSender",
163 address=network_endpoints["triginh"],
164 stype="msgpack")
165 )
166 ),
167
168 ("qton_timesync", qton.Conf(msg_type="dunedaq::dfmessages::TimeSync",
169 msg_module_name="TimeSyncNQ",
170 sender_config=nos.Conf(ipm_plugin_type="ZmqSender",
171 address=network_endpoints["timesync"],
172 stype="msgpack")
173 )
174 ),
175
176 ("rqg", rqg.ConfParams(
177 map=rqg.mapgeoidqueue([
178 rqg.geoidinst(apa=0, link=idx, queueinstance=f"data_requests_{idx}") for idx in range(NUMBER_OF_DATA_PRODUCERS)
179 ])
180 )),
181 ("ffr", ffr.ConfParams(
182 general_queue_timeout=QUEUE_POP_WAIT_MS
183 )),
184 ("datawriter", dw.ConfParams(
185 initial_token_count=TOKEN_COUNT,
186 data_store_parameters=hdf5ds.ConfParams(
187 name="data_store",
188
189 directory_path = OUTPUT_PATH,
190
191 max_file_size_bytes = 1073741834,
192 disable_unique_filename_suffix = False,
193 filename_parameters = hdf5ds.HDF5DataStoreFileNameParams(
194 overall_prefix = "fake_minidaqapp",
195
196 file_index_prefix = "file"
197 ),
198 file_layout_parameters = hdf5ds.HDF5DataStoreFileLayoutParams(
199 trigger_record_name_prefix= "TriggerRecord",
200 digits_for_trigger_number = 5,
201 )
202 )
203 )),
204 ("fake_timesync_source", ftss.ConfParams(
205 sync_interval_ticks = (CLOCK_SPEED_HZ/DATA_RATE_SLOWDOWN_FACTOR),
206 clock_frequency_hz = (CLOCK_SPEED_HZ/DATA_RATE_SLOWDOWN_FACTOR),
207 )),
208 ] + [
209 (f"fakedataprod_{idx}", fdp.ConfParams(
210 temporarily_hacked_link_number = idx
211 )) for idx in range(NUMBER_OF_DATA_PRODUCERS)
212 ])
213
214 startpars = rccmd.StartParams(run=RUN_NUMBER, disable_data_storage=DISABLE_OUTPUT)
215 startcmd = mrccmd("start", "CONFIGURED", "RUNNING", [
216 ("ntoq_trigdec", startpars),
217 ("qton_token", startpars),
218 ("qton_timesync", startpars),
219 ("datawriter", startpars),
220 ("ffr", startpars),
221 ("fakedataprod_.*", startpars),
222 ("rqg", startpars),
223 ("fake_timesync_source", startpars),
224 ])
225
226 stopcmd = mrccmd("stop", "RUNNING", "CONFIGURED", [
227 ("ntoq_trigdec", None),
228 ("qton_timesync", None),
229 ("qton_token", None),
230 ("fake_timesync_source", None),
231 ("rqg", None),
232 ("fakedataprod_.*", None),
233 ("ffr", None),
234 ("datawriter", None),
235 ])
236
237 scrapcmd = mcmd("scrap", [
238 ("", None)
239 ])
240
241
242 cmd_seq = [initcmd, confcmd, startcmd, stopcmd, scrapcmd]
243
244
245 jstr = json.dumps([c.pod() for c in cmd_seq], indent=4, sort_keys=True)
246 return jstr
247
248