Skip to content

Commit

Permalink
Merge pull request #730 from lnls-sirius/fix-bugs
Browse files Browse the repository at this point in the history
Fix bugs
  • Loading branch information
anacso17 authored Aug 17, 2021
2 parents 74c1bba + be5e860 commit 6c44474
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 29 deletions.
56 changes: 29 additions & 27 deletions siriuspy/siriuspy/cycle/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,11 @@ def check_pwrsupplies(self, ppty, psnames, timeout=TIMEOUT_CHECK):

self._update_log('Checking power supplies '+ppty+'...')
self._checks_result = {psn: False for psn in psnames}
msg = 'Successfully checked '+ppty+' preparation for {}/' + \
str(len(psnames))
time = _time.time()
while _time.time() - time < timeout:
for idx, psname in enumerate(psnames):
for psname in psnames:
if self._checks_result[psname]:
continue
cycler = self._get_cycler(psname)
Expand All @@ -440,15 +442,14 @@ def check_pwrsupplies(self, ppty, psnames, timeout=TIMEOUT_CHECK):
if ret:
self._checks_result[psname] = True
checked = sum(self._checks_result.values())
if checked % 5 == 0 or idx == len(psnames)-1:
self._update_log(
'Successfully checked '+ppty+' preparation for ' +
'{0}/{1}'.format(str(checked), str(len(psnames))))
if not checked % 5:
self._update_log(msg.format(str(checked)))
if _time.time() - time > timeout:
break
if all(self._checks_result.values()):
break
_time.sleep(TIMEOUT_SLEEP)
self._update_log(msg.format(str(checked)))

status = True
for psname, sts in self._checks_result.items():
Expand Down Expand Up @@ -637,18 +638,16 @@ def check_pwrsupplies_finalsts(self, psnames):
self._update_log('Checking power supplies final state...')
self._checks_final_result = dict()
sucess_cnt = 0
msg = 'Successfully checked final state for {0}/{1}'
for idx, psname in enumerate(psnames):
msg = 'Successfully checked final state for {}/'+str(len(psnames))
for psname in psnames:
cycler = self._get_cycler(psname)
status = cycler.check_final_state(self.mode)
if status == _Const.CycleEndStatus.Ok:
sucess_cnt += 1
if sucess_cnt % 5 == 0 or idx == len(psnames)-1:
self._update_log(
msg.format(str(sucess_cnt), str(len(psnames))))
if sucess_cnt % 5 == 0:
self._update_log(msg.format(str(sucess_cnt)))
self._checks_final_result[psname] = status
if sucess_cnt != len(psnames):
self._update_log(msg.format(str(sucess_cnt), str(len(psnames))))
self._update_log(msg.format(str(sucess_cnt)))

all_ok = True
for psname, has_prob in self._checks_final_result.items():
Expand Down Expand Up @@ -692,24 +691,25 @@ def check_pwrsupplies_sofbmode(self, psnames, timeout=TIMEOUT_CHECK):

self._update_log('Checking power supplies SOFBMode...')
self._checks_result = {psn: False for psn in psnames}
msg = 'Successfully checked SOFBMode preparation for {}/' + \
str(len(psnames))
time = _time.time()
while _time.time() - time < timeout:
for idx, psname in enumerate(psnames):
for psname in psnames:
if self._checks_result[psname]:
continue
cycler = self._get_cycler(psname)
if cycler.check_sofbmode('off', 0.05):
self._checks_result[psname] = True
checked = sum(self._checks_result.values())
if checked % 5 == 0 or idx == len(psnames)-1:
self._update_log(
'Successfully checked SOFBMode preparation for ' +
'{0}/{1}'.format(str(checked), str(len(psnames))))
if not checked % 5:
self._update_log(msg.format(str(checked)))
if _time.time() - time > timeout:
break
if all(self._checks_result.values()):
break
_time.sleep(TIMEOUT_SLEEP)
self._update_log(msg.format(str(checked)))

status = True
for psname, sts in self._checks_result.items():
Expand Down Expand Up @@ -744,24 +744,25 @@ def check_pwrsupplies_slowref(self, psnames, timeout=TIMEOUT_CHECK):

self._update_log('Checking power supplies opmode...')
self._checks_result = {psn: False for psn in psnames}
msg = 'Successfully checked opmode preparation for {}/' + \
str(len(psnames))
time = _time.time()
while _time.time() - time < timeout:
for idx, psname in enumerate(psnames):
for psname in psnames:
if self._checks_result[psname]:
continue
cycler = self._get_cycler(psname)
if cycler.check_opmode_slowref(0.05):
self._checks_result[psname] = True
checked = sum(self._checks_result.values())
if checked % 5 == 0 or idx == len(psnames)-1:
self._update_log(
'Successfully checked opmode preparation for ' +
'{0}/{1}'.format(str(checked), str(len(psnames))))
if not checked % 5:
self._update_log(msg.format(str(checked)))
if _time.time() - time > timeout:
break
if all(self._checks_result.values()):
break
_time.sleep(TIMEOUT_SLEEP)
self._update_log(msg.format(str(checked)))

status = True
for psname, sts in self._checks_result.items():
Expand All @@ -786,24 +787,25 @@ def check_pwrsupplies_current_zero(self, psnames, timeout=TIMEOUT_CHECK):
"""Check power supplies current."""
self._update_log('Checking power supplies current...')
self._checks_result = {psn: False for psn in psnames}
msg = 'Successfully checked current preparation for {}/' + \
str(len(psnames))
time = _time.time()
while _time.time() - time < timeout:
for idx, psname in enumerate(psnames):
for psname in psnames:
if self._checks_result[psname]:
continue
cycler = self._get_cycler(psname)
if cycler.check_current_zero(0.05):
self._checks_result[psname] = True
checked = sum(self._checks_result.values())
if checked % 5 == 0 or idx == len(psnames)-1:
self._update_log(
'Successfully checked current preparation for ' +
'{0}/{1}'.format(str(checked), str(len(psnames))))
if not checked % 5:
self._update_log(msg.format(str(checked)))
if _time.time() - time > timeout:
break
if all(self._checks_result.values()):
break
_time.sleep(TIMEOUT_SLEEP)
self._update_log(msg.format(str(checked)))

status = True
for psname, sts in self._checks_result.items():
Expand Down
4 changes: 2 additions & 2 deletions siriuspy/siriuspy/devices/injsys.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def on_values(self):
vals = dict()
for dev, ppties in self._on_values.items():
for ppty, val in ppties.items():
vals[dev.devname+':'+ppty] = val
vals[dev.pv_object(ppty).pvname] = val
return vals


Expand Down Expand Up @@ -441,7 +441,7 @@ def __init__(self):
devices = (self.evg, self.injboevt)

self._on_values = {
self.injboevt: {'InjBOMode-Sts': Event.MODES.index('Continuous')}}
self.injboevt: {'Mode-Sts': Event.MODES.index('Continuous')}}

# call base class constructor
super().__init__('', devices)
Expand Down

0 comments on commit 6c44474

Please sign in to comment.