keithley_daq6510.scpi.operation package

Submodules

keithley_daq6510.scpi.operation.parameter module

class keithley_daq6510.scpi.operation.parameter.Parameter(name, formatter=<class 'str'>, validator=None)[source]

Bases: typing.Generic

__init__(name, formatter=<class 'str'>, validator=None)[source]

SCPI operation parameter abstraction.

Examples

Most simple parameter with just a name:

Parameter('bit_number')

Parameter with range validation:

Parameter('bit_number', validator=range(0, 15))

Custom validator function rather than iterable of allowed values:

Parameter('bit_number', validator=lambda n: 0 <= n <= 14)

Parameter with custom formatter:

Parameter('bit_number', formatter=lambda n: f'#b{n:b}')
Parameters
  • name (str) – Parameter name, preferably as in the official device documentation.

  • formatter (Callable[[~T], str]) – Custom parameter-to-string converter to be called within SCPI operation string construction.

  • validator (Union[Iterable[~T], Callable[[~T], bool], Type[Any], None]) – Custom parameter whitelist or validation function. Accepts an iterable of allowed values (whitelist) or a function. If given a function, it is expected to return True if and only if the passed value is allowed.

Raises

TypeError – If validator is none of None, an iterable, or a callable.

Module contents

Module containing abstractions for SCPI operations (i.e., commands and queries).

class keithley_daq6510.scpi.operation.Operation(command, formatter=<function comma_separated>, parameters=None)[source]

Bases: object

Abstraction for a SCPI operation (i.e., commands and queries).

Instances of this class are intended to be used just like descriptors would.

Example

Base usage:

class Instrument:
    idn = Operation('*IDN?')
__get__(caller, cls=None)[source]

Get function wrapping SCPI operation parameter validation and device communication, and bind it to caller.

Parameters
Return type

Callable[…, Any]

Returns

Callable implementing the actual parameter validation and communication with the device.

__init__(command, formatter=<function comma_separated>, parameters=None)[source]

SCPI operation (command or query) builder.

Example

Intended to be used in class attribute initialization:

class Sample:
    idn = Operation('*IDN?')
Parameters
  • command (str) – Full SCPI command string (without parameters). SCPI queries are expected to end with a ?.

  • formatter (Callable[[str, Any], str]) – Customize building and formatting the SCPI operation string before sending it to the device. Defaults to format <scpi-command> <arg1>[, <arg2>[, ...<argN>]].

  • parameters (Optional[Iterable[Parameter]]) – Define iterable of allowed parameters, including optional validation and formatting.