inspy.instrument

Top level module for instruments.

class inspy.instrument.InstrumentBase(transport)[source]

Bases: object

Instrument Base class.

This class should be subclassed by all instrument classes. It provides basic functionality for connecting and disconnecting from the instrument.

auto_log_level: int = 20

The log level used for automatic logging of method calls.

To disable logging set to logging.NOTSET.

abstract await_completion()[source]

Configure the instrument to wait for all pending operations.

Return type:

None

Example implementation:
>>> self.transport.query("*OPC?")
Or if supported:
>>> self.transport.command("*WAI")
connect()[source]

Connect to instrument using the transport layer.

Return type:

None

disconnect()[source]
Return type:

None

get_id()[source]

Identification Query.

Return type:

str

Returns:

Instrument Identification String.

abstract reset()[source]

Reset instrument to factory default state, including clearing status.

Return type:

None

Example implementation:
>>> self.transport.clear()
>>> self.transport.command("*CLS")
>>> self.transport.command("*RST")
exception inspy.instrument.InstrumentError(errors)[source]

Bases: Exception

Error class raised when errors are reported by the instrument.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class inspy.instrument.SerialInstrumentMixin(visa_address=None, transport=None)[source]

Bases: InstrumentBase

Mixin adding serial-address construction to an instrument.

Mix into an InstrumentBase subclass. Builds a SerialTransport from a VISA resource name, or accepts a ready-made transport. Subclasses can override this to configure serial settings (e.g. baudrate, parity).

auto_log_level: int = 20

The log level used for automatic logging of method calls.

To disable logging set to logging.NOTSET.

abstract await_completion()

Configure the instrument to wait for all pending operations.

Return type:

None

Example implementation:
>>> self.transport.query("*OPC?")
Or if supported:
>>> self.transport.command("*WAI")
connect()

Connect to instrument using the transport layer.

Return type:

None

disconnect()
Return type:

None

get_id()

Identification Query.

Return type:

str

Returns:

Instrument Identification String.

is_connected: bool
logger: Logger
abstract reset()

Reset instrument to factory default state, including clearing status.

Return type:

None

Example implementation:
>>> self.transport.clear()
>>> self.transport.command("*CLS")
>>> self.transport.command("*RST")
transport: SerialTransport
class inspy.instrument.VisaInstrumentMixin(visa_address=None, transport=None)[source]

Bases: InstrumentBase

Mixin adding VISA-address construction to an instrument.

Mix into an InstrumentBase subclass. Builds a PyVisaTransport from a VISA address, or accepts a ready-made transport.

auto_log_level: int = 20

The log level used for automatic logging of method calls.

To disable logging set to logging.NOTSET.

abstract await_completion()

Configure the instrument to wait for all pending operations.

Return type:

None

Example implementation:
>>> self.transport.query("*OPC?")
Or if supported:
>>> self.transport.command("*WAI")
connect()

Connect to instrument using the transport layer.

Return type:

None

disconnect()
Return type:

None

get_id()

Identification Query.

Return type:

str

Returns:

Instrument Identification String.

is_connected: bool
logger: Logger
abstract reset()

Reset instrument to factory default state, including clearing status.

Return type:

None

Example implementation:
>>> self.transport.clear()
>>> self.transport.command("*CLS")
>>> self.transport.command("*RST")
transport: PyVisaTransport