Skip to content

Commit 8f1484b

Browse files
committed
fixes #254
1 parent cf8162e commit 8f1484b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

apstools/devices.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
.. autosummary::
88
9+
~ApsCycleComputed
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,21 @@ def use_EPICS_scaler_channels(scaler):
174176
scaler.channels.configuration_attrs = configuration_attrs
175177

176178

179+
class ApsCycleComputed(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+
188+
def get(self):
189+
dt = datetime.now()
190+
aps_cycle = f"{dt.year}-{int((dt.month-0.1)/4) + 1}"
191+
return aps_cycle
192+
193+
177194
class ApsOperatorMessagesDevice(Device):
178195
"""general messages from the APS main control room"""
179196
operators = Component(EpicsSignalRO, "OPS:message1", string=True)
@@ -218,6 +235,7 @@ class ApsMachineParametersDevice(Device):
218235
"""
219236
current = Component(EpicsSignalRO, "S:SRcurrentAI")
220237
lifetime = Component(EpicsSignalRO, "S:SRlifeTimeHrsCC")
238+
aps_cycle = Component(ApsCycleComputed)
221239
machine_status = Component(EpicsSignalRO, "S:DesiredMode", string=True)
222240
# In [3]: APS.machine_status.enum_strs
223241
# Out[3]:

0 commit comments

Comments
 (0)