Ejemplo n.º 1
0
 def __init__(self,x,y,th,th2,chi,phi,sx,sy,sz,dy,gam,objName="diff",pvBase=None,presetsfile=None):
    if presetsfile == None:
       presetsfile = "/reg/neh/operator/" + guessBeamline() + "opr/" + guessBeamline() + "python_files/motorPresets/goniometer/gonGroup.txt"
    Device.__init__(self,objName,pvBase,presetsfile)
    self.x = x
    self.y = y
    self.th = th
    self.th2 = th2
    self.chi = chi
    self.phi = phi
    self.sx = sx
    self.sy = sy
    self.sz = sz
    self.dy = dy
    self.gam = gam
    self.objName = objName
    self.detCenOffset = None
    self.pvBase = pvBase
    self.reflectdet = None # externally defined, in beamline.py
    self.reflect = None    # externally defined, in beamline.py
    
    self.motors = {
       "x": x,
       "y": y,
       "th": th,
       "th2": th2,
       "chi": chi,
       "phi": phi,
       "sx": sx,
       "sy": sy,
       "sz": sz,
       "dy": dy,
       "gam": gam
       }
Ejemplo n.º 2
0
 def __init__(self, dbpath=None):
     self.dbpath = dbpath
     self.db = None
     if guessBeamline() == "xpp":
         self.defpalias = "PRINCETON"  # xpp.
     else:
         self.defpalias = "PRINCETON_BURST"  # xcs or mec.
Ejemplo n.º 3
0
 def _gui(self, file, ipm_macro):
     try:
         hutch = guessBeamline()
         base, iocpv, evrpv = self._config_pvs()
         macros = {
             "DEVICE":
             self._ipmPV,
             "IPM":
             ipm_macro,
             "TARGETM":
             self.ty.pvname,
             "DIODEM":
             self.dy.pvname,
             "CONFIG":
             "env -i /reg/neh/operator/xppopr/bin/ipmConfigEpics_basic {0} {1} {2}"
             .format(base, iocpv, evrpv),
             "LOCATION":
             self._ipmPV.split(":")[1],
             "DEV_NAME":
             self.__desc.upper(),
         }
         edm_hutch_open("device_states/{}.edl".format(file), **macros)
     except Exception, exc:
         print "Error opening ipm gui:"
         print exc
Ejemplo n.º 4
0
 def __init__(self,system=None,beamline=None):
   if beamline == None:
     beamline = guessBeamline()
   self.bll = beamline.lower
   if system == None:
     system = laserDict[self.bll]["system"]
   self.system=system
   self.timeout=2000
   self.gainthresh=5000
   self.beamline=beamline
   self.__pvnames(self.system)
Ejemplo n.º 5
0
 def __init__(self,PVbase=None,edm=None):
   if PVbase == None:
     PVbase = 'LAS:FS%d' % laserDict[guessBeamline().lower()]["system"]
   self._PVbase = PVbase
   self._PVtarg = Pv.Pv(PVbase+':VIT:FS_TGT_TIME', initialize=True, monitor=True)
   self._PVshifterStatus = Pv.Pv(PVbase+':MMS:PH:STATUS', initialize=True, monitor=True)
   self._PVtarg.wait_ready(3.0)
   self._PVshifterStatus.wait_ready(3.0)
   self.ismoving=False
   self._newtarget=None
   self._lasttarget = self.getDelay()
   self._lastmovetime = time()
   self._edm_exec = edm
Ejemplo n.º 6
0
def checkFolder():
    """ returns (and set global variable) for folder to use for logfile
  most of the time it will be ~operator/pyps/log"""
    beamline = blutil.guessBeamline()
    user = "******" % beamline
    base_folder = os.path.expanduser("~%s" % user)
    # test writing permission
    can_write = os.access(base_folder, os.W_OK)
    if (can_write):
        folder = base_folder + "/pyps/log"
    else:
        folder = os.path.expanduser("~") + "/pyps/log"
    if (not os.path.exists(folder)): os.makedirs(folder)
    globals()["gLogfolder"] = folder
    return folder
Ejemplo n.º 7
0
  def __init__(self,procedure_object,status_dir=None, home_session=None,width=70,indent = ' | '):
    if home_session == None:
      home_session = guessBeamline() + "python"
    self._obj = procedure_object
    self._desc = self._obj['desc']
    self._steps= self._obj['steps']
    self._width=width
    self._indent=indent
    for key in self._obj.keys():
      if not (key in standardfields):
	self.__dict__['_'+key] = self._obj[key]
	self.__dict__['_get_'+key] = partial(self._printthis,self.__dict__['_'+key])
	self.__dict__[key] = property(self.__dict__['_get_'+key])

    self.name = self._obj['name']
    if status_dir == None:
      status_dir = expanduser("~")
    statusfilename = home_session+'_procedures_status.txt'
    self._status_file = join(status_dir,statusfilename)
Ejemplo n.º 8
0
def getMotorPvList(motors, filename=None):
    if filename == None:
        bl = guessBeamline()
        blu = bl.upper()
        filename = '/reg/g/pcds/dist/pds/%s/misc/epicsArch_%s_%spython.txt' % (
            bl, blu, bl)
    PV = dict()
    for motname in motors.__dict__.keys():
        try:
            if motors.__dict__[motname].pvname == 'virtual motor':
                tPV = motors.__dict__[motname].pvpos
            else:
                tPV = motors.__dict__[motname]._Motor__readbackpv
            if not tPV:
                print 'WARNING! Motor %s has no epics PV' % (motname)
            else:
                PV[motname] = tPV
        except:
            print 'WARNING! Unknown problem with  %s' % (motname)
    return PV
Ejemplo n.º 9
0
def check_missing_PVs(motors,
                      daqepicsfile=None,
                      addfile=None,
                      updatelabel='missing_motors'):
    if daqepicsfile == None:
        daqepicsfile = '/reg/g/pcds/dist/pds/%s/misc/epicsArch.txt' % guessBeamline(
        )
    if addfile == None:
        bl = guessBeamline()
        blu = bl.upper()
        addfile = '/reg/g/pcds/dist/pds/%s/misc/epicsArch_%s_%spython.txt' % (
            bl, blu, bl)
    includedPVs = rdEpicsArchiveDaq(daqepicsfile, ignore_labels=True)
    try:
        includedPVs.pop(updatelabel)
    except:
        pass
    usedPVs = getMotorPvList(motors)
    update = dict()
    for lab, PV in zip(usedPVs.keys(), usedPVs.values()):
        isin = False
        for group in includedPVs:
            if PV in includedPVs[group].values():
                isin = True
        if not isin:
            update[lab] = PV
    pvs = []
    for PV in update.values():
        pvs.append(Pv.Pv(PV))
        pvs[-1].connect()
    sleep(1)
    isavailable = []
    for pv in pvs:
        isavailable.append(pv._Pv__connection_sem.isSet())

    print "Following motor PVs are not in the DAQ archiver, red=not available\n"
    labs = update.keys()
    PVs = update.values()
    labslen = max([len(lab) for lab in labs])
    PVslen = max([len(PV) for PV in PVs])
    for av, lab in zip(isavailable, labs):
        tstr = '   ' + ljust(lab, labslen, ' ') + ':  ' + update[lab]
        if not av:
            tstr = estr(tstr, color='red')
        print tstr
    print 'Would you like to write these to '
    print '%s ?' % addfile
    print 'y(es) / n(o) / o(nly available PVs) '
    inp = raw_input()
    if inp == 'y':
        writegroup = dict()
        writegroup[updatelabel] = update
        writeEpicsArchiveDaq(daqepicsfile, writegroup)
    elif inp == 'o':
        writegroup = dict()
        avupdate = dict()
        for ia, lab in zip(isavailable, labs):
            if ia:
                avupdate[lab] = update[lab]
        writegroup[updatelabel] = avupdate
        return writeEpicsArchiveDaq(daqepicsfile, writegroup)
Ejemplo n.º 10
0
 def is_sequence_owner(self):
     return Pv.get(self.__pv_hutch_id) == hutch_dict[guessBeamline()]