From e196daf9647e8ecb16927bfe702fa9d6137ddc99 Mon Sep 17 00:00:00 2001 From: eir17846 Date: Fri, 30 Jan 2026 15:11:40 +0000 Subject: [PATCH 1/6] add docstring, move name to last parameter, remove extra arbitrary parameters --- src/dodal/devices/synchrotron.py | 37 ++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/dodal/devices/synchrotron.py b/src/dodal/devices/synchrotron.py index 7d1fa52fb3..1ed8d0296f 100644 --- a/src/dodal/devices/synchrotron.py +++ b/src/dodal/devices/synchrotron.py @@ -36,13 +36,46 @@ class SynchrotronMode(StrictEnum): class Synchrotron(StandardReadable): + """A StandardReadable device that represents a synchrotron facility, providing access to + various synchrotron parameters and operational status. + + Parameters + ---------- + name : str, optional + The name of the device. Default is an empty string. + signal_prefix : str, optional + The prefix for signal PVs. Default is Prefix.SIGNAL. + status_prefix : str, optional + The prefix for status PVs. Default is Prefix.STATUS. + topup_prefix : str, optional + The prefix for top-up related PVs. Default is Prefix.TOP_UP. + + Attributes: + ---------- + current : EpicsSignalR + Read-only signal for the synchrotron beam current (float). + energy : EpicsSignalR + Read-only signal for the beam energy (float). + probe : SoftSignalRW + Configurable signal for the probe type (str). Default is "x-ray". + type : SoftSignalRW + Configurable signal for the synchrotron type (str). Default is "Synchrotron X-ray Source". + synchrotron_mode : EpicsSignalR + Read-only signal for the current synchrotron mode (SynchrotronMode). + machine_user_countdown : EpicsSignalR + Read-only signal for the machine user countdown timer (float). + top_up_start_countdown : EpicsSignalR + Read-only signal for the top-up start countdown timer (float). + top_up_end_countdown : EpicsSignalR + Read-only signal for the top-up end countdown timer (float). + """ + def __init__( self, - name: str = "", - *, signal_prefix=Prefix.SIGNAL, status_prefix=Prefix.STATUS, topup_prefix=Prefix.TOP_UP, + name: str = "", ): with self.add_children_as_readables(): self.current = epics_signal_r(float, signal_prefix + Suffix.SIGNAL) From 4d4f1ccdae4bcb858f368dcdf36f27b39d19d557 Mon Sep 17 00:00:00 2001 From: eir17846 Date: Fri, 30 Jan 2026 15:17:18 +0000 Subject: [PATCH 2/6] remove attributes from dosctring --- src/dodal/devices/synchrotron.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/dodal/devices/synchrotron.py b/src/dodal/devices/synchrotron.py index 1ed8d0296f..d158585e30 100644 --- a/src/dodal/devices/synchrotron.py +++ b/src/dodal/devices/synchrotron.py @@ -39,17 +39,6 @@ class Synchrotron(StandardReadable): """A StandardReadable device that represents a synchrotron facility, providing access to various synchrotron parameters and operational status. - Parameters - ---------- - name : str, optional - The name of the device. Default is an empty string. - signal_prefix : str, optional - The prefix for signal PVs. Default is Prefix.SIGNAL. - status_prefix : str, optional - The prefix for status PVs. Default is Prefix.STATUS. - topup_prefix : str, optional - The prefix for top-up related PVs. Default is Prefix.TOP_UP. - Attributes: ---------- current : EpicsSignalR From 7bc05a3e8ec62ef71d8da6a33672ef1a8ea278bb Mon Sep 17 00:00:00 2001 From: eir17846 Date: Fri, 6 Feb 2026 10:03:17 +0000 Subject: [PATCH 3/6] add type hints for all parameters --- src/dodal/devices/synchrotron.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dodal/devices/synchrotron.py b/src/dodal/devices/synchrotron.py index d158585e30..1d3c1a4206 100644 --- a/src/dodal/devices/synchrotron.py +++ b/src/dodal/devices/synchrotron.py @@ -61,9 +61,9 @@ class Synchrotron(StandardReadable): def __init__( self, - signal_prefix=Prefix.SIGNAL, - status_prefix=Prefix.STATUS, - topup_prefix=Prefix.TOP_UP, + signal_prefix: str = Prefix.SIGNAL, + status_prefix: str = Prefix.STATUS, + topup_prefix: str = Prefix.TOP_UP, name: str = "", ): with self.add_children_as_readables(): From 33761096e850c5a67772e81a65cfed67c9b61658 Mon Sep 17 00:00:00 2001 From: eir17846 Date: Tue, 10 Feb 2026 15:21:15 +0000 Subject: [PATCH 4/6] fix attributes docstring, add args --- src/dodal/devices/synchrotron.py | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/dodal/devices/synchrotron.py b/src/dodal/devices/synchrotron.py index 1d3c1a4206..de9a1c41dc 100644 --- a/src/dodal/devices/synchrotron.py +++ b/src/dodal/devices/synchrotron.py @@ -39,24 +39,21 @@ class Synchrotron(StandardReadable): """A StandardReadable device that represents a synchrotron facility, providing access to various synchrotron parameters and operational status. + Args: + signal_prefix (str, optional): Beamline part of PV. Defaults to Prefix.SIGNAL. + status_prefix (str, optional): Status part of PV. Defaults to Prefix.STATUS. + topup_prefix (str, optional): Top-up part of PV. Defaults to Prefix.TOP_UP. + name (str, optional): Name of the device. Defaults to an empty string. + Attributes: - ---------- - current : EpicsSignalR - Read-only signal for the synchrotron beam current (float). - energy : EpicsSignalR - Read-only signal for the beam energy (float). - probe : SoftSignalRW - Configurable signal for the probe type (str). Default is "x-ray". - type : SoftSignalRW - Configurable signal for the synchrotron type (str). Default is "Synchrotron X-ray Source". - synchrotron_mode : EpicsSignalR - Read-only signal for the current synchrotron mode (SynchrotronMode). - machine_user_countdown : EpicsSignalR - Read-only signal for the machine user countdown timer (float). - top_up_start_countdown : EpicsSignalR - Read-only signal for the top-up start countdown timer (float). - top_up_end_countdown : EpicsSignalR - Read-only signal for the top-up end countdown timer (float). + current (SignalR[float]): Read-only signal for the synchrotron beam current. + energy (SignalR[float]): Read-only signal for the beam energy. + probe (SignalR[str]): Read-only signal for the probe type. Defaults to ``"x-ray"``. + type (SignalR[str]): Read-only signal for the synchrotron type. Defaults to ``"Synchrotron X-ray Source"``. + synchrotron_mode (SignalR[SynchrotronMode]): Read-only signal for the current synchrotron operating mode. + machine_user_countdown (SignalR[float]): Read-only signal for the machine user countdown timer. + top_up_start_countdown (SignalR[float]): Read-only signal for the top-up start countdown timer. + top_up_end_countdown (SignalR[float]): Read-only signal for the top-up end countdown timer. """ def __init__( From 0e2b58b71f6553bce647313b74b3146c8a830af2 Mon Sep 17 00:00:00 2001 From: eir17846 Date: Thu, 12 Feb 2026 12:45:03 +0000 Subject: [PATCH 5/6] rewrite attribute docs. add more PVs from GDA beamlines code --- src/dodal/devices/synchrotron.py | 67 ++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 17 deletions(-) diff --git a/src/dodal/devices/synchrotron.py b/src/dodal/devices/synchrotron.py index de9a1c41dc..27c36e83fb 100644 --- a/src/dodal/devices/synchrotron.py +++ b/src/dodal/devices/synchrotron.py @@ -18,10 +18,13 @@ class Prefix(str, Enum): class Suffix(str, Enum): SIGNAL = "SIGNAL" MODE = "MODE" - USER_COUNTDOWN = "USERCOUNTDN" - BEAM_ENERGY = "BEAMENERGY" + USERCOUNTDOWN = "USERCOUNTDN" + BEAMENERGY = "BEAMENERGY" COUNTDOWN = "COUNTDOWN" - END_COUNTDOWN = "ENDCOUNTDN" + STACOUNTDN = "STACOUNTDN" + ENDCOUNTDOWN = "ENDCOUNTDN" + TOPUPSTATE = "TOPUPSTATE" + FILLPERIOD = "FILLPERIOD" class SynchrotronMode(StrictEnum): @@ -35,9 +38,17 @@ class SynchrotronMode(StrictEnum): UNKNOWN = "Unknown" +class TopUpState(StrictEnum): + OFF = "Off" + RUNNING = "Running" + STOPPING = "Stopping" + FAILED = "Failed" + NO_PROCESS = "No process" + + class Synchrotron(StandardReadable): - """A StandardReadable device that represents a synchrotron facility, providing access to - various synchrotron parameters and operational status. + """A StandardReadable device that represents a synchrotron facility, providing + access to various synchrotron parameters and operational status. Args: signal_prefix (str, optional): Beamline part of PV. Defaults to Prefix.SIGNAL. @@ -46,14 +57,34 @@ class Synchrotron(StandardReadable): name (str, optional): Name of the device. Defaults to an empty string. Attributes: - current (SignalR[float]): Read-only signal for the synchrotron beam current. - energy (SignalR[float]): Read-only signal for the beam energy. - probe (SignalR[str]): Read-only signal for the probe type. Defaults to ``"x-ray"``. - type (SignalR[str]): Read-only signal for the synchrotron type. Defaults to ``"Synchrotron X-ray Source"``. - synchrotron_mode (SignalR[SynchrotronMode]): Read-only signal for the current synchrotron operating mode. - machine_user_countdown (SignalR[float]): Read-only signal for the machine user countdown timer. - top_up_start_countdown (SignalR[float]): Read-only signal for the top-up start countdown timer. - top_up_end_countdown (SignalR[float]): Read-only signal for the top-up end countdown timer. + current (SignalR[float]): Read-only signal for the synchrotron ring current. + Standard optional field in NXsource component of nexus file. + energy (SignalR[float]): Read-only signal for the synchrotron ring energy. + Standard optional field in NXsource component of nexus file. + probe (SignalR[str]): Read-only signal for the probe type. Defaults to + ``"x-ray"``. Standard optional field in NXsource component of nexus file. + type (SignalR[str]): Read-only signal for the synchrotron type. Defaults to + ``"Synchrotron X-ray Source"``. Standard optional field in NXsource + component of nexus file. + synchrotron_mode (SignalR[SynchrotronMode]): current state of the synchrotron + ring. Standard optional field ``"mode"`` in NXsource component of nexus file. + machine_user_countdown (SignalR[float]): If current mode in user, counts down + the number of seconds until the end of the current period. + top_up_start_countdown (SignalR[float]): counter that runs to zero at the start + of TopUp and remains there until the fill is complete when it resets to time + before next TopUp fill. Used in data acquisition to avoid beam intensity + change during topup. + top_up_countdown (SignalR[float]): counter that runs to zero at the start + of TopUp fill and is reset immediately to the time to next TopUp fill once + TopUp starts. + top_up_end_countdown (SignalR[float]): counter that runs to zero at the end of + TopUp fill and resets immediately to an estimate of the time before the end + of the next TopUp fill. Used in data acquisition to avoid beam intensity + change during topup. + fill_period (signalR[float]): time between TopUp (in minutes).Used in data + acquisition to monitor synchrotron state. + top_up_state (signalR[TopUpState]): state of the TopUp process. Used in data + acquisition to confirm state. """ def __init__( @@ -65,7 +96,7 @@ def __init__( ): with self.add_children_as_readables(): self.current = epics_signal_r(float, signal_prefix + Suffix.SIGNAL) - self.energy = epics_signal_r(float, status_prefix + Suffix.BEAM_ENERGY) + self.energy = epics_signal_r(float, status_prefix + Suffix.BEAMENERGY) with self.add_children_as_readables(StandardReadableFormat.CONFIG_SIGNAL): self.probe, _ = soft_signal_r_and_setter(str, initial_value="x-ray") @@ -76,13 +107,15 @@ def __init__( SynchrotronMode, status_prefix + Suffix.MODE ) self.machine_user_countdown = epics_signal_r( - float, status_prefix + Suffix.USER_COUNTDOWN + float, status_prefix + Suffix.USERCOUNTDOWN ) self.top_up_start_countdown = epics_signal_r( float, topup_prefix + Suffix.COUNTDOWN ) + self.top_up_countdown = epics_signal_r(float, topup_prefix + Suffix.STACOUNTDN) self.top_up_end_countdown = epics_signal_r( - float, topup_prefix + Suffix.END_COUNTDOWN + float, topup_prefix + Suffix.ENDCOUNTDOWN ) - + self.fill_period = epics_signal_r(float, topup_prefix + Suffix.FILLPERIOD) + self.top_up_state = epics_signal_r(TopUpState, topup_prefix + Suffix.TOPUPSTATE) super().__init__(name=name) From 05e5ca2d38991acf7c0af07ef33f2527d84e1833 Mon Sep 17 00:00:00 2001 From: eir17846 Date: Thu, 12 Feb 2026 14:50:48 +0000 Subject: [PATCH 6/6] add topup_state attribute docstring --- src/dodal/devices/synchrotron.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dodal/devices/synchrotron.py b/src/dodal/devices/synchrotron.py index 27c36e83fb..22631e604b 100644 --- a/src/dodal/devices/synchrotron.py +++ b/src/dodal/devices/synchrotron.py @@ -83,8 +83,9 @@ class Synchrotron(StandardReadable): change during topup. fill_period (signalR[float]): time between TopUp (in minutes).Used in data acquisition to monitor synchrotron state. - top_up_state (signalR[TopUpState]): state of the TopUp process. Used in data - acquisition to confirm state. + top_up_state (signalR[TopUpState]): tracks whether TopUp is currently running or + not. If it is anything other than Running or Stopping TopUp isn't active so + will not disturb the beam. Used in data acquisition to confirm TopUp state. """ def __init__(