From cf0268b483ba834070cf23f11a2738c046920a94 Mon Sep 17 00:00:00 2001 From: Oli Wenman Date: Tue, 24 Feb 2026 16:34:16 +0000 Subject: [PATCH 1/2] Update fast shutter and selectable source device names --- src/dodal/devices/fast_shutter.py | 10 ++++++++++ src/dodal/devices/selectable_source.py | 5 +++++ tests/devices/test_fast_shutters.py | 6 ++---- tests/devices/test_selectable_source.py | 6 +----- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/dodal/devices/fast_shutter.py b/src/dodal/devices/fast_shutter.py index 170da4cf57b..6d9cb07b70a 100644 --- a/src/dodal/devices/fast_shutter.py +++ b/src/dodal/devices/fast_shutter.py @@ -71,6 +71,11 @@ def __init__( self.shutter_state = epics_signal_rw(type(self.open_state), pv) super().__init__(name) + def set_name(self, name: str, *, child_name_separator: str | None = None) -> None: + """Set name of the device and its children.""" + super().set_name(name, child_name_separator=child_name_separator) + self.shutter_state.set_name(name) + class DualFastShutter(StandardReadable, FastShutter[EnumTypesT], Generic[EnumTypesT]): """A fast shutter device that handles the positions of two other fast shutters. The @@ -153,3 +158,8 @@ async def _set_shutter_state(self, value: EnumTypesT): ) await inactive_shutter.set(inactive_shutter.close_state) await active_shutter.set(value) + + def set_name(self, name: str, *, child_name_separator: str | None = None) -> None: + """Set name of the device and its children.""" + super().set_name(name, child_name_separator=child_name_separator) + self.shutter_state.set_name(name) diff --git a/src/dodal/devices/selectable_source.py b/src/dodal/devices/selectable_source.py index 2e3a69cdaf2..dd9823d926f 100644 --- a/src/dodal/devices/selectable_source.py +++ b/src/dodal/devices/selectable_source.py @@ -36,6 +36,11 @@ def __init__(self, name: str = ""): ) super().__init__(name) + def set_name(self, name: str, *, child_name_separator: str | None = None) -> None: + """Set name of the device and its children.""" + super().set_name(name, child_name_separator=child_name_separator) + self.selected_source.set_name(name) + @AsyncStatus.wrap async def set(self, value: SelectedSource): await self.selected_source.set(value) diff --git a/tests/devices/test_fast_shutters.py b/tests/devices/test_fast_shutters.py index 5babc3dde94..04345c48868 100644 --- a/tests/devices/test_fast_shutters.py +++ b/tests/devices/test_fast_shutters.py @@ -31,9 +31,7 @@ async def test_shutter_set_open_close_without_knowing_enum_values( async def test_shutter_read(shutter1: GenericFastShutter) -> None: - await assert_reading( - shutter1, {f"{shutter1.name}-shutter_state": partial_reading(InOut.IN)} - ) + await assert_reading(shutter1, {shutter1.name: partial_reading(InOut.IN)}) @pytest.fixture @@ -139,7 +137,7 @@ async def test_dual_fast_shutter_read( ) await assert_reading( dual_fast_shutter, - {f"{dual_fast_shutter.name}-shutter_state": partial_reading(InOut.IN)} + {dual_fast_shutter.name: partial_reading(InOut.IN)} | shutter1_read | shutter2_read | source_selector_read, diff --git a/tests/devices/test_selectable_source.py b/tests/devices/test_selectable_source.py index 5373180c23f..c8e35861cc9 100644 --- a/tests/devices/test_selectable_source.py +++ b/tests/devices/test_selectable_source.py @@ -28,11 +28,7 @@ async def test_source_selector_set( async def test_source_selector_read(source_selector: SourceSelector) -> None: await assert_reading( source_selector, - { - f"{source_selector.name}-selected_source": partial_reading( - SelectedSource.SOURCE1 - ) - }, + {source_selector.name: partial_reading(SelectedSource.SOURCE1)}, ) From d384d96d55a4002480651f238a381a491a4313c4 Mon Sep 17 00:00:00 2001 From: Oli Wenman Date: Tue, 24 Feb 2026 16:42:12 +0000 Subject: [PATCH 2/2] Update to use hinted signal --- src/dodal/devices/fast_shutter.py | 4 ++-- src/dodal/devices/selectable_source.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/dodal/devices/fast_shutter.py b/src/dodal/devices/fast_shutter.py index 6d9cb07b70a..c45e66423f1 100644 --- a/src/dodal/devices/fast_shutter.py +++ b/src/dodal/devices/fast_shutter.py @@ -67,7 +67,7 @@ def __init__( ): self.open_state = open_state self.close_state = close_state - with self.add_children_as_readables(): + with self.add_children_as_readables(StandardReadableFormat.HINTED_SIGNAL): self.shutter_state = epics_signal_rw(type(self.open_state), pv) super().__init__(name) @@ -109,7 +109,7 @@ def __init__( self._shutter2_ref = Reference(shutter2) self._selected_shutter_ref = Reference(selected_source) - with self.add_children_as_readables(): + with self.add_children_as_readables(StandardReadableFormat.HINTED_SIGNAL): self.shutter_state = derived_signal_rw( self._read_shutter_state, self._set_shutter_state, diff --git a/src/dodal/devices/selectable_source.py b/src/dodal/devices/selectable_source.py index dd9823d926f..d182e449532 100644 --- a/src/dodal/devices/selectable_source.py +++ b/src/dodal/devices/selectable_source.py @@ -1,7 +1,13 @@ from typing import TypeVar from bluesky.protocols import Movable -from ophyd_async.core import AsyncStatus, StandardReadable, StrictEnum, soft_signal_rw +from ophyd_async.core import ( + AsyncStatus, + StandardReadable, + StandardReadableFormat, + StrictEnum, + soft_signal_rw, +) class SelectedSource(StrictEnum): @@ -30,7 +36,7 @@ class SourceSelector(StandardReadable, Movable[SelectedSource]): """ def __init__(self, name: str = ""): - with self.add_children_as_readables(): + with self.add_children_as_readables(StandardReadableFormat.HINTED_SIGNAL): self.selected_source = soft_signal_rw( SelectedSource, SelectedSource.SOURCE1 )