Example #1
0
    def __setGainN(self, igain, num):
        """
    Set ipimb gain as an integer index in the enum.

    Return True if args were ok, False otherwise.
    """
        if (not isinstance(num, int)):
            print 'channel number should be an integer!'
            return False
        currgain = self.__getGainN(num)
        if currgain is None:
            return False
        if (igain == -1):
            igain = currgain - 1
        elif (igain == 101):
            igain = currgain + 1
        if igain < self.__minGain:
            igain = self.__minGain
        elif igain >= self.__maxGain:
            igain = self.__maxGain - 1
        if 0 <= num <= 3:
            gain_str = self.__gainPV + str(num)
        else:
            print 'invalid channel # %f, wont set gain' % num
            return False
        Pv.put(gain_str, igain)
        return True
Example #2
0
 def switch(self):
     """ switches illuminator """
     onoff = Pv.get(self.pv_OnOff)
     if onoff == 1:
         Pv.put(self.pv_OnOff, 1)
     elif onoff == 0:
         Pv.put(self.pv_OnOff, 0)
Example #3
0
 def set_testburst_rate(self, rate):
     if not (rate in self.__dictRateToEnum):
         print "!! Rate should be one of:",
         print self.__dictRateToEnum.keys()
     else:
         Pv.put("PATT:SYS0:1:TESTBURST.N", 0)
         Pv.put("PATT:SYS0:1:TESTBURSTRATE", self.__dictRateToEnum[rate])
Example #4
0
 def __move(self,pos):
     Pv.put(self.__pvbase+":GO",0)
     Pv.put(self.__pvbase+":STOP",1)
     Pv.put(self.__pvbase+":CTRL_POS",int(pos*1.0e6/self.__getstepsize()))
     Pv.put(self.__pvbase+":GO",1)
     Pv.put(self.__pvbase+":STOP",0)
     pass
Example #5
0
 def __setDelay(self, delay):
     if (delay > self.__maxDelay or delay < self.__minDelay):
         print ' the requested delay has to be between %s and %s' % (
             self.__minDelay, self.__maxDelay)
         print ' leave delay at ', self.__getDelay
         return
     Pv.put(self.__delayPV, delay)
Example #6
0
 def __theta_movement(self, theta):
     x1, x2, z = ThetaToMotors(theta)
     z_now = self.z.wm()
     try:
         if z_now < z:
             print 'moving z to %+4.f' % z
             self.z.mv(z)
             self.z.wait()
             print 'moving x1 to %+4.f and x2 to %.4f\n' % (x1, x2)
             self.x1.mv(x1)
             self.x2.mv(x2)
             self.waitAll()
         else:
             print 'moving x1 to %+4.f and x2 to %.4f\n' % (x1, x2)
             self.x1.mv(x1)
             self.x2.mv(x2)
             self.x1.wait()
             self.x2.wait()
             print 'moving z to %+4.f' % z
             self.z.mv(z)
             self.waitAll()
     except KeyboardInterrupt:
         self.stop()
     finally:
         Pv.put(self._theta_pv, self.wmTheta())
Example #7
0
 def __init__(self,name,pv_base,pv_TTL,Vlow=0,Vhigh=5):
   self.name = name
   self.pv_base = pv_base
   self.pv_TTL = pv_TTL
   self.Vhigh = Vhigh
   self.Vlow = Vlow
   Pv.put(pv_base,5)
   Pv.put(pv_TTL,0)
Example #8
0
 def close(self, fast=False):
     """ close the shutter; the option fast when enable skip the test
 that makes sure that the output is not triggered by any event code"""
     #if (not fast):
     #self.evr.disableAllEvents()
     #self.evr.polarity(not self.__polarity)
     self._cleanup()
     Pv.put(self._PVname('S_CLOSE'), 1)
Example #9
0
 def __setBias(self, bias):
     #fix this, unprotexted now
     if (bias > self.__maxBias or bias < self.__minBias):
         print ' the requested bias has to be between %s and %s' % (
             self.__minBias, self.__maxBias)
         print ' leave bias at ', self.__getBias()
         return
     Pv.put(self.__biasPV, bias)
Example #10
0
 def set_fburst(self, f="Full"):
     f.replace(" ", "")
     # remove spaces
     if not (f in self.__freqs):
         print "!! Frequency should be one of:",
         print self.__freqs.keys()
     else:
         Pv.put("PATT:SYS0:1:MPSBURSTRATE", self.__freqs[f])
Example #11
0
 def speed(self,value=None):
   if (value is not None):
     Pv.put(self.speed_pv,value)
   if (self.speed_rbv is None):
     s=Pv.get(self.speed_pv)
   else:
     s=Pv.get(self.speed_rbv)
   return s
Example #12
0
 def moveDSPhi(self, phi):
   """ Move physical motors in sample/detector stages to get Phi reflection geometry """
   if not self.assertLimitsDSPhi(phi):
     return
   self.reflectdet.move_silent(phi)
   self.phi.move_silent(phi)
   if self.pvBase is not None:
     Pv.put(self.pvBase + ":GON:REF",phi)
   pass
Example #13
0
 def moveEwithVernier(self, E, vernierThresKeV=.003):
     """ E in keV """
     if (E > 2000):
         E = E / 1e3
     Ever0 = Pv.get(self.__vernierPV) / 1000.
     if n.abs(Ever0 - E) > vernierThresKeV:
         Pv.put(self.__vernierPV, E * 1000)
     alio = EToAlio(E)
     self.alio.move(alio)
Example #14
0
 def gain(self,value=None):
   ''' Reads or changes gain in the PD feedback loop
       usage:   gain(): reads back current gain
                gain(value): sets gain to passed value
   '''
   if (value is None):
     return Pv.get(self.__pv_gain)
   else:
     Pv.put(self.__pv_gain,value)
Example #15
0
 def move(self, position):
     if position in self.__positionMap:
         curpos = self.__getPosition()
         if curpos == positoin:
             print "WARNING: Stopper is already %s\n" % (position)
         else:
             Pv.put(self.__getPV(self.__cmdPV), position)
     else:
         print "ERROR: '%s' is not a valid position, please use one of: %s\n" % (
             position, __positionMap.keys())
Example #16
0
 def disableAllEventsForGivenTrigger(self, trigger):
     """ Disable all events code for a give  trigger """
     if (trigger > self.__ntriggers - 1):
         print "in disableAllEventsForGivenTrigger you asked for a trigger that is not defined ... exiting"
         return 0
     for i in range(self.__nevent_numbers):
         names = self.__getpvnames(i + 1)
         # starts with 1 and not zero
         Pv.put(names[trigger], 0)
     return 1
Example #17
0
 def trip(self, value=None):
     """ Sets or Returns the gauge trip point for the vacuum PLC """
     previous_trip = Pv.get(self.__pstatsprbck)
     if (value is not None):
         Pv.put(self.__pstatspdes, value)
         s = "Resetting PLC trip point of `%s` from %.4g to %.4g" % (
             self.name, previous_trip, value)
         logprint(s, print_screen=True)
     else:
         print "%s trip point is %.4g" % (self.name, previous_trip)
Example #18
0
 def set(self, value):
     if (self._set is not None):
         self._set(value)
     elif (self.pvoff is not None):
         offset = value - self.direction * self.wm_dial()
         Pv.put(self.pvoff, offset)
         sleep(0.1)
         # gives epics time to update offset pv
         self.wm()
     else:
         print "user position not defined for this motor"
Example #19
0
  def speed(self,value=None):
    """returns the speed, or sets it.
       This is a temporary hack, particularly for the nanoc for the tychography
    """

    if value==None:
      v=Pv.get(self.pvspeed)
      return v

    else:
      Pv.put(self.pvspeed,str(value))
Example #20
0
    def __init__(self):
        self.howto()
        #self.elog = pypsElog.pypsElog()
        for pv, item in self._pvs.items():
            print 'Adding ', pv, item
            item['Pv'] = Pv.Pv(item['pv'])
            setattr(self, pv, item['default'])
            Pv.put(item['pv'] + '.DESC', item['desc'])

        self.EXP = 'current'
        self.run()
Example #21
0
def fixSN(pmgr, PV):
    pv.put(PV + ".RINI", 1) # Re-initialize motor to get accurate SN
    objID = objFromPV(pmgr, PV)
    pmgr.updateTables()
    d = pmgr.objs[objID]
    # Set up Pv object so we can specify a timeout and wait for init.
    SNPV = pv.Pv(PV + ".SN")
    SNPV.connect(timeout=5)
    SN = SNPV.get() # Pull the value we need
    SNPV.disconnect()
    d["FLD_SN"] = SN
    transaction(pmgr, "objectChange", objID, d)
Example #22
0
def fixSN(pmgr, PV):
    pv.put(PV + ".RINI", 1)  # Re-initialize motor to get accurate SN
    objID = objFromPV(pmgr, PV)
    pmgr.updateTables()
    d = pmgr.objs[objID]
    # Set up Pv object so we can specify a timeout and wait for init.
    SNPV = pv.Pv(PV + ".SN")
    SNPV.connect(timeout=5)
    SN = SNPV.get()  # Pull the value we need
    SNPV.disconnect()
    d["FLD_SN"] = SN
    transaction(pmgr, "objectChange", objID, d)
Example #23
0
 def moveDetPhi(self, phi):
   """ Move Detector to phi reflection (2*phi).  This requires translating det-y and rotating det-gamma """
   self.checkDetPhiConfig()
   if not self.assertLimitsDetPhi(phi):
     return
   tphi = 2. * phi
   y_off = -1. * self.detCenOffset * math.tan(tphi*math.pi/180.)
   print "moving gam,dy to %f,%f" % (tphi,y_off)
   self.gam.move_silent(tphi)
   self.dy.move_silent(y_off)
   if self.pvBase is not None:
     Pv.put(self.pvBase + ":GON:REFD",phi)
   pass
Example #24
0
 def level(self, level='status'):
     """changes illumination level"""
     if level is "status":
         volt = Pv.get(self.pv_Volt)
         level = (volt - self.Vlow) / (self.Vhigh - self.Vlow)
         return level
     else:
         level = float(level)
         if level > 1:
             level = level / 100.
             print 'Illuminator Level was interpreted as percent'
         levelinvolt = self.Vlow + level * (self.Vhigh - self.Vlow)
         Pv.put(self.pv_Volt, levelinvolt)
Example #25
0
 def moveEn(self, energy):
     """ Move Energy to value -> Analyzer crystal to according theta, detector to 2theta """
     self.energy = energy
     th = self.convertEnergyToAngle(energy)
     if th is not None and self.assertLimitsEn(energy):
         print "moving th, tth to %f,%f" % (th, 2 * th)
         self.ath.move_silent(th)
         self.atth.move_silent(2 * th)
         if self.pvBase is not None:
             #print "putting energy"
             Pv.put(self.pvBase + ":Analyzer_Energy", energy)
             pass
     pass
Example #26
0
 def delay(self, value=None):
     '''return the current delay of the X-rays with respect to laser if  value is None.
        If a value is passed, the delay is change to that value. All values in seconds.
     '''
     if value == None:
         delay_value = self.get_offset() - self.dial_delay()
         if self._delay_pv_name != None:
             Pv.put(self._delay_pv_name, delay_value)
         return delay_value
     else:
         self.dial_delay(self.get_offset() - value)
         if self._delay_pv_name != None:
             Pv.put(self._delay_pv_name, value)
Example #27
0
    def dial_delay(self, value=None):
        '''return the current delay  if  value is None.
           If a value is passed, the delay is change to that value. All values in seconds.
           The returned values are those directly read of the DG645, without offset taken into
           account.
        '''

        if value == None:
            delay_read = Pv.get(self._pvbase + 'DelaySI')
            return double(delay_read[5:])
        elif self._low_lim < value < self._high_lim:
            Pv.put(self._pvbase + 'DelayAO', value)
        else:
            print('Delay outside of allowed range')
Example #28
0
 def setDefaultsForTrigger(self, trigger):
     """ Set EVR defaults for a given trigger (including mapping trigger#i->out#i"""
     self.EVReventCode.setDefaultsForTrigger(trigger)
     Pv.put(self.ioc + ":CTRL.ENAB", 1)
     #enable card
     self.assignOutToTrigger(trigger, trigger)
     # assign out #i to trigger #i
     self.change("enable", 1, trigger)
     # enable trigger #i
     self.change("polarity", 0, trigger)
     # polarity normal for trigger #i
     self.change("prescale", 1, trigger)
     # default prescaler for trigger #i
     self.setWidth(1e-3, trigger)
     self.setDelay(1e-3, trigger)
Example #29
0
 def wm(self, debug=0):
     if debug > 0:
         print 'virt motor wm: '
     if (self.pvoff is None):
         offset = 0
     else:
         offset = Pv.get(self.pvoff)
     if debug > 0:
         print 'virtualmotor offset: ', offset
         print 'virtualmotor dir: ', self.direction
         print 'virtualmotor dial pos: ', self.wm_dial()
     user = self.direction * self.wm_dial() + offset
     if (self.pvpos is not None):
         Pv.put(self.pvpos, user)
     return user
Example #30
0
 def setDefaults(self):
     self.EVReventCode.setDefaults()
     Pv.put(self.ioc + ":CTRL.ENAB", 1)
     #enable card
     for i in range(self.__ntriggers):
         self.assignOutToTrigger(i, i)
         # assign out #i to trigger #i
     for i in range(self.__ntriggers):
         self.change("enable", 1, i)
         # enable trigger #i
         self.change("polarity", 0, i)
         # polarity normal for trigger #i
         self.change("prescale", 1, i)
         # default prescaler for trigger #i
         self.setWidth(1e-3, i)
         self.setDelay(1e-3, i)
Example #31
0
 def __move(self, pos):
     ll = self.get_lowlim()
     lh = self.get_hilim()
     if (pos < ll):
         print "ERROR: Commanded position (%.3f) exceeds low soft-limit (%.3f)" % (
             pos, ll)
         pass
     elif (pos > lh):
         print "ERROR: Commanded position (%.3f) exceeds high soft-limit (%.3f)" % (
             pos, lh)
         pass
     else:
         Pv.put(self.pvname, pos)
         self.__commanded_position = pos
         pass
     pass