def capture_images(self, nImages): if nImages > 100: print "Max 100 images, aborting" return pass pypsepics.put("SXR:GIGE:CAM:703:1:JPEG:NumCapture", nImages) pypsepics.put("SXR:GIGE:CAM:703:2:JPEG:NumCapture", nImages) pypsepics.put("SXR:GIGE:CAM:703:3:JPEG:NumCapture", nImages) for i in range(1, 4): name = pypsepics.get("SXR:GIGE:CAM:703:%d:JPEG:FileName_RBV" % i) #form = pypsepics.get("SXR:GIGE:CAM:703:%d:JPEG:FileTemplate_RBV" % i) next = pypsepics.get("SXR:GIGE:CAM:703:%d:JPEG:FileNumber" % i) #print form #import sys #sys.stdout.flush() #f1 = form % ("",name,next) #print "Capturing %d images for cam%d: beginning with %s" % (nImages,f1) print "Capturing %d images for cam%d: beginning with image-# %04d" % ( nImages, i, next) pass pypsepics.put("SXR:GIGE:CAM:703:1:JPEG:Capture", 1) pypsepics.put("SXR:GIGE:CAM:703:2:JPEG:Capture", 1) pypsepics.put("SXR:GIGE:CAM:703:3:JPEG:Capture", 1) pass
def load_MMS_pars(cvsfile): f=open(cvsfile) lines = f.readlines() for i in range(len(lines)): lines[i]=lines[i].rstrip("\n") fields = lines[1]; lines = lines[2:]; fields = fields.split(",")[1:] for l in lines: ll=l.split(",") pv=ll[0] if pv.startswith("#"): continue values=ll[1:] for i in range(len(fields)): if fields[i].startswith("#"): continue if (values[i] != "?"): try: vv=float(values[i]) except: vv=values[i] if (fields[i]==":RC"): vv=str(values[i]); # for some reason the run current must be a string ! if (fields[i]==":EE"): vv=str(values[i]); # for some reason the use encoder must be a string ! if (fields[i]==".DIR"): vv=int(values[i]); if (fields[i]==".SREV"): vv=int(values[i]); try: print "setting ",pv+fields[i]," to ",values[i], pypsepics.put(pv+fields[i],vv) if (fields[i]==".S"): pypsepics.put(pv+".SMAX",vv) print " done" except: print "FAILED TO set ",pv+fields[i]," to ",values[i] # time.sleep(0.1) try: print "readback ",pv+fields[i], " " ,pypsepics.get(pv+fields[i]) except: print "FAILED TO READBACK ",pv+fields[i]
def ShutterWaitUntilResetDone(): iTry = 0 while iTry < Shutter.iNumMaxTry: if pypsepics.get(SHUTTER_PV_STATUS) == 0: return 0 time.sleep(Shutter.fTimeTry) iTry += 1 return 1
def ShutterWaitUntilMode(iModeTarget): iTry = 0 while iTry < Shutter.iNumMaxTry: #print "Get SE_L = %d (try %d)" % (pypsepics.get(SHUTTER_PV_SE_L), iTry) if pypsepics.get(SHUTTER_PV_SE_L) == iModeTarget: return 0 time.sleep(Shutter.fTimeTry) iTry += 1 return 1
def aliowait(): dt = 0.02 mt = 10. tt = 0. while ( (tt < mt) and (abs(alioget() - pypsepics.get("SXR:MON:MPZ:01:POSITIONSET")) > 3e-4)): sleep(dt) tt += dt
def clear_all_pu(self, nonuser=True): from common import pypsepics mots = self.get_motors(nonuser=nonuser) for m in mots: print m.name, ":" try: pu = pypsepics.get("%s:PU" % m.pvname) if not pu: print "Ok, pu=", pu else: print "PU=", pu, " resetting..." pypsepics.put("%s:SET_PU" % m.pvname, 0) pu = pypsepics.get("%s:PU" % m.pvname) if not pu: print "Ok, pu=", pu else: print "Failed! pu=", pu pass pass pass except Exception, ex: print ex
def motor_par(motor_pvlist): pars = [ 'description' , '.DESC', 'acceleration' , '.ACCL', 'units (EGU)' , '.EGU', 'direction' , '.DIR', 'encoder step size' , '.ERES', 'Gear x Pitch' , '.UREV', 'User Offset (EGU)' , '.OFF', 'retry deadband (EGU)', '.RDBD', 'Steps Per Rev' , '.SREV', 'Speed(RPS)' , '.S', 'Speed(UGU/S)' , '.VELO', 'base speed (RPS)' , '.SBAS', 'base speed (EGU/s)' , '.VBAS', 'backlash' , '.BDST', 'run current (%)' , ':RC', 'use encoder (:EE)' , ':EE' ] fields_desc=pars[::2] fields=pars[1::2] out=[] title1="pvname" title2="------" for f in fields_desc: title1 += ",%s" % f for f in fields: title2 += ",%s" % f out.append(title1) out.append(title2) for m in motor_pvlist: v=m for f in fields: try: vv=pypsepics.get( m + f) except: print m + f vv="?" v += ",%s" % vv out.append(v) return out
def log_images(self, message="L703 camera images"): if self.elog is None: print "Elog not defined, sorry!" return cam1next = pypsepics.get("SXR:GIGE:CAM:703:1:JPEG:FileNumber") cam2next = pypsepics.get("SXR:GIGE:CAM:703:2:JPEG:FileNumber") cam3next = pypsepics.get("SXR:GIGE:CAM:703:3:JPEG:FileNumber") pypsepics.put("SXR:GIGE:CAM:703:1:JPEG:NumCapture", 1) pypsepics.put("SXR:GIGE:CAM:703:2:JPEG:NumCapture", 1) pypsepics.put("SXR:GIGE:CAM:703:3:JPEG:NumCapture", 1) print "capturing..." pypsepics.put("SXR:GIGE:CAM:703:1:JPEG:Capture", 1) pypsepics.put("SXR:GIGE:CAM:703:2:JPEG:Capture", 1) pypsepics.put("SXR:GIGE:CAM:703:3:JPEG:Capture", 1) print "waiting..." self.__dumb_wait("SXR:GIGE:CAM:703:1:JPEG:FileNumber", cam1next + 1) self.__dumb_wait("SXR:GIGE:CAM:703:2:JPEG:FileNumber", cam2next + 1) self.__dumb_wait("SXR:GIGE:CAM:703:3:JPEG:FileNumber", cam3next + 1) f1 = self.__str_from_arr( pypsepics.get("SXR:GIGE:CAM:703:1:JPEG:FullFileName_RBV")) f2 = self.__str_from_arr( pypsepics.get("SXR:GIGE:CAM:703:2:JPEG:FullFileName_RBV")) f3 = self.__str_from_arr( pypsepics.get("SXR:GIGE:CAM:703:3:JPEG:FullFileName_RBV")) print f1 print f2 print f3 print "logging..." self.elog.submit(text=message, file=f1, file_descr="cam1: %s" % ("/reg/d/psdm/sxr/sxr70313/usr/" + f1.split("/")[-1])) self.elog.submit(text=message, file=f2, file_descr="cam2: %s" % ("/reg/d/psdm/sxr/sxr70313/usr/" + f2.split("/")[-1])) self.elog.submit(text=message, file=f3, file_descr="cam3: %s" % ("/reg/d/psdm/sxr/sxr70313/usr/" + f3.split("/")[-1])) print "done!"
def sxrvacstatus(): print "" print "HXX UM6 01 = %e Torr PIP = %e Torr" % (pypsepics.get('HXX:UM6:GCC:01:PMON'),pypsepics.get('HXX:UM6:PIP:01:PMON')) print "HXX UM6 02 = %e Torr PIP = %e Torr" % (pypsepics.get('HXX:UM6:GCC:02:PMON'),pypsepics.get('HXX:UM6:PIP:02:PMON'))
def __dumb_wait(self, channel, val): while pypsepics.get(channel) != val: time.sleep(.1) pass pass
def theta2finewait(): while (abs(theta2fineget() - pypsepics.get("SXR:MON:MPZ:02:POSITIONSET")) > 1e-3): sleep(0.02)
def theta2fineget(): return pypsepics.get("SXR:MON:MPZ:02:POSITIONGET")
def alioget(): return pypsepics.get("SXR:MON:MPZ:01:POSITIONGET")