From ad1b042f2ee74874659433c9eaa03a90c308cccf Mon Sep 17 00:00:00 2001 From: David Perl Date: Wed, 26 Nov 2025 09:40:36 +0100 Subject: [PATCH] fix: improvements from review --- ophyd_devices/devices/optics_shutter.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/ophyd_devices/devices/optics_shutter.py b/ophyd_devices/devices/optics_shutter.py index bcb1bd5..2ccb11d 100644 --- a/ophyd_devices/devices/optics_shutter.py +++ b/ophyd_devices/devices/optics_shutter.py @@ -4,6 +4,7 @@ from ophyd import Component as Cpt from ophyd import EpicsSignal, EpicsSignalRO, Kind from ophyd.status import SubscriptionStatus +from ophyd_devices import CompareStatus from ophyd_devices.interfaces.base_classes.psi_device_base import PSIDeviceBase @@ -17,13 +18,6 @@ class ShutterEnabled(IntEnum): DISABLED = 0 -def _is_state(state: int | str): - def _cb(*, old_value, value, **kwargs): - return value == state - - return _cb - - class Shutter(PSIDeviceBase): """A generic optics shutter device, for IOCs with the format '[BEAMLINE]-EH1-PSYS:SH-[A/B]-' @@ -47,11 +41,13 @@ class Shutter(PSIDeviceBase): """ - is_open = Cpt(EpicsSignalRO, "OPEN", kind=Kind.hinted) + USER_ACCESS = ["open", "close", "status", "enabled"] + + is_open = Cpt(EpicsSignalRO, "OPEN", kind=Kind.config, auto_monitor=True) is_closed = Cpt(EpicsSignalRO, "CLOSE", kind=Kind.omitted) - is_enabled = Cpt(EpicsSignalRO, "ENABLE") - is_ok = Cpt(EpicsSignalRO, "OK") - alarm = Cpt(EpicsSignalRO, "ALARM") + is_enabled = Cpt(EpicsSignalRO, "ENABLE", kind=Kind.config, auto_monitor=True) + is_ok = Cpt(EpicsSignalRO, "OK", kind=Kind.omitted, auto_monitor=True) + alarm = Cpt(EpicsSignalRO, "ALARM", kind=Kind.omitted, auto_monitor=True) set_open = Cpt(EpicsSignal, "OPEN-SET", kind=Kind.omitted) set_closed = Cpt(EpicsSignal, "CLOSE-SET", kind=Kind.omitted) @@ -66,7 +62,7 @@ class Shutter(PSIDeviceBase): """ self._check_enabled() self.set_open.put(1) - return SubscriptionStatus(self.is_open, _is_state(ShutterOpenState.OPEN)) + return CompareStatus(self.is_open, ShutterOpenState.OPEN) def close(self): """Close the shutter. @@ -75,7 +71,7 @@ class Shutter(PSIDeviceBase): """ self._check_enabled() self.set_closed.put(1) - return SubscriptionStatus(self.is_open, _is_state(ShutterOpenState.CLOSED)) + return CompareStatus(self.is_open, ShutterOpenState.CLOSED) def status(self) -> ShutterOpenState: return ShutterOpenState(self.is_open.get())