DataSourceManager

Name

DataSourceManager -- Data source manager and its API

Synopsis

package require DataSourceManager

set singleton [DataSourcemanagerSingleton %AUTO%]

set providers [DataSourceManager::enumerateProviders]

$singelton load provider-name

set params \ [$singleton parameters provider-name]

set caps \ [$singleton capabilities provider-name]

set caps \ [$singleton systemCapabilities]

$singleton addSource provider-name param-dict

set sourceid \ [$singleton removeSource id]

set status [$singleton check]

set source-descriptions [$singleton sources]

$singleton stop id

$singleton stopAll

$singleton startAll

$singleton begin run-number title

$singleton end

$singleton pause

$singleton resume

$singleton init

$singleton initall

DESCRIPTION

The DataSourceManager is in charge of maintaining knowledge of the data source providers and active data sources. The DataSourceManager as used in the ReadoutGUI is a singleton object. Rather than directly instantiating a DataSourceManager your code should instantiate a DataSourcemanagerSingleton. Doing so generates a Facade object that wraps the one and only data source manager the ReadoutGUI uses. The resulting object exports and delegates all methods to the underlying singleton.

TYPE METHODS

DataSourceManager::enumerateProviders

Returns a list of the names of the data source providers known at the time of the call. For more information on data source providers see Introduction and the interaces its related pages describe...

The set of providers is determined by the set of packages that can be located and loaded with names appropriate to that of a data source provider. No attempt is made to determine if these packages contain code that actually meets all the requirements of a data source provider.

METHODS

The public methods provided by the data source manage are:

load provider-name

Loads a data source provider package. Note that:

  • provider-name is the name of the provider not the name of the provider's package (e.g SSH not SSH_Provider).

  • For the load to be successful the provider's package must be locatable via the normal Tcl package require command. For custom providers this may necessitate changes to the ::auto_path variable.

Until a package is loaded nothing can be done with it. You must use the load method rather than directly doing a package require as the data source manager maintains a list of registered packages.

parameters provider-name

Returns a dict that describes the parameterization required by data sources that provider-name manages. See Introduction for a description of this dict.

If you are not familiar with Tcl dicts see http://www.tcl.tk/man/tcl8.5/TclCmd/dict.htm for a description of dicts and the command ensemble that acts on them.

capabilities provider-name

Returns a dict that describes the capabilities of provider-name. The form of this dict is described in Introduction.

systemCapabilities

Returns the minimal set of capabilities the data sources have. This is the intersection of the capabilities of all providers that are represented by data sources that have been added to the manager.

Another way to look at this method is that it returns a dict of capabilities that all sources have. For example, if two data sources have been added to the manager, one of them capable of pausing a run and the other not, the resulting dict will show that the system cannot pause runs. The form of this dict is described in Introduction.

addSource provider-name params

Adds a data source to the manager. provider-name defines the name of the data source provider that will manage the source. params is a dict that defines the actual parameterization of this source. The keys in this dictionary are determined by the result of parameters for the provider.

Note that the source is not yet started. See startAll below. Note as well that this method allocates and defines the source id for the data source. That implies that if the params dict has a sourceid key its value will be overwritten when the parameterization is stored internally by the manager.

The result of this method is a unique source id which can be used to identify this source when calling methods that work on a single source.

removeSource source-id

Removes a source (the inverse of addSource) from the manager. If the soure is running, it is stopped first. source-id is the source id returned from the call to addSource that added the source to the manager.

It is an error to attempt to remove a nonexsitent source.

check

Checks the liveness of all data sources. This returns a dict whose keys are data source ids and whose values are the results of check on those data sources.

sources

Returns information about all of the sources that have been added to the manager. The result is a list ofr dicts. Each dict contains the parameterization of the data source as well as keys for sourceid which has the source id as a value and provider which is the name of the provider that manages this source when it is running.

stop source-id

Stops the single source identified by source-id.

stopAll

Stops all data sources.

startAll

Starts all data sources that have been added.

In addition to the data source manipulation methods described above, the manager also exports run control methods. It is better, however to force run state transitions to happen via the RunStateMachine. In that way other actions associated with run state transitions can occur.

For completeness, the run state control methods are described below. The operate by iterating over the running data sources and delegating the method to their provider.

begin run-number title

Starts a run in all of the providers. The run-number and title parameters are passed without interpretation to the provider's begin command for each data source.

end

Iterates over all data sources calling end for them in their data source provider.

pause

Iterates over all data sources pausing them in the middle of an active run. Before invoking this method, the caller must ensure all data sources implement the pause operation by using systemCapabilities to get the intersection of all data source capabilites.

resume

Iterates over all data sources resuming the paused run.

init

Calls the init proc for the provider whose index is id.

initall

Iterates through all of the data sources and calls their respective init procs.