This commit is contained in:
e14968
2015-04-20 10:15:57 +02:00
commit 50c6eb4cdf
21 changed files with 2627 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
def calc(a):
return a*4
+4
View File
@@ -0,0 +1,4 @@
class cls:
def execute(self):
print "Execute"
+53
View File
@@ -0,0 +1,53 @@
data = [1,2,3,4,5]
path="group/data"
saveDataset(path, data)
read =loadData(path)
print read.tolist()
#plot(read)
data = [ [1,2,3,4,5], [2,3,4,5,6], [3,4,5,6,7]]
path="group/data2"
saveDataset(path, data)
read =loadData(path)
print read.tolist()
plot(read)
path = "group/data3"
createDataset(path, 'i')
for i in range(10):
saveDataItem(path,i)
path = "group/data4"
createDataset(path, 'd', False, (0,0))
for row in data:
saveDataItem(path, row)
path = "group/data5"
names = ["a", "b", "c", "d"]
types = ["d", "d", "d", "[d"]
lenghts = [0,0,0,5]
dims = [0,0,0,0]
data = [ [1,2,3,[0,1,2,3,4]],
[2,3,4,[3,4,5,6,7]],
[3,4,5,[6,7,8,9,4]] ]
createTable(path, names, types, lenghts, dims)
for row in data:
saveTableItem(path, row)
flushData()
read =loadData(path)
print read
+11
View File
@@ -0,0 +1,11 @@
ch.psi.jcae.ContextFactory.addressList=129.129.130.188 129.129.130.255 129.129.130.37 129.129.145.206:54321 129.129.145.26 129.129.145.31:54321 129.129.130.88 129.129.130.142 129.129.150.123 129.129.130.123 129.129.130.120 172.20.3.50
#ch.psi.jcae.ContextFactory.addressList=129.129.130.255 129.129.145.26 129.129.145.31 129.129.150.123
#ch.psi.jcae.ContextFactory.addressList=129.129.145.206:54321 129.129.150.123
#ch.psi.jcae.ContextFactory.addressList=sls-cagw 129.129.102.63
ch.psi.jcae.ContextFactory.maxArrayBytes=10000000
ch.psi.jcae.ChannelFactory.timeout=2000
ch.psi.jcae.ChannelFactory.retries=2
ch.psi.jcae.ChannelBeanFactory.timeout=10000
ch.psi.jcae.ChannelBeanFactory.waitTimeout=3600000
ch.psi.jcae.ChannelBeanFactory.retries=2
+41
View File
@@ -0,0 +1,41 @@
#Simple parallization
def task1():
return out.read()
def task2():
return inp.read()
def task3():
time.sleep(0.1)
return sin.read()
ret = parallelize(task1, task2, task3)
print ret
#Fork amd join
ret = fork(task1, task2, task3)
time.sleep(0.1)
ret = join(ret)
print ret
#Functions with parameters
def devRead(dev, msg):
print msg + " -> " + dev.getName()
return dev.read()
ret = parallelize((devRead,(out,"1")), (devRead,(inp,"2")), (devRead,(sin,"3")))
print ret
#Exception in parallel task
def taskExcept(msg):
raise Exception ("Error in parallel task " + msg)
ret = parallelize((taskExcept,("1")), (taskExcept,(inp,"2")) )
print ret
+2
View File
@@ -0,0 +1,2 @@
def calc(a):
return a*2
+79
View File
@@ -0,0 +1,79 @@
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(1)
#import os
#print os.environ
#import calc
lib.load("calc")
lib.load("cls")
time.sleep(1)
for x in range(3):
print x
while(True):
print x*2
break
time.sleep(1)
x=cls()
#x.execute()
#print dev.take()
#print dev2.val
time.sleep(1)
print calc(4)
data = [1,2,3,4,5]
path="group/data"
saveData(path, data)
read =loadData(path)
print read.tolist()
#plot(read)
data = [ [1,2,3,4,5], [2,3,4,5,6], [3,4,5,6,7]]
path="group/data2"
saveData(path, data)
read =loadData(path)
print read.tolist()
plot(read)
path = "group/data3"
createData(path, 'i')
for i in range(10):
saveDataItem(path,i)
path = "group/data4"
createData(path, 'l', False, (0,0))
for row in data:
saveDataItem(path, row)
"""
It lives!!!!
"""
+9
View File
@@ -0,0 +1,9 @@
"""
Line Scan
"""
a= lscan(inp,(sin,out,arr),0,40,20,0.1)
setDataAttr(currentDataGroup(), "AttrString", "Value")
setDataAttr(currentDataGroup(), "AttrInt", 1)
setDataAttr(currentDataGroup(), "AttrDouble", 10.1)
#setDataAttr(currentDataGroup()+"/arr", "AttrString", "Value")
+16
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
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
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
View File
@@ -0,0 +1,5 @@
"""
Area Scan
"""
ascan((dev,out),(sin,arr),(0,10),(20,30),(100,100))
+36
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)