control: Synchronize run based on control state
This MR introduces a monitoring thread that runs concurrently with SCDAQ. This thread listens to external changes to the `ctrl` structure (instigated by the Function Manager) that regulate the start and end of runs, triggering logic to smoothly transition SCDAQ between run states.
Key changes:
- Every call to the InputFilter functor
InputFilter(void*)
checks that the atomicctrl::running
is true, otherwise, the input sends anullptr
to the remaining pipeline stages. This will signal the pipeline teardown once all packets are processed. - A parallel monitoring thread is tasked with polling the contents of the
ctrl
structure, namely the current state and run number, triggering actions needed to start a new run or to wrap a current one, e.g. writing the End-of-Run file. - For efficiency w.r.t. busy-waiting clock cycles, the polling above is implemented through mutexed condition variables.
- Now, SCDAQ starts in a standby state, waiting for the first run number to be received by
session
and thectrl
structure. - Due to the above, the test suite now calls a Python script that emulates the Function Manager sending a
start
command through TCP to begin SCDAQ operations.
Edited by Giovanna Lazzari Miotto