exopy.instruments.plugin module

Instrument manager plugin.

exopy.instruments.plugin.validate_user(user)[source]

Validate that the user does declare a validate method if its policy is releasable.

exopy.instruments.plugin.validate_starter(starter)[source]

Validate a starter declaration by checking for members and provided starter.

class exopy.instruments.plugin.InstrumentManagerPlugin[source]

Bases: exopy.utils.plugin_tools.HasPreferencesPlugin

The instrument plugin manages the instrument drivers and their use.

profiles

List of the known instrument profile ids.

instruments

List of instruments for which at least one driver is declared.

users

List of registered intrument users. Only registered users can be granted the use of an instrument.

starters

List of registered instrument starters.

connections

List of registered connection types.

settings

List of registered settings.

used_profiles

Currently used profiles. This dict should be edited by user code.

start()[source]

Start the plugin lifecycle by collecting all contributions.

stop()[source]

Stop the plugin and remove all observers.

create_connection(connection_id, infos, read_only=False)[source]

Create a connection and initialize it.

Parameters
  • connection_id (unicode) – Id of the the connection to instantiate.

  • infos (dict) – Dictionarry to use to initialize the state of the connection.

  • read_only (bool) – Should the connection be created as read-only.

Returns

connection – Ready to use widget.

Return type

BaseConnection

create_settings(settings_id, infos, read_only=False)[source]

Create a settings and initialize it.

Parameters
  • settings_id (unicode) – Id of the the settings to instantiate.

  • infos (dict) – Dictionary to use to initialize the state of the settings.

  • read_only (bool) – Should the settings be created as read-only.

Returns

connection – Ready to use widget.

Return type

BaseSettings

get_drivers(drivers)[source]

Query drivers class and the associated starters.

Parameters

drivers (list) – List of driver ids for which the matching class should be returned.

Returns

  • drivers (dict) – Requested drivers and associated starter indexed by id.

  • missing (list) – List of ids which do not correspond to any known valid driver.

get_profiles(user_id, profiles, try_release=True, partial=False)[source]

Query profiles for use by a declared user.

Parameters
  • user_id (unicode) – Id of the user which request the authorization to use the instrument.

  • profiles (list) – Ids of the instrument profiles which are requested.

  • try_release (bool, optional) – Should we attempt to release currently used profiles.

  • partial (bool, optional) – Should only a subset of the requested profiles be returned if some profiles are not available.

Returns

  • profiles (dict) – Requested profiles as a dictionary.

  • unavailable (list) – List of profiles that are not currently available and cannot be released.

release_profiles(user_id, profiles)[source]

Release some previously acquired profiles.

The user should not maintain any communication with the instruments whose profiles have been released after calling this method.

Parameters
  • user_id (unicode) – Id of the user releasing the profiles.

  • profiles (iterable) – Profiles (ids) which are no longer needed by the user.

get_aliases(manufacturer)[source]

List the known aliases of a manufacturer.

Parameters

manufacturer (str) – Name of the manufacturer for which to return the aliases.

Returns

aliases – Known aliases of the manufacturer.

Return type

list[unicode]