hvl_ccb.dev.base
digraph inheritance99eb622714 { bgcolor=transparent; rankdir=TB; size=""; "ABC" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Helper class that provides a standard way to create an ABC using"]; "CCBError" [URL="../hvl_ccb.error.html#hvl_ccb.error.CCBError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "ConfigurationMixin" [URL="../hvl_ccb.configuration.html#hvl_ccb.configuration.ConfigurationMixin",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Mixin providing configuration to a class."]; "ABC" -> "ConfigurationMixin" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Device" [URL="../hvl_ccb.dev.base.html#hvl_ccb.dev.base.Device",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base class for devices. Implement this class for a concrete device,"]; "ConfigurationMixin" -> "Device" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ABC" -> "Device" [arrowsize=0.5,style="setlinewidth(0.5)"]; "DeviceError" [URL="../hvl_ccb.dev.base.html#hvl_ccb.dev.base.DeviceError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "CCBError" -> "DeviceError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "DeviceExistingError" [URL="../hvl_ccb.dev.base.html#hvl_ccb.dev.base.DeviceExistingError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Error to indicate that a device with that name already exists."]; "DeviceError" -> "DeviceExistingError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "DeviceFailuresError" [URL="../hvl_ccb.dev.base.html#hvl_ccb.dev.base.DeviceFailuresError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Error to indicate that one or several devices failed."]; "DeviceError" -> "DeviceFailuresError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "DeviceSequenceMixin" [URL="../hvl_ccb.dev.base.html#hvl_ccb.dev.base.DeviceSequenceMixin",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Mixin that can be used on a device or other classes to provide facilities for"]; "ABC" -> "DeviceSequenceMixin" [arrowsize=0.5,style="setlinewidth(0.5)"]; "EmptyConfig" [URL="../hvl_ccb.dev.base.html#hvl_ccb.dev.base.EmptyConfig",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Empty configuration dataclass that is the default configuration for a Device."]; "SingleCommDevice" [URL="../hvl_ccb.dev.base.html#hvl_ccb.dev.base.SingleCommDevice",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base class for devices with a single communication protocol."]; "Device" -> "SingleCommDevice" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ABC" -> "SingleCommDevice" [arrowsize=0.5,style="setlinewidth(0.5)"]; }Module with base classes for devices.
- class Device(dev_config=None)[source]
Bases:
ConfigurationMixin
,ABC
Base class for devices. Implement this class for a concrete device, such as measurement equipment or voltage sources.
Specifies the methods to implement for a device.
- exception DeviceExistingError[source]
Bases:
DeviceError
Error to indicate that a device with that name already exists.
- exception DeviceFailuresError(failures: dict[str, Exception], *args)[source]
Bases:
DeviceError
Error to indicate that one or several devices failed.
- failures: dict[str, Exception]
A dictionary of named devices failures (exceptions).
- class DeviceSequenceMixin(devices: dict[str, hvl_ccb.dev.base.Device])[source]
Bases:
ABC
Mixin that can be used on a device or other classes to provide facilities for handling multiple devices in a sequence.
- add_device(name: str, device: Device) None [source]
Add a new device to the device sequence.
- Parameters:
name – is the name of the device.
device – is the instantiated Device object.
- Raises:
- devices_failed_start: dict[str, hvl_ccb.dev.base.Device]
Dictionary of named device instances from the sequence for which the most recent start() attempt failed.
Empty if stop() was called last; cf. devices_failed_stop.
- devices_failed_stop: dict[str, hvl_ccb.dev.base.Device]
Dictionary of named device instances from the sequence for which the most recent stop() attempt failed.
Empty if start() was called last; cf. devices_failed_start.
- get_device(name: str) Device [source]
Get a device by name.
- Parameters:
name – is the name of the device.
- Returns:
the device object from this sequence.
- get_devices() list[tuple[str, hvl_ccb.dev.base.Device]] [source]
Get list of name, device pairs according to current sequence.
- Returns:
A list of tuples with name and device each.
- remove_device(name: str) Device [source]
Remove a device from this sequence and return the device object.
- Parameters:
name – is the name of the device.
- Returns:
device object or None if such device was not in the sequence.
- Raises:
ValueError – when device with given name was not found
- start() None [source]
Start all devices in this sequence in their added order.
- Raises:
DeviceFailuresError – if one or several devices failed to start
- stop() None [source]
Stop all devices in this sequence in their reverse order.
- Raises:
DeviceFailuresError – if one or several devices failed to stop
- class EmptyConfig[source]
Bases:
object
Empty configuration dataclass that is the default configuration for a Device.
- 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.
- class SingleCommDevice(com, dev_config=None)[source]
Bases:
Device
,ABC
Base class for devices with a single communication protocol.
- property com
Get the communication protocol of this device.
- Returns:
an instance of CommunicationProtocol subtype
- abstract static default_com_cls() type[hvl_ccb.comm.base.CommunicationProtocol] [source]
Get the class for the default communication protocol used with this device.
- Returns:
the type of the standard communication protocol for this device