Skip to content

Commit fced530

Browse files
authored
Merge pull request #261 from BCDA-APS/254-apscycle
add computed APS cycle signal (RO)
2 parents cf8162e + 687d5c7 commit fced530

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

apstools/devices.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
.. autosummary::
88
9+
~ApsCycleComputedRO
910
~ApsMachineParametersDevice
1011
~ApsPssShutter
1112
~ApsPssShutterWithStatus
@@ -129,6 +130,7 @@
129130
from ophyd import Signal, EpicsMotor, EpicsSignal, EpicsSignalRO
130131
from ophyd.mca import EpicsMCARecord
131132
from ophyd.scaler import EpicsScaler, ScalerCH
133+
from ophyd.sim import SignalRO
132134

133135
from ophyd.areadetector.filestore_mixins import FileStoreBase
134136
from ophyd.areadetector.filestore_mixins import FileStorePluginBase
@@ -174,6 +176,23 @@ def use_EPICS_scaler_channels(scaler):
174176
scaler.channels.configuration_attrs = configuration_attrs
175177

176178

179+
class ApsCycleComputedRO(SignalRO):
180+
"""
181+
compute the APS cycle name based on the calendar and the usual practice
182+
183+
Absent any facility PV that provides the name of the current operating
184+
cycle, this can be approximated by python computation (as long as the
185+
present scheduling pattern is maintained)
186+
187+
This signal is read-only.
188+
"""
189+
190+
def get(self):
191+
dt = datetime.now()
192+
aps_cycle = f"{dt.year}-{int((dt.month-0.1)/4) + 1}"
193+
return aps_cycle
194+
195+
177196
class ApsOperatorMessagesDevice(Device):
178197
"""general messages from the APS main control room"""
179198
operators = Component(EpicsSignalRO, "OPS:message1", string=True)
@@ -218,6 +237,7 @@ class ApsMachineParametersDevice(Device):
218237
"""
219238
current = Component(EpicsSignalRO, "S:SRcurrentAI")
220239
lifetime = Component(EpicsSignalRO, "S:SRlifeTimeHrsCC")
240+
aps_cycle = Component(ApsCycleComputedRO)
221241
machine_status = Component(EpicsSignalRO, "S:DesiredMode", string=True)
222242
# In [3]: APS.machine_status.enum_strs
223243
# Out[3]:

0 commit comments

Comments
 (0)