hvl_ccb.dev package

Submodules

hvl_ccb.dev.base module

Module with base classes for devices.

class hvl_ccb.dev.base.Device(dev_config=None)[source]

Bases: hvl_ccb.configuration.ConfigurationMixin, abc.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.

static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

abstract start()None[source]

Start or restart this Device. To be implemented in the subclass.

abstract stop()None[source]

Stop this Device. To be implemented in the subclass.

exception hvl_ccb.dev.base.DeviceExistingException[source]

Bases: Exception

Exception to indicate that a device with that name already exists.

exception hvl_ccb.dev.base.DeviceFailuresException(failures: Dict[str, Exception], *args)[source]

Bases: Exception

Exception to indicate that one or several devices failed.

failures: Dict[str, Exception]

A dictionary of named devices failures (exceptions).

class hvl_ccb.dev.base.DeviceSequenceMixin(devices: Dict[str, hvl_ccb.dev.base.Device])[source]

Bases: abc.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: hvl_ccb.dev.base.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

DeviceExistingException

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)hvl_ccb.dev.base.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)hvl_ccb.dev.base.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

DeviceFailuresException – if one or several devices failed to start

stop()None[source]

Stop all devices in this sequence in their reverse order.

Raises

DeviceFailuresException – if one or several devices failed to stop

class hvl_ccb.dev.base.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 hvl_ccb.dev.base.SingleCommDevice(com, dev_config=None)[source]

Bases: hvl_ccb.dev.base.Device, abc.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

start()None[source]

Open the associated communication protocol.

stop()None[source]

Close the associated communication protocol.

hvl_ccb.dev.crylas module

Device classes for a CryLas pulsed laser controller and a CryLas laser attenuator, using serial communication.

There are three modes of operation for the laser 1. Laser-internal hardware trigger (default): fixed to 20 Hz and max energy per pulse. 2. Laser-internal software trigger (for diagnosis only). 3. External trigger: required for arbitrary pulse energy or repetition rate. Switch to “external” on the front panel of laser controller for using option 3.

After switching on the laser with laser_on(), the system must stabilize for some minutes. Do not apply abrupt changes of pulse energy or repetition rate.

Manufacturer homepage: https://www.crylas.de/products/pulsed_laser.html

class hvl_ccb.dev.crylas.CryLasAttenuator(com, dev_config=None)[source]

Bases: hvl_ccb.dev.base.SingleCommDevice

Device class for the CryLas laser attenuator.

property attenuation
static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

static default_com_cls()[source]

Get the class for the default communication protocol used with this device.

Returns

the type of the standard communication protocol for this device

set_attenuation(percent: Union[int, float])None[source]

Set the percentage of attenuated light (inverse of set_transmission). :param percent: percentage of attenuation, number between 0 and 100 :raises ValueError: if param percent not between 0 and 100 :raises SerialCommunicationIOError: when communication port is not opened :raises CryLasAttenuatorError: if the device does not confirm success

set_init_attenuation()[source]

Sets the attenuation to its configured initial/default value

Raises

SerialCommunicationIOError – when communication port is not opened

set_transmission(percent: Union[int, float])None[source]

Set the percentage of transmitted light (inverse of set_attenuation). :param percent: percentage of transmitted light :raises ValueError: if param percent not between 0 and 100 :raises SerialCommunicationIOError: when communication port is not opened :raises CryLasAttenuatorError: if the device does not confirm success

start()None[source]

Open the com, apply the config value ‘init_attenuation’

Raises

SerialCommunicationIOError – when communication port cannot be opened

property transmission
class hvl_ccb.dev.crylas.CryLasAttenuatorConfig(init_attenuation: Union[int, float] = 0, response_sleep_time: Union[int, float] = 1)[source]

Bases: object

Device configuration dataclass for CryLas attenuator.

clean_values()[source]
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

init_attenuation: Union[int, float] = 0
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.

response_sleep_time: Union[int, float] = 1
exception hvl_ccb.dev.crylas.CryLasAttenuatorError[source]

Bases: Exception

General error with the CryLas Attenuator.

class hvl_ccb.dev.crylas.CryLasAttenuatorSerialCommunication(configuration)[source]

Bases: hvl_ccb.comm.serial.SerialCommunication

Specific communication protocol implementation for the CryLas attenuator. Already predefines device-specific protocol parameters in config.

static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

class hvl_ccb.dev.crylas.CryLasAttenuatorSerialCommunicationConfig(terminator: bytes = b'', encoding: str = 'utf-8', encoding_error_handling: str = 'replace', wait_sec_read_text_nonempty: Union[int, float] = 0.5, default_n_attempts_read_text_nonempty: int = 10, port: Union[str, NoneType] = None, baudrate: int = 9600, parity: Union[str, hvl_ccb.comm.serial.SerialCommunicationParity] = <SerialCommunicationParity.NONE: 'N'>, stopbits: Union[int, hvl_ccb.comm.serial.SerialCommunicationStopbits] = <SerialCommunicationStopbits.ONE: 1>, bytesize: Union[int, hvl_ccb.comm.serial.SerialCommunicationBytesize] = <SerialCommunicationBytesize.EIGHTBITS: 8>, timeout: Union[int, float] = 3)[source]

Bases: hvl_ccb.comm.serial.SerialCommunicationConfig

baudrate: int = 9600

Baudrate for CryLas attenuator is 9600 baud

bytesize: Union[int, hvl_ccb.comm.serial.SerialCommunicationBytesize] = 8

One byte is eight bits long

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

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.

parity: Union[str, hvl_ccb.comm.serial.SerialCommunicationParity] = 'N'

CryLas attenuator does not use parity

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.

stopbits: Union[int, hvl_ccb.comm.serial.SerialCommunicationStopbits] = 1

CryLas attenuator uses one stop bit

terminator: bytes = b''

No terminator

timeout: Union[int, float] = 3

use 3 seconds timeout as default

class hvl_ccb.dev.crylas.CryLasLaser(com, dev_config=None)[source]

Bases: hvl_ccb.dev.base.SingleCommDevice

CryLas laser controller device class.

class AnswersShutter(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: aenum.Enum

Standard answers of the CryLas laser controller to ‘Shutter’ command passed via com.

CLOSED = 'Shutter inaktiv'
OPENED = 'Shutter aktiv'
class AnswersStatus(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: aenum.Enum

Standard answers of the CryLas laser controller to ‘STATUS’ command passed via com.

ACTIVE = 'STATUS: Laser active'
HEAD = 'STATUS: Head ok'
INACTIVE = 'STATUS: Laser inactive'
READY = 'STATUS: System ready'
TEC1 = 'STATUS: TEC1 Regulation ok'
TEC2 = 'STATUS: TEC2 Regulation ok'
class LaserStatus(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: aenum.Enum

Status of the CryLas laser

READY_ACTIVE = 2
READY_INACTIVE = 1
UNREADY_INACTIVE = 0
property is_inactive
property is_ready
class RepetitionRates(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: aenum.IntEnum

Repetition rates for the internal software trigger in Hz

HARDWARE = 0
SOFTWARE_INTERNAL_SIXTY = 60
SOFTWARE_INTERNAL_TEN = 10
SOFTWARE_INTERNAL_TWENTY = 20
ShutterStatus

alias of hvl_ccb.dev.crylas.CryLasLaserShutterStatus

close_shutter()None[source]

Close the laser shutter.

Raises
static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

static default_com_cls()[source]

Get the class for the default communication protocol used with this device.

Returns

the type of the standard communication protocol for this device

get_pulse_energy_and_rate()Tuple[int, int][source]

Use the debug mode, return the measured pulse energy and rate.

Returns

(energy in micro joule, rate in Hz)

Raises
laser_off()None[source]

Turn the laser off.

Raises
laser_on()None[source]

Turn the laser on.

Raises
open_shutter()None[source]

Open the laser shutter.

Raises
set_init_shutter_status()None[source]

Open or close the shutter, to match the configured shutter_status.

Raises
set_pulse_energy(energy: int)None[source]

Sets the energy of pulses (works only with external hardware trigger). Proceed with small energy steps, or the regulation may fail.

Parameters

energy – energy in micro joule

Raises
set_repetition_rate(rate: Union[int, hvl_ccb.dev.crylas.CryLasLaser.RepetitionRates])None[source]

Sets the repetition rate of the internal software trigger.

Parameters

rate – frequency (Hz) as an integer

Raises
start()None[source]

Opens the communication protocol and configures the device.

Raises

SerialCommunicationIOError – when communication port cannot be opened

stop()None[source]

Stops the device and closes the communication protocol.

Raises
property target_pulse_energy
update_laser_status()None[source]

Update the laser status to LaserStatus.NOT_READY or LaserStatus.INACTIVE or LaserStatus.ACTIVE.

Note: laser never explicitly says that it is not ready ( LaserStatus.NOT_READY) in response to ‘STATUS’ command. It only says that it is ready (heated-up and implicitly inactive/off) or active (on). If it’s not either of these then the answer is Answers.HEAD. Moreover, the only time the laser explicitly says that its status is inactive ( Answers.INACTIVE) is after issuing a ‘LASER OFF’ command.

Raises

SerialCommunicationIOError – when communication port is not opened

update_repetition_rate()None[source]

Query the laser repetition rate.

Raises
update_shutter_status()None[source]

Update the shutter status (OPENED or CLOSED)

Raises
update_target_pulse_energy()None[source]

Query the laser pulse energy.

Raises
wait_until_ready()None[source]

Block execution until the laser is ready

Raises

CryLasLaserError – if the polling thread stops before the laser is ready

class hvl_ccb.dev.crylas.CryLasLaserConfig(calibration_factor: Union[int, float] = 4.35, polling_period: Union[int, float] = 12, polling_timeout: Union[int, float] = 300, auto_laser_on: bool = True, init_shutter_status: Union[int, hvl_ccb.dev.crylas.CryLasLaserShutterStatus] = <CryLasLaserShutterStatus.CLOSED: 0>)[source]

Bases: object

Device configuration dataclass for the CryLas laser controller.

ShutterStatus

alias of hvl_ccb.dev.crylas.CryLasLaserShutterStatus

auto_laser_on: bool = True
calibration_factor: Union[int, float] = 4.35
clean_values()[source]
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

init_shutter_status: Union[int, hvl_ccb.dev.crylas.CryLasLaserShutterStatus] = 0
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.

polling_period: Union[int, float] = 12
polling_timeout: Union[int, float] = 300
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.

exception hvl_ccb.dev.crylas.CryLasLaserError[source]

Bases: Exception

General error with the CryLas Laser.

exception hvl_ccb.dev.crylas.CryLasLaserNotReadyError[source]

Bases: hvl_ccb.dev.crylas.CryLasLaserError

Error when trying to turn on the CryLas Laser before it is ready.

class hvl_ccb.dev.crylas.CryLasLaserPoller(spoll_handler: Callable, check_handler: Callable, check_laser_status_handler: Callable, polling_delay_sec: Union[int, float] = 0, polling_interval_sec: Union[int, float] = 1, polling_timeout_sec: Optional[Union[int, float]] = None)[source]

Bases: hvl_ccb.dev.utils.Poller

Poller class for polling the laser status until the laser is ready.

Raises
class hvl_ccb.dev.crylas.CryLasLaserSerialCommunication(configuration)[source]

Bases: hvl_ccb.comm.serial.SerialCommunication

Specific communication protocol implementation for the CryLas laser controller. Already predefines device-specific protocol parameters in config.

READ_TEXT_SKIP_PREFIXES = ('>', 'MODE:')

Prefixes of lines that are skipped when read from the serial port.

static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

query(cmd: str, prefix: str, post_cmd: Optional[str] = None)str[source]

Send a command, then read the com until a line starting with prefix, or an empty line, is found. Returns the line in question.

Parameters
  • cmd – query message to send to the device

  • prefix – start of the line to look for in the device answer

  • post_cmd – optional additional command to send after the query

Returns

line in question as a string

Raises

SerialCommunicationIOError – when communication port is not opened

query_all(cmd: str, prefix: str)[source]

Send a command, then read the com until a line starting with prefix, or an empty line, is found. Returns a list of successive lines starting with prefix.

Parameters
  • cmd – query message to send to the device

  • prefix – start of the line to look for in the device answer

Returns

line in question as a string

Raises

SerialCommunicationIOError – when communication port is not opened

read()str[source]

Read first line of text from the serial port that does not start with any of self.READ_TEXT_SKIP_PREFIXES.

Returns

String read from the serial port; ‘’ if there was nothing to read.

Raises

SerialCommunicationIOError – when communication port is not opened

class hvl_ccb.dev.crylas.CryLasLaserSerialCommunicationConfig(terminator: bytes = b'\n', encoding: str = 'utf-8', encoding_error_handling: str = 'replace', wait_sec_read_text_nonempty: Union[int, float] = 0.5, default_n_attempts_read_text_nonempty: int = 10, port: Union[str, NoneType] = None, baudrate: int = 19200, parity: Union[str, hvl_ccb.comm.serial.SerialCommunicationParity] = <SerialCommunicationParity.NONE: 'N'>, stopbits: Union[int, hvl_ccb.comm.serial.SerialCommunicationStopbits] = <SerialCommunicationStopbits.ONE: 1>, bytesize: Union[int, hvl_ccb.comm.serial.SerialCommunicationBytesize] = <SerialCommunicationBytesize.EIGHTBITS: 8>, timeout: Union[int, float] = 10)[source]

Bases: hvl_ccb.comm.serial.SerialCommunicationConfig

baudrate: int = 19200

Baudrate for CryLas laser is 19200 baud

bytesize: Union[int, hvl_ccb.comm.serial.SerialCommunicationBytesize] = 8

One byte is eight bits long

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

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.

parity: Union[str, hvl_ccb.comm.serial.SerialCommunicationParity] = 'N'

CryLas laser does not use parity

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.

stopbits: Union[int, hvl_ccb.comm.serial.SerialCommunicationStopbits] = 1

CryLas laser uses one stop bit

terminator: bytes = b'\n'

The terminator is LF

timeout: Union[int, float] = 10

use 10 seconds timeout as default (a long timeout is needed!)

class hvl_ccb.dev.crylas.CryLasLaserShutterStatus(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: aenum.Enum

Status of the CryLas laser shutter

CLOSED = 0
OPENED = 1

hvl_ccb.dev.ea_psi9000 module

Device class for controlling a Elektro Automatik PSI 9000 power supply over VISA.

It is necessary that a backend for pyvisa is installed. This can be NI-Visa oder pyvisa-py (up to know, all the testing was done with NI-Visa)

class hvl_ccb.dev.ea_psi9000.PSI9000(com: Union[hvl_ccb.dev.ea_psi9000.PSI9000VisaCommunication, hvl_ccb.dev.ea_psi9000.PSI9000VisaCommunicationConfig, dict], dev_config: Optional[Union[hvl_ccb.dev.ea_psi9000.PSI9000Config, dict]] = None)[source]

Bases: hvl_ccb.dev.visa.VisaDevice

Elektro Automatik PSI 9000 power supply.

MS_NOMINAL_CURRENT = 2040
MS_NOMINAL_VOLTAGE = 80
SHUTDOWN_CURRENT_LIMIT = 0.1
SHUTDOWN_VOLTAGE_LIMIT = 0.1
check_master_slave_config()None[source]

Checks if the master / slave configuration and initializes if successful

Raises

PSI9000Error – if master-slave configuration failed

static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

static default_com_cls()[source]

Return the default communication protocol for this device type, which is VisaCommunication.

Returns

the VisaCommunication class

get_output()bool[source]

Reads the current state of the DC output of the source. Returns True, if it is enabled, false otherwise.

Returns

the state of the DC output

get_system_lock()bool[source]

Get the current lock state of the system. The lock state is true, if the remote control is active and false, if not.

Returns

the current lock state of the device

get_ui_lower_limits()Tuple[float, float][source]

Get the lower voltage and current limits. A lower power limit does not exist.

Returns

Umin in V, Imin in A

get_uip_upper_limits()Tuple[float, float, float][source]

Get the upper voltage, current and power limits.

Returns

Umax in V, Imax in A, Pmax in W

get_voltage_current_setpoint()Tuple[float, float][source]

Get the voltage and current setpoint of the current source.

Returns

Uset in V, Iset in A

measure_voltage_current()Tuple[float, float][source]

Measure the DC output voltage and current

Returns

Umeas in V, Imeas in A

set_lower_limits(voltage_limit: Optional[float] = None, current_limit: Optional[float] = None)None[source]

Set the lower limits for voltage and current. After writing the values a check is performed if the values are set correctly.

Parameters
  • voltage_limit – is the lower voltage limit in V

  • current_limit – is the lower current limit in A

Raises

PSI9000Error – if the limits are out of range

set_output(target_onstate: bool)None[source]

Enables / disables the DC output.

Parameters

target_onstate – enable or disable the output power

Raises

PSI9000Error – if operation was not successful

set_system_lock(lock: bool)None[source]

Lock / unlock the device, after locking the control is limited to this class unlocking only possible when voltage and current are below the defined limits

Parameters

lock – True: locking, False: unlocking

set_upper_limits(voltage_limit: Optional[float] = None, current_limit: Optional[float] = None, power_limit: Optional[float] = None)None[source]

Set the upper limits for voltage, current and power. After writing the values a check is performed if the values are set. If a parameter is left blank, the maximum configurable limit is set.

Parameters
  • voltage_limit – is the voltage limit in V

  • current_limit – is the current limit in A

  • power_limit – is the power limit in W

Raises

PSI9000Error – if limits are out of range

set_voltage_current(volt: float, current: float)None[source]

Set voltage and current setpoints.

After setting voltage and current, a check is performed if writing was successful.

Parameters
  • volt – is the setpoint voltage: 0..81.6 V (1.02 * 0-80 V) (absolute max, can be smaller if limits are set)

  • current – is the setpoint current: 0..2080.8 A (1.02 * 0 - 2040 A) (absolute max, can be smaller if limits are set)

Raises

PSI9000Error – if the desired setpoint is out of limits

start()None[source]

Start this device.

stop()None[source]

Stop this device. Turns off output and lock, if enabled.

class hvl_ccb.dev.ea_psi9000.PSI9000Config(spoll_interval: Union[int, float] = 0.5, spoll_start_delay: Union[int, float] = 2, power_limit: Union[int, float] = 43500, voltage_lower_limit: Union[int, float] = 0.0, voltage_upper_limit: Union[int, float] = 10.0, current_lower_limit: Union[int, float] = 0.0, current_upper_limit: Union[int, float] = 2040.0, wait_sec_system_lock: Union[int, float] = 0.5, wait_sec_settings_effect: Union[int, float] = 1, wait_sec_initialisation: Union[int, float] = 2)[source]

Bases: hvl_ccb.dev.visa.VisaDeviceConfig

Elektro Automatik PSI 9000 power supply device class. The device is communicating over a VISA TCP socket.

Using this power supply, DC voltage and current can be supplied to a load with up to 2040 A and 80 V (using all four available units in parallel). The maximum power is limited by the grid, being at 43.5 kW available through the CEE63 power socket.

clean_values()None[source]

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

current_lower_limit: Union[int, float] = 0.0

Lower current limit in A, depending on the experimental setup.

current_upper_limit: Union[int, float] = 2040.0

Upper current limit in A, depending on the experimental setup.

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

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.

power_limit: Union[int, float] = 43500

Power limit in W depending on the experimental setup. With 3x63A, this is 43.5kW. Do not change this value, if you do not know what you are doing. There is no lower power limit.

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.

voltage_lower_limit: Union[int, float] = 0.0

Lower voltage limit in V, depending on the experimental setup.

voltage_upper_limit: Union[int, float] = 10.0

Upper voltage limit in V, depending on the experimental setup.

wait_sec_initialisation: Union[int, float] = 2
wait_sec_settings_effect: Union[int, float] = 1
wait_sec_system_lock: Union[int, float] = 0.5
exception hvl_ccb.dev.ea_psi9000.PSI9000Error[source]

Bases: Exception

Base error class regarding problems with the PSI 9000 supply.

class hvl_ccb.dev.ea_psi9000.PSI9000VisaCommunication(configuration)[source]

Bases: hvl_ccb.comm.visa.VisaCommunication

Communication protocol used with the PSI 9000 power supply.

static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

class hvl_ccb.dev.ea_psi9000.PSI9000VisaCommunicationConfig(host: str, interface_type: Union[str, hvl_ccb.comm.visa.VisaCommunicationConfig.InterfaceType] = <InterfaceType.TCPIP_SOCKET: 1>, board: int = 0, port: int = 5025, timeout: int = 5000, chunk_size: int = 204800, open_timeout: int = 1000, write_termination: str = '\n', read_termination: str = '\n', visa_backend: str = '')[source]

Bases: hvl_ccb.comm.visa.VisaCommunicationConfig

Visa communication protocol config dataclass with specification for the PSI 9000 power supply.

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

interface_type: Union[str, hvl_ccb.comm.visa.VisaCommunicationConfig.InterfaceType] = 1

Interface type of the VISA connection, being one of InterfaceType.

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.dev.fug module

Device classes for “Probus V - ADDAT30” Interfaces which are used to control power supplies from FuG Elektronik GmbH

This interface is used for many FuG power units. Manufacturer homepage: https://www.fug-elektronik.de

The Professional Series of Power Supplies from FuG is a series of low, medium and high voltage direct current power supplies as well as capacitor chargers. The class FuG is tested with a HCK 800-20 000 in Standard Mode. The addressable mode is not implemented. Check the code carefully before using it with other devices. Manufacturer homepage: https://www.fug-elektronik.de/netzgeraete/professional-series/

The documentation of the interface from the manufacturer can be found here: https://www.fug-elektronik.de/wp-content/uploads/download/de/SOFTWARE/Probus_V.zip

The provided classes support the basic and some advanced commands. The commands for calibrating the power supplies are not implemented, as they are only for very special porpoises and should not used by “normal” customers.

class hvl_ccb.dev.fug.FuG(com, dev_config=None)[source]

Bases: hvl_ccb.dev.fug.FuGProbusV

FuG power supply device class.

The power supply is controlled over a FuG ADDA Interface with the PROBUS V protocol

property config_status

Returns the registers for the registers with the configuration and status values

Returns

FuGProbusVConfigRegisters

property current

Returns the registers for the current output

Returns

property current_monitor

Returns the registers for the current monitor.

A typically usage will be “self.current_monitor.value” to measure the output current

Returns

property di

Returns the registers for the digital inputs

Returns

FuGProbusVDIRegisters

identify_device()None[source]

Identify the device nominal voltage and current based on its model number.

Raises

SerialCommunicationIOError – when communication port is not opened

property max_current

Returns the maximal current which could provided within the test setup

Returns

property max_current_hardware

Returns the maximal current which could provided with the power supply

Returns

property max_voltage

Returns the maximal voltage which could provided within the test setup

Returns

property max_voltage_hardware

Returns the maximal voltage which could provided with the power supply

Returns

property on

Returns the registers for the output switch to turn the output on or off

Returns

FuGProbusVDORegisters

property outX0

Returns the registers for the digital output X0

Returns

FuGProbusVDORegisters

property outX1

Returns the registers for the digital output X1

Returns

FuGProbusVDORegisters

property outX2

Returns the registers for the digital output X2

Returns

FuGProbusVDORegisters

property outXCMD

Returns the registers for the digital outputX-CMD

Returns

FuGProbusVDORegisters

start(max_voltage=0, max_current=0)None[source]

Opens the communication protocol and configures the device.

Parameters
  • max_voltage – Configure here the maximal permissible voltage which is allowed in the given experimental setup

  • max_current – Configure here the maximal permissible current which is allowed in the given experimental setup

property voltage

Returns the registers for the voltage output

Returns

property voltage_monitor

Returns the registers for the voltage monitor.

A typically usage will be “self.voltage_monitor.value” to measure the output voltage

Returns

class hvl_ccb.dev.fug.FuGConfig(wait_sec_stop_commands: Union[int, float] = 0.5)[source]

Bases: object

Device configuration dataclass for FuG power supplies.

clean_values()[source]
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.

wait_sec_stop_commands: Union[int, float] = 0.5

Time to wait after subsequent commands during stop (in seconds)

class hvl_ccb.dev.fug.FuGDigitalVal(value)[source]

Bases: enum.IntEnum

An enumeration.

NO = 0
OFF = 0
ON = 1
YES = 1
exception hvl_ccb.dev.fug.FuGError(*args, **kwargs)[source]

Bases: Exception

Error with the FuG voltage source.

errorcode: str

Errorcode from the Probus, see documentation of Probus V chapter 5. Errors with three-digit errorcodes are thrown by this python module.

class hvl_ccb.dev.fug.FuGErrorcodes(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: hvl_ccb.utils.enum.NameEnum

The power supply can return an errorcode. These errorcodes are handled by this class. The original errorcodes from the source are with one or two digits, see documentation of Probus V chapter 5. All three-digit errorcodes are from this python module.

E0 = ('no error', 'standard response on each command')
E1 = ('no data available', 'Customer tried to read from GPIB but there were no data prepared. (IBIG50 sent command ~T2 to ADDA)')
E10 = ('unknown SCPI command', 'This SCPI command is not implemented')
E100 = ('Command is not implemented', 'You tried to execute a command, which is not implemented or does not exist')
E106 = ('The rampstate is a read-only register', 'You tried to write data to the register, which can only give you the status of the ramping.')
E11 = ('not allowed Trigger-on-Talk', 'Not allowed attempt to Trigger-on-Talk (~T1) while ADDA was in addressable mode.')
E115 = ('The given index to select a digital value is out of range', 'Only integer values between 0 and 1 are allowed.')
E12 = ('invalid argument in ~Tn command', 'Only ~T1 and ~T2 is implemented.')
E125 = ('The given index to select a ramp mode is out of range', 'Only integer values between 0 and 4 are allowed.')
E13 = ('invalid N-value', 'Register > K8 contained an invalid value. Error code is output on an attempt to query data with ? or ~T1')
E135 = ('The given index to select the readback channel is out of range', 'Only integer values between 0 and 6 are allowed.')
E14 = ('register is write only', 'Some registers can only be writte to (i.e.> H0)')
E145 = ('The given value for the AD-conversion is unknown', 'Valid values for the ad-conversion are integer values from "0" to "7".')
E15 = ('string too long', 'i.e.serial number string too long during calibration')
E155 = ('The given value to select a polarity is out range.', 'The value should be 0 or 1.')
E16 = ('wrong checksum', 'checksum over command string was not correct, refer also to 4.4 of the Probus V documentation')
E165 = ('The given index to select the terminator string is out of range', '')
E2 = ('unknown register type', "No valid register type after '>'")
E206 = ('This status register is read-only', 'You tried to write data to this register, which can only give you the actual status of the corresponding digital output.')
E306 = ('The monitor register is read-only', 'You tried to write data to a monitor, which can only give you measured data.')
E4 = ('invalid argument', 'The argument of the command was rejected .i.e. malformed number')
E5 = ('argument out of range', 'i.e. setvalue higher than type value')
E504 = ('Empty string as response', 'The connection is broken.')
E505 = ('The returned register is not the requested.', 'Maybe the connection is overburden.')
E6 = ('register is read only', 'Some registers can only be read but not written to. (i.e. monitor registers)')
E666 = ('You cannot overwrite the most recent error in the interface of the power supply. But, well: You created an error anyway...', '')
E7 = ('Receive Overflow', 'Command string was longer than 50 characters.')
E8 = ('EEPROM is write protected', 'Write attempt to calibration data while the write protection switch was set to write protected.')
E9 = ('address error', 'A non addressed command was sent to ADDA while it was in addressable mode (and vice versa).')
raise_()[source]
class hvl_ccb.dev.fug.FuGMonitorModes(value)[source]

Bases: enum.IntEnum

An enumeration.

T1MS = 1

15 bit + sign, 1 ms integration time

T200MS = 6

typ. 19 bit + sign, 200 ms integration time

T20MS = 3

17 bit + sign, 20 ms integration time

T256US = 0

14 bit + sign, 256 us integration time

T40MS = 4

17 bit + sign, 40 ms integration time

T4MS = 2

15 bit + sign, 4 ms integration time

T800MS = 7

typ. 20 bit + sign, 800 ms integration time

T80MS = 5

typ. 18 bit + sign, 80 ms integration time

class hvl_ccb.dev.fug.FuGPolarities(value)[source]

Bases: enum.IntEnum

An enumeration.

NEGATIVE = 1
POSITIVE = 0
class hvl_ccb.dev.fug.FuGProbusIV(com, dev_config=None)[source]

Bases: hvl_ccb.dev.base.SingleCommDevice, abc.ABC

FuG Probus IV device class

Sends basic SCPI commands and reads the answer. Only the special commands and PROBUS IV instruction set is implemented.

command(command: hvl_ccb.dev.fug.FuGProbusIVCommands, value=None)str[source]
Parameters
  • command – one of the commands given within FuGProbusIVCommands

  • value – an optional value, depending on the command

Returns

a String if a query was performed

static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

static default_com_cls()[source]

Get the class for the default communication protocol used with this device.

Returns

the type of the standard communication protocol for this device

output_off()None[source]

Switch DC voltage output off.

reset()None[source]

Reset of the interface: All setvalues are set to zero

abstract start()[source]

Open the associated communication protocol.

stop()None[source]

Close the associated communication protocol.

class hvl_ccb.dev.fug.FuGProbusIVCommands(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: hvl_ccb.utils.enum.NameEnum

An enumeration.

ADMODE = ('S', (<enum 'FuGMonitorModes'>, <class 'int'>))
CURRENT = ('I', (<class 'int'>, <class 'float'>))
EXECUTE = ('X', None)
EXECUTEONX = ('G', (<enum 'FuGDigitalVal'>, <class 'int'>))

Wait for “X” to execute pending commands

ID = ('*IDN?', None)
OUTPUT = ('F', (<enum 'FuGDigitalVal'>, <class 'int'>))
POLARITY = ('P', (<enum 'FuGPolarities'>, <class 'int'>))
QUERY = ('?', None)
READBACKCHANNEL = ('N', (<enum 'FuGReadbackChannels'>, <class 'int'>))
RESET = ('=', None)
TERMINATOR = ('Y', (<enum 'FuGTerminators'>, <class 'int'>))
VOLTAGE = ('U', (<class 'int'>, <class 'float'>))
XOUTPUTS = ('R', <class 'int'>)

TODO: the possible values are limited to 0..13

class hvl_ccb.dev.fug.FuGProbusV(com, dev_config=None)[source]

Bases: hvl_ccb.dev.fug.FuGProbusIV

FuG Probus V class which uses register based commands to control the power supplies

get_register(register: str)str[source]

get the value from a register

Parameters

register – the register from which the value is requested

Returns

the value of the register as a String

set_register(register: str, value: Union[int, float, str])None[source]

generic method to set value to register

Parameters
  • register – the name of the register to set the value

  • value – which should be written to the register

class hvl_ccb.dev.fug.FuGProbusVConfigRegisters(fug, super_register: hvl_ccb.dev.fug.FuGProbusVRegisterGroups)[source]

Bases: object

Configuration and Status values, acc. 4.2.5

property execute_on_x

status of Execute-on-X

Returns

FuGDigitalVal of the status

property most_recent_error

Reads the Error-Code of the most recent command

Return FuGError

Raises

FuGError – if code is not “E0”

property readback_data

Preselection of readout data for Trigger-on-Talk

Returns

index for the readback channel

property srq_mask

SRQ-Mask, Service-Request Enable status bits for SRQ 0: no SRQ Bit 2: SRQ on change of status to CC Bit 1: SRQ on change to CV

Returns

representative integer value

property srq_status

SRQ-Statusbyte output as a decimal number: Bit 2: PS is in CC mode Bit 1: PS is in CV mode

Returns

representative string

property status

Statusbyte as a string of 0/1. Combined status (compatibel to Probus IV), MSB first: Bit 7: I-REG Bit 6: V-REG Bit 5: ON-Status Bit 4: 3-Reg Bit 3: X-Stat (polarity) Bit 2: Cal-Mode Bit 1: unused Bit 0: SEL-D

Returns

string of 0/1

property terminator

Terminator character for answer strings from ADDA

Returns

FuGTerminators

class hvl_ccb.dev.fug.FuGProbusVDIRegisters(fug, super_register: hvl_ccb.dev.fug.FuGProbusVRegisterGroups)[source]

Bases: object

Digital Inputs acc. 4.2.4

property analog_control
Returns

shows 1 if power supply is controlled by the analog interface

property calibration_mode
Returns

shows 1 if power supply is in calibration mode

property cc_mode
Returns

shows 1 if power supply is in CC mode

property cv_mode
Returns

shows 1 if power supply is in CV mode

property digital_control
Returns

shows 1 if power supply is digitally controlled

property on
Returns

shows 1 if power supply ON

property reg_3

For special applications.

Returns

input from bit 3-REG

property x_stat
Returns

polarity of HVPS with polarity reversal

class hvl_ccb.dev.fug.FuGProbusVDORegisters(fug, super_register: hvl_ccb.dev.fug.FuGProbusVRegisterGroups)[source]

Bases: object

Digital outputs acc. 4.2.2

property out

Status of the output according to the last setting. This can differ from the actual state if output should only pulse.

Returns

FuGDigitalVal

property status

Returns the actual value of output. This can differ from the set value if pulse function is used.

Returns

FuGDigitalVal

class hvl_ccb.dev.fug.FuGProbusVMonitorRegisters(fug, super_register: hvl_ccb.dev.fug.FuGProbusVRegisterGroups)[source]

Bases: object

Analog monitors acc. 4.2.3

property adc_mode

The programmed resolution and integration time of the AD converter

Returns

FuGMonitorModes

property value

Value from the monitor.

Returns

a float value in V or A

property value_raw

uncalibrated raw value from AD converter

Returns

float value from ADC

class hvl_ccb.dev.fug.FuGProbusVRegisterGroups(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: hvl_ccb.utils.enum.NameEnum

An enumeration.

CONFIG = 'K'
INPUT = 'D'
MONITOR_I = 'M1'
MONITOR_V = 'M0'
OUTPUTONCMD = 'BON'
OUTPUTX0 = 'B0'
OUTPUTX1 = 'B1'
OUTPUTX2 = 'B2'
OUTPUTXCMD = 'BX'
SETCURRENT = 'S1'
SETVOLTAGE = 'S0'
class hvl_ccb.dev.fug.FuGProbusVSetRegisters(fug, super_register: hvl_ccb.dev.fug.FuGProbusVRegisterGroups)[source]

Bases: object

Setvalue control acc. 4.2.1 for the voltage and the current output

property actualsetvalue

The actual valid set value, which depends on the ramp function.

Returns

actual valid set value

property high_resolution

Status of the high resolution mode of the output.

Return 0

normal operation

Return 1

High Res. Mode

property rampmode

The set ramp mode to control the setvalue.

Returns

the mode of the ramp as instance of FuGRampModes

property ramprate

The set ramp rate in V/s.

Returns

ramp rate in V/s

property rampstate

Status of ramp function.

Return 0

if final setvalue is reached

Return 1

if still ramping up

property setvalue

For the voltage or current output this setvalue was programmed.

Returns

the programmed setvalue

class hvl_ccb.dev.fug.FuGRampModes(value)[source]

Bases: enum.IntEnum

An enumeration.

FOLLOWRAMP = 1

Follow the ramp up- and downwards

IMMEDIATELY = 0

Standard mode: no ramp

ONLYUPWARDSOFFTOZERO = 4

Follow the ramp up- and downwards, if output is OFF set value is zero

RAMPUPWARDS = 2

Follow the ramp only upwards, downwards immediately

SPECIALRAMPUPWARDS = 3

Follow a special ramp function only upwards

class hvl_ccb.dev.fug.FuGReadbackChannels(value)[source]

Bases: enum.IntEnum

An enumeration.

CURRENT = 1
FIRMWARE = 5
RATEDCURRENT = 4
RATEDVOLTAGE = 3
SN = 6
STATUSBYTE = 2
VOLTAGE = 0
class hvl_ccb.dev.fug.FuGSerialCommunication(configuration)[source]

Bases: hvl_ccb.comm.serial.SerialCommunication

Specific communication protocol implementation for FuG power supplies. Already predefines device-specific protocol parameters in config.

static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

query(command: str)str[source]

Send a command to the interface and handle the status message. Eventually raises an exception.

Parameters

command – Command to send

Raises

FuGError – if the connection is broken or the error from the power source itself

Returns

Answer from the interface or empty string

class hvl_ccb.dev.fug.FuGSerialCommunicationConfig(terminator: bytes = b'\n', encoding: str = 'utf-8', encoding_error_handling: str = 'replace', wait_sec_read_text_nonempty: Union[int, float] = 0.5, default_n_attempts_read_text_nonempty: int = 10, port: Union[str, NoneType] = None, baudrate: int = 9600, parity: Union[str, hvl_ccb.comm.serial.SerialCommunicationParity] = <SerialCommunicationParity.NONE: 'N'>, stopbits: Union[int, hvl_ccb.comm.serial.SerialCommunicationStopbits] = <SerialCommunicationStopbits.ONE: 1>, bytesize: Union[int, hvl_ccb.comm.serial.SerialCommunicationBytesize] = <SerialCommunicationBytesize.EIGHTBITS: 8>, timeout: Union[int, float] = 3)[source]

Bases: hvl_ccb.comm.serial.SerialCommunicationConfig

baudrate: int = 9600

Baudrate for FuG power supplies is 9600 baud

bytesize: Union[int, hvl_ccb.comm.serial.SerialCommunicationBytesize] = 8

One byte is eight bits long

default_n_attempts_read_text_nonempty: int = 10

default number of attempts to read a non-empty text

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

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.

parity: Union[str, hvl_ccb.comm.serial.SerialCommunicationParity] = 'N'

FuG does not use parity

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.

stopbits: Union[int, hvl_ccb.comm.serial.SerialCommunicationStopbits] = 1

FuG uses one stop bit

terminator: bytes = b'\n'

The terminator is LF

timeout: Union[int, float] = 3

use 3 seconds timeout as default

wait_sec_read_text_nonempty: Union[int, float] = 0.5

default time to wait between attempts of reading a non-empty text

class hvl_ccb.dev.fug.FuGTerminators(value)[source]

Bases: enum.IntEnum

An enumeration.

CR = 3
CRLF = 0
LF = 2
LFCR = 1

hvl_ccb.dev.heinzinger module

Device classes for Heinzinger Digital Interface I/II and Heinzinger PNC power supply.

The Heinzinger Digital Interface I/II is used for many Heinzinger power units. Manufacturer homepage: https://www.heinzinger.com/products/accessories-and-more/digital-interfaces/

The Heinzinger PNC series is a series of high voltage direct current power supplies. The class HeinzingerPNC is tested with two PNChp 60000-1neg and a PNChp 1500-1neg. Check the code carefully before using it with other PNC devices, especially PNC3p or PNCcap. Manufacturer homepage: https://www.heinzinger.com/products/high-voltage/universal-high-voltage-power-supplies/

class hvl_ccb.dev.heinzinger.HeinzingerConfig(default_number_of_recordings: Union[int, hvl_ccb.dev.heinzinger.HeinzingerConfig.RecordingsEnum] = 1, number_of_decimals: int = 6, wait_sec_stop_commands: Union[int, float] = 0.5)[source]

Bases: object

Device configuration dataclass for Heinzinger power supplies.

class RecordingsEnum(value)[source]

Bases: enum.IntEnum

An enumeration.

EIGHT = 8
FOUR = 4
ONE = 1
SIXTEEN = 16
TWO = 2
clean_values()[source]
default_number_of_recordings: Union[int, hvl_ccb.dev.heinzinger.HeinzingerConfig.RecordingsEnum] = 1
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.

number_of_decimals: int = 6
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.

wait_sec_stop_commands: Union[int, float] = 0.5

Time to wait after subsequent commands during stop (in seconds)

class hvl_ccb.dev.heinzinger.HeinzingerDI(com, dev_config=None)[source]

Bases: hvl_ccb.dev.base.SingleCommDevice, abc.ABC

Heinzinger Digital Interface I/II device class

Sends basic SCPI commands and reads the answer. Only the standard instruction set from the manual is implemented.

class OutputStatus(value)[source]

Bases: enum.IntEnum

Status of the voltage output

OFF = 0
ON = 1
UNKNOWN = -1
static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

static default_com_cls()[source]

Get the class for the default communication protocol used with this device.

Returns

the type of the standard communication protocol for this device

get_current()float[source]

Queries the set current of the Heinzinger PNC (not the measured current!).

Raises

SerialCommunicationIOError – when communication port is not opened

get_interface_version()str[source]

Queries the version number of the digital interface.

Raises

SerialCommunicationIOError – when communication port is not opened

get_number_of_recordings()int[source]

Queries the number of recordings the device is using for average value calculation.

Returns

int number of recordings

Raises

SerialCommunicationIOError – when communication port is not opened

get_serial_number()str[source]

Ask the device for its serial number and returns the answer as a string.

Returns

string containing the device serial number

Raises

SerialCommunicationIOError – when communication port is not opened

get_voltage()float[source]

Queries the set voltage of the Heinzinger PNC (not the measured voltage!).

Raises

SerialCommunicationIOError – when communication port is not opened

measure_current()float[source]

Ask the Device to measure its output current and return the measurement result.

Returns

measured current as float

Raises

SerialCommunicationIOError – when communication port is not opened

measure_voltage()float[source]

Ask the Device to measure its output voltage and return the measurement result.

Returns

measured voltage as float

Raises

SerialCommunicationIOError – when communication port is not opened

output_off()None[source]

Switch DC voltage output off and updates the output status.

Raises

SerialCommunicationIOError – when communication port is not opened

output_on()None[source]

Switch DC voltage output on and updates the output status.

Raises

SerialCommunicationIOError – when communication port is not opened

property output_status
reset_interface()None[source]

Reset of the digital interface; only Digital Interface I: Power supply is switched to the Local-Mode (Manual operation)

Raises

SerialCommunicationIOError – when communication port is not opened

set_current(value: Union[int, float])None[source]

Sets the output current of the Heinzinger PNC to the given value.

Parameters

value – current expressed in self.unit_current

Raises

SerialCommunicationIOError – when communication port is not opened

set_number_of_recordings(value: Union[int, hvl_ccb.dev.heinzinger.HeinzingerConfig.RecordingsEnum])None[source]

Sets the number of recordings the device is using for average value calculation. The possible values are 1, 2, 4, 8 and 16.

Raises

SerialCommunicationIOError – when communication port is not opened

set_voltage(value: Union[int, float])None[source]

Sets the output voltage of the Heinzinger PNC to the given value.

Parameters

value – voltage expressed in self.unit_voltage

Raises

SerialCommunicationIOError – when communication port is not opened

abstract start()[source]

Opens the communication protocol.

Raises

SerialCommunicationIOError – when communication port cannot be opened.

stop()None[source]

Stop the device. Closes also the communication protocol.

class hvl_ccb.dev.heinzinger.HeinzingerPNC(com, dev_config=None)[source]

Bases: hvl_ccb.dev.heinzinger.HeinzingerDI

Heinzinger PNC power supply device class.

The power supply is controlled over a Heinzinger Digital Interface I/II

class UnitCurrent(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: hvl_ccb.utils.enum.AutoNumberNameEnum

An enumeration.

A = 3
UNKNOWN = 1
mA = 2
class UnitVoltage(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: hvl_ccb.utils.enum.AutoNumberNameEnum

An enumeration.

UNKNOWN = 1
V = 2
kV = 3
identify_device()None[source]

Identify the device nominal voltage and current based on its serial number.

Raises

SerialCommunicationIOError – when communication port is not opened

property max_current
property max_current_hardware
property max_voltage
property max_voltage_hardware
set_current(value: Union[int, float])None[source]

Sets the output current of the Heinzinger PNC to the given value.

Parameters

value – current expressed in self.unit_current

Raises

SerialCommunicationIOError – when communication port is not opened

set_voltage(value: Union[int, float])None[source]

Sets the output voltage of the Heinzinger PNC to the given value.

Parameters

value – voltage expressed in self.unit_voltage

Raises

SerialCommunicationIOError – when communication port is not opened

start()None[source]

Opens the communication protocol and configures the device.

property unit_current
property unit_voltage
exception hvl_ccb.dev.heinzinger.HeinzingerPNCDeviceNotRecognizedException[source]

Bases: hvl_ccb.dev.heinzinger.HeinzingerPNCError

Error indicating that the serial number of the device is not recognized.

exception hvl_ccb.dev.heinzinger.HeinzingerPNCError[source]

Bases: Exception

General error with the Heinzinger PNC voltage source.

exception hvl_ccb.dev.heinzinger.HeinzingerPNCMaxCurrentExceededException[source]

Bases: hvl_ccb.dev.heinzinger.HeinzingerPNCError

Error indicating that program attempted to set the current to a value exceeding ‘max_current’.

exception hvl_ccb.dev.heinzinger.HeinzingerPNCMaxVoltageExceededException[source]

Bases: hvl_ccb.dev.heinzinger.HeinzingerPNCError

Error indicating that program attempted to set the voltage to a value exceeding ‘max_voltage’.

class hvl_ccb.dev.heinzinger.HeinzingerSerialCommunication(configuration)[source]

Bases: hvl_ccb.comm.serial.SerialCommunication

Specific communication protocol implementation for Heinzinger power supplies. Already predefines device-specific protocol parameters in config.

static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

class hvl_ccb.dev.heinzinger.HeinzingerSerialCommunicationConfig(terminator: bytes = b'\n', encoding: str = 'utf-8', encoding_error_handling: str = 'replace', wait_sec_read_text_nonempty: Union[int, float] = 0.5, default_n_attempts_read_text_nonempty: int = 40, port: Union[str, NoneType] = None, baudrate: int = 9600, parity: Union[str, hvl_ccb.comm.serial.SerialCommunicationParity] = <SerialCommunicationParity.NONE: 'N'>, stopbits: Union[int, hvl_ccb.comm.serial.SerialCommunicationStopbits] = <SerialCommunicationStopbits.ONE: 1>, bytesize: Union[int, hvl_ccb.comm.serial.SerialCommunicationBytesize] = <SerialCommunicationBytesize.EIGHTBITS: 8>, timeout: Union[int, float] = 3)[source]

Bases: hvl_ccb.comm.serial.SerialCommunicationConfig

baudrate: int = 9600

Baudrate for Heinzinger power supplies is 9600 baud

bytesize: Union[int, hvl_ccb.comm.serial.SerialCommunicationBytesize] = 8

One byte is eight bits long

default_n_attempts_read_text_nonempty: int = 40

increased to 40 default number of attempts to read a non-empty text

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

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.

parity: Union[str, hvl_ccb.comm.serial.SerialCommunicationParity] = 'N'

Heinzinger does not use parity

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.

stopbits: Union[int, hvl_ccb.comm.serial.SerialCommunicationStopbits] = 1

Heinzinger uses one stop bit

terminator: bytes = b'\n'

The terminator is LF

timeout: Union[int, float] = 3

use 3 seconds timeout as default

wait_sec_read_text_nonempty: Union[int, float] = 0.5

default time to wait between attempts of reading a non-empty text

hvl_ccb.dev.labjack module

Labjack Device for hvl_ccb. Originally developed and tested for LabJack T7-PRO.

Makes use of the LabJack LJM Library Python wrapper. This wrapper needs an installation of the LJM Library for Windows, Mac OS X or Linux. Go to: https://labjack.com/support/software/installers/ljm and https://labjack.com/support/software/examples/ljm/python

class hvl_ccb.dev.labjack.LabJack(com, dev_config=None)[source]

Bases: hvl_ccb.dev.base.SingleCommDevice

LabJack Device.

This class is tested with a LabJack T7-Pro and should also work with T4 and T7 devices communicating through the LJM Library. Other or older hardware versions and variants of LabJack devices are not supported.

class AInRange(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: hvl_ccb.utils.enum.StrEnumBase

An enumeration.

ONE = 1.0
ONE_HUNDREDTH = 0.01
ONE_TENTH = 0.1
TEN = 10.0
property value
class CalMicroAmpere(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: aenum.Enum

Pre-defined microampere (uA) values for calibration current source query.

TEN = '10uA'
TWO_HUNDRED = '200uA'
class CjcType(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: hvl_ccb.utils.enum.NameEnum

CJC slope and offset

internal = (1, 0)
lm34 = (55.56, 255.37)
DIOChannel

alias of hvl_ccb._dev.labjack.TSeriesDIOChannel

class DIOStatus(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: aenum.IntEnum

State of a digital I/O channel.

HIGH = 1
LOW = 0
class DeviceType(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)

Bases: hvl_ccb.utils.enum.AutoNumberNameEnum

LabJack device types.

Can be also looked up by ambigious Product ID (p_id) or by instance name: `python LabJackDeviceType(4) is LabJackDeviceType('T4') `

ANY = 1
T4 = 2
T7 = 3
T7_PRO = 4
classmethod get_by_p_id(p_id: int)Union[hvl_ccb._dev.labjack.DeviceType, List[hvl_ccb._dev.labjack.DeviceType]]

Get LabJack device type instance via LabJack product ID.

Note: Product ID is not unambiguous for LabJack devices.

Parameters

p_id – Product ID of a LabJack device

Returns

Instance or list of instances of LabJackDeviceType

Raises

ValueError – when Product ID is unknown

class TemperatureUnit(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: hvl_ccb.utils.enum.NameEnum

Temperature unit (to be returned)

C = 1
F = 2
K = 0
class ThermocoupleType(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: hvl_ccb.utils.enum.NameEnum

Thermocouple type; NONE means disable thermocouple mode.

C = 30
E = 20
J = 21
K = 22
NONE = 0
PT100 = 40
PT1000 = 42
PT500 = 41
R = 23
S = 25
T = 24
static default_com_cls()[source]

Get the class for the default communication protocol used with this device.

Returns

the type of the standard communication protocol for this device

get_ain(*channels: int)Union[float, Sequence[float]][source]

Read currently measured value (voltage, resistance, …) from one or more of analog inputs.

Parameters

channels – AIN number or numbers (0..254)

Returns

the read value (voltage, resistance, …) as float`or `tuple of them in case multiple channels given

get_cal_current_source(name: Union[str, CalMicroAmpere])float[source]

This function will return the calibration of the chosen current source, this ist not a measurement!

The value was stored during fabrication.

Parameters

name – ‘200uA’ or ‘10uA’ current source

Returns

calibration of the chosen current source in ampere

get_digital_input(address: Union[str, hvl_ccb._dev.labjack.TSeriesDIOChannel])hvl_ccb.dev.labjack.LabJack.DIOStatus[source]

Get the value of a digital input.

allowed names for T7 (Pro): FIO0 - FIO7, EIO0 - EIO 7, CIO0- CIO3, MIO0 - MIO2 :param address: name of the output -> ‘FIO0’ :return: HIGH when address DIO is high, and LOW when address DIO is low

get_product_id()int[source]

This function returns the product ID reported by the connected device.

Attention: returns 7 for both T7 and T7-Pro devices!

Returns

integer product ID of the device

get_product_name(force_query_id=False)str[source]

This function will return the product name based on product ID reported by the device.

Attention: returns “T7” for both T7 and T7-Pro devices!

Parameters

force_query_id – boolean flag to force get_product_id query to device instead of using cached device type from previous queries.

Returns

device name string, compatible with LabJack.DeviceType

get_product_type(force_query_id: bool = False)hvl_ccb._dev.labjack.DeviceType[source]

This function will return the device type based on reported device type and in case of unambiguity based on configuration of device’s communication protocol (e.g. for “T7” and “T7_PRO” devices), or, if not available first matching.

Parameters

force_query_id – boolean flag to force get_product_id query to device instead of using cached device type from previous queries.

Returns

DeviceType instance

Raises

LabJackIdentifierDIOError – when read Product ID is unknown

get_sbus_rh(number: int)float[source]

Read the relative humidity value from a serial SBUS sensor.

Parameters

number – port number (0..22)

Returns

relative humidity in %RH

get_sbus_temp(number: int)float[source]

Read the temperature value from a serial SBUS sensor.

Parameters

number – port number (0..22)

Returns

temperature in Kelvin

get_serial_number()int[source]

Returns the serial number of the connected LabJack.

Returns

Serial number.

read_resistance(channel: int)float[source]

Read resistance from specified channel.

Parameters

channel – channel with resistor

Returns

resistance value with 2 decimal places

read_thermocouple(pos_channel: int)float[source]

Read the temperature of a connected thermocouple.

Parameters

pos_channel – is the AIN number of the positive pin

Returns

temperature in specified unit

set_ain_differential(pos_channel: int, differential: bool)None[source]

Sets an analog input to differential mode or not. T7-specific: For base differential channels, positive must be even channel from 0-12 and negative must be positive+1. For extended channels 16-127, see Mux80 datasheet.

Parameters
  • pos_channel – is the AIN number (0..12)

  • differential – True or False

Raises

LabJackError – if parameters are unsupported

set_ain_range(channel: int, vrange: Union[Real, AInRange])None[source]

Set the range of an analog input port.

Parameters
  • channel – is the AIN number (0..254)

  • vrange – is the voltage range to be set

set_ain_resistance(channel: int, vrange: Union[Real, AInRange], resolution: int)None[source]

Set the specified channel to resistance mode. It utilized the 200uA current source of the LabJack.

Parameters
  • channel – channel that should measure the resistance

  • vrange – voltage range of the channel

  • resolution – resolution index of the channel T4: 0-5, T7: 0-8, T7-Pro 0-12

set_ain_resolution(channel: int, resolution: int)None[source]

Set the resolution index of an analog input port.

Parameters
  • channel – is the AIN number (0..254)

  • resolution – is the resolution index within 0…`get_product_type().ain_max_resolution` range; 0 will set the resolution index to default value.

set_ain_thermocouple(pos_channel: int, thermocouple: Union[None, str, ThermocoupleType], cjc_address: int = 60050, cjc_type: Union[str, CjcType] = <CjcType.internal: (1, 0)>, vrange: Union[Real, AInRange] = <AInRange.ONE_HUNDREDTH: '0.01'>, resolution: int = 10, unit: Union[str, TemperatureUnit] = <TemperatureUnit.K: 0>)None[source]

Set the analog input channel to thermocouple mode.

Parameters
  • pos_channel – is the analog input channel of the positive part of the differential pair

  • thermocouple – None to disable thermocouple mode, or string specifying the thermocouple type

  • cjc_address – modbus register address to read the CJC temperature

  • cjc_type – determines cjc slope and offset, ‘internal’ or ‘lm34’

  • vrange – measurement voltage range

  • resolution – resolution index (T7-Pro: 0-12)

  • unit – is the temperature unit to be returned (‘K’, ‘C’ or ‘F’)

Raises

LabJackError – if parameters are unsupported

set_digital_output(address: str, state: Union[int, DIOStatus])None[source]

Set the value of a digital output.

Parameters
  • address – name of the output -> ‘FIO0’

  • state – state of the output -> DIOStatus instance or corresponding int value

start()None[source]

Start the Device.

stop()None[source]

Stop the Device.

exception hvl_ccb.dev.labjack.LabJackError[source]

Bases: Exception

Errors of the LabJack device.

exception hvl_ccb.dev.labjack.LabJackIdentifierDIOError[source]

Bases: Exception

Error indicating a wrong DIO identifier

hvl_ccb.dev.mbw973 module

Device class for controlling a MBW 973 SF6 Analyzer over a serial connection.

The MBW 973 is a gas analyzer designed for gas insulated switchgear and measures humidity, SF6 purity and SO2 contamination in one go. Manufacturer homepage: https://www.mbw.ch/products/sf6-gas-analysis/973-sf6-analyzer/

class hvl_ccb.dev.mbw973.MBW973(com, dev_config=None)[source]

Bases: hvl_ccb.dev.base.SingleCommDevice

MBW 973 dew point mirror device class.

static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

static default_com_cls()[source]

Get the class for the default communication protocol used with this device.

Returns

the type of the standard communication protocol for this device

is_done()bool[source]

Poll status of the dew point mirror and return True, if all measurements are done.

Returns

True, if all measurements are done; False otherwise.

Raises

SerialCommunicationIOError – when communication port is not opened

read(cast_type: Type = <class 'str'>)[source]

Read value from self.com and cast to cast_type. Raises ValueError if read text (str) is not convertible to cast_type, e.g. to float or to int.

Returns

Read value of cast_type type.

read_float()float[source]

Convenience wrapper for self.read(), with typing hint for return value.

Returns

Read float value.

read_int()int[source]

Convenience wrapper for self.read(), with typing hint for return value.

Returns

Read int value.

read_measurements()Dict[str, float][source]

Read out measurement values and return them as a dictionary.

Returns

Dictionary with values.

Raises

SerialCommunicationIOError – when communication port is not opened

set_measuring_options(humidity: bool = True, sf6_purity: bool = False)None[source]

Send measuring options to the dew point mirror.

Parameters
  • humidity – Perform humidity test or not?

  • sf6_purity – Perform SF6 purity test or not?

Raises

SerialCommunicationIOError – when communication port is not opened

start()None[source]

Start this device. Opens the communication protocol and retrieves the set measurement options from the device.

Raises

SerialCommunicationIOError – when communication port cannot be opened.

start_control()None[source]

Start dew point control to acquire a new value set.

Raises

SerialCommunicationIOError – when communication port is not opened

stop()None[source]

Stop the device. Closes also the communication protocol.

write(value)None[source]

Send value to self.com.

Parameters

value – Value to send, converted to str.

Raises

SerialCommunicationIOError – when communication port is not opened

class hvl_ccb.dev.mbw973.MBW973Config(polling_interval: Union[int, float] = 2)[source]

Bases: object

Device configuration dataclass for MBW973.

clean_values()[source]
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.

polling_interval: Union[int, float] = 2

Polling period for is_done status queries [in seconds].

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.

exception hvl_ccb.dev.mbw973.MBW973ControlRunningException[source]

Bases: hvl_ccb.dev.mbw973.MBW973Error

Error indicating there is still a measurement running, and a new one cannot be started.

exception hvl_ccb.dev.mbw973.MBW973Error[source]

Bases: Exception

General error with the MBW973 dew point mirror device.

exception hvl_ccb.dev.mbw973.MBW973PumpRunningException[source]

Bases: hvl_ccb.dev.mbw973.MBW973Error

Error indicating the pump of the dew point mirror is still recovering gas, unable to start a new measurement.

class hvl_ccb.dev.mbw973.MBW973SerialCommunication(configuration)[source]

Bases: hvl_ccb.comm.serial.SerialCommunication

Specific communication protocol implementation for the MBW973 dew point mirror. Already predefines device-specific protocol parameters in config.

static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

class hvl_ccb.dev.mbw973.MBW973SerialCommunicationConfig(terminator: bytes = b'\r', encoding: str = 'utf-8', encoding_error_handling: str = 'replace', wait_sec_read_text_nonempty: Union[int, float] = 0.5, default_n_attempts_read_text_nonempty: int = 10, port: Union[str, NoneType] = None, baudrate: int = 9600, parity: Union[str, hvl_ccb.comm.serial.SerialCommunicationParity] = <SerialCommunicationParity.NONE: 'N'>, stopbits: Union[int, hvl_ccb.comm.serial.SerialCommunicationStopbits] = <SerialCommunicationStopbits.ONE: 1>, bytesize: Union[int, hvl_ccb.comm.serial.SerialCommunicationBytesize] = <SerialCommunicationBytesize.EIGHTBITS: 8>, timeout: Union[int, float] = 3)[source]

Bases: hvl_ccb.comm.serial.SerialCommunicationConfig

baudrate: int = 9600

Baudrate for MBW973 is 9600 baud

bytesize: Union[int, hvl_ccb.comm.serial.SerialCommunicationBytesize] = 8

One byte is eight bits long

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

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.

parity: Union[str, hvl_ccb.comm.serial.SerialCommunicationParity] = 'N'

MBW973 does not use parity

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.

stopbits: Union[int, hvl_ccb.comm.serial.SerialCommunicationStopbits] = 1

MBW973 does use one stop bit

terminator: bytes = b'\r'

The terminator is only CR

timeout: Union[int, float] = 3

use 3 seconds timeout as default

hvl_ccb.dev.newport module

Device class for Newport SMC100PP stepper motor controller with serial communication.

The SMC100PP is a single axis motion controller/driver for stepper motors up to 48 VDC at 1.5 A rms. Up to 31 controllers can be networked through the internal RS-485 communication link.

Manufacturer homepage: https://www.newport.com/f/smc100-single-axis-dc-or-stepper-motion-controller

class hvl_ccb.dev.newport.NewportConfigCommands(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: hvl_ccb.utils.enum.NameEnum

Commands predefined by the communication protocol of the SMC100PP

AC = 'acceleration'
BA = 'backlash_compensation'
BH = 'hysteresis_compensation'
FRM = 'micro_step_per_full_step_factor'
FRS = 'motion_distance_per_full_step'
HT = 'home_search_type'
JR = 'jerk_time'
OH = 'home_search_velocity'
OT = 'home_search_timeout'
QIL = 'peak_output_current_limit'
SA = 'rs485_address'
SL = 'negative_software_limit'
SR = 'positive_software_limit'
VA = 'velocity'
VB = 'base_velocity'
ZX = 'stage_configuration'
exception hvl_ccb.dev.newport.NewportControllerError[source]

Bases: Exception

Error with the Newport controller.

exception hvl_ccb.dev.newport.NewportMotorError[source]

Bases: Exception

Error with the Newport motor.

exception hvl_ccb.dev.newport.NewportMotorPowerSupplyWasCutError[source]

Bases: Exception

Error with the Newport motor after the power supply was cut and then restored, without interrupting the communication with the controller.

class hvl_ccb.dev.newport.NewportSMC100PP(com, dev_config=None)[source]

Bases: hvl_ccb.dev.base.SingleCommDevice

Device class of the Newport motor controller SMC100PP

class MotorErrors(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: aenum.Enum

Possible motor errors reported by the motor during get_state().

DC_VOLTAGE_TOO_LOW = 3
FOLLOWING_ERROR = 6
HOMING_TIMEOUT = 5
NED_END_OF_TURN = 11
OUTPUT_POWER_EXCEEDED = 2
PEAK_CURRENT_LIMIT = 9
POS_END_OF_TURN = 10
RMS_CURRENT_LIMIT = 8
SHORT_CIRCUIT = 7
WRONG_ESP_STAGE = 4
class StateMessages(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: aenum.Enum

Possible messages returned by the controller on get_state() query.

CONFIG = '14'
DISABLE_FROM_JOGGING = '3E'
DISABLE_FROM_MOVING = '3D'
DISABLE_FROM_READY = '3C'
HOMING_FROM_RS232 = '1E'
HOMING_FROM_SMC = '1F'
JOGGING_FROM_DISABLE = '47'
JOGGING_FROM_READY = '46'
MOVING = '28'
NO_REF_ESP_STAGE_ERROR = '10'
NO_REF_FROM_CONFIG = '0C'
NO_REF_FROM_DISABLED = '0D'
NO_REF_FROM_HOMING = '0B'
NO_REF_FROM_JOGGING = '11'
NO_REF_FROM_MOVING = '0F'
NO_REF_FROM_READY = '0E'
NO_REF_FROM_RESET = '0A'
READY_FROM_DISABLE = '34'
READY_FROM_HOMING = '32'
READY_FROM_JOGGING = '35'
READY_FROM_MOVING = '33'
States

alias of hvl_ccb.dev.newport.NewportStates

static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

static default_com_cls()[source]

Get the class for the default communication protocol used with this device.

Returns

the type of the standard communication protocol for this device

exit_configuration(add: Optional[int] = None)None[source]

Exit the CONFIGURATION state and go back to the NOT REFERENCED state. All configuration parameters are saved to the device”s memory.

Parameters

add – controller address (1 to 31)

Raises
get_acceleration(add: Optional[int] = None)Union[int, float][source]

Leave the configuration state. The configuration parameters are saved to the device”s memory.

Parameters

add – controller address (1 to 31)

Returns

acceleration (preset units/s^2), value between 1e-6 and 1e12

Raises
get_controller_information(add: Optional[int] = None)str[source]

Get information on the controller name and driver version

Parameters

add – controller address (1 to 31)

Returns

controller information

Raises
get_motor_configuration(add: Optional[int] = None)Dict[str, float][source]

Query the motor configuration and returns it in a dictionary.

Parameters

add – controller address (1 to 31)

Returns

dictionary containing the motor’s configuration

Raises
get_move_duration(dist: Union[int, float], add: Optional[int] = None)float[source]

Estimate the time necessary to move the motor of the specified distance.

Parameters
  • dist – distance to travel

  • add – controller address (1 to 31), defaults to self.address

Raises
get_negative_software_limit(add: Optional[int] = None)Union[int, float][source]

Get the negative software limit (the maximum position that the motor is allowed to travel to towards the left).

Parameters

add – controller address (1 to 31)

Returns

negative software limit (preset units), value between -1e12 and 0

Raises
get_position(add: Optional[int] = None)float[source]

Returns the value of the current position.

Parameters

add – controller address (1 to 31)

Raises
get_positive_software_limit(add: Optional[int] = None)Union[int, float][source]

Get the positive software limit (the maximum position that the motor is allowed to travel to towards the right).

Parameters

add – controller address (1 to 31)

Returns

positive software limit (preset units), value between 0 and 1e12

Raises
get_state(add: int = None)StateMessages[source]

Check on the motor errors and the controller state

Parameters

add – controller address (1 to 31)

Raises
Returns

state message from the device (member of StateMessages)

go_home(add: Optional[int] = None)None[source]

Move the motor to its home position.

Parameters

add – controller address (1 to 31), defaults to self.address

Raises
go_to_configuration(add: Optional[int] = None)None[source]

This method is executed during start(). It can also be executed after a reset(). The controller is put in CONFIG state, where configuration parameters can be changed.

Parameters

add – controller address (1 to 31)

Raises
initialize(add: Optional[int] = None)None[source]

Puts the controller from the NOT_REF state to the READY state. Sends the motor to its “home” position.

Parameters

add – controller address (1 to 31)

Raises
move_to_absolute_position(pos: Union[int, float], add: Optional[int] = None)None[source]

Move the motor to the specified position.

Parameters
  • pos – target absolute position (affected by the configured offset)

  • add – controller address (1 to 31), defaults to self.address

Raises
move_to_relative_position(pos: Union[int, float], add: Optional[int] = None)None[source]

Move the motor of the specified distance.

Parameters
  • pos – distance to travel (the sign gives the direction)

  • add – controller address (1 to 31), defaults to self.address

Raises
reset(add: Optional[int] = None)None[source]

Resets the controller, equivalent to a power-up. This puts the controller back to NOT REFERENCED state, which is necessary for configuring the controller.

Parameters

add – controller address (1 to 31)

Raises
set_acceleration(acc: Union[int, float], add: Optional[int] = None)None[source]

Leave the configuration state. The configuration parameters are saved to the device”s memory.

Parameters
  • acc – acceleration (preset units/s^2), value between 1e-6 and 1e12

  • add – controller address (1 to 31)

Raises
set_motor_configuration(add: Optional[int] = None, config: Optional[dict] = None)None[source]

Set the motor configuration. The motor must be in CONFIG state.

Parameters
  • add – controller address (1 to 31)

  • config – dictionary containing the motor’s configuration

Raises
set_negative_software_limit(lim: Union[int, float], add: Optional[int] = None)None[source]

Set the negative software limit (the maximum position that the motor is allowed to travel to towards the left).

Parameters
  • lim – negative software limit (preset units), value between -1e12 and 0

  • add – controller address (1 to 31)

Raises
set_positive_software_limit(lim: Union[int, float], add: Optional[int] = None)None[source]

Set the positive software limit (the maximum position that the motor is allowed to travel to towards the right).

Parameters
  • lim – positive software limit (preset units), value between 0 and 1e12

  • add – controller address (1 to 31)

Raises
start()[source]

Opens the communication protocol and applies the config.

Raises

SerialCommunicationIOError – when communication port cannot be opened

stop()None[source]

Stop the device. Close the communication protocol.

stop_motion(add: Optional[int] = None)None[source]

Stop a move in progress by decelerating the positioner immediately with the configured acceleration until it stops. If a controller address is provided, stops a move in progress on this controller, else stops the moves on all controllers.

Parameters

add – controller address (1 to 31)

Raises
wait_until_motor_initialized(add: Optional[int] = None)None[source]

Wait until the motor leaves the HOMING state (at which point it should have arrived to the home position).

Parameters

add – controller address (1 to 31)

Raises
class hvl_ccb.dev.newport.NewportSMC100PPConfig(address: int = 1, user_position_offset: Union[int, float] = 23.987, screw_scaling: Union[int, float] = 1, exit_configuration_wait_sec: Union[int, float] = 5, move_wait_sec: Union[int, float] = 1, acceleration: Union[int, float] = 10, backlash_compensation: Union[int, float] = 0, hysteresis_compensation: Union[int, float] = 0.015, micro_step_per_full_step_factor: int = 100, motion_distance_per_full_step: Union[int, float] = 0.01, home_search_type: Union[int, hvl_ccb.dev.newport.NewportSMC100PPConfig.HomeSearch] = <HomeSearch.HomeSwitch: 2>, jerk_time: Union[int, float] = 0.04, home_search_velocity: Union[int, float] = 4, home_search_timeout: Union[int, float] = 27.5, home_search_polling_interval: Union[int, float] = 1, peak_output_current_limit: Union[int, float] = 0.4, rs485_address: int = 2, negative_software_limit: Union[int, float] = -23.5, positive_software_limit: Union[int, float] = 25, velocity: Union[int, float] = 4, base_velocity: Union[int, float] = 0, stage_configuration: Union[int, hvl_ccb.dev.newport.NewportSMC100PPConfig.EspStageConfig] = <EspStageConfig.EnableEspStageCheck: 3>)[source]

Bases: object

Configuration dataclass for the Newport motor controller SMC100PP.

class EspStageConfig(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: aenum.IntEnum

Different configurations to check or not the motor configuration upon power-up.

DisableEspStageCheck = 1
EnableEspStageCheck = 3
UpdateEspStageInfo = 2
class HomeSearch(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: aenum.IntEnum

Different methods for the motor to search its home position during initialization.

CurrentPosition = 1
EndOfRunSwitch = 4
EndOfRunSwitch_and_Index = 3
HomeSwitch = 2
HomeSwitch_and_Index = 0
acceleration: Union[int, float] = 10
address: int = 1
backlash_compensation: Union[int, float] = 0
base_velocity: Union[int, float] = 0
clean_values()[source]
exit_configuration_wait_sec: Union[int, float] = 5
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

home_search_polling_interval: Union[int, float] = 1
home_search_timeout: Union[int, float] = 27.5
home_search_type: Union[int, hvl_ccb.dev.newport.NewportSMC100PPConfig.HomeSearch] = 2
home_search_velocity: Union[int, float] = 4
hysteresis_compensation: Union[int, float] = 0.015
is_configdataclass = True
jerk_time: Union[int, float] = 0.04
classmethod keys()Sequence[str]

Returns a list of all configdataclass fields key-names.

Returns

a list of strings containing all keys.

micro_step_per_full_step_factor: int = 100
motion_distance_per_full_step: Union[int, float] = 0.01
property motor_config

Gather the configuration parameters of the motor into a dictionary.

Returns

dict containing the configuration parameters of the motor

move_wait_sec: Union[int, float] = 1
negative_software_limit: Union[int, float] = -23.5
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.

peak_output_current_limit: Union[int, float] = 0.4
positive_software_limit: Union[int, float] = 25
post_force_value(fieldname, value)[source]
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.

rs485_address: int = 2
screw_scaling: Union[int, float] = 1
stage_configuration: Union[int, hvl_ccb.dev.newport.NewportSMC100PPConfig.EspStageConfig] = 3
user_position_offset: Union[int, float] = 23.987
velocity: Union[int, float] = 4
class hvl_ccb.dev.newport.NewportSMC100PPSerialCommunication(configuration)[source]

Bases: hvl_ccb.comm.serial.SerialCommunication

Specific communication protocol implementation Heinzinger power supplies. Already predefines device-specific protocol parameters in config.

class ControllerErrors(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: aenum.Enum

Possible controller errors with values as returned by the device in response to sent commands.

ADDR_INCORRECT = 'B'
CMD_EXEC_ERROR = 'V'
CMD_NOT_ALLOWED = 'D'
CMD_NOT_ALLOWED_CC = 'X'
CMD_NOT_ALLOWED_CONFIGURATION = 'I'
CMD_NOT_ALLOWED_DISABLE = 'J'
CMD_NOT_ALLOWED_HOMING = 'L'
CMD_NOT_ALLOWED_MOVING = 'M'
CMD_NOT_ALLOWED_NOT_REFERENCED = 'H'
CMD_NOT_ALLOWED_PP = 'W'
CMD_NOT_ALLOWED_READY = 'K'
CODE_OR_ADDR_INVALID = 'A'
COM_TIMEOUT = 'S'
DISPLACEMENT_OUT_OF_LIMIT = 'G'
EEPROM_ACCESS_ERROR = 'U'
ESP_STAGE_NAME_INVALID = 'F'
HOME_STARTED = 'E'
NO_ERROR = '@'
PARAM_MISSING_OR_INVALID = 'C'
POSITION_OUT_OF_LIMIT = 'N'
check_for_error(add: int)None[source]

Ask the Newport controller for the last error it recorded.

This method is called after every command or query.

Parameters

add – controller address (1 to 31)

Raises
static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

query(add: int, cmd: str, param: Optional[Union[int, float, str]] = None)str[source]

Send a query to the controller, read the answer, and check for errors. The prefix add+cmd is removed from the answer.

Parameters
  • add – the controller address (1 to 31)

  • cmd – the command to be sent

  • param – optional parameter (int/float/str) appended to the command

Returns

the answer from the device without the prefix

Raises
query_multiple(add: int, cmd: str, prefixes: List[str])List[str][source]

Send a query to the controller, read the answers, and check for errors. The prefixes are removed from the answers.

Parameters
  • add – the controller address (1 to 31)

  • cmd – the command to be sent

  • prefixes – prefixes of each line expected in the answer

Returns

list of answers from the device without prefix

Raises
read_text()str[source]

Read one line of text from the serial port, and check for presence of a null char which indicates that the motor power supply was cut and then restored. The input buffer may hold additional data afterwards, since only one line is read.

This method uses self.access_lock to ensure thread-safety.

Returns

String read from the serial port; ‘’ if there was nothing to read.

Raises
send_command(add: int, cmd: str, param: Optional[Union[int, float, str]] = None)None[source]

Send a command to the controller, and check for errors.

Parameters
  • add – the controller address (1 to 31)

  • cmd – the command to be sent

  • param – optional parameter (int/float/str) appended to the command

Raises
send_stop(add: int)None[source]

Send the general stop ST command to the controller, and check for errors.

Parameters

add – the controller address (1 to 31)

Returns

ControllerErrors reported by Newport Controller

Raises
class hvl_ccb.dev.newport.NewportSMC100PPSerialCommunicationConfig(terminator: bytes = b'\r\n', encoding: str = 'utf-8', encoding_error_handling: str = 'replace', wait_sec_read_text_nonempty: Union[int, float] = 0.5, default_n_attempts_read_text_nonempty: int = 10, port: Union[str, NoneType] = None, baudrate: int = 57600, parity: Union[str, hvl_ccb.comm.serial.SerialCommunicationParity] = <SerialCommunicationParity.NONE: 'N'>, stopbits: Union[int, hvl_ccb.comm.serial.SerialCommunicationStopbits] = <SerialCommunicationStopbits.ONE: 1>, bytesize: Union[int, hvl_ccb.comm.serial.SerialCommunicationBytesize] = <SerialCommunicationBytesize.EIGHTBITS: 8>, timeout: Union[int, float] = 10)[source]

Bases: hvl_ccb.comm.serial.SerialCommunicationConfig

baudrate: int = 57600

Baudrate for Heinzinger power supplies is 9600 baud

bytesize: Union[int, hvl_ccb.comm.serial.SerialCommunicationBytesize] = 8

One byte is eight bits long

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

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.

parity: Union[str, hvl_ccb.comm.serial.SerialCommunicationParity] = 'N'

Heinzinger does not use parity

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.

stopbits: Union[int, hvl_ccb.comm.serial.SerialCommunicationStopbits] = 1

Heinzinger uses one stop bit

terminator: bytes = b'\r\n'

The terminator is CR/LF

timeout: Union[int, float] = 10

use 10 seconds timeout as default

exception hvl_ccb.dev.newport.NewportSerialCommunicationError[source]

Bases: Exception

Communication error with the Newport controller.

class hvl_ccb.dev.newport.NewportStates(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: hvl_ccb.utils.enum.AutoNumberNameEnum

States of the Newport controller. Certain commands are allowed only in certain states.

CONFIG = 3
DISABLE = 6
HOMING = 2
JOGGING = 7
MOVING = 5
NO_REF = 1
READY = 4
exception hvl_ccb.dev.newport.NewportUncertainPositionError[source]

Bases: Exception

Error with the position of the Newport motor.

hvl_ccb.dev.pfeiffer_tpg module

Device class for Pfeiffer TPG controllers.

The Pfeiffer TPG control units are used to control Pfeiffer Compact Gauges. Models: TPG 251 A, TPG 252 A, TPG 256A, TPG 261, TPG 262, TPG 361, TPG 362 and TPG 366.

Manufacturer homepage: https://www.pfeiffer-vacuum.com/en/products/measurement-analysis/ measurement/activeline/controllers/

class hvl_ccb.dev.pfeiffer_tpg.PfeifferTPG(com, dev_config=None)[source]

Bases: hvl_ccb.dev.base.SingleCommDevice

Pfeiffer TPG control unit device class

class PressureUnits(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: hvl_ccb.utils.enum.NameEnum

Enum of available pressure units for the digital display. “0” corresponds either to bar or to mbar depending on the TPG model. In case of doubt, the unit is visible on the digital display.

Micron = 3
Pascal = 2
Torr = 1
Volt = 5
bar = 0
hPascal = 4
mbar = 0
class SensorStatus(value)[source]

Bases: enum.IntEnum

An enumeration.

Identification_error = 6
No_sensor = 5
Ok = 0
Overrange = 2
Sensor_error = 3
Sensor_off = 4
Underrange = 1
class SensorTypes(value)

Bases: enum.Enum

An enumeration.

CMR = 4
IKR = 2
IKR11 = 2
IKR9 = 2
IMR = 5
None = 7
PBR = 6
PKR = 3
TPR = 1
noSENSOR = 7
noSen = 7
static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

static default_com_cls()[source]

Get the class for the default communication protocol used with this device.

Returns

the type of the standard communication protocol for this device

get_full_scale_mbar()List[Union[int, float]][source]

Get the full scale range of the attached sensors

Returns

full scale range values in mbar, like [0.01, 1, 0.1, 1000, 50000, 10]

Raises
get_full_scale_unitless()List[int][source]

Get the full scale range of the attached sensors. See lookup table between command and corresponding pressure in the device user manual.

Returns

list of full scale range values, like [0, 1, 3, 3, 2, 0]

Raises
identify_sensors()None[source]

Send identification request TID to sensors on all channels.

Raises
measure(channel: int)Tuple[str, float][source]

Get the status and measurement of one sensor

Parameters

channel – int channel on which the sensor is connected, with 1 <= channel <= number_of_sensors

Returns

measured value as float if measurement successful, sensor status as string if not

Raises
measure_all()List[Tuple[str, float]][source]

Get the status and measurement of all sensors (this command is not available on all models)

Returns

list of measured values as float if measurements successful, and or sensor status as strings if not

Raises
property number_of_sensors
set_display_unit(unit: Union[str, hvl_ccb.dev.pfeiffer_tpg.PfeifferTPG.PressureUnits])None[source]

Set the unit in which the measurements are shown on the display.

Raises
set_full_scale_mbar(fsr: List[Union[int, float]])None[source]

Set the full scale range of the attached sensors (in unit mbar)

Parameters

fsr – full scale range values in mbar, for example [0.01, 1000]

Raises
set_full_scale_unitless(fsr: List[int])None[source]

Set the full scale range of the attached sensors. See lookup table between command and corresponding pressure in the device user manual.

Parameters

fsr – list of full scale range values, like [0, 1, 3, 3, 2, 0]

Raises
start()None[source]

Start this device. Opens the communication protocol, and identify the sensors.

Raises

SerialCommunicationIOError – when communication port cannot be opened

stop()None[source]

Stop the device. Closes also the communication protocol.

property unit

The pressure unit of readings is always mbar, regardless of the display unit.

class hvl_ccb.dev.pfeiffer_tpg.PfeifferTPGConfig(model: Union[str, hvl_ccb.dev.pfeiffer_tpg.PfeifferTPGConfig.Model] = <Model.TPG25xA: {1: 0, 10: 1, 100: 2, 1000: 3, 2000: 4, 5000: 5, 10000: 6, 50000: 7, 0.1: 8}>)[source]

Bases: object

Device configuration dataclass for Pfeiffer TPG controllers.

class Model(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: hvl_ccb.utils.enum.NameEnum

An enumeration.

TPG25xA = {0.1: 8, 1: 0, 10: 1, 100: 2, 1000: 3, 2000: 4, 5000: 5, 10000: 6, 50000: 7}
TPGx6x = {0.01: 0, 0.1: 1, 1: 2, 10: 3, 100: 4, 1000: 5, 2000: 6, 5000: 7, 10000: 8, 50000: 9}
is_valid_scale_range_reversed_str(v: str)bool[source]

Check if given string represents a valid reversed scale range of a model.

Parameters

v – Reversed scale range string.

Returns

True if valid, False otherwise.

clean_values()[source]
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.

model: Union[str, hvl_ccb.dev.pfeiffer_tpg.PfeifferTPGConfig.Model] = {0.1: 8, 1: 0, 10: 1, 100: 2, 1000: 3, 2000: 4, 5000: 5, 10000: 6, 50000: 7}
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.

exception hvl_ccb.dev.pfeiffer_tpg.PfeifferTPGError[source]

Bases: Exception

Error with the Pfeiffer TPG Controller.

class hvl_ccb.dev.pfeiffer_tpg.PfeifferTPGSerialCommunication(configuration)[source]

Bases: hvl_ccb.comm.serial.SerialCommunication

Specific communication protocol implementation for Pfeiffer TPG controllers. Already predefines device-specific protocol parameters in config.

static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

query(cmd: str)str[source]

Send a query, then read and returns the first line from the com port.

Parameters

cmd – query message to send to the device

Returns

first line read on the com

Raises
send_command(cmd: str)None[source]

Send a command to the device and check for acknowledgement.

Parameters

cmd – command to send to the device

Raises
class hvl_ccb.dev.pfeiffer_tpg.PfeifferTPGSerialCommunicationConfig(terminator: bytes = b'\r\n', encoding: str = 'utf-8', encoding_error_handling: str = 'replace', wait_sec_read_text_nonempty: Union[int, float] = 0.5, default_n_attempts_read_text_nonempty: int = 10, port: Union[str, NoneType] = None, baudrate: int = 9600, parity: Union[str, hvl_ccb.comm.serial.SerialCommunicationParity] = <SerialCommunicationParity.NONE: 'N'>, stopbits: Union[int, hvl_ccb.comm.serial.SerialCommunicationStopbits] = <SerialCommunicationStopbits.ONE: 1>, bytesize: Union[int, hvl_ccb.comm.serial.SerialCommunicationBytesize] = <SerialCommunicationBytesize.EIGHTBITS: 8>, timeout: Union[int, float] = 3)[source]

Bases: hvl_ccb.comm.serial.SerialCommunicationConfig

baudrate: int = 9600

Baudrate for Pfeiffer TPG controllers is 9600 baud

bytesize: Union[int, hvl_ccb.comm.serial.SerialCommunicationBytesize] = 8

One byte is eight bits long

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

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.

parity: Union[str, hvl_ccb.comm.serial.SerialCommunicationParity] = 'N'

Pfeiffer TPG controllers do not use parity

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.

stopbits: Union[int, hvl_ccb.comm.serial.SerialCommunicationStopbits] = 1

Pfeiffer TPG controllers use one stop bit

terminator: bytes = b'\r\n'

The terminator is <CR><LF>

timeout: Union[int, float] = 3

use 3 seconds timeout as default

hvl_ccb.dev.rs_rto1024 module

Python module for the Rhode & Schwarz RTO 1024 oscilloscope. The communication to the device is through VISA, type TCPIP / INSTR.

class hvl_ccb.dev.rs_rto1024.RTO1024(com: Union[hvl_ccb.dev.rs_rto1024.RTO1024VisaCommunication, hvl_ccb.dev.rs_rto1024.RTO1024VisaCommunicationConfig, dict], dev_config: Union[hvl_ccb.dev.rs_rto1024.RTO1024Config, dict])[source]

Bases: hvl_ccb.dev.visa.VisaDevice

Device class for the Rhode & Schwarz RTO 1024 oscilloscope.

class TriggerModes(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: hvl_ccb.utils.enum.AutoNumberNameEnum

Enumeration for the three available trigger modes.

AUTO = 1
FREERUN = 3
NORMAL = 2
classmethod names()[source]

Returns a list of the available trigger modes. :return: list of strings

activate_measurements(meas_n: int, source: str, measurements: List[str], category: str = 'AMPTime')[source]

Activate the list of ‘measurements’ of the waveform ‘source’ in the measurement box number ‘meas_n’. The list ‘measurements’ starts with the main measurement and continues with additional measurements of the same ‘category’.

Parameters
  • meas_n – measurement number 1..8

  • source – measurement source, for example C1W1

  • measurements – list of measurements, the first one will be the main measurement.

  • category – the category of measurements, by default AMPTime

backup_waveform(filename: str)None[source]

Backup a waveform file from the standard directory specified in the device configuration to the standard backup destination specified in the device configuration. The filename has to be specified without .bin or path.

Parameters

filename – The waveform filename without extension and path

static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

static default_com_cls()[source]

Return the default communication protocol for this device type, which is VisaCommunication.

Returns

the VisaCommunication class

file_copy(source: str, destination: str)None[source]

Copy a file from one destination to another on the oscilloscope drive. If the destination file already exists, it is overwritten without notice.

Parameters
  • source – absolute path to the source file on the DSO filesystem

  • destination – absolute path to the destination file on the DSO filesystem

Raises

RTO1024Error – if the operation did not complete

get_acquire_length()float[source]

Gets the time of one acquisition, that is the time across the 10 divisions of the diagram.

  • Range: 250E-12 … 500 [s]

  • Increment: 1E-12 [s]

Returns

the time for one acquisition. Range: 250e-12 … 500 [s]

get_channel_offset(channel: int)float[source]

Gets the voltage offset of the indicated channel.

Parameters

channel – is the channel number (1..4)

Returns

channel offset voltage in V (value between -1 and 1)

get_channel_position(channel: int)float[source]

Gets the vertical position of the indicated channel.

Parameters

channel – is the channel number (1..4)

Returns

channel position in div (value between -5 and 5)

get_channel_range(channel: int)float[source]

Queries the channel range in V.

Parameters

channel – is the input channel (1..4)

Returns

channel range in V

get_channel_scale(channel: int)float[source]

Queries the channel scale in V/div.

Parameters

channel – is the input channel (1..4)

Returns

channel scale in V/div

get_channel_state(channel: int)bool[source]

Queries if the channel is active or not.

Parameters

channel – is the input channel (1..4)

Returns

True if active, else False

get_reference_point()int[source]

Gets the reference point of the time scale in % of the display. If the “Trigger offset” is zero, the trigger point matches the reference point. ReferencePoint = zero pint of the time scale

  • Range: 0 … 100 [%]

  • Increment: 1 [%]

Returns

the reference in %

get_repetitions()int[source]

Get the number of acquired waveforms with RUN Nx SINGLE. Also defines the number of waveforms used to calculate the average waveform.

  • Range: 1 … 16777215

  • Increment: 10

  • *RST = 1

Returns

the number of waveforms to acquire

get_timestamps()List[float][source]

Gets the timestamps of all recorded frames in the history and returns them as a list of floats.

Returns

list of timestamps in [s]

Raises

RTO1024Error – if the timestamps are invalid

list_directory(path: str)List[Tuple[str, str, int]][source]

List the contents of a given directory on the oscilloscope filesystem.

Parameters

path – is the path to a folder

Returns

a list of filenames in the given folder

load_configuration(filename: str)None[source]

Load current settings from a configuration file. The filename has to be specified without base directory and ‘.dfl’ extension.

Information from the manual ReCaLl calls up the instrument settings from an intermediate memory identified by the specified number. The instrument settings can be stored to this memory using the command *SAV with the associated number. It also activates the instrument settings which are stored in a file and loaded using MMEMory:LOAD:STATe .

Parameters

filename – is the name of the settings file without path and extension

local_display(state: bool)None[source]

Enable or disable local display of the scope.

Parameters

state – is the desired local display state

prepare_ultra_segmentation()None[source]

Make ready for a new acquisition in ultra segmentation mode. This function does one acquisition without ultra segmentation to clear the history and prepare for a new measurement.

read_measurement(meas_n: int, name: str)float[source]
Parameters
  • meas_n – measurement number 1..8

  • name – measurement name, for example “MAX”

Returns

measured value

run_continuous_acquisition()None[source]

Start acquiring continuously.

run_single_acquisition()None[source]

Start a single or Nx acquisition.

save_configuration(filename: str)None[source]

Save the current oscilloscope settings to a file. The filename has to be specified without path and ‘.dfl’ extension, the file will be saved to the configured settings directory.

Information from the manual SAVe stores the current instrument settings under the specified number in an intermediate memory. The settings can be recalled using the command *RCL with the associated number. To transfer the stored instrument settings to a file, use MMEMory:STORe:STATe .

Parameters

filename – is the name of the settings file without path and extension

save_waveform_history(filename: str, channel: int, waveform: int = 1)None[source]

Save the history of one channel and one waveform to a .bin file. This function is used after an acquisition using sequence trigger mode (with or without ultra segmentation) was performed.

Parameters
  • filename – is the name (without extension) of the file

  • channel – is the channel number

  • waveform – is the waveform number (typically 1)

Raises

RTO1024Error – if storing waveform times out

set_acquire_length(timerange: float)None[source]

Defines the time of one acquisition, that is the time across the 10 divisions of the diagram.

  • Range: 250E-12 … 500 [s]

  • Increment: 1E-12 [s]

  • *RST = 0.5 [s]

Parameters

timerange – is the time for one acquisition. Range: 250e-12 … 500 [s]

set_channel_offset(channel: int, offset: float)None[source]

Sets the voltage offset of the indicated channel.

  • Range: Dependent on the channel scale and coupling [V]

  • Increment: Minimum 0.001 [V], may be higher depending on the channel scale and coupling

  • *RST = 0

Parameters
  • channel – is the channel number (1..4)

  • offset – Offset voltage. Positive values move the waveform down, negative values move it up.

set_channel_position(channel: int, position: float)None[source]

Sets the vertical position of the indicated channel as a graphical value.

  • Range: -5.0 … 5.0 [div]

  • Increment: 0.02

  • *RST = 0

Parameters
  • channel – is the channel number (1..4)

  • position – is the position. Positive values move the waveform up, negative values move it down.

set_channel_range(channel: int, v_range: float)None[source]

Sets the voltage range across the 10 vertical divisions of the diagram. Use the command alternatively instead of set_channel_scale.

  • Range for range: Depends on attenuation factors and coupling. With 1:1 probe and external attenuations and 50 Ω input coupling, the range is 10 mV to 10 V. For 1 MΩ input coupling, it is 10 mV to 100 V. If the probe and/or external attenuation is changed, multiply the range values by the attenuation factors.

  • Increment: 0.01

  • *RST = 0.5

Parameters
  • channel – is the channel number (1..4)

  • v_range – is the vertical range [V]

set_channel_scale(channel: int, scale: float)None[source]

Sets the vertical scale for the indicated channel. The scale value is given in volts per division.

  • Range for scale: depends on attenuation factor and coupling. With 1:1 probe and external attenuations and 50 Ω input coupling, the vertical scale (input sensitivity) is 1 mV/div to 1 V/div. For 1 MΩ input coupling, it is 1 mV/div to 10 V/div. If the probe and/or external attenuation is changed, multiply the values by the attenuation factors to get the actual scale range.

  • Increment: 1e-3

  • *RST = 0.05

See also: set_channel_range

Parameters
  • channel – is the channel number (1..4)

  • scale – is the vertical scaling [V/div]

set_channel_state(channel: int, state: bool)None[source]

Switches the channel signal on or off.

Parameters
  • channel – is the input channel (1..4)

  • state – is True for on, False for off

set_reference_point(percentage: int)None[source]

Sets the reference point of the time scale in % of the display. If the “Trigger offset” is zero, the trigger point matches the reference point. ReferencePoint = zero pint of the time scale

  • Range: 0 … 100 [%]

  • Increment: 1 [%]

  • *RST = 50 [%]

Parameters

percentage – is the reference in %

set_repetitions(number: int)None[source]

Set the number of acquired waveforms with RUN Nx SINGLE. Also defines the number of waveforms used to calculate the average waveform.

  • Range: 1 … 16777215

  • Increment: 10

  • *RST = 1

Parameters

number – is the number of waveforms to acquire

set_trigger_level(channel: int, level: float, event_type: int = 1)None[source]

Sets the trigger level for the specified event and source.

  • Range: -10 to 10 V

  • Increment: 1e-3 V

  • *RST = 0 V

Parameters
  • channel

    indicates the trigger source.

    • 1..4 = channel 1 to 4, available for all event types 1..3

    • 5 = external trigger input on the rear panel for analog signals, available for A-event type = 1

    • 6..9 = not available

  • level – is the voltage for the trigger level in [V].

  • event_type – is the event type. 1: A-Event, 2: B-Event, 3: R-Event

set_trigger_mode(mode: Union[str, hvl_ccb.dev.rs_rto1024.RTO1024.TriggerModes])None[source]

Sets the trigger mode which determines the behavior of the instrument if no trigger occurs.

Parameters

mode – is either auto, normal, or freerun.

Raises

RTO1024Error – if an invalid triggermode is selected

set_trigger_source(channel: int, event_type: int = 1)None[source]

Set the trigger (Event A) source channel.

Parameters
  • channel – is the channel number (1..4)

  • event_type – is the event type. 1: A-Event, 2: B-Event, 3: R-Event

start()None[source]

Start the RTO1024 oscilloscope and bring it into a defined state and remote mode.

stop()None[source]

Stop the RTO1024 oscilloscope, reset events and close communication. Brings back the device to a state where local operation is possible.

stop_acquisition()None[source]

Stop any acquisition.

class hvl_ccb.dev.rs_rto1024.RTO1024Config(waveforms_path: str, settings_path: str, backup_path: str, spoll_interval: Union[int, float] = 0.5, spoll_start_delay: Union[int, float] = 2, command_timeout_seconds: Union[int, float] = 60, wait_sec_short_pause: Union[int, float] = 0.1, wait_sec_enable_history: Union[int, float] = 1, wait_sec_post_acquisition_start: Union[int, float] = 2)[source]

Bases: hvl_ccb.dev.visa.VisaDeviceConfig, hvl_ccb.dev.rs_rto1024._RTO1024ConfigDefaultsBase, hvl_ccb.dev.rs_rto1024._RTO1024ConfigBase

Configdataclass for the RTO1024 device.

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

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.

exception hvl_ccb.dev.rs_rto1024.RTO1024Error[source]

Bases: Exception

class hvl_ccb.dev.rs_rto1024.RTO1024VisaCommunication(configuration)[source]

Bases: hvl_ccb.comm.visa.VisaCommunication

Specialization of VisaCommunication for the RTO1024 oscilloscope

static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

class hvl_ccb.dev.rs_rto1024.RTO1024VisaCommunicationConfig(host: str, interface_type: Union[str, hvl_ccb.comm.visa.VisaCommunicationConfig.InterfaceType] = <InterfaceType.TCPIP_INSTR: 2>, board: int = 0, port: int = 5025, timeout: int = 5000, chunk_size: int = 204800, open_timeout: int = 1000, write_termination: str = '\n', read_termination: str = '\n', visa_backend: str = '')[source]

Bases: hvl_ccb.comm.visa.VisaCommunicationConfig

Configuration dataclass for VisaCommunication with specifications for the RTO1024 device class.

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

interface_type: Union[str, hvl_ccb.comm.visa.VisaCommunicationConfig.InterfaceType] = 2

Interface type of the VISA connection, being one of InterfaceType.

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.dev.se_ils2t module

Device class for controlling a Schneider Electric ILS2T stepper drive over modbus TCP.

class hvl_ccb.dev.se_ils2t.ILS2T(com, dev_config=None)[source]

Bases: hvl_ccb.dev.base.SingleCommDevice

Schneider Electric ILS2T stepper drive class.

ACTION_JOG_VALUE = 0

The single action value for ILS2T.Mode.JOG

class ActionsPtp(value)[source]

Bases: enum.IntEnum

Allowed actions in the point to point mode (ILS2T.Mode.PTP).

ABSOLUTE_POSITION = 0
RELATIVE_POSITION_MOTOR = 2
RELATIVE_POSITION_TARGET = 1
DEFAULT_IO_SCANNING_CONTROL_VALUES = {'action': 2, 'continue_after_stop_cu': 0, 'disable_driver_di': 0, 'enable_driver_en': 0, 'execute_stop_sh': 0, 'fault_reset_fr': 0, 'mode': 3, 'quick_stop_qs': 0, 'ref_16': 1500, 'ref_32': 0, 'reset_stop_ch': 0}

Default IO Scanning control mode values

class Mode(value)[source]

Bases: enum.IntEnum

ILS2T device modes

JOG = 1
PTP = 3
class Ref16Jog(value)[source]

Bases: enum.Flag

Allowed values for ILS2T ref_16 register (the shown values are the integer representation of the bits), all in Jog mode = 1

FAST = 4
NEG = 2
NEG_FAST = 6
NONE = 0
POS = 1
POS_FAST = 5
RegAddr

Modbus Register Adresses

alias of hvl_ccb.dev.se_ils2t.ILS2TRegAddr

RegDatatype

Modbus Register Datatypes

alias of hvl_ccb.dev.se_ils2t.ILS2TRegDatatype

class State(value)[source]

Bases: enum.IntEnum

State machine status values

ON = 6
QUICKSTOP = 7
READY = 4
static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

static default_com_cls()[source]

Get the class for the default communication protocol used with this device.

Returns

the type of the standard communication protocol for this device

disable(log_warn: bool = True, wait_sec_max: Optional[int] = None)bool[source]

Disable the driver of the stepper motor and enable the brake.

Note: the driver cannot be disabled if the motor is still running.

Parameters
  • log_warn – if log a warning in case the motor cannot be disabled.

  • wait_sec_max – maximal wait time for the motor to stop running and to disable it; by default, with None, use a config value

Returns

True if disable request could and was sent, False otherwise.

do_ioscanning_write(**kwargs: int)None[source]

Perform a write operation using IO Scanning mode.

Parameters

kwargs – Keyword-argument list with options to send, remaining are taken from the defaults.

enable()None[source]

Enable the driver of the stepper motor and disable the brake.

execute_absolute_position(position: int)bool[source]

Execute a absolute position change, i.e. enable motor, perform absolute position change, wait until done and disable motor afterwards.

Check position at the end if wrong do not raise error; instead just log and return check result.

Parameters

position – absolute position of motor in user defined steps.

Returns

True if actual position is as expected, False otherwise.

execute_relative_step(steps: int)bool[source]

Execute a relative step, i.e. enable motor, perform relative steps, wait until done and disable motor afterwards.

Check position at the end if wrong do not raise error; instead just log and return check result.

Parameters

steps – Number of steps.

Returns

True if actual position is as expected, False otherwise.

get_dc_volt()float[source]

Read the DC supply voltage of the motor.

Returns

DC input voltage.

get_error_code()Dict[int, Dict[str, Any]][source]

Read all messages in fault memory. Will read the full error message and return the decoded values. At the end the fault memory of the motor will be deleted. In addition, reset_error is called to re-enable the motor for operation.

Returns

Dictionary with all information

get_position()int[source]

Read the position of the drive and store into status.

Returns

Position step value

get_status()Dict[str, int][source]

Perform an IO Scanning read and return the status of the motor.

Returns

dict with status information.

get_temperature()int[source]

Read the temperature of the motor.

Returns

Temperature in degrees Celsius.

jog_run(direction: bool = True, fast: bool = False)None[source]

Slowly turn the motor in positive direction.

jog_stop()None[source]

Stop turning the motor in Jog mode.

quickstop()None[source]

Stops the motor with high deceleration rate and falls into error state. Reset with reset_error to recover into normal state.

reset_error()None[source]

Resets the motor into normal state after quick stop or another error occured.

set_jog_speed(slow: int = 60, fast: int = 180)None[source]

Set the speed for jog mode. Default values correspond to startup values of the motor.

Parameters
  • slow – RPM for slow jog mode.

  • fast – RPM for fast jog mode.

set_max_acceleration(rpm_minute: int)None[source]

Set the maximum acceleration of the motor.

Parameters

rpm_minute – revolution per minute per minute

set_max_deceleration(rpm_minute: int)None[source]

Set the maximum deceleration of the motor.

Parameters

rpm_minute – revolution per minute per minute

set_max_rpm(rpm: int)None[source]

Set the maximum RPM.

Parameters

rpm – revolution per minute ( 0 < rpm <= RPM_MAX)

Raises

ILS2TException – if RPM is out of range

set_ramp_type(ramp_type: int = - 1)None[source]
Set the ramp type. There are two options available:

0: linear ramp -1: motor optimized ramp

Parameters

ramp_type – 0: linear ramp | -1: motor optimized ramp

start()None[source]

Start this device.

stop()None[source]

Stop this device. Disables the motor (applies brake), disables access and closes the communication protocol.

user_steps(steps: int = 16384, revolutions: int = 1)None[source]

Define steps per revolution. Default is 16384 steps per revolution. Maximum precision is 32768 steps per revolution.

Parameters
  • steps – number of steps in revolutions.

  • revolutions – number of revolutions corresponding to steps.

write_absolute_position(position: int)None[source]

Write instruction to turn the motor until it reaches the absolute position. This function does not enable or disable the motor automatically.

Parameters

position – absolute position of motor in user defined steps.

write_relative_step(steps: int)None[source]

Write instruction to turn the motor the relative amount of steps. This function does not enable or disable the motor automatically.

Parameters

steps – Number of steps to turn the motor.

class hvl_ccb.dev.se_ils2t.ILS2TConfig(rpm_max_init: numbers.Integral = 1500, wait_sec_post_enable: Union[int, float] = 1, wait_sec_max_disable: Union[int, float] = 10, wait_sec_post_cannot_disable: Union[int, float] = 1, wait_sec_post_relative_step: Union[int, float] = 2, wait_sec_post_absolute_position: Union[int, float] = 2)[source]

Bases: object

Configuration for the ILS2T stepper motor device.

clean_values()[source]
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.

rpm_max_init: numbers.Integral = 1500

initial maximum RPM for the motor, can be set up to 3000 RPM. The user is allowed to set a new max RPM at runtime using ILS2T.set_max_rpm(), but the value must never exceed this configuration setting.

wait_sec_max_disable: Union[int, float] = 10
wait_sec_post_absolute_position: Union[int, float] = 2
wait_sec_post_cannot_disable: Union[int, float] = 1
wait_sec_post_enable: Union[int, float] = 1
wait_sec_post_relative_step: Union[int, float] = 2
exception hvl_ccb.dev.se_ils2t.ILS2TException[source]

Bases: Exception

Exception to indicate problems with the SE ILS2T stepper motor.

class hvl_ccb.dev.se_ils2t.ILS2TModbusTcpCommunication(configuration)[source]

Bases: hvl_ccb.comm.modbus_tcp.ModbusTcpCommunication

Specific implementation of Modbus/TCP for the Schneider Electric ILS2T stepper motor.

static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

class hvl_ccb.dev.se_ils2t.ILS2TModbusTcpCommunicationConfig(host: str, unit: int = 255, port: int = 502)[source]

Bases: hvl_ccb.comm.modbus_tcp.ModbusTcpCommunicationConfig

Configuration dataclass for Modbus/TCP communciation specific for the Schneider Electric ILS2T stepper motor.

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

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.

unit: int = 255

The unit has to be 255 such that IO scanning mode works.

class hvl_ccb.dev.se_ils2t.ILS2TRegAddr(value)[source]

Bases: enum.IntEnum

Modbus Register Adresses for for Schneider Electric ILS2T stepper drive.

ACCESS_ENABLE = 282
FLT_INFO = 15362
FLT_MEM_DEL = 15112
FLT_MEM_RESET = 15114
IO_SCANNING = 6922
JOGN_FAST = 10506
JOGN_SLOW = 10504
POSITION = 7706
RAMP_ACC = 1556
RAMP_DECEL = 1558
RAMP_N_MAX = 1554
RAMP_TYPE = 1574
SCALE = 1550
TEMP = 7200
VOLT = 7198
class hvl_ccb.dev.se_ils2t.ILS2TRegDatatype(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: aenum.Enum

Modbus Register Datatypes for Schneider Electric ILS2T stepper drive.

From the manual of the drive:

datatype

byte

min

max

INT8

1 Byte

-128

127

UINT8

1 Byte

0

255

INT16

2 Byte

-32_768

32_767

UINT16

2 Byte

0

65_535

INT32

4 Byte

-2_147_483_648

2_147_483_647

UINT32

4 Byte

0

4_294_967_295

BITS

just 32bits

N/A

N/A

INT32 = (-2147483648, 2147483647)
is_in_range(value: int)bool[source]
exception hvl_ccb.dev.se_ils2t.IoScanningModeValueError[source]

Bases: hvl_ccb.dev.se_ils2t.ILS2TException

Exception to indicate that the selected IO scanning mode is invalid.

exception hvl_ccb.dev.se_ils2t.ScalingFactorValueError[source]

Bases: hvl_ccb.dev.se_ils2t.ILS2TException

Exception to indicate that a scaling factor value is invalid.

hvl_ccb.dev.sst_luminox module

Device class for a SST Luminox Oxygen sensor. This device can measure the oxygen concentration between 0 % and 25 %.

Furthermore, it measures the barometric pressure and internal temperature. The device supports two operating modes: in streaming mode the device measures all parameters every second, in polling mode the device measures only after a query.

Technical specification and documentation for the device can be found a the manufacturer’s page: https://www.sstsensing.com/product/luminox-optical-oxygen-sensors-2/

class hvl_ccb.dev.sst_luminox.Luminox(com, dev_config=None)[source]

Bases: hvl_ccb.dev.base.SingleCommDevice

Luminox oxygen sensor device class.

activate_output(mode: hvl_ccb.dev.sst_luminox.LuminoxOutputMode)None[source]

activate the selected output mode of the Luminox Sensor. :param mode: polling or streaming

static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

static default_com_cls()[source]

Get the class for the default communication protocol used with this device.

Returns

the type of the standard communication protocol for this device

query_polling(measurement: Union[str, hvl_ccb.dev.sst_luminox.LuminoxMeasurementType])Union[Dict[Union[str, hvl_ccb.dev.sst_luminox.LuminoxMeasurementType], Union[float, int, str]], float, int, str][source]

Query a value or values of Luminox measurements in the polling mode, according to a given measurement type.

Parameters

measurement – type of measurement

Returns

value of requested measurement

Raises
read_streaming()Dict[Union[str, hvl_ccb.dev.sst_luminox.LuminoxMeasurementType], Union[float, int, str]][source]

Read values of Luminox in the streaming mode. Convert the single string into separate values.

Returns

dictionary with LuminoxMeasurementType.all_measurements_types() keys and accordingly type-parsed values.

Raises
start()None[source]

Start this device. Opens the communication protocol.

stop()None[source]

Stop the device. Closes also the communication protocol.

class hvl_ccb.dev.sst_luminox.LuminoxConfig(wait_sec_post_activate: Union[int, float] = 0.5, wait_sec_trials_activate: Union[int, float] = 0.1, nr_trials_activate: int = 5)[source]

Bases: object

Configuration for the SST Luminox oxygen sensor.

clean_values()[source]
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.

nr_trials_activate: int = 5
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.

wait_sec_post_activate: Union[int, float] = 0.5
wait_sec_trials_activate: Union[int, float] = 0.1
class hvl_ccb.dev.sst_luminox.LuminoxMeasurementType(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: hvl_ccb.utils.enum.ValueEnum

Measurement types for LuminoxOutputMode.polling.

The all_measurements type will read values for the actual measurement types as given in LuminoxOutputMode.all_measurements_types(); it parses multiple single values using regexp’s for other measurement types, therefore, no regexp is defined for this measurement type.

all_measurements = 'A'
classmethod all_measurements_types()Tuple[hvl_ccb.dev.sst_luminox.LuminoxMeasurementType, ][source]

A tuple of LuminoxMeasurementType enum instances which are actual measurements, i.e. not date of manufacture or software revision.

barometric_pressure = 'P'
property command
date_of_manufacture = '# 0'
parse_read_measurement_value(read_txt: str)Union[Dict[Union[str, hvl_ccb.dev.sst_luminox.LuminoxMeasurementType], Union[float, int, str]], float, int, str][source]
partial_pressure_o2 = 'O'
percent_o2 = '%'
sensor_status = 'e'
serial_number = '# 1'
software_revision = '# 2'
temperature_sensor = 'T'
hvl_ccb.dev.sst_luminox.LuminoxMeasurementTypeDict

A typing hint for a dictionary holding LuminoxMeasurementType values. Keys are allowed as strings because LuminoxMeasurementType is of a StrEnumBase type.

alias of Dict[Union[str, LuminoxMeasurementType], Union[float, int, str]]

exception hvl_ccb.dev.sst_luminox.LuminoxMeasurementTypeError[source]

Bases: Exception

Wrong measurement type for requested data

hvl_ccb.dev.sst_luminox.LuminoxMeasurementTypeValue

A typing hint for all possible LuminoxMeasurementType values as read in either streaming mode or in a polling mode with LuminoxMeasurementType.all_measurements.

Beware: has to be manually kept in sync with LuminoxMeasurementType instances cast_type attribute values.

alias of Union[float, int, str]

class hvl_ccb.dev.sst_luminox.LuminoxOutputMode(value)[source]

Bases: enum.Enum

output mode.

polling = 1
streaming = 0
exception hvl_ccb.dev.sst_luminox.LuminoxOutputModeError[source]

Bases: Exception

Wrong output mode for requested data

class hvl_ccb.dev.sst_luminox.LuminoxSerialCommunication(configuration)[source]

Bases: hvl_ccb.comm.serial.SerialCommunication

Specific communication protocol implementation for the SST Luminox oxygen sensor. Already predefines device-specific protocol parameters in config.

static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

class hvl_ccb.dev.sst_luminox.LuminoxSerialCommunicationConfig(terminator: bytes = b'\r\n', encoding: str = 'utf-8', encoding_error_handling: str = 'replace', wait_sec_read_text_nonempty: Union[int, float] = 0.5, default_n_attempts_read_text_nonempty: int = 10, port: Union[str, NoneType] = None, baudrate: int = 9600, parity: Union[str, hvl_ccb.comm.serial.SerialCommunicationParity] = <SerialCommunicationParity.NONE: 'N'>, stopbits: Union[int, hvl_ccb.comm.serial.SerialCommunicationStopbits] = <SerialCommunicationStopbits.ONE: 1>, bytesize: Union[int, hvl_ccb.comm.serial.SerialCommunicationBytesize] = <SerialCommunicationBytesize.EIGHTBITS: 8>, timeout: Union[int, float] = 3)[source]

Bases: hvl_ccb.comm.serial.SerialCommunicationConfig

baudrate: int = 9600

Baudrate for SST Luminox is 9600 baud

bytesize: Union[int, hvl_ccb.comm.serial.SerialCommunicationBytesize] = 8

One byte is eight bits long

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

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.

parity: Union[str, hvl_ccb.comm.serial.SerialCommunicationParity] = 'N'

SST Luminox does not use parity

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.

stopbits: Union[int, hvl_ccb.comm.serial.SerialCommunicationStopbits] = 1

SST Luminox does use one stop bit

terminator: bytes = b'\r\n'

The terminator is CR LF

timeout: Union[int, float] = 3

use 3 seconds timeout as default

hvl_ccb.dev.technix module

Device classes for “RS 232” and “Ethernet” Interfaces which are used to control power supplies from Technix. Manufacturer homepage: https://www.technix-hv.com

The Regulated power Supplies Series and Capacitor Chargers Series from Technix are series of low and high voltage direct current power supplies as well as capacitor chargers. The class Technix is tested with a CCR10KV-7,5KJ via an ethernet connection as well as a CCR15-P-2500-OP via a serial connection. Check the code carefully before using it with other devices or device series

This Python package may support the following interfaces from Technix:
class hvl_ccb.dev.technix.Technix(com, dev_config)[source]

Bases: hvl_ccb.dev.base.SingleCommDevice

static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

property current
default_com_cls()Union[Type[hvl_ccb.dev.technix.TechnixSerialCommunication], Type[hvl_ccb.dev.technix.TechnixTelnetCommunication]][source]

Get the class for the default communication protocol used with this device.

Returns

the type of the standard communication protocol for this device

get_status_byte()hvl_ccb.dev.technix.TechnixStatusByte[source]
property hv
property inhibit
property max_current
property max_voltage
property remote
start()[source]

Open the associated communication protocol.

stop()[source]

Close the associated communication protocol.

property voltage
property voltage_regulation
class hvl_ccb.dev.technix.TechnixCommunication(config)[source]

Bases: hvl_ccb.comm.base.SyncCommunicationProtocol, abc.ABC

Generic communication class for Technix, which can be implemented via TechnixSerialCommunication or TechnixTelnetCommunication

query(command: str)str[source]

Send a command to the interface and handle the status message. Eventually raises an exception.

Parameters

command – Command to send

Raises

TechnixError – if the connection is broken

Returns

Answer from the interface

class hvl_ccb.dev.technix.TechnixCommunicationConfig(terminator: bytes = b'\r', encoding: str = 'utf-8', encoding_error_handling: str = 'replace', wait_sec_read_text_nonempty: Union[int, float] = 0.5, default_n_attempts_read_text_nonempty: int = 10)[source]

Bases: hvl_ccb.comm.base.SyncCommunicationProtocolConfig

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

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.

terminator: bytes = b'\r'

The terminator is CR

class hvl_ccb.dev.technix.TechnixConfig(communication_channel: Union[Type[hvl_ccb.dev.technix.TechnixSerialCommunication], Type[hvl_ccb.dev.technix.TechnixTelnetCommunication]], max_voltage: Union[int, float], max_current: Union[int, float], polling_interval_sec: Union[int, float] = 4, post_stop_pause_sec: Union[int, float] = 1, register_pulse_time: Union[int, float] = 0.1)[source]

Bases: object

clean_values()

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

communication_channel: Union[Type[hvl_ccb.dev.technix.TechnixSerialCommunication], Type[hvl_ccb.dev.technix.TechnixTelnetCommunication]]

communication channel between computer and Technix

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.

max_current: Union[int, float]

Maximal Output current

max_voltage: Union[int, float]

Maximal Output voltage

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.

polling_interval_sec: Union[int, float] = 4

Polling interval in s to maintain to watchdog of the device

post_stop_pause_sec: Union[int, float] = 1

Time to wait after stopping the device

register_pulse_time: Union[int, float] = 0.1

Time for pulsing a register

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.

exception hvl_ccb.dev.technix.TechnixError[source]

Bases: Exception

Technix related errors.

class hvl_ccb.dev.technix.TechnixSerialCommunication(configuration)[source]

Bases: hvl_ccb.dev.technix.TechnixCommunication, hvl_ccb.comm.serial.SerialCommunication

static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

class hvl_ccb.dev.technix.TechnixSerialCommunicationConfig(terminator: bytes = b'\r', encoding: str = 'utf-8', encoding_error_handling: str = 'replace', wait_sec_read_text_nonempty: Union[int, float] = 0.5, default_n_attempts_read_text_nonempty: int = 10, port: Union[str, NoneType] = None, baudrate: int = 9600, parity: Union[str, hvl_ccb.comm.serial.SerialCommunicationParity] = <SerialCommunicationParity.NONE: 'N'>, stopbits: Union[int, float, hvl_ccb.comm.serial.SerialCommunicationStopbits] = <SerialCommunicationStopbits.ONE: 1>, bytesize: Union[int, hvl_ccb.comm.serial.SerialCommunicationBytesize] = <SerialCommunicationBytesize.EIGHTBITS: 8>, timeout: Union[int, float] = 2)[source]

Bases: hvl_ccb.dev.technix.TechnixCommunicationConfig, hvl_ccb.comm.serial.SerialCommunicationConfig

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

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 hvl_ccb.dev.technix.TechnixStatusByte(value: int)[source]

Bases: object

msb_first(idx: int)Optional[bool][source]

Give the Bit at position idx with MSB first

Parameters

idx – Position of Bit as 1…8

Returns

class hvl_ccb.dev.technix.TechnixTelnetCommunication(configuration)[source]

Bases: hvl_ccb.comm.telnet.TelnetCommunication, hvl_ccb.dev.technix.TechnixCommunication

static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

class hvl_ccb.dev.technix.TechnixTelnetCommunicationConfig(terminator: bytes = b'\r\n', encoding: str = 'utf-8', encoding_error_handling: str = 'replace', wait_sec_read_text_nonempty: Union[int, float] = 0.5, default_n_attempts_read_text_nonempty: int = 10, host: Union[str, NoneType] = None, port: int = 4660, timeout: Union[int, float] = 0.2)[source]

Bases: hvl_ccb.comm.telnet.TelnetCommunicationConfig, hvl_ccb.dev.technix.TechnixCommunicationConfig

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

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.

port: int = 4660

Port at which Technix is listening

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.dev.tiepie module

hvl_ccb.dev.utils module

class hvl_ccb.dev.utils.Poller(spoll_handler: Callable, polling_delay_sec: Union[int, float] = 0, polling_interval_sec: Union[int, float] = 1, polling_timeout_sec: Optional[Union[int, float]] = None)[source]

Bases: object

Poller class wrapping concurrent.futures.ThreadPoolExecutor which enables passing of results and errors out of the polling thread.

is_polling()bool[source]

Check if device status is being polled.

Returns

True when polling thread is set and alive

start_polling()bool[source]

Start polling.

Returns

True if was not polling before, False otherwise

stop_polling()bool[source]

Stop polling.

Wait for until polling function returns a result as well as any exception that might have been raised within a thread.

Returns

True if was polling before, False otherwise, and last result of the polling function call.

Raises

polling function exceptions

wait_for_polling_result()[source]

Wait for until polling function returns a result as well as any exception that might have been raised within a thread.

Returns

polling function result

Raises

polling function errors

hvl_ccb.dev.visa module

class hvl_ccb.dev.visa.VisaDevice(com: Union[hvl_ccb.comm.visa.VisaCommunication, hvl_ccb.comm.visa.VisaCommunicationConfig, dict], dev_config: Optional[Union[hvl_ccb.dev.visa.VisaDeviceConfig, dict]] = None)[source]

Bases: hvl_ccb.dev.base.SingleCommDevice

Device communicating over the VISA protocol using VisaCommunication.

static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

static default_com_cls()Type[hvl_ccb.comm.visa.VisaCommunication][source]

Return the default communication protocol for this device type, which is VisaCommunication.

Returns

the VisaCommunication class

get_error_queue()str[source]

Read out error queue and logs the error.

Returns

Error string

get_identification()str[source]

Queries “*IDN?” and returns the identification string of the connected device.

Returns

the identification string of the connected device

reset()None[source]

Send “*RST” and “*CLS” to the device. Typically sets a defined state.

spoll_handler()[source]

Reads the status byte and decodes it. The status byte STB is defined in IEEE 488.2. It provides a rough overview of the instrument status.

Returns

start()None[source]

Start the VisaDevice. Sets up the status poller and starts it.

Returns

stop()None[source]

Stop the VisaDevice. Stops the polling thread and closes the communication protocol.

Returns

wait_operation_complete(timeout: Optional[float] = None)bool[source]

Waits for a operation complete event. Returns after timeout [s] has expired or the operation complete event has been caught.

Parameters

timeout – Time in seconds to wait for the event; None for no timeout.

Returns

True, if OPC event is caught, False if timeout expired

class hvl_ccb.dev.visa.VisaDeviceConfig(spoll_interval: Union[int, float] = 0.5, spoll_start_delay: Union[int, float] = 2)[source]

Bases: hvl_ccb.dev.visa._VisaDeviceConfigDefaultsBase, hvl_ccb.dev.visa._VisaDeviceConfigBase

Configdataclass for a VISA device.

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

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.

Module contents

Devices subpackage.