Esempio n. 1
0
    def rawAsynchronousMoveTo(self, new_position):
        '''move beam energy, polarisation, or both to specified values.
        At the background this moves both ID gap, phase, and PGM energy to the values corresponding to this energy, polarisation or both.
        If a child scannable can not be reached for whatever reason, it just prints out a message, then continue to next.'''
        gap = 20
        new_polarisation = None
        phase = 0
        try:
            if not self.SCANNING:  #ensure ID hardware in sync in 'pos' command
                self.rawGetPosition()
            #parse arguments as it could be 1 or 2 inputs, string or number type, depending on polarisation mode and instance attribute value
            if not isinstance(new_position, list): # single argument
                self.logger.debug("Single argument: {} given".format(type(new_position)))
                if isinstance(new_position, basestring):
                    #polarisation change requested
                    energy=float(self.mono_energy.getPosition())/1000.0 #get existing energy
                    if self.polarisationConstant: #input must be for energy
                        raise ValueError("Input value must be a number.")
                    new_polarisation=str(new_position)
                    if not new_polarisation in ["LH", "LV","CR", "CL", "LH3"]:
                        raise ValueError('Input value must be one of valid polarisation mode: "LH", "LV","CR", "CL", "LH3"')
                elif isinstance(new_position, numbers.Number):
                    # energy change requested
                    if self.polarisationConstant: #input must be for energy
                        energy=float(new_position) 
                        gap, new_polarisation, phase = self.getIDPositions() #get existing polarisation
                    else:
                        raise ValueError("Polarisation is not constant, but a number: {} was given".format(new_position))
                else:
                    raise ValueError("Input value must be a string or number.")
            else: #2 arguments
                args = list(new_position)
                if len(args) != 2:
                    raise ValueError("Expect 2 arguments but got %s" % len(args))
                if isinstance(args[0], numbers.Number):
                    self.logger.debug("Two arguments given and first argument {} is a number".format(args[0]))
                    energy = float(args[0]) #range validation is done later
                else:
                    raise ValueError("1st input for energy must be a number")
                if isinstance(args[1], basestring):
                    new_polarisation = args[1]
                else:
                    raise ValueError("2nd input  for polarisation must be a string")
                
            gap, phase=self.idgapphase(Ep=energy, mode=new_polarisation)
        except:
            raise #re-raise any exception from above try block

        if self.feedbackPV is not None and not self.SCANNING:
            #stop feedback
            from gdascripts.utils import caput
            caput(self.feedbackPV, 1)        
            self.moveDevices(gap, new_polarisation, phase, energy)
            self.waitWhileBusy()
            caput(self.feedbackPV, 0)
        else:
            self.moveDevices(gap, new_polarisation, phase, energy)
Esempio n. 2
0
    def rawAsynchronousMoveTo(self, new_position):
        """
        move beam energy to specified value.
        In the background this moves both ID gap and Mono Bragg to the values
        corresponding to this energy. If a child scannable can not be reached
        for whatever reason, it just prints out a message, then continue to next.
        """
        min_energy, max_energy = self.energyRangeForOrder(self.order)
        energy = float(new_position)
        self.logger.debug(
            ("rawAsynchronousMoveTo called for energy {}. "
             "min_energy for order is: {}, max_energy is: {}").format(
                 energy, min_energy, max_energy))

        gap = self.idgap(energy, self.order)

        if not min_energy < energy < max_energy:
            raise ValueError(("Requested photon energy {} is out of range for "
                              "harmonic {}: min: {}, max: {}").format(
                                  energy, self.order, min_energy, max_energy))

        if self.feedbackPVs is not None and not self.SCANNING:
            caput(self.feedbackPVs[0], 1)
            caput(self.feedbackPVs[1], 1)
            self.moveDevices(energy, gap)
            self.waitWhileBusy()
            caput(self.feedbackPVs[0], 0)
            caput(self.feedbackPVs[1], 0)
        else:
            self.moveDevices(energy, gap)
Esempio n. 3
0
    def rawAsynchronousMoveTo(self, new_position):
        """
        move beam energy to specified value.
        At the background this moves both ID gap and Mono Bragg to the values corresponding to this energy.
        If a child scannable can not be reached for whatever reason, it just prints out a message, then continue to next.
        """
        energy = float(new_position)
        gap = self.idgap(energy, self.order)

        if self.feedbackPV is not None and not self.SCANNING:
            caput(self.feedbackPV, 1)
            self.moveDevices(energy, gap)
            self.waitWhileBusy()
            caput(self.feedbackPV, 0)
        else:
            self.moveDevices(energy, gap)
def scan_fpitch(start, step, n):
    posns = []
    izeros = []
    pos(fpitch2, start)
    sleep(1)
    less = 0
    for i in range(n):
        posn = start + step * i
        pos(fpitch2, posn)
        sleep(0.12)
        posns.append(posn)
        caput("BL11I-EA-COUNT-01.CNT", 1)
        sleep(0.12)
        izero = Io.getPosition()
        izeros.append(izero)
        if len(izeros) < 3:
            continue
        if izeros[-1] > izeros[-2]:
            less = 0
        else:
            less += 1
        if less > 5:
            break
    return (posns, izeros)
Esempio n. 5
0
def zerosupplies():
    caput("BL09I-EA-DET-01:CAM:ZERO_SUPPLIES", 1)
step = 0.2
n = 176
ysize = 0.8
ycentre = -1.226

# wait for topup to complete if it will interrupt us
topup_time = float(caget("SR-CS-FILL-01:COUNTDOWN"))
needed_time = n*0.29 + 20.0
if needed_time > topup_time:
    waiting_time = topup_time + 10
    print "Waiting %.2fs for topup to complete..." % waiting_time
    sleep(waiting_time)
print "Starting Optimisation"

# setup scaler and disable fast feedback
caput("BL11I-EA-COUNT-01.TP",0.1)
caput("BL11I-OP-DCM-01:PID:AUTO", 0)
caput("BL11I-OP-DCM-01:PID.FBON", 0)
'''
s4yplus.asynchronousMoveTo(1.4)
s4yminus.asynchronousMoveTo(-2.4)
s4yplus.waitWhileBusy()
s4yminus.waitWhileBusy()
'''
# moving function
def scan_fpitch(start, step, n):
    posns = []
    izeros = []
    pos(fpitch2, start)
    sleep(1)
    less = 0
Esempio n. 7
0
 def horizontal(self):
     '''set horizontal rastering
     '''
     caput(self.pv_hfm, ON)
     caput(self.pv_vfm, OFF)
Esempio n. 8
0
 def vertical(self):
     '''set vertical rastering
     '''
     caput(self.pv_hfm, OFF)
     caput(self.pv_vfm, ON)
Esempio n. 9
0
 def vroff(self):
     '''set vertical rastering off
     '''
     caput(self.pv_vfm, OFF)
Esempio n. 10
0
 def hroff(self):
     '''sets horizontal rastering off
     '''
     caput(self.pv_hfm, OFF)
Esempio n. 11
0
 def vron(self):
     '''sets vertical rastering on
     '''
     caput(self.pv_vfm, ON)
Esempio n. 12
0
 def hron(self):
     '''sets horizontal rastering on
     '''
     caput(self.pv_hfm, ON)
Esempio n. 13
0
'''
Created on 9 Dec 2013

@author: fy65
'''
from gdascripts.utils import caput
caput("BL11I-EA-BLOW-01:SP", 500)