def __init__(self, parent=None, channels2values=dict(), color_list=None): """Init.""" QLed.__init__(self, parent) PyDMWidget.__init__(self) self.stateColors = _dcopy(color_list) or self.default_colorlist self._connected = False self._operations_dict = { 'eq': self._eq, 'cl': self._cl, 'ne': self._ne, 'gt': self._gt, 'lt': self._lt, 'ge': self._ge, 'le': self._le, 'in': self._in, 'wt': self._wt } self._address2values = dict() self._address2channel = dict() self._address2conn = dict() self._address2status = dict() self._address2currvals = dict() self.set_channels2values(_dcopy(channels2values))
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)
def __init__(self, parent=None, channels=list(), color_list=None): """Init.""" QLed.__init__(self, parent) PyDMWidget.__init__(self) self.stateColors = color_list or self.default_colorlist self._address2conn = dict() self._address2channel = dict() self.set_channels(channels)
def __init__(self, parent=None, init_channel=None, bit=-1, color_list=None): """Init.""" QLed.__init__(self, parent) PyDMWidget.__init__(self, init_channel=init_channel) self.pvbit = bit self.stateColors = color_list or self.default_colorlist
def __init__(self, parent=None, init_channel=None, replace=None): QListWidget.__init__(self, parent) PyDMWidget.__init__(self, init_channel=init_channel) self._buffer_size = 1000 self._prepend_date_time = True self._display_format_type = DisplayFormat.String self._string_encoding = "utf_8" self._date_time_fmt = '%Y/%m/%d-%H:%M:%S' self._replace = list() if replace is None else replace channel = '' if init_channel is None else init_channel self._plugin_conns = plugin_for_address(channel).connections
def connection_changed(self, conn): """Reimplement connection_changed to handle all channels.""" if not self.sender(): # do nothing when sender is None return address = self.sender().address self._address2conn[address] = conn allconn = True for conn in self._address2conn.values(): allconn &= conn PyDMWidget.connection_changed(self, allconn) self._connected = allconn self._update_statuses()
def __init__(self, parent=None, init_channel=None, **kws): """Init.""" QLabel.__init__(self, parent, **kws) PyDMWidget.__init__(self, init_channel=init_channel) self.app = QApplication.instance() self.setTextFormat(Qt.PlainText) self.setTextInteractionFlags(Qt.NoTextInteraction) self.setText("PyDMLabel") self._display_format_type = self.DisplayFormat.Default self._string_encoding = "utf_8" self._conv = 1 if is_pydm_app(): self._string_encoding = self.app.get_string_encoding()
def value_changed(self, new_val): PyDMWidget.value_changed(self, new_val) if new_val is None: return if isinstance(new_val, _np.ndarray): _log.warning('PyDMLed received a numpy array to ' + self.channel+' ('+str(new_val)+')!') return bits_set = [text for bit, text in enumerate(self.labels) if get_bit(int(new_val), bit)] state = 0 if len(bits_set) == 0 \ else 1 if len(bits_set) == 1 and \ bits_set[0] == 'Alarms' else 2 self.setState(state)
def __init__(self, parent, dev, device, prefix='', acc='SI'): """Initialize the matrix data of the specified dev.""" # initialize BaseObject BaseObject.__init__(self, device, prefix=prefix, acc=acc) self.dev = dev max_rz = self._csorb.MAX_RINGSZ bpms = np.array(self._csorb.bpm_pos) bpm_pos = [bpms + i * self._csorb.circum for i in range(max_rz)] bpm_pos = np.hstack(bpm_pos) bpm_name = self._csorb.bpm_names * max_rz bpm_nknm = self._csorb.bpm_nicknames * max_rz self.devpos = { 'BPMX': bpm_pos, 'BPMY': bpm_pos, 'CH': self._csorb.ch_pos, 'CV': self._csorb.cv_pos } self.devotpl = {'BPMX': 'BPMY', 'BPMY': 'BPMX', 'CH': 'CV', 'CV': 'CH'} self.devnames = { 'BPMX': (bpm_name, bpm_nknm), 'BPMY': (bpm_name, bpm_nknm), 'CH': (self._csorb.ch_names, self._csorb.ch_nicknames), 'CV': (self._csorb.cv_names, self._csorb.cv_nicknames) } # initialize SelectionWidget SelectionWidget.__init__(self, parent=parent, title=dev + "List", has_bothplanes=dev.lower().startswith('bpm')) # initialize PyDMWidget init_channel = self.devpref.substitute(propty=self.dev + 'EnblList-RB') PyDMWidget.__init__(self, init_channel=init_channel) self.pv_sp = _ConnSignal(init_channel.replace('-RB', '-SP')) self.pv_otpl = _ConnSignal( self.devpref.substitute(propty=self.devotpl[self.dev] + 'EnblList-SP')) # connect signals and slots self.applyChangesClicked.connect(self.send_value) self.applyBothPlanesClicked.connect(_part(self.send_value, other=True))
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)
def value_changed(self, new_val): """ Receive new value and set led color accordingly. For int or float data type the standard led behaviour is to be red when the value is 0, and green otherwise. If a :attr:`bit` is set the value received will be treated as an int and the bit value is extracted using a mask. The led represents the value of the chosen bit. """ PyDMWidget.value_changed(self, new_val) if new_val is None: return if isinstance(new_val, _np.ndarray): _log.warning('PyDMLed received a numpy array to ' + self.channel + ' (' + str(new_val) + ')!') return value = int(new_val) if self._bit < 0: # Led represents value of PV self.setState(value) else: # Led represents specific bit of PV bit_val = (value & self._mask) >> self._bit self.setState(bit_val)
def __init__(self, parent=None, image_channel=None, xaxis_channel=None, yaxis_channel=None, roioffsetx_channel=None, roioffsety_channel=None, roiwidth_channel=None, roiheight_channel=None, title='', background='w', image_width=0, image_height=0): """Initialize widget.""" GraphicsLayoutWidget.__init__(self, parent) PyDMWidget.__init__(self) self.thread = None self._imagechannel = None self._xaxischannel = None self._yaxischannel = None self._roioffsetxchannel = None self._roioffsetychannel = None self._roiwidthchannel = None self._roiheightchannel = None self._channels = 7 * [ None, ] self.image_waveform = np.zeros(0) self._image_width = image_width if not xaxis_channel else 0 self._image_height = image_height if not yaxis_channel else 0 self._roi_offsetx = 0 self._roi_offsety = 0 self._roi_width = 0 self._roi_height = 0 self._normalize_data = False self._auto_downsample = True self._last_yaxis_data = None self._last_xaxis_data = None self._auto_colorbar_lims = True self.format_tooltip = '{0:.4g}, {1:.4g}' # ViewBox and imageItem. self._view = ViewBox() self._image_item = ImageItem() self._view.addItem(self._image_item) # ROI self.ROICurve = PlotCurveItem([0, 0, 0, 0, 0], [0, 0, 0, 0, 0]) self.ROIColor = QColor('red') pen = mkPen() pen.setColor(QColor('transparent')) pen.setWidth(1) self.ROICurve.setPen(pen) self._view.addItem(self.ROICurve) # Axis. self.xaxis = AxisItem('bottom') self.xaxis.setPen(QColor(0, 0, 0)) if not xaxis_channel: self.xaxis.setVisible(False) self.yaxis = AxisItem('left') self.yaxis.setPen(QColor(0, 0, 0)) if not yaxis_channel: self.yaxis.setVisible(False) # Colorbar legend. self.colorbar = _GradientLegend() # Title. start_row = 0 if title: self.title = LabelItem(text=title, color='#000000') self.addItem(self.title, 0, 0, 1, 3) start_row = 1 # Set layout. self.addItem(self._view, start_row, 1) self.addItem(self.yaxis, start_row, 0) self.addItem(self.colorbar, start_row, 2) self.addItem(self.xaxis, start_row + 1, 1) self.setBackground(background) self.ci.layout.setColumnSpacing(0, 0) self.ci.layout.setRowSpacing(start_row, 0) # Set color map limits. self.cm_min = 0.0 self.cm_max = 255.0 # Set default reading order of numpy array data to Clike. self._reading_order = ReadingOrder.Clike # Make a right-click menu for changing the color map. self.cm_group = QActionGroup(self) self.cmap_for_action = {} for cm in self.color_maps: action = self.cm_group.addAction(cmap_names[cm]) action.setCheckable(True) self.cmap_for_action[action] = cm # Set the default colormap. self._cm_colors = None self.colorMap = PyDMColorMap.Inferno # Setup the redraw timer. self.needs_redraw = False self.redraw_timer = QTimer(self) self.redraw_timer.timeout.connect(self.redrawImage) self._redraw_rate = 30 self.maxRedrawRate = self._redraw_rate self.newImageSignal = self._image_item.sigImageChanged # Set Channels. self.imageChannel = image_channel self.xAxisChannel = xaxis_channel self.yAxisChannel = yaxis_channel self.ROIOffsetXChannel = roioffsetx_channel self.ROIOffsetYChannel = roioffsety_channel self.ROIWidthChannel = roiwidth_channel self.ROIHeightChannel = roiheight_channel