def run(self): self.queuestarttime=None while True: resultstr=initcommand(self.app.options,["stat"],self.app.netconf) result=json.loads(resultstr) time.sleep(1) if 'start time' in result['data']["stat"]: starttime=result['data']["stat"]['start time'] if self.queuestarttime and self.queuestarttime!=starttime: self.emit(QtCore.SIGNAL('ServerQueueTimeChanged()')) self.queuestarttime=starttime if ( 'images processed' in result['data']["stat"]): fresh=False if(result['data']["stat"]['images processed']!=self.lastcount): self.lastcount=result['data']["stat"]['images processed'] plotdata=initcommand(self.app.options,["plotdata"],self.app.netconf) self.emit(QtCore.SIGNAL('plotdata(QString)'), plotdata) else: self.emit(QtCore.SIGNAL('histupdate(QString)'),resultstr) if ( 'mergecount' in result['data']["stat"]): if(result['data']["stat"]['mergecount']!=self.lastmergecount): self.lastmergecount=result['data']["stat"]['mergecount'] mergedata=initcommand(self.app.options,["getmergedata"],self.app.netconf) self.emit(QtCore.SIGNAL('mergeresultdata(QString)'), mergedata) print("getmergedata") elif result["result"]=="Error": self.emit(QtCore.SIGNAL('ProtocolError(QString)'), plotdata)
def run(self): self.queuestarttime=None while True: resultstr=initcommand(self.app.options,["stat"],self.app.netconf) result=json.loads(resultstr) time.sleep(1) if 'start time' in result['data']["stat"]: starttime=result['data']["stat"]['start time'] if self.queuestarttime and self.queuestarttime!=starttime: self.emit(QtCore.SIGNAL('ServerQueueTimeChanged()')) self.queuestarttime=starttime if ( 'images processed' in result['data']["stat"]): fresh=False if(result['data']["stat"]['images processed']!=self.lastcount): self.lastcount=result['data']["stat"]['images processed'] plotdata=initcommand(self.app.options,["plotdata"],self.app.netconf) self.emit(QtCore.SIGNAL('plotdata(QString)'), plotdata) else: self.emit(QtCore.SIGNAL('histupdate(QString)'),resultstr) if ( 'mergecount' in result['data']["stat"]): if(result['data']["stat"]['mergecount']!=self.lastmergecount): self.lastmergecount=result['data']["stat"]['mergecount'] mergedata=initcommand(self.app.options,["getmergedata"],self.app.netconf) self.emit(QtCore.SIGNAL('mergeresultdata(QString)'), mergedata) print "getmergedata" elif result["result"]=="Error": self.emit(QtCore.SIGNAL('ProtocolError(QString)'), plotdata)
def run(self): while True: resultstr=initcommand(self.app.options,["stat"],self.app.netconf) result=json.loads(resultstr) time.sleep(1) if result['data']["stat"]['images processed']!=self.lastcount: self.lastcount=result['data']["stat"]['images processed'] plotdata=result=initcommand(self.app.options,["plotdata"],self.app.netconf) self.emit(QtCore.SIGNAL('plotdata(QString)'), plotdata) else: self.emit(QtCore.SIGNAL('histupdate(QString)'),resultstr)
def run(self): while True: resultstr = initcommand(self.app.options, ["stat"], self.app.netconf) result = json.loads(resultstr) time.sleep(1) if result['data']["stat"]['images processed'] != self.lastcount: self.lastcount = result['data']["stat"]['images processed'] plotdata = result = initcommand(self.app.options, ["plotdata"], self.app.netconf) self.emit(QtCore.SIGNAL('plotdata(QString)'), plotdata) else: self.emit(QtCore.SIGNAL('histupdate(QString)'), resultstr)
def run(self): argu=["get"] opt=atrdict.AttrDict({"serverno":None,"server":self.conf["Server"]}) result=initcommand( opt,argu,self.conf ) print result self.emit( SIGNAL('connected(QString)') ,result)
def run(self): argu = ["get"] opt = atrdict.AttrDict({ "serverno": None, "server": self.conf["Server"] }) result = initcommand(opt, argu, self.conf) print result self.emit(SIGNAL('connected(QString)'), result)
def rereaddir(self): import atrdict conf=json.load(open(os.path.expanduser("~"+os.sep+".saxsdognetwork"))) argu=["readdir"] result=initcommand(self.options,argu,conf) self.log("reread directory") msgBox=QMessageBox(self) msgBox.setText( result); msgBox.exec_();
def __init__(self,app,parent,index,showfiles=False): super(RemoteDirPicker, self).__init__( parent) myrow= index.row() parentitem=index.model().itemFromIndex(index.parent()) dirs=[] for row in range(myrow): diritem= parentitem.child(row,1) dirs.append(unicode(diritem.data( QtCore.Qt.DisplayRole).toString())) argu=["listdir", os.sep.join(dirs)] result=json.loads( initcommand(app.options,argu,app.netconf)) self.addItem(".") if 'dircontent' in result['data']: for dir in result['data']['dircontent']: if dir['isdir'] or showfiles : self.addItem(dir['path'])
def __init__(self, app, parent, index): super(RemoteDirPicker, self).__init__(parent) myrow = index.row() parentitem = index.model().itemFromIndex(index.parent()) dirs = [] for row in range(myrow): diritem = parentitem.child(row, 1) dirs.append(unicode( diritem.data(QtCore.Qt.DisplayRole).toString())) argu = ["listdir", os.sep.join(dirs)] result = json.loads(initcommand(app.options, argu, app.netconf)) self.addItem(".") if 'dircontent' in result['data']: for dir in result['data']['dircontent']: if dir['isdir']: self.addItem(dir['path'])
def run(self): print "############Check Server Calib"+ str(self.app.netconf) ServerCalib=json.loads(initcommand(self.app.options,["get"],self.app.netconf)) LocalCalib=json.loads(json.dumps(self.app.calibeditor.model.getjson())) json.dump(ServerCalib["data"]["cal"],open("server","w"),indent=2,sort_keys=True)# json.dump(LocalCalib,open("local","w"),indent=2,sort_keys=True) hash1=hashlib.sha1() hash2=hashlib.sha1() hash1.update(json.dumps(ServerCalib["data"]["cal"],sort_keys=True)) hash2.update(json.dumps(LocalCalib,sort_keys=True)) # hash attachments if True: for attachment in ServerCalib["data"]['attachments']: hash1.update( attachment['data']) for mask in LocalCalib["Masks"]: hash2.update(base64.b64encode(open(mask["MaskFile"],"rb").read())) if hash1.hexdigest()!=hash2.hexdigest(): self.emit(QtCore.SIGNAL("ServerQueueChanged(QString)"),json.dumps(ServerCalib))
def fillbox(self, box, path, selected="-"): currentdirname = os.path.dirname(path) argu = ["listdir", os.sep.join(path.split(os.sep))] result = json.loads(initcommand(self.options, argu, self.netconf)) i = 1 box.blockSignals(True) box.clear() box.addItem("-") box.setCurrentIndex(0) if 'dircontent' in result['data']: for dir in result['data']['dircontent']: if dir['isdir']: box.addItem(dir['path']) if dir['path'] == selected: box.setCurrentIndex(i) i = i + 1 box.blockSignals(False)
def fillbox(self,box,path,selected="-"): currentdirname=os.path.dirname(path) argu=["listdir",os.sep.join(path.split(os.sep))] result=json.loads( initcommand(self.options,argu,self.netconf)) i=1 box.blockSignals(True) box.clear() box.addItem("-") box.setCurrentIndex(0) if 'dircontent' in result['data']: for dir in result['data']['dircontent']: if dir['isdir']: box.addItem(dir['path']) if dir['path']==selected: box.setCurrentIndex(i) i=i+1 box.blockSignals(False)
def commandnew(self): if self.data.cal: filename="tempcalfile" fh=open(filename,"w") json.dump(self.data.cal,fh) fh.close() conf=json.load(open(os.path.expanduser("~"+os.sep+".saxsdognetwork"))) argu=["new", filename,self.data.cal["MaskFile"], self.directorypicker.getdirlist() ,self.ui.Threads.value() ] try: result=initcommand(self.options,argu,conf) except Exception as e: self.errmsg.showMessage(str(e)) self.ui.pushButtonnew.setText("Restart Queue with Changed Calibration") self.plotworker.start() self.log("New calibration loaded onto server.") os.remove(filename) else: dialog=QErrorMessage(self) dialog.showMessage("Load file first")
def closequeue(self): argu=["close"] conf=json.load(open(os.path.expanduser("~"+os.sep+".saxsdognetwork"))) result=initcommand(self.options,argu,conf) QMessageBox(self).about(self,"closed",result)
def run(self): """ special method of Qtread subclass. this is caled when the .start() method is called to initiate the thread. """ self.ax = self.mw.figure.add_subplot(111) self.axhist=self.mw.figurehist.add_subplot(111) #try: if True: conf=json.load(open(os.path.expanduser("~"+os.sep+".saxsdognetwork"))) argu=["plotdata"] result=initcommand(self.options,argu,conf) time.sleep(.1) # plot data object=json.loads(result) if object['result']=="Empty": pass else: self.ax.cla() self.ax.set_ylabel('Intensity [counts/pixel]') self.ax.set_xlabel('q [1/nm]') data=np.array(object['data']['array']).transpose() data[data==0]=np.NaN skip=0 clip=1 clipat=0 self.ax.plot(data[skip:-clip,0],data[skip:-clip,1]) self.ax.fill_between( data[skip:-clip,0] , np.clip(data[skip:-clip,1]-data[skip:-clip,2],clipat,1e300), np.clip(data[skip:-clip,1]+data[skip:-clip,2],clipat,1e300), facecolor='blue' ,alpha=0.2,linewidth=0,label="Count Error") self.ax.set_title(object['data']['filename']) self.ax.set_yscale(self.yscale) self.axhist.cla() self.axhist.set_ylabel('Rate [/s]') self.axhist.set_xlabel('Time [s]') stat=object['data']["stat"] self.mw.data.stat=stat timeinterval=stat['time']- self.lasttime picsprocessedinintervall=stat['images processed']- self.lastcount rate=float(picsprocessedinintervall)/timeinterval if self.lastcount==0: picsprocessedinintervall=0 rate=0 self.lastcount=stat['images processed'] self.lasttime=stat['time'] self.mw.data.rate[0]= rate self.mw.data.stat["rate"]=rate self.mw.data.time[0]= stat['time'] - self.starttime self.mw.data.time=np.roll(self.mw.data.time,-1) self.mw.data.rate=np.roll(self.mw.data.rate,-1) plottime=self.mw.data.time-self.mw.data.time.max() self.axhist.plot(plottime,self.mw.data.rate,lw=2) self.axhist.fill_between(plottime,0,self.mw.data.rate,alpha=0.4) self.axhist.set_ylim( [0,np.max([np.max(self.mw.data.rate),1])]) self.axhist.set_xlim( [np.min(plottime),np.max(plottime)+1]) time.sleep(.1) # refresh canvas #except Exception as e: #print e self.emit( SIGNAL('update(QString)'), "data plotted" )