Пример #1
0
    def __init__(self, parent=None, filters=None):
        """Call super and set on/off colors."""
        QLed.__init__(self, parent)
        PyDMWidget.__init__(self)
        self.onColor = PyDMLed.Red
        self.offColor = PyDMLed.LightGreen

        self.prefix = VACA_PREFIX
        self.devname = PVName('LI-01:PS-Spect')
        self.prefixed_name = self.devname.substitute(prefix=self.prefix)
        self.filter = filters

        self.intlkstatus_ch = SiriusConnectionSignal(
            self.prefixed_name.substitute(propty='StatusIntlk-Mon'))
        self.intlkstatus_ch.connection_slot = self.connectionStateChanged
        self.intlkwarn_ch = SiriusConnectionSignal(
            self.prefixed_name.substitute(propty='IntlkWarn-Mon'))
        self.intlkwarn_ch.connection_slot = self.connectionStateChanged
        self.channel = self.intlkstatus_ch.address

        self.intlkwarn_bit = _PSe.LINAC_INTLCK_WARN.index('LoadI Over Thrs')

        self.intlkstatus_val = None
        self.intlkwarn_val = None
        self.intlkstatus_conn = None
        self.intlkwarn_conn = None

        self.intlkstatus_ch.new_value_signal[int].connect(self._update_values)
        self.intlkwarn_ch.new_value_signal[int].connect(self._update_values)
Пример #2
0
 def _createConnectors(self):
     """Create connectors to monitor device positions."""
     self._scrap_pospos = 0
     self.conn_scrap_pospos = SiriusConnectionSignal(
         self.device.substitute(propty='PositiveEdgePos-RB'))
     self.conn_scrap_pospos.new_value_signal[float].connect(self._setDevPos)
     self._scrap_negpos = 0
     self.conn_scrap_negpos = SiriusConnectionSignal(
         self.device.substitute(propty='NegativeEdgePos-RB'))
     self.conn_scrap_negpos.new_value_signal[float].connect(self._setDevPos)
Пример #3
0
 def _createConnectors(self):
     """Create connectors to monitor device positions."""
     self._slit_center = 0
     self._slit_width = 0
     self.conn_slitcenter = SiriusConnectionSignal(
         self.device.substitute(propty='Center-RB'))
     self.conn_slitcenter.new_value_signal[float].connect(self._setDevPos)
     self.conn_slitwidth = SiriusConnectionSignal(
         self.device.substitute(propty='Width-RB'))
     self.conn_slitwidth.new_value_signal[float].connect(self._setDevPos)
Пример #4
0
    def __init__(self, parent=None, prefix=_VACA_PREFIX, device=None):
        """Initialize object."""
        QWidget.__init__(self, parent=parent)
        self.prefix = prefix
        self.device = SiriusPVName(device)
        self.scrn_prefix = self.device.substitute(prefix=prefix)
        self._receivedData = False
        self.setObjectName(self.scrn_prefix.sec + 'App')

        self.screen_type_conn = SiriusConnectionSignal(
            self.scrn_prefix.substitute(propty='ScrnType-Sts'))
        self.screen_type_conn.new_value_signal.connect(
            self.updateCalibrationGridFlag)
        self._calibrationgrid_flag = self.screen_type_conn.getvalue()
        self.save_files.connect(self._saveGridLocalFiles)
        self.ch_ImgROIHeight = SiriusConnectionSignal(
            self.scrn_prefix.substitute(propty='ImgROIHeight-RB'))
        self.ch_ImgROIWidth = SiriusConnectionSignal(
            self.scrn_prefix.substitute(propty='ImgROIWidth-RB'))
        self.ch_ImgROIOffsetX = SiriusConnectionSignal(
            self.scrn_prefix.substitute(propty='ImgROIOffsetX-RB'))
        self.ch_ImgROIOffsetY = SiriusConnectionSignal(
            self.scrn_prefix.substitute(propty='ImgROIOffsetY-RB'))

        self._setupUi()
        self.setFocus(True)
        self.setFocusPolicy(Qt.StrongFocus)
        self._loadCalibrationGrid(default=True)
Пример #5
0
    def __init__(self, parent=None, channels=list(), label2width=dict(),
                 is_status=False):
        # QTableView.__init__(self, parent)
        QTreeView.__init__(self, parent)
        PyDMWidget.__init__(self)

        # setup table
        self._is_status = is_status
        self._date_fmt = ' %Y/%m/%d '
        self._time_fmt = ' %H:%M:%S '
        self.headerLabels = label2width.keys()
        self._model = QStandardItemModel()
        self._model.setHorizontalHeaderLabels(self.headerLabels)
        self.setModel(self._model)
        self.setUniformRowHeights(True)
        self.setHeader(QHeaderView(Qt.Horizontal))
        for idx, width in enumerate(label2width.values()):
            self.header().resizeSection(idx, width)
        self.header().resizeSections(QHeaderView.Fixed)
        self.header().setStretchLastSection(True)
        self.setSortingEnabled(True)
        self.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.setItemDelegateForColumn(2, LogItemDelegate(self))
        self.setSelectionBehavior(QAbstractItemView.SelectItems)
        self.setSelectionMode(QAbstractItemView.SingleSelection)
        self.setStyleSheet("gridline-color: #ffffff;")

        # set channels
        self.address2conn = dict()
        self.address2channels = dict()
        for address in channels:
            self.address2conn[address] = False
            channel = SiriusConnectionSignal(
                address=address,
                connection_slot=self.connection_changed,
                value_slot=self.value_changed,
                severity_slot=self.alarm_severity_changed)
            channel.connect()
            self.address2channels[address] = channel
            self._channels.append(channel)
Пример #6
0
 def _make_connections(self, wid, pv):
     if self.position:
         names = ('X', 'Y', 'Q', 'SUM')
     else:
         names = ('A', 'B', 'C', 'D')
     wid.channel = self.get_pvname(names[0] + pv)
     for name in names[1:]:
         chan = SiriusConnectionSignal(self.get_pvname(name + pv))
         wid.send_value_signal[int].connect(
             chan.send_value_signal[int].emit)
         wid.send_value_signal[float].connect(
             chan.send_value_signal[float].emit)
         chan.new_value_signal[int].connect(wid.channelValueChanged)
         chan.new_value_signal[float].connect(wid.channelValueChanged)
         self._chans.append(chan)
Пример #7
0
    def _setupUi(self):
        self.gbox_reliablemeas = self._setupReliableMeasWidget()

        self.gbox_generalsettings = self._setupGeneralSettingsWidget()

        self.gbox_trigger = self._setupTriggerWidget()

        self.gbox_config = self._setupConfigurationWidget()

        self.gbox_normalmode = self._setupMeasSettingsWidget('Normal')
        self.gbox_fastmode = self._setupMeasSettingsWidget('Fast')
        lay_mode = QGridLayout()
        lay_mode.addWidget(self.gbox_normalmode, 0, 0)
        lay_mode.addWidget(self.gbox_fastmode, 0, 0)
        self.mode_channel = SiriusConnectionSignal(
            self.dcct_prefix.substitute(propty='MeasMode-Sel'))
        self.mode_channel.new_value_signal.connect(self._showMeasModeSettings)

        lay = QGridLayout()
        lay.addWidget(
            QLabel('<h3>' + self.device + ' Settings Details</h3>',
                   self,
                   alignment=Qt.AlignCenter), 0, 0, 1, 2)
        lay.addWidget(self.gbox_reliablemeas, 1, 0)
        lay.addWidget(self.gbox_generalsettings, 2, 0)
        lay.addWidget(self.gbox_config, 3, 0)
        lay.addWidget(self.gbox_trigger, 3, 1)
        lay.addLayout(lay_mode, 1, 1, 2, 1)
        lay.setVerticalSpacing(15)
        lay.setHorizontalSpacing(15)
        lay.setRowStretch(0, 1)
        lay.setRowStretch(1, 3)
        lay.setRowStretch(2, 7)
        lay.setRowStretch(3, 2)
        self.setLayout(lay)

        self.setStyleSheet("""
            PyDMSpinbox, PyDMLabel{
                min-width:6em; max-width:6em;
                qproperty-alignment: AlignCenter;}
            PyDMLedMultiChannel, PyDMStateButton, PyDMEnumComboBox{
                min-width:6em; max-width:6em;}""")
Пример #8
0
    def __init__(self, parent=None, acq_type='ACQ', prefix='', bpm=''):
        self.acq_type = acq_type
        data_prefix = 'GEN_' if acq_type == 'ACQ' else 'PM_'
        super().__init__(
            parent=parent, prefix=prefix, bpm=bpm, data_prefix=data_prefix)

        self.samplespre = SiriusConnectionSignal(self.get_pvname(
            acq_type+'SamplesPre-RB', is_data=False))
        self.samplespost = SiriusConnectionSignal(self.get_pvname(
            acq_type+'SamplesPost-RB', is_data=False))
        self.shots = SiriusConnectionSignal(self.get_pvname(
            acq_type+'Shots-RB', is_data=False))

        self._chans.extend([self.samplespre, self.samplespost, self.shots])
        self.radio_buttons = []
        self.setupui()
Пример #9
0
    def _setupUi(self):
        cw = QWidget(self)
        self.setCentralWidget(cw)
        self.setFocusPolicy(Qt.StrongFocus)

        label = QLabel('<h4>Booster Charge</h4>',
                       self,
                       alignment=Qt.AlignCenter)

        # timeplot
        self.timeplot = SiriusTimePlot(parent=self, background='w')
        timespan = 60 * 60 * 6
        colors = ['blue', 'red', 'green', 'magenta']
        self.timeplot.timeSpan = timespan  # [s]
        self.timeplot.bufferSize = 2 * timespan  # [2 samples/s]
        self.timeplot.autoRangeY = True
        self.timeplot.showXGrid = True
        self.timeplot.showYGrid = True
        self.timeplot.setLabel('left', text='Charge', units='nC')
        self.timeplot.setObjectName('timeplot')
        self.timeplot.setStyleSheet(
            '#timeplot{min-width:28em; min-height: 18em;}')
        t_end = Time.now()
        t_init = t_end - timespan

        self._channels = dict()
        self._curves = dict()
        self._cb_show = dict()
        self._pvs_labels = dict()
        self._cb_offsets = dict()
        glay_aux = QGridLayout()
        glay_aux.setHorizontalSpacing(20)
        glay_aux.setVerticalSpacing(10)
        glay_aux.addWidget(QLabel('Show curves: ', self),
                           0,
                           0,
                           alignment=Qt.AlignCenter)
        glay_aux.addWidget(QLabel('Offset [nC]: ', self),
                           2,
                           0,
                           alignment=Qt.AlignCenter)
        for i, e in enumerate(self._energies):
            pvname = self._ioc_prefix.substitute(propty='Charge' + e + '-Mon')
            self._channels[e] = SiriusConnectionSignal(address=pvname)
            self._channels[e].new_value_signal[float].connect(
                self._update_charges)

            self.timeplot.addYChannel('Charge' + e,
                                      color=colors[i],
                                      lineWidth=2)
            curve = self.timeplot.curveAtIndex(-1)
            self._curves[e] = curve
            self.timeplot.fill_curve_with_archdata(self._curves[e],
                                                   pvname,
                                                   t_init=t_init.get_iso8601(),
                                                   t_end=t_end.get_iso8601())

            cb = QCheckBox(e)
            cb.setChecked(True)
            cb.setStyleSheet('color:' + colors[i] + ';')
            cb.stateChanged.connect(curve.setVisible)
            self._cb_show[e] = cb

            lb = QLabel('', self, alignment=Qt.AlignCenter)
            self._pvs_labels[e] = lb

            sb = QDoubleSpinBoxPlus(self)
            sb.energy = e
            sb.setMinimum(0)
            sb.setMaximum(1e6)
            sb.setDecimals(4)
            sb.setStyleSheet('max-width: 5em;')
            sb.setValue(self._latest_offsets[e])
            sb.editingFinished.connect(self._update_offset)
            self._cb_offsets[e] = sb

            glay_aux.addWidget(cb, 0, i + 1, alignment=Qt.AlignCenter)
            glay_aux.addWidget(lb, 1, i + 1, alignment=Qt.AlignCenter)
            glay_aux.addWidget(sb, 2, i + 1, alignment=Qt.AlignCenter)

        self.pb_offset = QPushButton('Update offset', self)
        self.pb_offset.clicked.connect(self._set_current_values_2_offset)
        self.pb_offset.setToolTip('Set offsets to current charge values.')
        glay_aux.addWidget(self.pb_offset, 1, 0)

        lay = QVBoxLayout(cw)
        lay.addWidget(label)
        lay.addWidget(self.timeplot)
        lay.addLayout(glay_aux)
Пример #10
0
class DCCTMonitor(QWidget):
    """DCCT data monitoring."""
    def __init__(self, parent=None, prefix='', device=''):
        """Initialize object."""
        super().__init__(parent)
        self.prefix = prefix
        self.device = SiriusPVName(device)
        self.use_raw = self.device.sec == 'BO'
        self.dcct_prefix = self.device.substitute(prefix=prefix)

        self.acqmode_channel = SignalChannel(
            self.dcct_prefix.substitute(propty='MeasMode-Sel'))
        self.acqmode_channel.new_value_signal[int].connect(self.updateParams)
        self.normalnrsamp_channel = SignalChannel(
            self.dcct_prefix.substitute(propty='SampleCnt-RB'))
        self.normalnrsamp_channel.new_value_signal[int].connect(
            self.updateParams)
        self.fastnrsamp_channel = SignalChannel(
            self.dcct_prefix.substitute(propty='FastSampleCnt-RB'))
        self.fastnrsamp_channel.new_value_signal[int].connect(
            self.updateParams)
        self._acq_mode = None
        self._acq_normalnrsamp = None
        self._acq_fastnrsamp = None

        self._downsampling = 1
        self._smooth_method = 'Average'
        self._smooth_nracq = 1
        self._smooth_buffer = list()

        self._setupUi()

    def _setupUi(self):
        self.currhist = self._setupTimeHistory()
        self.currhist.setVisible(not self.use_raw)
        self.rawreads = self._setupRawReadings()
        self.rawreads.setVisible(self.use_raw)

        self.pb_vis = QPushButton(self)
        self.pb_vis.setStyleSheet(
            'QPushButton{min-width: 0.8em; max-width: 0.8em;}')
        self.menu_vis = QMenu()
        self.switch_act = self.menu_vis.addAction('Switch to ' + (
            'Time History' if self.use_raw else 'Raw Readings'))
        self.switch_act.triggered.connect(self._handle_data_visualization)
        self.pb_vis.setMenu(self.menu_vis)

        self.setStyleSheet("""
            .QLabel{max-height:1.5em;}
            PyDMWaveformPlot, PyDMTimePlot{min-width:30em; min-height:20em;}
        """)

        lay = QGridLayout(self)
        lay.setContentsMargins(0, 0, 0, 0)
        lay.setHorizontalSpacing(0)
        lay.addWidget(self.pb_vis, 0, 0, alignment=Qt.AlignTop | Qt.AlignLeft)
        lay.addWidget(self.currhist, 0, 1)
        lay.addWidget(self.rawreads, 0, 1)

    def _setupTimeHistory(self):
        self.label_currhist = QLabel('<h3>Current History</h3>',
                                     self,
                                     alignment=Qt.AlignCenter)

        self.timegraph = SiriusTimePlot(self)
        self.timegraph.timeSpan = 600
        channel = self.dcct_prefix.substitute(propty='Current-Mon')
        self.timegraph.addYChannel(y_channel=channel,
                                   name='Current History',
                                   color='blue',
                                   lineWidth=1,
                                   lineStyle=Qt.SolidLine)
        self.timegraph.autoRangeX = True
        self.timegraph.autoRangeY = True
        self.timegraph.backgroundColor = QColor(255, 255, 255)
        self.timegraph.showLegend = False
        self.timegraph.showXGrid = True
        self.timegraph.showYGrid = True
        self.timegraph.plotItem.showButtons()
        self.timecurve = self.timegraph.curveAtIndex(0)

        wid = QWidget()
        lay = QGridLayout(wid)
        lay.setAlignment(Qt.AlignTop)
        lay.setRowStretch(0, 1)
        lay.setRowStretch(1, 9)
        lay.addWidget(self.label_currhist, 0, 0)
        lay.addWidget(self.timegraph, 1, 0)
        return wid

    def _setupRawReadings(self):
        self.label_waveread = QLabel('<h3>Current Raw Readings</h3>',
                                     self,
                                     alignment=Qt.AlignCenter)

        self.wavegraph = PyDMWaveformPlot(self)
        self.wavegraph.setLabels(left='Current [mA]', bottom='Index')
        channel = 'FAKE:Readings'
        self.rawreadings_channel = SignalChannel(
            self.dcct_prefix.substitute(propty='RawReadings-Mon'))
        self.rawreadings_channel.new_value_signal[np.ndarray].connect(
            self._updateRawBuffer)
        self.wavegraph.addChannel(y_channel=channel,
                                  name='Current Raw Readings',
                                  color='blue',
                                  lineWidth=2,
                                  lineStyle=Qt.SolidLine)
        self.wavegraph.autoRangeX = True
        self.wavegraph.autoRangeY = True
        self.wavegraph.backgroundColor = QColor(255, 255, 255)
        self.wavegraph.showLegend = False
        self.wavegraph.showXGrid = True
        self.wavegraph.showYGrid = True
        self.wavegraph.plotItem.showButtons()
        self.wavecurve = self.wavegraph.curveAtIndex(0)

        wid = QWidget()
        lay = QGridLayout(wid)
        lay.setAlignment(Qt.AlignTop)
        lay.setRowStretch(0, 1)
        lay.setRowStretch(1, 9)
        lay.addWidget(self.label_waveread, 0, 0)
        lay.addWidget(self.wavegraph, 1, 0)

        # Smoothing
        evgname = SiriusPVName(_LLTimeSearch.get_evg_name())
        self._evnt_dly = SignalChannel(
            evgname.substitute(prefix=self.prefix,
                               propty='Dig' + self.device.sec + 'Delay-RB'))
        self._evnt_dly.new_value_signal[float].connect(self.updateRawXAxis)
        self._trig_dly = SignalChannel(
            self.dcct_prefix.substitute(dis='TI', propty='Delay-RB'))
        self._trig_dly.new_value_signal[float].connect(self.updateRawXAxis)
        self._smpl_cnt = SignalChannel(
            self.dcct_prefix.substitute(propty='FastSampleCnt-RB'))
        self._smpl_cnt.new_value_signal[float].connect(self.updateRawXAxis)
        self._meas_per = SignalChannel(
            self.dcct_prefix.substitute(propty='FastMeasPeriod-RB'))
        self._meas_per.new_value_signal[float].connect(self.updateRawXAxis)

        self.cb_timeaxis = QCheckBox('Use time axis', self)
        self.cb_timeaxis.setChecked(True)
        self.cb_timeaxis.stateChanged.connect(self.updateRawXAxis)
        self.cb_timeaxis.setLayoutDirection(Qt.RightToLeft)
        lay.addWidget(self.cb_timeaxis, 2, 0, alignment=Qt.AlignLeft)
        lay.setRowStretch(2, 1)

        l_smoothmethod = QLabel('Method: ', self)
        self.cb_smoothmethod = QComboBox(self)
        self.cb_smoothmethod.addItems(['Average', 'Median'])
        self.cb_smoothmethod.currentTextChanged.connect(
            self.setRawSmoothMethod)

        l_smoothnracq = QLabel('Nr.Acqs.: ', self)
        self.sb_smoothnracq = QSpinBoxPlus(self)
        self.sb_smoothnracq.setValue(1)
        self.sb_smoothnracq.valueChanged.connect(self.setRawSmoothNrAcq)

        l_smoothbuff = QLabel('Buffer Size: ', self)
        l_smoothbuff.setSizePolicy(QSzPly.Minimum, QSzPly.Preferred)
        self.label_buffsize = QLabel('', self)
        self.label_buffsize.setStyleSheet('min-width:3em; max-width:3em;')
        self.pb_resetbuff = QPushButton(qta.icon('mdi.delete-empty'), '', self)
        self.pb_resetbuff.setToolTip('Reset buffer')
        self.pb_resetbuff.setObjectName('resetbuff')
        self.pb_resetbuff.setStyleSheet(
            "#resetbuff{min-width:25px; max-width:25px; icon-size:20px;}")
        self.pb_resetbuff.clicked.connect(self.resetRawBuffer)
        hlay_buff = QHBoxLayout()
        hlay_buff.addWidget(self.label_buffsize)
        hlay_buff.addWidget(self.pb_resetbuff)

        l_down = QLabel('Downsampling: ', self)
        self.sb_down = QSpinBoxPlus(self)
        self.sb_down.setValue(1)
        self.sb_down.valueChanged.connect(self.setRawDownsampling)

        gbox_smooth = QGroupBox('Smoothing of Readings')
        glay_smooth = QGridLayout(gbox_smooth)
        glay_smooth.addWidget(l_smoothmethod, 0, 0)
        glay_smooth.addWidget(self.cb_smoothmethod, 0, 1)
        glay_smooth.addWidget(l_smoothnracq, 1, 0)
        glay_smooth.addWidget(self.sb_smoothnracq, 1, 1)
        glay_smooth.addWidget(QLabel(''), 0, 2)
        glay_smooth.addWidget(l_smoothbuff, 0, 3)
        glay_smooth.addLayout(hlay_buff, 0, 4, 1, 2)
        glay_smooth.addWidget(l_down, 1, 3)
        glay_smooth.addWidget(self.sb_down, 1, 4, 1, 2)
        glay_smooth.setColumnStretch(0, 10)
        glay_smooth.setColumnStretch(1, 10)
        glay_smooth.setColumnStretch(2, 2)
        glay_smooth.setColumnStretch(3, 10)
        glay_smooth.setColumnStretch(4, 5)
        glay_smooth.setColumnStretch(5, 5)
        lay.addWidget(gbox_smooth, 3, 0)
        lay.setRowStretch(3, 3)
        gbox_smooth.setStyleSheet("""
            .QLabel{
                qproperty-alignment: 'AlignVCenter | AlignRight';}
            QPushButton{
                min-width:3em; max-width:3em;}""")

        return wid

    def _updateRawBuffer(self, raw):
        if raw is None:
            return
        samp = self._acq_fastnrsamp \
            if self._acq_mode == _DCCTc.MeasModeSel.Fast \
            else self._acq_normalnrsamp
        if not samp:
            return
        samp -= samp % self._downsampling
        if samp < 1:
            return
        data = raw[:samp]

        self._smooth_buffer.append(data)
        if len(self._smooth_buffer) > self._smooth_nracq:
            self._smooth_buffer.pop(0)

        self._updateRawCurve()

    def _updateRawCurve(self):
        buff = np.array(self._smooth_buffer, dtype=float)
        self.label_buffsize.setText(str(self.smoothBufferSize))

        if not len(buff):
            return
        if len(buff) > 1:
            if self._smooth_method == 'Average':
                fdata = np.mean(buff, axis=0)
            elif self._smooth_method == 'Median':
                fdata = np.median(buff, axis=0)
        else:
            fdata = buff[0]

        down = self._downsampling
        if down > 1:
            fdata = np.mean(fdata.reshape(-1, down), axis=1)

        self.wavecurve.receiveYWaveform(fdata)
        self.wavecurve.redrawCurve()

    def setRawDownsampling(self, new_value):
        """Update number of samples to use in downsampling."""
        self._downsampling = new_value
        self.resetRawBuffer()

    def setRawSmoothMethod(self, new_method):
        """Update method to perform raw readings smoothing."""
        self._smooth_method = new_method
        self._updateRawCurve()

    def setRawSmoothNrAcq(self, new_value):
        """Update number of samples to use in smoothing."""
        self._smooth_nracq = new_value
        exc = len(self._smooth_buffer) - self._smooth_nracq
        if exc > 0:
            for i in range(exc):
                self._smooth_buffer.pop(0)

    @property
    def smoothBufferSize(self):
        """Smoothing buffer length."""
        return len(self._smooth_buffer)

    def resetRawBuffer(self):
        """Reset smoothing buffer."""
        self._smooth_buffer = list()
        self._updateRawCurve()

    def updateParams(self, new_value):
        """Handle control visualization according to mode."""
        address = self.sender().address
        if 'Mode' in address:
            self._acq_mode = new_value
        elif 'Fast' in address:
            self._acq_fastnrsamp = new_value
        else:
            self._acq_normalnrsamp = new_value
        self.resetRawBuffer()

    def updateRawXAxis(self):
        """Update X axis of waveform graph."""
        smpl = self._smpl_cnt.getvalue()
        if self.cb_timeaxis.checkState():
            evnt = self._evnt_dly.getvalue()
            trig = self._trig_dly.getvalue()
            peri = self._meas_per.getvalue()

            if any([val is None for val in [evnt, trig, smpl, peri]]):
                return

            init = (evnt + trig) / 1e3
            endt = init + peri * 1e3

            xdata = np.linspace(init, endt, smpl)
            xlabel = 'Time [ms]'
        else:
            xdata = np.arange(0, smpl)
            xlabel = 'Index'
        self.wavegraph.setLabels(bottom=xlabel)
        self.wavecurve.receiveXWaveform(xdata)

    def _handle_data_visualization(self):
        show_raw = 'Raw' in self.sender().text()
        self.sender().setText('Switch to ' +
                              ('Time History' if show_raw else 'Raw Readings'))
        self.currhist.setVisible(not show_raw)
        self.rawreads.setVisible(show_raw)
Пример #11
0
    def __init__(self, parent=None, prefix='', section=''):
        """Init."""
        super().__init__(parent)
        self.prefix = prefix
        self.section = section

        self.autoRangeX = True
        self.autoRangeY = True
        self.showXGrid = True
        self.showYGrid = True
        self.axisColor = QColor(0, 0, 0)
        self.backgroundColor = QColor(255, 255, 255)
        self.showLegend = False
        self.plotItem.showButtons()
        leftAxis = self.getAxis('left')
        leftAxis.setStyle(autoExpandTextSpace=False, tickTextWidth=25)

        self.x_channel = 'Tune'

        self.addChannel(y_channel='FAKE:SpectrumH',
                        name='Tune H',
                        redraw_mode=2,
                        color='blue',
                        lineWidth=2,
                        lineStyle=Qt.SolidLine)
        self.curveH = self.curveAtIndex(0)
        self.curveH.x_channels = {
            'Tune':
            SiriusConnectionSignal(
                _PVName(self.section +
                        '-Glob:DI-Tune-H:TuneFracArray-Mon').substitute(
                            prefix=self.prefix)),
            'Freq':
            SiriusConnectionSignal(
                _PVName(self.section +
                        '-Glob:DI-Tune-H:FreqArray-Mon').substitute(
                            prefix=self.prefix))
        }
        self.curveH.setVisible(True)

        self.addChannel(y_channel='FAKE:SpectrumV',
                        name='Tune V',
                        redraw_mode=2,
                        color='red',
                        lineWidth=2,
                        lineStyle=Qt.SolidLine)
        self.curveV = self.curveAtIndex(1)
        self.curveV.x_channels = {
            'Tune':
            SiriusConnectionSignal(
                _PVName(self.section +
                        '-Glob:DI-Tune-V:TuneFracArray-Mon').substitute(
                            prefix=self.prefix)),
            'Freq':
            SiriusConnectionSignal(
                _PVName(self.section +
                        '-Glob:DI-Tune-V:FreqArray-Mon').substitute(
                            prefix=self.prefix))
        }
        self.curveV.setVisible(True)

        if self.section == 'SI':
            self.maxRedrawRate = 5
            self.curveH_y_channel = SiriusConnectionSignal(
                _PVName('SI-Glob:DI-TuneProc-H:Trace-Mon').substitute(
                    prefix=self.prefix))
            self.curveH_y_channel.new_value_signal[np.ndarray].connect(
                self.receiveDataH)
            self.curveV_y_channel = SiriusConnectionSignal(
                _PVName('SI-Glob:DI-TuneProc-V:Trace-Mon').substitute(
                    prefix=self.prefix))
            self.curveV_y_channel.new_value_signal[np.ndarray].connect(
                self.receiveDataV)
            self.freqrevH_channel = SiriusConnectionSignal(
                _PVName('SI-Glob:DI-Tune-H:FreqRev-Mon').substitute(
                    prefix=self.prefix))
            self.freqrevV_channel = SiriusConnectionSignal(
                _PVName('SI-Glob:DI-Tune-V:FreqRev-Mon').substitute(
                    prefix=self.prefix))
            self.freqrevnH_channel = SiriusConnectionSignal(
                _PVName('SI-Glob:DI-Tune-H:FreqRevN-Mon').substitute(
                    prefix=self.prefix))
            self.freqrevnV_channel = SiriusConnectionSignal(
                _PVName('SI-Glob:DI-Tune-V:FreqRevN-Mon').substitute(
                    prefix=self.prefix))
            self.revnH_channel = SiriusConnectionSignal(
                _PVName('SI-Glob:DI-Tune-H:RevN-RB').substitute(
                    prefix=self.prefix))
            self.revnV_channel = SiriusConnectionSignal(
                _PVName('SI-Glob:DI-Tune-V:RevN-RB').substitute(
                    prefix=self.prefix))

            self.markers = dict()
            ci = 2
            for ax in ['H', 'V']:
                self.markers[ax] = dict()
                for mtyp in ['', 'D']:
                    for i in range(1, 5):
                        si = str(i)
                        mark_dict = dict()
                        ch_enbl = SiriusConnectionSignal(
                            _PVName('SI-Glob:DI-TuneProc-' + ax + ':Enbl' +
                                    mtyp + 'Mark' + si +
                                    '-Sts').substitute(prefix=self.prefix))
                        ch_enbl.orientation = ax
                        ch_enbl.idx = si
                        ch_enbl.new_value_signal[int].connect(
                            self._update_markers_enable)
                        mark_dict['Enbl'] = ch_enbl

                        ch_x = SiriusConnectionSignal(
                            _PVName('SI-Glob:DI-TuneProc-' + ax + ':' + mtyp +
                                    'MarkX' + si +
                                    'Disp-Mon').substitute(prefix=self.prefix))
                        ch_x.orientation = ax
                        ch_x.idx = si
                        ch_x.axis = 'X'
                        ch_x.new_value_signal[float].connect(
                            self._update_markers_value)
                        mark_dict['X'] = ch_x

                        ch_y = SiriusConnectionSignal(
                            _PVName('SI-Glob:DI-TuneProc-' + ax + ':' + mtyp +
                                    'MarkY' + si +
                                    ('' if mtyp == '' else 'Disp') +
                                    '-Mon').substitute(prefix=self.prefix))
                        ch_y.orientation = ax
                        ch_y.idx = si
                        ch_y.axis = 'Y'
                        ch_y.new_value_signal[float].connect(
                            self._update_markers_value)
                        mark_dict['Y'] = ch_y

                        self.addChannel(y_channel='FAKE:' + mtyp + 'MarkY',
                                        x_channel='FAKE:' + mtyp + 'MarkX',
                                        name=mtyp + 'Mark ' + si,
                                        redraw_mode=2,
                                        color=marker_color[mtyp +
                                                           'Mark'][ax][si],
                                        lineWidth=2,
                                        lineStyle=1,
                                        symbol='o',
                                        symbolSize=10)
                        mark_dict['curve'] = self.curveAtIndex(ci)
                        ci += 1
                        self.markers[ax][mtyp + 'Mark' + si] = mark_dict
Пример #12
0
    def _setupUi(self):
        cwt = QWidget(self)
        self.setCentralWidget(cwt)

        # label
        lab = QLabel(
            '<h3>'+self._tl+' Position and Angle Correction</h3>', cwt)
        lab.setStyleSheet("""
            min-height:1.55em; max-height: 1.55em;
            qproperty-alignment: 'AlignVCenter | AlignRight';
            background-color: qlineargradient(spread:pad, x1:1, y1:0.0227273,
                              x2:0, y2:0, stop:0 rgba(173, 190, 207, 255),
                              stop:1 rgba(213, 213, 213, 255));""")

        # apply button
        self.pb_updateref = PyDMPushButton(
            self, 'Update Reference', pressValue=1,
            init_channel=self.posang_prefix.substitute(
                propty='SetNewRefKick-Cmd'))
        self.pb_updateref.setStyleSheet(
            'min-height: 2.4em; max-height: 2.4em;')
        self.led_needrefupdt = SiriusLedAlert(
            self, self.posang_prefix.substitute(propty='NeedRefUpdate-Mon'))
        self.ch_needrefupdt = SiriusConnectionSignal(
            self.posang_prefix.substitute(propty='NeedRefUpdate-Mon'))
        self.ch_needrefupdt.new_value_signal[int].connect(
            self._handle_need_update_ref_led)
        self.led_needrefupdt.setStyleSheet(
            'QLed{min-width: 1.29em; max-width: 1.29em;}')
        box_ref = QHBoxLayout()
        box_ref.setContentsMargins(0, 0, 0, 0)
        box_ref.addWidget(self.pb_updateref)
        box_ref.addWidget(self.led_needrefupdt)

        # delta setters
        self.hgbox = QGroupBox('Horizontal', self)
        self.hgbox.setLayout(self._setupDeltaControlLayout('x'))

        self.vgbox = QGroupBox('Vertical', self)
        self.vgbox.setLayout(self._setupDeltaControlLayout('y'))

        # correctors
        self.corrgbox = QGroupBox('Correctors', self)
        self.corrgbox.setLayout(self._setupCorrectorsLayout())

        # status
        self.statgbox = QGroupBox('Correction Status', self)
        self.statgbox.setLayout(self._setupStatusLayout())

        glay = QGridLayout(cwt)
        glay.setHorizontalSpacing(12)
        glay.setVerticalSpacing(12)
        glay.addWidget(lab, 0, 0, 1, 2)
        glay.addLayout(box_ref, 1, 0, 1, 2)
        glay.addWidget(self.hgbox, 2, 0)
        glay.addWidget(self.vgbox, 2, 1)
        glay.addWidget(self.corrgbox, 3, 0, 1, 2)
        glay.addWidget(self.statgbox, 4, 0, 1, 2)

        # menu
        act_settings = self.menuBar().addAction('Settings')
        _hlautil.connect_window(act_settings, CorrParamsDetailWindow,
                                parent=self, tl=self._tl, prefix=self._prefix)

        # stlesheet
        self.setStyleSheet("""
            PyDMSpinbox{
                min-width: 5em; max-width: 5em;
            }
            PyDMLabel, PyDMSpinboxScrollbar{
                min-width: 6em; max-width: 6em;
            }
            QPushButton{
                min-width: 8em;
            }
            QLabel{
                min-height: 1.35em;
                qproperty-alignment: AlignCenter;
            }
        """)
Пример #13
0
 def __init__(self, parent=None, prefix='', bpm=''):
     super().__init__(parent=parent, prefix=prefix, bpm=bpm)
     self.setupui()
     mode = SiriusConnectionSignal(self.get_pvname('ACQBPMMode-Sts'))
     mode.new_value_signal[int].connect(self.toggle_multi_single)
     self._chans.append(mode)
Пример #14
0
class MultiTurnData(BaseWidget):

    def __init__(self, parent=None, acq_type='ACQ', prefix='', bpm=''):
        self.acq_type = acq_type
        data_prefix = 'GEN_' if acq_type == 'ACQ' else 'PM_'
        super().__init__(
            parent=parent, prefix=prefix, bpm=bpm, data_prefix=data_prefix)

        self.samplespre = SiriusConnectionSignal(self.get_pvname(
            acq_type+'SamplesPre-RB', is_data=False))
        self.samplespost = SiriusConnectionSignal(self.get_pvname(
            acq_type+'SamplesPost-RB', is_data=False))
        self.shots = SiriusConnectionSignal(self.get_pvname(
            acq_type+'Shots-RB', is_data=False))

        self._chans.extend([self.samplespre, self.samplespost, self.shots])
        self.radio_buttons = []
        self.setupui()

    @property
    def nrsamplespershot(self):
        if self.samplespost.connected and self.samplespre.connected:
            return self.samplespost.getvalue() + self.samplespre.getvalue()

    @property
    def nrsamples(self):
        val = self.nrsamplespershot
        if val and self.shots.connected:
            return self.nrsamplespershot*self.shots.getvalue()

    def setupui(self):
        vbl = QVBoxLayout(self)
        self.stack = QStackedWidget(self)
        vbl.addWidget(self.stack)

        rbA = QRadioButton('Antennas', self)
        rbP = QRadioButton('Positions', self)
        rbA.toggled.connect(_part(self.toggle_button, 0))
        rbP.toggled.connect(_part(self.toggle_button, 1))
        self.radio_buttons.append(rbA)
        self.radio_buttons.append(rbP)
        rbA.setChecked(True)
        hbl = QHBoxLayout()
        hbl.addStretch()
        hbl.addWidget(rbA)
        hbl.addStretch()
        hbl.addWidget(rbP)
        hbl.addStretch()
        vbl.addItem(hbl)

        # ##### Antennas Widget ######
        stack1 = QWidget(self.stack)
        self.stack.addWidget(stack1)
        vbl = QVBoxLayout(stack1)

        graph = self.create_graph(stack1, False)
        vbl.addWidget(graph)
        stats = self.create_statistics(stack1, False)
        vbl.addWidget(stats)

        if not self.data_prefix.startswith('PM'):
            hbl2 = QHBoxLayout()
            hbl2.addStretch()
            vbl.addItem(hbl2)
            pb = QPushButton('Open FFT Data', stack1)
            hbl2.addWidget(pb)
            hbl2.addStretch()
            Window = create_window_from_widget(
                FFTData, title=self.bpm+': FFT Data')
            util.connect_window(
                pb, Window, parent=stack1, prefix=self.prefix,
                bpm=self.bpm, data_prefix=self.data_prefix, position=False)

        # ##### Position Widget ######
        stack2 = QWidget(self.stack)
        self.stack.addWidget(stack2)
        vbl = QVBoxLayout(stack2)

        graph = self.create_graph(stack2, True)
        vbl.addWidget(graph)
        stats = self.create_statistics(stack2, True)
        vbl.addWidget(stats)

        if not self.data_prefix.startswith('PM'):
            hbl2 = QHBoxLayout()
            hbl2.addStretch()
            vbl.addItem(hbl2)
            pb = QPushButton('Open FFT Data', stack2)
            hbl2.addWidget(pb)
            hbl2.addStretch()
            Window = create_window_from_widget(
                FFTData, title=self.bpm+': FFT Data')
            util.connect_window(
                pb, Window, parent=stack1, prefix=self.prefix,
                bpm=self.bpm, data_prefix=self.data_prefix, position=True)

        self.setStyleSheet("""
            #MultiTurnDataGraph{
                min-width:48em;
                min-height:24em;
            }
            QLabel{
                min-width:6em; max-width:6em;
                min-height:1.5em; max-height:1.5em;
            }""")

    def create_statistics(self, wid, position=True):
        text, unit, names, _ = self._get_properties(position)

        wid = QWidget(wid)
        hbl = QHBoxLayout(wid)
        hbl.addStretch()
        grpbx = QGroupBox('Statistics', wid)
        hbl.addWidget(grpbx)
        hbl.addStretch()

        gdl = QGridLayout(grpbx)
        gdl.setHorizontalSpacing(20)
        gdl.setVerticalSpacing(20)

        stats = ('MeanValue', 'Sigma', 'MinValue', 'MaxValue')
        for j, stat in enumerate(('Average', 'Sigma', 'Minimum', 'Maximum')):
            lab = QLabel(stat, wid)
            lab.setAlignment(Qt.AlignCenter)
            gdl.addWidget(lab, 0, j+1)
        for i, name in enumerate(names):
            lab = QLabel(text[:3] + name, wid)
            lab.setAlignment(Qt.AlignCenter)
            gdl.addWidget(lab, i+1, 0)
            for j, stat in enumerate(stats):
                lab = SiriusLabel(wid, init_channel=self.get_pvname(
                    name+'_STATS'+stat+'_RBV'))
                lab.setAlignment(Qt.AlignCenter)
                lab.unit_changed(unit)
                lab.showUnits = True
                lab.precisionFromPV = False
                lab.precision = 3
                gdl.addWidget(lab, i+1, j+1)
        return wid

    def create_graph(self, wid, position=True):
        text, unit, names, colors = self._get_properties(position)
        if position:
            unit = unit[1:]

        graph = GraphWave(
            wid, prefix=self.prefix, bpm=self.bpm,
            data_prefix=self.data_prefix)
        graph.setObjectName('MultiTurnDataGraph')
        graph.setLabel('left', text=text, units=unit)
        for name, cor in zip(names, colors):
            opts = dict(
                y_channel=name+'ArrayData',
                name=text[:3]+name,
                color=cor,
                lineStyle=1,
                lineWidth=1)  # NOTE: If > 1: very low performance
            opts['y_channel'] = self.get_pvname(opts['y_channel'])
            if position:
                graph.addChannel(add_scale=1e-9, **opts)
            else:
                graph.addChannel(**opts)
        return graph

    def _get_properties(self, position=True):
        if position:
            text = 'Positions'
            unit = 'nm'
            names = ('X', 'Y', 'Q', 'SUM')
            colors = ('blue', 'red', 'green', 'black')
        else:
            text = 'Antennas'
            unit = 'count'
            names = ('A', 'B', 'C', 'D')
            colors = ('blue', 'red', 'green', 'magenta')
        return text, unit, names, colors

    def toggle_button(self, i, tog):
        if tog:
            self.stack.setCurrentIndex(i)

    def control_visibility_buttons(self, text):
        bo = not text.startswith('adc')
        self.radio_buttons[1].setVisible(bo)
        self.radio_buttons[0].setChecked(True)
Пример #15
0
    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
Пример #16
0
    def _setupUi(self):
        cw = QWidget(self)
        self.setCentralWidget(cw)
        lay = QFormLayout(cw)
        lay.setLabelAlignment(Qt.AlignRight)
        lay.setFormAlignment(Qt.AlignCenter)

        # title
        self.title_label = QLabel('<h3>' + self.title + '<h3>',
                                  self,
                                  alignment=Qt.AlignCenter)
        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)
        lay.addRow(self.title_label)

        label_enbl = QLabel('Enable: ', self)
        self.bt_enbl = PyDMStateButton(
            self,
            self.dev.substitute(propty='Enbl' + self.mtyp + 'Mark' + self.idx +
                                '-Sel'))
        self.bt_enbl.shape = 1
        self.led_enbl = SiriusLedState(
            self,
            self.dev.substitute(propty='Enbl' + self.mtyp + 'Mark' + self.idx +
                                '-Sts'))
        hbox_enbl = QHBoxLayout()
        hbox_enbl.addWidget(self.bt_enbl)
        hbox_enbl.addWidget(self.led_enbl)
        lay.addRow(label_enbl, hbox_enbl)

        label_enblautomax = QLabel('Auto Max Peak: ', self)
        ch_enblautomax = self.dev.substitute(propty='Enbl' + self.mtyp +
                                             'MaxAuto' + self.idx + '-Sel')
        self.enblAutoMaxChannel = SiriusConnectionSignal(ch_enblautomax)
        self.enblAutoMaxChannel.new_value_signal[int].connect(
            self._handle_values_visibility)
        self.bt_enblautomax = PyDMStateButton(self, ch_enblautomax)
        self.bt_enblautomax.shape = 1
        self.led_enblautomax = SiriusLedState(
            self,
            self.dev.substitute(propty='Enbl' + self.mtyp + 'MaxAuto' +
                                self.idx + '-Sts'))
        hbox_enblautomax = QHBoxLayout()
        hbox_enblautomax.addWidget(self.bt_enblautomax)
        hbox_enblautomax.addWidget(self.led_enblautomax)
        lay.addRow(label_enblautomax, hbox_enblautomax)

        label_x = QLabel(' X: ', self)
        self.sb_x = PyDMLineEdit(
            self,
            self.dev.substitute(propty=self.mtyp + 'MarkX' + self.idx + '-SP'))
        self.lb_x = PyDMLabel(
            self,
            self.dev.substitute(propty=self.mtyp + 'MarkX' + self.idx + '-RB'))
        hbox_x = QHBoxLayout()
        hbox_x.addWidget(self.sb_x)
        hbox_x.addWidget(self.lb_x)
        lay.addRow(label_x, hbox_x)

        label_y = QLabel(' Y: ', self)
        self.lb_y = PyDMLabel(
            self,
            self.dev.substitute(propty=self.mtyp + 'MarkY' + self.idx +
                                '-Mon'))
        hbox_y = QHBoxLayout()
        hbox_y.addWidget(self.lb_y)
        if self.mtyp == 'D':
            self.lb_dynamicY = PyDMLabel(
                self,
                self.dev.substitute(propty='DynamicDX' + self.idx + '-Mon'))
            self.lb_dynamicY.setVisible(False)
            hbox_y.addWidget(self.lb_dynamicY)
        lay.addRow(label_y, hbox_y)

        self.pb_max = PyDMPushButton(
            parent=self,
            label='Mark Max Peak',
            pressValue=1,
            init_channel=self.dev.substitute(propty=self.mtyp + 'MarkMax' +
                                             self.idx + '-Cmd'))
        self.pb_maxnext = PyDMPushButton(
            parent=self,
            label='Mark Max Next',
            pressValue=1,
            init_channel=self.dev.substitute(propty=self.mtyp + 'MarkMaxNext' +
                                             self.idx + '-Cmd'))
        self.pb_maxright = PyDMPushButton(
            parent=self,
            label='Mark Max Right',
            pressValue=1,
            init_channel=self.dev.substitute(
                propty=self.mtyp + 'MarkMaxRight' + self.idx + '-Cmd'))
        self.pb_maxleft = PyDMPushButton(
            parent=self,
            label='Mark Max Left',
            pressValue=1,
            init_channel=self.dev.substitute(propty=self.mtyp + 'MarkMaxLeft' +
                                             self.idx + '-Cmd'))
        vbox_cmd = QVBoxLayout()
        vbox_cmd.addWidget(self.pb_max)
        vbox_cmd.addWidget(self.pb_maxnext)
        vbox_cmd.addWidget(self.pb_maxright)
        vbox_cmd.addWidget(self.pb_maxleft)
        lay.addItem(QSpacerItem(1, 6, QSzPlcy.Ignored, QSzPlcy.Fixed))
        lay.addRow(vbox_cmd)

        if self.mtyp == '' and self.idx == '1':
            lay.addItem(QSpacerItem(1, 6, QSzPlcy.Ignored, QSzPlcy.Fixed))

            label_enblautomin = QLabel('Enable Auto Min: ', self)
            self.bt_enblautomin = PyDMStateButton(
                self, self.dev.substitute(propty='EnblMinAuto-Sel'))
            self.bt_enblautomin.shape = 1
            self.led_enblautomin = SiriusLedState(
                self, self.dev.substitute(propty='EnblMinAuto-Sts'))
            hbox_enblautomin = QHBoxLayout()
            hbox_enblautomin.addWidget(self.bt_enblautomin)
            hbox_enblautomin.addWidget(self.led_enblautomin)
            lay.addRow(label_enblautomin, hbox_enblautomin)

            label_enbllimit = QLabel('Enable Mark Limit: ', self)
            self.bt_enbllimit = PyDMStateButton(
                self, self.dev.substitute(propty='EnblMarkLimit-Sel'))
            self.bt_enbllimit.shape = 1
            self.led_enbllimit = SiriusLedState(
                self, self.dev.substitute(propty='EnblMarkLimit-Sts'))
            hbox_enbllimit = QHBoxLayout()
            hbox_enbllimit.addWidget(self.bt_enbllimit)
            hbox_enbllimit.addWidget(self.led_enbllimit)
            lay.addRow(label_enbllimit, hbox_enbllimit)

            label_limright = QLabel('Mark Limit Right: ', self)
            self.sb_limright = PyDMLineEdit(
                self, self.dev.substitute(propty='MarkLimitRight-SP'))
            self.lb_limright = PyDMLabel(
                self, self.dev.substitute(propty='MarkLimitRight-RB'))
            hbox_limright = QHBoxLayout()
            hbox_limright.addWidget(self.sb_limright)
            hbox_limright.addWidget(self.lb_limright)
            lay.addRow(label_limright, hbox_limright)

            label_limleft = QLabel('Mark Limit Left: ', self)
            self.sb_limleft = PyDMLineEdit(
                self, self.dev.substitute(propty='MarkLimitLeft-SP'))
            self.lb_limleft = PyDMLabel(
                self, self.dev.substitute(propty='MarkLimitLeft-RB'))
            hbox_limleft = QHBoxLayout()
            hbox_limleft.addWidget(self.sb_limleft)
            hbox_limleft.addWidget(self.lb_limleft)
            lay.addRow(label_limleft, hbox_limleft)

        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;
            }""")
Пример #17
0
    def _setupUi(self):
        lay = QVBoxLayout()
        lay.addWidget(
            QLabel('<h3>Settings</h3>',
                   self,
                   alignment=Qt.AlignHCenter | Qt.AlignBottom))
        lay.setStretch(0, 1)

        # Measure
        l_reliablemeas = QLabel('Reliability: ')
        self.led_ReliableMeas = SiriusLedAlert(
            self, self.dcct_prefix.substitute(propty='ReliableMeas-Mon'))

        l_curr = QLabel('Current [mA]: ', self, alignment=Qt.AlignRight)
        self.label_current = PyDMLabel(
            self, self.dcct_prefix.substitute(propty='Current-Mon'))
        self.led_StoredEBeam = SiriusLedState(
            self, self.dcct_prefix.substitute(propty='StoredEBeam-Mon'))
        hlay_current = QHBoxLayout()
        hlay_current.addWidget(self.label_current)
        hlay_current.addWidget(self.led_StoredEBeam)

        l_enbl = QLabel('Enable:', self)
        self.pydmstatebutton_Enbl = PyDMStateButton(
            self, self.dcct_prefix.substitute(propty='Enbl-Sel'))
        self.pydmstatebutton_Enbl.shape = 1
        self.led_Enbl = SiriusLedState(
            self, self.dcct_prefix.substitute(propty='Enbl-Sts'))
        hlay_enbl = QHBoxLayout()
        hlay_enbl.addWidget(self.pydmstatebutton_Enbl)
        hlay_enbl.addWidget(self.led_Enbl)

        l_meastrig = QLabel('Trigger Source:', self)
        self.pydmenumcombobox_MeasTrg = PyDMEnumComboBox(
            self, self.dcct_prefix.substitute(propty='MeasTrg-Sel'))
        self.pydmlabel_MeasTrg = PyDMLabel(
            self, self.dcct_prefix.substitute(propty='MeasTrg-Sts'))
        hlay_meastrig = QHBoxLayout()
        hlay_meastrig.addWidget(self.pydmenumcombobox_MeasTrg)
        hlay_meastrig.addWidget(self.pydmlabel_MeasTrg)

        if 'SI' in self.device:
            l_range = QLabel('Range: ', self)
            self.pydmenumcombobox_Range = PyDMEnumComboBox(
                self, self.dcct_prefix.substitute(propty='Range-Sel'))
            self.pydmlabel_Range = PyDMLabel(
                self, self.dcct_prefix.substitute(propty='Range-Sts'))
            hlay_range = QHBoxLayout()
            hlay_range.addWidget(self.pydmenumcombobox_Range)
            hlay_range.addWidget(self.pydmlabel_Range)
            hlay_range.setContentsMargins(0, 0, 0, 0)

        l_measmode = QLabel('Mode: ', self)
        self.pydmenumcombobox_MeasMode = PyDMEnumComboBox(
            self, self.dcct_prefix.substitute(propty='MeasMode-Sel'))
        self.pydmlabel_MeasMode = PyDMLabel(
            self, self.dcct_prefix.substitute(propty='MeasMode-Sts'))
        hlay_measmode = QHBoxLayout()
        hlay_measmode.addWidget(self.pydmenumcombobox_MeasMode)
        hlay_measmode.addWidget(self.pydmlabel_MeasMode)
        hlay_measmode.setContentsMargins(0, 0, 0, 0)

        glay_mode = QGridLayout()
        self.normalmode_widget = self._setupMeasSettingsWidget('Normal')
        self.fastmode_widget = self._setupMeasSettingsWidget('Fast')
        glay_mode.addWidget(self.normalmode_widget, 0, 0)
        glay_mode.addWidget(self.fastmode_widget, 0, 0)
        glay_mode.setContentsMargins(0, 0, 0, 0)
        self.mode_channel = SiriusConnectionSignal(
            self.dcct_prefix.substitute(propty='MeasMode-Sel'))
        self.mode_channel.new_value_signal.connect(self._showMeasModeSettings)

        # Details
        self.pb_details = QPushButton(qta.icon('fa5s.ellipsis-h'), '', self)
        self.pb_details.setToolTip('Open details')
        self.pb_details.setObjectName('detail')
        self.pb_details.setStyleSheet(
            "#detail{min-width:25px; max-width:25px; icon-size:20px;}")
        detail_window = create_window_from_widget(DCCTSettingsDetails,
                                                  title=self.device +
                                                  ' Settings Details')
        _hlautil.connect_window(self.pb_details,
                                detail_window,
                                self,
                                prefix=self.prefix,
                                device=self.device)

        gbox_gen = QGroupBox('Measure')
        glay_gen = QGridLayout(gbox_gen)
        glay_gen.setAlignment(Qt.AlignVCenter)
        glay_gen.addWidget(l_curr, 0, 0)
        glay_gen.addLayout(hlay_current, 0, 1)
        glay_gen.addWidget(l_reliablemeas, 1, 0)
        glay_gen.addWidget(self.led_ReliableMeas, 1, 1, alignment=Qt.AlignLeft)
        glay_gen.addWidget(l_enbl, 2, 0)
        glay_gen.addLayout(hlay_enbl, 2, 1)
        glay_gen.addWidget(l_meastrig, 3, 0)
        glay_gen.addLayout(hlay_meastrig, 3, 1)
        if 'SI' in self.device:
            glay_gen.addWidget(l_range, 4, 0)
            glay_gen.addLayout(hlay_range, 4, 1)
        glay_gen.addWidget(l_measmode, 5, 0)
        glay_gen.addLayout(hlay_measmode, 5, 1)
        glay_gen.addLayout(glay_mode, 6, 0, 1, 2)
        glay_gen.addWidget(self.pb_details,
                           7,
                           0,
                           1,
                           2,
                           alignment=Qt.AlignRight)
        gbox_gen.setStyleSheet("""
            .QLabel{
                qproperty-alignment: 'AlignVCenter | AlignRight';
                min-width: 6em;}
            PyDMLed{
                min-width: 6em;}""")
        lay.addWidget(gbox_gen)
        lay.setStretch(1, 7)

        # Trigger
        self.trigger_widget = QGroupBox('Trigger')
        hbl = QHBoxLayout(self.trigger_widget)
        hbl.addWidget(
            HLTriggerSimple(self.trigger_widget,
                            device=self.device.substitute(dis='TI'),
                            prefix=self.prefix))
        lay.addWidget(self.trigger_widget)
        lay.setStretch(2, 3)

        self.setLayout(lay)
        self.setStyleSheet("""
            QSpinBox, QComboBox, QPushButton,
            PyDMSpinbox, PyDMEnumComboBox, PyDMLabel{
                min-width:6em; max-width:6em;}
            .QLabel{max-height:1.5em;}""")
Пример #18
0
class SiriusScrnView(QWidget):
    """
    Class to read Sirius screen cameras image data.

    To allow saving a grid correctly, control calibrationgrid_flag, which
    indicates if the screen is in calibration grid position.
    You can control it by using the method/Slot updateCalibrationGridFlag.
    """

    save_files = Signal()

    def __init__(self, parent=None, prefix=_VACA_PREFIX, device=None):
        """Initialize object."""
        QWidget.__init__(self, parent=parent)
        self.prefix = prefix
        self.device = SiriusPVName(device)
        self.scrn_prefix = self.device.substitute(prefix=prefix)
        self._receivedData = False
        self.setObjectName(self.scrn_prefix.sec + 'App')

        self.screen_type_conn = SiriusConnectionSignal(
            self.scrn_prefix.substitute(propty='ScrnType-Sts'))
        self.screen_type_conn.new_value_signal.connect(
            self.updateCalibrationGridFlag)
        self._calibrationgrid_flag = self.screen_type_conn.getvalue()
        self.save_files.connect(self._saveGridLocalFiles)
        self.ch_ImgROIHeight = SiriusConnectionSignal(
            self.scrn_prefix.substitute(propty='ImgROIHeight-RB'))
        self.ch_ImgROIWidth = SiriusConnectionSignal(
            self.scrn_prefix.substitute(propty='ImgROIWidth-RB'))
        self.ch_ImgROIOffsetX = SiriusConnectionSignal(
            self.scrn_prefix.substitute(propty='ImgROIOffsetX-RB'))
        self.ch_ImgROIOffsetY = SiriusConnectionSignal(
            self.scrn_prefix.substitute(propty='ImgROIOffsetY-RB'))

        self._setupUi()
        self.setFocus(True)
        self.setFocusPolicy(Qt.StrongFocus)
        self._loadCalibrationGrid(default=True)

    @property
    def calibrationgrid_flag(self):
        """Indicate if the screen device is in calibration grid position."""
        return self._calibrationgrid_flag

    @Slot(int)
    def updateCalibrationGridFlag(self, new_state):
        """Update calibrationgrid_flag property."""
        self._calibrationgrid_flag = new_state
        if new_state == 1:
            self.pushbutton_savegrid.setEnabled(True)
        else:
            self.pushbutton_savegrid.setEnabled(False)

    def _setupUi(self):
        self.cameraview_widget = QWidget()
        self.cameraview_widget.setLayout(self._cameraviewLayout())

        self.settings_widget = QWidget(self)
        self.settings_widget.setLayout(self._settingsLayout())
        self.settings_widget.setStyleSheet("""
            .QLabel{
                min-width: 5em;}
            QLabel{
                qproperty-alignment: AlignCenter;}""")

        self.calibrationgrid_widget = QWidget(self)
        self.calibrationgrid_widget.setLayout(self._calibrationgridLayout())
        self.calibrationgrid_widget.setSizePolicy(QSzPlcy.Expanding,
                                                  QSzPlcy.Expanding)
        self.calibrationgrid_widget.layout().setAlignment(Qt.AlignHCenter)
        self.tab = QTabWidget(self)
        self.tab.setStyleSheet("""
            QTabWidget::pane {
                border-left: 2px solid gray;
                border-bottom: 2px solid gray;
                border-right: 2px solid gray;
            }""")
        self.tab.addTab(self.settings_widget, 'Camera Settings')
        self.tab.addTab(self.calibrationgrid_widget, 'Calibration')

        self.statistics_groupBox = QGroupBox('Statistics', self)
        self.statistics_groupBox.setLayout(self._statisticsLayout())
        self.statistics_groupBox.setSizePolicy(QSzPlcy.Expanding,
                                               QSzPlcy.Expanding)
        self.statistics_groupBox.setStyleSheet("""
            .QLabel{
                min-width:0.28em; max-width:0.28em;
                min-height:1.29em; max-height:1.29em;}
            QLabel{
                qproperty-alignment: AlignCenter;}
            PyDMWidget{
                min-width:4.84em; max-width:4.84em;
                min-height:1.29em; max-height:1.29em;}""")

        self.trigger_groupBox = QGroupBox('Trigger', self)
        if 'TB' in self.device or 'BO' in self.device:
            trg_prefix = 'AS-Fam:TI-Scrn-TBBO'
        elif 'TS' in self.device:
            trg_prefix = 'TS-Fam:TI-Scrn'
        hbl = QHBoxLayout(self.trigger_groupBox)
        hbl.addWidget(
            HLTriggerSimple(parent=self.trigger_groupBox,
                            device=trg_prefix,
                            prefix=self.prefix))
        self.trigger_groupBox.setLayout(hbl)
        self.trigger_groupBox.setStyleSheet("""
            PyDMWidget{
                min-width:4.84em; max-width:4.84em;
                min-height:1.29em; max-height:1.29em;}""")

        vlay = QVBoxLayout()
        vlay.addWidget(self.statistics_groupBox)
        vlay.addWidget(self.trigger_groupBox)
        vlay.setSpacing(10)

        lay = QGridLayout(self)
        lay.setHorizontalSpacing(10)
        lay.setVerticalSpacing(10)
        lay.addWidget(self.cameraview_widget, 0, 0, 1, 2)
        lay.addWidget(self.tab, 1, 0)
        lay.addLayout(vlay, 1, 1)
        lay.setRowStretch(0, 15)
        lay.setRowStretch(1, 7)

    def _cameraviewLayout(self):
        label = QLabel(self.device, self)
        label.setStyleSheet("""font-weight: bold;max-height:1.29em;""")
        label.setAlignment(Qt.AlignCenter)
        self.image_view = _SiriusImageView(
            parent=self,
            image_channel=self.scrn_prefix.substitute(propty='ImgData-Mon'),
            width_channel=self.scrn_prefix.substitute(propty='ImgROIWidth-RB'),
            offsetx_channel=self.scrn_prefix.substitute(
                propty='ImgROIOffsetX-RB'),
            offsety_channel=self.scrn_prefix.substitute(
                propty='ImgROIOffsetY-RB'),
            maxwidth_channel=self.scrn_prefix.substitute(
                propty='ImgMaxWidth-Cte'),
            maxheight_channel=self.scrn_prefix.substitute(
                propty='ImgMaxHeight-Cte'))
        self.image_view.setObjectName('ScrnView')
        self.image_view.normalizeData = True
        self.image_view.readingOrder = self.image_view.Clike
        self.image_view.maxRedrawRate = 15
        self.image_view.setStyleSheet("""
            #ScrnView{min-width:30em; min-height:24em;}""")
        self.image_view.failToSaveGrid.connect(self._showFailToSaveGridMsg)
        self.image_view.receivedData.connect(self._setReceivedDataFlag)

        lay = QGridLayout()
        lay.setContentsMargins(0, 0, 0, 0)
        lay.addWidget(label, 0, 1)
        lay.addItem(QSpacerItem(40, 2, QSzPlcy.Preferred, QSzPlcy.Fixed), 1, 1)
        lay.addWidget(self.image_view, 2, 1)
        return lay

    def _calibrationgridLayout(self):
        self.checkBox_showgrid = QCheckBox('Show', self)
        self.checkBox_showgrid.setEnabled(False)
        self.checkBox_showgrid.setStyleSheet("""
            min-width:4em; max-width:4em;
            min-height:1.29em; max-height:1.29em;""")
        self.checkBox_showgrid.toggled.connect(
            self.image_view.showCalibrationGrid)
        self.pushbutton_savegrid = QPushButton('Save', self)
        self.pushbutton_savegrid.setEnabled(False)
        self.pushbutton_savegrid.setStyleSheet("""
            min-width:4em; max-width:4em;
            min-height:1.29em; max-height:1.29em;""")
        self.pushbutton_savegrid.clicked.connect(self._saveCalibrationGrid)
        self.pushbutton_loadgrid = QPushButton('Load', self)
        self.pushbutton_loadgrid.setStyleSheet("""
            min-width:4em; max-width:4em;
            min-height:1.29em; max-height:1.29em;""")
        self.pushbutton_loadgrid.clicked.connect(self._loadCalibrationGrid)
        hbox_grid = QHBoxLayout()
        hbox_grid.addWidget(self.checkBox_showgrid)
        hbox_grid.addWidget(self.pushbutton_savegrid)
        hbox_grid.addWidget(self.pushbutton_loadgrid)

        lb = QLabel('Show levels <')
        lb.setStyleSheet("min-width:7em;max-width:7em;")
        self.spinbox_gridfilterfactor = QSpinBoxPlus()
        self.spinbox_gridfilterfactor.setMaximum(100)
        self.spinbox_gridfilterfactor.setMinimum(0)
        self.spinbox_gridfilterfactor.setValue(
            self.image_view.calibration_grid_filterfactor)
        self.spinbox_gridfilterfactor.editingFinished.connect(
            self._setCalibrationGridFilterFactor)
        self.spinbox_gridfilterfactor.setStyleSheet("""
            min-width:4em; max-width:4em;""")
        hbox_filter = QHBoxLayout()
        hbox_filter.setSpacing(0)
        hbox_filter.addWidget(lb)
        hbox_filter.addWidget(self.spinbox_gridfilterfactor)
        hbox_filter.addWidget(QLabel(' %'))

        lb = QLabel('Remove border: ')
        lb.setStyleSheet("min-width:7em;max-width:7em;")
        self.spinbox_removeborder = QSpinBoxPlus()
        self.spinbox_removeborder.setMaximum(512)
        self.spinbox_removeborder.setMinimum(0)
        self.spinbox_removeborder.setValue(
            self.image_view.calibration_grid_removeborder)
        self.spinbox_removeborder.editingFinished.connect(
            self._setCalibrationGridBorder2Remove)
        self.spinbox_removeborder.setStyleSheet("""
            min-width:4em; max-width:4em;""")
        hbox_remove = QHBoxLayout()
        hbox_remove.setSpacing(0)
        hbox_remove.addWidget(lb)
        hbox_remove.addWidget(self.spinbox_removeborder)
        hbox_remove.addWidget(QLabel(' px'))

        hbox_EnblLED = _create_propty_layout(parent=self,
                                             prefix=self.scrn_prefix,
                                             propty='EnblLED',
                                             propty_type='enbldisabl',
                                             width=4.68)

        lay = QFormLayout()
        lay.addItem(QSpacerItem(1, 10, QSzPlcy.Ignored, QSzPlcy.Preferred))
        lay.addRow('  Grid: ', hbox_grid)
        lay.addItem(QSpacerItem(1, 10, QSzPlcy.Ignored, QSzPlcy.Preferred))
        lay.addRow('  ', hbox_filter)
        lay.addRow('  ', hbox_remove)
        lay.addItem(QSpacerItem(1, 20, QSzPlcy.Ignored, QSzPlcy.Preferred))
        lay.addRow('  LED: ', hbox_EnblLED)
        lay.addItem(QSpacerItem(1, 10, QSzPlcy.Ignored, QSzPlcy.Preferred))
        lay.setLabelAlignment(Qt.AlignRight)
        lay.setFormAlignment(Qt.AlignCenter)
        return lay

    def _settingsLayout(self):
        label_CamEnbl = QLabel('Enable: ', self)
        hbox_CamEnbl = _create_propty_layout(parent=self,
                                             prefix=self.scrn_prefix,
                                             propty='CamEnbl',
                                             propty_type='enbldisabl')

        label_CamAcqPeriod = QLabel('Acquire\nPeriod [s]:', self)
        hbox_CamAcqPeriod = _create_propty_layout(parent=self,
                                                  prefix=self.scrn_prefix,
                                                  propty='CamAcqPeriod',
                                                  propty_type='sprb',
                                                  width=5.0)

        label_CamExposureTime = QLabel('Exposure\nTime [us]:', self)
        hbox_CamExposureTime = _create_propty_layout(parent=self,
                                                     prefix=self.scrn_prefix,
                                                     propty='CamExposureTime',
                                                     propty_type='sprb',
                                                     width=5.0)

        label_CamGain = QLabel('Gain[dB]:', self)
        hbox_CamGain = _create_propty_layout(parent=self,
                                             prefix=self.scrn_prefix,
                                             propty='CamGain',
                                             width=5.0,
                                             propty_type='sprb')

        label_AutoGain = QLabel('Auto Gain: ', self)
        self.pb_autogain = PyDMPushButton(
            label='',
            icon=qta.icon('mdi.auto-fix'),
            parent=self,
            pressValue=1,
            init_channel=self.scrn_prefix.substitute(propty='CamAutoGain-Cmd'))
        self.pb_autogain.setObjectName('autog')
        self.pb_autogain.setStyleSheet(
            "#autog{min-width:25px; max-width:25px; icon-size:20px;}")

        cam_prefix = SiriusPVName(self.scrn_prefix).substitute(dev='ScrnCam')
        label_Reset = QLabel('Reset: ', self)
        self.pb_dtl = PyDMPushButton(
            label='',
            icon=qta.icon('fa5s.sync'),
            parent=self,
            pressValue=1,
            init_channel=cam_prefix.substitute(propty='Rst-Cmd'))
        self.pb_dtl.setObjectName('reset')
        self.pb_dtl.setStyleSheet(
            "#reset{min-width:25px; max-width:25px; icon-size:20px;}")

        self.pb_details = QPushButton(qta.icon('fa5s.ellipsis-h'), '', self)
        self.pb_details.setToolTip('More settings')
        self.pb_details.setObjectName('detail')
        self.pb_details.setStyleSheet(
            "#detail{min-width:25px; max-width:25px; icon-size:20px;}")
        self.pb_details.setSizePolicy(QSzPlcy.Expanding, QSzPlcy.Preferred)
        util.connect_window(self.pb_details,
                            _ScrnSettingsDetails,
                            parent=self,
                            prefix=self.prefix,
                            device=self.device)

        hbox_aux = QHBoxLayout()
        hbox_aux.addWidget(self.pb_dtl, alignment=Qt.AlignLeft)
        hbox_aux.addWidget(self.pb_details, alignment=Qt.AlignRight)

        lay = QFormLayout()
        lay.setFormAlignment(Qt.AlignCenter)
        lay.addRow(label_CamEnbl, hbox_CamEnbl)
        lay.addRow(label_CamAcqPeriod, hbox_CamAcqPeriod)
        lay.addRow(label_CamExposureTime, hbox_CamExposureTime)
        lay.addRow(label_CamGain, hbox_CamGain)
        lay.addRow(label_AutoGain, self.pb_autogain)
        lay.addRow(label_Reset, hbox_aux)
        return lay

    def _statisticsLayout(self):
        # - Method
        label_Method = QLabel('CalcMethod:', self)
        label_Method.setStyleSheet("min-width:7em;")

        self.comboBox_Method = QComboBox(self)
        self.comboBox_Method.addItem('DimFei', 0)
        self.comboBox_Method.addItem('NDStats', 1)
        self.comboBox_Method.setCurrentIndex(0)
        self.comboBox_Method.setStyleSheet("""
            QComboBox::item {height: 1em;}
            QComboBox{min-width:6em;}""")
        self.comboBox_Method.currentIndexChanged.connect(
            self._handleShowStatistics)

        # - Centroid
        label_Centroid = QLabel('Centroid [mm]: ', self)
        label_Centroid.setStyleSheet("min-width:7em;")
        label_i_Center = QLabel('(', self)
        self.PyDMLabel_CenterXDimFei = PyDMLabel(
            parent=self,
            init_channel=self.scrn_prefix.substitute(
                propty='CenterXDimFei-Mon'))
        self.PyDMLabel_CenterXDimFei.setStyleSheet(
            'min-width:4em; max-width:4em;')
        self.PyDMLabel_CenterXNDStats = PyDMLabel(
            parent=self,
            init_channel=self.scrn_prefix.substitute(
                propty='CenterXNDStats-Mon'))
        self.PyDMLabel_CenterXNDStats.setStyleSheet(
            'min-width:4em; max-width:4em;')
        self.PyDMLabel_CenterXNDStats.setVisible(False)
        label_m_Center = QLabel(',', self)
        self.PyDMLabel_CenterYDimFei = PyDMLabel(
            parent=self,
            init_channel=self.scrn_prefix.substitute(
                propty='CenterYDimFei-Mon'))
        self.PyDMLabel_CenterYDimFei.setStyleSheet(
            'min-width:4em; max-width:4em;')
        self.PyDMLabel_CenterYNDStats = PyDMLabel(
            parent=self,
            init_channel=self.scrn_prefix.substitute(
                propty='CenterYNDStats-Mon'))
        self.PyDMLabel_CenterYNDStats.setStyleSheet(
            'min-width:4em; max-width:4em;')
        self.PyDMLabel_CenterYNDStats.setVisible(False)
        label_f_Center = QLabel(')', self)

        # - Sigma
        label_Sigma = QLabel('Sigma [mm]: ', self)
        label_Sigma.setStyleSheet("min-width:7em;")
        label_i_Sigma = QLabel('(', self)
        self.PyDMLabel_SigmaXDimFei = PyDMLabel(
            parent=self,
            init_channel=self.scrn_prefix.substitute(
                propty='SigmaXDimFei-Mon'))
        self.PyDMLabel_SigmaXDimFei.setStyleSheet(
            'min-width:4em; max-width:4em;')
        self.PyDMLabel_SigmaXNDStats = PyDMLabel(
            parent=self,
            init_channel=self.scrn_prefix.substitute(
                propty='SigmaXNDStats-Mon'))
        self.PyDMLabel_SigmaXNDStats.setStyleSheet(
            'min-width:4em; max-width:4em;')
        self.PyDMLabel_SigmaXNDStats.setVisible(False)
        label_m_Sigma = QLabel(',', self)
        self.PyDMLabel_SigmaYDimFei = PyDMLabel(
            parent=self,
            init_channel=self.scrn_prefix.substitute(
                propty='SigmaYDimFei-Mon'))
        self.PyDMLabel_SigmaYDimFei.setStyleSheet(
            'min-width:4em; max-width:4em;')
        self.PyDMLabel_SigmaYNDStats = PyDMLabel(
            parent=self,
            init_channel=self.scrn_prefix.substitute(
                propty='SigmaYNDStats-Mon'))
        self.PyDMLabel_SigmaYNDStats.setStyleSheet(
            'min-width:4em; max-width:4em;')
        self.PyDMLabel_SigmaYNDStats.setVisible(False)
        label_f_Sigma = QLabel(')', self)

        # - Theta
        label_Theta = QLabel('Theta [rad]: ')
        label_Theta.setStyleSheet("min-width:7em;")
        label_i_Theta = QLabel('(', self)
        self.PyDMLabel_ThetaDimFei = PyDMLabel(
            parent=self,
            init_channel=self.scrn_prefix.substitute(propty='ThetaDimFei-Mon'))
        self.PyDMLabel_ThetaDimFei.setStyleSheet("max-width:12em;")
        self.PyDMLabel_ThetaNDStats = PyDMLabel(
            parent=self,
            init_channel=self.scrn_prefix.substitute(
                propty='ThetaNDStats-Mon'))
        self.PyDMLabel_ThetaNDStats.setStyleSheet("max-width:12em;")
        self.PyDMLabel_ThetaNDStats.setVisible(False)
        label_f_Theta = QLabel(')', self)

        lay = QGridLayout()
        lay.addWidget(label_Method, 1, 1, 1, 3)
        lay.addWidget(self.comboBox_Method, 1, 3, 1, 3)
        lay.addWidget(label_Centroid, 3, 1, alignment=Qt.AlignCenter)
        lay.addWidget(label_i_Center, 3, 2)
        lay.addWidget(self.PyDMLabel_CenterXDimFei, 3, 3)
        lay.addWidget(self.PyDMLabel_CenterXNDStats, 3, 3)
        lay.addWidget(label_m_Center, 3, 4)
        lay.addWidget(self.PyDMLabel_CenterYDimFei, 3, 5)
        lay.addWidget(self.PyDMLabel_CenterYNDStats, 3, 5)
        lay.addWidget(label_f_Center, 3, 6)
        lay.addWidget(label_Sigma, 5, 1, alignment=Qt.AlignCenter)
        lay.addWidget(label_i_Sigma, 5, 2)
        lay.addWidget(self.PyDMLabel_SigmaXDimFei, 5, 3)
        lay.addWidget(self.PyDMLabel_SigmaXNDStats, 5, 3)
        lay.addWidget(label_m_Sigma, 5, 4)
        lay.addWidget(self.PyDMLabel_SigmaYDimFei, 5, 5)
        lay.addWidget(self.PyDMLabel_SigmaYNDStats, 5, 5)
        lay.addWidget(label_f_Sigma, 5, 6)
        lay.addWidget(label_Theta, 7, 1, alignment=Qt.AlignCenter)
        lay.addWidget(label_i_Theta, 7, 2)
        lay.addWidget(self.PyDMLabel_ThetaDimFei, 7, 3, 1, 3)
        lay.addWidget(self.PyDMLabel_ThetaNDStats, 7, 3, 1, 3)
        lay.addWidget(label_f_Theta, 7, 6)
        return lay

    def _handleShowStatistics(self, visible):
        self.PyDMLabel_CenterXDimFei.setVisible(not visible)
        self.PyDMLabel_CenterXNDStats.setVisible(visible)
        self.PyDMLabel_CenterYDimFei.setVisible(not visible)
        self.PyDMLabel_CenterYNDStats.setVisible(visible)
        self.PyDMLabel_ThetaDimFei.setVisible(not visible)
        self.PyDMLabel_ThetaNDStats.setVisible(visible)
        self.PyDMLabel_SigmaXDimFei.setVisible(not visible)
        self.PyDMLabel_SigmaXNDStats.setVisible(visible)
        self.PyDMLabel_SigmaYDimFei.setVisible(not visible)
        self.PyDMLabel_SigmaYNDStats.setVisible(visible)

    def _saveCalibrationGrid(self):
        t = Thread(target=self._saveCalibrationGrid_thread, daemon=True)
        t.start()

    def _saveCalibrationGrid_thread(self):
        roi_h = float(self.ch_ImgROIHeight.value)
        roi_w = float(self.ch_ImgROIWidth.value)
        roi_offsetx = float(self.ch_ImgROIOffsetX.value)
        roi_offsety = float(self.ch_ImgROIOffsetY.value)

        cond = roi_h != float(self.image_view.image_maxheight) or \
            roi_w != float(self.image_view.image_maxwidth) or \
            roi_offsetx != 0 or roi_offsety != 0
        if cond:
            # Disable camera acquisition and wait for disabling
            self.PyDMStateButton_CamEnbl.send_value_signal[int].emit(0)
            state = self.SiriusLedState_CamEnbl.state
            while state == 1:
                time.sleep(0.1)
                state = self.SiriusLedState_CamEnbl.state

            # Change ROI to get entire image
            self.ch_ImgROIHeight.send_value_signal[float].emit(
                float(self.image_view.image_maxheight))
            self.ch_ImgROIWidth.send_value_signal[float].emit(
                float(self.image_view.image_maxwidth))
            self.ch_ImgROIOffsetX.send_value_signal[float].emit(0)
            self.ch_ImgROIOffsetY.send_value_signal[float].emit(0)

        # Enable led and wait for status
        self.PyDMStateButton_EnblLED.send_value_signal[int].emit(1)
        while not self.SiriusLedState_EnblLED.state:
            time.sleep(0.1)

        # Enable camera acquisition and wait for receiveing first frame
        self._receivedData = False
        self.PyDMStateButton_CamEnbl.send_value_signal[int].emit(1)
        while not self._receivedData:
            time.sleep(0.1)

        # Save grid
        self.image_view.saveCalibrationGrid()

        if cond:
            # Disable camera acquisition and wait for disabling
            self.PyDMStateButton_CamEnbl.send_value_signal[int].emit(0)
            state = self.SiriusLedState_CamEnbl.state
            while state == 1:
                time.sleep(0.1)
                state = self.SiriusLedState_CamEnbl.state

            # Change ROI to original size
            self.ch_ImgROIHeight.send_value_signal[float].emit(roi_h)
            self.ch_ImgROIWidth.send_value_signal[float].emit(roi_w)
            self.ch_ImgROIOffsetX.send_value_signal[float].emit(roi_offsetx)
            self.ch_ImgROIOffsetY.send_value_signal[float].emit(roi_offsety)

            # Enable camera acquisition
            self.PyDMStateButton_CamEnbl.send_value_signal[int].emit(1)

        # Enable showing saved grid
        time.sleep(0.1)
        self.checkBox_showgrid.setEnabled(True)
        self.save_files.emit()

    def _saveGridLocalFiles(self):
        home = os.path.expanduser('~')
        folder_month = datetime.now().strftime('%Y-%m')
        folder_day = datetime.now().strftime('%Y-%m-%d')
        path = os.path.join(home, 'mounts', 'screens-iocs', folder_month,
                            folder_day)
        if not os.path.exists(path):
            os.makedirs(path)
        fn, _ = QFileDialog.getSaveFileName(
            self, 'Save Grid As...', path + '/' + self.device +
            datetime.now().strftime('_%Y-%m-%d_%Hh%Mmin'), '*.npy')
        if not fn:
            return False

        path_default = os.path.join(home, 'mounts', 'screens-iocs', 'default')
        if not os.path.exists(path_default):
            os.makedirs(path_default)
        fn_default = path_default + '/' + self.device

        grid = self.image_view.calibrationGrid
        width = self.image_view.imageWidth
        data = np.append(width, grid)
        np.save(fn, data)
        np.save(fn_default, data)

    def _loadCalibrationGrid(self, default=False):
        home = os.path.expanduser('~')
        if not default:
            folder_month = datetime.now().strftime('%Y-%m')
            path = os.path.join(home, 'mounts', 'screens-iocs', folder_month)
            fn, _ = QFileDialog.getOpenFileName(self, 'Load Grid...', path,
                                                '*.npy')
            if not fn:
                return
            if self.device not in fn:
                ans = QMessageBox.question(
                    self, 'Warning',
                    'The name of the selected file does not contain the name' +
                    ' of this screen. Are you sure you\'re loading this grid?',
                    QMessageBox.Yes, QMessageBox.Cancel)
                if ans == QMessageBox.Cancel:
                    return
        else:
            path = os.path.join(home, 'mounts', 'screens-iocs', 'default')
            fn = path + '/' + self.device + '.npy'

        try:
            data = np.load(fn)
            self.image_view.calibrationGrid = data
        except Exception as e:
            if not default:
                QMessageBox.critical(
                    self, 'Error',
                    'Could not load calibration grid from file ' + fn + '. ' +
                    '\nError message: ' + str(e), QMessageBox.Ok)
            return

        # Enable showing saved grid
        self.checkBox_showgrid.setEnabled(True)

    def _setReceivedDataFlag(self):
        self._receivedData = True

    def _setCalibrationGridFilterFactor(self):
        self.image_view.set_calibration_grid_filterfactor(
            self.spinbox_gridfilterfactor.value())

    def _setCalibrationGridBorder2Remove(self):
        self.image_view.set_calibration_grid_border2remove(
            self.spinbox_removeborder.value())

    @Slot()
    def _showFailToSaveGridMsg(self):
        QMessageBox.warning(self, 'Warning',
                            'Could not save calibration grid!', QMessageBox.Ok)
Пример #19
0
 def _add_scale(self, channel, scale):
     cdta = self.graph.curveAtIndex(-1)
     chan = SiriusConnectionSignal(channel)
     chan.new_value_signal[self.DATA_CLASS].connect(
         _part(self._apply_scale, cdta, scale))
     self._chans.append(chan)
Пример #20
0
    def _setupGraphPanelLayout(self):
        # Main Panel
        # # Labels
        self._ld_current = QLabel('Current', self, alignment=Qt.AlignCenter)
        self._ld_current.setStyleSheet("font-weight:bold; max-height1.5em;")
        self._lb_current = PyDMLabel(
            self, self.devname.substitute(propty='Current-Mon'))
        self._lb_current.setStyleSheet("font-size:40px;")
        self._lb_current.precision = 0
        self._lb_current.showUnits = True

        self._ld_lifetime = QLabel('Lifetime', self)
        self._ld_lifetime.setStyleSheet("font-weight:bold; max-height1.5em;")
        self._ld_lifetime.setAlignment(Qt.AlignCenter)
        self._lb_lifetime = QLabel('0:00:00', self)
        self._lb_lifetime.channel = self.devname.substitute(
            propty='Lifetime-Mon')
        self._lb_lifetime.setStyleSheet("font-size:40px;")
        self.lifetime_dcct_pv = SiriusConnectionSignal(
            self.devname.substitute(propty='Lifetime-Mon'))
        self.lifetime_dcct_pv.new_value_signal[float].connect(
            self._format_lifetime_label)
        self.lifetime_bpm_pv = SiriusConnectionSignal(
            self.devname.substitute(propty='LifetimeBPM-Mon'))
        self.lifetime_bpm_pv.new_value_signal[float].connect(
            self._format_lifetime_label)

        # # Graph
        self.graph = SiriusTimePlot(self, background='w')
        self.graph.plotItem.getAxis('left').setLabel('Current [mA]',
                                                     color='blue')
        self.graph.plotItem.getAxis('right').setLabel('Lifetime [h]',
                                                      color='red')
        self.graph.showLegend = False
        self.graph.showXGrid = True
        self.graph.showYGrid = True
        self.graph.autoRangeY = True
        self.graph.setObjectName('graph')
        self.graph.setStyleSheet('#graph{min-width:40em;min-height:32em;}')
        self.graph.bufferSize = 60 * 60 * 10
        self.graph.timeSpan = 30 * 60

        t_end = Time.now()
        t_init = t_end - 30 * 60
        t_end_iso = t_end.get_iso8601()
        t_init_iso = t_init.get_iso8601()

        pvname = self.devname.substitute(propty='Current-Mon')
        self.graph.addYChannel(y_channel=pvname,
                               axis='left',
                               name='Current',
                               color='blue',
                               lineWidth=1)
        self._curve_current = self.graph.curveAtIndex(0)
        self.graph.fill_curve_with_archdata(self._curve_current,
                                            pvname,
                                            t_init=t_init_iso,
                                            t_end=t_end_iso)

        pvname = _PVName('SI-01M1:DI-BPM:Sum-Mon').substitute(
            prefix=self.prefix)
        self.graph.addYChannel(y_channel=pvname,
                               axis='left',
                               name='Current',
                               color='blue',
                               lineWidth=1)
        self._curve_bpmsum = self.graph.curveAtIndex(1)
        self.graph.fill_curve_with_archdata(self._curve_bpmsum,
                                            pvname,
                                            t_init=t_init_iso,
                                            t_end=t_end_iso)

        self.graph.addYChannel(y_channel='FAKE:Lifetime',
                               axis='right',
                               name='Lifetime',
                               color='red',
                               lineWidth=1)
        self._curve_lifetimedcct = self.graph.curveAtIndex(2)
        self.graph.fill_curve_with_archdata(
            self._curve_lifetimedcct,
            self.devname.substitute(propty='Lifetime-Mon'),
            t_init=t_init_iso,
            t_end=t_end_iso,
            factor=3600)

        self.graph.addYChannel(y_channel='FAKE:LifetimeBPM',
                               axis='right',
                               name='Lifetime',
                               color='red',
                               lineWidth=1)
        self._curve_lifetimebpm = self.graph.curveAtIndex(3)
        self.graph.fill_curve_with_archdata(
            self._curve_lifetimebpm,
            self.devname.substitute(propty='LifetimeBPM-Mon'),
            t_init=t_init_iso,
            t_end=t_end_iso,
            factor=3600)

        self.lifetime_dcct_pv.new_value_signal[float].connect(
            self._update_graph)
        self.lifetime_bpm_pv.new_value_signal[float].connect(
            self._update_graph)

        self._flag_need_dcctx = True
        self._flag_need_dccty = True
        self._flag_need_bpmx = True
        self._flag_need_bpmy = True
        self.dcct_wavx = _np.array([])
        self.dcct_wavy = _np.array([])
        self.bpm_wavx = _np.array([])
        self.bpm_wavy = _np.array([])
        self.dcct_buff_y_pv = SiriusConnectionSignal(
            self.devname.substitute(propty='BufferValue-Mon'))
        self.dcct_buff_x_pv = SiriusConnectionSignal(
            self.devname.substitute(propty='BufferTimestamp-Mon'))
        self.bpm_buff_y_pv = SiriusConnectionSignal(
            self.devname.substitute(propty='BufferValueBPM-Mon'))
        self.bpm_buff_x_pv = SiriusConnectionSignal(
            self.devname.substitute(propty='BufferTimestampBPM-Mon'))
        self.dcct_buff_y_pv.new_value_signal[_np.ndarray].connect(
            self._update_waveforms)
        self.dcct_buff_x_pv.new_value_signal[_np.ndarray].connect(
            self._update_waveforms)
        self.bpm_buff_y_pv.new_value_signal[_np.ndarray].connect(
            self._update_waveforms)
        self.bpm_buff_x_pv.new_value_signal[_np.ndarray].connect(
            self._update_waveforms)

        self.graph.addYChannel(y_channel='FAKE:DCCTBuffer',
                               axis='left',
                               name='DCCTBuffer',
                               color='blue',
                               lineStyle=Qt.NoPen,
                               symbolSize=10,
                               symbol='o')
        self._curve_dcct_buff = self.graph.curveAtIndex(4)
        self.graph.addYChannel(y_channel='FAKE:BPMBuffer',
                               axis='left',
                               name='BPMBuffer',
                               color='blue',
                               lineStyle=Qt.NoPen,
                               symbolSize=10,
                               symbol='o')
        self._curve_bpm_buff = self.graph.curveAtIndex(5)

        self._curve_bpmsum.setVisible(False)
        self._curve_lifetimebpm.setVisible(False)
        self._curve_bpm_buff.setVisible(False)

        lay = QGridLayout()
        lay.addItem(QSpacerItem(1, 1, QSzPlcy.Expanding, QSzPlcy.Minimum), 0,
                    0)
        lay.addWidget(self._ld_current, 0, 1)
        lay.addItem(QSpacerItem(1, 1, QSzPlcy.Expanding, QSzPlcy.Minimum), 0,
                    2)
        lay.addItem(QSpacerItem(1, 1, QSzPlcy.Expanding, QSzPlcy.Minimum), 0,
                    3)
        lay.addWidget(self._ld_lifetime, 0, 4)
        lay.addItem(QSpacerItem(1, 1, QSzPlcy.Expanding, QSzPlcy.Minimum), 0,
                    5)
        lay.addWidget(self._lb_current, 1, 1)
        lay.addWidget(self._lb_lifetime, 1, 4)
        lay.addWidget(self.graph, 2, 0, 1, 6)
        return lay
Пример #21
0
    def _setupRawReadings(self):
        self.label_waveread = QLabel('<h3>Current Raw Readings</h3>',
                                     self,
                                     alignment=Qt.AlignCenter)

        self.wavegraph = PyDMWaveformPlot(self)
        self.wavegraph.setLabels(left='Current [mA]', bottom='Index')
        channel = 'FAKE:Readings'
        self.rawreadings_channel = SignalChannel(
            self.dcct_prefix.substitute(propty='RawReadings-Mon'))
        self.rawreadings_channel.new_value_signal[np.ndarray].connect(
            self._updateRawBuffer)
        self.wavegraph.addChannel(y_channel=channel,
                                  name='Current Raw Readings',
                                  color='blue',
                                  lineWidth=2,
                                  lineStyle=Qt.SolidLine)
        self.wavegraph.autoRangeX = True
        self.wavegraph.autoRangeY = True
        self.wavegraph.backgroundColor = QColor(255, 255, 255)
        self.wavegraph.showLegend = False
        self.wavegraph.showXGrid = True
        self.wavegraph.showYGrid = True
        self.wavegraph.plotItem.showButtons()
        self.wavecurve = self.wavegraph.curveAtIndex(0)

        wid = QWidget()
        lay = QGridLayout(wid)
        lay.setAlignment(Qt.AlignTop)
        lay.setRowStretch(0, 1)
        lay.setRowStretch(1, 9)
        lay.addWidget(self.label_waveread, 0, 0)
        lay.addWidget(self.wavegraph, 1, 0)

        # Smoothing
        evgname = SiriusPVName(_LLTimeSearch.get_evg_name())
        self._evnt_dly = SignalChannel(
            evgname.substitute(prefix=self.prefix,
                               propty='Dig' + self.device.sec + 'Delay-RB'))
        self._evnt_dly.new_value_signal[float].connect(self.updateRawXAxis)
        self._trig_dly = SignalChannel(
            self.dcct_prefix.substitute(dis='TI', propty='Delay-RB'))
        self._trig_dly.new_value_signal[float].connect(self.updateRawXAxis)
        self._smpl_cnt = SignalChannel(
            self.dcct_prefix.substitute(propty='FastSampleCnt-RB'))
        self._smpl_cnt.new_value_signal[float].connect(self.updateRawXAxis)
        self._meas_per = SignalChannel(
            self.dcct_prefix.substitute(propty='FastMeasPeriod-RB'))
        self._meas_per.new_value_signal[float].connect(self.updateRawXAxis)

        self.cb_timeaxis = QCheckBox('Use time axis', self)
        self.cb_timeaxis.setChecked(True)
        self.cb_timeaxis.stateChanged.connect(self.updateRawXAxis)
        self.cb_timeaxis.setLayoutDirection(Qt.RightToLeft)
        lay.addWidget(self.cb_timeaxis, 2, 0, alignment=Qt.AlignLeft)
        lay.setRowStretch(2, 1)

        l_smoothmethod = QLabel('Method: ', self)
        self.cb_smoothmethod = QComboBox(self)
        self.cb_smoothmethod.addItems(['Average', 'Median'])
        self.cb_smoothmethod.currentTextChanged.connect(
            self.setRawSmoothMethod)

        l_smoothnracq = QLabel('Nr.Acqs.: ', self)
        self.sb_smoothnracq = QSpinBoxPlus(self)
        self.sb_smoothnracq.setValue(1)
        self.sb_smoothnracq.valueChanged.connect(self.setRawSmoothNrAcq)

        l_smoothbuff = QLabel('Buffer Size: ', self)
        l_smoothbuff.setSizePolicy(QSzPly.Minimum, QSzPly.Preferred)
        self.label_buffsize = QLabel('', self)
        self.label_buffsize.setStyleSheet('min-width:3em; max-width:3em;')
        self.pb_resetbuff = QPushButton(qta.icon('mdi.delete-empty'), '', self)
        self.pb_resetbuff.setToolTip('Reset buffer')
        self.pb_resetbuff.setObjectName('resetbuff')
        self.pb_resetbuff.setStyleSheet(
            "#resetbuff{min-width:25px; max-width:25px; icon-size:20px;}")
        self.pb_resetbuff.clicked.connect(self.resetRawBuffer)
        hlay_buff = QHBoxLayout()
        hlay_buff.addWidget(self.label_buffsize)
        hlay_buff.addWidget(self.pb_resetbuff)

        l_down = QLabel('Downsampling: ', self)
        self.sb_down = QSpinBoxPlus(self)
        self.sb_down.setValue(1)
        self.sb_down.valueChanged.connect(self.setRawDownsampling)

        gbox_smooth = QGroupBox('Smoothing of Readings')
        glay_smooth = QGridLayout(gbox_smooth)
        glay_smooth.addWidget(l_smoothmethod, 0, 0)
        glay_smooth.addWidget(self.cb_smoothmethod, 0, 1)
        glay_smooth.addWidget(l_smoothnracq, 1, 0)
        glay_smooth.addWidget(self.sb_smoothnracq, 1, 1)
        glay_smooth.addWidget(QLabel(''), 0, 2)
        glay_smooth.addWidget(l_smoothbuff, 0, 3)
        glay_smooth.addLayout(hlay_buff, 0, 4, 1, 2)
        glay_smooth.addWidget(l_down, 1, 3)
        glay_smooth.addWidget(self.sb_down, 1, 4, 1, 2)
        glay_smooth.setColumnStretch(0, 10)
        glay_smooth.setColumnStretch(1, 10)
        glay_smooth.setColumnStretch(2, 2)
        glay_smooth.setColumnStretch(3, 10)
        glay_smooth.setColumnStretch(4, 5)
        glay_smooth.setColumnStretch(5, 5)
        lay.addWidget(gbox_smooth, 3, 0)
        lay.setRowStretch(3, 3)
        gbox_smooth.setStyleSheet("""
            .QLabel{
                qproperty-alignment: 'AlignVCenter | AlignRight';}
            QPushButton{
                min-width:3em; max-width:3em;}""")

        return wid