This commit is contained in:
2015-04-01 11:04:59 +02:00
parent 0b70b7bc9a
commit 2cc7b9ee9e
2 changed files with 51 additions and 21 deletions

View File

@@ -1,4 +1,5 @@
#Fri Mar 27 10:38:34 CET 2015
#Wed Apr 01 10:35:49 CEST 2015
autoSaveScanData=false
dataFile={data}/{year}_{month}/{date}/{date}_{time}_{context}
dataFilesCreation=true
devicePoolFile={config}/devices.properties

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(scrip)
controller.getTaskManager().create(script,interval_ms)
controller.getTaskManager().start(script)
def stopBackgroudTask(script):
controller.taskManager.stop(scrip)
def stopTask(script, interval):
controller.getTaskManager().remove(script)
execfile(controller.setup.getScriptPath()+"/local.py")