Exemple #1
0
    def setup_outputs(self):
        ffs = self.config.get('fastfaults')
        if not ffs:
            return
        outs_container = self.ui.arbiter_outputs_content
        if outs_container is None:
            return
        count = 0
        for ff in ffs:
            prefix = ff.get('prefix')
            ffo_start = ff.get('ffo_start')
            ffo_end = ff.get('ffo_end')

            ffos_zfill = len(str(ffo_end)) + 1

            entries = range(ffo_start, ffo_end + 1)

            template = 'templates/arbiter_outputs_entry.ui'
            for _ffo in entries:
                s_ffo = str(_ffo).zfill(ffos_zfill)
                macros = dict(index=count, P=prefix, FFO=s_ffo)
                widget = PyDMEmbeddedDisplay(parent=outs_container)
                widget.macros = json.dumps(macros)
                widget.filename = template
                widget.disconnectWhenHidden = False
                outs_container.layout().addWidget(widget)
                count += 1
        print(f'Added {count} arbiter outputs')
Exemple #2
0
    def do_search(self):
        # First lets clear the old connections
        self.app.close_widget_connections(self.frm_result)

        # For each widget inside the results frame, lets destroy them
        for widget in self.frm_result.findChildren(QWidget):
            widget.setParent(None)
            widget.deleteLater()
        
        # Grab the filter text
        filter_text = self.txt_filter.text()

        # For every entry in the dataset...
        for entry in self.data:
            # Check if they match our filter
            if filter_text.upper() not in entry.upper():
                continue
            # Create a PyDMEmbeddedDisplay for this entry
            disp = PyDMEmbeddedDisplay(parent=self)
            disp.macros = json.dumps({"MOTOR":entry})
            disp.filename = 'inline_motor.ui'
            disp.setMinimumWidth(700)
            disp.setMinimumHeight(40)
            disp.setMaximumHeight(100)
            # Add the Embedded Display to the Results Layout
            self.results_layout.addWidget(disp)
        # Recursively establish the connection for widgets
        # inside the Results Frame
        self.app.establish_widget_connections(self.frm_result)
Exemple #3
0
    def add_row(self, macros: dict[str, str]) -> None:
        """
        Adds a single row to the table.

        Each row will be created from the same UI file template.
        The macros used must have the same keys as all the previously
        added rows, or else the table will not work correctly.

        Parameters
        ----------
        macros : dict of str
            The macro substitutions for the UI file. These must be
            strings because we're effectively substituting them into
            the file's text.
        """
        widget = PyDMEmbeddedDisplay(parent=self)
        widget.macros = json.dumps(macros)
        widget.filename = self.ui_filename
        widget.loadWhenShown = False
        widget.disconnectWhenHidden = False
        self.add_context_menu_to_children(widget.embedded_widget)

        row_position = self.rowCount()
        self.insertRow(row_position)

        # Put the widget into the table
        self.setCellWidget(row_position, 0, widget)
        self._header_map['widget'] = 0
        self.setRowHeight(row_position, widget.height())

        # Put the index into the table
        item = ChannelTableWidgetItem(
            header='index',
            default=row_position,
        )
        self.setItem(row_position, 1, item)
        self._header_map['index'] = 1
        # Put the macros into the table
        index = 2
        for key, value in macros.items():
            item = ChannelTableWidgetItem(
                header=key,
                default=value,
            )
            self.setItem(row_position, index, item)
            self._header_map[key] = index
            index += 1
        # Set up the data columns and the channels
        for header in self._channel_headers:
            source = widget.findChild(QtCore.QObject, header)
            item = ChannelTableWidgetItem(
                header=header,
                channel=source.channel,
            )
            self.setItem(row_position, index, item)
            self._header_map[header] = index
            if item.pydm_channel is not None:
                self._channels.append(item.pydm_channel)
            index += 1
Exemple #4
0
 def show_motors(self):
     for m in self.motors:
         disp = PyDMEmbeddedDisplay(parent=self)
         disp.macros = json.dumps({"MOTOR": m})
         if os.path.exists(os.path.join(LOCAL_PATH, 'motors.ui')):
             disp.filename = os.path.join(LOCAL_PATH, 'motors.ui')
         disp.setMinimumWidth(300)
         disp.setMinimumHeight(24)
         disp.setMaximumHeight(30)
         # Add the Embedded Display to the Results Layout
         self.results_layout.addWidget(disp)
    def do_search(self):
        # For each widget inside the results frame, lets destroy them
        for widget in self.frmLT_result.findChildren(QWidget):
            widget.setParent(None)
            widget.deleteLater()
        for widget in self.frmBO_result.findChildren(QWidget):
            widget.setParent(None)
            widget.deleteLater()
        for widget in self.frmSR_result.findChildren(QWidget):
            widget.setParent(None)
            widget.deleteLater()
        for widget in self.frmDCL_result.findChildren(QWidget):
            widget.setParent(None)
            widget.deleteLater()

        # Grab the filter text
        filter_text = self.txt_filter.text()

        # For every entry in the dataset...
        for entry in self.BBB_PS_list:
            # Check if they match our filter
            if filter_text.upper() not in entry.upper():
                continue

            # Create macros list
            dict_macro_BBB = {
                "PS_CON": entry,
                "PYTHON":
                "python" if platform.system() == "Windows" else "python3"
            }
            for i in range(1, len(self.BBB_PS_list[entry]) + 1):
                dict_macro_BBB["PS{}".format(i)] = self.BBB_PS_list[entry][i -
                                                                           1]
            # Create a PyDMEmbeddedDisplay for this entry
            disp = PyDMEmbeddedDisplay(parent=self)
            PyDMApplication.instance().close_widget_connections(disp)
            disp.macros = json.dumps(dict_macro_BBB)
            disp.filename = 'PS_Controller.ui'
            disp.setMinimumWidth(700)
            disp.setMinimumHeight(40)
            disp.setMaximumHeight(100)

            # Add the Embedded Display to the Results Layout
            if "DCL" in entry:
                self.resultsDCL_layout.addWidget(disp)
            elif "SI" in entry:
                self.resultsSR_layout.addWidget(disp)
            elif "BO" in entry:
                self.resultsBO_layout.addWidget(disp)
            elif ("TB" in entry) or ("TS" in entry):
                self.resultsLT_layout.addWidget(disp)

            PyDMApplication.instance().establish_widget_connections(disp)
    def setup_requests(self):
        """Populate the table from the config file and the item_info_list."""
        if not self.config:
            return
        reqs = self.config.get('preemptive_requests')
        if not reqs:
            return
        reqs_table = self.ui.reqs_table_widget
        # setup table
        ncols = len(item_info_list) + 2
        reqs_table.setColumnCount(ncols)
        # hide extra sort columns: these just hold values for easy sorting
        for col in range(1, ncols):
            reqs_table.hideColumn(col)

        if reqs_table is None:
            return
        count = 0
        for req in reqs:
            prefix = req.get('prefix')
            arbiter = req.get('arbiter_instance')
            pool_start = req.get('assertion_pool_start')
            pool_end = req.get('assertion_pool_end')

            pool_zfill = len(str(pool_end)) + 1

            template = 'templates/preemptive_requests_entry.ui'
            for pool_id in range(pool_start, pool_end + 1):
                pool = str(pool_id).zfill(pool_zfill)
                macros = dict(index=count,
                              P=prefix,
                              ARBITER=arbiter,
                              POOL=pool)
                widget = PyDMEmbeddedDisplay(parent=reqs_table)
                widget.prefixes = macros
                widget.macros = json.dumps(macros)
                widget.filename = template
                widget.loadWhenShown = False
                widget.disconnectWhenHidden = False

                # insert the widget you see into the table
                row_position = reqs_table.rowCount()
                reqs_table.insertRow(row_position)
                reqs_table.setCellWidget(row_position, 0, widget)

                # insert a cell to preserve the original sort order
                item = PMPSTableWidgetItem(
                    store_type=int,
                    data_type=int,
                    default=count,
                )
                item.setSizeHint(widget.size())
                reqs_table.setItem(row_position, 1, item)

                # insert invisible customized QTableWidgetItems for sorting
                for num, info in enumerate(item_info_list):
                    inner_widget = widget.findChild(
                        info.widget_class,
                        info.widget_name,
                    )
                    item = PMPSTableWidgetItem(
                        store_type=info.store_type,
                        data_type=info.data_type,
                        default=info.default,
                        channel=inner_widget.channel,
                    )
                    item.setSizeHint(widget.size())
                    reqs_table.setItem(row_position, num + 2, item)
                    self._channels.append(item.pydm_channel)

                count += 1
        reqs_table.resizeRowsToContents()
        self.row_count = count
        print(f'Added {count} preemptive requests')