This commit is contained in:
boccioli_m
2015-06-26 09:24:55 +02:00
parent 87f5cb833c
commit 382bb652d5
4 changed files with 380 additions and 360 deletions

View File

@@ -1,14 +1,23 @@
#Running scripts in parallel
run("Motor Test 3 100ms")
ret = parallelize((run,("Motor Test 3 100ms")), (run,("Motor Test 3 200ms")))
print ret
#Simple parallization
def task1():
return out.read()
return 1
def task2():
return inp.read()
return 2
def task3():
time.sleep(0.1)
return sin.read()
return 3
ret = parallelize(task1, task2, task3)
print ret
@@ -23,10 +32,10 @@ print ret
#Functions with parameters
def devRead(dev, msg):
print msg + " -> " + dev.getName()
return dev.read()
print msg
return "OK"
ret = parallelize((devRead,(out,"1")), (devRead,(inp,"2")), (devRead,(sin,"3")))
ret = parallelize((devRead,(1,"1")), (devRead,(2,"2")), (devRead,(3,"3")))
print ret
@@ -35,8 +44,7 @@ def taskExcept(msg):
raise Exception ("Error in parallel task " + msg)
ret = parallelize((taskExcept,("1")), (taskExcept,(inp,"2")) )
ret = parallelize((taskExcept,("1")), (taskExcept,("2")) )
print ret