def _start_aquisition(self): print "start triggered" #AQ = AcquisitionThread(DATA) """ Callback of the "start stop acquisition" button. This starts the acquisition thread, or kills it/ """ if self.acquisition_thread and self.acquisition_thread.isAlive(): self.data.wants_abort = True else: # connect the function calls self.m_poll.setEnabled(True) self.acquisition_thread = AcquisitionThread(self.data) self.acquisition_thread.update_sig.connect(self._update_gui) self.acquisition_thread.start()
def _start_aquisition(self): #AQ = AcquisitionThread(DATA) """ Callback of the "start stop acquisition" button. This starts the acquisition thread, or kills it/ """ if self.acquisition_thread and self.acquisition_thread.isAlive(): self.data.wants_abort = True else: # connect the function calls self.acquisition_thread = AcquisitionThread(self.data) self.acquisition_thread.T_sig.connect(self._update_Temp) self.acquisition_thread.H_sig.connect(self._update_Heat) self.acquisition_thread.E_sig.connect(self._update_Error) self.acquisition_thread.T_sig.connect(self.T_field.setValue) self.acquisition_thread.H_sig.connect(self.H_field.setValue) self.acquisition_thread.R_sig.connect(self.R_field.setValue) self._update_PID_from_remote() self._update_SET_temperature() self.acquisition_thread.start()
class MainWindow(QMainWindow, Ui_MainWindow): # custom slot def myquit(self): exit() def __init__(self,data): self.data = data QMainWindow.__init__(self) # set up User Interface (widgets, layout...) self.setupUi(self) #self.menubar.setNativeMenuBar(False) self._setup_signal_slots() self._setup_views() self.acquisition_thread =False self.data.T = [numpy.zeros(10) for _ in range (5)] self.data.times = [numpy.zeros(10) for _ in range (5)] def _setup_signal_slots(self): QObject.connect(self.actionStart,SIGNAL("triggered()"),self._start_aquisition) QObject.connect(self.b_auto,SIGNAL("triggered()"),self._autorange_plots) QObject.connect(self.b_24,SIGNAL("triggered()"),self._range_24) QObject.connect(self.b_12,SIGNAL("triggered()"),self._range_12) QObject.connect(self.b_6,SIGNAL("triggered()"),self._range_6) QObject.connect(self.b_2,SIGNAL("triggered()"),self._range_2) QObject.connect(self.b_1,SIGNAL("triggered()"),self._range_1) QObject.connect(self.m_poll,SIGNAL("triggered()"),self._req_meas) QObject.connect(self.actionQuit,SIGNAL("triggered()"),self._quit_tip_gui) QObject.connect(self,SIGNAL("destroyed()"),self._quit_tip_gui) def _setup_views(self): self.Temp_view1.setLabel('left',"He-Bath / K") self.Temp_view1.setLabel('bottom',"Time") self.Temp_view1.plt = self.Temp_view1.plot(pen='y') self.Temp_view2.setLabel('left',"1K Pot / K") self.Temp_view2.setLabel('bottom',"Time") self.Temp_view2.plt = self.Temp_view2.plot(pen='y') self.Temp_view3.setLabel('left',"Still / K") self.Temp_view3.setLabel('bottom',"Time") self.Temp_view3.plt = self.Temp_view3.plot(pen='y') self.Temp_view4.setLabel('left',"Base / K") self.Temp_view4.setLabel('bottom',"Time") self.Temp_view4.plt = self.Temp_view4.plot(pen='y') self.Temp_view5.setLabel('left',"Intermediate / K") self.Temp_view5.setLabel('bottom',"Time") self.Temp_view5.plt = self.Temp_view5.plot(pen='y') def _update_newT(self,T): pass def _quit_tip_gui(self): self.data.wants_abort = True sleep(0.5) exit() def _start_aquisition(self): print "start triggered" #AQ = AcquisitionThread(DATA) """ Callback of the "start stop acquisition" button. This starts the acquisition thread, or kills it/ """ if self.acquisition_thread and self.acquisition_thread.isAlive(): self.data.wants_abort = True else: # connect the function calls self.m_poll.setEnabled(True) self.acquisition_thread = AcquisitionThread(self.data) self.acquisition_thread.update_sig.connect(self._update_gui) self.acquisition_thread.start() def _autorange_plots(self): for i in range(5): exec("self.Temp_view%i.enableAutoRange()"%(i+1)) def _range_plots(self,rang): for i in range(5): yRange= [numpy.min(self.data.T[i][numpy.where((self.data.times[i][-1]-self.data.times[i])<rang*3600)]),numpy.max(self.data.T[i][numpy.where((self.data.times[i][-1]-self.data.times[i])<rang*3600)])] exec("self.Temp_view%i.setRange(xRange=[-rang,0],yRange=yRange)"%(i+1)) def _range_24(self): self._range_plots(24) def _range_12(self): self._range_plots(12) def _range_6(self): self._range_plots(6) def _range_2(self): self._range_plots(2) def _range_1(self): self._range_plots(1) def _req_meas(self): self.acquisition_thread.acquire_from_remote("set/therm/:/schedule",delay=.2) @pyqtSlot(float) def _update_gui(self): self.Temp_view1.plt.setData(x=(self.data.times[0]-self.data.times[0][-1])/3600, y=self.data.T[0]) self.Temp_view2.plt.setData(x=(self.data.times[1]-self.data.times[1][-1])/3600, y=self.data.T[1]) self.Temp_view3.plt.setData(x=(self.data.times[2]-self.data.times[2][-1])/3600, y=self.data.T[2]) self.Temp_view4.plt.setData(x=(self.data.times[3]-self.data.times[3][-1])/3600, y=self.data.T[3]) self.Temp_view5.plt.setData(x=(self.data.times[4]-self.data.times[4][-1])/3600, y=self.data.T[4]) self.T1a_field.setSuffix(" "+("m" if self.data.T[0][-1]<.8 else "")+"K") self.T1a_field.setValue(self.data.T[0][-1]*(1e3 if self.data.T[0][-1]<.8 else 1 )) self.T2_field.setSuffix(" "+("m" if self.data.T[1][-1]<.8 else "")+"K") self.T2_field.setValue(self.data.T[1][-1]*(1e3 if self.data.T[1][-1]<.8 else 1 )) self.T3_field.setSuffix(" "+("m" if self.data.T[2][-1]<.8 else "")+"K") self.T3_field.setValue(self.data.T[2][-1]*(1e3 if self.data.T[2][-1]<.8 else 1 )) self.T4_field.setSuffix(" "+("m" if self.data.T[3][-1]<.8 else "")+"K") self.T4_field.setValue(self.data.T[3][-1]*(1e3 if self.data.T[3][-1]<.8 else 1 )) self.T5_field.setSuffix(" "+("m" if self.data.T[4][-1]<.8 else "")+"K") self.T5_field.setValue(self.data.T[4][-1]*(1e3 if self.data.T[4][-1]<.8 else 1 ))
class MainWindow(QMainWindow, Ui_MainWindow): # custom slot def myquit(self): exit() def __init__(self,data): self.data = data QMainWindow.__init__(self) # set up User Interface (widgets, layout...) self.setupUi(self) #self.menubar.setNativeMenuBar(False) self._setup_signal_slots() self._setup_views() self.acquisition_thread =False self.Temps =numpy.zeros(100) self.Errors=numpy.zeros(100) self.Heats = numpy.zeros(100) self.times = numpy.arange(100,0,-1) def _setup_signal_slots(self): QObject.connect(self.newT_SpinBox,SIGNAL("valueChanged(double)"),self._update_newT) QObject.connect(self.P_SpinBox,SIGNAL("valueChanged(double)"),self._update_P) QObject.connect(self.I_SpinBox,SIGNAL("valueChanged(double)"),self._update_I) QObject.connect(self.D_SpinBox,SIGNAL("valueChanged(double)"),self._update_D) QObject.connect(self.Start,SIGNAL("released()"),self._start_aquisition) QObject.connect(self.Quit,SIGNAL("released()"),self._quit_tip_gui) def _setup_views(self): self.Temp_view.setLabel('left',"Temperature / K") self.Temp_view.setLabel('bottom',"Time") self.Temp_view.plt = self.Temp_view.plot(pen='y') self.Heat_view.setLabel('left',"Heat / uW") self.Heat_view.setLabel('bottom',"Time") self.Heat_view.plt = self.Heat_view.plot(pen='y') self.Error_view.setLabel('left',"Error / uK ") self.Error_view.setLabel('bottom',"Time") self.Error_view.plt = self.Error_view.plot(pen='y') #for i in range(3): # self.Temp_view.plot(x, y[i], pen=(i,3)) def _update_newT(self,T): #print "new T:",T #print self.newT_SpinBox.value() rc = remote_client(self.data) rc.send("set T "+str(T)) if not int(rc.recv().strip()) == 1: raise Error("communication error") rc.close() def _quit_tip_gui(self): self.data.wants_abort = True sleep(0.5) exit() def _start_aquisition(self): #AQ = AcquisitionThread(DATA) """ Callback of the "start stop acquisition" button. This starts the acquisition thread, or kills it/ """ if self.acquisition_thread and self.acquisition_thread.isAlive(): self.data.wants_abort = True else: # connect the function calls self.acquisition_thread = AcquisitionThread(self.data) self.acquisition_thread.T_sig.connect(self._update_Temp) self.acquisition_thread.H_sig.connect(self._update_Heat) self.acquisition_thread.E_sig.connect(self._update_Error) self.acquisition_thread.T_sig.connect(self.T_field.setValue) self.acquisition_thread.H_sig.connect(self.H_field.setValue) self.acquisition_thread.R_sig.connect(self.R_field.setValue) self._update_PID_from_remote() self._update_SET_temperature() self.acquisition_thread.start() def _update_P(self,P): self.data.P = P self._update_PID() #print self.P_SpinBox.value() def _update_I(self,I): self.data.I = I self._update_PID() def _update_D(self,D): self.data.D = D self._update_PID() def _update_PID(self): rc = remote_client(self.data) rc.send("set PID %.5f %.5f %.5f"% (self.data.P,self.data.I,self.data.D)) if not int(rc.recv().strip()) == 1: raise Error("communication error") rc.close() def _update_PID_from_remote(self): rc = remote_client(self.data) rc.send("GET PID") pid_str=rc.recv().split() rc.close() self.data.P = float(pid_str[0]) self.data.I = float(pid_str[1]) self.data.D = float(pid_str[2]) self.P_SpinBox.setValue(self.data.P) self.I_SpinBox.setValue(self.data.I) self.D_SpinBox.setValue(self.data.D) def _update_SET_temperature(self): rc = remote_client(self.data) rc.send("GET TCTRL") self.data.set_T = float(rc.recv()) rc.close() self.newT_SpinBox.setValue(self.data.set_T) @pyqtSlot(float) def _update_Temp(self,Temp): self.Temps = numpy.delete(numpy.append(self.Temps,Temp*1e3),0) self.Temp_view.plt.setData(x=self.times, y=self.Temps)#, pen=(1,3)) @pyqtSlot(float) def _update_Heat(self,Heat): self.Heats = numpy.delete(numpy.append(self.Heats,Heat*1e6),0) self.Heat_view.plt.setData(self.times, self.Heats)#, pen=(1,3)) @pyqtSlot(float) def _update_Error(self,Error): self.Errors=numpy.delete(numpy.append(self.Errors,Error*1e6),0) self.Error_view.plt.setData(self.times, self.Errors) def _update_gui_values(self,T,R,Heat,Tctrl): #print T self.T_field.setValue(T) self.R_field.setValue(R) self.H_field.setValue(Heat*1e6)