This chapter attempts to document the order of important operations done during environment transitions. Since AliECS is an evolving system, the information presented here might be out-of-date, thus please refer to event handling in core/environment/environment.go and plugin calls in ControlWorkflows/workflows/readout-dataflow.yaml for the ultimate source of truth. Also, please report to the ECS developers any inaccuracies.
State Machine Callbacks documents the order of callbacks that can be associated with state machine transitions.
This is the order of actions happening at a healthy start of run.
before_START_ACTIVITYhooks with negative weights are executed:trg.PrepareForRun()at-200
"run_number"is set."run_start_time_ms"is set using the current time. It is considered as the SOR and SOSOR timestamps.before_START_ACTIVITYhooks with positive weights (incl. 0) are executed:trg.RunLoad(),bookkeeping.StartOfRun()at10bookkeeping.RetrieveFillInfo()at11kafka.PublishStartActivityUpdate()at50dcs.StartOfRun(),odc.Start()(does not need to return now),ccdb.RunStart()at100
leave_CONFIGUREDhooks are executed:kafka.PublishLeaveStateUpdate()at0
- Fill Info previously retrieved by the BKP plugin is read from the variable stack and put into transition message to tasks
- Tasks are transitioned to
RUNNING - If everything succeeds up to this point, we report that the run has started
enter_RUNNINGhooks are executedo2-roc-ctp-emulatorfor all ROC CTP emulator endpoints,kafka.PublishEnterStateUpdate()at0
after_START_ACTIVITYhooks with negative weights are executedtrg.RunStart()at-10- waiting until
odc.Start()executed atbefore_START_ACTIVITY+100completes at-10
"run_start_completion_time_ms"is set using current time. It is considered as the EOSOR timestamp.after_START_ACTIVITYhooks with positive weights (incl. 0) are executed:bookkeeping.UpdateRunStart(),bookkeeping.UpdateEnv()at+100
This is the order of actions happening at a healthy end of run.
before_STOP_ACTIVITYhooks with negative weights are executedtrg.RunStop()at-10
"run_end_time_ms"is set using the current time. It is considered as the EOR and SOEOR timestamps.before_STOP_ACTIVITYhooks with positive weights (incl. 0) are executed:odc.Stop()(does not need to return now) at0
leave_RUNNINGhooks are executedkafka.PublishLeaveStateUpdate()at0
- Tasks are transitioned to
CONFIGURED - If everything succeeds up to this point, we consider that the run has stopped
enter_CONFIGUREDhooks are executedkafka.PublishEnterStateUpdate()at0
after_STOP_ACTIVITYhooks with negative weights are executed:trg.RunUnload()at-100dcs.EndOfRun()at-50- waiting until
odc.Stop()executed atbefore_STOP_ACTIVITYcompletes at-50
"run_end_completion_time_ms"is set using current time. It is considered as the EOEOR timestamp.after_STOP_ACTIVITYhooks with positive weights (incl. 0) are executed:ccdb.RunStop()at0bookkeeping.UpdateRunStop(),bookkeeping.UpdateEnv()at+100
The DCS integration plugin exposes to the workflow template (WFT) context the following operations. Their associated transitions in this table refer to the readout-dataflow workflow template.
| DCS operation | WFT call | Call timing | Critical | Contingent on detector state |
|---|---|---|---|---|
| Prepare For Run (PFR) | dcs.PrepareForRun |
during CONFIGURE |
false |
yes |
| Start Of Run (SOR) | dcs.StartOfRun |
early in START_ACTIVITY |
true |
yes |
| End Of Run (EOR) | dcs.EndOfRun |
late in STOP_ACTIVITY |
true |
no |
The DCS integration plugin subscribes to the DCS service and continually receives information on operation-state compatibility for all detectors. When a given environment reaches a DCS call, the relevant DCS operation will be called only if the DCS service reports that all detectors in that environment are compatible with this operation, except EOR, which is always called.
Unlike SOR and EOR, which are mandatory if dcs_enabled is set to true,
an impossibility to run PFR or a PFR failure will not prevent the
environment from transitioning forward.
When dcs.PrepareForRun is called, if at least one detector is in a
state that is incompatible with PFR as reported by the DCS service,
a grace period of 10 seconds is given for the detector(s) to become
compatible with PFR, with 1Hz polling frequency. As soon as all
detectors become compatible with PFR, the PFR operation is requested
to the DCS service.
If the grace period ends and at least one detector included in the environment is still incompatible with PFR, the PFR operation will not run for any detector.
However, the environment
can still transition forward towards the RUNNING state, and any DCS
activities that would have taken place in PFR will instead happen
during SOR. Only at that point, if at least one detector is not
compatible with SOR (or if it is but SOR fails), will the environment
declare a failure.
When dcs.PrepareForRun is called, if all detectors are compatible
with PFR as reported by the DCS service (or become compatible during
the grace period), the PFR operation is immediately requested to the
DCS service.
If this operation fails for one or more detectors, the
dcs.PrepareForRun call as a whole is considered to have failed,
but since it is non-critical the environment may still reach the
CONFIGURED state and transition forward towards RUNNING.
As in the case of an impossibility to run PFR, any DCS activities that would have taken place in PFR will instead be done during SOR.
The SOR operation is mandatory if dcs_enabled is set to true
(AliECS GUI "DCS" switched on).
When dcs.StartOfRun is called, if at least one detector is in a
state that is incompatible with SOR as reported by the DCS service,
or if after a grace period of 10 seconds at least one detector is
still incompatible with SOR, the SOR operation will not run for any
detector.
The environment will then declare a failure, the
START_ACTIVITY transition will be blocked and the environment
will move to ERROR.
When dcs.StartOfRun is called, if all detectors are compatible
with SOR as reported by the DCS service (or become compatible during
the grace period), the SOR operation is immediately requested to the
DCS service.
If this operation fails for one or more detectors, the
dcs.StartOfRun call as a whole is considered to have failed.
The environment will then declare a failure, the
START_ACTIVITY transition will be blocked and the environment
will move to ERROR
The EOR operation is mandatory if dcs_enabled is set to true
(AliECS GUI "DCS" switched on). However, unlike with PFR and SOR, there
is no check for compatibility with the EOR operation. The EOR
request will always be sent to the DCS service during STOP_ACTIVITY.
If this operation fails for one or more detectors, the
dcs.EndOfRun call as a whole is considered to have failed.
The environment will then declare a failure, the
STOP_ACTIVITY transition will be blocked and the environment
will move to ERROR.