diff options
author | Wolfgang Draxinger (root@gar-ex-erdastep) <Wolfgang.Draxinger@physik.uni-muenchen.de> | 2011-12-05 19:00:55 +0100 |
---|---|---|
committer | Wolfgang Draxinger (root@gar-ex-erdastep) <Wolfgang.Draxinger@physik.uni-muenchen.de> | 2011-12-05 19:00:55 +0100 |
commit | fe91c5a842da5baad29d422c5ff57a6169e3ed83 (patch) | |
tree | aebded002562e5488a73bdbb840dd8be4b83e45e /scratchpad.py | |
parent | 181bddd60f7b32b913ddc81a912f718369cb9ac5 (diff) | |
parent | 72400ed382301accce49612ebcad6ec32dbfe394 (diff) | |
download | PyMotionControl-fe91c5a842da5baad29d422c5ff57a6169e3ed83.tar.gz PyMotionControl-fe91c5a842da5baad29d422c5ff57a6169e3ed83.tar.bz2 |
Merge branch 'master' of github.com:datenwolf/PyMotionControl
Diffstat (limited to 'scratchpad.py')
-rw-r--r-- | scratchpad.py | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/scratchpad.py b/scratchpad.py index 97e0f91..931a2a4 100644 --- a/scratchpad.py +++ b/scratchpad.py @@ -71,20 +71,37 @@ class ActionExecuter(object): class MotionControl(object): def __init__(self, name): + import weakref, threading self.name = name + self.on_cycle_started = Signal() + self.on_cycle_finished = Signal() + self.on_cycle_aborted = Signal() + + def __del__(self): + + def start_cycle(self): self.active = True - self.worker_thread = threading.Thread(target = self.workerLoop, name = "MotionControl.worker_thread") - self.worker_thread.setDaemon(True) + self.worker_thread = threading.Thread(target = MotionControl.cycle_threadfunction, name = "MotionControl.worker_thread"), args=(weakref.proxy(self),)) + self.worker_thread.daemon =True self.worker_thread.start() + self.on_cycle_started.send() + + def abort(self): + self.active = False + self.worker_thread.join() def __del__(self): self.active = False - def workerLoop(self): - import time - while self.active: - print self.name - time.sleep(1) + def cycle_threadfunction(ref): + try: + import time + while ref.active: + print self.name + time.sleep(1) + ref.on_cycle_finished.send() + except: + ref.on_cycle_aborted.send() import threading import rpyc |