Skip to content

psdaq.control.TimedRun

TimedRun(control, *, daqState, args) moves a DAQ between states for a run of fixed length; psdaq/psdaq/control/lab3_timed_run.py is the example script. control is a DaqControl object (the code only calls its setState and monitorStatus), daqState is the state returned by control.getState(), and args is the parsed command line (the constructor reads args.v). The constructor starts two daemon threads: one requests the states with control.setState, the other reads control.monitorStatus() and updates daqState. stage() and unstage() request connected, set_running_state() requests running; each call waits until the requesting thread reports that the state was reached (it never reports this if setState returns an error). Send 'shutdown' on push_socket to stop the requesting thread.

See DAQ control.

psdaq.control.TimedRun

Helper class that drives the DAQ through state changes for a timed run.

TimedRun

TimedRun(control, *, daqState, args)

Drive a DAQ control object between states using two background threads.

On construction it binds/connects an inproc PUSH/PULL socket pair ('inproc://timed_run') and starts daq_communicator_thread and daq_monitor_thread as daemon threads. control must provide setState and monitorStatus.

daq_communicator_thread

daq_communicator_thread()

Loop forever, requesting the DAQ states received on the inproc PULL socket.

Each message is split on the first ',' into a state and an unused second part. A valid state (in ControlDef.states) is requested with control.setState; the thread then waits on daqState_cv until daqState equals it and sets the ready event. Returns when 'shutdown' is received; logs an error for other input or on a setState error.

daq_monitor_thread

daq_monitor_thread()

Loop forever, updating daqState from control.monitorStatus().

Stops when the first returned part is None. For 'error'/'warning' the second part is logged; parts whose first element is not in ControlDef.transitions (and is not 'error'/'warning') are ignored. Otherwise daqState is set to the second part and daqState_cv is notified.

sleep

sleep(secs)

Sleep for secs seconds with debug log messages before and after.

set_connected_state

set_connected_state()

Request the 'connected' state and block until the communicator thread sets ready.

set_running_state

set_running_state()

Request the 'running' state and block until the communicator thread sets ready.

stage

stage()

Put the DAQ in the 'connected' state (calls set_connected_state).

unstage

unstage()

Put the DAQ in the 'connected' state (calls set_connected_state).