Skip to content

Commit

Permalink
Merge branch 'PR-bbb-from-bottom-up' of ssh://github.com/lnls-sirius/…
Browse files Browse the repository at this point in the history
…dev-packages into PR-bbb-from-bottom-up
  • Loading branch information
xresende committed May 11, 2018
2 parents 32d10b7 + 239d4de commit 7347afe
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
38 changes: 19 additions & 19 deletions siriuspy/siriuspy/pwrsupply/beaglebone.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
_DeviceInfo = _namedtuple('DeviceInfo', 'name, id')


class Watcher(_threading.Thread):
class _Watcher(_threading.Thread):
"""Watcher PS on given operation mode."""

INSTANCE_COUNT = 0
Expand All @@ -47,18 +47,18 @@ def __init__(self, controller, dev_info, op_mode):
self.controller = controller
self.dev_info = dev_info
self.op_mode = op_mode
self.state = Watcher.WAIT_OPMODE
self.state = _Watcher.WAIT_OPMODE
self.exit = False

def run(self):
Watcher.INSTANCE_COUNT += 1
_Watcher.INSTANCE_COUNT += 1
if self.op_mode == _PSConst.OpMode.Cycle:
self._watch_cycle()
elif self.op_mode == _PSConst.OpMode.MigWfm:
self._watch_mig()
elif self.op_mode == _PSConst.OpMode.RmpWfm:
self._watch_rmp()
Watcher.INSTANCE_COUNT -= 1
_Watcher.INSTANCE_COUNT -= 1

def stop(self):
"""Stop thread."""
Expand All @@ -68,58 +68,58 @@ def _watch_cycle(self):
while True:
if self.exit:
break
elif self.state == Watcher.WAIT_OPMODE:
elif self.state == _Watcher.WAIT_OPMODE:
if self._achieved_op_mode() and self._sync_started():
self.state = Watcher.WAIT_TRIGGER
elif self.state == Watcher.WAIT_TRIGGER:
self.state = _Watcher.WAIT_TRIGGER
elif self.state == _Watcher.WAIT_TRIGGER:
if self._changed_op_mode():
break
elif self._sync_stopped():
if self._cycle_started() or self._sync_pulsed():
self.state = Watcher.WAIT_CYCLE
self.state = _Watcher.WAIT_CYCLE
else:
break
elif self.state == Watcher.WAIT_CYCLE:
elif self.state == _Watcher.WAIT_CYCLE:
if self._changed_op_mode():
break
elif self._cycle_stopped():
# self._set_current()
self._set_slow_ref()
break
_time.sleep(Watcher.WAIT)
_time.sleep(_Watcher.WAIT)

def _watch_mig(self):
while True:
if self.exit:
break
elif self.state == Watcher.WAIT_OPMODE:
elif self.state == _Watcher.WAIT_OPMODE:
if self._achieved_op_mode() and self._sync_started():
self.state = Watcher.WAIT_MIG
elif self.state == Watcher.WAIT_MIG:
self.state = _Watcher.WAIT_MIG
elif self.state == _Watcher.WAIT_MIG:
if self._changed_op_mode():
break
elif self._sync_stopped():
if self._sync_pulsed():
self._set_current()
self._set_slow_ref()
break
_time.sleep(Watcher.WAIT)
_time.sleep(_Watcher.WAIT)

def _watch_rmp(self):
while True:
if self.exit:
break
elif self.state == Watcher.WAIT_OPMODE:
elif self.state == _Watcher.WAIT_OPMODE:
if self._achieved_op_mode() and self._sync_started():
self.state = Watcher.WAIT_RMP
elif self.state == Watcher.WAIT_RMP:
self.state = _Watcher.WAIT_RMP
elif self.state == _Watcher.WAIT_RMP:
if self._changed_op_mode():
break
elif self._sync_stopped():
if self._sync_pulsed():
self._set_current()
break
_time.sleep(Watcher.WAIT)
_time.sleep(_Watcher.WAIT)

def _current_op_mode(self):
return self.controller.read(self.dev_info.name, 'OpMode-Sts')
Expand Down Expand Up @@ -478,7 +478,7 @@ def _set_wfmdata_sp(self, devices_info, setpoint):
def _set_watchers(self, op_mode, devices_info):
self._watchers.clear()
for dev_info in devices_info:
t = Watcher(self, dev_info, op_mode)
t = _Watcher(self, dev_info, op_mode)
try:
if self._watchers[dev_info.id].is_alive():
self._watchers[dev_info.id].stop()
Expand Down
1 change: 1 addition & 0 deletions siriuspy/tests/pwrsupply/test_beaglebone.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class TestBeagleBone(unittest.TestCase):

public_interface = (
'psnames',
'devices_database',
'pru_controller',
'e2s_controller',
'read',
Expand Down

0 comments on commit 7347afe

Please sign in to comment.