Event handling flow of controlStructure of the ProgramInitialization flow controlState transition flow control

State transition flow control

The readout software manages data acquisition as a simple state machine. The state machine is described in the figure labelled Readout State Machine.

Readout State Machine
 

Descriptively:

Inactive In this state, no data is being taken. The trigger thread is not alive. When the program starts, data acquisition is in the inactive state. Valid transitions occur on the begin command (which requests a transition to the Active state), and the end state (which requests that the program exit).
Active In this state data is being acquired. There is a trigger thread that is actively responding to event triggers by reading out associated events. The allowed transitions are initiated by the commands: end (which requests a transition to the inactive state), and pause (which requests a transition to the paused state).
Paused In this state, the run is suspended for possible resumption. Valid state transitions are initiated by the commands: resume, (which requests that the run be returned to the active state so that data taking can be continued) and end (which requests that the run be exited).

All state transitions are initiated from outside the trigger thread. For example, command execution will happen either in the Tcl/Tk guest event loop thread, or within one of the TclServer threads. The flow control breaks into two types of transitions. Those that initiate event taking (transitions into the active state), and those that end event taking (transitions into the inactive, or paused state).

Transitions into the Active state will call the CExperiment::Start(). This function will setup and start two threads of control. The clock thread will manage the timing of scaler readouts and keep a run elapsed time for elapsed time fields of the buffer. The trigger thread wil monitor triggers and, on receipt of one, Call CExperiment::ReadEvent() in the context of its thread to read the event.

Transitions out of the Active state will call the CExperiment::Stop() member function. The trigger thread is halted by calling it's stop function. The stop function sets a stop flag in the threads member data and does a Join operation to wait for the thread to actually exit. The clock thread is also halted in the same way. Without an active trigger thread to initiate event readout and a clock thread to initiate periodic scaler readout, the run is effectively halted.


Report documentation errors to Ron Fox (fox@nscl.msu.edu)or NSCL's Bugzilla page

Event handling flow of controlStructure of the ProgramInitialization flow controlState transition flow control