Skip to content

Commit

Permalink
Make BimorphMirrorChannel Movable (#977)
Browse files Browse the repository at this point in the history
Add BimorphMirror ophyd class, with child class BimorphMirrorChannel.
  • Loading branch information
dan-fernandes authored Jan 9, 2025
1 parent a29f3af commit a7a01e7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/dodal/devices/bimorph_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class BimorphMirrorStatus(StrictEnum):
ERROR = "Error"


class BimorphMirrorChannel(StandardReadable, EpicsDevice):
class BimorphMirrorChannel(StandardReadable, Movable, EpicsDevice):
"""Collection of PVs comprising a single bimorph channel.
Attributes:
Expand All @@ -56,6 +56,15 @@ class BimorphMirrorChannel(StandardReadable, EpicsDevice):
status: A[SignalR[BimorphMirrorOnOff], PvSuffix("STATUS"), Format.CONFIG_SIGNAL]
shift: A[SignalW[float], PvSuffix("SHIFT")]

@AsyncStatus.wrap
async def set(self, value: float):
"""Sets channel's VOUT to given value.
Args:
value: float to set VOUT to
"""
await self.output_voltage.set(value)


class BimorphMirror(StandardReadable, Movable):
"""Class to represent CAENels Bimorph Mirrors.
Expand Down
13 changes: 13 additions & 0 deletions tests/devices/unit_tests/test_bimorph_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,16 @@ async def test_init_mirror_with_invalid_channels_throws_error(number_of_channels
async def test_init_mirror_with_zero_channels(number_of_channels):
mirror = BimorphMirror(prefix="FAKE-PREFIX", number_of_channels=number_of_channels)
assert len(mirror.channels) == 0


@pytest.mark.parametrize("mirror", VALID_BIMORPH_CHANNELS, indirect=True)
async def test_bimorph_mirror_channel_set(
mirror: BimorphMirror,
valid_bimorph_values: dict[int, float],
):
for value, channel in zip(
valid_bimorph_values.values(), mirror.channels.values(), strict=True
):
assert await channel.output_voltage.get_value() != value
await channel.set(value)
assert await channel.output_voltage.get_value() == value

0 comments on commit a7a01e7

Please sign in to comment.