Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update APS cycle name after end of current cycle #418

Merged
merged 2 commits into from
Sep 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = "1980" # 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(sep=" ") >= 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