Beispiel #1
0
class PathScan():
    def __init__(self, name, detectorToUse=edxd):#@UndefinedVariable
        self.name=name
        self.sg = ScannableGroup()
        self.pointid=[]
        self.path=[]
        self.startline=1
        self.lastline=10
        self.scannablelist=[]
        self.scannableunitlist=[]
        self.detector=detectorToUse
        self.detectorunit="s"
        self.exposuretime=[]
        
    def read_scan_path(self,filename):
        f = open(filename, "r")
        lines = f.readlines()
        f.close()
        lines = map(string.split, map(string.strip, lines))
        self.pointid=[]
        self.path=[]
        self.scannablelist=[]
        self.scannableunitlist=[]
        self.exposuretime=[]
        # parsing the input data
        for line in lines:
            print line
            if line[0].startswith("#"):     #ignore comment
                continue
            elif line[0].startswith("First"):
                self.startline=line[-1]
            elif line[0].startswith("Last"):
                self.lastline=line[-1]
            elif line[0].startswith("ScannableNames"):
                self.scannablelist=[globals()[x] for x in line[1:]] # get all motors
                self.sg.setName("pathscangroup")
                self.sg.setGroupMembers(self.scannablelist)
                self.sg.configure()
            elif line[0].startswith("ScannableUnits"):
                self.scannableunitlist=[x for x in line[1:]]
            else: #real data go here
                if int(line[0])>= self.startline or int(line[0]) <= self.lastline:
                    self.pointid.append(int(line[0]))
                    self.path.append([float(x) for x in line[1:]])
                    
    def setStartPoint(self, start):
        self.startline=start
    
    def getStartPoint(self):
        return self.startline
    
    def setStopPoint(self, stop):
        self.lastline=stop
        
    def getStopPoint(self):
        return self.lastline
    
    def setDetector(self, det):
        self.detector=det
        
    def getDetector(self):
        return self.detector
    
    def getPath(self):
        return self.path
    
    def setPath(self, path):
        self.path=path
        
    def getPointIDs(self):
        return self.pointid
    
    def setPointIDs(self, points):
        self.pointid=points

    def start(self,filename, exposureTime):
        ''' kept for backward compatibility'''
        self.read_scan_path(filename)
        print self.pointid
        print self.path
        print self.exposuretime
        pathPositions=tuple(self.path)
        print pathPositions
        scan([self.sg, pathPositions, self.detector, exposureTime])
    
    def startScan(self,filename, exposureTime):
        print self.pointid
        print self.exposuretime
        pathPositions=tuple(self.path)
        print pathPositions
        scan([self.sg, pathPositions, self.detector, exposureTime])
            
    def setName(self, name):
        self.name=name
        
    def getName(self):
        return self.name
Beispiel #2
0
    def __init__(self, name):
        self.name = name
        self.inputNames = ['epoch']
        self.extraNames = []
        self.outputFormat = ['%.3f']
        self.level = 9
        self.target_time = None

    def asynchronousMoveTo(self, time):
        self.target_time = time
        
    def isBusy(self):
        if self.target_time is None:
            return False
        return time.time() <= self.target_time
    
    def getPosition(self):
        return time.time()
       

t = TimeSinceScanStart('t')
dt = TimeSinceLastGetPosition("dt")
w = Wait("w")
clock = TimeOfDay('clock')
epoch = TimeSinceEpoch('epoch')

timerelated = ScannableGroup()
timerelated.setName("timerelated")
timerelated.setGroupMembers([t, dt, w, clock, epoch])