This commit is contained in:
2018-04-17 12:05:48 +02:00
parent 14edc0e745
commit 58a1260003
428 changed files with 41350 additions and 477 deletions
+54
View File
@@ -0,0 +1,54 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
//// Using Parallelization API to execute tasks concurrently
///////////////////////////////////////////////////////////////////////////////////////////////////
//Simple parallization
function task1(){
m1.moveRel(1.0)
return m1.getPosition()
}
function task2(){
m2.moveRel(1.0)
return m1.getPosition()
}
function task3(){
return ai1.read()
}
ret = parallelize(task1, task2, task3)
print (ret
)
//Fork amd join
ret = fork(task1, task2, task3)
print (ai1.read()
)
ret = join(ret)
print (ret
)
//Functions with parameters
function moveRelative(motor, step){
motor.moveRel(step)
return motor.getPosition()
}
ret = parallelize([moveRelative,[m1,-2]], [moveRelative,[m2,-2]])
print (ret
)
//Exception in parallel task is thrown back to script
try{
parallelize([moveRelative,[ai1,1]], [moveRelative,[ai2,1]])
}catch (ex){
print ("Ok, caught exception:"
)
print(ex)
}