def update_clicked(self): xtalcmd = SpecCommand.SpecCommandA('', 'corvette.cars.aps.anl.gov:6789') Dist = self.T1.text() cmdcon0 = 'BMCPilatusDist = ' + Dist eval("xtalcmd.executeCommand(\"%s\")" % cmdcon0) time.sleep(0.2) beamX = self.T2.text() cmdcon1 = 'BMCPilatusBeamX = ' + beamX eval("xtalcmd.executeCommand(\"%s\")" % cmdcon1) time.sleep(0.2) beamY = self.T3.text() cmdcon2 = 'BMCPilatusBeamY = ' + beamY eval("xtalcmd.executeCommand(\"%s\")" % cmdcon2) time.sleep(0.2) if self.R2.isChecked() == True: cmdcon3 = 'TIFCBF = 1' xtalcmd.executeCommand(cmdcon3) else: cmdcon3 = 'TIFCBF = 0' xtalcmd.executeCommand(cmdcon3) CrysTxt = 'APEX parameters have been written.\nCrysAlis parameters are:\nDetectorDist = ' CrysTxt = CrysTxt + Dist + '\nX0 = ' CrysTxt = CrysTxt + str(float(beamX) + 32.0) + '\nY0= ' CrysTxt = CrysTxt + str(1044.0 - float(beamY)) self.CrysAlis.setText(CrysTxt)
def DataColl(self, Delt, Nu, KphiS, KphiE, StpN, TimNE): flgon = 1 flgon = self.epicswarning(self.Delt, self.warn1, '13BMC:m37', flgon) flgon = self.epicswarning(self.Nu, self.warn2, '13BMC:m38', flgon) flgon = self.epicswarning(self.KphiStart, self.warn3, '13BMC:m33', flgon) flgon = self.epicswarning(self.KphiEnd, self.warn4, '13BMC:m33', flgon) flgon = self.stepwarning(self.StpN, self.warn5, flgon) flgon = self.speedwarning(self.TimperFrm, self.warn6, self.KphiStart, self.KphiEnd, self.StpN, flgon) if flgon: self.Detmov(Delt, Nu) xtalcmd = SpecCommand.SpecCommandA( '', 'corvette.cars.aps.anl.gov:6789') kphivelo = epics.caget('13BMC:m33.VELO') kphiini = epics.caget('13BMC:m33.VAL') cmdcon = "xtal kphi " + KphiS.text() + ' ' + KphiE.text( ) + ' ' + StpN.text() + ' ' + TimNE.text() eval("xtalcmd.executeCommand(\"%s\")" % cmdcon) Ttem = np.abs(kphiini - float(KphiS.text())) / kphivelo + float( TimNE.text()) * float(StpN.text()) + 3 time.sleep(Ttem) if (int(StpN.text()) > 1) and (self.SUMCK.isChecked() == True): time.sleep(2) DummyPath = SpecVariable.SpecVariable( 'SCANLOG_PATH', 'corvette.cars.aps.anl.gov:6789').getValue() DummyN = SpecVariable.SpecVariable( 'SCAN_N', 'corvette.cars.aps.anl.gov:6789').getValue() DumS = 'S' + (3 - len(str(DummyN))) * '0' + str(DummyN) + '/' L = re.split('/', DummyPath) # For Win7 system # FL = 'T:/'+ L[5]+'/'+ L[6]+'/'+ L[7]+'/'+ L[8]+'/'+ L[9]+'/'+ L[10]+'/'+ L[11]+'/images/'+ L[13]+'/'+DumS # For Win10 system FL = '//cars5/data/' + L[5] + '/' + L[6] + '/' + L[ 7] + '/' + L[8] + '/' + L[9] + '/' + L[10] + '/' + L[ 11] + '/images/' + L[13] + '/' + DumS files = [] # r=root, d=directories, f = files for r, d, f in os.walk(FL): for file in f: if '.cbf' in file: files.append(os.path.join(r, file)) elif '.tif' in file: files.append(os.path.join(r, file)) img = fabio.open(files[0]) for file in files[1:]: data = fabio.open(file).data img.data = img.data + data for xi in range(1043): for xj in range(981): if img.data[xi, xj] < 0: img.data[xi, xj] = -1 IML = FL + 'sum.cbf' img.write(IML) self.lastscan(self.LogL1, 'templog.txt')
def newsample(self, newsample): SamNam = newsample.text() self.warn7.setText('') if (SamNam.find('_')!=-1) or (SamNam.find('/')!=-1) or (SamNam.find('.')!=-1) or (SamNam.find(' ')!=-1): self.warn7.setText('Invalid symbol: _ / . space') else: xtalcmd = SpecCommand.SpecCommandA('','corvette.cars.aps.anl.gov:6780') cmdcon = 'newsample '+SamNam eval("xtalcmd.executeCommand(\"%s\")" % cmdcon) time.sleep(0.2) self.nextscan(self.LogL1, 'templog.txt')
def Detmov(self, widget1, widget2): strX = widget1.text() strY = widget2.text() dl1 = float(strX) nu1 = float(strY) dl0 = epics.caget('13BMC:m37.RBV') nu0 = epics.caget('13BMC:m38.RBV') dlV = epics.caget('13BMC:m37.VELO') nuV = epics.caget('13BMC:m38.VELO') epics.caput('13BMC:m37.VAL',dl1) epics.caput('13BMC:m38.VAL',nu1) Ttem = max(np.abs(dl1-dl0)/dlV,np.abs(nu1-nu0)/nuV)+4.0 time.sleep(Ttem) xtalcmd = SpecCommand.SpecCommandA('','corvette.cars.aps.anl.gov:6780') eval("xtalcmd.executeCommand(\"%s\")" % 'wh') time.sleep(2)
MajorPath = SpecVariable.SpecVariable( 'STARTUP_PROJECT_PATH', 'corvette.cars.aps.anl.gov:6789').getValue() len1 = len(MajorPath + "scandata/") dummy = LogPath[len1:-1] cmdcon = time.asctime( ) + '\n New data will be saved in folder: ' + dummy + '\n' f = open(tempfile, 'a+') dummy2 = f.read() f.close() os.remove(tempfile) dummy3 = cmdcon + dummy2 f = open(tempfile, 'a+') f.write(dummy3) f.close() widget1.setText(dummy3) if __name__ == "__main__": xtalcmd = SpecCommand.SpecCommandA('', 'corvette.cars.aps.anl.gov:6789') eval("xtalcmd.executeCommand(\"%s\")" % 'wh') try: os.remove('templog.txt') except: pass time.sleep(0.3) app = QtWidgets.QApplication(sys.argv) mainWindow = mainUI() mainWindow.show() sys.exit(app.exec_())