Asynchronous instruments implementation

Asynchronous extension of fluidlab.interfaces.QueryInterface (pymanip.interfaces.aiointer)

This module defines AsyncQueryInterface as the default subclass for fluidlab.interfaces.QueryInterface. The default implementation simply runs the methods of QueryInterface into an executor, therefore in a separate thread. Because the parent class is probably not thread-safe, each call is protected by a lock to prevent concurrent calls to the instrument. However, the main thread is released and other tasks can be run on other instruments.

The methods that are defined in this way are __aenter__(), __aexit__(), _aread(), _awrite(), _aquery() and await_for_srq(). The higher lever co-routine methods aread(), awrite() and aquery() simply checks that the interface is opened, and then awaits the low-level method, in a similar fashion as in the QueryInterface class.

Therefore, concrete subclass such as pymanip.interfaces.aioserial.AsyncSerialInterface, or pymanip.interfaces.aiovisa.AsyncVISAInterface only have to override the low-level co-routine methods (if necessary).

class pymanip.interfaces.aiointer.AsyncQueryInterface[source]

This class represents an asynchronous Query interface. It is a subclass of the synchronous QueryInterface defined in FluidLab. The input parameters are those of QueryInterface.

Concrete subclasses may replace the lock attribute, and replace it by a global board lock if necessary.

async _aquery(command, time_delay=0.1, **kwargs)[source]

Low-level co-routine to write/read a query. This method does not check whether the interface is opened. There are two cases:

  • if the QueryInterface has a _query() method, then the interface lock is acquired and the _query() method is run in an executor;

  • otherwise, the awrite() and aread() co-routine methods are used.

async _aread(*args, **kwargs)[source]

Low-level co-routine to read data from the instrument. This method does not check whether the interface is opened. In this basic class, it simply acquires the interface lock and runs the _read() method in an executor.

async _awrite(*args, **kwargs)[source]

Low-level co-routine to send data to the instrument. This method does not check whether the interface is opened. In this basic class, it simply acquires the interface lock and runs the _write() method in an executor.

async aquery(command, time_delay=0.1, **kwargs)[source]

This co-routine method queries the instrument. The parameters are identical to those of the query() method.

async aread(*args, **kwargs)[source]

This co-routine method reads data from the instrument. The parameters are identical to the read() method.

async awrite(*args, **kwargs)[source]

This co-routine method writes data to the instrument. The parameters are identical to the write() method.

Asynchronous extension of fluidlab.interfaces.SerialInterface (pymanip.interfaces.aioserial)

This module defines AsyncSerialInterface as a subclass of fluidlab.interfaces.serial_inter.SerialInterface and pymanip.interface.aiointer.AsyncQueryInterface.

class pymanip.interfaces.aioserial.AsyncSerialInterface(port, baudrate=9600, bytesize=8, parity='N', stopbits=1, timeout=1, xonxoff=False, rtscts=False, dsrdtr=False, eol=None, multilines=False, autoremove_eol=False)[source]

This class is an asynchronous extension of fluidlab.interfaces.serial_inter.SerialInterface. It inherits all its methods from the parent classes.

Asynchronous extension of fluidlab.interfaces.VISAInterface (pymanip.interfaces.aiovisa)

This module defines AsyncVISAInterface as a subclass of fluidlab.interfaces.visa_inter.VISAInterface and pymanip.interface.aiointer.AsyncQueryInterface.

class pymanip.interfaces.aiovisa.AsyncVISAInterface(resource_name, backend=None)[source]

This class is an asynchronous extension of fluidlab.interfaces.visa_inter.VISAInterface. The parameters are the same as those of the fluidlab.interfaces.visa_inter.VISAInterface class.

async await_for_srq(timeout=None)[source]

This co-routine method acquires the interface lock and run wait_for_srq in an executor.

Asynchronous instruments module (pymanip.aioinstruments)

This module auto-imports all the asynchronous instrument classes.

Asynchronous Instrument drivers (pymanip.aioinstruments.aiodrivers)

This module defines a subclass of fluidlab.instruments.drivers.Driver where the QueryInterface attribute is replaced by the corresponding AsyncQueryInterface instance. The asynchronous context manager is bound to the interface asynchronous context manager.

pymanip.aioinstruments.aiodrivers.interface_from_string(name, default_physical_interface=None, **kwargs)[source]

This function is similar to fluidlab.interfaces.interface_from_string() except that it returns an instance of AsyncQueryInterface instead of QueryInterface.

class pymanip.aioinstruments.aiodrivers.AsyncDriver(interface=None)[source]

This class is an asynchronous extension of fluidlab.instruments.drivers.Driver.

Asynchronous Instrument features (pymanip.aioinstruments.aiofeatures)

Asynchronous extension of fluidlab instrument features. The main difference is that they define aget() and aset() co-routine methods. The original get() and set() are not overridden, and may still be used.

class pymanip.aioinstruments.aiofeatures.AsyncWriteCommand(name, doc='', command_str='')[source]
_build_driver_class(Driver)[source]

Add a “write function” to the driver class

class pymanip.aioinstruments.aiofeatures.AsyncQueryCommand(name, doc='', command_str='', parse_result=None)[source]
_build_driver_class(Driver)[source]

Add a “query function” to the driver class

class pymanip.aioinstruments.aiofeatures.AsyncValue(name, doc='', command_set=None, command_get=None, check_instrument_value=True, pause_instrument=0.0, channel_argument=False)[source]
class pymanip.aioinstruments.aiofeatures.AsyncNumberValue(name, doc='', command_set=None, command_get=None, limits=None, check_instrument_value=True, pause_instrument=0.0, channel_argument=False)[source]
class pymanip.aioinstruments.aiofeatures.AsyncFloatValue(name, doc='', command_set=None, command_get=None, limits=None, check_instrument_value=True, pause_instrument=0.0, channel_argument=False)[source]
class pymanip.aioinstruments.aiofeatures.AsyncBoolValue(name, doc='', command_set=None, command_get=None, check_instrument_value=True, pause_instrument=0.0, channel_argument=False, true_string='1', false_string='0')[source]
class pymanip.aioinstruments.aiofeatures.AsyncIntValue(name, doc='', command_set=None, command_get=None, limits=None, check_instrument_value=True, pause_instrument=0.0, channel_argument=False)[source]
class pymanip.aioinstruments.aiofeatures.AsyncRegisterValue(name, doc='', command_set=None, command_get=None, keys=None, default_value=0, check_instrument_value=True, pause_instrument=0.0, channel_argument=False)[source]

Asynchronous IEC60488 instrument driver (pymanip.aioinstruments.aioiec60488)

This module defines an asynchronous subclass of fluidlab.instruments.iec60488.IEC60488.

class pymanip.aioinstruments.aioiec60488.AsyncIEC60488(interface=None)[source]
aclear_status = <function AsyncWriteCommand._build_driver_class.<locals>.func>
aquery_esr = <function AsyncQueryCommand._build_driver_class.<locals>.func>
aquery_stb = <function AsyncQueryCommand._build_driver_class.<locals>.func>
aquery_identification = <function AsyncQueryCommand._build_driver_class.<locals>.func>
areset_device = <function AsyncWriteCommand._build_driver_class.<locals>.func>
aperform_internal_test = <function AsyncQueryCommand._build_driver_class.<locals>.func>
await_till_completion_of_operations = <function AsyncWriteCommand._build_driver_class.<locals>.func>
aget_operation_complete_flag = <function AsyncQueryCommand._build_driver_class.<locals>.func>
await_continue = <function AsyncQueryCommand._build_driver_class.<locals>.func>
async aclear_status()

Clears the data status structure

async aget_operation_complete_flag()

Get operation complete flag

async aperform_internal_test()

Perform internal self-test

async aquery_esr()

Query the event status register

async aquery_identification()

Identification query

async aquery_stb()

Query the status register

async areset_device()

Perform a device reset

async await_continue()

Wait to continue

async await_till_completion_of_operations()

Return “1” when all operation are completed

event_status_enable_register = <pymanip.aioinstruments.aiofeatures.AsyncRegisterValue object>
status_enable_register = <pymanip.aioinstruments.aiofeatures.AsyncRegisterValue object>