Run States and Transitions

From MidasWiki
Jump to navigation Jump to search


Three Run States define the states of the MIDAS DAQ system:

Stopped, Paused, Running

In order to change from one state to another, MIDAS provides four basic transition functions :


Representation of run states and associated transitions

MIDAS State and Transition Codes

MIDAS provides three State Codes (defined in midas.h) for the three run states (Stopped, Paused and Running).

The run states and their values are:


The current State of an experiment is available under the /Runinfo ODB tree.

The Transition Codes (also defined in midas.h for the four Transitions are:

  • TR_START 1
  • TR_STOP 2
  • TR_PAUSE 4

While a transition is in progress, these Transition Codes will be found under the /Runinfo ODB tree for an experiment.

Run Transition Priority

During these transition periods, any MIDAS client registered to receive notification of such a transition will be able to perform dedicated tasks in either synchronized or asynchronized mode, within the overall run control of the experiment.

In order to provide more flexibility to the transition sequence of all the MIDAS clients connected to a given experiment, each transition function has a transition sequence number attached to it. This transition sequence is used to establish within a given transition the order of the invocation of the MIDAS clients (from the lowest sequence number to the highest). By this means, MIDAS provides the user with full control of the sequencing of any MIDAS client.

Click on the links to see an example of how the transition priority operates at start of run and at end of run.

Registering for a run transition

Any MIDAS client can register to receive notification for a run transition. This notification is done by registering to the system for a given transition ( cm_register_transition() ) by specifying the transition type and the sequencing number (1 to 1000). The following example show registering to the TR_START transition with a sequencing number of 450 and to a TR_STOP transition with a sequencing number of 650.

 INT main()
 cm_register_transition(TR_START, tr_prestart,450);
 cm_register_transition(TR_STOP, tr_poststop,650);
// callback INT tr_prestart(INT run_number, char *error) { // code to perform actions prior to frontend starting return (status); }
// callback INT tr_poststop(INT run_number, char *error) { // code to perform actions after frontend has stopped return (status); }

On a TR_START transition, tr_prestart will run after the logger and event builder, but before the Frontend (see Default Transition Sequence Numbers). On a TR_STOP transition, tr_poststop will run after the frontend, but before the logger and event builder.

Multiple Registration to a Transition

Multiple registration to a given transition can be requested. This last option allows (for example) two callback functions to be invoked before and after a given transition , such as the start of the logger.


// Callback INT before_logger(INT run_number, char *error) { printf("Initialize ... before the logger gets the Start Transition"); ... return CM_SUCCESS; }
// Callback INT after_logger(INT run_number, char *error) { printf("Log initial info to file... after logger gets the Start Transition"); ... return CM_SUCCESS; }
INT main() { ... cm_register_transition(TR_START, before_logger, 100); cm_register_transition(TR_START, after_logger, 300); ... }

Default Transition Sequence Numbers

By default the following sequence numbers are used:


Default Transition Sequence Number

500 500 500 500
500 500 800
500 500 700

Review the Client Transition Sequence Numbers in the ODB

The /System ODB tree contains information specific to each "MIDAS client" currently connected to the experiment. The sequence number appears in the ODB under the /System/Clients subtree.

Change the Client Sequence Number

The /System/Clients subtree reflects the system at a given time. If a permanent change of a client sequence number is required, the MIDAS system call cm_set_transition_sequence() can be used.

Deferred Transitions

Any transition may be deferred until some condition is satisfied. This is usually set up in a frontend (see setup Deferred Transition for further information).