hvl_ccb package

Submodules

hvl_ccb.configuration module

Facilities providing classes for handling configuration for communication protocols and devices.

class hvl_ccb.configuration.ConfigurationMixin(configuration)[source]

Bases: abc.ABC

Mixin providing configuration to a class.

property config

ConfigDataclass property.

Returns

the configuration

abstract static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

configuration_save_json(path: str)None[source]

Save current configuration as JSON file.

Parameters

path – path to the JSON file.

classmethod from_json(filename: str)[source]

Instantiate communication protocol using configuration from a JSON file.

Parameters

filename – Path and filename to the JSON configuration

class hvl_ccb.configuration.EmptyConfig[source]

Bases: object

Empty configuration dataclass.

clean_values()

Cleans and enforces configuration values. Does nothing by default, but may be overridden to add custom configuration value checks.

force_value(fieldname, value)

Forces a value to a dataclass field despite the class being frozen.

NOTE: you can define post_force_value method with same signature as this method to do extra processing after value has been forced on fieldname.

Parameters
  • fieldname – name of the field

  • value – value to assign

is_configdataclass = True
classmethod keys()Sequence[str]

Returns a list of all configdataclass fields key-names.

Returns

a list of strings containing all keys.

classmethod optional_defaults()Dict[str, object]

Returns a list of all configdataclass fields, that have a default value assigned and may be optionally specified on instantiation.

Returns

a list of strings containing all optional keys.

classmethod required_keys()Sequence[str]

Returns a list of all configdataclass fields, that have no default value assigned and need to be specified on instantiation.

Returns

a list of strings containing all required keys.

hvl_ccb.configuration.configdataclass(direct_decoration=None, frozen=True)[source]

Decorator to make a class a configdataclass. Types in these dataclasses are enforced. Implement a function clean_values(self) to do additional checking on value ranges etc.

It is possible to inherit from a configdataclass and re-decorate it with @configdataclass. In a subclass, default values can be added to existing fields. Note: adding additional non-default fields is prone to errors, since the order has to be respected through the whole chain (first non-default fields, only then default-fields).

Parameters

frozen – defaults to True. False allows to later change configuration values. Attention: if configdataclass is not frozen and a value is changed, typing is not enforced anymore!

hvl_ccb.experiment_manager module

Main module containing the top level ExperimentManager class. Inherit from this class to implement your own experiment functionality in another project and it will help you start, stop and manage your devices.

exception hvl_ccb.experiment_manager.ExperimentError[source]

Bases: Exception

Exception to indicate that the current status of the experiment manager is on ERROR and thus no operations can be made until reset.

class hvl_ccb.experiment_manager.ExperimentManager(*args, **kwargs)[source]

Bases: hvl_ccb.dev.base.DeviceSequenceMixin

Experiment Manager can start and stop communication protocols and devices. It provides methods to queue commands to devices and collect results.

add_device(name: str, device: hvl_ccb.dev.base.Device)None[source]

Add a new device to the manager. If the experiment is running, automatically start the device. If a device with this name already exists, raise an exception.

Parameters
  • name – is the name of the device.

  • device – is the instantiated Device object.

Raises

DeviceExistingException

finish()None[source]

Stop experimental setup, stop all devices.

is_error()bool[source]

Returns true, if the status of the experiment manager is error.

Returns

True if on error, false otherwise

is_finished()bool[source]

Returns true, if the status of the experiment manager is finished.

Returns

True if finished, false otherwise

is_running()bool[source]

Returns true, if the status of the experiment manager is running.

Returns

True if running, false otherwise

run()None[source]

Start experimental setup, start all devices.

start()None[source]

Alias for ExperimentManager.run()

property status

Get experiment status.

Returns

experiment status enum code.

stop()None[source]

Alias for ExperimentManager.finish()

class hvl_ccb.experiment_manager.ExperimentStatus(value)[source]

Bases: enum.Enum

Enumeration for the experiment status

ERROR = 5
FINISHED = 4
FINISHING = 3
INITIALIZED = 0
INITIALIZING = -1
RUNNING = 2
STARTING = 1

Module contents

Top-level package for HVL Common Code Base.