Skip to content

Commit

Permalink
(#826) make backlight conform to Moveable
Browse files Browse the repository at this point in the history
  • Loading branch information
dperl-dls committed Oct 9, 2024
1 parent fc240e8 commit 09d6530
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/dodal/devices/backlight.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from asyncio import sleep
from enum import Enum

from bluesky.protocols import Movable
from ophyd_async.core import AsyncStatus, StandardReadable
from ophyd_async.epics.signal import epics_signal_rw

Expand All @@ -15,7 +16,7 @@ class BacklightPosition(str, Enum):
OUT = "Out"


class Backlight(StandardReadable):
class Backlight(StandardReadable, Movable):
"""Simple device to trigger the pneumatic in/out."""

TIME_TO_MOVE_S = 1 # Tested using a stopwatch on the beamline 09/2024
Expand All @@ -29,7 +30,7 @@ def __init__(self, prefix: str, name: str = "") -> None:
super().__init__(name)

@AsyncStatus.wrap
async def set(self, position: BacklightPosition):
async def set(self, value: BacklightPosition):
"""This setter will turn the backlight on when we move it in to the beam and off
when we move it out.
Expand All @@ -38,10 +39,10 @@ async def set(self, position: BacklightPosition):
to move completely in/out so we sleep here to simulate this.
"""
old_position = await self.position.get_value()
await self.position.set(position)
if position == BacklightPosition.OUT:
await self.position.set(value)
if value == BacklightPosition.OUT:
await self.power.set(BacklightPower.OFF)
else:
await self.power.set(BacklightPower.ON)
if old_position != position:
if old_position != value:
await sleep(self.TIME_TO_MOVE_S)

0 comments on commit 09d6530

Please sign in to comment.