def get_correction_widget(self, parent): """.""" corr_wid = QGroupBox('Correction', parent) corr_wid.setLayout(QVBoxLayout()) if self.acc != 'BO': lbl = QLabel('Auto Correction State:', corr_wid) wid = self.create_pair_butled(corr_wid, 'LoopState') hbl = QHBoxLayout() hbl.addWidget(lbl) hbl.addWidget(wid) corr_wid.layout().addLayout(hbl) corr_tab = QTabWidget(corr_wid) corr_wid.layout().addWidget(corr_tab) if self.acc != 'BO': auto_wid = self.get_auto_correction_widget(corr_tab) corr_tab.addTab(auto_wid, 'Automatic') man_wid = self.get_manual_correction_widget(corr_tab) corr_tab.addTab(man_wid, 'Manual') kicks_wid = KicksConfigWidget( parent, self.device, prefix=self.prefix, acc=self.acc) corr_tab.addTab(kicks_wid, 'Kicks Config') if self.acc != 'BO': hbl = kicks_wid.get_status_widget(corr_wid) corr_wid.layout().addLayout(hbl) return corr_wid
def get_main_widget(self, parent): main_wid = QWidget(parent) main_lay = QVBoxLayout(main_wid) main_lay.setContentsMargins(0, 0, 0, 0) sel_gp = QGroupBox('Sel.') sel_gp.setLayout(QHBoxLayout()) sel_gp.layout().setContentsMargins(0, 0, 0, 0) sel_wid = self.get_selection_lists_widget(sel_gp) sel_gp.layout().addWidget(sel_wid) main_lay.addWidget(sel_gp) svld_gp = QGroupBox('Load and Save') svld_gp.setLayout(QHBoxLayout()) svld_gp.layout().setContentsMargins(0, 0, 0, 0) svld_wid = self.get_saveload_widget(svld_gp) svld_gp.layout().addWidget(svld_wid) main_lay.addWidget(svld_gp) return main_wid
def _make_checkboxes(self): dev_gb = QGroupBox("Device Type") dev_gb.setLayout(QGridLayout()) dev_gb.layout().setSpacing(6) all_btn = QPushButton("All") dev_gb.layout().addWidget(all_btn, 0, 0, 1, 1) none_btn = QPushButton("None") dev_gb.layout().addWidget(none_btn, 0, 1, 1, 1) for i, label in enumerate(DevTypeLabels): cb = QCheckBox(label) cb.setChecked(DevTypeLabels[label] not in self._filters) cb.toggled.connect(partial(self._toggle_filter, label)) dev_gb.layout().addWidget(cb, i + 1, 0, 1, 2) @all_btn.clicked.connect def _check_all(): for cxbx in dev_gb.findChildren(QCheckBox): cxbx.setChecked(True) @none_btn.clicked.connect def _check_none(): for cxbx in dev_gb.findChildren(QCheckBox): cxbx.setChecked(False) for i in dev_gb.findChildren(QWidget): i.setFocusPolicy(Qt.FocusPolicy.NoFocus) ro = QCheckBox("Show read-only") ro.setChecked(self._show_read_only) ro.toggled.connect(self._set_show_read_only) ro.setFocusPolicy(Qt.FocusPolicy.NoFocus) c = QWidget() c.setLayout(QVBoxLayout()) c.layout().addWidget(dev_gb) c.layout().addWidget(ro) c.layout().addStretch() return c
def _setupUi(self): vl = QVBoxLayout(self) self.image_view = ImageView( self.process_image, parent=self, image_channel=self.image_channel, width_channel=self.width_channel) self.image_view.maxRedrawRate = 5 self.image_view.readingOrder = self.image_view.Clike self.plt_roi = PlotCurveItem([0, 0, 400, 400, 0], [0, 400, 400, 0, 0]) pen = mkPen() pen.setColor(QColor('red')) pen.setWidth(1) self.plt_roi.setPen(pen) self.image_view.addItem(self.plt_roi) self.plt_fit_x = PlotCurveItem([0, 0], [0, 400]) self.plt_fit_y = PlotCurveItem([0, 0], [0, 400]) self.plt_his_x = PlotCurveItem([0, 0], [0, 400]) self.plt_his_y = PlotCurveItem([0, 0], [0, 400]) pen = mkPen() pen.setColor(QColor('yellow')) self.plt_his_x.setPen(pen) self.plt_his_y.setPen(pen) self.image_view.addItem(self.plt_fit_x) self.image_view.addItem(self.plt_fit_y) self.image_view.addItem(self.plt_his_x) self.image_view.addItem(self.plt_his_y) vl.addWidget(self.image_view) gb_trig = QGroupBox('Trigger', self) vl.addWidget(gb_trig) gb_trig.setLayout(QVBoxLayout()) gb_trig.layout().addWidget(HLTriggerSimple( gb_trig, device=self.trig_name, prefix=self._prefix)) gb_pos = QGroupBox('Position [mm]', self) vl.addWidget(gb_pos) hl = QHBoxLayout(gb_pos) fl = QFormLayout() hl.addLayout(fl) self.cbox_method = QComboBox(gb_pos) self.cbox_method.addItem('Gauss Fit') self.cbox_method.addItem('Moments') fl.addRow(QLabel('Method', gb_pos), self.cbox_method) self.spbox_roi_size_x = QSpinBoxPlus(gb_pos) self.spbox_roi_size_y = QSpinBoxPlus(gb_pos) self.spbox_roi_center_x = QSpinBoxPlus(gb_pos) self.spbox_roi_center_y = QSpinBoxPlus(gb_pos) self.spbox_roi_size_x.setKeyboardTracking(False) self.spbox_roi_size_y.setKeyboardTracking(False) self.spbox_roi_center_x.setKeyboardTracking(False) self.spbox_roi_center_y.setKeyboardTracking(False) self.spbox_roi_size_x.setMaximum(2448) self.spbox_roi_size_y.setMaximum(2050) self.spbox_roi_center_x.setMaximum(2448) self.spbox_roi_center_y.setMaximum(2050) self.spbox_roi_size_x.setValue(300) self.spbox_roi_size_y.setValue(400) self.spbox_roi_center_x.setValue(500) self.spbox_roi_center_y.setValue(500) fl.addRow(QLabel('ROI Size X', gb_pos), self.spbox_roi_size_x) fl.addRow(QLabel('ROI Size Y', gb_pos), self.spbox_roi_size_y) self.cbbox_auto_center = QCheckBox('Automatic Centering', gb_pos) self.cbbox_auto_center.clicked.connect(self.cbbox_auto_center_clicked) self.cbbox_auto_center.setChecked(True) fl.addRow(self.cbbox_auto_center) fl.addRow(QLabel('ROI Center X', gb_pos), self.spbox_roi_center_x) fl.addRow(QLabel('ROI Center Y', gb_pos), self.spbox_roi_center_y) self.spbox_img_max = QSpinBoxPlus(gb_pos) self.spbox_img_max.setKeyboardTracking(False) self.spbox_img_max.setMinimum(0) self.spbox_img_max.setMaximum(2448) self.spbox_img_max.setValue(0) fl.addRow(QLabel('Max. Pixel Val.', gb_pos), self.spbox_img_max) self.cbbox_acq_bg = QCheckBox('Acquire Background', gb_pos) self.cbbox_acq_bg.clicked.connect(self.cbbox_acq_bg_checked) fl.addRow(self.cbbox_acq_bg) self.pb_reset_bg = QPushButton('Reset BG', gb_pos) self.pb_reset_bg.clicked.connect(self.pb_reset_bg_clicked) fl.addRow(self.pb_reset_bg) fl = QFormLayout() hl.addLayout(fl) self.lb_xave = QLabel('0', gb_pos) self.lb_yave = QLabel('0', gb_pos) self.lb_xstd = QLabel('0', gb_pos) self.lb_ystd = QLabel('0', gb_pos) fl.addRow(QLabel('Average Position', gb_pos)) fl.addRow(QLabel('x = ', gb_pos), self.lb_xave) fl.addRow(QLabel('y = ', gb_pos), self.lb_yave) fl.addRow(QLabel('Beam Size', gb_pos)) fl.addRow(QLabel('x = ', gb_pos), self.lb_xstd) fl.addRow(QLabel('y = ', gb_pos), self.lb_ystd) hl.setSpacing(12) hl.setStretch(0, 1) hl.setStretch(1, 1)
def _setupUi(self): gl = QGridLayout(self) fig = mplt.figure() wid = MatplotlibWidget(fig, parent=self) wid.setObjectName('fig_result') wid.setStyleSheet('#fig_result{min-width: 25em;}') self.fig_res = wid gs = mgs.GridSpec(3, 1) gs.update(left=0.18, right=0.98, top=0.97, bottom=0.08, hspace=0.25) axes = wid.figure.add_subplot(gs[0, 0]) axes.set_xlabel('Index') axes.set_ylabel('Normalized Emit. [mm.mrad]') axes.grid(True) axes.set_aspect('auto') self.line_nemitx_tm = axes.plot( self.nemitx_tm, '-bo', lw=1, label='Hor. Trans. Mat.')[0] self.line_nemitx_parf = axes.plot( self.nemitx_parf, '--bd', lw=1, label='Hor. Parab. Fit')[0] self.line_nemity_tm = axes.plot( self.nemity_tm, '--ro', lw=1, label='Vert. Trans. Mat.')[0] self.line_nemity_parf = axes.plot( self.nemity_parf, '--rd', lw=1, label='Vert. Parab. Fit')[0] axes.legend(loc='best') axes = wid.figure.add_subplot(gs[1, 0]) axes.set_xlabel('Index') axes.set_ylabel(r'$\beta$ [m]') self.line_betax_tm = axes.plot( self.betax_tm, '-bo', lw=1, label='Hor. Trans. Mat.')[0] self.line_betax_parf = axes.plot( self.betax_parf, '--bd', lw=1, label='Hor. Parab. Fit')[0] self.line_betay_tm = axes.plot( self.betay_tm, '--ro', lw=1, label='Vert. Trans. Mat.')[0] self.line_betay_parf = axes.plot( self.betay_parf, '--rd', lw=1, label='Vert. Parab. Fit')[0] axes = wid.figure.add_subplot(gs[2, 0]) axes.set_xlabel('Index') axes.set_ylabel(r'$\alpha$') self.line_alphax_tm = axes.plot( self.alphax_tm, '-bo', lw=1, label='Hor. Trans. Mat.')[0] self.line_alphax_parf = axes.plot( self.alphax_parf, '--bd', lw=1, label='Hor. Parab. Fit')[0] self.line_alphay_tm = axes.plot( self.alphay_tm, '--ro', lw=1, label='Vert. Trans. Mat.')[0] self.line_alphay_parf = axes.plot( self.alphay_parf, '--rd', lw=1, label='Vert. Parab. Fit')[0] measlay = QVBoxLayout() gb = QGroupBox('QF3 Current [A]', self) measlay.addWidget(gb) gb.setLayout(QHBoxLayout()) spnbox = SiriusSpinbox( gb, _PVName('LI-01:PS-QF3:Current-SP').substitute( prefix=self._prefix)) lbl = SiriusLabel( gb, _PVName('LI-01:PS-QF3:Current-Mon').substitute( prefix=self._prefix)) spnbox.showStepExponent = False gb.layout().addWidget(spnbox) gb.layout().addWidget(lbl) gb.layout().setAlignment(Qt.AlignTop) gb = QGroupBox('Data Acquisition Configs.', self) fl = QFormLayout(gb) measlay.addWidget(gb) self.pb_start = QPushButton('Start', gb) self.pb_start.clicked.connect(self.pb_start_clicked) self.pb_stop = QPushButton('Stop', gb) self.pb_stop.clicked.connect(self.pb_stop_clicked) self.pb_stop.setEnabled(False) hbox_bts = QHBoxLayout() hbox_bts.addWidget(self.pb_start) hbox_bts.addWidget(self.pb_stop) fl.addRow(hbox_bts) self.cbbox_plane = QComboBox(gb) self.cbbox_plane.addItem('Horizontal') self.cbbox_plane.addItem('Vertical') fl.addRow(QLabel('Plane', gb), self.cbbox_plane) self.spbox_steps = QSpinBoxPlus(gb) self.spbox_steps.setValue(11) fl.addRow(QLabel('Nr Steps', gb), self.spbox_steps) self.spbox_samples = QSpinBoxPlus(gb) self.spbox_samples.setMinimum(1) self.spbox_samples.setValue(16) fl.addRow(QLabel('Nr Samples per step', gb), self.spbox_samples) self.spbox_outliers = QSpinBoxPlus(gb) self.spbox_outliers.setMinimum(0) self.spbox_outliers.setValue(12) fl.addRow(QLabel('Nr Outliers', gb), self.spbox_outliers) self.spbox_I_ini = QDoubleSpinBoxPlus(gb) self.spbox_I_ini.setMinimum(-4) self.spbox_I_ini.setMaximum(4) self.spbox_I_ini.setValue(-0.7) self.spbox_I_ini.setDecimals(3) fl.addRow(QLabel('Initial Current [A]', gb), self.spbox_I_ini) self.spbox_I_end = QDoubleSpinBoxPlus(gb) self.spbox_I_end.setMinimum(-4) self.spbox_I_end.setMaximum(4) self.spbox_I_end.setValue(0.7) self.spbox_I_end.setDecimals(3) fl.addRow(QLabel('Final Current [A]', gb), self.spbox_I_end) self.spbox_threshold = QDoubleSpinBoxPlus(gb) self.spbox_threshold.setMinimum(0) self.spbox_threshold.setMaximum(20) self.spbox_threshold.setValue(4) self.spbox_threshold.setDecimals(2) fl.addRow(QLabel('Max. Size Accpbl. [mm]', gb), self.spbox_threshold) measlay.setStretch(0, 2) measlay.setStretch(1, 8) anllay = QVBoxLayout() gb = QGroupBox('Analysis Configs.', self) vl = QVBoxLayout(gb) anllay.addWidget(gb) self.spbox_energy = QDoubleSpinBoxPlus(gb) self.spbox_energy.setMinimum(0.511) self.spbox_energy.setMaximum(200) self.spbox_energy.setValue(150) self.spbox_energy.setDecimals(2) self.pb_analyse_data = QPushButton('Analyse', gb) self.pb_analyse_data.clicked.connect(self.pb_analyse_data_clicked) hl = QHBoxLayout() hl.addWidget(QLabel('Energy [MeV]', gb)) hl.addWidget(self.spbox_energy) hl.addWidget(self.pb_analyse_data) vl.addLayout(hl) self.pb_save_data = QPushButton('Save Raw', gb) self.pb_save_data.clicked.connect(self.pb_save_data_clicked) self.pb_load_data = QPushButton('Load Raw', gb) self.pb_load_data.clicked.connect(self.pb_load_data_clicked) hl = QHBoxLayout() hl.addWidget(self.pb_save_data) hl.addWidget(self.pb_load_data) vl.addLayout(hl) self.logdisplay = PyDMLogDisplay(self, level=_log.INFO) vl.addWidget(self.logdisplay) resultsgb = QGroupBox('Results', self) gl2 = QGridLayout(resultsgb) gl2.addWidget(QLabel('Trans. Matrix', resultsgb), 0, 1, 1, 2) gl2.addWidget(QLabel('Parabola Fit', resultsgb), 0, 3, 1, 2) gl2.addWidget(QLabel('Hor.', resultsgb), 1, 1) gl2.addWidget(QLabel('Vert.', resultsgb), 1, 2) gl2.addWidget(QLabel('Hor.', resultsgb), 1, 3) gl2.addWidget(QLabel('Vert.', resultsgb), 1, 4) gl2.addWidget(QLabel('Norm. emitt.\n[mm.mrad]', resultsgb), 2, 0) gl2.addWidget(QLabel('beta [m]', resultsgb), 3, 0) gl2.addWidget(QLabel('alpha', resultsgb), 4, 0) for i, pref in enumerate(('nemit', 'beta', 'alpha')): for j, tp in enumerate(('x_tm', 'y_tm', 'x_parf', 'y_parf')): name = pref + tp lb = QLabel('----', resultsgb) setattr(self, 'lb_' + name, lb) gl2.addWidget(lb, i+2, j+1) wid = MatplotlibWidget(parent=self) axes = wid.figure.add_subplot(111) axes.set_xlabel('Quad. Current [A]') axes.set_ylabel('Beam Size [mm]') wid.figure.set_tight_layout(True) self.line_sigmax = axes.plot([], 'bo', lw=1, label='Horizontal')[0] self.line_sigmay = axes.plot([], 'ro', lw=1, label='Vertical')[0] self.line_fit = axes.plot([], '-k', lw=1)[0] wid.setObjectName('fig_sigma') wid.setStyleSheet('#fig_sigma{min-width: 25em;}') self.fig_sigma = wid gl.addWidget(self.plt_image, 0, 0, 2, 1) gl.addItem(measlay, 0, 1) gl.addWidget(self.fig_sigma, 1, 1) gl.addItem(anllay, 0, 2) gl.addWidget(resultsgb, 1, 2) gl.addWidget(self.fig_res, 0, 3, 2, 1)
class TuneDetails(SiriusMainWindow): """Tune Details.""" def __init__(self, parent=None, prefix='', section='', orientation='H', background=None): """Init.""" super().__init__(parent) self.prefix = prefix self.section = section.upper() self.orientation = orientation self.device = SiriusPVName('AC-Glob:DI-Tune-O') self.device = self.device.substitute(sec=self.section, idx=self.orientation, prefix=self.prefix) if self.section == 'BO': self.trigger = SiriusPVName('BO-Glob:TI-TuneProc') self.background = background self.setWindowTitle(self.device + ' Detailed Settings') self.setObjectName(self.section + 'App') self._setupUi() self.setFocusPolicy(Qt.StrongFocus) def _setupUi(self): cw = QWidget(self) self.setCentralWidget(cw) # title self.title_label = QLabel( '<h3>Tune ' + self.orientation + ' Detailed Settings<h3>', self) self.title_label.setObjectName('title') pal = self.title_label.palette() pal.setColor(QPalette.Background, self.background) self.title_label.setAutoFillBackground(True) self.title_label.setPalette(pal) # measurement self.meas_gbox = QGroupBox('Measurement', self) self.meas_gbox.setLayout(self._measLayout()) # config self.config_gbox = QGroupBox('Configuration', self) self.config_gbox.setLayout(self._configLayout()) if self.section == 'BO': # trigger self.trg_gbox = QGroupBox('Trigger', self) self.trg_gbox.setLayout(QHBoxLayout()) self.trg_gbox.layout().addWidget( HLTriggerSimple(self.trg_gbox, device='BO-Glob:TI-TuneProc', prefix=self.prefix, duration=True, nrpulses=True)) # spectrogram view self.spec_gbox = QGroupBox('Spectrogram View', self) self.spec_gbox.setLayout(self._specViewLayout()) # roi self.roi_gbox = QGroupBox('ROI', self) self.roi_gbox.setLayout(self._roiLayout()) vbox = QVBoxLayout() vbox.addWidget(self.trg_gbox) vbox.addWidget(self.spec_gbox) vbox.addWidget(self.roi_gbox) vbox.addWidget(self.config_gbox) lay = QGridLayout(cw) lay.addWidget(self.title_label, 0, 0, 1, 2) lay.addWidget(self.meas_gbox, 1, 0) lay.addLayout(vbox, 1, 1) else: lay = QVBoxLayout(cw) lay.addWidget(self.title_label) lay.addWidget(self.meas_gbox) lay.addWidget(self.config_gbox) self.setStyleSheet(""" QLed{ min-width:1.29em; max-width:1.29em; } #title { min-height:1.29em; max-height:1.29em; qproperty-alignment: "AlignVCenter | AlignHCenter"; } PyDMLabel, PyDMSpinbox, PyDMEnumComboBox, PyDMStateButton{ min-width:6em; max-width:6em; }""") def _measLayout(self): # Acquisition lbl_acq = QLabel('Acquisition', self) self.bt_acq = PyDMStateButton( self, self.device.substitute(propty='SpecAnaGetSpec-Sel')) self.bt_acq.shape = 1 self.led_acq = SiriusLedState( self, self.device.substitute(propty='SpecAnaGetSpec-Sts')) hbox_acq = QHBoxLayout() hbox_acq.addWidget(self.bt_acq) hbox_acq.addWidget(self.led_acq) # Excitation lbl_drive = QLabel('Excitation', self) self.bt_drive = PyDMStateButton( self, self.device.substitute(propty='Enbl-Sel')) self.bt_drive.shape = 1 value = 0b111 if self.section == 'BO' else 1 self.led_drive = PyDMLedMultiChannel( parent=self, channels2values={self.device.substitute(propty='Enbl-Sts'): value}) self.led_drive.setOffColor(PyDMLed.DarkGreen) hbox_drive = QHBoxLayout() hbox_drive.addWidget(self.bt_drive) hbox_drive.addWidget(self.led_drive) # Excitation Status Detailed gbox_enblsts = QGridLayout() lbl_enblsts = QLabel('Excitation\nEnable Status\nDetailed', self, alignment=Qt.AlignVCenter | Qt.AlignRight) if self.section == 'BO': # # Carrier Generator self.led_carrier = SiriusLedState( self, self.device.substitute(propty='EnblCarrierGen-Sts')) gbox_enblsts.addWidget(self.led_carrier, 0, 0) gbox_enblsts.addWidget(QLabel('Carrier Generator'), 0, 1) # # Noise Generator self.led_noise = SiriusLedState( self, self.device.substitute(propty='EnblNoiseGen-Sts')) gbox_enblsts.addWidget(self.led_noise, 1, 0) gbox_enblsts.addWidget(QLabel('Noise Generator'), 1, 1) else: # # Noise Generator self.led_trkgen = SiriusLedState( self, self.device.substitute(propty='SpecAnaTrkGen-Sts')) gbox_enblsts.addWidget(self.led_trkgen, 1, 0) gbox_enblsts.addWidget(QLabel('Tracking Generator'), 1, 1) # # Amplifier self.led_amp = SiriusLedState( self, self.device.substitute(propty='EnblAmp-Sts')) gbox_enblsts.addWidget(self.led_amp, 2, 0) gbox_enblsts.addWidget(QLabel('Amplifier'), 2, 1) if self.section == 'BO': # Frame Count lbl_acqcnt = QLabel('Frame Count', self) dev = self.device.substitute(dev='TuneProc') self.lb_acqcnt = PyDMLabel(self, dev.substitute(propty='FrameCount-Mon')) self.lb_acqcnt.setAlignment(Qt.AlignCenter) self.led_acqcnt = PyDMLedMultiChannel(parent=self) self.trigNrPulseChannel = SiriusConnectionSignal( self.trigger.substitute(prefix=self.prefix, propty='NrPulses-RB')) self.trigNrPulseChannel.new_value_signal[int].connect( self._updateNrAcq) hbox_acqcnt = QHBoxLayout() hbox_acqcnt.addWidget(self.lb_acqcnt) hbox_acqcnt.addWidget(self.led_acqcnt) # Nr. Samples p/ spec lbl_nrsmp = QLabel('Nr. Samples p/ Spec.', self) self.lb_nrsmp = PyDMLabel(parent=self, init_channel=self.device.substitute( dev='TuneProc', propty_name='SwePts', propty_suffix='RB')) if self.section == 'SI': # Acquisition Time lbl_acqtime = QLabel('Acq. Time', self) self.cb_acqtime = PyDMEnumComboBox( parent=self, init_channel=self.device.substitute(dev='TuneProc', propty_name='Trace', propty_suffix='Mon', field='SCAN')) # Sweep time lbl_swetime = QLabel('Sweep Time [ms]', self) self.lb_swetime = PyDMLabel(parent=self, init_channel=self.device.substitute( dev='TuneProc', propty_name='SweTime', propty_suffix='Mon')) # Span lbl_span = QLabel('Span [kHz]', self) self.le_span = PyDMLineEdit(self, self.device.substitute(propty='Span-SP')) self.le_span.precisionFromPV = True self.lb_span = PyDMLabel(self, self.device.substitute(propty='Span-RB')) hbox_span = QHBoxLayout() hbox_span.addWidget(self.le_span) hbox_span.addWidget(self.lb_span) # RBW lbl_rbw = QLabel('RBW', self) if self.section == 'BO': self.cb_rbw = PyDMEnumComboBox( self, self.device.substitute(propty='SpecAnaRBW-Sel')) else: items = [ '1 Hz', '2 Hz', '3 Hz', '5 Hz', '10 Hz', '20 Hz', '30 Hz', '50 Hz', '100 Hz', '200 Hz', '300 Hz', '500 Hz', '1 kHz', '2 kHz', '3 kHz', '5 kHz', '6.25 kHz', '10 kHz', '20 kHz', '30 kHz', '50 kHz', '100 kHz', '200 kHz', '300 kHz', '500 kHz', '1 MHz', '2 MHz', '3 MHz', '5 MHz', '10 MHz' ] self.cb_rbw = SiriusStringComboBox( self, self.device.substitute(propty='SpecAnaRBW-Sel'), items=items) self.lb_rbw = PyDMLabel( self, self.device.substitute(propty='SpecAnaRBW-Sts')) hbox_rbw = QHBoxLayout() hbox_rbw.addWidget(self.cb_rbw) hbox_rbw.addWidget(self.lb_rbw) # Harmonic lbl_h = QLabel('Harmonic (n)', self) self.sb_h = PyDMSpinbox(self, self.device.substitute(propty='RevN-SP')) self.sb_h.showStepExponent = False self.sb_h.precisionFromPV = True self.lb_h = PyDMLabel(self, self.device.substitute(propty='RevN-RB')) hbox_h = QHBoxLayout() hbox_h.addWidget(self.sb_h) hbox_h.addWidget(self.lb_h) # Harmonic Frequency lbl_Fh = QLabel('Harm. Freq. [kHz]', self) self.lb_Fh = PyDMLabel(parent=self) self.lb_Fh.setToolTip('Frf/(h*n)') self.lb_Fh.channel = self.device.substitute(propty='FreqRevN-Mon') # Frequency Offset lbl_foff = QLabel('Frequency Offset [kHz]', self) self.sb_foff = PyDMSpinbox(self, self.device.substitute(propty='FreqOff-SP')) self.sb_foff.showStepExponent = False self.sb_foff.precisionFromPV = True self.lb_foff = PyDMLabel(self, self.device.substitute(propty='FreqOff-RB')) hbox_foff = QHBoxLayout() hbox_foff.addWidget(self.sb_foff) hbox_foff.addWidget(self.lb_foff) # Center Frequency lbl_Fc = QLabel('Center Frequency [MHz]', self) self.le_Fc = PyDMLineEdit( self, self.device.substitute(propty='CenterFreq-SP')) self.le_Fc.precisionFromPV = True self.lb_Fc = PyDMLabel(self, self.device.substitute(propty='CenterFreq-RB')) hbox_Fc = QHBoxLayout() hbox_Fc.addWidget(self.le_Fc) hbox_Fc.addWidget(self.lb_Fc) # Lock Center Freq. lbl_autoFc = QLabel('Lock Center Frequency ', self) self.bt_autoFc = PyDMStateButton( self, self.device.substitute(propty='CenterFreqAuto-Sel')) self.bt_autoFc.shape = 1 self.led_autoFc = SiriusLedState( self, self.device.substitute(propty='CenterFreqAuto-Sts')) hbox_autoFc = QHBoxLayout() hbox_autoFc.addWidget(self.bt_autoFc) hbox_autoFc.addWidget(self.led_autoFc) # Amplifier Gain lbl_drivegain = QLabel('Amplifier Gain [dB]', self) self.sb_drivegain = PyDMSpinbox( self, self.device.substitute(propty='AmpGain-SP')) self.sb_drivegain.showStepExponent = False self.sb_drivegain.precisionFromPV = True self.lb_drivegain = PyDMLabel( self, self.device.substitute(propty='AmpGain-RB')) hbox_drivegain = QHBoxLayout() hbox_drivegain.addWidget(self.sb_drivegain) hbox_drivegain.addWidget(self.lb_drivegain) if self.section == 'BO': # Auto Configure Excitation lbl_driveauto = QLabel('Auto Config. Excit.', self) self.bt_driveauto = PyDMStateButton( self, self.device.substitute(propty='DriveAuto-Sel')) self.bt_driveauto.shape = 1 self.led_driveauto = SiriusLedState( self, self.device.substitute(propty='DriveAuto-Sts')) hbox_driveauto = QHBoxLayout() hbox_driveauto.addWidget(self.bt_driveauto) hbox_driveauto.addWidget(self.led_driveauto) # Noise Amplitude lbl_noiseamp = QLabel('Noise Amplitude [V]', self) self.sb_noiseamp = PyDMSpinbox( self, self.device.substitute(propty='NoiseAmpl-SP')) self.sb_noiseamp.showStepExponent = False self.sb_noiseamp.precisionFromPV = True self.lb_noiseamp = PyDMLabel( self, self.device.substitute(propty='NoiseAmpl-RB')) hbox_noiseamp = QHBoxLayout() hbox_noiseamp.addWidget(self.sb_noiseamp) hbox_noiseamp.addWidget(self.lb_noiseamp) else: # Noise Amplitude lbl_trkgenlvl = QLabel('Trk. Gen. Power [dBm]', self) self.sb_trkgenlvl = PyDMLineEdit( self, self.device.substitute(propty='SpecAnaTrkGenLvl-SP')) self.lb_trkgenlvl = PyDMLabel( self, self.device.substitute(propty='SpecAnaTrkGenLvl-RB')) hbox_trkgenlvl = QHBoxLayout() hbox_trkgenlvl.addWidget(self.sb_trkgenlvl) hbox_trkgenlvl.addWidget(self.lb_trkgenlvl) # Spectrum Acquisition lbl_getspec = QLabel('Spectrum Acq.', self) self.cb_getspec = PyDMStateButton( parent=self, init_channel=self.device.substitute(dev='TuneProc', propty_name='GetSpectrum', propty_suffix='Sel')) self.cb_getspec.shape = 1 self.lb_getspec = PyDMLed(parent=self, init_channel=self.device.substitute( dev='TuneProc', propty_name='GetSpectrum', propty_suffix='Sts')) hbox_getspec = QHBoxLayout() hbox_getspec.addWidget(self.cb_getspec) hbox_getspec.addWidget(self.lb_getspec) lay = QFormLayout() lay.setLabelAlignment(Qt.AlignRight) lay.setFormAlignment(Qt.AlignCenter) lay.addRow(lbl_acq, hbox_acq) lay.addItem(QSpacerItem(1, 6, QSzPlcy.Ignored, QSzPlcy.Fixed)) lay.addRow(lbl_drive, hbox_drive) lay.addRow(lbl_enblsts, gbox_enblsts) if self.section == 'BO': lay.addItem(QSpacerItem(1, 6, QSzPlcy.Ignored, QSzPlcy.Fixed)) lay.addRow(lbl_acqcnt, hbox_acqcnt) lay.addItem(QSpacerItem(1, 6, QSzPlcy.Ignored, QSzPlcy.Fixed)) lay.addRow(lbl_nrsmp, self.lb_nrsmp) if self.section == 'SI': lay.addRow(lbl_acqtime, self.cb_acqtime) lay.addRow(lbl_swetime, self.lb_swetime) lay.addRow(lbl_span, hbox_span) lay.addRow(lbl_rbw, hbox_rbw) lay.addItem(QSpacerItem(1, 6, QSzPlcy.Ignored, QSzPlcy.Fixed)) lay.addRow(lbl_h, hbox_h) lay.addRow(lbl_Fh, self.lb_Fh) lay.addRow(lbl_foff, hbox_foff) lay.addRow(lbl_Fc, hbox_Fc) lay.addRow(lbl_autoFc, hbox_autoFc) lay.addItem(QSpacerItem(1, 6, QSzPlcy.Ignored, QSzPlcy.Fixed)) lay.addRow(lbl_drivegain, hbox_drivegain) if self.section == 'BO': lay.addRow(lbl_driveauto, hbox_driveauto) lay.addRow(lbl_noiseamp, hbox_noiseamp) else: lay.addRow(lbl_trkgenlvl, hbox_trkgenlvl) lay.addItem(QSpacerItem(1, 6, QSzPlcy.Ignored, QSzPlcy.Fixed)) lay.addRow(lbl_getspec, hbox_getspec) return lay def _configLayout(self): self.bt_rst = PyDMPushButton( parent=self, init_channel=self.device.substitute(propty='Rst-Cmd'), pressValue=1, icon=qta.icon('fa5s.sync')) self.bt_rst.setObjectName('bt_rst') self.bt_rst.setStyleSheet( '#bt_rst{min-width:25px; max-width:25px; icon-size:20px;}') lay = QFormLayout() lay.setLabelAlignment(Qt.AlignRight) lay.setFormAlignment(Qt.AlignCenter) lay.addRow('Restore Default', self.bt_rst) return lay def _specViewLayout(self): dev = self.device.substitute(dev='TuneProc') # Mode lbl_mode = QLabel('Mode', self) self.cb_mode = PyDMEnumComboBox(self, dev.substitute(propty='SpecMode-Sel')) self.lb_mode = PyDMLabel(self, dev.substitute(propty='SpecMode-Sts')) hbox_mode = QHBoxLayout() hbox_mode.addWidget(self.cb_mode) hbox_mode.addWidget(self.lb_mode) # Time window lbl_timewdw = QLabel('Time Window [ms]', self) self.le_timewdw = PyDMLineEdit(self, dev.substitute(propty='SpecTime-SP')) self.le_timewdw.precisionFromPV = True self.lb_timewdw = PyDMLabel(self, dev.substitute(propty='SpecTime-RB')) hbox_timewdw = QHBoxLayout() hbox_timewdw.addWidget(self.le_timewdw) hbox_timewdw.addWidget(self.lb_timewdw) lay = QFormLayout() lay.setLabelAlignment(Qt.AlignRight) lay.setFormAlignment(Qt.AlignCenter) lay.addRow(lbl_mode, hbox_mode) lay.addRow(lbl_timewdw, hbox_timewdw) return lay def _roiLayout(self): # StartX lbl_roistartx = QLabel('Start X [MHz]', self) self.le_roistartx = PyDMLineEdit( self, self.device.substitute(propty='ROIOffsetX-SP')) self.le_roistartx.precisionFromPV = True self.lb_roistartx = PyDMLabel( self, self.device.substitute(propty='ROIOffsetX-RB')) hbox_roistartx = QHBoxLayout() hbox_roistartx.addWidget(self.le_roistartx) hbox_roistartx.addWidget(self.lb_roistartx) # Width lbl_roiwidth = QLabel('Width [MHz]', self) self.le_roiwidth = PyDMLineEdit( self, self.device.substitute(propty='ROIWidth-SP')) self.le_roiwidth.precisionFromPV = True self.lb_roiwidth = PyDMLabel( self, self.device.substitute(propty='ROIWidth-RB')) hbox_roiwidth = QHBoxLayout() hbox_roiwidth.addWidget(self.le_roiwidth) hbox_roiwidth.addWidget(self.lb_roiwidth) # StartY lbl_roistarty = QLabel('Start Y [ms]', self) self.le_roistarty = PyDMLineEdit( self, self.device.substitute(propty='ROIOffsetY-SP')) self.le_roistarty.precisionFromPV = True self.lb_roistarty = PyDMLabel( self, self.device.substitute(propty='ROIOffsetY-RB')) hbox_roistarty = QHBoxLayout() hbox_roistarty.addWidget(self.le_roistarty) hbox_roistarty.addWidget(self.lb_roistarty) # Height lbl_roiheight = QLabel('Height [ms]', self) self.le_roiheight = PyDMLineEdit( self, self.device.substitute(propty='ROIHeight-SP')) self.le_roiheight.precisionFromPV = True self.lb_roiheight = PyDMLabel( self, self.device.substitute(propty='ROIHeight-RB')) hbox_roiheight = QHBoxLayout() hbox_roiheight.addWidget(self.le_roiheight) hbox_roiheight.addWidget(self.lb_roiheight) # Auto adjust lbl_roiauto = QLabel('Auto Positioning', self) self.bt_roiauto = PyDMStateButton( self, self.device.substitute(propty='ROIAuto-Sel')) self.bt_roiauto.shape = 1 self.led_roiauto = SiriusLedState( self, self.device.substitute(propty='ROIAuto-Sts')) hbox_roiauto = QHBoxLayout() hbox_roiauto.addWidget(self.bt_roiauto) hbox_roiauto.addWidget(self.led_roiauto) lay = QFormLayout() lay.setLabelAlignment(Qt.AlignRight) lay.setFormAlignment(Qt.AlignCenter) lay.addRow(lbl_roistartx, hbox_roistartx) lay.addRow(lbl_roiwidth, hbox_roiwidth) lay.addRow(lbl_roistarty, hbox_roistarty) lay.addRow(lbl_roiheight, hbox_roiheight) lay.addRow(lbl_roiauto, hbox_roiauto) return lay def _updateNrAcq(self, new_value): dev = self.device.substitute(dev='TuneProc') self.led_acqcnt.set_channels2values( {dev.substitute(propty='FrameCount-Mon'): new_value})
class Tune(SiriusMainWindow): """Tune Window.""" def __init__(self, parent=None, prefix=VACA_PREFIX, section=''): super().__init__(parent) self.prefix = prefix self.section = section.upper() self.setObjectName(self.section+'App') self.setWindowTitle(self.section+' Tune') self.setWindowIcon( qta.icon('mdi.pulse', color=util.get_appropriate_color(self.section))) self._setupUi() self.setFocusPolicy(Qt.StrongFocus) def _setupUi(self): label = QLabel('<h2>'+self.section+' Tune<h2>', self, alignment=Qt.AlignHCenter) label.setObjectName('label') label.setStyleSheet('#label{min-height: 1.29em; max-height: 1.29em;}') if self.section == 'SI': # Tune self.wid_tune_mon = SITuneMonitor(self, self.prefix) # Settings self.tabCtrl = QTabWidget(self) hcolor = QColor(179, 229, 255) vcolor = QColor(255, 179, 179) self.ctrlH = TuneControls(parent=self, prefix=self.prefix, section=self.section, orientation='H', background=hcolor) self.tabCtrl.addTab(self.ctrlH, 'Horizontal') self.ctrlV = TuneControls(parent=self, prefix=self.prefix, section=self.section, orientation='V', background=vcolor) self.tabCtrl.addTab(self.ctrlV, 'Vertical') self.tabCtrl.setStyleSheet(""" QTabWidget::pane { border-left: 2px solid gray; border-bottom: 2px solid gray; border-right: 2px solid gray; } QTabBar::tab:first { background-color: #B3E5FF; } QTabBar::tab:last { background-color: #FFB3B3; } """) self.settings = QWidget() vbox_sett = QVBoxLayout(self.settings) vbox_sett.addWidget(self.tabCtrl) # Spectra view self.spectra_view = TuneSpectraControls( self, self.prefix, self.section) self.spectra_view.setObjectName('spectra_view') if self.section == 'BO': self.trig_gbox = QGroupBox('Trigger', self) self.trig_gbox.setLayout(QHBoxLayout()) self.trig_gbox.layout().addWidget(HLTriggerSimple( self.trig_gbox, device='BO-Glob:TI-TuneProc', prefix=self.prefix, duration=True, nrpulses=True)) vbox_sett.addWidget(self.trig_gbox) # Sepctrograms self.specH = BOTuneSpectrogramControls( parent=self, prefix=self.prefix, orientation='H', title='<h3>Horizontal</h3>', background=hcolor) self.specH.setObjectName('specH') self.specV = BOTuneSpectrogramControls( parent=self, prefix=self.prefix, orientation='V', title='<h3>Vertical</h3>', background=vcolor) self.specV.setObjectName('specV') vbox_meas = QVBoxLayout() vbox_meas.addWidget(self.specH) vbox_meas.addSpacing(10) vbox_meas.addWidget(self.specV) # Connect signals self.specH.spectrogram.idx2send_changed.connect( self.specV.update_idx2plot) self.specH.sb_idx2plot.editingFinished.connect( self.specV.update_idx2plot) self.specH.pb_resetbuff.clicked.connect( self.specV.spectrogram.resetBuffer) self.specH.sb_buffsz.editingFinished.connect( self.specV.update_buffsize) self.specV.spectrogram.idx2send_changed.connect( self.specH.update_idx2plot) self.specV.sb_idx2plot.editingFinished.connect( self.specH.update_idx2plot) self.specV.pb_resetbuff.clicked.connect( self.specH.spectrogram.resetBuffer) self.specV.sb_buffsz.editingFinished.connect( self.specH.update_buffsize) self.specH.spectrogram.new_data.connect( self.spectra_view.spectra.receiveDataH) self.specV.spectrogram.new_data.connect( self.spectra_view.spectra.receiveDataV) self.pb_showsett = QPushButton('>', self) self.pb_showsett.setObjectName('showsett') self.pb_showsett.setToolTip('Hide settings') self.pb_showsett.setStyleSheet( '#showsett{min-width:0.7em;max-width:0.7em;}') self.pb_showsett.released.connect(self._handle_settings_vis) hbox_vis = QHBoxLayout() hbox_vis.addWidget(self.pb_showsett, alignment=Qt.AlignLeft) self.setStyleSheet( "#specH, #specV {min-width:40em; min-height: 18em;}" "#spectra_view {min-width:40em; min-height: 36em;}" "#wid_tuneh, #wid_tunev {border:2px solid gray;}") cw = QWidget(self) self.setCentralWidget(cw) lay = QVBoxLayout(cw) if self.section == 'BO': hbox = QHBoxLayout() hbox.addWidget(self.settings) hbox.addLayout(vbox_meas) hbox.addWidget(self.spectra_view) hbox.setStretch(0, 1) hbox.setStretch(1, 1) hbox.setStretch(2, 1) lay.addWidget(label) lay.addLayout(hbox) lay.addLayout(hbox_vis) else: hbox = QHBoxLayout() hbox.addWidget(self.settings) hbox.addWidget(self.spectra_view) hbox.setStretch(0, 1) hbox.setStretch(1, 1) lay.addWidget(label) lay.addWidget(self.wid_tune_mon) lay.addLayout(hbox) lay.addLayout(hbox_vis) def _handle_settings_vis(self): vis = self.settings.isVisible() text = '<' if vis else '>' ttip = 'Show' if vis else 'Hide' self.pb_showsett.setText(text) self.pb_showsett.setToolTip(ttip+' settings') self.settings.setVisible(not vis) self.sender().parent().adjustSize() self.centralWidget().adjustSize() self.adjustSize()
def _setupCoefficientsViewWidget(self): ld_coef0 = QLabel('<h4>Set 0</h4>', self) ld_coef0.setStyleSheet('max-width: 3em;') lb_coef0 = PyDMLabel(self, self.dev_pref + ':DESC_CSET0') lb_coef0.setStyleSheet('background-color: #DCDCDC;') led_coef0 = SiriusLedAlert(self, self.dev_pref + ':CVERIFY.C') led_coef0.setStyleSheet('min-width: 1.29em; max-width: 1.29em;') graph_coef0 = WfmGraph(self) graph_coef0.add_scatter_curve(ychannel=self.dev_pref + ':CSET0', lineStyle=Qt.SolidLine) ld_coef1 = QLabel('<h4>Set 1</h4>', self) ld_coef1.setStyleSheet('max-width: 3em;') lb_coef1 = PyDMLabel(self, self.dev_pref + ':DESC_CSET1') lb_coef1.setStyleSheet('background-color: #DCDCDC;') led_coef1 = SiriusLedAlert(self, self.dev_pref + ':CVERIFY.D') led_coef1.setStyleSheet('min-width: 1.29em; max-width: 1.29em;') graph_coef1 = WfmGraph(self) graph_coef1.add_scatter_curve(ychannel=self.dev_pref + ':CSET1', lineStyle=Qt.SolidLine) ld_coef2 = QLabel('<h4>Set 2</h4>', self) ld_coef2.setStyleSheet('max-width: 3em;') lb_coef2 = PyDMLabel(self, self.dev_pref + ':DESC_CSET2') lb_coef2.setStyleSheet('background-color: #DCDCDC;') led_coef2 = SiriusLedAlert(self, self.dev_pref + ':CVERIFY.G') led_coef2.setStyleSheet('min-width: 1.29em; max-width: 1.29em;') graph_coef2 = WfmGraph(self) graph_coef2.add_scatter_curve(ychannel=self.dev_pref + ':CSET2', lineStyle=Qt.SolidLine) ld_coef3 = QLabel('<h4>Set 3</h4>', self) ld_coef3.setStyleSheet('max-width: 3em;') lb_coef3 = PyDMLabel(self, self.dev_pref + ':DESC_CSET3') lb_coef3.setStyleSheet('background-color: #DCDCDC;') led_coef3 = SiriusLedAlert(self, self.dev_pref + ':CVERIFY.H') led_coef3.setStyleSheet('min-width: 1.29em; max-width: 1.29em;') graph_coef3 = WfmGraph(self) graph_coef3.add_scatter_curve(ychannel=self.dev_pref + ':CSET3', lineStyle=Qt.SolidLine) gbox_coefview = QGroupBox('Coefficient Sets View', self) gbox_coefview.setLayout(QGridLayout()) tab_coefview = QTabWidget(gbox_coefview) gbox_coefview.layout().addWidget(tab_coefview, 0, 0) norm_wid = QWidget(tab_coefview) tab_coefview.addTab(norm_wid, 'Normal') lay_norm = QGridLayout(norm_wid) lay_norm.addWidget(ld_coef0, 0, 0) lay_norm.addWidget(lb_coef0, 0, 1) lay_norm.addWidget(led_coef0, 0, 2) lay_norm.addWidget(graph_coef0, 1, 0, 1, 3) lay_norm.addWidget(ld_coef1, 2, 0) lay_norm.addWidget(lb_coef1, 2, 1) lay_norm.addWidget(led_coef1, 2, 2) lay_norm.addWidget(graph_coef1, 3, 0, 1, 3) alter_wid = QWidget(tab_coefview) tab_coefview.addTab(alter_wid, 'Alternate') lay_alter = QGridLayout(alter_wid) lay_alter.addWidget(ld_coef2, 0, 3) lay_alter.addWidget(lb_coef2, 0, 4) lay_alter.addWidget(led_coef2, 0, 5) lay_alter.addWidget(graph_coef2, 1, 3, 1, 3) lay_alter.addWidget(ld_coef3, 2, 3) lay_alter.addWidget(lb_coef3, 2, 4) lay_alter.addWidget(led_coef3, 2, 5) lay_alter.addWidget(graph_coef3, 3, 3, 1, 3) return gbox_coefview