コード例 #1
0
    def prepare_modulation_buffer(self, total_samples: int, show_error=True) -> IQArray:
        dtype = Modulator.get_dtype()
        n = 2 if dtype == np.int8 else 4 if dtype == np.int16 else 8

        memory_size_for_buffer = total_samples * n
        logger.debug("Allocating {0:.2f}MB for modulated samples".format(memory_size_for_buffer / (1024 ** 2)))
        try:
            # allocate it three times as we need the same amount for the sending process
            IQArray(None, dtype=dtype, n=3*total_samples)
        except MemoryError:
            # will go into continuous mode in this case
            if show_error:
                Errors.not_enough_ram_for_sending_precache(3*memory_size_for_buffer)
            return None

        return IQArray(None, dtype=dtype, n=total_samples)
コード例 #2
0
ファイル: ContinuousModulator.py プロジェクト: zjywlive/urh
    def __init__(self, messages, modulators, num_repeats=-1):
        """
        
        :type messages: list of Message 
        :type modulators: list of Modulator 
        """
        self.messages = messages
        self.modulators = modulators
        self.num_repeats = num_repeats  # -1 or 0 = infinite

        self.ring_buffer = RingBuffer(
            int(settings.CONTINUOUS_BUFFER_SIZE_MB * 1e6) // 8,
            dtype=Modulator.get_dtype())

        self.current_message_index = Value("L", 0)

        self.abort = Value("i", 0)
        self.process = Process(target=self.modulate_continuously,
                               args=(self.num_repeats, ),
                               daemon=True)
コード例 #3
0
    def __init__(self,
                 installed_plugins,
                 highlighted_plugins=None,
                 parent=None):
        super().__init__(parent)

        self.backend_handler = BackendHandler()

        self.ui = Ui_DialogOptions()
        self.ui.setupUi(self)
        self.setWindowFlags(Qt.Window)

        self.device_options_model = DeviceOptionsTableModel(
            self.backend_handler, self)
        self.device_options_model.update()
        self.ui.tblDevices.setModel(self.device_options_model)
        self.ui.tblDevices.horizontalHeader().setSectionResizeMode(
            QHeaderView.Stretch)

        self.ui.tblDevices.setItemDelegateForColumn(
            1, ComboBoxDelegate(["native", "GNU Radio"]))

        self.setAttribute(Qt.WA_DeleteOnClose)
        layout = QHBoxLayout(self.ui.tab_plugins)
        self.plugin_controller = PluginFrame(installed_plugins,
                                             highlighted_plugins,
                                             parent=self)
        layout.addWidget(self.plugin_controller)
        self.ui.tab_plugins.setLayout(layout)

        self.ui.btnViewBuildLog.hide()
        self.build_log = ""

        # We use bundled native device backends on windows, so no need to reconfigure them
        self.ui.groupBoxNativeOptions.setVisible(sys.platform != "win32")
        self.ui.labelIconTheme.setVisible(sys.platform == "linux")
        self.ui.comboBoxIconTheme.setVisible(sys.platform == "linux")

        self.ui.comboBoxTheme.setCurrentIndex(
            settings.read("theme_index", 0, int))
        self.ui.comboBoxIconTheme.setCurrentIndex(
            settings.read("icon_theme_index", 0, int))
        self.ui.checkBoxShowConfirmCloseDialog.setChecked(
            not settings.read('not_show_close_dialog', False, bool))
        self.ui.checkBoxHoldShiftToDrag.setChecked(
            settings.read('hold_shift_to_drag', True, bool))
        self.ui.checkBoxDefaultFuzzingPause.setChecked(
            settings.read('use_default_fuzzing_pause', True, bool))

        self.ui.checkBoxAlignLabels.setChecked(
            settings.read('align_labels', True, bool))

        self.ui.doubleSpinBoxRAMThreshold.setValue(
            100 * settings.read('ram_threshold', 0.6, float))

        if self.backend_handler.gr_python_interpreter:
            self.ui.lineEditGRPythonInterpreter.setText(
                self.backend_handler.gr_python_interpreter)

        self.ui.doubleSpinBoxFuzzingPause.setValue(
            settings.read("default_fuzzing_pause", 10**6, int))
        self.ui.doubleSpinBoxFuzzingPause.setEnabled(
            settings.read('use_default_fuzzing_pause', True, bool))

        self.ui.checkBoxMultipleModulations.setChecked(
            settings.read("multiple_modulations", False, bool))

        self.ui.radioButtonLowModulationAccuracy.setChecked(
            Modulator.get_dtype() == np.int8)
        self.ui.radioButtonMediumModulationAccuracy.setChecked(
            Modulator.get_dtype() == np.int16)
        self.ui.radioButtonHighModulationAccuracy.setChecked(
            Modulator.get_dtype() == np.float32)

        completer = QCompleter()
        completer.setModel(QDirModel(completer))
        self.ui.lineEditGRPythonInterpreter.setCompleter(completer)

        self.ui.spinBoxFontSize.setValue(qApp.font().pointSize())

        self.refresh_device_tab()

        self.create_connects()
        self.old_show_pause_as_time = False

        self.field_type_table_model = FieldTypeTableModel([], parent=self)
        self.ui.tblLabeltypes.setModel(self.field_type_table_model)
        self.ui.tblLabeltypes.horizontalHeader().setSectionResizeMode(
            QHeaderView.Stretch)

        self.ui.tblLabeltypes.setItemDelegateForColumn(
            1,
            ComboBoxDelegate([f.name for f in FieldType.Function],
                             return_index=False,
                             parent=self))
        self.ui.tblLabeltypes.setItemDelegateForColumn(
            2, ComboBoxDelegate(ProtocolLabel.DISPLAY_FORMATS, parent=self))

        self.read_options()

        self.old_default_view = self.ui.comboBoxDefaultView.currentIndex()
        self.old_num_sending_repeats = self.ui.spinBoxNumSendingRepeats.value()
        self.ui.labelRebuildNativeStatus.setText("")

        self.show_available_colormaps()

        try:
            self.restoreGeometry(
                settings.read("{}/geometry".format(self.__class__.__name__)))
        except TypeError:
            pass