aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfgang Draxinger <Wolfgang.Draxinger@draxit.de>2011-12-05 17:59:04 +0100
committerWolfgang Draxinger <Wolfgang.Draxinger@draxit.de>2011-12-05 17:59:04 +0100
commit1767c392685afa763fd9221f25e73ee76948bd35 (patch)
tree55cea1a6c3a1bbde6945b4b3317bfe20543d2dbd
parent68d1ddf0e3e781d4fe2f00317b06f3b501d2ad69 (diff)
downloadPyMotionControl-1767c392685afa763fd9221f25e73ee76948bd35.tar.gz
PyMotionControl-1767c392685afa763fd9221f25e73ee76948bd35.tar.bz2
scratchpad.py
-rw-r--r--scratchpad.py31
1 files changed, 23 insertions, 8 deletions
diff --git a/scratchpad.py b/scratchpad.py
index e5aac7b..cf2db27 100644
--- a/scratchpad.py
+++ b/scratchpad.py
@@ -69,19 +69,34 @@ class ActionExecuter(threading.Thread)
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 __del__(self):
+ def abort(self):
+ self.active = False
+ self.worker_thread.join()
- 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