コード例 #1
0
 def __init__(self,
              checksum_label: ChecksumLabel,
              message: Message,
              proto_view: int,
              parent=None):
     super().__init__(parent)
     self.ui = Ui_ChecksumOptions()
     self.ui.setupUi(self)
     self.checksum_label = checksum_label
     self.data_range_table_model = self.RangeTableModel(checksum_label,
                                                        message,
                                                        proto_view,
                                                        parent=self)
     self.ui.tableViewDataRanges.setItemDelegateForColumn(
         0, SpinBoxDelegate(1, 999999, self))
     self.ui.tableViewDataRanges.setItemDelegateForColumn(
         1, SpinBoxDelegate(1, 999999, self))
     self.ui.tableViewDataRanges.horizontalHeader().setSectionResizeMode(
         QHeaderView.Stretch)
     self.ui.tableViewDataRanges.setModel(self.data_range_table_model)
     self.ui.tableViewDataRanges.setEditTriggers(
         QAbstractItemView.AllEditTriggers)
     self.display_crc_data_ranges_in_table()
     self.ui.comboBoxCRCFunction.addItems(
         [crc_name for crc_name in GenericCRC.DEFAULT_POLYNOMIALS])
     self.ui.comboBoxCRCFunction.addItems(
         [special_crc_name for special_crc_name in self.SPECIAL_CRCS])
     self.ui.lineEditCRCPolynomial.setValidator(
         QRegExpValidator(QRegExp("[0-9,a-f]*")))
     self.ui.comboBoxCategory.clear()
     for _, member in self.checksum_label.Category.__members__.items():
         self.ui.comboBoxCategory.addItem(member.value)
     self.set_ui_for_category()
     self.setFocus()
     self.create_connects()
コード例 #2
0
    def __init__(self,
                 preselected_index,
                 message: Message,
                 viewtype: int,
                 parent=None):
        super().__init__(parent)
        self.ui = Ui_DialogLabels()
        self.ui.setupUi(self)
        field_types = FieldType.load_from_xml()
        self.model = PLabelTableModel(message, field_types)
        self.preselected_index = preselected_index

        self.ui.tblViewProtoLabels.setItemDelegateForColumn(
            0,
            ComboBoxDelegate([ft.caption for ft in field_types],
                             is_editable=True,
                             return_index=False,
                             parent=self))
        self.ui.tblViewProtoLabels.setItemDelegateForColumn(
            1, SpinBoxDelegate(1, len(message), self))
        self.ui.tblViewProtoLabels.setItemDelegateForColumn(
            2, SpinBoxDelegate(1, len(message), self))
        self.ui.tblViewProtoLabels.setItemDelegateForColumn(
            3,
            ComboBoxDelegate([""] * len(constants.LABEL_COLORS),
                             colors=constants.LABEL_COLORS,
                             parent=self))
        self.ui.tblViewProtoLabels.setItemDelegateForColumn(
            4, CheckBoxDelegate(self))
        self.ui.tblViewProtoLabels.setModel(self.model)
        self.ui.tblViewProtoLabels.selectRow(preselected_index)
        self.ui.tblViewProtoLabels.setEditTriggers(
            QAbstractItemView.AllEditTriggers)

        self.ui.tblViewProtoLabels.horizontalHeader().setSectionResizeMode(
            QHeaderView.Stretch)

        self.ui.tblViewProtoLabels.resizeColumnsToContents()
        self.setWindowFlags(Qt.Window)
        self.setWindowTitle(
            self.tr("Edit Protocol Labels from message type %s") %
            message.message_type.name)

        self.configure_special_config_tabs()
        self.ui.splitter.setSizes([self.height() / 2, self.height() / 2])

        self.create_connects()
        self.ui.cbProtoView.setCurrentIndex(viewtype)
        self.setAttribute(Qt.WA_DeleteOnClose)

        try:
            self.restoreGeometry(
                constants.SETTINGS.value("{}/geometry".format(
                    self.__class__.__name__)))
        except TypeError:
            pass

        for i in range(self.model.rowCount()):
            self.open_editors(i)
コード例 #3
0
    def __init__(self,
                 preselected_index,
                 message_type: MessageType,
                 viewtype: int,
                 max_end: int,
                 parent=None):
        super().__init__(parent)
        self.ui = Ui_DialogLabels()
        self.ui.setupUi(self)
        field_types = FieldType.load_from_xml()
        self.model = PLabelTableModel(message_type, field_types)
        self.preselected_index = preselected_index

        self.ui.tblViewProtoLabels.setItemDelegateForColumn(
            0,
            ComboBoxDelegate([ft.caption for ft in field_types],
                             is_editable=True,
                             return_index=False,
                             parent=self))
        self.ui.tblViewProtoLabels.setItemDelegateForColumn(
            1, SpinBoxDelegate(1, max_end, self))
        self.ui.tblViewProtoLabels.setItemDelegateForColumn(
            2, SpinBoxDelegate(1, max_end, self))
        self.ui.tblViewProtoLabels.setItemDelegateForColumn(
            3,
            ComboBoxDelegate([""] * len(constants.LABEL_COLORS),
                             colors=constants.LABEL_COLORS,
                             parent=self))
        self.ui.tblViewProtoLabels.setItemDelegateForColumn(
            4, CheckBoxDelegate(self))

        self.ui.tblViewProtoLabels.setModel(self.model)
        self.ui.tblViewProtoLabels.selectRow(preselected_index)

        self.ui.tblViewProtoLabels.horizontalHeader().setSectionResizeMode(
            QHeaderView.Stretch)

        for i in range(self.model.row_count):
            self.open_editors(i)

        self.ui.tblViewProtoLabels.resizeColumnsToContents()
        self.setWindowTitle(
            self.tr("Edit Protocol Labels from %s") % message_type.name)

        self.create_connects()
        self.ui.cbProtoView.setCurrentIndex(viewtype)
        self.setAttribute(Qt.WA_DeleteOnClose)
コード例 #4
0
    def __init__(self, parameters: list, modulation_type: str, parent=None):
        super().__init__(parent)
        self.ui = Ui_DialogModulationParameters()
        self.ui.setupUi(self)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setWindowFlags(Qt.Window)

        self.parameters = parameters
        self.num_bits = int(math.log2(len(parameters)))

        if "FSK" in modulation_type:
            self.ui.tblSymbolParameters.setItemDelegateForColumn(
                1, KillerSpinBoxDelegate(-1e12, 1e12, self))
            self.ui.tblSymbolParameters.horizontalHeaderItem(1).setText(
                "Frequency in Hz")
        elif "ASK" in modulation_type:
            self.ui.tblSymbolParameters.horizontalHeaderItem(1).setText(
                "Amplitude")
            self.ui.tblSymbolParameters.setItemDelegateForColumn(
                1, SpinBoxDelegate(0, 100, self, "%"))
        elif "PSK" in modulation_type:
            self.ui.tblSymbolParameters.setItemDelegateForColumn(
                1, SpinBoxDelegate(-360, 360, self, "°"))
            self.ui.tblSymbolParameters.horizontalHeaderItem(1).setText(
                "Phase")

        fmt = "{0:0" + str(self.num_bits) + "b}"
        self.ui.tblSymbolParameters.setRowCount(len(parameters))
        for i, parameter in enumerate(parameters):
            item = QTableWidgetItem(fmt.format(i))
            font = item.font()
            font.setBold(True)
            item.setFont(font)
            item.setFlags(Qt.ItemIsEnabled)
            self.ui.tblSymbolParameters.setItem(i, 0, item)

            item = QTableWidgetItem()
            item.setData(Qt.DisplayRole, self.parameters[i])
            self.ui.tblSymbolParameters.setItem(i, 1, item)
            self.ui.tblSymbolParameters.openPersistentEditor(
                self.ui.tblSymbolParameters.item(i, 1))

        self.create_connects()
コード例 #5
0
    def __init__(self, preselected_index, proto_group: ProtocolGroup, offset: int, viewtype: int,
                 parent=None):
        super().__init__(parent)
        self.ui = Ui_DialogLabels()
        self.ui.setupUi(self)
        self.model = PLabelTableModel(proto_group, offset)
        self.preselected_index = preselected_index

        if proto_group.num_blocks > 0:
            maxval = numpy.max([len(block) for block in proto_group.decoded_bits_str])
        else:
            maxval = 42000

        self.ui.tblViewProtoLabels.setItemDelegateForColumn(1, SpinBoxDelegate(1, maxval, self))
        self.ui.tblViewProtoLabels.setItemDelegateForColumn(2, SpinBoxDelegate(1, maxval, self))
        self.ui.tblViewProtoLabels.setItemDelegateForColumn(3, CheckBoxDelegate(self))
        self.ui.tblViewProtoLabels.setItemDelegateForColumn(4, SpinBoxDelegate(offset+1,
                                                                               offset+proto_group.num_blocks,
                                                                               self))

        self.ui.tblViewProtoLabels.setItemDelegateForColumn(5,
                                                            ComboBoxDelegate([""] * len(constants.LABEL_COLORS), True,
                                                                             self))
        self.ui.tblViewProtoLabels.setItemDelegateForColumn(6, CheckBoxDelegate(self))
        self.ui.tblViewProtoLabels.setItemDelegateForColumn(7, DeleteButtonDelegate(self))

        self.ui.tblViewProtoLabels.setModel(self.model)
        self.ui.tblViewProtoLabels.selectRow(preselected_index)

        for i in range(self.model.row_count):
            self.openEditors(i)

        self.ui.tblViewProtoLabels.resizeColumnsToContents()
        self.setWindowTitle(self.tr("Edit Protocol Labels from %s") % proto_group.name)

        self.create_connects()
        self.ui.cbProtoView.setCurrentIndex(viewtype)
        self.setAttribute(Qt.WA_DeleteOnClose)