hvl_ccb.dev.tiepie

Inheritance diagram of hvl_ccb.dev.tiepie

This module is a wrapper around libtiepie Oscilloscope devices; see https://www.tiepie.com/en/libtiepie-sdk .

The device classes adds simplifications for starting of the device (using serial number) and managing mutable configuration of both the device and oscilloscope’s channels. This includes extra validation and typing hints support.

To install libtiepie on Windows: The installation of the Python bindings “python-libtiepie” is done automatically with the dependencies of the hvl_ccb. The additional DLL for Windows is included in that package.

On a Linux-system additional libraries have to be installed; see https://www.tiepie.com/en/libtiepie-sdk/linux .

On a Windows system, if you encounter an OSError like this:

...
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

most likely the python-libtiepie package was installed in your site-packages/ directory as a python-libtiepie-*.egg file via python setup.py install or python setup.py develop command. In this case uninstall the library and re-install it using pip:

$ pip uninstall python-libtiepie
$ pip install python-libtiepie

This should create libtiepie/ folder. Alternatively, manually move the folder libtiepie/ from inside of the .egg archive file to the containing it site-packages/ directory (PyCharm’s Project tool window supports reading and extracting from .egg archives).

class GeneratorParameterLimits(dev_gen: libtiepie.generator.Generator)[source]

Bases: object

Default limits for generator parameters.

class I2CHostParameterLimits(dev_i2c: libtiepie.i2chost.I2CHost)[source]

Bases: object

Default limits for I2C host parameters.

class OscilloscopeChannelParameterLimits(osc_channel: libtiepie.oscilloscopechannel.OscilloscopeChannel)[source]

Bases: object

Default limits for oscilloscope channel parameters.

class OscilloscopeParameterLimits(dev_osc: libtiepie.oscilloscope.Oscilloscope)[source]

Bases: object

Default limits for oscilloscope parameters.

class PublicPropertiesReprMixin[source]

Bases: object

General purpose utility mixin that overwrites object representation to a one analogous to dataclass instances, but using public properties and their values instead of fields.

class TiePieDeviceConfig(serial_number: int, require_block_measurement_support: bool = True, n_max_try_get_device: int = 10, wait_sec_retry_get_device: Union[int, float] = 1.0, is_data_ready_polling_interval_sec: Union[int, float] = 0.01)[source]

Bases: object

Configuration dataclass for TiePie

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
is_data_ready_polling_interval_sec: Union[int, float] = 0.01
classmethod keys()Sequence[str]

Returns a list of all configdataclass fields key-names.

Returns

a list of strings containing all keys.

n_max_try_get_device: int = 10
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.

require_block_measurement_support: bool = True
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.

serial_number: int
wait_sec_retry_get_device: Union[int, float] = 1.0
class TiePieDeviceType(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: hvl_ccb.utils.enum.NameEnum

TiePie device type.

GENERATOR = 2
I2C = 4
OSCILLOSCOPE = 1
exception TiePieError[source]

Bases: Exception

Error of the class TiePie

class TiePieGeneratorConfig(dev_gen: libtiepie.generator.Generator)[source]

Bases: hvl_ccb.dev.tiepie.PublicPropertiesReprMixin

Generator’s configuration with cleaning of values in properties setters.

property amplitude
clean_amplitude(amplitude: float)float[source]
static clean_enabled(enabled: bool)bool[source]
clean_frequency(frequency: float)float[source]
clean_offset(offset: float)float[source]
static clean_signal_type(signal_type: Union[int, hvl_ccb.dev.tiepie.TiePieGeneratorSignalType])hvl_ccb.dev.tiepie.TiePieGeneratorSignalType[source]
property enabled
property frequency
property offset
property signal_type
class TiePieGeneratorMixin(com, dev_config)[source]

Bases: object

TiePie Generator sub-device.

A wrapper for the libtiepie.generator.Generator class. To be mixed in with TiePieOscilloscope base class.

config_gen: Optional[hvl_ccb.dev.tiepie.TiePieGeneratorConfig]

Generator’s dynamical configuration.

generator_start()[source]

Start signal generation.

generator_stop()[source]

Stop signal generation.

start()None[source]

Start the Generator.

stop()None[source]

Stop the generator.

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

Bases: hvl_ccb.utils.enum.NameEnum

An enumeration.

ARBITRARY = 32
DC = 8
NOISE = 16
PULSE = 64
SINE = 1
SQUARE = 4
TRIANGLE = 2
UNKNOWN = 0
class TiePieHS5(com, dev_config)[source]

Bases: hvl_ccb.dev.tiepie.TiePieI2CHostMixin, hvl_ccb.dev.tiepie.TiePieGeneratorMixin, hvl_ccb.dev.tiepie.TiePieOscilloscope

TiePie HS5 device.

config_gen: Optional[hvl_ccb.dev.tiepie.TiePieGeneratorConfig]

Generator’s dynamical configuration.

class TiePieHS6(com, dev_config)[source]

Bases: hvl_ccb.dev.tiepie.TiePieOscilloscope

TiePie HS6 DIFF device.

class TiePieI2CHostConfig(dev_i2c: libtiepie.i2chost.I2CHost)[source]

Bases: hvl_ccb.dev.tiepie.PublicPropertiesReprMixin

I2C Host’s configuration with cleaning of values in properties setters.

class TiePieI2CHostMixin(com, dev_config)[source]

Bases: object

TiePie I2CHost sub-device.

A wrapper for the libtiepie.i2chost.I2CHost class. To be mixed in with TiePieOscilloscope base class.

config_i2c: Optional[hvl_ccb.dev.tiepie.TiePieI2CHostConfig]

I2C host’s dynamical configuration.

start()None[source]

Start the I2C Host.

stop()None[source]

Stop the I2C host.

class TiePieOscilloscope(com, dev_config)[source]

Bases: hvl_ccb.dev.base.SingleCommDevice

TiePie oscilloscope.

A wrapper for TiePie oscilloscopes, based on the class libtiepie.oscilloscope.Oscilloscope with simplifications for starting of the device (using serial number) and managing mutable configuration of both the device and its channels, including extra validation and typing hints support for configurations.

Note that, in contrast to libtiepie library, since all physical TiePie devices include an oscilloscope, this is the base class for all physical TiePie devices. The additional TiePie sub-devices: “Generator” and “I2CHost”, are mixed-in to this base class in subclasses.

The channels use 1..N numbering (not 0..N-1), as in, e.g., the Multi Channel software.

property channels_enabled

Yield numbers of enabled channels.

Returns

Numbers of enabled channels

collect_measurement_data(timeout: Optional[Union[int, float]] = 0)Optional[numpy.ndarray][source]

Try to collect the data from TiePie; return None if data is not ready.

Parameters

timeout – The timeout to wait until data is available. This option makes this function blocking the code. timeout = None blocks the code infinitely till data will be available. Per default, the timeout is set to 0: The function will not block.

Returns

Measurement data of only enabled channels and time vector in a 2D-numpy.ndarray with float sample data; or None if there is no data available.

static config_cls()Type[hvl_ccb.dev.tiepie.TiePieDeviceConfig][source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

config_osc: Optional[hvl_ccb.dev.tiepie.TiePieOscilloscopeConfig]

Oscilloscope’s dynamical configuration.

config_osc_channel_dict: Dict[int, hvl_ccb.dev.tiepie.TiePieOscilloscopeChannelConfig]

Channel configuration. A dict mapping actual channel number, numbered 1..N, to channel configuration. The channel info is dynamically read from the device only on the first start(); beforehand the dict is empty.

static default_com_cls()Type[hvl_ccb.comm.base.NullCommunicationProtocol][source]

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

Returns

the type of the standard communication protocol for this device

force_trigger()None[source]

Forces the TiePie to trigger with a software sided trigger event.

Return None

Raises

TiePieError – when device is not started or status of underlying device gives an error

is_measurement_data_ready()bool[source]

Reports if TiePie has data which is ready to collect

Returns

if the data is ready to collect.

Raises

TiePieError – when device is not started or status of underlying device gives an error

is_triggered()bool[source]

Reports if TiePie has triggered. Maybe data is not yet available. One can check with the function is_measurement_data_ready().

Returns

if a trigger event occurred

static list_devices()libtiepie.devicelist.DeviceList[source]

List available TiePie devices.

Returns

libtiepie up to date list of devices

property n_channels

Number of channels in the oscilloscope.

Returns

Number of channels.

start()None[source]

Start the oscilloscope.

start_measurement()None[source]

Start a measurement using set configuration.

Raises

TiePieError – when device is not started or status of underlying device gives an error

stop()None[source]

Stop the oscilloscope.

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

Bases: hvl_ccb.utils.enum.NameEnum

An enumeration.

ALL = 4
DISABLED = 1
NATIVEONLY = 2
UNKNOWN = 0
class TiePieOscilloscopeChannelConfig(ch_number: int, channel: libtiepie.oscilloscopechannel.OscilloscopeChannel)[source]

Bases: hvl_ccb.dev.tiepie.PublicPropertiesReprMixin

Oscilloscope’s channel configuration, with cleaning of values in properties setters as well as setting and reading them on and from the device’s channel.

static clean_coupling(coupling: Union[str, hvl_ccb.dev.tiepie.TiePieOscilloscopeChannelCoupling])hvl_ccb.dev.tiepie.TiePieOscilloscopeChannelCoupling[source]
static clean_enabled(enabled: bool)bool[source]
clean_input_range(input_range: Union[float, hvl_ccb.dev.tiepie.TiePieOscilloscopeRange])hvl_ccb.dev.tiepie.TiePieOscilloscopeRange[source]
clean_probe_offset(probe_offset: float)float[source]
static clean_safe_ground_enabled(safe_ground_enabled: bool)bool[source]
static clean_trigger_enabled(trigger_enabled)[source]
clean_trigger_hysteresis(trigger_hysteresis: float)float[source]
static clean_trigger_kind(trigger_kind: Union[str, hvl_ccb.dev.tiepie.TiePieOscilloscopeTriggerKind])hvl_ccb.dev.tiepie.TiePieOscilloscopeTriggerKind[source]
clean_trigger_level(trigger_level: Union[int, float])float[source]
static clean_trigger_level_mode(level_mode: Union[str, hvl_ccb.dev.tiepie.TiePieOscilloscopeTriggerLevelMode])hvl_ccb.dev.tiepie.TiePieOscilloscopeTriggerLevelMode[source]
property coupling
property enabled
property has_safe_ground

Check whether bound oscilloscope device has “safe ground” option

Returns

bool: 1=safe ground available

property input_range
property probe_offset
property safe_ground_enabled
property trigger_enabled
property trigger_hysteresis
property trigger_kind
property trigger_level
property trigger_level_mode
class TiePieOscilloscopeChannelCoupling(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: hvl_ccb.utils.enum.NameEnum

An enumeration.

ACA = 8
ACV = 2
DCA = 4
DCV = 1
class TiePieOscilloscopeConfig(dev_osc: libtiepie.oscilloscope.Oscilloscope)[source]

Bases: hvl_ccb.dev.tiepie.PublicPropertiesReprMixin

Oscilloscope’s configuration with cleaning of values in properties setters.

property auto_resolution_mode
static clean_auto_resolution_mode(auto_resolution_mode: Union[int, hvl_ccb.dev.tiepie.TiePieOscilloscopeAutoResolutionModes])hvl_ccb.dev.tiepie.TiePieOscilloscopeAutoResolutionModes[source]
clean_pre_sample_ratio(pre_sample_ratio: float)float[source]
clean_record_length(record_length: Union[int, float])int[source]
static clean_resolution(resolution: Union[int, hvl_ccb.dev.tiepie.TiePieOscilloscopeResolution])hvl_ccb.dev.tiepie.TiePieOscilloscopeResolution[source]
clean_sample_frequency(sample_frequency: float)float[source]
clean_trigger_timeout(trigger_timeout: Optional[Union[int, float]])float[source]
property pre_sample_ratio
property record_length
property resolution
property sample_frequency
property trigger_timeout
class TiePieOscilloscopeRange(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: hvl_ccb.utils.enum.NameEnum

An enumeration.

EIGHTY_VOLT = 80
EIGHT_HUNDRED_MILLI_VOLT = 0.8
EIGHT_VOLT = 8
FORTY_VOLT = 40
FOUR_HUNDRED_MILLI_VOLT = 0.4
FOUR_VOLT = 4
TWENTY_VOLT = 20
TWO_HUNDRED_MILLI_VOLT = 0.2
TWO_VOLT = 2
static suitable_range(value)[source]
class TiePieOscilloscopeResolution(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: aenum.IntEnum

An enumeration.

EIGHT_BIT = 8
FOURTEEN_BIT = 14
SIXTEEN_BIT = 16
TWELVE_BIT = 12
class TiePieOscilloscopeTriggerKind(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: hvl_ccb.utils.enum.NameEnum

An enumeration.

ANY = 16
FALLING = 2
RISING = 1
RISING_OR_FALLING = 16
class TiePieOscilloscopeTriggerLevelMode(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: hvl_ccb.utils.enum.NameEnum

An enumeration.

ABSOLUTE = 2
RELATIVE = 1
UNKNOWN = 0
class TiePieWS5(com, dev_config)[source]

Bases: hvl_ccb.dev.tiepie.TiePieI2CHostMixin, hvl_ccb.dev.tiepie.TiePieGeneratorMixin, hvl_ccb.dev.tiepie.TiePieOscilloscope

TiePie WS5 device.

config_i2c: Optional[hvl_ccb.dev.tiepie.TiePieI2CHostConfig]

I2C host’s dynamical configuration.

get_device_by_serial_number(serial_number: int, device_type: Union[str, Tuple[int, _LtpDeviceReturnType]], n_max_try_get_device: int = 10, wait_sec_retry_get_device: float = 1.0)_LtpDeviceReturnType[source]

Open and return handle of TiePie device with a given serial number

Parameters
  • serial_number – int serial number of the device

  • device_type – a TiePieDeviceType instance containing device identifier (int number) and its corresponding class, both from libtiepie, or a string name of such instance

  • n_max_try_get_device – maximal number of device list updates (int number)

  • wait_sec_retry_get_device – waiting time in seconds between retries (int number)

Returns

Instance of a libtiepie device class according to the specified device_type

Raises
  • TiePieError – when there is no device with given serial number

  • ValueError – when device_type is not an instance of TiePieDeviceType

log_set(prop_name: str, prop_value: object, value_suffix: str = '')None[source]
wrap_libtiepie_exception(func: Callable)Callable[source]

Decorator wrapper for libtiepie methods that use libtiepie.library.check_last_status_raise_on_error() calls.

Parameters

func – Function or method to be wrapped

Raises

TiePieError – instead of LibTiePieException or one of its subtypes.

Returns

whatever func returns