attpcdaq.daq.views.api.refresh_state_all

attpcdaq.daq.views.api.refresh_state_all(request)[source]

Fetch the state of all data sources from the database and return the overall state of the system.

The value of the data source state that will be returned is whatever the database says. These values will be returned along with the overall state of the system and some information about the current experiment and run.

Note

This function does not communicate with the ECC server in any way. To contact the ECC server and update the state stored in the database, call attpcdaq.daq.models.ECCServer.refresh_state() instead.

The JSON array returned will contain the following keys:

overall_state
The overall state of the system. If all of the data sources have the same state, this should be the numerical ID of a state. If the sources have different states, it should be -1.
overall_state_name
The name of the overall state of the system. Either a state name or “Mixed” if the state is inconsistent.
run_number
The current run number.
start_time
The date and time when the current run started.
run_duration
The duration of the current run. This is with respect to the current time if the run has not ended.
individual_results
The results for the individual data sources. These are sub-arrays.

The sub arrays for the individual results should include the keys:

success
Whether the request succeeded.
pk
The primary key of the source.
error_message
An error message.
state
The ID of the current state.
state_name
The name of the current state
transitioning
Whether the source is undergoing a state transition.
Parameters:request (HttpRequest) – The request object. The method must be GET.
Returns:An array of dictionaries containing the results from each data source. See above for the contents.
Return type:JsonResponse