microscope.testsuite.devices module

Test devices for use during development.

This module provides a series of test devices, which mimic real hardware behaviour. They implement the different ABC.

class microscope.testsuite.devices.CamEnum(value)[source]

Bases: enum.IntEnum

An enumeration.

A = 1
B = 2
C = 3
D = 4
class microscope.testsuite.devices.DummyDSP(**kwargs)[source]

Bases: microscope.abc.Device

Abort()[source]
DownloadProfile()[source]
InitProfile(numReps)[source]
MoveAbsolute(aline, pos)[source]
PrepareActions(actions, numReps=1)[source]
ReadDigital()[source]
ReadPosition(aline)[source]
RunActions()[source]
WriteDigital(value)[source]
arcl(mask, pairs)[source]
initialize()[source]

Initialize the device.

profileSet(pstr, digitals, *analogs)[source]
receiveClient(*args, **kwargs)[source]
set_client(*args, **kwargs)[source]
trigCollect(*args, **kwargs)[source]
class microscope.testsuite.devices.DummySLM(**kwargs)[source]

Bases: microscope.abc.Device

get_sequence_index()[source]
get_sim_diffraction_angle()[source]
get_sim_sequence()[source]
initialize()[source]

Initialize the device.

run()[source]
set_sim_diffraction_angle(theta)[source]
set_sim_sequence(seq)[source]
stop()[source]
class microscope.testsuite.devices.TestCamera(**kwargs)[source]

Bases: microscope.abc.Camera

abort()[source]

Stop acquisition as soon as possible.

get_cycle_time()[source]

Return the cycle time, in seconds.

get_exposure_time()[source]

Return the current exposure time, in seconds.

get_trigger_type()[source]

Return the current trigger mode.

One of

TRIGGER_AFTER, TRIGGER_BEFORE or TRIGGER_DURATION (bulb exposure.)

initialize()[source]

Initialise the camera.

Open the connection, connect properties and populate settings dict.

make_safe()[source]

Put the device into a safe state.

set_exposure_time(value)[source]

Set the exposure time on the device.

Parameters

value – exposure time in seconds

soft_trigger()[source]

Optional software trigger - implement if available.

class microscope.testsuite.devices.TestController(devices: Mapping[str, microscope.abc.Device])[source]

Bases: microscope.abc.Controller

property devices

Map of names to the controlled devices.

class microscope.testsuite.devices.TestDeformableMirror(n_actuators, **kwargs)[source]

Bases: microscope.abc.DeformableMirror

get_current_pattern()[source]

Method for debug purposes only.

This method is not part of the DeformableMirror ABC, it only exists on this test device to help during development.

property n_actuators
set_trigger(ttype: microscope.TriggerType, tmode: microscope.TriggerMode)None[source]

Set device for a specific trigger.

property trigger_mode
property trigger_type
class microscope.testsuite.devices.TestFilterWheel(**kwargs)[source]

Bases: microscope.abc.FilterWheel

initialize()[source]

Initialize the device.

class microscope.testsuite.devices.TestFloatingDevice(uid: str, **kwargs)[source]

Bases: microscope.abc.FloatingDeviceMixin, microscope.abc.Device

Simple device with a UID after having been initialized.

Floating devices are devices where we can’t specify which one to get, we can only construct it and after initialisation check its UID. In this class for test units we can check which UID to get.

get_id()str[source]

Return a unique hardware identifier, such as a serial number.

initialize()None[source]

Initialize the device.

class microscope.testsuite.devices.TestLaser(**kwargs)[source]

Bases: microscope.abc.Laser

get_is_on()[source]

Return True if the laser is currently able to produce light.

get_status()[source]

Query and return the laser status.

initialize()[source]

Initialize the device.

class microscope.testsuite.devices.TestStage(limits: Mapping[str, microscope.AxisLimits], **kwargs)[source]

Bases: microscope.abc.Stage

A test stage with any number of axis.

Parameters

limits – map of test axis to be created and their limits.

# Test XY motorized stage of square shape:
xy_stage = TestStage({
    'X' : AxisLimits(0, 5000),
    'Y' : AxisLimits(0, 5000),
})

# XYZ stage, on rectangular shape and negative coordinates:
xyz_stage = TestStage({
    'X' : AxisLimits(-5000, 5000),
    'Y' : AxisLimits(-10000, 12000),
    'Z' : AxisLimits(0, 1000),
})
property axes

Map of axis names to the corresponding StageAxis.

for name, axis in stage.axes.items():
    print(f'moving axis named {name}')
    axis.move_by(1)

If an axis is not available then it is not included, i.e., given a stage with optional axes the missing axes will not appear on the returned dict with a value of None or some other special StageAxis instance.

initialize()None[source]

Initialize the device.

move_by(delta: Mapping[str, float])None[source]

Move axes by the corresponding amounts.

Parameters

delta – map of axis name to the amount to be moved.

# Move 'x' axis by 10.2 units and the y axis by -5 units:
stage.move_by({'x': 10.2, 'y': -5})

# The above is equivalent, but possibly faster than:
stage.axes['x'].move_by(10.2)
stage.axes['y'].move_by(-5)

The axes will not move beyond limits(). If delta would move an axis beyond it limit, no exception is raised. Instead, the stage will move until the axis limit.

move_to(position: Mapping[str, float])None[source]

Move axes to the corresponding positions.

Parameters

position – map of axis name to the positions to move to.

# Move 'x' axis to position 8 and the y axis to position -5.3
stage.move_to({'x': 8, 'y': -5.3})

# The above is equivalent to
stage.axes['x'].move_to(8)
stage.axes['y'].move_to(-5.3)

The axes will not move beyond limits(). If positions is beyond the limits, no exception is raised. Instead, the stage will move until the axes limit.

class microscope.testsuite.devices.TestStageAxis(limits: microscope.AxisLimits)[source]

Bases: microscope.abc.StageAxis

property limits

Upper and lower limits values for position.

move_by(delta: float)None[source]

Move axis by given amount.

move_to(pos: float)None[source]

Move axis to specified position.

property position

Current axis position.

microscope.testsuite.devices.must_be_initialized(f)[source]