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

10
.gitignore vendored Normal file
View File

@@ -0,0 +1,10 @@
/data
/sessions
/context
/log
/plugins
/extensions
/www
script/cachedir
script/Lib
script/*.class

22
config/config.properties Normal file
View File

@@ -0,0 +1,22 @@
#Mon Apr 20 10:14:33 CEST 2015
autoSaveScanData=true
createSessionFiles=false
dataPath={data}/{year}_{month}/{date}/{date}_{time}_{context}
dataProvider=default
dataScanStrategy=default
devicePoolFile={config}/devices.properties
deviceUpdateStrategyFile={config}/update.properties
imageSourcesFile={config}/imaging.properties
logDaysToLive=-1
logLevel=Info
logLevelConsole=Off
scriptType=py
serverEnabled=false
serverPort=8080
simulation=false
tasksFile={config}/tasks.properties
terminalEnabled=false
terminalPort=3579
versionTrackingEnabled=true
versionTrackingLogin=
versionTrackingRemote=

View File

View File

86
script/_local.py~ Normal file
View File

@@ -0,0 +1,86 @@
#det.data.monitored=True
#startTask("back", 5.0)
#controller.dataManager.dataProvider.setItemSeparator('\t')
data1 = [1.0, 2.0, 3.0, 5.0, 1.0]
data1b = [2.0, 3.0, 1.0, 2.0, 2.0]
data2 = [ [1.0, 2.0, 3.0, 5.0, 1.0],
[2.0, 2.0, 3.0, 5.0, 1.0],
[3.0, 3.0, 3.0, 5.0, 1.0],
[4.0, 4.0, 5.0, 5.0, 1.0] ]
data3 = [
[ [1.0, 1.0, 1.0, 1.0, 1.0],
[2.0, 2.0, 3.0, 5.0, 1.0],
[3.0, 3.0, 3.0, 5.0, 1.0],
[4.0, 4.0, 5.0, 5.0, 1.0] ],
[ [2.0, 2.0, 2.0, 2.0, 2.0],
[2.0, 2.0, 3.0, 5.0, 1.0],
[3.0, 3.0, 3.0, 5.0, 1.0],
[4.0, 4.0, 5.0, 5.0, 1.0] ],
[ [3.0, 3.0, 3.0, 3.0, 3.0],
[2.0, 2.0, 3.0, 5.0, 1.0],
[3.0, 3.0, 3.0, 5.0, 1.0],
[4.0, 4.0, 5.0, 5.0, 1.0] ] ]
idata1 = [1, 2, 3, 5, 1]
idata2 = [ [1, 2, 3, 5, 1],
[2, 2, 3, 5, 1],
[3, 3, 3, 5, 1],
[4, 4, 5, 5, 1] ]
idata3 = [
[ [1, 1, 1, 1, 1],
[2, 2, 3, 5, 1],
[3, 3, 3, 5, 1],
[4, 4, 5, 5, 1] ],
[ [2, 2, 2, 2, 2],
[2, 2, 3, 5, 1],
[3, 3, 3, 5, 1],
[4, 4, 5, 5, 1] ],
[ [3, 3, 3, 3, 3],
[2, 2, 3, 5, 1],
[3, 3, 3, 5, 1],
[4, 4, 5, 5, 1] ] ]
class DevListener(DeviceAdapter):
def onValueChanged(self, device, value, former):
print value
device_listener = DevListener()
#java.lang.System.setProperty("gov.aps.jca.jni.ThreadSafeContext.addr_list", "129.129.145.206")
import os.path
#sys.path.append(str(java.nio.file.Paths.get(controller.setup.getStandardLibraryPath(), "epics")))
#sys.path.append(os.path.join(controller.setup.getStandardLibraryPath(), "epics"))
#import epics
#import _ca
#if run_count >0:
# _ca.initialize()
from epicsPV import epicsPV
di=epicsPV("TESTIOC:TESTSINUS:SinCalc")
do=epicsPV("TESTIOC:TESTCALCOUT:Input")
mdi=epicsPV("TESTIOC:TESTWF2:MyWF")

View File

@@ -0,0 +1,47 @@
#! /usr/bin/env python
# Federica Marone, July 2, 2014
from epicsMotor import epicsMotor
from epicsPV import epicsPV
chScanType=epicsPV("X02DA-ES1-SCAN1:TYPE")
chSystemOffset=epicsPV("X02DA-SCAN-CAM1:SYSOFF")
# Machine
chRingCurrentStatus=epicsPV("ARIDI-PCT:CURRENT")
chRingCurrentStartFake=epicsPV("X02DA-SCAN-SCN1:CURR")
chRingCurrentStartFake.setMonitor()
chInterlockStatus=epicsPV("X02DA-FE-AB1:ILK-STATE")
chInterlockStatus.setMonitor()
chAbsorberStatus=epicsPV("X02DA-FE-AB1:CLOSE4BL")
chAbsorberStatus.setMonitor()
# Energy
chCrystal1Pitch=epicsMotor("X02DA-OP-MO1:C1THE")
chBeamEnergy=epicsPV("X02DA-OP-ENE:ACTUAL")
chStripe=epicsPV("X02DA-OP-MO1:ACT_STR")
# Filters
chFEFilter=epicsPV("X02DA-FE-FI1:READ")
chOPFilter1=epicsPV("X02DA-OP-FI1:READ")
chOPFilter2=epicsPV("X02DA-OP-FI2:READ")
chOPFilter3=epicsPV("X02DA-OP-FI3:READ")
chOPFilter4=epicsMotor('X02DA-OP-FI4:TRY')
# Box
chBoxModeSelection=epicsPV("X02DA-ES1-BOX:MODE_SEL")
chCamera=epicsPV("X02DA-ES1-CAM1:CAM_SEL")
chMicroscope=epicsPV("X02DA-ES1-MS:MS_SEL")
chScintillator=epicsPV("X02DA-ES1-MS1:SCINTIL")
chPixelSize=epicsPV("X02DA-ES1-CAM1:ACT_PIXL_SIZE")
chMagnification=epicsPV("X02DA-ES1-MS:MAGNF")
# DPC
chGridStartRaw=epicsPV("X02DA-SCAN-SCN1:GRIDMIN.VAL")
chGridEndRaw=epicsPV("X02DA-SCAN-SCN1:GRIDMAX.VAL")
chGridNSteps=epicsPV("X02DA-SCAN-SCN1:GRIDSTEP")
chGridNPeriods=epicsPV("X02DA-SCAN-SCN1:GRIDPER")
chPiezo=epicsMotor("X02DA-ES1-PZOSTG2:DTR1")
chActualStep=epicsPV("X02DA-SCAN-SCN1:ACTSTEP")
chMillisecondShutter=epicsPV("X02DA-ES1-MSSH1:EXP-MODE")

6
script/local.py Normal file
View File

@@ -0,0 +1,6 @@
#from epicsPV import epicsPV
#di=epicsPV("TESTIOC:TESTSINUS:SinCalc")
#do=epicsPV("TESTIOC:TESTCALCOUT:Input")
#mdi=epicsPV("TESTIOC:TESTWF2:MyWF")

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

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

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

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

53
script/test/data.py Normal file
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

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
script/test/parallel.py Normal file
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
script/test/scan.py Normal file
View File

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

79
script/test/script.py Normal file
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
script/test/test1.py Normal file
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
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,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)

2174
script/tomography-scan.py Normal file

File diff suppressed because it is too large Load Diff