This commit is contained in:
x03daop
2015-04-02 15:06:44 +02:00
parent 7f8d0db1b0
commit d03b370987
2 changed files with 53 additions and 22 deletions
+3 -1
View File
@@ -1,4 +1,6 @@
#Tue Mar 31 11:24:32 CEST 2015
#Thu Apr 02 15:06:16 CEST 2015
autoSaveScanData=false
createSessionFiles=false
dataFile={data}/{year}_{month}/{date}/{date}_{time}_{context}
dataFilesCreation=true
devicePoolFile={config}/devices.properties
+50 -21
View File
@@ -2,10 +2,12 @@ import sys
import time
import math
from array import array
from java.lang.reflect import Array as JavaArray
import java.lang.Class as Class
import org.python.core.PyArray as PyArray
import ch.psi.pshell.dev.MotorGroupBase.MoveMode as MoveMode
import jarray
import ch.psi.pshell.scan.LineScan
import ch.psi.pshell.scan.AreaScan
@@ -62,6 +64,19 @@ def toList(obj):
return obj
def toArray(obj):
if isinstance(obj,PyArray):
return obj
if isinstance(obj,tuple) or isinstance(obj,list):
if len(obj)>0 and (isinstance(obj[0],tuple) or isinstance(obj[0],list)):
ret = JavaArray.newInstance(Class.forName("[D"),len(obj))
for i in range(len(obj)):
ret[i]=toArray(obj[i])
return ret
return jarray.array(obj,'d')
return obj
def lscan(writables, readables, start, end, steps, latency=0.0, plot=None, before_read=None, after_read=None):
"""Line Scan: positioners change together, linearly from start to end positions.
@@ -207,24 +222,38 @@ class ListReader(Readable):
self.counter=self.counter+1
return ret
def plot(data, plot=None):
"""Plot a list in a graph.
data = toArray(data)
controller.plot(toArray(data),plot)
def saveData(path, data):
data = toArray(data)
controller.dataManager.setData(path,data)
def loadData(path):
slice = controller.dataManager.getData(path)
return slice.sliceData
def createData(path, type, unsigned=False, dimensions=None):
type = Class.forName(channel_types.get(type,type))
controller.dataManager.createDataArray(path, type, unsigned, dimensions)
def saveDataItem(path, data, index=None):
data = toArray(data)
if index is None:
controller.dataManager.appendItem(path, data)
else:
controller.dataManager.setItem(path, data, index)
def setDataAttr(path, name, value, unsigned = False):
controller.dataManager.setAttribute(path,name, value, unsigned)
def currentDataGroup():
return controller.dataManager.getCurrentGroup()
Args:
data(list): data to be plotted
plot(str, optional): plotting context name.
"""
latency_ms=0
data=toList(data)
writables=[]
readables=[ListReader(data,plot),]
start=[0,]
end=[len(data),]
steps=len(data)-1
scan = LineScan(writables,readables, start, end , steps,latency_ms, controller)
scan.setPlotName(plot)
scan.start()
channel_types = {
'b': "java.lang.Byte",
@@ -299,12 +328,12 @@ def log(log):
"""
controller.getDataManager().addLog(str(log))
def startBackgroudTask(script, interval):
def startTask(script, interval):
interval_ms=int(interval*1000)
controller.taskManager.create(script,interval_ms)
controller.taskManager.start(script)
controller.getTaskManager().create(script,interval_ms)
controller.getTaskManager().start(script)
def stopBackgroudTask(script):
controller.taskManager.remove(script)
def stopTask(script, interval):
controller.getTaskManager().remove(script)
execfile(controller.setup.getScriptPath()+"/local.py")
execfile(controller.setup.getScriptPath()+"/local.py")