Startup
This commit is contained in:
@@ -10,100 +10,4 @@ bscan (st1, 10)
|
||||
|
||||
|
||||
r1 = rscan(inp,[sin,inp] , [[0,5,5], [10,15,20], [20,25,5]] , 0.01, false, passes = 1)
|
||||
|
||||
|
||||
lscan(inp, [sin,], 0, 40, 20, 0.01)
|
||||
|
||||
|
||||
|
||||
|
||||
load("nashorn:mozilla_compat.js")
|
||||
importClass(java.util.concurrent.FutureTask)
|
||||
|
||||
|
||||
print ("a")
|
||||
|
||||
function _getCallable(func, args){
|
||||
var callable = new java.util.concurrent.Callable() {
|
||||
call: function() {
|
||||
print ("HAHA")
|
||||
//print (func)
|
||||
print (args)
|
||||
return func(args)
|
||||
}
|
||||
}
|
||||
return callable
|
||||
}
|
||||
|
||||
|
||||
function fork(){
|
||||
print ("FORK")
|
||||
print (arguments.length)
|
||||
print (typeof arguments[0])
|
||||
var callables = []
|
||||
for(i =0; i<arguments.length; i++){
|
||||
var m = arguments[i]
|
||||
print (m)
|
||||
if (get_rank(m)>0){
|
||||
print("X")
|
||||
print (m.length)
|
||||
//print (m[0])
|
||||
print (m[1])
|
||||
callables.push(_getCallable(m[0], m[1]))
|
||||
}
|
||||
else
|
||||
callables.push(_getCallable(m))
|
||||
|
||||
}
|
||||
return Threading.fork(callables)
|
||||
}
|
||||
|
||||
|
||||
function join(futures){
|
||||
try{
|
||||
return Threading.join(futures)
|
||||
} catch(err){
|
||||
throw err.getCause()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function parallelize() {
|
||||
futures = fork.apply(this, arguments)
|
||||
return join(futures)
|
||||
}
|
||||
|
||||
function task1() {
|
||||
print("On 1")
|
||||
motor.moveRel(1.0)
|
||||
return motor.getPosition()
|
||||
}
|
||||
function task2() {
|
||||
print("On 2")
|
||||
motor2.moveRel(1.0)
|
||||
return motor2.getPosition()
|
||||
}
|
||||
|
||||
function task3() {
|
||||
print("On 3")
|
||||
return sin.read()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function moveRelative(args){
|
||||
motor = args[0]
|
||||
step = args[1]
|
||||
print ("Moving " + motor.getName() + " step = " + step)
|
||||
motor.moveRel(step)
|
||||
return motor.getPosition()
|
||||
}
|
||||
|
||||
ret = parallelize([moveRelative,[motor,-2]], [moveRelative,[motor2,-2]])
|
||||
//ret = fork([moveRelative,[motor,-2]], [moveRelative,[motor2,-2]])
|
||||
//ret = parallelize(task1,task2)
|
||||
//ret = fork(task1,task2)
|
||||
//ret = join(ret)
|
||||
print (ret)
|
||||
|
||||
set_return("OK")
|
||||
Reference in New Issue
Block a user