Instrument management (async)
The InstrumentManagerAsync()
class and supporting functions use
asyncio to
provide a high-performance concurrent interface
for instrument control.
These api for these functions and classes remain largely the same as the sequential versions.
The main difference is that these are async enabled. This means you have to use the await/async expressions to manage the event loop.
For example, to connect:
import pypalmsens
async with await pypalmsens.connect_async() as manager:
method = pypalmsens.ChronoAmperometry()
measurement = await manager.measure(method)
or using InstrumentManagerAsync()
directly as a context manager:
instruments = await discover_async()
async with pypalmsens.InstrumentManagerAsync(instruments[0]) as manager:
measurement = await manager.measure(method)
or managing the instrument connection yourself:
instruments = await discover_async()
manager = pypalmsens.InstrumentManagerAsync(instruments[0])
await manager.connect()
...
await manager.disconnect()
For more information, see xref:api/measuring.adoc
pypalmsens
Classes:
-
InstrumentManagerAsync – Asynchronous instrument manager for PalmSens instruments.
Functions:
-
connect_async – Connect to instrument and return InstrumentManagerAsync.
-
discover_async – Discover instruments.
InstrumentManagerAsync
InstrumentManagerAsync(instrument, *, callback=None)
Asynchronous instrument manager for PalmSens instruments.
Parameters:
-
instrument – Instrument to connect to, use
discover()
to find connected instruments. -
callback (link:#typing.Optional[link:#pypalmsens._instruments._common.Callback]) – If specified, call this function on every new set of data points. New data points are batched, and contain all points since the last time it was called. Each point is a dictionary containing
frequency
,z_re
,z_im
for impedimetric techniques andindex
,x
,x_unit
,x_type
,y
,y_unit
andy_type
for non-impedimetric techniques.
Functions:
-
is_connected – Return True if an instrument connection exists.
-
connect – Connect to instrument.
-
set_cell – Turn the cell on or off.
-
set_potential – Set the potential of the cell.
-
set_current_range – Set the current range for the cell.
-
read_current – Read the current in µA.
-
read_potential – Read the potential in V.
-
get_instrument_serial – Return instrument serial number.
-
validate_method – Validate method.
-
measure – Start measurement using given method parameters.
-
initiate_hardware_sync_follower_channel – Initiate hardware sync follower channel.
-
wait_digital_trigger – Wait for digital trigger.
-
abort – Abort measurement.
-
initialize_multiplexer – Initialize the multiplexer.
-
set_mux8r2_settings – Set the settings for the Mux8R2 multiplexer.
-
set_multiplexer_channel – Sets the multiplexer channel.
-
disconnect – Disconnect from the instrument.
Attributes:
-
callback – This callback is called on every data point.
-
instrument – Instrument to connect to.
set_cell
set_cell(cell_on)
Turn the cell on or off.
Parameters:
-
cell_on (bool) – If true, turn on the cell
set_potential
set_potential(potential)
Set the potential of the cell.
Parameters:
-
potential (float) – Potential in V
set_current_range
set_current_range(current_range)
Set the current range for the cell.
Parameters:
-
current_range (CURRENT_RANGE) – Set the current range, use
pypalmsens.settings.CURRENT_RANGE
.
get_instrument_serial
get_instrument_serial()
Return instrument serial number.
Returns:
-
str – Instrument serial.
measure
measure(method, hardware_sync_initiated_event=None)
Start measurement using given method parameters.
Parameters:
-
method (MethodSettings) – Method parameters for measurement
-
hardware_sync_initiated_event – …
initiate_hardware_sync_follower_channel
initiate_hardware_sync_follower_channel(method)
Initiate hardware sync follower channel.
Parameters:
-
method (MethodParameters) – Method parameters
wait_digital_trigger
wait_digital_trigger(wait_for_high)
Wait for digital trigger.
Parameters:
-
wait_for_high – …
initialize_multiplexer
initialize_multiplexer(mux_model)
Initialize the multiplexer.
Parameters:
-
mux_model (int) – The model of the multiplexer. 0 = 8 channel, 1 = 16 channel, 2 = 32 channel.
Returns:
-
int – Number of available multiplexes channels
set_mux8r2_settings
set_mux8r2_settings(connect_sense_to_working_electrode=False, combine_reference_and_counter_electrodes=False, use_channel_1_reference_and_counter_electrodes=False, set_unselected_channel_working_electrode=0)
Set the settings for the Mux8R2 multiplexer.
Parameters:
-
connect_sense_to_working_electrode (bool) – Connect the sense electrode to the working electrode. Default is False.
-
combine_reference_and_counter_electrodes (bool) – Combine the reference and counter electrodes. Default is False.
-
use_channel_1_reference_and_counter_electrodes (bool) – Use channel 1 reference and counter electrodes for all working electrodes. Default is False.
-
set_unselected_channel_working_electrode (int) – Set the unselected channel working electrode to disconnected/floating (0), ground (1), or standby potential (2). Default is 0.
set_multiplexer_channel
set_multiplexer_channel(channel)
Sets the multiplexer channel.
Parameters:
-
channel (int) – Index of the channel to set.
connect_async
connect_async(instrument=None)
Connect to instrument and return InstrumentManagerAsync.
Parameters:
-
instrument (Instrument) – Connect to this instrument. If not specified, automatically discover and connect to the first instrument.
Returns:
-
manager (InstrumentManagerAsync) – Return instance of
InstrumentManagerAsync
connected to the given instrument. The connection will be terminated after the context ends.