Skip to content

Commit

Permalink
fixes #254
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Nov 22, 2019
1 parent cf8162e commit 8f1484b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions apstools/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
.. autosummary::
~ApsCycleComputed
~ApsMachineParametersDevice
~ApsPssShutter
~ApsPssShutterWithStatus
Expand Down Expand Up @@ -129,6 +130,7 @@
from ophyd import Signal, EpicsMotor, EpicsSignal, EpicsSignalRO
from ophyd.mca import EpicsMCARecord
from ophyd.scaler import EpicsScaler, ScalerCH
from ophyd.sim import SignalRO

from ophyd.areadetector.filestore_mixins import FileStoreBase
from ophyd.areadetector.filestore_mixins import FileStorePluginBase
Expand Down Expand Up @@ -174,6 +176,21 @@ def use_EPICS_scaler_channels(scaler):
scaler.channels.configuration_attrs = configuration_attrs


class ApsCycleComputed(SignalRO):
"""
compute the APS cycle name based on the calendar and the usual practice
Absent any facility PV that provides the name of the current operating
cycle, this can be approximated by python computation (as long as the
present scheduling pattern is maintained)
"""

def get(self):
dt = datetime.now()
aps_cycle = f"{dt.year}-{int((dt.month-0.1)/4) + 1}"
return aps_cycle


class ApsOperatorMessagesDevice(Device):
"""general messages from the APS main control room"""
operators = Component(EpicsSignalRO, "OPS:message1", string=True)
Expand Down Expand Up @@ -218,6 +235,7 @@ class ApsMachineParametersDevice(Device):
"""
current = Component(EpicsSignalRO, "S:SRcurrentAI")
lifetime = Component(EpicsSignalRO, "S:SRlifeTimeHrsCC")
aps_cycle = Component(ApsCycleComputed)
machine_status = Component(EpicsSignalRO, "S:DesiredMode", string=True)
# In [3]: APS.machine_status.enum_strs
# Out[3]:
Expand Down

0 comments on commit 8f1484b

Please sign in to comment.