Skip to content

Commit

Permalink
fixes #417
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Sep 4, 2020
1 parent fb9890f commit 633b87c
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions apstools/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,16 @@ class ApsCycleDM(SynSignalRO):
This signal is read-only.
"""

_time_last_updated = -1
_update_period_s = 60*60*24 # update from dm no more than daily
_cycle_ends = "0" # force a read from DM on first get()
_cycle_name = "unknown"

def get(self):
from .beamtime.apsbss import getCurrentCycle
if time.time() > self._time_last_updated + self._update_period_s:
# only update from data management once per day
self._cycle_name = getCurrentCycle()
self._time_last_updated = time.time()
# TODO: could get the end time for current cycle and use that instead
if datetime.now().isoformat() >= self._cycle_ends:
from .beamtime.apsbss import api_bss
# only update from data management after the end of the run
cycle = api_bss.getCurrentRun()
self._cycle_name = cycle["name"]
self._cycle_ends = cycle["endTime"]
return self._cycle_name


Expand Down

0 comments on commit 633b87c

Please sign in to comment.