Closedown

This commit is contained in:
x03daop
2015-03-26 16:19:45 +01:00
parent 48af97c3cc
commit e6fcd60b61
18 changed files with 260 additions and 0 deletions

7
script/test/back.py Normal file
View File

@@ -0,0 +1,7 @@
import java.util.logging.Logger as Logger
logger = Logger.getLogger("back")
logger.info("Started")

6
script/test/calc.groovy Normal file
View File

@@ -0,0 +1,6 @@
def calc(a){
a*2
}

5
script/test/calc.js Normal file
View File

@@ -0,0 +1,5 @@
function calc(a) {
return a * 5;
}

3
script/test/calc.py Normal file
View File

@@ -0,0 +1,3 @@
def calc(a):
return a*2

7
script/test/cls.groovy Normal file
View File

@@ -0,0 +1,7 @@
package script
class cls {
double val = 1.0
void exec(){
println "Exec"
}
}

4
script/test/cls.py Normal file
View File

@@ -0,0 +1,4 @@
class cls:
def execute(self):
print "Execute"

3
script/test/scan.py Normal file
View File

@@ -0,0 +1,3 @@
def calc(a):
return a*2

1
script/test/scan1.py Normal file
View File

@@ -0,0 +1 @@
a= lscan(scienta.sizeX, (scienta.spectrum,current,cur1), 980.0, 992.0, 12, 0.1)

31
script/test/script.groovy Normal file
View File

@@ -0,0 +1,31 @@
def function(a){
a*2
}
//evaluate (new File("calc.groovy"))
//evaluate (new File("cls.groovy"))
println "--------------"
lib.load "calc"
cls = lib.load "cls"
//This is how to load a new class dinamically
// ClassLoader parent = lib.class.getClassLoader();
// groovy.lang.GroovyClassLoader loader = new groovy.lang.GroovyClassLoader(parent);
// Class cls = loader.parseClass(new File("script\\cls.groovy"));
println dev.get()
println dev2.val
println calc(6)
//cls = Class.forName('cls')
//obj = new cls()
obj = cls.newInstance()
println obj.val
obj.exec()

13
script/test/script.js Normal file
View File

@@ -0,0 +1,13 @@
function calcx(a) {
return a * 5;
}
print('Hello, World')
lib.load ("calc")
a=3
a
print (dev.get())
print (dev2.val)
print (calc(5))

42
script/test/script.py Normal file
View File

@@ -0,0 +1,42 @@
import sys
import time
#To add library folders from within the script
#sys.path.append("./site-packages")
import requests
r = requests.get('https://api.github.com', auth=('user', 'pass'))
print r.status_code
print r.headers['content-type']
r.close()
def calc2(a):
return a*2
time.sleep(2)
#import os
#print os.environ
#import calc
lib.load("calc")
lib.load("cls")
time.sleep(2)
for x in range(3):
print x
while(True):
print x*2
break
time.sleep(2)
x=cls()
x.execute()
print dev.take()
print dev2.val
time.sleep(1)
print calc(4)
"""
It lives!!!!
"""

View File

@@ -0,0 +1,53 @@
import ch.psi.pshell.scan.LineScan;
import ch.psi.pshell.scan.AreaScan;
def sleep(millis){
Thread.sleep(millis);
}
def toArray(obj){
/* if (!obj.getClass().isArray()){
arr = java.lang.reflect.Array.newInstance(obj.getClass(), 1);
arr[0]= obj;
obj=arr
}*/
return obj
}
def scan(writables, readables, start, end, steps, latency_ms=0, plot=null){
writables=toList(writables)
readables=toList(readables)
start=toList(start)
end=toList(end)
scan = LineScan(writables,readables, start, end , steps,latency_ms, controller)
scan.setPlotName(plot)
scan.start()
return scan.getResult()
}
def tscan(readables, points, interval_ms, plot=null){
writables=[]
//readables=toList(readables)
readables=[readables,]
start=[0]
end=[points]
steps=points
scan = LineScan(writables,readables, start, end , steps,interval_ms, controller)
scan.setPlotName(plot)
scan.start()
return scan.getResult()
}
def ascan(writables, readables, start, end, steps, latency_ms0, plot=null){
writables=toList(writables)
readables=toList(readables)
start=toList(start)
end=toList(end)
scan = AreaScan(writables,readables, start, end , steps,latency_ms, controller)
scan.setPlotName(plot)
scan.start()
return scan.getResult()
}

5
script/test/test1.py Normal file
View File

@@ -0,0 +1,5 @@
"""
Line Scan
"""
a= lscan(inp,(sin,out,arr),0,40,20,0.1)

16
script/test/test2.py Normal file
View File

@@ -0,0 +1,16 @@
"""
Line Scan with 2 writables and triggering
"""
index=0
def BeforeReadout():
global index
print "Frame = " + str(index)
index=index+1
#log("trigger " + index)
caput("TESTIOC:TESTBO:MyBO","On")
caput("TESTIOC:TESTBO:MyBO","Off")
a= lscan((motor,inp),(sin,out,arr),(0,0),(4,40),20,0.1, before_read=BeforeReadout)

12
script/test/test3.py Normal file
View File

@@ -0,0 +1,12 @@
"""
Processing and plotting scan data
"""
inp.write(0.0)
scan1= lscan(inp,(sin,out,arr),0,40,20,0.1,"Scan 1")
scan2= lscan(inp,(sin,out,arr),0,40,20,0.1,"Scan 2")
result=[]
for i in range(20):
result.append(scan1[i].values[0]+scan2[i].values[0])
plot(result)
print result

11
script/test/test4.py Normal file
View File

@@ -0,0 +1,11 @@
"""
Vector Scan
"""
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] ]
a= vscan((dev,inp),(sin,out),vector,0.1)

5
script/test/test5.py Normal file
View File

@@ -0,0 +1,5 @@
"""
Area Scan
"""
ascan((dev,out),(sin,out,arr),(0,10),(20,30),(100,100))

36
script/test/test6.py Normal file
View File

@@ -0,0 +1,36 @@
"""
Creating pseudo-devices
"""
import time
sin_val=None
class Sensor(ch.psi.pshell.dev.Readable):
def read(self):
global sin_val
return sin_val + time.clock()
def getName(self):
return "Sensor"
class Positioner(ch.psi.pshell.dev.Writable):
def write(self,pos):
print pos
def getName(self):
return "Positioner"
class Listener (ch.psi.pshell.dev.DeviceListener):
def onStateChanged(self, device, state, former):
pass
def onValueChanged(self, device, value, former):
global sin_val
sin_val=value
sensor=Sensor()
positioner=Positioner()
listener = Listener()
sin.addListener(listener)
try:
a= lscan((inp,positioner),(sin,sensor),(0,0),(40,10),20,0.1)
finally:
sin.removeListener(listener)