Source code for csaxs_bec.devices.epics.fast_shutter

"""
Shutter device for the cSAXS beamline with 2 PVs. One is connected to a
signal can be set to control the shutter signal, and the other is a readback signal
that can be monitored to check the shutter status as it may be controlled directly by
the delay generator."""

from ophyd import Component as Cpt
from ophyd import Device, EpicsSignal, EpicsSignalRO, Kind


[docs] class cSAXSFastEpicsShutter(Device): """ Fast EPICS shutter with automatic PV selection based on host subnet. IOC prefix is 'X12SA-ES1-TTL:' """ USER_ACCESS = ["fshopen", "fshclose", "fshstatus", "fshinfo", "fshstatus_readback", "help"] SUB_VALUE = "value" _default_sub = SUB_VALUE # PVs shutter = Cpt(EpicsSignal, "OUT_01", kind=Kind.normal, auto_monitor=True) shutter_readback = Cpt(EpicsSignalRO, "INP_01", kind=Kind.normal, auto_monitor=True) # ----------------------------------------------------- # User-facing shutter control functions # ----------------------------------------------------- # pylint: disable=protetced-access
[docs] def fshopen(self) -> None: """Open the fast shutter.""" self.shutter.set(1).wait(timeout=self.shutter._timeout) # 2s default for ES
# pylint: disable=protetced-access
[docs] def fshclose(self) -> None: """Close the fast shutter.""" self.shutter.set(0).wait(timeout=self.shutter._timeout) # 2s default for ES
[docs] def fshstatus(self) -> int: """Return the fast shutter control status (0=closed, 1=open).""" return self.shutter.get() # Ensure we have the latest value from EPICS
[docs] def fshstatus_readback(self) -> int: """Return the fast shutter status (0=closed, 1=open).""" return self.shutter_readback.get() # Ensure we have the latest value from EPICS
[docs] def fshinfo(self) -> None: """Print information about which EPICS PV channel is being used.""" pvname = self.shutter.pvname shutter_readback_pvname = self.shutter_readback.pvname print( f"Fast shutter connected to EPICS channel: {pvname} with shutter readback: {shutter_readback_pvname}" )
[docs] def stop(self, *, success: bool = False) -> None: """Stop the shutter device. Make sure to close it.""" self.shutter.put(0) super().stop(success=success)
[docs] def help(self): """Display available user methods.""" print("Available methods:") for method in self.USER_ACCESS: print(f" - {method}")
if __name__ == "__main__": fsh = cSAXSFastEpicsShutter(name="fsh", prefix="X12SA-ES1-TTL:")