ibex_bluesky_core.devices.block

ophyd-async devices and utilities for communicating with IBEX blocks.

Members

BlockMot

Device representing an IBEX block pointing at a motor.

BlockR

Device representing an IBEX readable block of arbitrary data type.

BlockRw

Device representing an IBEX read/write block of arbitrary data type.

BlockRwRbv

Device representing an IBEX read/write/setpoint readback block of arbitrary data type.

BlockWriteConfig

Configuration settings for writing to blocks.

RunControl

Subdevice for common run-control signals.

block_mot

Get a local block pointing at a motor record for the local instrument.

block_r

Get a local read-only block for the current instrument.

block_rw

Get a local read-write block for the current instrument.

block_rw_rbv

Get a local read/write/setpoint readback block for the current instrument.

class ibex_bluesky_core.devices.block.BlockMot(prefix: str, block_name: str)[source]

Bases: Motor

Device representing an IBEX block pointing at a motor.

Create a new motor-record block.

The ‘BlockMot’ object supports motion-specific functionality such as: - Stopping if a scan is aborted (supports the bluesky ‘Stoppable’ protocol) - Limit checking (before a move starts - supports the bluesky ‘Checkable’ protocol) - Automatic calculation of move timeouts based on motor velocity - Fly scanning

However, it generally relies on the underlying motor being “well-behaved”. For example, a motor which does many retries may exceed the simple default timeout based on velocity (it is possible to explicitly specify a timeout on set() to override this).

Blocks pointing at motors do not take a BlockWriteConfiguration parameter, as these parameters duplicate functionality which already exists in the motor record. The mapping is:

use_completion_callback:

Motors always use completion callbacks to check whether motion has completed. Whether to wait on that completion callback can be configured by the ‘wait’ keyword argument on set().

set_success_func:

Use .RDBD and .RTRY to control motor retries if the position has not been reached to within a specified tolerance. Note that motors which retry a lot may exceed the default motion timeout which is calculated based on velocity, distance and acceleration.

set_timeout_s:

A suitable timeout is calculated automatically based on velocity, distance and acceleration as defined on the motor record. This may be overridden by the ‘timeout’ keyword-argument on set().

settle_time_s:

Use .DLY on the motor record to configure this.

class ibex_bluesky_core.devices.block.BlockR(datatype: Type[T], prefix: str, block_name: str)[source]

Bases: StandardReadable, Triggerable, Generic[T]

Device representing an IBEX readable block of arbitrary data type.

Create a new read-only block.

Parameters:
  • datatype – the type of data in this block (e.g. str, int, float)

  • prefix – the current instrument’s PV prefix

  • block_name – the name of the block

trigger() None[source]

Blocks need to be triggerable to be used in adaptive scans.

They do not do anything when triggered.

class ibex_bluesky_core.devices.block.BlockRw(datatype: Type[T], prefix: str, block_name: str, *, write_config: BlockWriteConfig[T] | None = None)[source]

Bases: BlockR[T], Movable

Device representing an IBEX read/write block of arbitrary data type.

Create a new read-write block.

The setpoint is not added to read() by default. For most cases where setpoint readback functionality is desired, BlockRwRbv is a more suitable type.

If you explicitly need to read the setpoint from a BlockRw, you can do so in a plan with:

import bluesky.plan_stubs as bps
block: BlockRw = ...
bps.read(block.setpoint)

But note that this does not read back the setpoint from hardware, but rather the setpoint which was last sent by EPICS.

Parameters:
  • datatype – the type of data in this block (e.g. str, int, float)

  • prefix – the current instrument’s PV prefix

  • block_name – the name of the block

  • write_config – Settings which control how this device will set the underlying PVs

set(value: T) None[source]

Set the setpoint of this block.

class ibex_bluesky_core.devices.block.BlockRwRbv(datatype: Type[T], prefix: str, block_name: str, *, write_config: BlockWriteConfig[T] | None = None)[source]

Bases: BlockRw[T], Locatable

Device representing an IBEX read/write/setpoint readback block of arbitrary data type.

Create a new read/write/setpoint readback block.

The setpoint readback is added to read(), but not hints(), by default. If you do not need a setpoint readback, choose BlockRw instead of BlockRwRbv.

Parameters:
  • datatype – the type of data in this block (e.g. str, int, float)

  • prefix – the current instrument’s PV prefix

  • block_name – the name of the block

  • write_config – Settings which control how this device will set the underlying PVs

async locate() Location[T][source]

Get the current ‘location’ of this block.

class ibex_bluesky_core.devices.block.BlockWriteConfig(*, use_completion_callback: bool = True, set_success_func: Callable[[T, T], bool] | None = None, set_timeout_s: float | None = None, settle_time_s: float = 0.0)[source]

Bases: Generic[T]

Configuration settings for writing to blocks.

use_completion_callback:

Whether to wait for an EPICS completion callback while setting this block. Defaults to true, which is appropriate for most blocks.

set_success_func:

An arbitrary function which is called to decide whether the block has set successfully yet or not. The function takes (setpoint, actual) as arguments and should return true if the value has successfully set and is “ready”, or False otherwise.

This can be used to implement arbitrary tolerance behaviour. For example:

def check(setpoint: T, actual: T) -> bool:
    return setpoint - 0.1 <= actual <= setpoint + 0.1

If use_completion_callback is True, the completion callback must complete before set_success_func is ever called.

Executing this function should be “fast” (i.e. the function should not sleep), and it should not do any external I/O.

Defaults to None, which means no check is applied.

set_timeout_s:

A timeout, in seconds, on the value being set successfully. The timeout applies to the EPICS completion callback (if enabled) and the set success function (if provided), and excludes any configured settle time.

Defaults to None, which means no timeout.

settle_time_s:

A wait time, in seconds, which is unconditionally applied just before the set status is marked as complete. Defaults to zero.

class ibex_bluesky_core.devices.block.RunControl(prefix: str, name: str = '')[source]

Bases: StandardReadable

Subdevice for common run-control signals.

Create a run control wrapper for a block.

Usually run control should be accessed via the run_control property on a block, rather than by constructing an instance of this class directly.

Parameters:
  • prefix – the run-control prefix, e.g. “IN:INSTRUMENT:CS:SB:blockname:RC:”

  • name – ophyd device name

ibex_bluesky_core.devices.block.block_mot(block_name: str) BlockMot[source]

Get a local block pointing at a motor record for the local instrument.

See documentation of BlockMot for more information.

ibex_bluesky_core.devices.block.block_r(datatype: Type[T], block_name: str) BlockR[T][source]

Get a local read-only block for the current instrument.

See documentation of BlockR for more information.

ibex_bluesky_core.devices.block.block_rw(datatype: Type[T], block_name: str, *, write_config: BlockWriteConfig[T] | None = None) BlockRw[T][source]

Get a local read-write block for the current instrument.

See documentation of BlockRw for more information.

ibex_bluesky_core.devices.block.block_rw_rbv(datatype: Type[T], block_name: str, *, write_config: BlockWriteConfig[T] | None = None) BlockRwRbv[T][source]

Get a local read/write/setpoint readback block for the current instrument.

See documentation of BlockRwRbv for more information.