def connect_pvs(self, verbose=True): if self.prefix is None or len(self.prefix) < 2: return if self.prefix.endswith(':'): self.prefix = self.prefix[:-1] if self.prefix.endswith(':image1'): self.prefix = self.prefix[:-7] if self.prefix.endswith(':cam1'): self.prefix = self.prefix[:-5] self.write('Connecting to AD %s' % self.prefix) self.ad_img = epics.Device(self.prefix + ':image1:', delim='', attrs=self.img_attrs) self.ad_cam = epics.Device(self.prefix + ':cam1:', delim='', attrs=self.cam_attrs) epics.caput("%s:TIFF1:EnableCallbacks" % self.prefix, 1) epics.caput("%s:TIFF1:AutoSave" % self.prefix, 0) epics.caput("%s:TIFF1:AutoIncrement" % self.prefix, 0) epics.caput("%s:TIFF1:FileWriteMode" % self.prefix, 0) time.sleep(0.002) if not self.ad_img.PV('UniqueId_RBV').connected: epics.poll() if not self.ad_img.PV('UniqueId_RBV').connected: self.write('Warning: Camera seems to not be connected!') return if verbose: self.write('Connected to AD %s' % self.prefix) self.SetTitle("Epics Image Display: %s" % self.prefix) sizex = self.ad_cam.MaxSizeX_RBV sizey = self.ad_cam.MaxSizeY_RBV sizelabel = 'Image Size: %i x %i pixels' try: sizelabel = sizelabel % (sizex, sizey) except: sizelabel = sizelabel % (0, 0) self.imagesize.SetLabel(sizelabel) self.ad_cam.add_callback('DetectorState_RBV', self.onDetState) self.contrast.set_level_str('0.05')
def connect_pvs(self, verbose=True): if self.prefix is None or len(self.prefix) < 2: return self.write('Connecting to areaDetector %s' % self.prefix) self.ad_img = epics.Device(self.prefix + 'image1:', delim='', attrs=self.img_attrs) self.ad_cam = epics.Device(self.prefix + 'cam1:', delim='', attrs=self.cam_attrs) if self.config['general']['use_filesaver']: epics.caput("%s%sEnableCallbacks" % (self.prefix, self.fsaver), 1) epics.caput("%s%sAutoSave" % (self.prefix, self.fsaver), 0) epics.caput("%s%sAutoIncrement" % (self.prefix, self.fsaver), 0) epics.caput("%s%sFileWriteMode" % (self.prefix, self.fsaver), 0) time.sleep(0.002) if not self.ad_img.PV('UniqueId_RBV').connected: epics.poll() if not self.ad_img.PV('UniqueId_RBV').connected: self.write('Warning: detector seems to not be connected!') return if verbose: self.write('Connected to detector %s' % self.prefix) self.SetTitle("Epics areaDetector Display: %s" % self.prefix) sizex = self.ad_cam.MaxSizeX_RBV sizey = self.ad_cam.MaxSizeY_RBV sizelabel = 'Image Size: %i x %i pixels' try: sizelabel = sizelabel % (sizex, sizey) except: sizelabel = sizelabel % (0, 0) self.imagesize.SetLabel(sizelabel) self.ad_cam.add_callback('DetectorState_RBV', self.onDetState) self.contrast.set_level_str('0.01')
def connect_pvs(self): # print 'Connecting... ', self.prefix, self.attrs self.ad_dev = epics.Device(self.prefix, delim='', attrs=self.attrs) if not self.ad_dev.PV('UniqueId_RBV').connected: epics.ca.poll() if not self.ad_dev.PV('UniqueId_RBV').connected: return self.SetTitle("PV Image Display: %s" % self.prefix) self.ad_dev.add_callback('UniqueId_RBV', self.onNewImage) self.ad_dev.add_callback('ArraySize0_RBV', self.onProperty, dim=0) self.ad_dev.add_callback('ArraySize1_RBV', self.onProperty, dim=1) self.ad_dev.add_callback('ArraySize2_RBV', self.onProperty, dim=2) self.ad_dev.add_callback('ColorMode_RBV', self.onProperty, dim='color') self.GetImageSize() self.timer = EpicsTimer(self, period=100) epics.poll() self.RefreshImage()
def __init__(self, **kwargs): self.bpm = epics.Device() self.bpmname = None if 'bpm' in kwargs: if kwargs['bpm'].lower() == 'bpm1': self.bpmname = 'bpm1' for name in bpmlist['bpm1']: self.bpm.add_pv(bpmlist['bpm1'][name]) self._H_Cal = 0.11107 self._V_Cal = 0.106813 elif kwargs['bpm'].lower() == 'bpm2': self.bpmname = 'bpm2' for name in bpmlist['bpm2']: self.bpm.add_pv(bpmlist['bpm2'][name]) self._H_Cal = 0.12913 self._V_Cal = 0.101989 else: print("Don't recognize this BPM...exiting.") return None else: return None
def __init__(self, parent=None): super(MonitorWidget, self).__init__(parent) # __init__(parent) for main self.cntName = cntpv # GUI construction self.ui = Ui_monitorWidget() self.ui.setupUi(self) # SR beamcurrent & motor position monitor... self.beamPV = PV(beampv) self.m1PosPV = PV(m1pospv+'.RBV') self.m2PosPV = PV(m2pospv+'.RBV') self.beamPV.add_callback(self.beamCallbackFunc) self.m1PosPV.add_callback(self.m1CallbackFunc) self.m2PosPV.add_callback(self.m2CallbackFunc) # for counter... self.countPV = PV(self.cntName+'_calc2') scalerAttrs = ('calc1','calc2','calc3','calc4', 'calc5','calc6','calc7','calc8') self.scalerDev = epics.Device(prefix=self.cntName+'_', delim='', attrs=scalerAttrs, mutable=False) epics.poll() try: epics.poll(0.001, 1.0) val = self.scalerDev.get_all() self.ui.IoCnt.display(val['calc2']) self.ui.ItCnt.display(val['calc3']) self.ui.IfCnt.display(val['calc4']) self.ui.IrCnt.display(val['calc5']) except: pass self.countPV.add_callback(self.countersCallbackFunc, run_now=True)
def __init__(self): self.temp = epics.Device() for name in epstemplist.keys(): self.temp.add_pv(epstemplist[name]) self.temp.PV(epstemplist[name]).get()
#attoz = epics.Motor('26idcNES:sm27.') attox = epics.Motor('atto2:m4.') attoz = epics.Motor('atto2:m3.') #samchi = epics.Motor('atto2:m1.') #samphi = epics.Motor('atto2:m2.') objx = epics.Motor('26idcnpi:m1.') xrfx = epics.Motor('26idcDET:m7.') #piezox = epics.Motor('26idcSOFT:sm1.') #piezoy = epics.Motor('26idcSOFT:sm2.') #lensx = epics.Motor('4idcThor:m2.') #lensy = epics.Motor('4idcThor:m3.') chopy = epics.Motor('26idc:m7.') chopx = epics.Motor('26idc:m8.') #hybridx = epics.Device('26idcDEV:X_HYBRID_SP.VAL', attrs=('VAL','DESC')) hybridx = epics.Device('26idcnpi:X_HYBRID_SP.VAL', attrs=('VAL','DESC')) #hybridx = epics.Device('26idcnpi:m34.VAL', attrs=('VAL','DESC')) hybridx.add_pv('26idcnpi:m34.RBV', attr='RBV') #hybridy = epics.Device('26idcDEV:Y_HYBRID_SP.VAL', attrs=('VAL','DESC')) hybridy = epics.Device('26idcnpi:Y_HYBRID_SP.VAL', attrs=('VAL','DESC')) hybridy.add_pv('26idcnpi:m35.RBV', attr='RBV') twotheta = epics.Motor('26idcSOFT:sm3.') #twotheta = epics.Device('26idcDET:base:Theta.VAL', attrs=('VAL','DESC')) #twotheta.add_pv('26idcDET:base:Theta_d', attr='RBV') #dcmy = epics.Device('26idb:DAC1_1.VAL', attrs=('VAL','DESC')) #dcmy.add_pv('26idcDET:base:Theta_d', attr='RBV') not_epics_motors = [hybridx.NAME, hybridy.NAME, twotheta.NAME] # Define zone plate in-focus position optic_in_x = -1083.2 optic_in_y = -966.1
def __init__(self,prefix): self.det=epics.Device(prefix,delim=':',attrs=DET_FIELDS) self.h5=epics.Device(prefix+":HDF5",delim=':',attrs=FILE_FIELDS) self.roi=epics.Device(prefix,delim=':',attrs=ROI_FIELDS) self.ch1=epics.Device(prefix+":ARR1",delim=':',attrs=ARRAY_FIELDS) self.ch2=epics.Device(prefix+":ARR2",delim=':',attrs=ARRAY_FIELDS) self.ch3=epics.Device(prefix+":ARR3",delim=':',attrs=ARRAY_FIELDS) self.ch1sum=epics.Device(prefix+":ARRSUM1",delim=':',attrs=ARRAY_FIELDS) self.ch2sum=epics.Device(prefix+":ARRSUM2",delim=':',attrs=ARRAY_FIELDS) self.ch3sum=epics.Device(prefix+":ARRSUM3",delim=':',attrs=ARRAY_FIELDS) self.c1roi1=epics.Device(prefix+":C1_ROI1",delim=':',attrs=IND_ROI_FIELDS) self.c1roi2=epics.Device(prefix+":C1_ROI2",delim=':',attrs=IND_ROI_FIELDS) self.c1roi3=epics.Device(prefix+":C1_ROI3",delim=':',attrs=IND_ROI_FIELDS) self.c1roi4=epics.Device(prefix+":C1_ROI4",delim=':',attrs=IND_ROI_FIELDS) self.c2roi1=epics.Device(prefix+":C2_ROI1",delim=':',attrs=IND_ROI_FIELDS) self.c2roi2=epics.Device(prefix+":C2_ROI2",delim=':',attrs=IND_ROI_FIELDS) self.c2roi3=epics.Device(prefix+":C2_ROI3",delim=':',attrs=IND_ROI_FIELDS) self.c2roi4=epics.Device(prefix+":C2_ROI4",delim=':',attrs=IND_ROI_FIELDS) self.c3roi1=epics.Device(prefix+":C3_ROI1",delim=':',attrs=IND_ROI_FIELDS) self.c3roi2=epics.Device(prefix+":C3_ROI2",delim=':',attrs=IND_ROI_FIELDS) self.c3roi3=epics.Device(prefix+":C3_ROI3",delim=':',attrs=IND_ROI_FIELDS) self.c3roi4=epics.Device(prefix+":C3_ROI4",delim=':',attrs=IND_ROI_FIELDS) self.det.ERASE = 0 #initializing roi data, set them back to zero.
def __init__(self,**kwargs): self.fe=epics.Device() self.fename='5id1' for name in felist[self.fename]: self.fe.add_pv(felist[self.fename][name])
def connect_pvs(self, verbose=True): if self.prefix is None or len(self.prefix) < 2: return try: self.ad_cam.Acquire = 0 except: pass if self.prefix.endswith(':'): self.prefix = self.prefix[:-1] if self.prefix.endswith(':image1'): self.prefix = self.prefix[:-7] if self.prefix.endswith(':cam1'): self.prefix = self.prefix[:-5] if verbose: self.messag('Connecting to AD %s' % self.prefix) self.ad_img = epics.Device(self.prefix + ':image1:', delim='', attrs=self.img_attrs) self.ad_cam = epics.Device(self.prefix + ':cam1:', delim='', attrs=self.cam_attrs) self.ad_overlays = [] if HAS_OVERLAY_DEVICE: for ix in (1, 2): pvn = '%s:Over1:%i:' % (self.prefix, ix) self.ad_overlays.append(AD_OverlayPlugin(pvn)) time.sleep(0.010) if not self.ad_img.PV('UniqueId_RBV').connected: epics.poll() if not self.ad_img.PV('UniqueId_RBV').connected: self.messag('Warning: Camera seems to not be connected!') return if verbose: self.messag('Connected to AD %s' % self.prefix) self.SetTitle("Epics Image Display: %s" % self.prefix) self.wids['color'].SetPV(self.ad_cam.PV('ColorMode')) self.wids['exptime'].SetPV(self.ad_cam.PV('AcquireTime')) self.wids['period'].SetPV(self.ad_cam.PV('AcquirePeriod')) self.wids['gain'].SetPV(self.ad_cam.PV('Gain')) self.wids['numimages'].SetPV(self.ad_cam.PV('NumImages')) self.wids['imagemode'].SetPV(self.ad_cam.PV('ImageMode')) self.wids['triggermode'].SetPV(self.ad_cam.PV('TriggerMode')) sizex = self.ad_cam.MaxSizeX_RBV sizey = self.ad_cam.MaxSizeY_RBV if HAS_OVERLAY_DEVICE: over = self.ad_overlays[0] c1 = (over.Red, over.Green, over.Blue) self.wids['o1color'].SetColour(hexcolor(c1)) self.wids['o1posx'].SetPV(over.PV('PositionX')) self.wids['o1posx'].SetMax(sizex) self.wids['o1posy'].SetPV(over.PV('PositionY')) self.wids['o1posy'].SetMax(sizey) self.wids['o1sizx'].SetPV(over.PV('SizeX')) self.wids['o1sizx'].SetMax(sizex) self.wids['o1sizy'].SetPV(over.PV('SizeY')) self.wids['o1sizy'].SetMax(sizey) self.wids['o1shape'].SetPV(over.PV('Shape')) self.wids['o1name'].SetPV(over.PV('Name')) self.wids['o1use'].SetPV(over.PV('Use')) over = self.ad_overlays[1] c1 = (over.Red, over.Green, over.Blue) self.wids['o2color'].SetColour(hexcolor(c1)) self.wids['o2posx'].SetPV(over.PV('PositionX')) self.wids['o2posx'].SetMax(sizex) self.wids['o2posy'].SetPV(over.PV('PositionY')) self.wids['o2posy'].SetMax(sizey) self.wids['o2sizx'].SetPV(over.PV('SizeX')) self.wids['o2sizx'].SetMax(sizex) self.wids['o2sizy'].SetPV(over.PV('SizeY')) self.wids['o2sizy'].SetMax(sizey) self.wids['o2shape'].SetPV(over.PV('Shape')) self.wids['o2name'].SetPV(over.PV('Name')) self.wids['o2use'].SetPV(over.PV('Use')) sizelabel = 'Image Size: %i x %i pixels' try: sizelabel = sizelabel % (sizex, sizey) except: sizelabel = sizelabel % (0, 0) self.wids['fullsize'].SetLabel(sizelabel) self.showZoomsize() self.ad_img.add_callback('ArrayCounter_RBV', self.onNewImage) self.ad_img.add_callback('ArraySize0_RBV', self.onProperty, dim=0) self.ad_img.add_callback('ArraySize1_RBV', self.onProperty, dim=1) self.ad_img.add_callback('ArraySize2_RBV', self.onProperty, dim=2) self.ad_img.add_callback('ColorMode_RBV', self.onProperty, dim='color') self.ad_cam.add_callback('DetectorState_RBV', self.onDetState) epics.caput("%s:cam1:ArrayCallbacks" % self.prefix, 1) for p in self.enabled_plugins: epics.caput("%s:%s:EnableCallbacks" % (self.prefix, p), 1) epics.caput("%s:JPEG1:NDArrayPort" % self.prefix, "OVER1") epics.caput("%s:TIFF1:NDArrayPort" % self.prefix, "OVER1") epics.caput("%s:image1:NDArrayPort" % self.prefix, "OVER1") self.ad_cam.Acquire = 1 self.GetImageSize() self.unZoom() epics.poll() self.RefreshImage()
def main(argv=None): global gvalarm global ccgalarm global gvlist global ccglist global igvlist global iccglist global errlist global ierrlist global erralarm global flowalarm global flowlist global iflowlist global pending_update #console update flag pending_update = True usage = "usage: %prog [options]" parser = OptionParser(usage) parser.add_option("--snapshot", action="store_true", dest="snap", default="False", help="print one status message and exit") (options, args) = parser.parse_args() #add pvs, initialize alarm states ID05err = epics.Device() for name in errlist.keys(): ID05err.add_pv(errlist[name]) #delay for epics and pyepics to shake hands time.sleep(0.03) ID05err.PV(errlist[name]).get() if ID05err.get(errlist[name]) is not 0: erralarm[name] = ee_str else: erralarm[name] = ok_str ID05err.add_callback(errlist[name], cbferr) #pyepics device consisting of all CCGs ID05ccg = epics.Device() for name in ccglist.keys(): ID05ccg.add_pv(ccglist[name][0]) time.sleep(0.03) ID05ccg.PV(ccglist[name][0]).get() #initialize alarm list tval = float(ID05ccg.get(ccglist[name][0])) if tval > float(ccglist[name][1]) and tval <= float(ccglist[name][2]): ccgalarm[name] = ww_str elif tval > float(ccglist[name][2]): ccgalarm[name] = ee_str else: ccgalarm[name] = ok_str #install callbacks ID05ccg.add_callback(ccglist[name][0], cbfccg) ID05flow = epics.Device() for name in tlist.keys(): #initialize alarm list tval = float(tobj.temp.get(tlist[name][0])) if tval > float(tlist[name][1]) and tval <= float(tlist[name][2]): talarm[name] = ww_str elif tval > float(tlist[name][2]): talarm[name] = ee_str else: talarm[name] = ok_str #install callbacks tobj.temp.add_callback(tlist[name][0], cbftemp) for name in flowlist.keys(): ID05flow.add_pv(flowlist[name][0]) time.sleep(0.03) ID05flow.PV(flowlist[name][0]).get() #initialize alarm list tval = float(ID05flow.get(flowlist[name][0])) if tval < float(flowlist[name][1]) and tval >= float( flowlist[name][2]): flowalarm[name] = ww_str elif tval < float(flowlist[name][2]): flowalarm[name] = ee_str else: flowalarm[name] = ok_str #install callbacks ID05flow.add_callback(flowlist[name][0], cbfflow) #pyepics device consisting of all gate valves ID05gv = epics.Device() for name in gvlist.keys(): ID05gv.add_pv(gvlist[name]) time.sleep(0.03) ID05gv.PV(gvlist[name]).get() if ID05gv.get(gvlist[name]) == 0: gvalarm[name] = ee_str else: gvalarm[name] = ok_str ID05gv.add_callback(gvlist[name], cbfgv) #pyepics device consisting of all shutters ID05sh = epics.Device() for name in shutlist.keys(): ID05sh.add_pv(shutlist[name]) time.sleep(0.03) ID05sh.PV(shutlist[name]).get() if ID05sh.get(shutlist[name]) == 0: shalarm[name] = ok_str else: shalarm[name] = ee_str ID05sh.add_callback(shutlist[name], cbfsh) #force an update at least once every 30 sec t_old = time.time() while True: if pending_update == True: fflag_fe = fflag_a = fflag_b = fflag_d = False wflag_fe = wflag_a = wflag_b = wflag_d = False os.system('clear') pending_update = False Ngv = 1 #list of lists for terminaltables trow = list() #first row of table is labeling trow.append([ 'CC GAUGE', 'STAT', 'PUMP HV', 'STAT', 'GATEVALVE', 'STAT', 'FLOW', 'STAT', 'RTD', 'STAT' ]) #CCG list is most comprehensive for name in sorted(hvlist.keys()): s = name.rsplit(' ')[0] + ' IG_' + name.rsplit('_')[1] if ccgalarm.has_key(s): if erralarm[s] == ee_str: alarm = ee_str else: alarm = ccgalarm[s] trow.append([ccglist[s][0].rsplit('{')[1].rsplit('}')[0]]) #trow[Ngv].append(ccgalarm[s]) if alarm == ok_str: istr = oktext("%1.0e" % ID05ccg.get(ccglist[s][0])) elif alarm == ww_str: istr = wwtext("%1.0e" % ID05ccg.get(ccglist[s][0])) else: istr = eetext("%1.0e" % ID05ccg.get(ccglist[s][0])) if name.rsplit(' ')[0] < 8: fflag_a = True elif name.rsplit(' ')[0] < 11: fflag_b = True else: fflag_d = True trow[Ngv].append(istr) else: trow.append(['']) trow[Ngv].append('') #create keys for HV list s = name.rsplit(' ')[0] + ' HV_' + name.rsplit('_')[1] #check for status errors if erralarm.has_key(s): trow[Ngv].append(errlist[s].rsplit('{')[1].rsplit('}')[0]) trow[Ngv].append(erralarm[s]) else: trow[Ngv].append('') trow[Ngv].append('') #create potential keys for the gate valves s = name.rsplit(' ')[0] + ' GV_' + name.rsplit('_')[1] #check for closed gate valves if gvalarm.has_key(s): trow[Ngv].append(gvlist[s].rsplit('{')[1].rsplit('}')[0]) trow[Ngv].append(gvalarm[s]) if gvalarm[s] == ee_str: if int(name.rsplit(' ')[0]) == 0: fflag_fe = True elif int(name.rsplit(' ')[0]) < 8: wflag_a = True elif int(name.rsplit(' ')[0]) < 11: wflag_b = True else: wflag_d = True else: trow[Ngv].append('') trow[Ngv].append('') s = name.rsplit(' ')[0] + ' FL_' + name.rsplit('_')[1] if flowalarm.has_key(s): trow[Ngv].append( flowlist[s][0].rsplit('{')[1].rsplit('}')[0]) alarm = flowalarm[s] if alarm == ok_str: istr = oktext("%4.2f" % ID05flow.get(flowlist[s][0])) elif alarm == ww_str: istr = wwtext("%4.2f" % ID05flow.get(flowlist[s][0])) else: istr = eetext("%4.2f" % ID05flow.get(flowlist[s][0])) fflag_a = True trow[Ngv].append(istr) else: trow[Ngv].append('') trow[Ngv].append('') s = name.rsplit(' ')[0] + ' T_' + name.rsplit('_')[1] if talarm.has_key(s): trow[Ngv].append(tlist[s][0].rsplit('{')[1].rsplit('}')[0]) alarm = talarm[s] if tlist[s][0] == 'XF:05IDA-OP:1{Msk:1}T:TU-I': ivalue = tobj.avgm1u() elif tlist[s][0] == 'XF:05IDA-OP:1{Slt:1U}T:TU-I': ivalue = tobj.avgwbslu() else: ivalue = tobj.temp.get(tlist[s][0]) if alarm == ok_str: istr = oktext("%6.1f" % ivalue) elif alarm == ww_str: istr = wwtext("%6.1f" % ivalue) else: istr = eetext("%6.1f" % ivalue) fflag_a = True trow[Ngv].append(istr) else: trow[Ngv].append('') trow[Ngv].append('') Ngv = Ngv + 1 table = terminaltables.UnixTable(trow) # sys.stdout.write(table.table) if shalarm[ '00'] == ee_str and fflag_fe == False and wflag_fe == False: fflag_fe = True if shalarm[ '07'] == ee_str and fflag_b == False and wflag_b == False: fflag_b = True if shalarm[ '12'] == ee_str and fflag_d == False and wflag_d == False: fflag_d = True nrow = list() if fflag_fe == True: nrow.append(eetext('FRONT END')) else: nrow.append(oktext('FRONT END')) if fflag_a == True: nrow.append(eetext('HUTCH A')) elif wflag_a == True: nrow.append(wwtext('HUTCH A')) else: nrow.append(oktext('HUTCH A')) if fflag_b == True: nrow.append(eetext('HUTCH B')) elif wflag_b == True: nrow.append(wwtext('HUTCH B')) else: nrow.append(oktext('HUTCH B')) if fflag_d == True: nrow.append(eetext('HUTCH D')) elif wflag_d == True: nrow.append(wwtext('HUTCH D')) else: nrow.append(oktext('HUTCH D')) istr = '\n\t\t' for i in range(0, len(nrow)): istr = istr + nrow[i] + '\t\t\t' istr = istr + '\t' # sys.stdout.write(istr) # sys.stdout.flush() msg = table.table + istr if options.snap == True: print msg break sys.stdout.write(msg) sys.stdout.flush() epics.poll(evt=1.e-3, iot=0.1) if (time.time() - t_old) > 30.: t_old = time.time() pending_update = True