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 (non-async) version.
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 start a measurement:
>>> import pypalmsens as ps
>>> import asyncio
>>> method = ps.CyclicVoltammetry()
>>> async def main():
... await ps.measure_async(method)
>>> asyncio.run(main())
Or to manage the connection yourself:
>>> async def main():
... async with await ps.connect_async() as manager:
... method = ps.ChronoAmperometry()
... measurement = await manager.measure(method)
>>> asyncio.run(main())
Or using InstrumentManagerAsync() directly as a context manager:
>>> async def main():
... instrument, *_ = await ps.discover_async()
... async with ps.InstrumentManagerAsync(instrument) as manager:
... measurement = await manager.measure(method)
>>> asyncio.run(main())
Or managing the instrument connection yourself:
>>> async def main():
... instrument, *_ = await ps.discover_async()
... manager = ps.InstrumentManagerAsync(instrument)
... await manager.connect()
... # ...
... await manager.disconnect()
>>> asyncio.run(main())
For more information, see the measurement documentation.
Classes:
pypalmsens.connect_async
async
connect_async(instrument: None | Instrument = None) -> InstrumentManagerAsync
Async connect to instrument and return InstrumentManagerAsync.
Connects to any plugged-in PalmSens USB device. Error if multiple devices are plugged-in.
Parameters:
-
(instrumentInstrument, default:None) –Connect to a specific instrument. Use
pypalmsens.discover_async()to discover instruments.
Returns:
-
manager(InstrumentManagerAsync) –Return instance of
InstrumentManagerAsyncconnected to the given instrument.
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
pypalmsens.discover_async
async
discover_async(ftdi: bool = True, usbcdc: bool = True, winusb: bool = True, bluetooth: bool = False, serial: bool = True, ignore_errors: bool = False) -> list[Instrument]
Discover instruments.
For a list of device interfaces, see: https://dev.palmsens.com/python/latest/_attachments/installation/index.html#compatibility
Parameters:
-
(ftdibool, default:True) –If True, discover ftdi devices
-
(usbcdcbool, default:True) –If True, discover usbcdc devices (Windows only)
-
(winusbbool, default:True) –If True, discover winusb devices (Windows only)
-
(bluetoothbool, default:False) –If True, discover bluetooth devices (Windows only)
-
(serialbool, default:True) –If True, discover serial devices
-
(ignore_errorsFalse, default:False) –Ignores errors in device discovery
Returns:
-
discovered(list[Instrument]) –List of dataclasses with discovered instruments.
Source code in src/pypalmsens/_instruments/instrument.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | |
pypalmsens.measure_async
async
measure_async(method: MethodTypeCompatible, instrument: None | Instrument = None, callback: Callback | CallbackEIS | None = None) -> Measurement
Run measurement async.
Executes the given method on any plugged-in PalmSens USB device. Error if multiple devices are plugged-in.
Parameters:
-
(instrumentInstrument, default:None) –Connect to and meassure on a specific instrument. Use
pypalmsens.discover_async()to discover instruments. -
(callbackCallback | CallbackEIS | None, default:None) –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 an instance of
ps.data.CallbackDatafor non-impedimetric orps.data.CallbackDataEISfor impedimetric measurments.
Returns:
-
measurement(Measurement) –Finished measurement.
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
pypalmsens.InstrumentManagerAsync
InstrumentManagerAsync(instrument: Instrument)
Asynchronous instrument manager for PalmSens instruments.
Parameters:
-
(instrumentInstrument) –Instrument to connect to, use
discover()to find connected instruments.
Methods:
-
abort–Abort measurement.
-
connect–Connect to instrument.
-
disconnect–Disconnect from the instrument.
-
ensure_connection–Raises connection error if the instrument is not connected.
-
get_current_range–Get the current range for the cell.
-
get_estimated_duration–Get the estimated duration for this method.
-
get_instrument_serial–Return instrument serial number.
-
get_potential_range–Get the potential range for the cell.
-
initialize_multiplexer–Initialize the multiplexer.
-
is_cell_on–Get cell status.
-
is_connected–Return True if an instrument connection exists.
-
is_measuring–Return True if device is measuring.
-
measure–Start measurement using given method parameters.
-
on–Register a callback to invoke for the specified event.
-
on_curve_begin–Register a callback to invoke at the start of a new curve.
-
on_curve_end–Register a callback to invoke at the end of a curve.
-
on_curve_new_data–Register a callback to invoke when new data are received
-
on_eis_data_begin–Register a callback to invoke at the start of a new EIS data set.
-
on_eis_data_end–Register a callback to invoke at the end of an EIS data set.
-
on_eis_new_data–Register a callback to invoke when new eis data are received.
-
on_error–Register a callback to invoke when an error occurs during a measurement.
-
on_measurement_begin–Register a callback to invoke at the start of a measurement.
-
on_measurement_end–Register a callback to invoke at the end of a measurement.
-
on_measurement_setup–Register a callback to invoke before the measurement starts.
-
on_measurement_teardown–Register a callback to invoke after the measurement ends.
-
on_receive_message–Register a callback for when a new message is received.
-
on_receive_status–Register a callback for idle status update events.
-
query–Send a command using the communication protocol and return its response.
-
read_current–Read the current in µA.
-
read_potential–Read the potential in V.
-
set_cell–Turn the cell on or off.
-
set_current_range–Set the current range for the cell.
-
set_multiplexer_channel–Sets the multiplexer channel.
-
set_mux8r2_settings–Set the settings for the Mux8R2 multiplexer.
-
set_potential–Set the potential of the cell.
-
set_potential_range–Set the potential range for the cell.
-
status–Get status.
-
supported_applied_current_ranges–List applied current ranges supported by this device.
-
supported_bipot_current_ranges–List bipot current ranges supported by this device.
-
supported_current_ranges–List current ranges supported by this device.
-
supported_methods–List methods supported by this device.
-
supported_potential_ranges–List applied potential ranges supported by this device.
-
validate_method–Validate method.
-
wait_digital_trigger–Wait for digital trigger.
Attributes:
-
capabilities(Capabilities) –Retrieve device capabilities and device info as a dataclass.
-
instrument(Instrument) –Instrument being managed by this class.
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
124 125 126 127 128 129 130 131 132 | |
capabilities
property
capabilities: Capabilities
Retrieve device capabilities and device info as a dataclass.
Returns:
-
capabilities(Capabilities) –Device capabilities and device info.
instrument
instance-attribute
instrument: Instrument = instrument
Instrument being managed by this class.
abort
async
abort() -> None
Abort measurement.
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
439 440 441 442 | |
connect
async
connect() -> None
Connect to instrument.
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
171 172 173 174 175 176 177 178 179 180 181 | |
disconnect
async
disconnect()
Disconnect from the instrument.
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
583 584 585 586 587 588 589 590 | |
ensure_connection
ensure_connection()
Raises connection error if the instrument is not connected.
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
166 167 168 169 | |
get_current_range
async
get_current_range() -> AllowedCurrentRanges
Get the current range for the cell.
Returns:
-
current_range(AllowedCurrentRanges) –
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
242 243 244 245 246 247 248 249 250 251 252 253 254 | |
get_estimated_duration
get_estimated_duration(method: Method | MethodTypeCompatible) -> float
Get the estimated duration for this method.
Parameters:
-
(methodMethodType) –The method to get the estimated duration for.
Returns:
-
float–Estimated duration in seconds.
Source code in src/pypalmsens/_instruments/capabilities_mixin.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
get_instrument_serial
async
get_instrument_serial() -> str
Return instrument serial number.
Returns:
-
serial(str) –Instrument serial.
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 | |
get_potential_range
async
get_potential_range() -> AllowedPotentialRanges
Get the potential range for the cell.
Returns:
-
potential_range(AllowedPotentialRanges) –
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
295 296 297 298 299 300 301 302 303 304 | |
initialize_multiplexer
async
Initialize the multiplexer.
Parameters:
-
(mux_modelint) –The model of the multiplexer. - 0 = 8 channel - 1 = 16 channel - 2 = 32 channel
Returns:
-
channels(int) –Number of available multiplexes channels
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 | |
is_cell_on
async
is_cell_on() -> bool
Get cell status.
Returns:
-
cell_on(bool) –Return true if the cell is on
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
216 217 218 219 220 221 222 223 224 225 226 227 | |
is_connected
is_connected() -> bool
Return True if an instrument connection exists.
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
162 163 164 | |
is_measuring
is_measuring() -> bool
Return True if device is measuring.
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
146 147 148 | |
measure
async
measure(method: MethodTypeCompatible, *, callback: Callback | CallbackEIS | None = None, stream: Path | str | None = None, sync_event: Event | None = None)
Start measurement using given method parameters.
Parameters:
-
(methodMethodTypeCompatible) –Method parameters for measurement.
-
(callbackCallback | CallbackEIS | None, default:None) –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 an instance of
ps.data.CallbackDatafor non-impedimetric orps.data.CallbackDataEIS. for impedimetric measurments. -
(streamPath | str | None, default:None) –If defined, stream data directly to this file in JSON Lines text format (https://jsonlines.org). This option is useful for long-term measurements. In case of a PC crash or power outage, the most recent measurement data will still be available.
-
(sync_eventEvent | None, default:None) –Event for hardware synchronization. Do not use directly. Instead, initiate hardware sync via
InstrumentPoolAsync.measure().
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | |
on
on(event: AllowedEvents, callback: Callable[..., None]) -> EventHandle
Register a callback to invoke for the specified event.
Parameters:
-
(eventAllowedEvents) –Name of the event to subscribe to. For most events this simply appends callback to the internal listeners dictionary.
-
(callbackCallable[..., None]) –Function that will be invoked when the event is triggered.
Returns:
-
EventHandle–Handle that can be used to cancel the subscription.
Notes
'receive_message'and'receive_status'are handled specially: they create instances of :class:EventHandleReceiveMessageor :class:EventHandleStatus, respectively, which attach the callback directly to the underlying communication layer.
Source code in src/pypalmsens/_instruments/events_mixin.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
on_curve_begin
Register a callback to invoke at the start of a new curve.
For EIS use on_eis_data_start.
Parameters:
-
(callbackCallable[[Curve]]) –The function to call when triggered. Passes pypalmsens.data.Curve as argument to the callback.
Returns:
-
EventHandle–Handle that can be used to cancel the subscription.
Source code in src/pypalmsens/_instruments/events_mixin.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | |
on_curve_end
Register a callback to invoke at the end of a curve.
For EIS use on_eis_data_end.
Parameters:
-
(callbackCallable[[Curve]]) –The function to call when triggered. Passes pypalmsens.data.Curve as argument to the callback.
Returns:
-
EventHandle–Handle that can be used to cancel the subscription.
Source code in src/pypalmsens/_instruments/events_mixin.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
on_curve_new_data
on_curve_new_data(callback: Callable[[CallbackData], None]) -> EventHandle
Register a callback to invoke when new data are received
Note that the data are batched depending on available resources.
For EIS use on_eis_new_data.
Parameters:
-
(callbackCallable[[CallbackData]]) –The function to call when triggered. Passes pypalmsens.data.CallbackData as argument to the callback.
Returns:
-
EventHandle–Handle that can be used to cancel the subscription.
Source code in src/pypalmsens/_instruments/events_mixin.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
on_eis_data_begin
Register a callback to invoke at the start of a new EIS data set.
Parameters:
-
(callbackCallable[[EISData]]) –The function to call when triggered. Passes pypalmsens.data.EISData as argument to the callback.
Returns:
-
EventHandle–Handle that can be used to cancel the subscription.
Source code in src/pypalmsens/_instruments/events_mixin.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
on_eis_data_end
Register a callback to invoke at the end of an EIS data set.
Parameters:
-
(callbackCallable) –The function to call when triggered.
Returns:
-
EventHandle–Handle that can be used to cancel the subscription.
Source code in src/pypalmsens/_instruments/events_mixin.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 | |
on_eis_new_data
on_eis_new_data(callback: Callable[[CallbackDataEIS], None]) -> EventHandle
Register a callback to invoke when new eis data are received.
Data points are batched depending on available resources.
Parameters:
-
(callbackCallable[[CallbackDataEIS]]) –The function to call when triggered. Passes pypalmsens.data.CallbackDataEIS as argument to the callback.
Returns:
-
EventHandle–Handle that can be used to cancel the subscription.
Source code in src/pypalmsens/_instruments/events_mixin.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | |
on_error
Register a callback to invoke when an error occurs during a measurement.
These errors can be a connection or communication error.
Parameters:
-
(callbackCallable) –The function to call when triggered.
Returns:
-
EventHandle–Handle that can be used to cancel the subscription.
Source code in src/pypalmsens/_instruments/events_mixin.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
on_measurement_begin
on_measurement_begin(callback: Callable[[Measurement], None]) -> EventHandle
Register a callback to invoke at the start of a measurement.
Parameters:
-
(callbackCallable) –The function to call when triggered. Passes pypalmsens.data.Measurement as argument to the callback.
Returns:
-
EventHandle–Handle that can be used to cancel the subscription.
Source code in src/pypalmsens/_instruments/events_mixin.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
on_measurement_end
on_measurement_end(callback: Callable[[Measurement], None]) -> EventHandle
Register a callback to invoke at the end of a measurement.
Parameters:
-
(callbackCallable) –The function to call when triggered. Passes pypalmsens.data.Measurement as argument to the callback.
Returns:
-
EventHandle–Handle that can be used to cancel the subscription.
Source code in src/pypalmsens/_instruments/events_mixin.py
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
on_measurement_setup
Register a callback to invoke before the measurement starts.
Use this to set up file resources, database connections, etc.
Parameters:
-
(callbackCallable) –The function to call when triggered.
Returns:
-
EventHandle–Handle that can be used to cancel the subscription.
Source code in src/pypalmsens/_instruments/events_mixin.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | |
on_measurement_teardown
Register a callback to invoke after the measurement ends.
The measurement ends when it finnished successfully or after an error occurs. Use this to close files or clean up resources.
Parameters:
-
(callbackCallable) –The function to call when triggered.
Returns:
-
EventHandle–Handle that can be used to cancel the subscription.
Source code in src/pypalmsens/_instruments/events_mixin.py
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | |
on_receive_message
Register a callback for when a new message is received.
The callback will be invoked, for example, when a method is started,
or when send_string is called in MethodSCRIPT.
Parameters:
-
(callbackcallable[[str]]) –The function to call when triggered. Passes str as argument to the callback.
Returns:
-
EventHandle–Handle that can be used to cancel the subscription.
Source code in src/pypalmsens/_instruments/events_mixin.py
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | |
on_receive_status
Register a callback for idle status update events.
Requires active event loop (i.e. async only).
The callback will be invoked whenever the instrument sends updated current/potential values during idle state or pretreatment phases. The update frequency varies per device.
Parameters:
-
(callbackcallable[[Status]]) –The function to call when triggered. Passes pypalmsens.data.Status as argument to the callback.
Returns:
-
EventHandle–Handle that can be used to cancel the subscription.
Source code in src/pypalmsens/_instruments/events_mixin.py
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | |
query
async
Send a command using the communication protocol and return its response.
This is a method for direct communication with the instrument. It writes the command to the device, waits for completion, reads the full response, and returns it as a string.
For commands that run for a long time (e.g. scripts), this method will block until the script completes or times out.
See also pypalmsens.CommProtocolAsync.
Parameters:
-
(commandstr) –The command to send (e.g., 'i' to get the serial number). If
commanddoes not end with'\n', one is automatically added. -
(delayfloat, default:None) –Pause (in seconds) between read attempts. Defaults to
self.delay.
Returns:
-
response(str) –The complete response from the device.
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 | |
read_current
async
read_current() -> float
Read the current in µA.
Returns:
-
current(float) –Current in µA.
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
229 230 231 232 233 234 235 236 237 238 239 240 | |
read_potential
async
read_potential() -> float
Read the potential in V.
Returns:
-
potential(float) –Potential in V.
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
270 271 272 273 274 275 276 277 278 279 280 281 282 | |
set_cell
async
Turn the cell on or off.
Parameters:
-
(cell_onbool) –If true, turn on the cell
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
205 206 207 208 209 210 211 212 213 214 | |
set_current_range
async
set_current_range(current_range: AllowedCurrentRanges)
Set the current range for the cell.
Parameters:
-
(current_rangeAllowedCurrentRanges) –Set the current range as a string. See
pypalmsens.settings.AllowedCurrentRangesfor options.
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
256 257 258 259 260 261 262 263 264 265 266 267 268 | |
set_multiplexer_channel
async
Sets the multiplexer channel.
Parameters:
-
(channelint) –Index of the channel to set.
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
572 573 574 575 576 577 578 579 580 581 | |
set_mux8r2_settings
async
set_mux8r2_settings(connect_sense_to_working_electrode: bool = False, combine_reference_and_counter_electrodes: bool = False, use_channel_1_reference_and_counter_electrodes: bool = False, set_unselected_channel_working_electrode: int = 0)
Set the settings for the Mux8R2 multiplexer.
Parameters:
-
(connect_sense_to_working_electrodebool, default:False) –Connect the sense electrode to the working electrode. Default is False.
-
(combine_reference_and_counter_electrodesbool, default:False) –Combine the reference and counter electrodes. Default is False.
-
(use_channel_1_reference_and_counter_electrodesbool, default:False) –Use channel 1 reference and counter electrodes for all working electrodes. Default is False.
-
(set_unselected_channel_working_electrodeint, default:0) –Set the unselected channel working electrode to disconnected/floating (0), ground (1), or standby potential (2). Default is 0.
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 | |
set_potential
async
Set the potential of the cell.
Parameters:
-
(potentialfloat) –Potential in V
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
284 285 286 287 288 289 290 291 292 293 | |
set_potential_range
async
set_potential_range(potential_range: AllowedPotentialRanges)
Set the potential range for the cell.
Parameters:
-
(potential_rangeAllowedPotentialRanges) –Set the potential range as a string. See
pypalmsens.settings.AllowedPotentialRangesfor options.
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
306 307 308 309 310 311 312 313 314 315 316 317 318 | |
status
status() -> Status
Get status.
Sets device 'StatusWhenIdle' flag on device, which tells it to periodically send an updated status message.
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
supported_applied_current_ranges
supported_applied_current_ranges() -> list[AllowedCurrentRanges]
List applied current ranges supported by this device.
Returns:
-
current_ranges(list[AllowedCurrentRanges]) –List of supported current ranges.
Source code in src/pypalmsens/_instruments/capabilities_mixin.py
63 64 65 66 67 68 69 70 71 72 | |
supported_bipot_current_ranges
supported_bipot_current_ranges() -> list[AllowedCurrentRanges]
List bipot current ranges supported by this device.
Returns:
-
current_ranges(list[AllowedCurrentRanges]) –List of supported current ranges.
Source code in src/pypalmsens/_instruments/capabilities_mixin.py
74 75 76 77 78 79 80 81 82 83 | |
supported_current_ranges
supported_current_ranges() -> list[AllowedCurrentRanges]
List current ranges supported by this device.
Returns:
-
current_ranges(list[AllowedCurrentRanges]) –List of supported current ranges.
Source code in src/pypalmsens/_instruments/capabilities_mixin.py
52 53 54 55 56 57 58 59 60 61 | |
supported_methods
supported_methods() -> list[AllowedMethods]
List methods supported by this device.
Returns:
-
methods(list[AllowedMethods]) –List of supported methods.
Source code in src/pypalmsens/_instruments/capabilities_mixin.py
41 42 43 44 45 46 47 48 49 50 | |
supported_potential_ranges
supported_potential_ranges() -> list[AllowedPotentialRanges]
List applied potential ranges supported by this device.
Returns:
-
potential_ranges(list[AllowedPotentialRanges]) –List of supported potential ranges.
Source code in src/pypalmsens/_instruments/capabilities_mixin.py
85 86 87 88 89 90 91 92 93 94 | |
validate_method
validate_method(method: MethodTypeCompatible)
Validate method.
Raise ValueError if the method cannot be validated.
Parameters:
-
(methodMethodTypeCompatible) –The method to validate.
Source code in src/pypalmsens/_instruments/capabilities_mixin.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
wait_digital_trigger
async
wait_digital_trigger(wait_for_high: bool) -> None
Wait for digital trigger.
Parameters:
-
(wait_for_highbool) –Wait for digital line high before starting
Source code in src/pypalmsens/_instruments/instrument_manager_async.py
425 426 427 428 429 430 431 432 433 434 435 436 437 | |
pypalmsens.InstrumentPoolAsync
InstrumentPoolAsync(instruments_or_managers: Sequence[Instrument | InstrumentManagerAsync])
Manages a set of instrument.
Most calls are run asynchronously in the background, which means that measurements are running in parallel.
Parameters:
-
(instruments_or_managerslist[Instrument | InstrumentManagerAsync]) –List of instrumnets or managers.
Methods:
-
add–Open and add manager to the pool.
-
connect–Connect all instrument managers in the pool.
-
disconnect–Disconnect all instrument managers in the pool.
-
is_connected–Return true if all managers in the pool are connected.
-
is_disconnected–Return true if all managers in the pool are disconnected.
-
measure–Concurrently start measurement on all managers in the pool.
-
remove–Close and remove manager from pool.
-
status–Return status for all managers in pool.
-
submit–Concurrently start measurement on all managers in the pool.
Attributes:
-
managers(list[InstrumentManagerAsync]) –List of instruments managers in the pool.
Source code in src/pypalmsens/_instruments/instrument_pool_async.py
32 33 34 35 36 37 38 39 40 41 42 43 | |
managers
instance-attribute
managers: list[InstrumentManagerAsync] = []
List of instruments managers in the pool.
add
async
add(manager: InstrumentManagerAsync) -> None
Open and add manager to the pool.
Parameters:
-
(managerInstrumentManagerAsync) –Instance of an instrument manager.
Source code in src/pypalmsens/_instruments/instrument_pool_async.py
114 115 116 117 118 119 120 121 122 123 | |
connect
async
Connect all instrument managers in the pool.
Parameters:
-
(attemptsint, default:1) –Number of attempts to establish connection. Use this if you experience connection issues via USB.
Source code in src/pypalmsens/_instruments/instrument_pool_async.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
disconnect
async
disconnect() -> None
Disconnect all instrument managers in the pool.
Source code in src/pypalmsens/_instruments/instrument_pool_async.py
90 91 92 93 | |
is_connected
is_connected() -> bool
Return true if all managers in the pool are connected.
Source code in src/pypalmsens/_instruments/instrument_pool_async.py
95 96 97 | |
is_disconnected
is_disconnected() -> bool
Return true if all managers in the pool are disconnected.
Source code in src/pypalmsens/_instruments/instrument_pool_async.py
99 100 101 | |
measure
async
measure(method: MethodType, callback: Sequence[Callback | CallbackEIS] | Callback | CallbackEIS | None = None, **kwargs) -> list[Measurement]
Concurrently start measurement on all managers in the pool.
For hardware synchronization, set .general.use_hardware_sync on the method.
For MethodSCRIPT, use 'set_channel_sync 1'.
In addition, the pool must contain: - channels from a single multichannel instrument only - the first channel of the multichannel instrument - at least two channels
All instruments are prepared and put in a waiting state. The measurements are started via a hardware sync trigger on channel 1.
Parameters:
-
(methodMethodType) –Method parameters for measurement.
-
(callbacklist[Callback] | Callback | CallbackEIS | None, default:None) –If specified, call these functions/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.
Specify a sequence of callbacks to set a different function for every channel. The number of callbacks must match the number of channels.
Specify a single callback to set the same function to all channels.
-
–**kwargsThese keyword parameters are passed to the measure function.
Source code in src/pypalmsens/_instruments/instrument_pool_async.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
remove
async
remove(manager: InstrumentManagerAsync) -> None
Close and remove manager from pool.
Parameters:
-
(managerInstrumentManagerAsync) –Instance of an instrument manager.
Source code in src/pypalmsens/_instruments/instrument_pool_async.py
103 104 105 106 107 108 109 110 111 112 | |
status
Return status for all managers in pool.
Returns:
Source code in src/pypalmsens/_instruments/instrument_pool_async.py
125 126 127 128 129 130 131 132 133 | |
submit
async
Concurrently start measurement on all managers in the pool.
This method does not support hardware sync.
Parameters:
-
(funcCallable) –This function gets called with an instance of
InstrumentManagerAsyncas the argument. -
(**kwargsAny, default:{}) –These keyword arguments are passed on to the submitted function.
Source code in src/pypalmsens/_instruments/instrument_pool_async.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |