def __init__(self, device=None): QWidget.__init__(self) self.p = device # connection to the device hardware self.resultCols = utils.makeResultColors() self.traceCols = utils.makeTraceColors() self.htmlColors = utils.makeHtmlColors() self.pwin = pg.PlotWidget() # pyqtgraph window self.pwin.showGrid(x=True, y=True) # with grid ax = self.pwin.getAxis('bottom') ax.setLabel(self.tr('Time (mS)')) ax = self.pwin.getAxis('left') ax.setLabel(self.tr('Voltage(V)')) self.pwin.disableAutoRange() self.pwin.setXRange(self.TMIN, self.TMAX) self.pwin.setYRange(self.VMIN, self.VMAX) self.pwin.hideButtons() # Do not show the 'A' button of pg for ch in range(self.MAXCHAN): self.traces[ch] = self.pwin.plot([0,0],[0,0], pen = self.traceCols[ch]) right = QVBoxLayout() # right side vertical layout right.setAlignment(Qt.AlignTop) right.setSpacing(self.RPGAP) H = QHBoxLayout() l = QLabel(text=self.tr('Total Duration')) l.setMaximumWidth(100) H.addWidget(l) self.TMAXtext = utils.lineEdit(40, self.TMAX, 6, None) H.addWidget(self.TMAXtext) l = QLabel(text=self.tr('Seconds')) l.setMaximumWidth(60) H.addWidget(l) right.addLayout(H) H = QHBoxLayout() l = QLabel(text=self.tr('Measure every')) l.setMaximumWidth(100) H.addWidget(l) self.TGAPtext = utils.lineEdit(40, self.TGAP, 6, None) H.addWidget(self.TGAPtext) l = QLabel(text=self.tr('Seconds')) l.setMaximumWidth(60) H.addWidget(l) right.addLayout(H) for ch in range(self.MAXCHAN): H = QHBoxLayout() H.setAlignment(Qt.AlignLeft) self.chanSelCB[ch] = QCheckBox() #self.chanSelCB[ch].stateChanged.connect(partial (self.select_channel,ch)) H.addWidget(self.chanSelCB[ch]) l = QLabel(text='<font color="%s">%s' %(self.htmlColors[ch],self.sources[ch])) l.setMaximumWidth(30) l.setMinimumWidth(30) H.addWidget(l) right.addLayout(H) self.chanSelCB[0].setChecked(True) b = QPushButton(self.tr("Start")) right.addWidget(b) b.clicked.connect(self.start) b = QPushButton(self.tr("Stop")) right.addWidget(b) b.clicked.connect(self.stop) b = QPushButton(self.tr("Clear Traces")) right.addWidget(b) b.clicked.connect(self.clear) self.SaveButton = QPushButton(self.tr("Save Data")) self.SaveButton.clicked.connect(self.save_data) right.addWidget(self.SaveButton) #------------------------end of right panel ---------------- top = QHBoxLayout() top.addWidget(self.pwin) top.addLayout(right) full = QVBoxLayout() full.addLayout(top) self.msgwin = QLabel(text=self.tr('')) full.addWidget(self.msgwin) self.setLayout(full) self.timer = QTimer() self.timer.timeout.connect(self.update) self.timer.start(self.TIMER)
def __init__(self, device=None): QWidget.__init__(self) self.resultCols = utils.makeResultColors() self.traceCols = utils.makeTraceColors() self.htmlColors = utils.makeHtmlColors() self.p = device # connection to the device hardware self.chanStatus = [1,0,0,0] # PyQt problem. chanStatus somehow getting preserved ??? left = QVBoxLayout() # right side vertical layout for ch in range(self.MAXCHAN): self.offSliders[ch] = utils.sliderVert(-4, 4, 0, 40, None) left.addWidget(self.offSliders[ch]) self.offSliders[ch].valueChanged.connect(partial (self.set_offset,ch)) self.offSliders[ch].setStyleSheet("border: 1px solid %s;"%self.htmlColors[ch]) win = pg.GraphicsWindow() self.pwin = win.addPlot() self.pwin.proxy = pg.SignalProxy(self.pwin.scene().sigMouseMoved, rateLimit=60, slot=self.updateTV) self.pwin.showGrid(x=True, y=True) # with grid for k in range(self.MAXCHAN): # pg textItem to show the voltage scales self.scaleLabs[k] = pg.TextItem(text='') for k in range(self.MAXRES): # pg textItem to show the Results self.resLabs[k] = pg.TextItem() self.pwin.addItem(self.resLabs[k]) vLine = pg.InfiniteLine(angle=90, movable=False, pen = 'w') self.pwin.addItem(vLine, ignoreBounds=True) self.pwin.vLine=vLine self.pwin.vLine.setPos(-1) hLine = pg.InfiniteLine(angle=0, movable=False, pen = 'w') self.pwin.addItem(hLine, ignoreBounds=True) self.pwin.hLine=hLine self.pwin.hLine.setPos(-17) ax = self.pwin.getAxis('bottom') ax.setLabel(self.tr('Time (mS)')) ax = self.pwin.getAxis('left') ax.setStyle(showValues=False) ax.setLabel(self.tr('Voltage')) self.set_timebase(self.TBval) self.pwin.disableAutoRange() self.pwin.setXRange(0, self.tbvals[self.TBval]*10) self.pwin.setYRange(-16, 16) self.pwin.hideButtons() # Do not show the 'A' button of pg for ch in range(self.MAXCHAN): # initialize the pg trace widgets self.traceWidget[ch] = self.pwin.plot([0,0],[0,0], pen = self.traceCols[ch]) self.diffTraceW = self.pwin.plot([0,0],[0,0], pen = self.traceCols[-1]) right = QVBoxLayout() # right side vertical layout right.setAlignment(Qt.AlignTop) right.setSpacing(self.RPVspacing) l = QLabel(text= '<font color="red">' +self.tr('DC Voltages at A1, A2 and A3')) l.setMinimumWidth(self.RPWIDTH) right.addWidget(l) H = QHBoxLayout() for k in range(3): H.setAlignment(Qt.AlignLeft) self.voltMeterCB[k] = QCheckBox(self.tr(self.sources[k])) H.addWidget(self.voltMeterCB[k]) self.voltMeters[k] = QLabel() self.voltMeters[k].setMinimumWidth(50) H.addWidget(self.voltMeters[k]) right.addLayout(H) H = QHBoxLayout() l = QLabel(text=self.tr('Resistance on SEN = ')) H.addWidget(l) self.RES = QLabel() H.addWidget(self.RES) right.addLayout(H) H = QHBoxLayout() b = QPushButton(self.tr("Click for Capacitance on IN1")) b.setMinimumWidth(200) H.addWidget(b) b.clicked.connect(self.measure_cap) self.CAP = QLabel('') H.addWidget(self.CAP) right.addLayout(H) H = QHBoxLayout() b = QPushButton(self.tr("Click for Frequency on IN2")) b.setMinimumWidth(200) H.addWidget(b) b.clicked.connect(self.measure_freq) self.IN2 = QLabel('') H.addWidget(self.IN2) right.addLayout(H) H = QHBoxLayout() self.OD1 = QCheckBox(self.tr("Enable OD1")) H.addWidget(self.OD1) self.OD1.stateChanged.connect(self.control_od1) self.CCS = QCheckBox(self.tr("Enable CCS")) H.addWidget(self.CCS) self.CCS.stateChanged.connect(self.control_ccs) right.addLayout(H) H = QHBoxLayout() l = QLabel(text=self.tr('WG Shape')) H.addWidget(l) self.Wshape = QPushButton('sine') menu = QMenu() for k in range(len(self.Waves)): menu.addAction(self.Waves[k], lambda index=k: self.select_wave(index)) self.Wshape.setMenu(menu) H.addWidget(self.Wshape) l = QLabel(text=self.tr('Amplitude')) H.addWidget(l) self.Wgain = QPushButton(self.Wgains[self.wgainindex]) menu = QMenu() for k in range(len(self.Wgains)): menu.addAction(self.Wgains[k], lambda index=k: self.select_wgain(index)) self.Wgain.setMenu(menu) H.addWidget(self.Wgain) right.addLayout(H) H = QHBoxLayout() l = QLabel(text=self.tr('WG')) l.setMaximumWidth(30) H.addWidget(l) self.AWGslider = utils.slider(self.AWGmin, self.AWGmax, self.AWGval,100,self.awg_slider) H.addWidget(self.AWGslider) self.AWGtext = utils.lineEdit(100, self.AWGval, 6, self.awg_text) H.addWidget(self.AWGtext) l = QLabel(text=self.tr('Hz')) l.setMaximumWidth(40) l.setMinimumWidth(40) H.addWidget(l) right.addLayout(H) H = QHBoxLayout() l = QLabel(text=self.tr('SQ1')) l.setMaximumWidth(30) l.setMinimumWidth(30) H.addWidget(l) self.SQ1slider = utils.slider(self.SQ1min, self.SQ1max, self.SQ1val,100,self.sq1_slider) H.addWidget(self.SQ1slider) self.SQ1text = utils.lineEdit(60, self.SQ1val, 6, self.sq1_text) H.addWidget(self.SQ1text) l = QLabel(text=self.tr('Hz')) l.setMaximumWidth(15) H.addWidget(l) self.SQ1DCtext = utils.lineEdit(30, 50, 6, self.sq1_dc) H.addWidget(self.SQ1DCtext) l = QLabel(text=self.tr('%')) l.setMaximumWidth(15) H.addWidget(l) right.addLayout(H) H = QHBoxLayout() l = QLabel(text=self.tr('PV1')) l.setMaximumWidth(25) H.addWidget(l) self.PV1slider = utils.slider(self.PV1min*1000, self.PV1max*1000, self.PV1val*1000,100,self.pv1_slider) H.addWidget(self.PV1slider) self.PV1text = utils.lineEdit(100, self.PV1val, 6, self.pv1_text) H.addWidget(self.PV1text) l = QLabel(text=self.tr('Volt')) l.setMaximumWidth(40) l.setMinimumWidth(40) H.addWidget(l) right.addLayout(H) H = QHBoxLayout() l = QLabel(text=self.tr('PV2')) l.setMaximumWidth(25) H.addWidget(l) self.PV2slider = utils.slider(self.PV2min*1000, self.PV2max*1000, self.PV2val*1000,100,self.pv2_slider) H.addWidget(self.PV2slider) self.PV2text = utils.lineEdit(100, self.PV2val, 6, self.pv2_text) H.addWidget(self.PV2text) l = QLabel(text=self.tr('Volt')) l.setMaximumWidth(40) l.setMinimumWidth(40) H.addWidget(l) right.addLayout(H) #--------------------------Scope Controls--------------------- l = QLabel('<font color="red">' +self.tr('Oscilloscope Channels, Range and Analysis ')) right.addWidget(l) for ch in range(4): H = QHBoxLayout() H.setAlignment(Qt.AlignLeft) self.chanSelCB[ch] = QCheckBox() self.chanSelCB[ch].stateChanged.connect(partial (self.select_channel,ch)) H.addWidget(self.chanSelCB[ch]) l = QLabel(text='<font color="%s">%s'%(self.htmlColors[ch],self.sources[ch])) l.setMaximumWidth(30) l.setMinimumWidth(30) H.addWidget(l) self.rangeSelPB[ch] = QPushButton('4 V') self.rangeSelPB[ch].setMaximumWidth(60) menu = QMenu() if ch <= 1: for k in range(len(self.Ranges12)): menu.addAction(self.Ranges12[k], lambda index=(ch,k): self.select_range(index)) else: for k in range(len(self.Ranges34)): menu.addAction(self.Ranges34[k], lambda index=(ch,k): self.select_range(index)) self.rangeSelPB[ch].setMenu(menu) H.addWidget(self.rangeSelPB[ch]) self.fitSelCB[ch] = QCheckBox('') self.fitSelCB[ch].setMaximumWidth(30) H.addWidget(self.fitSelCB[ch]) self.fitResLab[ch] = QLabel('') H.addWidget(self.fitResLab[ch]) right.addLayout(H) self.chanSelCB[0].setChecked(True) H = QHBoxLayout() l = QLabel(text=self.tr('Timebase')) l.setMaximumWidth(60) H.addWidget(l) self.TBslider = utils.slider(0, 8, self.TBval, 180, self.set_timebase) H.addWidget(self.TBslider) l = QLabel(text=self.tr('mS/div')) l.setMaximumWidth(60) H.addWidget(l) right.addLayout(H) H = QHBoxLayout() l = QLabel(text=self.tr('Trigger')) l.setMaximumWidth(60) H.addWidget(l) self.Trigslider = utils.slider(-3300, 3300, self.Triglevel, 150, self.set_trigger) H.addWidget(self.Trigslider) l = QLabel(text=self.tr('On')) l.setMaximumWidth(30) H.addWidget(l) self.Trigbutton = QPushButton(self.tr('A1')) self.Trigbutton.setMaximumWidth(50) menu = QMenu() for k in range(len(self.sources)): menu.addAction(self.sources[k], lambda index=k :self.select_trig_source(index)) self.Trigbutton.setMenu(menu) H.addWidget(self.Trigbutton) right.addLayout(H) H = QHBoxLayout() self.SaveButton = QPushButton(self.tr("Save Traces")) #self.SaveButton.setMaximumWidth(80) self.SaveButton.clicked.connect(self.save_data) H.addWidget(self.SaveButton) #self.Filename = utils.lineEdit(100, self.tr('scope.txt'), 20, None) #H.addWidget(self.Filename) self.FFT = QPushButton(self.tr("Fourier Transform")) #self.FFT.setMaximumWidth(50) H.addWidget(self.FFT) self.FFT.clicked.connect(self.show_fft) right.addLayout(H) H = QHBoxLayout() self.Cross = QCheckBox(self.tr("Cross hair")) self.Cross.stateChanged.connect(self.cross_hair) H.addWidget(self.Cross) self.Freeze = QCheckBox(self.tr("Freeze")) H.addWidget(self.Freeze) self.Diff = QCheckBox(self.tr('A1-A2')) H.addWidget(self.Diff) self.Diff.stateChanged.connect(self.show_diff) right.addLayout(H) #------------------------end of right panel ---------------- top = QHBoxLayout() top.addLayout(left) top.addWidget(win)# self.pwin) top.addLayout(right) full = QVBoxLayout() full.addLayout(top) self.msgwin = QLabel(text=self.tr('messages')) full.addWidget(self.msgwin) self.setLayout(full) self.timer = QTimer() self.timer.timeout.connect(self.update) self.timer.start(self.TIMER) self.recover()
def __init__(self, device=None): QWidget.__init__(self) self.p = device # connection to the device hardware self.resultCols = utils.makeResultColors() self.traceCols = utils.makeTraceColors() self.htmlColors = utils.makeHtmlColors() self.pwin = pg.PlotWidget() # pyqtgraph window self.pwin.showGrid(x=True, y=True) # with grid ax = self.pwin.getAxis('bottom') ax.setLabel(self.tr('Time (mS)')) ax = self.pwin.getAxis('left') ax.setLabel(self.tr('Voltage(V)')) self.pwin.disableAutoRange() self.pwin.setXRange(self.TMIN, self.TMAX) self.pwin.setYRange(self.VMIN, self.VMAX) self.pwin.hideButtons() # Do not show the 'A' button of pg for ch in range(self.MAXCHAN): self.traces[ch] = self.pwin.plot([0, 0], [0, 0], pen=self.traceCols[ch]) right = QVBoxLayout() # right side vertical layout right.setAlignment(Qt.AlignTop) right.setSpacing(self.RPGAP) H = QHBoxLayout() l = QLabel(text=self.tr('Total Duration')) l.setMaximumWidth(100) H.addWidget(l) self.TMAXtext = utils.lineEdit(40, self.TMAX, 6, None) H.addWidget(self.TMAXtext) l = QLabel(text=self.tr('Seconds')) l.setMaximumWidth(60) H.addWidget(l) right.addLayout(H) H = QHBoxLayout() l = QLabel(text=self.tr('Measure every')) l.setMaximumWidth(100) H.addWidget(l) self.TGAPtext = utils.lineEdit(40, self.TGAP, 6, None) H.addWidget(self.TGAPtext) l = QLabel(text=self.tr('Seconds')) l.setMaximumWidth(60) H.addWidget(l) right.addLayout(H) for ch in range(self.MAXCHAN): H = QHBoxLayout() H.setAlignment(Qt.AlignLeft) self.chanSelCB[ch] = QCheckBox() #self.chanSelCB[ch].stateChanged.connect(partial (self.select_channel,ch)) H.addWidget(self.chanSelCB[ch]) l = QLabel(text='<font color="%s">%s' % (self.htmlColors[ch], self.sources[ch])) l.setMaximumWidth(30) l.setMinimumWidth(30) H.addWidget(l) right.addLayout(H) self.chanSelCB[0].setChecked(True) b = QPushButton(self.tr("Start")) right.addWidget(b) b.clicked.connect(self.start) b = QPushButton(self.tr("Stop")) right.addWidget(b) b.clicked.connect(self.stop) b = QPushButton(self.tr("Clear Traces")) right.addWidget(b) b.clicked.connect(self.clear) self.SaveButton = QPushButton(self.tr("Save Data")) self.SaveButton.clicked.connect(self.save_data) right.addWidget(self.SaveButton) #------------------------end of right panel ---------------- top = QHBoxLayout() top.addWidget(self.pwin) top.addLayout(right) full = QVBoxLayout() full.addLayout(top) self.msgwin = QLabel(text=self.tr('')) full.addWidget(self.msgwin) self.setLayout(full) self.timer = QTimer() self.timer.timeout.connect(self.update) self.timer.start(self.TIMER)
def __init__(self, device=None): QWidget.__init__(self) self.resultCols = utils.makeResultColors() self.traceCols = utils.makeTraceColors() self.htmlColors = utils.makeHtmlColors() self.p = device # connection to the device hardware self.chanStatus = [ 1, 0, 0, 0 ] # PyQt problem. chanStatus somehow getting preserved ??? left = QVBoxLayout() # right side vertical layout for ch in range(self.MAXCHAN): self.offSliders[ch] = utils.sliderVert(-4, 4, 0, 40, None) left.addWidget(self.offSliders[ch]) self.offSliders[ch].valueChanged.connect( partial(self.set_offset, ch)) self.offSliders[ch].setStyleSheet("border: 1px solid %s;" % self.htmlColors[ch]) win = pg.GraphicsWindow() self.pwin = win.addPlot() self.pwin.proxy = pg.SignalProxy(self.pwin.scene().sigMouseMoved, rateLimit=60, slot=self.updateTV) self.pwin.showGrid(x=True, y=True) # with grid for k in range(self.MAXCHAN): # pg textItem to show the voltage scales self.scaleLabs[k] = pg.TextItem(text='') for k in range(self.MAXRES): # pg textItem to show the Results self.resLabs[k] = pg.TextItem() self.pwin.addItem(self.resLabs[k]) vLine = pg.InfiniteLine(angle=90, movable=False, pen='w') self.pwin.addItem(vLine, ignoreBounds=True) self.pwin.vLine = vLine self.pwin.vLine.setPos(-1) hLine = pg.InfiniteLine(angle=0, movable=False, pen='w') self.pwin.addItem(hLine, ignoreBounds=True) self.pwin.hLine = hLine self.pwin.hLine.setPos(-17) ax = self.pwin.getAxis('bottom') ax.setLabel(self.tr('Time (mS)')) ax = self.pwin.getAxis('left') ax.setStyle(showValues=False) ax.setLabel(self.tr('Voltage')) self.set_timebase(self.TBval) self.pwin.disableAutoRange() self.pwin.setXRange(0, self.tbvals[self.TBval] * 10) self.pwin.setYRange(-16, 16) self.pwin.hideButtons() # Do not show the 'A' button of pg for ch in range(self.MAXCHAN): # initialize the pg trace widgets self.traceWidget[ch] = self.pwin.plot([0, 0], [0, 0], pen=self.traceCols[ch]) self.diffTraceW = self.pwin.plot([0, 0], [0, 0], pen=self.traceCols[-1]) right = QVBoxLayout() # right side vertical layout right.setAlignment(Qt.AlignTop) right.setSpacing(self.RPVspacing) l = QLabel(text='<font color="red">' + self.tr('DC Voltages at A1, A2 and A3')) l.setMinimumWidth(self.RPWIDTH) right.addWidget(l) H = QHBoxLayout() for k in range(3): H.setAlignment(Qt.AlignLeft) self.voltMeterCB[k] = QCheckBox(self.tr(self.sources[k])) H.addWidget(self.voltMeterCB[k]) self.voltMeters[k] = QLabel() self.voltMeters[k].setMinimumWidth(50) H.addWidget(self.voltMeters[k]) right.addLayout(H) H = QHBoxLayout() l = QLabel(text=self.tr('Resistance on SEN = ')) H.addWidget(l) self.RES = QLabel() H.addWidget(self.RES) right.addLayout(H) H = QHBoxLayout() b = QPushButton(self.tr("Click for Capacitance on IN1")) b.setMinimumWidth(200) H.addWidget(b) b.clicked.connect(self.measure_cap) self.CAP = QLabel('') H.addWidget(self.CAP) right.addLayout(H) H = QHBoxLayout() b = QPushButton(self.tr("Click for Frequency on IN2")) b.setMinimumWidth(200) H.addWidget(b) b.clicked.connect(self.measure_freq) self.IN2 = QLabel('') H.addWidget(self.IN2) right.addLayout(H) H = QHBoxLayout() self.OD1 = QCheckBox(self.tr("Enable OD1")) H.addWidget(self.OD1) self.OD1.stateChanged.connect(self.control_od1) self.CCS = QCheckBox(self.tr("Enable CCS")) H.addWidget(self.CCS) self.CCS.stateChanged.connect(self.control_ccs) right.addLayout(H) H = QHBoxLayout() l = QLabel(text=self.tr('WG Shape')) H.addWidget(l) self.Wshape = QPushButton('sine') menu = QMenu() for k in range(len(self.Waves)): menu.addAction(self.Waves[k], lambda index=k: self.select_wave(index)) self.Wshape.setMenu(menu) H.addWidget(self.Wshape) l = QLabel(text=self.tr('Amplitude')) H.addWidget(l) self.Wgain = QPushButton(self.Wgains[self.wgainindex]) menu = QMenu() for k in range(len(self.Wgains)): menu.addAction(self.Wgains[k], lambda index=k: self.select_wgain(index)) self.Wgain.setMenu(menu) H.addWidget(self.Wgain) right.addLayout(H) H = QHBoxLayout() l = QLabel(text=self.tr('WG')) l.setMaximumWidth(30) H.addWidget(l) self.AWGslider = utils.slider(self.AWGmin, self.AWGmax, self.AWGval, 100, self.awg_slider) H.addWidget(self.AWGslider) self.AWGtext = utils.lineEdit(100, self.AWGval, 6, self.awg_text) H.addWidget(self.AWGtext) l = QLabel(text=self.tr('Hz')) l.setMaximumWidth(40) l.setMinimumWidth(40) H.addWidget(l) right.addLayout(H) H = QHBoxLayout() l = QLabel(text=self.tr('SQ1')) l.setMaximumWidth(30) l.setMinimumWidth(30) H.addWidget(l) self.SQ1slider = utils.slider(self.SQ1min, self.SQ1max, self.SQ1val, 100, self.sq1_slider) H.addWidget(self.SQ1slider) self.SQ1text = utils.lineEdit(60, self.SQ1val, 6, self.sq1_text) H.addWidget(self.SQ1text) l = QLabel(text=self.tr('Hz')) l.setMaximumWidth(15) H.addWidget(l) self.SQ1DCtext = utils.lineEdit(30, 50, 6, self.sq1_dc) H.addWidget(self.SQ1DCtext) l = QLabel(text=self.tr('%')) l.setMaximumWidth(15) H.addWidget(l) right.addLayout(H) H = QHBoxLayout() l = QLabel(text=self.tr('PV1')) l.setMaximumWidth(25) H.addWidget(l) self.PV1slider = utils.slider(self.PV1min * 1000, self.PV1max * 1000, self.PV1val * 1000, 100, self.pv1_slider) H.addWidget(self.PV1slider) self.PV1text = utils.lineEdit(100, self.PV1val, 6, self.pv1_text) H.addWidget(self.PV1text) l = QLabel(text=self.tr('Volt')) l.setMaximumWidth(40) l.setMinimumWidth(40) H.addWidget(l) right.addLayout(H) H = QHBoxLayout() l = QLabel(text=self.tr('PV2')) l.setMaximumWidth(25) H.addWidget(l) self.PV2slider = utils.slider(self.PV2min * 1000, self.PV2max * 1000, self.PV2val * 1000, 100, self.pv2_slider) H.addWidget(self.PV2slider) self.PV2text = utils.lineEdit(100, self.PV2val, 6, self.pv2_text) H.addWidget(self.PV2text) l = QLabel(text=self.tr('Volt')) l.setMaximumWidth(40) l.setMinimumWidth(40) H.addWidget(l) right.addLayout(H) #--------------------------Scope Controls--------------------- l = QLabel('<font color="red">' + self.tr('Oscilloscope Channels, Range and Analysis ')) right.addWidget(l) for ch in range(4): H = QHBoxLayout() H.setAlignment(Qt.AlignLeft) self.chanSelCB[ch] = QCheckBox() self.chanSelCB[ch].stateChanged.connect( partial(self.select_channel, ch)) H.addWidget(self.chanSelCB[ch]) l = QLabel(text='<font color="%s">%s' % (self.htmlColors[ch], self.sources[ch])) l.setMaximumWidth(30) l.setMinimumWidth(30) H.addWidget(l) self.rangeSelPB[ch] = QPushButton('4 V') self.rangeSelPB[ch].setMaximumWidth(60) menu = QMenu() if ch <= 1: for k in range(len(self.Ranges12)): menu.addAction( self.Ranges12[k], lambda index=(ch, k): self.select_range(index)) else: for k in range(len(self.Ranges34)): menu.addAction( self.Ranges34[k], lambda index=(ch, k): self.select_range(index)) self.rangeSelPB[ch].setMenu(menu) H.addWidget(self.rangeSelPB[ch]) self.fitSelCB[ch] = QCheckBox('') self.fitSelCB[ch].setMaximumWidth(30) H.addWidget(self.fitSelCB[ch]) self.fitResLab[ch] = QLabel('') H.addWidget(self.fitResLab[ch]) right.addLayout(H) self.chanSelCB[0].setChecked(True) H = QHBoxLayout() l = QLabel(text=self.tr('Timebase')) l.setMaximumWidth(60) H.addWidget(l) self.TBslider = utils.slider(0, 8, self.TBval, 180, self.set_timebase) H.addWidget(self.TBslider) l = QLabel(text=self.tr('mS/div')) l.setMaximumWidth(60) H.addWidget(l) right.addLayout(H) H = QHBoxLayout() l = QLabel(text=self.tr('Trigger')) l.setMaximumWidth(60) H.addWidget(l) self.Trigslider = utils.slider(-3300, 3300, self.Triglevel, 150, self.set_trigger) H.addWidget(self.Trigslider) l = QLabel(text=self.tr('On')) l.setMaximumWidth(30) H.addWidget(l) self.Trigbutton = QPushButton(self.tr('A1')) self.Trigbutton.setMaximumWidth(50) menu = QMenu() for k in range(len(self.sources)): menu.addAction(self.sources[k], lambda index=k: self.select_trig_source(index)) self.Trigbutton.setMenu(menu) H.addWidget(self.Trigbutton) right.addLayout(H) H = QHBoxLayout() self.SaveButton = QPushButton(self.tr("Save Traces")) #self.SaveButton.setMaximumWidth(80) self.SaveButton.clicked.connect(self.save_data) H.addWidget(self.SaveButton) #self.Filename = utils.lineEdit(100, self.tr('scope.txt'), 20, None) #H.addWidget(self.Filename) self.FFT = QPushButton(self.tr("Fourier Transform")) #self.FFT.setMaximumWidth(50) H.addWidget(self.FFT) self.FFT.clicked.connect(self.show_fft) right.addLayout(H) H = QHBoxLayout() self.Cross = QCheckBox(self.tr("Cross hair")) self.Cross.stateChanged.connect(self.cross_hair) H.addWidget(self.Cross) self.Freeze = QCheckBox(self.tr("Freeze")) H.addWidget(self.Freeze) self.Diff = QCheckBox(self.tr('A1-A2')) H.addWidget(self.Diff) self.Diff.stateChanged.connect(self.show_diff) right.addLayout(H) #------------------------end of right panel ---------------- top = QHBoxLayout() top.addLayout(left) top.addWidget(win) # self.pwin) top.addLayout(right) full = QVBoxLayout() full.addLayout(top) self.msgwin = QLabel(text=self.tr('messages')) full.addWidget(self.msgwin) self.setLayout(full) self.timer = QTimer() self.timer.timeout.connect(self.update) self.timer.start(self.TIMER) self.recover()
def __init__(self, device=None): super(Expt, self).__init__() self.setupUi(self) try: self.setStyleSheet(open(os.path.join(os.path.dirname(__file__),"layouts/style.qss"), "r").read()) except Exception as e: print('stylesheet missing. ',e) self.resultCols = utils.makeResultColors() self.traceCols = utils.makeTraceColors() self.htmlColors = utils.makeHtmlColors() self.pwin = pg.PlotWidget(self.pwinview) self.plotLayout.addWidget(self.pwin) self.p = device # connection to the device hardware self.chanStatus = [1,0,0,0] # PyQt problem. chanStatus somehow getting preserved ??? self.offSliders = [self.slider1,self.slider2,self.slider3,self.slider4] for ch in range(self.MAXCHAN): self.offSliders[ch].valueChanged.connect(partial (self.set_offset,ch)) self.offSliders[ch].setStyleSheet('''QSlider::handle:vertical{background: %s;};'''%(self.htmlColors[ch])) self.pwin.proxy = pg.SignalProxy(self.pwin.scene().sigMouseMoved, rateLimit=60, slot=self.updateTV) self.pwin.showGrid(x=True, y=True) # with grid for k in range(self.MAXCHAN): # pg textItem to show the voltage scales self.scaleLabs[k] = pg.TextItem(text='') for k in range(self.MAXRES): # pg textItem to show the Results self.resLabs[k] = pg.TextItem() self.pwin.addItem(self.resLabs[k]) vLine = pg.InfiniteLine(angle=90, movable=False, pen = 'r') self.pwin.addItem(vLine, ignoreBounds=True) self.pwin.vLine=vLine self.pwin.vLine.setPos(-1) ax = self.pwin.getAxis('bottom') ax.setLabel(self.tr('Time (mS)')) ax = self.pwin.getAxis('left') ax.setStyle(showValues=False) ax.setLabel(self.tr('Voltage')) self.set_timebase(self.TBval) self.pwin.disableAutoRange() self.pwin.setXRange(0, self.tbvals[self.TBval]*10) self.pwin.setYRange(-16, 16) self.pwin.hideButtons() # Do not show the 'A' button of pg for ch in range(self.MAXCHAN): # initialize the pg trace widgets self.traceWidget[ch] = self.pwin.plot([0,0],[0,0], pen = self.traceCols[ch]) self.diffTraceW = self.pwin.plot([0,0],[0,0], pen = self.traceCols[-1]) self.CAP.clicked.connect(self.measure_cap) self.FREQ.clicked.connect(self.measure_freq) self.OD1.stateChanged.connect(self.control_od1) self.CCS.stateChanged.connect(self.control_ccs) self.chanSelCB = [self.A1Box,self.A2Box,self.A3Box,self.MICBox] self.rangeSelPB = [self.A1Range,self.A2Range,self.A3Range,self.MICRange] self.fitSelCB = [self.A1Fit,self.A2Fit,self.A3Fit,self.MICFit] self.voltMeterCB = [self.voltMeterCB1,self.voltMeterCB2,self.voltMeterCB3] for ch in range(4): self.chanSelCB[ch].stateChanged.connect(partial (self.select_channel,ch)) self.chanSelCB[ch].setStyleSheet('''border: 1px solid %s;'''%(self.htmlColors[ch])) #<font color="%s"> self.rangeSelPB[ch].currentIndexChanged['int'].connect(partial(self.select_range,ch)) self.chanSelCB[0].setChecked(True) self.trigBox.addItems(self.sources) self.A1Map.addItems(self.sources) self.recover() self.timer = QTimer() self.timer.timeout.connect(self.update) self.timer.start(self.TIMER)