ophyd_async.sim#

Some simulated devices to be used in tutorials and testing.

Package Contents#

Classes#

SimMotor

For usage when simulating a motor.

FlySimMotorInfo

Minimal set of information required to fly a SimMotor.

SimStage

A simulated sample stage with X and Y movables.

PatternGenerator

Generates pattern images in files.

SimPointDetector

Simalutes a point detector with multiple channels.

SimBlobDetector

Simulates a detector and writes Blobs to file.

API#

class ophyd_async.sim.SimMotor(name='', instant=True)[source]#

Bases: ophyd_async.core.StandardReadable, bluesky.protocols.Movable, bluesky.protocols.Stoppable

For usage when simulating a motor.

set_name(name: str, *, child_name_separator: str | None = None) None[source]#

Set self.name=name and each self.child.name=name+"-child".

Parameters:
  • name – New name to set.

  • child_name_separator – Use this as a separator instead of “-”. Use “_” instead to make the same names as the equivalent ophyd sync device.

async prepare(value: FlySimMotorInfo)[source]#

Calculate run-up and move there, setting fly velocity when there.

async kickoff()[source]#

Begin moving motor from prepared position to final position.

complete() WatchableAsyncStatus[source]#

Mark as complete once motor reaches completed position.

async set(value: float)[source]#

Asynchronously move the motor to a new position.

async stop(success=True)[source]#

Stop the motor if it is moving.

class ophyd_async.sim.FlySimMotorInfo(/, **data: ~typing.Any)[source]#

Bases: pydantic.BaseModel

Minimal set of information required to fly a SimMotor.

model_config#

‘ConfigDict(…)’

cv_start: float#

None

Absolute position of the motor once it finishes accelerating to desired velocity, in motor EGUs

cv_end: float#

None

Absolute position of the motor once it begins decelerating from desired velocity, in EGUs

cv_time: float#

‘Field(…)’

Time taken for the motor to get from start_position to end_position, excluding run-up and run-down, in seconds.

property velocity: float#

Calculate the velocity of the constant velocity phase.

start_position(acceleration_time: float) float[source]#

Calculate the start position with run-up distance added on.

end_position(acceleration_time: float) float[source]#

Calculate the end position with run-down distance added on.

class ophyd_async.sim.SimStage(pattern_generator: PatternGenerator, name='')[source]#

Bases: ophyd_async.core.StandardReadable

A simulated sample stage with X and Y movables.

class ophyd_async.sim.PatternGenerator[source]#

Generates pattern images in files.

set_x(x: float)[source]#
set_y(y: float)[source]#
generate_point(channel: int = 1, high_energy: bool = False) float[source]#

Make a point between 0 and 1 based on x and y.

open_file(path: Path, width: int, height: int)[source]#
write_image_to_file(exposure: float)[source]#
async observe_indices_written(timeout: float) AsyncGenerator[int][source]#
async get_last_index() int[source]#
close_file()[source]#
class ophyd_async.sim.SimPointDetector(generator: PatternGenerator, num_channels: int = 3, name: str = '')[source]#

Bases: ophyd_async.core.StandardReadable

Simalutes a point detector with multiple channels.

async trigger()[source]#
class ophyd_async.sim.SimBlobDetector(path_provider: PathProvider, pattern_generator: PatternGenerator | None = None, config_sigs: Sequence[SignalR] = (), name: str = '')[source]#

Bases: ophyd_async.core.StandardDetector

Simulates a detector and writes Blobs to file.