Interacting with the system

Interaction with the Django web app occurs through views, which are just functions and classes that Django calls when certain URLs are requested. Views are used to render the pages of the web app, and they are also how the user tells the system to “do something” like configure a CoBo or refresh the state of an ECC server.

Views are mapped to URLs automatically by Django. This mapping is set up in the module attpcdaq.daq.urls.

Some views render pages that accept information from the user. These generally use a Django form class to process the data.

Since the views serve a number of different purposes, they are organized into a few separate modules in the package attpcdaq.daq.views.

Page rendering views

These views, located in the module attpcdaq.daq.views.pages, are used to render the pages of the web app. This includes functions like status(), which renders the main status page, and others like show_log_page(), which contacts a remote computer, fetches the end of a log file, and renders a page showing it.

Views

status(request) Renders the main status page.
choose_config(request, pk) Renders a page for choosing the config for an ECC server.
experiment_settings(request) Renders the experiment settings page.
show_log_page(request, pk, program) Retrieve and render the log file for the given program.
EasySetupPage(**kwargs) Renders the easy setup page, where the system can be set up in one step.

Backend functions

easy_setup(experiment, num_cobos, ...[, ...]) Create a set of model instances with default values based on the given parameters.

ECC interaction views

A few of the views in the module attpcdaq.daq.views.api are used to interact with the ECC servers and request that they perform some action. These views are called when the user clicks a button to request a state change.

source_change_state(request) Submits a request to tell the ECC server to change a source’s state.
source_change_state_all(request) Send requests to change the state of all ECC servers.

API views

The remaining views in the attpcdaq.daq.views.api module provide an interface to the information stored in the database. These generate pages that allow the user to add, modify, and remove instances of models. There are also views that return information from the database so the GUI can be updated by AJAX calls.

Unlike other views described above, the API views for manipulating database objects are based on classes instead of functions. These are all subclasses of generic views provided by Django, so for more information on these views, take a look at Django’s documentation for class-based views.

Refreshing data

refresh_state_all(request) Fetch the state of all data sources from the database and return the overall state of the system.

Working with data sources

AddDataSourceView(**kwargs) Add a data source.
ListDataSourcesView(**kwargs) List all data sources.
UpdateDataSourceView(**kwargs) Change parameters on a data source.
RemoveDataSourceView(**kwargs) Delete a data source.

Working with data routers

AddDataRouterView(**kwargs) Add a data router.
ListDataRoutersView(**kwargs) List all data routers.
UpdateDataRouterView(**kwargs) Modify a data router.
RemoveDataRouterView(**kwargs) Delete a data router.

Working with ECC servers

AddECCServerView(**kwargs) Add an ECC server.
ListECCServersView(**kwargs) List all ECC servers.
UpdateECCServerView(**kwargs) Modify an ECC server.
RemoveECCServerView(**kwargs) Delete an ECC server.

Working with run metadata

ListRunMetadataView(**kwargs) List the run information for all runs.
UpdateRunMetadataView(**kwargs) Change run metadata
UpdateLatestRunMetadataView(**kwargs) Redirects to UpdateRunMetadataView for the latest run.

Working with Observables

AddObservableView(**kwargs) Add a new observable to the experiment.
ListObservablesView(**kwargs) List the observables registered for this experiment.
UpdateObservableView(**kwargs) Change properties of an Observable.
RemoveObservableView(**kwargs) Remove an observable from this experiment.

Setting the ordering of observables

set_observable_ordering(request) An AJAX request that sets the order in which observables are displayed.

Helper functions

These helper functions are called by some of the views to avoid duplicating code. They are located in the module attpcdaq.daq.views.helpers.

calculate_overall_state(request) Find the overall state of the system.
get_ecc_server_statuses(request) Gets some information about the ECC servers.
get_data_router_statuses(request) Gets some information about the data routers.
get_status(request) Returns some information about the system’s status.