This commit is contained in:
2019-03-20 13:52:00 +01:00
parent 3084fe0510
commit 5db0f78aee
910 changed files with 191152 additions and 322 deletions

View File

@@ -0,0 +1,6 @@
import json
st = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
l = []
for i in range(200000):
l.append(st)
d = json.dumps(l)

View File

@@ -0,0 +1,13 @@
from mathutils import *
x = [0,1,3,7,12,54,32,11,4,2,1,1,0]
#x = [0,1,5,10,16,559,359,20,17,20,25,31,30]
y = range(len(x))
print fit_gaussian(x,y)
print fit_gaussian_offset(x,y)
print fit_gaussian_linear(x,y)
print fit_gaussian_exp_bkg(x,y)

View File

@@ -0,0 +1,38 @@
def gen():
num = 0.0
while num < 10:
yield num
num += 1
g = gen()
#r1 = vscan(inp,(sin, out),gen(),False, 0.5, title = "1D Generator")
def gen():
a,b = 0.0, 10.0
while abs(a) < 1.0:
while b < 20.0:
yield [a,b]
b=b+1.0
b=10.0
a=a+0.25
r2 = vscan((motor,inp),(sin, out),gen(),False, 0.1, title = "2D Generator", range = [-2.0,2.0, 10.0, 19.0])
#2D vector scan, plot to 2D Vector tab
vector = [ [1,1] , [1,2] , [1,3] , [1,4] ,
[1.5,2.5] ,
[2,1] , [2,2] , [2,3] , [2,4] ,
[2.5,2.5] ,
[3,1] , [3,2] , [3,3] , [3,3.5] , [3,3.6], [3,3.7], [3,4] ]
#r2 = vscan((motor,inp),(sin, out),vector,False, 0.1, title = "2D Vector", range = [0,4,0,5])

View File

@@ -0,0 +1,57 @@
###################################################################################################
# Demonstrate use of Vector Scan: one or multiple positioners set with a list or generator.
###################################################################################################
#1D vector scan, positions in a list
vector = [ 1, 3, 5, 10, 25, 40, 45, 47, 49, 20, 2]
#r1 = vscan(inp,(out,sin),vector,False, 0.5, title = "1D Vector")
#1D vector scan, positions given by a generator
def gen():
num = 0.0
while num < 10:
yield num
num += 1
#v2 = vscan(ao1,(ai1,ai2),gen(),False, 0.5, title = "1D Generator")
vector = [ [1,1] , [1,2] , [1,3] , [1,4] ,
[1.5,2.5] ,
[2,1] , [2,2] , [2,3] , [2,4] ,
[2.5,2.5] ,
[3,1] , [3,2] , [3,3] , [3,4] , [2.1, 2.1] ]
r3 = vscan((m1,m2),(wf1, ai1,ai2),vector,False, 0.1, title = "2D Vector")
#2D vector scan, positions given by a generator
def gen():
a= 0
while abs(a) < len(vector):
yield vector[a]
a=a+1
#r2 = vscan((m1,m2),(ai1,ai2),gen(),False, 0.1, title = "2D Generator", range = [0.0,5.0, 0.0, 5.0])
def spiral_gen(radius, step, resolution=.1, angle=0.0, origin=[0.0, 0.0]):
d = 0.0
while d * math.hypot(math.cos(angle), math.sin(angle)) < radius:
cord=[]
cord.append(origin[0] + d * math.cos(angle))
cord.append(origin[1] + d * math.sin(angle))
yield(cord)
d+=step
angle+=resolution
spiral = spiral_gen(10, 0.1)
#for i in spiral_gen(10, 1, 0.1, 0.0, 0.0):
# print i
#r2 = vscan((m1,m2),(wf1, ai1,ai2),spiral,False, 0.1, title = "2D Generator", range = [-10.0,10.0, -10.0, 10.0])

View File

@@ -0,0 +1,39 @@
"""
class MyInterlock1 (Interlock):
def __init__(self):
Interlock.__init__(self, (motor, motor2))
def check(self, (m, m2)):
if m2>m:
return False
return True
"""
class MyInterlock1 (Interlock):
def __init__(self):
Interlock.__init__(self, (table,))
def check(self, (t,)):
m,m2 = t
if m2>m:
return False
return True
i1 = MyInterlock1()
set_exec_pars(then = "i1.close()")
show_panel(table)
table.move([0.0, 0.0], 1.0)
table.move([1.0, 1.0], 2.0)

View File

@@ -1,21 +1,3 @@
index=0
def calc():
global index
index += 1
ret= tscan(sin, 10, 0.1, tag="scan " + str(index))
#ret= tscan(sin, 10, 0.1)
v = max(ret.getReadable(0))
return float(v)
class PseudoDev(Readable):
def read(self):
return calc()
d= PseudoDev()
ret= lscan(inp, (d), 0, 40, 5, 0.2, tag="output")
#ret= lscan(inp, (d), 0, 40, 5, 0.2)
run("test/test1")
run("test/test1")
run("test/test1")

View File

@@ -1,17 +1,14 @@
from PID import PID
PID = get_context().getClassByName("PID")
pid=PID(1,1,1);
pid=PID(0.1,0,0)
pid.SetPoint =20.0
#pid.setOutputLimits(-100, 100)
while True:
sensor = sin.read()
target = 30.0
sensor = out.read()
#set some sort of target value
output=pid.getOutput(sensor,target);
print output
pid.update(sensor)
print pid.output
#do something with the output
inp.write(output)
inp.write(pid.output)
time.sleep(1.0)

18
script/test/TestPIDOld.py Normal file
View File

@@ -0,0 +1,18 @@
#Qhttps://github.com/tekdemo/MiniPID-Java
PID = get_context().getClassByName("MiniPID")
target = 41.0
pid=PID(0.2,0,0)
pid.setSetpoint(target)
pid.setOutputLimits(-100, 100)
while True:
sensor = out.read()
#set some sort of target value
output=pid.getOutput(sensor)
print output
#do something with the output
inp.write(output)
time.sleep(1.0)

View File

@@ -1,14 +1,14 @@
print args
print get_exec_pars().source
if get_exec_pars().source == CommandSource.ui:
msg = None
start = 0
end = 10.0
steps = 10
else:
msg = args[0]
start = float(args[1])
end = float(args[2])
steps = int(args[3])
msg = None
start = float(args[0])
end = float(args[1])
steps = int(args[2])
print msg

View File

@@ -1,2 +1,7 @@
lscan(inp, sin, 0, 10, 0.1)
set_exec_pars(then="lscan(inp, sin, 0, 10, 0.2)")
set_exec_pars(then="run('test/test2',[1,3,4])")
lscan(inp, sin, 0, 10, 1.0, latency = 0.1)
1/0
print 1+2
#set_exec_pars(then="lscan(inp, arr, 0, 10, 0.2)")

View File

@@ -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")

View File

@@ -3,3 +3,4 @@ set_exec_pars(group = "g1")
a= lscan(inp, (sin,out,arr), 0, 40, 20, 0.1, group = "g2")
#set_exec_pars(name = "test2", open = False)
a= lscan(inp, (sin,out,arr), 0, 40, 20, 0.1)
set_return('OK')

View File

@@ -4,7 +4,12 @@ Line Scan
#import ch.psi.pshell.data.LayoutSF as LayoutSF
#LayoutSF.setExperimentArguments([sin, out])
#run("test/test2")
#et_exec_pars(name="new", open=True)
run("test/testb")
set_exec_pars(name="out", open=False)
print get_exec_pars().path
def before_pass(pass_num):
@@ -12,33 +17,13 @@ def before_pass(pass_num):
def after_pass(pass_num):
print "Finished pass: " , pass_num
set_exec_pars(layout="sf")
a= lscan(inp, (sin,out,arr), 0, 40, 10, 0.2, passes = 2, before_pass = before_pass, after_pass=after_pass, title = "Test")
ret= tscan((sin, create_averager(sin,3,0.1)), 10, 0.1, passes = 2, before_pass = before_pass, after_pass=after_pass)
ret= mscan([],sin, 10, -1, passes = 2, before_pass = before_pass, after_pass=after_pass)
p = get_exec_pars()
print p.getPath()
print p.getScanPath()
path = get_exec_pars().group
#save_dataset(path + "data", a.getReadable(0) )
#set_attribute(path + "data", "Temp", 39.0)
set_attribute(path, "AttrString", "Value")
set_attribute(path, "AttrInteger", 1)
set_attribute(path, "AttrDouble", 2.0)
set_attribute(path, "AttrBoolean", True)
set_attribute(path, "AttrArr", [1,2,3])
set_attribute(path + "sin", "Temp", 39.0)
#set_exec_pars(layout="sf")
ret= lscan(inp, (sin,out), 0, 40, 10, 0.2, passes = 1, before_pass = before_pass, after_pass=after_pass,title = "Test")
#set_return([1.0, 3, [1,2,3,4]])
#set_return("T\"es\"t")
#set_return([3.0,2])
set_return(ret)

View File

@@ -13,5 +13,5 @@ def BeforeReadout():
caput("TESTIOC:TESTBO:MyBO","Off")
a= lscan((m1,inp), (sin,out,arr), (0,0), (4,40), 20, 0.1, before_read=BeforeReadout)
a= lscan((inp), (sin,out,arr), 0, 4, 20, 0.1, before_read=BeforeReadout)
set_exec_pars(then="print 'OK'")

View File

@@ -1,17 +1,26 @@
from startup import *
#inject()
#globals().update(get_context().scriptManager.injections)
set_exec_pars(name="in")
#tscan(sin, 10, 0.1)
#tscan(sin, 10, 0.1, name="yyy", layout = "SF")
tscan(sin, 10, 0.1, name="yyy", layout = "SF")
tscan(sin, 10, 0.1,open=False)
#tscan(sin, 10, 0.1)
print "LOADED"
#def inject():
# globals().update(get_context().scriptManager.injections)
"""
def test():
#globals().update(get_context().scriptManager.injections)
##dev = None
#inject()
stop()
inject()
print 2* dev.read()
print 2* dev.read()
"""