Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/dodal/devices/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class SampleLocation:
pin: int


SAMPLE_LOCATION_EMPTY = SampleLocation(-1, -1)


class PinMounted(StrictEnum):
NO_PIN_MOUNTED = "No Pin Mounted"
PIN_MOUNTED = "Pin Mounted"
Expand All @@ -61,7 +64,7 @@ async def raise_if_error(self, raise_from: Exception):
raise RobotLoadError(int(error_code), error_string) from raise_from


class BartRobot(StandardReadable, Movable[SampleLocation | None]):
class BartRobot(StandardReadable, Movable[SampleLocation]):
"""The sample changing robot."""

# How long to wait for the robot if it is busy soaking/drying
Expand Down Expand Up @@ -179,16 +182,16 @@ async def _load_pin_and_puck(self, sample_location: SampleLocation):
await self.pin_state_or_error()

@AsyncStatus.wrap
async def set(self, value: SampleLocation | None):
async def set(self, value: SampleLocation):
"""
Perform a sample load from the specified sample location
Args:
value: The pin and puck to load, or None to unload the sample.
value: The pin and puck to load, or SAMPLE_LOCATION_EMPTY to unload the sample.
Raises:
RobotLoadError if a timeout occurs, or if an error occurs loading the smaple.
RobotLoadError if a timeout occurs, or if an error occurs loading the sample.
"""
try:
if value is not None:
if value != SAMPLE_LOCATION_EMPTY:
await wait_for(
self._load_pin_and_puck(value),
timeout=self.LOAD_TIMEOUT + self.NOT_BUSY_TIMEOUT,
Expand Down
7 changes: 4 additions & 3 deletions tests/devices/test_bart_robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
)

from dodal.devices.robot import (
SAMPLE_LOCATION_EMPTY,
WAIT_FOR_NEW_PIN_MSG,
WAIT_FOR_OLD_PIN_MSG,
BartRobot,
Expand Down Expand Up @@ -253,7 +254,7 @@ async def test_moving_the_robot_will_reset_error_if_light_curtain_is_tripped_and
async def test_unloading_the_robot_waits_for_drying_to_complete(robot_for_unload):
robot, trigger_completed, drying_completed = robot_for_unload
drying_completed.set()
unload_status = robot.set(None)
unload_status = robot.set(SAMPLE_LOCATION_EMPTY)

await asyncio.sleep(0.1)
assert not unload_status.done
Expand All @@ -269,7 +270,7 @@ async def test_unloading_the_robot_times_out_if_unloading_takes_too_long(
):
robot, trigger_completed, drying_completed = robot_for_unload
drying_completed.set()
unload_status = robot.set(None)
unload_status = robot.set(SAMPLE_LOCATION_EMPTY)

with pytest.raises(RobotLoadError) as exc_info:
await unload_status
Expand All @@ -280,7 +281,7 @@ async def test_unloading_the_robot_times_out_if_unloading_takes_too_long(
async def test_unloading_the_robot_times_out_if_drying_takes_too_long(robot_for_unload):
robot, trigger_completed, drying_completed = robot_for_unload
trigger_completed.set()
unload_status = robot.set(None)
unload_status = robot.set(SAMPLE_LOCATION_EMPTY)

with pytest.raises(RobotLoadError) as exc_info:
await unload_status
Expand Down