fix: improvements from review

This commit is contained in:
2025-11-26 09:40:36 +01:00
committed by David Perl
parent 288096b8ff
commit ad1b042f2e

View File

@@ -4,6 +4,7 @@ from ophyd import Component as Cpt
from ophyd import EpicsSignal, EpicsSignalRO, Kind from ophyd import EpicsSignal, EpicsSignalRO, Kind
from ophyd.status import SubscriptionStatus from ophyd.status import SubscriptionStatus
from ophyd_devices import CompareStatus
from ophyd_devices.interfaces.base_classes.psi_device_base import PSIDeviceBase from ophyd_devices.interfaces.base_classes.psi_device_base import PSIDeviceBase
@@ -17,13 +18,6 @@ class ShutterEnabled(IntEnum):
DISABLED = 0 DISABLED = 0
def _is_state(state: int | str):
def _cb(*, old_value, value, **kwargs):
return value == state
return _cb
class Shutter(PSIDeviceBase): class Shutter(PSIDeviceBase):
"""A generic optics shutter device, for IOCs with the format '[BEAMLINE]-EH1-PSYS:SH-[A/B]-' """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_closed = Cpt(EpicsSignalRO, "CLOSE", kind=Kind.omitted)
is_enabled = Cpt(EpicsSignalRO, "ENABLE") is_enabled = Cpt(EpicsSignalRO, "ENABLE", kind=Kind.config, auto_monitor=True)
is_ok = Cpt(EpicsSignalRO, "OK") is_ok = Cpt(EpicsSignalRO, "OK", kind=Kind.omitted, auto_monitor=True)
alarm = Cpt(EpicsSignalRO, "ALARM") alarm = Cpt(EpicsSignalRO, "ALARM", kind=Kind.omitted, auto_monitor=True)
set_open = Cpt(EpicsSignal, "OPEN-SET", kind=Kind.omitted) set_open = Cpt(EpicsSignal, "OPEN-SET", kind=Kind.omitted)
set_closed = Cpt(EpicsSignal, "CLOSE-SET", kind=Kind.omitted) set_closed = Cpt(EpicsSignal, "CLOSE-SET", kind=Kind.omitted)
@@ -66,7 +62,7 @@ class Shutter(PSIDeviceBase):
""" """
self._check_enabled() self._check_enabled()
self.set_open.put(1) self.set_open.put(1)
return SubscriptionStatus(self.is_open, _is_state(ShutterOpenState.OPEN)) return CompareStatus(self.is_open, ShutterOpenState.OPEN)
def close(self): def close(self):
"""Close the shutter. """Close the shutter.
@@ -75,7 +71,7 @@ class Shutter(PSIDeviceBase):
""" """
self._check_enabled() self._check_enabled()
self.set_closed.put(1) 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: def status(self) -> ShutterOpenState:
return ShutterOpenState(self.is_open.get()) return ShutterOpenState(self.is_open.get())