def make_objective_widget(self, property): widget = Qt.QComboBox() widget.setEditable(False) mags = self.get_scope_attr(self.PROPERTY_ROOT + 'nosepiece.all_objectives') model = _ObjectivesModel(mags, widget.font(), self) widget.setModel(model) def prop_changed(value): widget.setCurrentIndex(value) update = self.subscribe(property, callback=prop_changed) if update is None: widget.setEnabled(False) else: def gui_changed(value): try: update(value) except rpc_client.RPCError as e: error = 'Could not set {} ({}).'.format( property, e.args[0]) Qt.QMessageBox.warning(self, 'RPC Exception', error) # TODO: verify the below doesn't blow up without indexing the # overloaded currentIndexChanged signal as [int] widget.currentIndexChanged.connect(gui_changed) return widget
def make_enum_widget(self, property): widget = Qt.QComboBox() values = sorted( getattr(self.scope.camera, property + '_values').keys()) indices = {v: i for i, v in enumerate(values)} widget.addItems(values) update = self.subscribe( self.PROPERTY_ROOT + property, callback=lambda value: widget.setCurrentIndex(indices[value])) if update is None: raise TypeError('{} is not a writable property!'.format(property)) def changed(value): try: update(value) except rpc_client.RPCError as e: if e.args[0].find('NOTWRITABLE') != -1: error = "Given the camera state, {} can't be changed.".format( property) elif e.args[0].find('NOTAVAILABLE') != -1: accepted_values = sorted( k for k, v in getattr(self.scope.camera, property + '_values').items() if v) error = 'Given the camera state, {} can only be one of [{}].'.format( property, ', '.join(accepted_values)) else: error = 'Could not set {} ({}).'.format( property, e.args[0]) Qt.QMessageBox.warning(self, 'Invalid Value', error) widget.currentIndexChanged[str].connect(changed) return widget
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.setWindowTitle("Cute Fileserver Client") # Create a container object self._container = Qt.QWidget() self.setCentralWidget(self._container) # Create a grid self.grid = Qt.QGridLayout() # Create the ip address selection text field self.address_field = Qt.QLineEdit() self.address_field.setPlaceholderText("127.0.0.1:3001") self.grid.addWidget(self.address_field) # Create the connect button self.connect_btn = Qt.QPushButton() self.connect_btn.setText("Connect") self.connect_btn.clicked.connect(self.connect) self.grid.addWidget(self.connect_btn) # Create the file selection combobox self.file_selector = Qt.QComboBox() self.file_selector.setEnabled(False) self.grid.addWidget(self.file_selector) # Create the download button self.download_btn = Qt.QPushButton() self.download_btn.setText("Download") self.download_btn.setEnabled(False) self.download_btn.clicked.connect(self.download) self.grid.addWidget(self.download_btn) # Set the grid as layout self._container.setLayout(self.grid) # Extra data self.client_socket = None
def _addSelectorItem(self, parent, title, setting, items, icons, ids): """ Add combo box item. Arguments: parent (QWidget): Parent widget. title (str): Text label. setting (str): Preference item's identifier. items (list[str]): Selector items (choices). icons (list[str]): Names of icons for the selector items. ids (list[str]): Identifiers of the selector items (to identify choices in the preferences file). """ label = Q.QLabel(title, parent) _setObjName(label, "label", setting) editor = Q.QComboBox(parent) _setObjName(editor, "combo", setting) for index, item in enumerate(items): editor.addItem(item) if index < len(icons) and icons[index]: editor.setItemIcon(index, load_icon(icons[index])) if index < len(ids) and ids[index]: editor.setItemData(index, ids[index]) row = self._layout(parent).rowCount() self._layout(parent).addWidget(label, row, 0) self._layout(parent).addWidget(editor, row, 1) self.widgets[setting] = editor
def __init__(self): ZlmCollapsableWidget.__init__(self, "Presets: ") self.cb_preset_file = Qt.QComboBox() self.cb_layer_presets = Qt.QComboBox() self.pb_activate = Qt.QPushButton('Activate') self.pb_activate.clicked.connect(self.on_preset_activated) self.pb_add_file = Qt.QPushButton(Qt.QIcon(':/add.png'), '') self.pb_add_file.clicked.connect(self.pb_add_file_clicked) self.pb_rem_file = Qt.QPushButton(Qt.QIcon(':/remove.png'), '') self.pb_rem_file.clicked.connect(self.pb_rem_file_clicked) self.pb_add_preset = Qt.QPushButton(Qt.QIcon(':/add.png'), '') self.pb_add_preset.clicked.connect(self.pb_add_preset_clicked) self.pb_rem_preset = Qt.QPushButton(Qt.QIcon(':/remove.png'), '') self.pb_rem_preset.clicked.connect(self.pb_rem_preset_clicked) self.pb_save_preset = Qt.QPushButton(Qt.QIcon(':/save.png'), '') self.pb_save_preset.clicked.connect(self.pb_save_preset_clicked) layout1 = Qt.QHBoxLayout() layout1.addWidget(self.cb_preset_file, 1) layout1.addWidget(self.pb_add_file, 0) layout1.addWidget(self.pb_rem_file, 0) layout2 = Qt.QHBoxLayout() layout2.addWidget(self.cb_layer_presets, 1) layout2.addWidget(self.pb_save_preset, 0) layout2.addWidget(self.pb_add_preset, 0) layout2.addWidget(self.pb_rem_preset, 0) mainLayout = Qt.QVBoxLayout() mainLayout.addLayout(layout1) mainLayout.addLayout(layout2) mainLayout.addWidget(self.pb_activate) self.set_layout(mainLayout) self.presets = {} self._app_index = 0 self._user_index = 0 self.build_presets() self.cb_preset_file.currentIndexChanged.connect( self.preset_file_changed)
def _curvesComboBox(self): b = Qt.QComboBox() for i in self.curveTypes: b.addItem(i) b.currentIndexChanged.connect(self._curveTypeChanged) self._curveInfo = b return b
def make_enum_widget(self, rppath, pt, choices_rppath): widget = Qt.QComboBox() widget.setEditable(False) ppath = self.PROPERTY_ROOT + rppath widget.addItems(sorted(self.pattr(choices_rppath))) update = self.subscribe(ppath, callback=widget.setCurrentText) if update is None: raise TypeError('{} is not a writable property!'.format(ppath)) def gui_changed(value): try: update(value) except rpc_client.RPCError as e: error = 'Could not set {} ({}).'.format(ppath, e.args[0]) Qt.QMessageBox.warning(self, 'RPC Exception', error) widget.currentTextChanged.connect(gui_changed) return widget
def _init_toolbars(self): self.main_view_toolbar = self.addToolBar('Main View') self.main_view_zoom_combo = Qt.QComboBox(self) self.main_view_toolbar.addWidget(self.main_view_zoom_combo) self.main_view_zoom_combo.setEditable(True) self.main_view_zoom_combo.setInsertPolicy(Qt.QComboBox.NoInsert) self.main_view_zoom_combo.setDuplicatesEnabled(True) self.main_view_zoom_combo.setSizeAdjustPolicy( Qt.QComboBox.AdjustToContents) for zoom in GeneralView._ZOOM_PRESETS: self.main_view_zoom_combo.addItem( self._format_zoom(zoom * 100) + '%') self.main_view_zoom_combo.setCurrentIndex( GeneralView._ZOOM_ONE_TO_ONE_PRESET_IDX) self.main_view_zoom_combo.activated[int].connect( self._main_view_zoom_combo_changed) self.main_view_zoom_combo.lineEdit().returnPressed.connect( self._main_view_zoom_combo_custom_value_entered) self.main_view.zoom_changed.connect(self._main_view_zoom_changed) self.main_view_toolbar.addAction(self.main_view.zoom_to_fit_action) self.main_view_toolbar.addAction( self.layer_stack_reset_curr_min_max_action) self.main_view_toolbar.addAction( self.layer_stack_reset_curr_gamma_action) self.main_view_toolbar.addAction( self.layer_stack.auto_min_max_master_on_enabled_action) self.main_view_toolbar.addAction( self.layer_stack.examine_layer_mode_action) self.main_view_toolbar.addAction(self.main_view_snapshot_action) self.main_view_toolbar.addAction( self.flipbook.consolidate_selected_action) self.main_view_toolbar.addAction(self.flipbook.delete_selected_action) self.dock_widget_visibility_toolbar = self.addToolBar( 'Dock Widget Visibility') self.dock_widget_visibility_toolbar.addAction( self.layer_table_dock_widget.toggleViewAction()) self.dock_widget_visibility_toolbar.addAction( self.layer_stack_painter_dock_widget.toggleViewAction()) self.dock_widget_visibility_toolbar.addAction( self.histogram_dock_widget.toggleViewAction()) self.dock_widget_visibility_toolbar.addAction( self.flipbook_dock_widget.toggleViewAction()) self.dock_widget_visibility_toolbar.addAction( self.fps_display_dock_widget.toggleViewAction())
def __init__(self, system, database, parent=None, app=None): ConnectViewer.__init__(self, system, database, app=app, parent=parent) self.setWindowTitle("Connect all") self.wgt_dgraph = DGraphWidget(database=self.database, parent=self) self.connect_manager = ConnectManager(database) self.view_dgraph = self.new_view("Disconnectivity Graph", self.wgt_dgraph, QtCore.Qt.TopDockWidgetArea) self.view_dgraph.hide() self.ui.actionD_Graph.setVisible(True) self.ui.actionD_Graph.setChecked(False) self.textEdit_summary = QtGui.QTextEdit(parent=self) self.textEdit_summary.setReadOnly(True) self.view_summary = self.new_view("Summary", self.textEdit_summary, pos=QtCore.Qt.TopDockWidgetArea) self.connect_summary = _ConnectAllSummary() self.ui.actionSummary.setVisible(True) self.view_summary.hide() self.ui.actionSummary.setChecked(False) self.ui.action3D.setChecked(False) self.view_3D.hide() self.ui.actionEnergy.setChecked(False) self.view_energies.hide() self.ui.actionPause.setVisible(True) self.is_running = False self.failed_pairs = set() # add combo box to toolbar self.combobox = Qt.QComboBox() self.ui.toolBar.addWidget(self.combobox) self.combobox.addItems( ["connect strategy:", "random", "global min", "untrap", "combine"]) self.combobox.setToolTip( "the strategy used to select which minima to connect")
def make_enum_widget(self, property, choices_property): widget = Qt.QComboBox() widget.setEditable(False) widget.addItems( sorted(self.get_scope_attr(self.PROPERTY_ROOT + choices_property))) update = self.subscribe(property, callback=widget.setCurrentText) if update is None: widget.setEnabled(False) else: def gui_changed(value): try: update(value) except rpc_client.RPCError as e: error = 'Could not set {} ({}).'.format( property, e.args[0]) Qt.QMessageBox.warning(self, 'RPC Exception', error) widget.currentTextChanged.connect(gui_changed) return widget
def test_qt(): from PyQt5 import Qt app = Qt.QApplication([]) state = Dict(foo='foo', count=1, items=tuple('abcdefg')) label_foo = Qt.QLabel() edit_foo = Qt.QLineEdit() label_count = Qt.QLabel() spin_count = Qt.QSpinBox() combo_count = Qt.QComboBox() qt.connect(label_foo, state, 'foo') qt.connect(edit_foo, state, 'foo') qt.connect(label_count, state, 'count') qt.connect(spin_count, state, 'count') qt.connect_combo_box_items(combo_count, state, 'items') qt.connect(combo_count, state, 'count') assert label_foo.text() == 'foo' assert edit_foo.text() == 'foo' assert spin_count.value() == 1 assert label_count.text() == '1' assert combo_count.currentIndex() == 1 assert tuple(combo_count.itemText(i) for i in range(combo_count.count())) == state['items'] state['foo'] = 'bar' assert label_foo.text() == 'bar' assert edit_foo.text() == 'bar' assert label_count.text() == '1' assert spin_count.value() == 1 state['count'] += 1 assert label_foo.text() == 'bar' assert edit_foo.text() == 'bar' assert label_count.text() == '2' assert spin_count.value() == 2
def __init__(self): SettingsTabBase.__init__(self, "External Application") self.pb_send_after_export = Qt.QPushButton('Send to app') self.pb_send_after_export.setCheckable(True) self.cb_current_app = Qt.QComboBox() self.app_table = Qt.QTableWidget() self.app_table.itemChanged.connect(self.item_changed) pb_add = Qt.QPushButton(Qt.QIcon(":/add.png"), '') pb_add.clicked.connect(self.add_app) pb_rem = Qt.QPushButton(Qt.QIcon(":/remove.png"), '') pb_rem.clicked.connect(self.remove_app) pb_reset = Qt.QPushButton(Qt.QIcon(":/reset.png"), "") pb_reset.clicked.connect(self.reset_settings) top_layout = Qt.QHBoxLayout() top_layout.addWidget(self.pb_send_after_export, 1) top_layout.addSpacing(10) top_layout.addWidget(Qt.QLabel("Current Application: "), 0) top_layout.addWidget(self.cb_current_app, 1) bot_layout = Qt.QHBoxLayout() bot_layout.addWidget(pb_add) bot_layout.addWidget(pb_rem) bot_layout.addStretch() bot_layout.addWidget(pb_reset) layout = Qt.QVBoxLayout() layout.addLayout(top_layout) layout.addWidget(self.app_table) layout.addLayout(bot_layout) self.set_layout(layout)
def make_objective_widget(self, rppath, pt, objectives_rppath): widget = Qt.QComboBox() widget.setEditable(False) ppath = self.PROPERTY_ROOT + rppath mags = self.pattr(objectives_rppath) model = _ObjectivesModel(mags, widget.font(), self) widget.setModel(model) def prop_changed(value): widget.setCurrentIndex(value) update = self.subscribe(ppath, callback=prop_changed) if update is None: raise TypeError('{} is not a writable property!'.format(ppath)) def gui_changed(value): try: update(value) except rpc_client.RPCError as e: error = 'Could not set {} ({}).'.format(ppath, e.args[0]) Qt.QMessageBox.warning(self, 'RPC Exception', error) widget.currentIndexChanged[int].connect(gui_changed) return widget
def __init__(self): super().__init__() self.setWindowTitle('speech_recognition__microphone__google') self.pb_microphone = Qt.QPushButton('🎤 SPEAK') self.pb_microphone.setFont(Qt.QFont('Arial', 16)) self.cb_lang = Qt.QComboBox() self.cb_lang.addItems(["en-US", "ru-RU"]) self.cb_lang.setCurrentIndex(1) self.pte_result = Qt.QPlainTextEdit() self.pte_result.setFont(Qt.QFont('Arial', 12)) self.pte_result.setReadOnly(True) self.progress_bar = Qt.QProgressBar() self.progress_bar.setTextVisible(False) self.progress_bar.hide() self.progress_bar.setRange(0, 0) # Infinity layout = Qt.QVBoxLayout() layout.addWidget(self.pb_microphone) layout.addWidget(self.cb_lang) layout.addWidget(self.pte_result) layout.addWidget(self.progress_bar) self.setLayout(layout) self.thread = SpeechRecognitionThread() self.thread.about_text.connect(self.pte_result.appendPlainText) self.thread.started.connect(self.progress_bar.show) self.thread.finished.connect(self._speech_recognition_finish) # Start speech recognition self.pb_microphone.clicked.connect(self._speech_recognition_start)
def __init__(self, buflen=4096, dc_offset_i=0, dc_offset_q=0, instance=0, num_buffers=16, num_xfers=8, rx_bandwidth=1.5e6, rx_frequency=950e6, rx_lna_gain=6, rx_sample_rate=3e6, rx_vga_gain=20, serial="", verbosity="info"): gr.top_block.__init__(self, "Simple bladeRF RX GUI") Qt.QWidget.__init__(self) self.setWindowTitle("Simple bladeRF RX GUI") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "bladeRF_rx") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Parameters ################################################## self.buflen = buflen self.dc_offset_i = dc_offset_i self.dc_offset_q = dc_offset_q self.instance = instance self.num_buffers = num_buffers self.num_xfers = num_xfers self.rx_bandwidth = rx_bandwidth self.rx_frequency = rx_frequency self.rx_lna_gain = rx_lna_gain self.rx_sample_rate = rx_sample_rate self.rx_vga_gain = rx_vga_gain self.serial = serial self.verbosity = verbosity ################################################## # Variables ################################################## self.bladerf_selection = bladerf_selection = str( instance) if serial == "" else serial self.bladerf_args = bladerf_args = "bladerf=" + bladerf_selection + ",buffers=" + str( num_buffers) + ",buflen=" + str(buflen) + ",num_xfers=" + str( num_xfers) + ",verbosity=" + verbosity self.gui_rx_vga_gain = gui_rx_vga_gain = rx_vga_gain self.gui_rx_sample_rate = gui_rx_sample_rate = rx_sample_rate self.gui_rx_lna_gain = gui_rx_lna_gain = rx_lna_gain self.gui_rx_frequency = gui_rx_frequency = rx_frequency self.gui_rx_bandwidth = gui_rx_bandwidth = rx_bandwidth self.gui_dc_offset_q = gui_dc_offset_q = dc_offset_q self.gui_dc_offset_i = gui_dc_offset_i = dc_offset_i self.gui_bladerf_args = gui_bladerf_args = bladerf_args ################################################## # Blocks ################################################## self._gui_rx_vga_gain_range = Range(5, 60, 1, rx_vga_gain, 200) self._gui_rx_vga_gain_win = RangeWidget(self._gui_rx_vga_gain_range, self.set_gui_rx_vga_gain, 'RX VGA1 + VGA2 Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._gui_rx_vga_gain_win, 0, 5, 1, 4) [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(5, 9)] self._gui_rx_sample_rate_range = Range(1.5e6, 40e6, 500e3, rx_sample_rate, 200) self._gui_rx_sample_rate_win = RangeWidget( self._gui_rx_sample_rate_range, self.set_gui_rx_sample_rate, 'Sample Rate', "counter_slider", float) self.top_grid_layout.addWidget(self._gui_rx_sample_rate_win, 1, 0, 1, 2) [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 2)] self._gui_rx_lna_gain_options = ( 0, 3, 6, ) self._gui_rx_lna_gain_labels = ( '0 dB', '3 dB', '6 dB', ) self._gui_rx_lna_gain_tool_bar = Qt.QToolBar(self) self._gui_rx_lna_gain_tool_bar.addWidget(Qt.QLabel('LNA Gain' + ": ")) self._gui_rx_lna_gain_combo_box = Qt.QComboBox() self._gui_rx_lna_gain_tool_bar.addWidget( self._gui_rx_lna_gain_combo_box) for label in self._gui_rx_lna_gain_labels: self._gui_rx_lna_gain_combo_box.addItem(label) self._gui_rx_lna_gain_callback = lambda i: Qt.QMetaObject.invokeMethod( self._gui_rx_lna_gain_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._gui_rx_lna_gain_options.index(i))) self._gui_rx_lna_gain_callback(self.gui_rx_lna_gain) self._gui_rx_lna_gain_combo_box.currentIndexChanged.connect( lambda i: self.set_gui_rx_lna_gain(self._gui_rx_lna_gain_options[i] )) self.top_grid_layout.addWidget(self._gui_rx_lna_gain_tool_bar, 0, 9, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(9, 10)] self._gui_rx_frequency_range = Range(0, 3.8e9, 1e6, rx_frequency, 200) self._gui_rx_frequency_win = RangeWidget(self._gui_rx_frequency_range, self.set_gui_rx_frequency, 'Frequency', "counter_slider", float) self.top_grid_layout.addWidget(self._gui_rx_frequency_win, 0, 0, 1, 5) [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 5)] self._gui_rx_bandwidth_range = Range(1.5e6, 28e6, 0.5e6, rx_bandwidth, 200) self._gui_rx_bandwidth_win = RangeWidget(self._gui_rx_bandwidth_range, self.set_gui_rx_bandwidth, 'Bandwidth', "counter_slider", float) self.top_grid_layout.addWidget(self._gui_rx_bandwidth_win, 1, 2, 1, 2) [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(2, 4)] self._gui_dc_offset_q_range = Range(-1.0, 1.0, (1.0 / 2048.0), dc_offset_q, 200) self._gui_dc_offset_q_win = RangeWidget(self._gui_dc_offset_q_range, self.set_gui_dc_offset_q, 'Q DC Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._gui_dc_offset_q_win, 1, 6, 1, 2) [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(6, 8)] self._gui_dc_offset_i_range = Range(-1.0, 1.0, (1.0 / 2048.0), dc_offset_i, 200) self._gui_dc_offset_i_win = RangeWidget(self._gui_dc_offset_i_range, self.set_gui_dc_offset_i, 'I DC Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._gui_dc_offset_i_win, 1, 4, 1, 2) [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(4, 6)] self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 8192, #size firdes.WIN_BLACKMAN_hARRIS, #wintype gui_rx_frequency, #fc gui_rx_sample_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 2, 5, 5, 5) [self.top_grid_layout.setRowStretch(r, 1) for r in range(2, 7)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(5, 10)] self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 8192, #size rx_sample_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 7, 0, 3, 10) [self.top_grid_layout.setRowStretch(r, 1) for r in range(7, 10)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 10)] self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 8192, #size firdes.WIN_BLACKMAN_hARRIS, #wintype gui_rx_frequency, #fc gui_rx_sample_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 2, 0, 5, 5) [self.top_grid_layout.setRowStretch(r, 1) for r in range(2, 7)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 5)] self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + bladerf_args) self.osmosdr_source_0.set_sample_rate(gui_rx_sample_rate) self.osmosdr_source_0.set_center_freq(gui_rx_frequency, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(1, 0) self.osmosdr_source_0.set_iq_balance_mode(1, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(gui_rx_lna_gain, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(gui_rx_vga_gain, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(gui_rx_bandwidth, 0) self._gui_bladerf_args_tool_bar = Qt.QToolBar(self) if None: self._gui_bladerf_args_formatter = None else: self._gui_bladerf_args_formatter = lambda x: str(x) self._gui_bladerf_args_tool_bar.addWidget( Qt.QLabel("bladeRF arguments" + ": ")) self._gui_bladerf_args_label = Qt.QLabel( str(self._gui_bladerf_args_formatter(self.gui_bladerf_args))) self._gui_bladerf_args_tool_bar.addWidget(self._gui_bladerf_args_label) self.top_grid_layout.addWidget(self._gui_bladerf_args_tool_bar, 11, 0, 1, 10) [self.top_grid_layout.setRowStretch(r, 1) for r in range(11, 12)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 10)] self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_const_vxx_0_0 = blocks.add_const_vff( (gui_dc_offset_q, )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((gui_dc_offset_i, )) ################################################## # Connections ################################################## self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_add_const_vxx_0_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_add_const_vxx_0_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_complex_to_float_0, 0))
def __init__(self): gr.top_block.__init__(self, "Wifi Rx") Qt.QWidget.__init__(self) self.setWindowTitle("Wifi Rx") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "wifi_rx") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.window_size = window_size = 48 self.sync_length = sync_length = 320 self.samp_rate = samp_rate = 2e6 self.rf = rf = 14 self.lo_offset = lo_offset = 0 self.gain = gain = 0.75 self.freqq = freqq = 2.412e6 self.freq = freq = 2412000000.0 self.device_6 = device_6 = "hackrf=26b468dc3540b58f" self.device_5 = device_5 = "hackrf=88869dc38686a1b" self.device_4 = device_4 = "hackrf=88869dc2930b41b" self.device_3 = device_3 = "hackrf=88869dc3347501b" self.device_2 = device_2 = "hackrf=88869dc3918701b" self.device_1 = device_1 = "hackrf=88869dc3397a01b" self.chan_est = chan_est = 0 self.bb = bb = 20 self.IF = IF = 30 ################################################## # Blocks ################################################## # Create the options list self._samp_rate_options = [ 2000000.0, 5000000.0, 10000000.0, 20000000.0 ] # Create the labels list self._samp_rate_labels = ['2MHz', '5 MHz', '10 MHz', '20 MHz'] # Create the combo box self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate: ")) self._samp_rate_combo_box = Qt.QComboBox() self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box) for _label in self._samp_rate_labels: self._samp_rate_combo_box.addItem(_label) self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod( self._samp_rate_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._samp_rate_options.index(i))) self._samp_rate_callback(self.samp_rate) self._samp_rate_combo_box.currentIndexChanged.connect( lambda i: self.set_samp_rate(self._samp_rate_options[i])) # Create the radio buttons self.top_layout.addWidget(self._samp_rate_tool_bar) self._rf_range = Range(0, 50, 1, 14, 200) self._rf_win = RangeWidget(self._rf_range, self.set_rf, 'rf', "counter_slider", int) self.top_layout.addWidget(self._rf_win) # Create the options list self._chan_est_options = [0, 1, 3, 2] # Create the labels list self._chan_est_labels = ['LS', 'LMS', 'STA', 'Linear Comb'] # Create the combo box # Create the radio buttons self._chan_est_group_box = Qt.QGroupBox('chan_est' + ": ") self._chan_est_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._chan_est_button_group = variable_chooser_button_group() self._chan_est_group_box.setLayout(self._chan_est_box) for i, _label in enumerate(self._chan_est_labels): radio_button = Qt.QRadioButton(_label) self._chan_est_box.addWidget(radio_button) self._chan_est_button_group.addButton(radio_button, i) self._chan_est_callback = lambda i: Qt.QMetaObject.invokeMethod( self._chan_est_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._chan_est_options.index(i))) self._chan_est_callback(self.chan_est) self._chan_est_button_group.buttonClicked[int].connect( lambda i: self.set_chan_est(self._chan_est_options[i])) self.top_layout.addWidget(self._chan_est_group_box) self._bb_range = Range(0, 70, 1, 20, 200) self._bb_win = RangeWidget(self._bb_range, self.set_bb, 'bb', "counter_slider", int) self.top_layout.addWidget(self._bb_win) self._IF_range = Range(0, 50, 1, 30, 200) self._IF_win = RangeWidget(self._IF_range, self.set_IF, 'IF', "counter_slider", int) self.top_layout.addWidget(self._IF_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 48 * 10, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_win) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + device_5) self.osmosdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t()) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(2.45e9, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(rf, 0) self.osmosdr_source_0.set_if_gain(IF, 0) self.osmosdr_source_0.set_bb_gain(bb, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) # Create the options list self._lo_offset_options = [0, 6000000.0, 11000000.0] # Create the labels list self._lo_offset_labels = ['0', '6000000.0', '11000000.0'] # Create the combo box self._lo_offset_tool_bar = Qt.QToolBar(self) self._lo_offset_tool_bar.addWidget(Qt.QLabel("lo_offset: ")) self._lo_offset_combo_box = Qt.QComboBox() self._lo_offset_tool_bar.addWidget(self._lo_offset_combo_box) for _label in self._lo_offset_labels: self._lo_offset_combo_box.addItem(_label) self._lo_offset_callback = lambda i: Qt.QMetaObject.invokeMethod( self._lo_offset_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._lo_offset_options.index(i))) self._lo_offset_callback(self.lo_offset) self._lo_offset_combo_box.currentIndexChanged.connect( lambda i: self.set_lo_offset(self._lo_offset_options[i])) # Create the radio buttons self.top_layout.addWidget(self._lo_offset_tool_bar) self.ieee802_11_sync_short_0 = ieee802_11.sync_short( 0.56, 2, False, False) self.ieee802_11_sync_long_0 = ieee802_11.sync_long( sync_length, True, False) self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(True, True) self.ieee802_11_frame_equalizer_0 = ieee802_11.frame_equalizer( chan_est, 2.45e9, samp_rate, False, False) self.ieee802_11_decode_mac_0 = ieee802_11.decode_mac(True, False) self._gain_range = Range(0, 1, 0.01, 0.75, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, 'gain', "counter_slider", float) self.top_layout.addWidget(self._gain_win) # Create the options list self._freqq_options = [2437000.0, 2462000.0, 2412000.0] # Create the labels list self._freqq_labels = ['ch6', 'ch11', 'ch1'] # Create the combo box self._freqq_tool_bar = Qt.QToolBar(self) self._freqq_tool_bar.addWidget(Qt.QLabel("freqq: ")) self._freqq_combo_box = Qt.QComboBox() self._freqq_tool_bar.addWidget(self._freqq_combo_box) for _label in self._freqq_labels: self._freqq_combo_box.addItem(_label) self._freqq_callback = lambda i: Qt.QMetaObject.invokeMethod( self._freqq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freqq_options.index(i))) self._freqq_callback(self.freqq) self._freqq_combo_box.currentIndexChanged.connect( lambda i: self.set_freqq(self._freqq_options[i])) # Create the radio buttons self.top_layout.addWidget(self._freqq_tool_bar) # Create the options list self._freq_options = [ 2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5250000000.0, 5260000000.0, 5270000000.0, 5280000000.0, 5290000000.0, 5300000000.0, 5310000000.0, 5320000000.0, 5500000000.0, 5510000000.0, 5520000000.0, 5530000000.0, 5540000000.0, 5550000000.0, 5560000000.0, 5570000000.0, 5580000000.0, 5590000000.0, 5600000000.0, 5610000000.0, 5620000000.0, 5630000000.0, 5640000000.0, 5660000000.0, 5670000000.0, 5680000000.0, 5690000000.0, 5700000000.0, 5710000000.0, 5720000000.0, 5745000000.0, 5755000000.0, 5765000000.0, 5775000000.0, 5785000000.0, 5795000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0 ] # Create the labels list self._freq_labels = [ ' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a', ' 52 | 5260.0 | 11a', ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5290.0 | 11a', ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a', ' 64 | 5320.0 | 11a', '100 | 5500.0 | 11a', '102 | 5510.0 | 11a', '104 | 5520.0 | 11a', '106 | 5530.0 | 11a', '108 | 5540.0 | 11a', '110 | 5550.0 | 11a', '112 | 5560.0 | 11a', '114 | 5570.0 | 11a', '116 | 5580.0 | 11a', '118 | 5590.0 | 11a', '120 | 5600.0 | 11a', '122 | 5610.0 | 11a', '124 | 5620.0 | 11a', '126 | 5630.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '134 | 5670.0 | 11a', '136 | 5680.0 | 11a', '138 | 5690.0 | 11a', '140 | 5700.0 | 11a', '142 | 5710.0 | 11a', '144 | 5720.0 | 11a', '149 | 5745.0 | 11a (SRD)', '151 | 5755.0 | 11a (SRD)', '153 | 5765.0 | 11a (SRD)', '155 | 5775.0 | 11a (SRD)', '157 | 5785.0 | 11a (SRD)', '159 | 5795.0 | 11a (SRD)', '161 | 5805.0 | 11a (SRD)', '165 | 5825.0 | 11a (SRD)', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p' ] # Create the combo box self._freq_tool_bar = Qt.QToolBar(self) self._freq_tool_bar.addWidget(Qt.QLabel("freq: ")) self._freq_combo_box = Qt.QComboBox() self._freq_tool_bar.addWidget(self._freq_combo_box) for _label in self._freq_labels: self._freq_combo_box.addItem(_label) self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod( self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i))) self._freq_callback(self.freq) self._freq_combo_box.currentIndexChanged.connect( lambda i: self.set_freq(self._freq_options[i])) # Create the radio buttons self.top_layout.addWidget(self._freq_tool_bar) self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False) self.fft_vxx_0 = fft.fft_vcc(64, True, window.rectangular(64), True, 1) self.correctiq_correctiq_0 = correctiq.correctiq() self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, 64) self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream( blocks.complex_t, 'packet_len') self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_moving_average_xx_1 = blocks.moving_average_cc( window_size, 1, 4000, 1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( window_size + 16, 1, 4000, 1) self.blocks_file_sink_2 = blocks.file_sink( gr.sizeof_gr_complex * 1, '/home/erc/SDN/symbols_5_1.bin', False) self.blocks_file_sink_2.set_unbuffered(True) self.blocks_file_sink_1_1 = blocks.file_sink( gr.sizeof_gr_complex * 64, '/home/erc/SDN/before_fft_5_1.bin', False) self.blocks_file_sink_1_1.set_unbuffered(True) self.blocks_file_sink_1_0 = blocks.file_sink( gr.sizeof_char * 48, '/home/erc/SDN/output_equ_5_1.bin', False) self.blocks_file_sink_1_0.set_unbuffered(True) self.blocks_file_sink_1 = blocks.file_sink( gr.sizeof_gr_complex * 64, '/home/erc/SDN/after_fft_5_1.bin', False) self.blocks_file_sink_1.set_unbuffered(True) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/erc/SDN/wifi_5_1.pcap', False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, 16) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, sync_length) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.msg_connect((self.ieee802_11_decode_mac_0, 'out'), (self.foo_wireshark_connector_0, 'in')) self.msg_connect((self.ieee802_11_decode_mac_0, 'out'), (self.ieee802_11_parse_mac_0, 'in')) self.msg_connect((self.ieee802_11_frame_equalizer_0, 'symbols'), (self.blocks_pdu_to_tagged_stream_1, 'pdus')) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.ieee802_11_sync_long_0, 1)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.ieee802_11_sync_short_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.ieee802_11_sync_short_0, 2)) self.connect((self.blocks_divide_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_moving_average_xx_1, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.blocks_moving_average_xx_1, 0), (self.ieee802_11_sync_short_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_moving_average_xx_1, 0)) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.blocks_file_sink_2, 0)) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_file_sink_1_1, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.correctiq_correctiq_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.correctiq_correctiq_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.correctiq_correctiq_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_file_sink_1, 0)) self.connect((self.fft_vxx_0, 0), (self.ieee802_11_frame_equalizer_0, 0)) self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.ieee802_11_frame_equalizer_0, 0), (self.blocks_file_sink_1_0, 0)) self.connect((self.ieee802_11_frame_equalizer_0, 0), (self.ieee802_11_decode_mac_0, 0)) self.connect((self.ieee802_11_sync_long_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.ieee802_11_sync_short_0, 0), (self.blocks_delay_0, 0)) self.connect((self.ieee802_11_sync_short_0, 0), (self.ieee802_11_sync_long_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.correctiq_correctiq_0, 0))
def __init__(self): gr.top_block.__init__(self, "IEEE 802.15.4 Transceiver using OQPSK PHY") Qt.QWidget.__init__(self) self.setWindowTitle("IEEE 802.15.4 Transceiver using OQPSK PHY") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "pure_sig") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.tx_gain = tx_gain = float(d_txdb) self.samp = samp = 4 self.rx_gain = rx_gain = float(d_rxdb) self.freq = freq = float(d_freq) self.buf = buf = 0x8000 self.bits = bits = 16 self.samp_rate = samp_rate = 4e6 ################################################## # Blocks ################################################## self._tx_gain_range = Range(-20, 64, 0.01, tx_gain, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, "tx_gain", "counter_slider", float) self.top_layout.addWidget(self._tx_gain_win) self._rx_gain_range = Range(0, 72, 0.01, rx_gain, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, "rx_gain", "counter_slider", float) self.top_layout.addWidget(self._rx_gain_win) self._freq_options = [2450000000, 915000000, 430000000] self._freq_labels = ['2.45GHz', '915MHz', '430MHz'] self._freq_tool_bar = Qt.QToolBar(self) self._freq_tool_bar.addWidget(Qt.QLabel('Channel' + ": ")) self._freq_combo_box = Qt.QComboBox() self._freq_tool_bar.addWidget(self._freq_combo_box) for label in self._freq_labels: self._freq_combo_box.addItem(label) self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod( self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i))) self._freq_callback(self.freq) self._freq_combo_box.currentIndexChanged.connect( lambda i: self.set_freq(self._freq_options[i])) self.top_layout.addWidget(self._freq_tool_bar) self._bits_range = Range(1, 127, 1, 16, 200) self._bits_win = RangeWidget(self._bits_range, self.set_bits, "bits", "counter_slider", int) self.top_layout.addWidget(self._bits_win) self.qtgui_time_sink_x_0_1_0 = qtgui.time_sink_f( buf * 16, #size samp_rate, #samp_rate "HSS OQPSK", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_1_0.set_update_time(0.10) self.qtgui_time_sink_x_0_1_0.set_y_axis(0, 2e-4) self.qtgui_time_sink_x_0_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_1_0.enable_tags(-1, False) self.qtgui_time_sink_x_0_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_1_0.enable_autoscale(True) self.qtgui_time_sink_x_0_1_0.enable_grid(False) self.qtgui_time_sink_x_0_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_1_0.enable_control_panel(False) self.qtgui_time_sink_x_0_1_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_1_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_1_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_1_0_win) self.pluto_source_0 = iio.pluto_source(d_rxid, int(freq), int(4e6), int(20000000), buf * 16, True, True, True, "manual", rx_gain, '', True) self.pluto_sink_0 = iio.pluto_sink(d_txid, int(freq), int(4e6), int(20000000), buf, True, tx_gain, '', True) self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack( ([129]), ([131]), ([132]), ([23, 42])) self.ieee802_15_4_phy_0 = ieee802_15_4_oqpsk_phy() if argv[7] == 'ook': self.ieee802_15_4_phy_0 = ieee802_15_4_ook_phy( threshold=float(argv[8])) if argv[7] == 'fsk': self.ieee802_15_4_phy_0 = ieee802_15_4_cpfsk_phy() self.ieee802_15_4_mac_0 = ieee802_15_4.mac(False, 0x8841, 0, 0x1aaa, 0xffff, 0x3344) self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False) self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", '', '52001', 10000, False) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1) self.blocks_message_strobe_0_0 = blocks.message_strobe( pmt.intern('a' * bits), 10) self.blocks_file_sink_1_0_0 = blocks.file_sink( gr.sizeof_float * 1, '/home/hrbenitez/Desktop/just_sig.bin', False) self.blocks_file_sink_1_0_0.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/hrbenitez/Desktop/2_pluto.pcap', False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'), (self.ieee802_15_4_rime_stack_0, 'bcin')) self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'), (self.ieee802_15_4_rime_stack_0, 'bcin')) self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.ieee802_15_4_phy_0, 'txin')) self.msg_connect((self.ieee802_15_4_mac_0, 'app out'), (self.ieee802_15_4_rime_stack_0, 'fromMAC')) self.msg_connect((self.ieee802_15_4_phy_0, 'rxout'), (self.foo_wireshark_connector_0, 'in')) self.msg_connect((self.ieee802_15_4_phy_0, 'rxout'), (self.ieee802_15_4_mac_0, 'pdu in')) self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'), (self.blocks_socket_pdu_0_0, 'pdus')) self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'), (self.ieee802_15_4_mac_0, 'app in')) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_file_sink_1_0_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.qtgui_time_sink_x_0_1_0, 0)) self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.ieee802_15_4_phy_0, 2), (self.blocks_null_sink_0, 1)) self.connect((self.ieee802_15_4_phy_0, 3), (self.blocks_null_sink_0, 2)) self.connect((self.ieee802_15_4_phy_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.ieee802_15_4_phy_0, 0), (self.pluto_sink_0, 0)) self.connect((self.pluto_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.pluto_source_0, 0), (self.ieee802_15_4_phy_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.uisigtype = uisigtype = 101 self.uiselect = uiselect = 0 self.uifreq = uifreq = 1000 self.samp_rate = samp_rate = 48000 ################################################## # Blocks ################################################## self._uisigtype_options = ( 101, 103, ) self._uisigtype_labels = ( 'Sine', 'Square', ) self._uisigtype_tool_bar = Qt.QToolBar(self) self._uisigtype_tool_bar.addWidget(Qt.QLabel("uisigtype" + ": ")) self._uisigtype_combo_box = Qt.QComboBox() self._uisigtype_tool_bar.addWidget(self._uisigtype_combo_box) for label in self._uisigtype_labels: self._uisigtype_combo_box.addItem(label) self._uisigtype_callback = lambda i: Qt.QMetaObject.invokeMethod( self._uisigtype_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._uisigtype_options.index(i))) self._uisigtype_callback(self.uisigtype) self._uisigtype_combo_box.currentIndexChanged.connect( lambda i: self.set_uisigtype(self._uisigtype_options[i])) self.top_grid_layout.addWidget(self._uisigtype_tool_bar, 0, 0, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 1)] self._uiselect_options = ( 0, 1, ) self._uiselect_labels = ( 'Sound card', 'Test signal', ) self._uiselect_tool_bar = Qt.QToolBar(self) self._uiselect_tool_bar.addWidget(Qt.QLabel('Select source' + ": ")) self._uiselect_combo_box = Qt.QComboBox() self._uiselect_tool_bar.addWidget(self._uiselect_combo_box) for label in self._uiselect_labels: self._uiselect_combo_box.addItem(label) self._uiselect_callback = lambda i: Qt.QMetaObject.invokeMethod( self._uiselect_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._uiselect_options.index(i))) self._uiselect_callback(self.uiselect) self._uiselect_combo_box.currentIndexChanged.connect( lambda i: self.set_uiselect(self._uiselect_options[i])) self.top_grid_layout.addWidget(self._uiselect_tool_bar, 0, 2, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(2, 3)] self._uifreq_range = Range(10, 100000, 10, 1000, 200) self._uifreq_win = RangeWidget(self._uifreq_range, self.set_uifreq, "uifreq", "counter_slider", float) self.top_grid_layout.addWidget(self._uifreq_win, 0, 1, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(1, 2)] self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(True) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 1, 0, 1, 3) [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 3)] self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=2, num_outputs=1, input_index=uiselect, output_index=0, ) self.audio_source_0 = audio.source(samp_rate, '', True) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, uisigtype, uifreq, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.audio_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blks2_selector_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blks2_selector_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blks2_selector_0, 1))
def initUI(self): # Add a first QwtPlot to the UI: #self.qplt_mag = Qwt.QwtPlot() self.qplt_mag = pg.PlotWidget() self.qplt_mag.setTitle('Magnitude response') #self.qplt_mag.setCanvasBackground(Qt.Qt.white) #self.qplt_mag.setAxisScaleEngine(Qwt.QwtPlot.xBottom, Qwt.QwtLog10ScaleEngine()) self.qplt_mag.getPlotItem().setLogMode(x=True) #print('DisplayTransferFunctionWindow: initUI(): first plot widget created') # plot_grid = Qwt.QwtPlotGrid() # plot_grid.setMajPen(Qt.QPen(Qt.Qt.black, 0, Qt.Qt.DotLine)) # plot_grid.attach(self.qplt_mag) self.qplt_mag.showGrid(x=True, y=True) self.colors_order = [ [0, 114, 189], [217, 83, 25], [237, 177, 32], [126, 47, 142], [119, 172, 48], [77, 190, 238], [162, 20, 47], ] # Add a second QwtPlot to the UI: self.qplt_phase = pg.PlotWidget() self.qplt_phase.setTitle('Phase response') #self.qplt_phase.setCanvasBackground(Qt.Qt.white) #self.qplt_phase.setAxisScaleEngine(Qwt.QwtPlot.xBottom, Qwt.QwtLog10ScaleEngine()) self.qplt_phase.getPlotItem().setLogMode(x=True) #print('DisplayTransferFunctionWindow: initUI(): 2nd plot widget created') # plot_grid = Qwt.QwtPlotGrid() # plot_grid.setMajPen(Qt.QPen(Qt.Qt.black, 0, Qt.Qt.DotLine)) # plot_grid.attach(self.qplt_phase) self.qplt_phase.showGrid(x=True, y=True) # create the lists to hold the curve objects as they get added to the plots: self.curve_mag_list = [] self.curve_phase_list = [] ###################################################################### # Controls to adjust the model ###################################################################### # Units select units_label = Qt.QLabel('Units:') self.qcombo_units = Qt.QComboBox() self.qcombo_units.addItems([ 'dB', 'Linear', 'real part', 'imag part', 'Ohms, 50*Vin/Vout', 'Ohms, shunt DUT, 50 ohms probe', 'Ohms, Shunt DUT, high-Z probe + Series source impedance' ]) self.qcombo_units.setCurrentIndex(0) # self.qcombo_units.changeEvent.connect(self.updateGraph) self.qcombo_units.currentIndexChanged.connect(self.updateGraph) self.qlabel_SeriesImpedance = Qt.QLabel('Series Impedance [Ohms]:') self.qedit_SeriesImpedance = Qt.QLineEdit('100e3') self.qedit_SeriesImpedance.editingFinished.connect(self.updateGraph) self.qchk_display_model = Qt.QCheckBox('Display model') self.qchk_display_model.setChecked(False) self.qchk_DDCFilter = Qt.QCheckBox('DDC sinc filter') self.qchk_DDCFilter.clicked.connect(self.updateGraph) self.qradio_signp = Qt.QRadioButton('+ Sign') self.qradio_signp.setChecked(True) self.qradio_signn = Qt.QRadioButton('- Sign') button_group = Qt.QButtonGroup() button_group.addButton(self.qradio_signp) button_group.addButton(self.qradio_signn) self.qradio_signp.clicked.connect(self.updateGraph) self.qradio_signn.clicked.connect(self.updateGraph) # set the default DC gain to the value of the transfer function at the lowest frequency: self.qlabel_k = Qt.QLabel('DC Gain [dB]') self.qedit_k = Qt.QLineEdit(str(0)) self.qedit_k.setMaximumWidth(60) self.qedit_k.textChanged.connect(self.updateGraph) self.qlabel_f1 = Qt.QLabel('1st order poles') self.qedit_f1 = Qt.QLineEdit('20e3,600e3') self.qedit_f1.setMaximumWidth(120) self.qedit_f1.textChanged.connect(self.updateGraph) self.qlabel_f0 = Qt.QLabel('2nd order poles') self.qedit_f0 = Qt.QLineEdit('1.5e6') self.qedit_f0.setMaximumWidth(120) self.qedit_f0.textChanged.connect(self.updateGraph) self.qlabel_zeta = Qt.QLabel('zeta') self.qedit_zeta = Qt.QLineEdit('0.1') self.qedit_zeta.setMaximumWidth(120) self.qedit_zeta.textChanged.connect(self.updateGraph) self.qlabel_T = Qt.QLabel('Pure delay') self.qedit_T = Qt.QLineEdit('570e-9') self.qedit_T.setMaximumWidth(60) self.qedit_T.textChanged.connect(self.updateGraph) self.qchk_controller = Qt.QCheckBox('Closed-loop prediction') self.qchk_controller.clicked.connect(self.updateGraph) self.qlabel_pgain = Qt.QLabel('P gain [dB]') self.qedit_pgain = Qt.QLineEdit('-100') self.qedit_pgain.setMaximumWidth(60) self.qedit_pgain.textChanged.connect(self.updateGraph) self.qlabel_icorner = Qt.QLabel('I corner [Hz]') self.qedit_icorner = Qt.QLineEdit('0') self.qedit_icorner.setMaximumWidth(60) self.qedit_icorner.textChanged.connect(self.updateGraph) self.qedit_comment = Qt.QTextEdit('') # self.qedit_comment.setMaximumWidth(80) #self.qedit_comment.textChanged.connect(self.updateGraph) # Put all the widgets into a grid layout grid = Qt.QGridLayout() grid.addWidget(units_label, 0, 0) grid.addWidget(self.qcombo_units, 0, 1) grid.addWidget(self.qlabel_SeriesImpedance, 1, 0) grid.addWidget(self.qedit_SeriesImpedance, 1, 1) # grid.addWidget(self.qchk_display_model , 2, 1) # grid.addWidget(self.qradio_signp , 3, 0) # grid.addWidget(self.qradio_signn , 3, 1) # grid.addWidget(self.qlabel_k , 4, 0) # grid.addWidget(self.qedit_k , 4, 1) # grid.addWidget(self.qlabel_f1 , 5, 0) # grid.addWidget(self.qedit_f1 , 5, 1) # grid.addWidget(self.qlabel_f0 , 6, 0) # grid.addWidget(self.qedit_f0 , 6, 1) # grid.addWidget(self.qlabel_zeta , 7, 0) # grid.addWidget(self.qedit_zeta , 7, 1) # grid.addWidget(self.qlabel_T , 8, 0) # grid.addWidget(self.qedit_T , 8, 1) # grid.addWidget(self.qchk_controller , 9, 0, 1, 2) # grid.addWidget(self.qlabel_pgain , 10, 0) # grid.addWidget(self.qedit_pgain , 10, 1) # grid.addWidget(self.qlabel_icorner , 12, 0) # grid.addWidget(self.qedit_icorner , 12, 1) # grid.addWidget(self.qchk_DDCFilter , 13, 0, 1, 2) grid.addWidget(self.qedit_comment, 14, 0, 1, 2) grid.setRowStretch(15, 0) # grid.addWidget(Qt.QLabel(''), 12, 0, 1, 2) # grid.setRowStretch(14, 1) vbox = Qt.QVBoxLayout() vbox.addWidget(self.qplt_mag) vbox.addWidget(self.qplt_phase) hbox = Qt.QHBoxLayout() hbox.addLayout(grid) hbox.addLayout(vbox, 1) # hbox.setStretch(2, 1) self.setLayout(hbox) # Adjust the size and position of the window self.resize(1200, 500) self.center() self.setWindowTitle('Transfer function #%d' % self.window_number) self.show()
def __init__(self, plugin, gui, icon): Qt.QDialog.__init__(self, gui) self.plugin = plugin self.gui = gui self.full_db = gui.current_db self.db = gui.current_db.new_api self.setWindowTitle(TITLE) self.setWindowIcon(icon) self.setWindowFlags(QtCore.Window | QtCore.WindowTitleHint | QtCore.CustomizeWindowHint) self.layout = Qt.QVBoxLayout() self.setLayout(self.layout) self.search_label = Qt.QLabel('Enter text to search in content') self.layout.addWidget(self.search_label) self.search_text_layout = Qt.QHBoxLayout() self.search_textbox = Qt.QComboBox(self) self.search_textbox.setMinimumWidth(400) self.search_textbox.setEditable(True) self.search_textbox.setInsertPolicy(Qt.QComboBox.NoInsert) for _, value in sorted(prefs.get('search_lru', {}).items()): self.search_textbox.addItem(value) self.search_textbox.setEditText('') self.search_textbox.editTextChanged.connect( self.on_search_text_changed) self.search_label.setBuddy(self.search_textbox) self.search_text_layout.addWidget(self.search_textbox) self.search_help_button = Qt.QPushButton('?', self) fixed_size_policy = self.search_help_button.sizePolicy() fixed_size_policy.setHorizontalPolicy(QtWidgets.QSizePolicy.Fixed) self.search_help_button.setSizePolicy(fixed_size_policy) self.search_help_button.clicked.connect(self.on_search_help) self.search_text_layout.addWidget(self.search_help_button) self.layout.addLayout(self.search_text_layout) self.search_button = Qt.QPushButton('&Search', self) self.search_button.setEnabled(False) self.search_button.setDefault(True) self.search_button.clicked.connect(self.on_search) self.layout.addWidget(self.search_button) self.cancel_button = Qt.QPushButton('&Cancel', self) self.cancel_button.clicked.connect(self.on_cancel) self.cancel_button.setVisible(False) self.layout.addWidget(self.cancel_button) self.status_label = Qt.QLabel() self.status_label.setAlignment(QtCore.AlignCenter) self.layout.addWidget(self.status_label) self.progress_bar = Qt.QProgressBar(self) self.progress_bar.setVisible(False) retain_size_policy = self.progress_bar.sizePolicy() retain_size_policy.setRetainSizeWhenHidden(True) self.progress_bar.setSizePolicy(retain_size_policy) self.layout.addWidget(self.progress_bar) self.details_button = Qt.QPushButton('&Details', self) self.details_button.setVisible(False) retain_size_policy = self.details_button.sizePolicy() retain_size_policy.setRetainSizeWhenHidden(True) self.details_button.setSizePolicy(retain_size_policy) self.details_button.setFlat(True) self.details_button.setStyleSheet('text-align: left') icon = get_icons('images/right-arrow.png') self.details_button.setIcon(icon) self.details_button.clicked.connect(self.on_details) self.layout.addWidget(self.details_button) self.details = Qt.QListWidget(self) self.details.setVisible(False) self.layout.addWidget(self.details) self.layout.addStretch() self.reindex_layout = Qt.QHBoxLayout() self.reindex_button = Qt.QPushButton('&Reindex new books', self) self.reindex_button.clicked.connect(self.on_reindex) self.reindex_layout.addWidget(self.reindex_button) self.reindex_all_button = Qt.QPushButton('&Reindex all books', self) self.reindex_all_button.clicked.connect(self.on_reindex_all) self.reindex_layout.addWidget(self.reindex_all_button) self.layout.addLayout(self.reindex_layout) self.conf_button = Qt.QPushButton('&Options...', self) self.conf_button.clicked.connect(self.on_config) self.layout.addWidget(self.conf_button) self.readme_button = Qt.QPushButton('&Readme...', self) self.readme_button.clicked.connect(self.on_readme) self.layout.addWidget(self.readme_button) self.close_button = Qt.QPushButton('&Close', self) self.close_button.clicked.connect(self.close) self.layout.addWidget(self.close_button) self.thread_pool = Qt.QThreadPool() self.add_workers_submitted = 0 self.add_workers_complete = 0 self.delete_workers_submitted = 0 self.delete_workers_complete = 0 self.first_paint = True self.pdftotext_full_path = None if 'version' not in prefs: file_formats = set(prefs['file_formats'].split(',') + ARCHIVE_FORMATS) prefs['file_formats'] = ','.join(file_formats) prefs['version'] = CapsPlugin.version
def __init__(self): gr.top_block.__init__(self, "Play sigMF recordings") Qt.QWidget.__init__(self) self.setWindowTitle("Play sigMF recordings") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "file_play") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 self.gain = gain = 0 self.freq = freq = 433.7e6 self.antenna = antenna = "TX/RX" ################################################## # Blocks ################################################## self._gain_range = Range(0, 60, 1, 0, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, 'Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._gain_win) self._freq_range = Range(400e6, 6e9, 100e3, 433.7e6, 200) self._freq_win = RangeWidget(self._freq_range, self.set_freq, 'Freq', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_win) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", args='', channels=list(range(0,1)), ), '', ) self.uhd_usrp_sink_0.set_center_freq(freq, 0) self.uhd_usrp_sink_0.set_gain(gain, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.uhd_usrp_sink_0.set_bandwidth(samp_rate, 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_time_unknown_pps(uhd.time_spec()) self.fosphor_qt_sink_c_0_0 = fosphor.qt_sink_c() self.fosphor_qt_sink_c_0_0.set_fft_window(window.WIN_BLACKMAN_hARRIS) self.fosphor_qt_sink_c_0_0.set_frequency_range(freq, samp_rate) self._fosphor_qt_sink_c_0_0_win = sip.wrapinstance(self.fosphor_qt_sink_c_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._fosphor_qt_sink_c_0_0_win) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_file_source_1 = blocks.file_source(gr.sizeof_gr_complex*1, '/home/david/sigMF_ML/RF_SVD/ptt_2_10_svd_1024_fft/ptt_svd5_1024_fft', True, 0, 0) self.blocks_file_source_1.set_begin_tag(pmt.PMT_NIL) # Create the options list self._antenna_options = ("TX/RX", "RX2", ) # Create the labels list self._antenna_labels = ("TX/RX", "RX2", ) # Create the combo box self._antenna_tool_bar = Qt.QToolBar(self) self._antenna_tool_bar.addWidget(Qt.QLabel('Antenna' + ": ")) self._antenna_combo_box = Qt.QComboBox() self._antenna_tool_bar.addWidget(self._antenna_combo_box) for _label in self._antenna_labels: self._antenna_combo_box.addItem(_label) self._antenna_callback = lambda i: Qt.QMetaObject.invokeMethod(self._antenna_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._antenna_options.index(i))) self._antenna_callback(self.antenna) self._antenna_combo_box.currentIndexChanged.connect( lambda i: self.set_antenna(self._antenna_options[i])) # Create the radio buttons self.top_grid_layout.addWidget(self._antenna_tool_bar) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_1, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_file_source_1, 0), (self.fosphor_qt_sink_c_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.uhd_usrp_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.volume = volume = 25 self.samp_rate = samp_rate = 2e6 self.freq = freq = 98.5e6 self.filter_cutoff = filter_cutoff = 100e3 self.down_rate = down_rate = 250e3 ################################################## # Blocks ################################################## self._freq_options = ( 98.5e6, 462.7e6, ) self._freq_labels = ( 'Radio', 'FRS', ) self._freq_tool_bar = Qt.QToolBar(self) self._freq_tool_bar.addWidget(Qt.QLabel('Frequency' + ": ")) self._freq_combo_box = Qt.QComboBox() self._freq_tool_bar.addWidget(self._freq_combo_box) for label in self._freq_labels: self._freq_combo_box.addItem(label) self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod( self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i))) self._freq_callback(self.freq) self._freq_combo_box.currentIndexChanged.connect( lambda i: self.set_freq(self._freq_options[i])) self.top_layout.addWidget(self._freq_tool_bar) self._filter_cutoff_range = Range(1e3, 200e3, 1, 100e3, 200) self._filter_cutoff_win = RangeWidget(self._filter_cutoff_range, self.set_filter_cutoff, 'Filter Cutoff Freq', "counter_slider", float) self.top_layout.addWidget(self._filter_cutoff_win) self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(70, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_2 = filter.rational_resampler_fff( interpolation=24, decimation=240, taps=None, fractional_bw=None, ) self.low_pass_filter_0 = filter.fir_filter_ccf( int(samp_rate / down_rate), firdes.low_pass(2, samp_rate, filter_cutoff, 10e3, firdes.WIN_KAISER, 6.76)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.25, )) self.audio_sink_0 = audio.sink(24000, '', True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=down_rate, audio_decimation=1, ) ################################################## # Connections ################################################## self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.rational_resampler_xxx_2, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0))
def initUI(self): ################################################################################### self.qgroupbox_clkselect = Qt.QGroupBox('Clock source') self.qgroupbox_clkselect.setAutoFillBackground(True) grid = Qt.QGridLayout() self.qradio_internal_clk = Qt.QRadioButton('Internal clock') self.qradio_external_clk = Qt.QRadioButton('External clock') self.qradio_internal_clk.setChecked(True) self.qradio_internal_clk.clicked.connect(self.setClkSelect) self.qradio_external_clk.clicked.connect(self.setClkSelect) self.lblExtClkFreq = Qt.QLabel('Ext clk freq = %.6f MHz' % 0.0) grid.addWidget(self.qradio_internal_clk, 0, 0) grid.addWidget(self.qradio_external_clk, 1, 0) grid.addWidget(self.lblExtClkFreq, 2, 0) #grid.setRowStretch(2, 2) self.qgroupbox_clkselect.setLayout(grid) ################################################################################### self.qgroupbox_xadc = Qt.QGroupBox('XADC inputs') self.qgroupbox_xadc.setAutoFillBackground(True) grid = Qt.QGridLayout() self.time_start = time.perf_counter() self.qplots = DataLoggingDisplayWidget.DataLoggingDisplayWidget( numPlots=1, numCurvesPerPlot=1) self.qplots.pltItemsList[0].setLabel('left', 'Temp [degC]') # self.qplots.show() self.qlbl_Temp = Qt.QLabel('Zynq temperature: %.2f degC' % 0.) self.qlbl_vccint = Qt.QLabel('Vccint = %.2f V' % 0.) self.qlbl_vccaux = Qt.QLabel('Vccaux = %.2f V' % 0.) self.qbtn_OpenTempGraph = Qt.QPushButton( 'Open temperature display window') self.qbtn_OpenTempGraph.clicked.connect(self.qplots.show) grid.addWidget(self.qlbl_Temp, 0, 0, 1, 2) grid.addWidget(self.qlbl_vccint, 1, 0) grid.addWidget(self.qlbl_vccaux, 2, 0) grid.addWidget(self.qbtn_OpenTempGraph, 2, 1) #grid.setRowStretch(2, 2) self.qgroupbox_xadc.setLayout(grid) # polling timer for the xadc values: self.timerXADC = Qt.QTimer(self) self.timerXADC.timeout.connect(self.timerXADCEvent) ################################################################################### self.qgroupbox_MUX_vco = Qt.QGroupBox('Select VCO connection') self.qgroupbox_MUX_vco.setAutoFillBackground(True) MUX_vco = Qt.QGridLayout() self.qradio_VCO_to_DAC0 = Qt.QRadioButton('VCO connected to DAC A') self.qradio_VCO_to_DAC1 = Qt.QRadioButton('VCO connected to DAC B') self.qradio_no_VCO = Qt.QRadioButton('VCO not connected') self.qradio_no_VCO.setChecked(True) self.qradio_VCO_to_DAC0.clicked.connect(self.mux_vco_Action) self.qradio_VCO_to_DAC1.clicked.connect(self.mux_vco_Action) self.qradio_no_VCO.clicked.connect(self.mux_vco_Action) self.qlabel_int_vco_amplitude = Qt.QLabel( 'Internal VCO Amplitude [0-1]') self.qedit_int_vco_amplitude = user_friendly_QLineEdit('0.5') self.qedit_int_vco_amplitude.returnPressed.connect( self.setInternalVCO_amplitude) self.qedit_int_vco_amplitude.setMaximumWidth(100) self.qlabel_int_vco_offset = Qt.QLabel('Internal VCO offset [0-1]') self.qedit_int_vco_offset = user_friendly_QLineEdit('0.0') self.qedit_int_vco_offset.returnPressed.connect( self.setInternalVCO_offset) self.qedit_int_vco_offset.setMaximumWidth(60) MUX_vco.addWidget(self.qradio_VCO_to_DAC0, 0, 0) MUX_vco.addWidget(self.qradio_VCO_to_DAC1, 1, 0) MUX_vco.addWidget(self.qradio_no_VCO, 2, 0) MUX_vco.addWidget(self.qlabel_int_vco_offset, 1, 1) MUX_vco.addWidget(self.qedit_int_vco_offset, 1, 2) MUX_vco.addWidget(self.qlabel_int_vco_amplitude, 2, 1) MUX_vco.addWidget(self.qedit_int_vco_amplitude, 2, 2) MUX_vco.addItem( Qt.QSpacerItem(0, 0, Qt.QSizePolicy.MinimumExpanding, Qt.QSizePolicy.Minimum), 2, 0) MUX_vco.setRowStretch(2, 2) self.qgroupbox_MUX_vco.setLayout(MUX_vco) ################################################################################### self.qgroupbox_MUX_pll2 = Qt.QGroupBox('Select connection to PLL 2') self.qgroupbox_MUX_pll2.setAutoFillBackground(True) MUX_pll2 = Qt.QGridLayout() self.qradio_ddc1_to_pll2 = Qt.QRadioButton( 'DDC_a output to PLL_b input') self.qradio_pll1_to_pll2 = Qt.QRadioButton( 'DAC_a output to PLL_b input (cascade lock)') self.qradio_ddc2_to_pll2 = Qt.QRadioButton( 'DDC_b output to PLL_b input') self.qradio_ddc2_to_pll2.setChecked(True) self.qradio_pll1_to_pll2.clicked.connect(self.mux_pll2_Action) self.qradio_ddc1_to_pll2.clicked.connect(self.mux_pll2_Action) self.qradio_ddc2_to_pll2.clicked.connect(self.mux_pll2_Action) MUX_pll2.addWidget(self.qradio_ddc1_to_pll2, 0, 0) MUX_pll2.addWidget(self.qradio_pll1_to_pll2, 1, 0) MUX_pll2.addWidget(self.qradio_ddc2_to_pll2, 2, 0) MUX_pll2.setRowStretch(2, 0) self.qgroupbox_MUX_pll2.setLayout(MUX_pll2) ################################################################################### self.qgroupbox_read_data = Qt.QGroupBox( 'Read data from dpll (channel 2)') self.qgroupbox_read_data.setAutoFillBackground(True) read_data = Qt.QGridLayout() self.qlabel_addr = Qt.QLabel('Address: 0x') self.qedit_addr = user_friendly_QLineEdit('9000') self.qedit_addr.setMaximumWidth(100) self.qlabel_data = Qt.QLabel('Data:') self.qedit_data = user_friendly_QLineEdit('0') self.qedit_data.setMaximumWidth(300) self.qbtn_1 = QtGui.QPushButton('Read data') self.qbtn_1.clicked.connect(self.read_RP) read_data.addWidget(self.qlabel_addr, 0, 0) read_data.addWidget(self.qedit_addr, 0, 1) read_data.addWidget(self.qlabel_data, 1, 0) read_data.addWidget(self.qedit_data, 1, 1, 1, 2) read_data.addWidget(self.qbtn_1, 0, 2) read_data.setRowStretch(1, 2) self.qgroupbox_read_data.setLayout(read_data) ################################################################################### self.qgroupbox_fanUI = Qt.QGroupBox('Turn fan on/off') self.qgroupbox_fanUI.setAutoFillBackground(True) fanUI = Qt.QGridLayout() self.qradio_fan_on = Qt.QRadioButton('Fan on') self.qradio_fan_off = Qt.QRadioButton('Fan off') self.qradio_fan_on.setChecked(True) self.qradio_fan_on.clicked.connect(self.setFan) self.qradio_fan_off.clicked.connect(self.setFan) fanUI.addWidget(self.qradio_fan_on, 0, 0) fanUI.addWidget(self.qradio_fan_off, 1, 0) #fanUI.setRowStretch(2, 2) self.qgroupbox_fanUI.setLayout(fanUI) ################################################################################### self.qbtn_reconnect = QtGui.QPushButton('Open communication menu') self.qbtn_reconnect.clicked.connect(self.communication_menu) ################################################################################### SATA = Qt.QGridLayout() self.qgroupbox_SATA = Qt.QGroupBox('Configure serial receiver (SATA)') self.qgroupbox_SATA.setAutoFillBackground(True) self.qlabel_SATA = Qt.QLabel('SATA mode:') self.qcombo_SATA = Qt.QComboBox() self.qcombo_SATA.addItems(['Off', 'Fast+Slow control', 'Training']) self.qcombo_SATA.setCurrentIndex(0) self.qcombo_SATA.currentIndexChanged.connect(self.setSATA) SATA.addWidget(self.qlabel_SATA, 2, 1) SATA.addWidget(self.qcombo_SATA, 2, 2) #SATA.addItem(Qt.QSpacerItem(0, 0, Qt.QSizePolicy.MinimumExpanding, Qt.QSizePolicy.Minimum), 3, 0) #SATA.setRowStretch(3, 2) self.qgroupbox_SATA.setLayout(SATA) ################################################################################### self.group = Qt.QGroupBox('RP configuration') self.group.setAutoFillBackground(True) group = Qt.QGridLayout() group.addWidget(self.qgroupbox_clkselect, 0, 0, 1, 1) group.addWidget(self.qgroupbox_xadc, 0, 1, 1, 2) group.addWidget(self.qgroupbox_MUX_vco, 1, 0, 1, 3) group.addWidget(self.qgroupbox_MUX_pll2, 2, 0, 1, 3) group.addWidget(self.qgroupbox_read_data, 3, 0, 1, 3) group.addWidget(self.qgroupbox_fanUI, 4, 0, 1, 1) group.addWidget(self.qbtn_reconnect, 4, 1, 1, 1) group.addWidget(self.qgroupbox_SATA, 4, 2, 1, 1) #vbox = Qt.QVBoxLayout() #vbox.addStretch(1) self.group.setLayout(group) grid = Qt.QGridLayout() grid.addWidget(self.group) self.setLayout(grid) #self.center() self.setWindowTitle(self.custom_shorthand + ': RP Configuration')
def __init__(self): gr.top_block.__init__(self, "Wifi Rx") Qt.QWidget.__init__(self) self.setWindowTitle("Wifi Rx") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "wifi_rx") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.window_size = window_size = 48 self.sync_length = sync_length = 320 self.samp_rate = samp_rate = 10e6 self.lo_offset = lo_offset = 0 self.gain = gain = 0.75 self.freq = freq = int(sys.argv[1]) * 10e5 self.chan_est = chan_est = 0 ################################################## # Blocks ################################################## self._samp_rate_options = [5e6, 10e6, 20e6] self._samp_rate_labels = ["5 MHz", "10 MHz", "20 MHz"] self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate"+": ")) self._samp_rate_combo_box = Qt.QComboBox() self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box) for label in self._samp_rate_labels: self._samp_rate_combo_box.addItem(label) self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._samp_rate_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._samp_rate_options.index(i))) self._samp_rate_callback(self.samp_rate) self._samp_rate_combo_box.currentIndexChanged.connect( lambda i: self.set_samp_rate(self._samp_rate_options[i])) self.top_layout.addWidget(self._samp_rate_tool_bar) self._freq_options = [2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5250000000.0, 5260000000.0, 5270000000.0, 5280000000.0, 5290000000.0, 5300000000.0, 5310000000.0, 5320000000.0, 5500000000.0, 5510000000.0, 5520000000.0, 5530000000.0, 5540000000.0, 5550000000.0, 5560000000.0, 5570000000.0, 5580000000.0, 5590000000.0, 5600000000.0, 5610000000.0, 5620000000.0, 5630000000.0, 5640000000.0, 5660000000.0, 5670000000.0, 5680000000.0, 5690000000.0, 5700000000.0, 5710000000.0, 5720000000.0, 5745000000.0, 5755000000.0, 5765000000.0, 5775000000.0, 5785000000.0, 5795000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0] self._freq_labels = [' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a', ' 52 | 5260.0 | 11a', ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5290.0 | 11a', ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a', ' 64 | 5320.0 | 11a', '100 | 5500.0 | 11a', '102 | 5510.0 | 11a', '104 | 5520.0 | 11a', '106 | 5530.0 | 11a', '108 | 5540.0 | 11a', '110 | 5550.0 | 11a', '112 | 5560.0 | 11a', '114 | 5570.0 | 11a', '116 | 5580.0 | 11a', '118 | 5590.0 | 11a', '120 | 5600.0 | 11a', '122 | 5610.0 | 11a', '124 | 5620.0 | 11a', '126 | 5630.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '134 | 5670.0 | 11a', '136 | 5680.0 | 11a', '138 | 5690.0 | 11a', '140 | 5700.0 | 11a', '142 | 5710.0 | 11a', '144 | 5720.0 | 11a', '149 | 5745.0 | 11a (SRD)', '151 | 5755.0 | 11a (SRD)', '153 | 5765.0 | 11a (SRD)', '155 | 5775.0 | 11a (SRD)', '157 | 5785.0 | 11a (SRD)', '159 | 5795.0 | 11a (SRD)', '161 | 5805.0 | 11a (SRD)', '165 | 5825.0 | 11a (SRD)', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'] self._freq_tool_bar = Qt.QToolBar(self) self._freq_tool_bar.addWidget(Qt.QLabel("freq"+": ")) self._freq_combo_box = Qt.QComboBox() self._freq_tool_bar.addWidget(self._freq_combo_box) for label in self._freq_labels: self._freq_combo_box.addItem(label) self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i))) self._freq_callback(self.freq) self._freq_combo_box.currentIndexChanged.connect( lambda i: self.set_freq(self._freq_options[i])) self.top_layout.addWidget(self._freq_tool_bar) self._chan_est_options = [ieee802_11.LS, ieee802_11.LMS, ieee802_11.STA, ieee802_11.COMB] self._chan_est_labels = ["LS", "LMS", "STA", "Linear Comb"] self._chan_est_group_box = Qt.QGroupBox("chan_est") self._chan_est_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._chan_est_button_group = variable_chooser_button_group() self._chan_est_group_box.setLayout(self._chan_est_box) for i, label in enumerate(self._chan_est_labels): radio_button = Qt.QRadioButton(label) self._chan_est_box.addWidget(radio_button) self._chan_est_button_group.addButton(radio_button, i) self._chan_est_callback = lambda i: Qt.QMetaObject.invokeMethod(self._chan_est_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._chan_est_options.index(i))) self._chan_est_callback(self.chan_est) self._chan_est_button_group.buttonClicked[int].connect( lambda i: self.set_chan_est(self._chan_est_options[i])) self.top_layout.addWidget(self._chan_est_group_box) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(10, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 48*10, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_win) self._lo_offset_options = (0, 6e6, 11e6, ) self._lo_offset_labels = (str(self._lo_offset_options[0]), str(self._lo_offset_options[1]), str(self._lo_offset_options[2]), ) self._lo_offset_tool_bar = Qt.QToolBar(self) self._lo_offset_tool_bar.addWidget(Qt.QLabel("lo_offset"+": ")) self._lo_offset_combo_box = Qt.QComboBox() self._lo_offset_tool_bar.addWidget(self._lo_offset_combo_box) for label in self._lo_offset_labels: self._lo_offset_combo_box.addItem(label) self._lo_offset_callback = lambda i: Qt.QMetaObject.invokeMethod(self._lo_offset_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._lo_offset_options.index(i))) self._lo_offset_callback(self.lo_offset) self._lo_offset_combo_box.currentIndexChanged.connect( lambda i: self.set_lo_offset(self._lo_offset_options[i])) self.top_layout.addWidget(self._lo_offset_tool_bar) self.ieee802_11_sync_short_0 = ieee802_11.sync_short(0.56, 2, False, False) self.ieee802_11_sync_long_0 = ieee802_11.sync_long(sync_length, True, False) self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(True, True) self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff(window_size + 16) self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc(window_size) self.ieee802_11_frame_equalizer_0 = ieee802_11.frame_equalizer(chan_est, freq, samp_rate, False, False) self.ieee802_11_decode_mac_0 = ieee802_11.decode_mac(True, False) self._gain_range = Range(0, 1, 0.01, 0.75, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "counter_slider", float) self.top_layout.addWidget(self._gain_win) self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True, 1) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 64) self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream(blocks.complex_t, 'packet_len') self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex*1, 16) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, sync_length) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.msg_connect((self.ieee802_11_decode_mac_0, 'out'), (self.ieee802_11_parse_mac_0, 'in')) self.msg_connect((self.ieee802_11_frame_equalizer_0, 'symbols'), (self.blocks_pdu_to_tagged_stream_1, 'pdus')) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.ieee802_11_moving_average_xx_1, 0)) self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.ieee802_11_sync_long_0, 1)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.ieee802_11_sync_short_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.ieee802_11_sync_short_0, 2)) self.connect((self.blocks_divide_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.ieee802_11_moving_average_xx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.fft_vxx_0, 0), (self.ieee802_11_frame_equalizer_0, 0)) self.connect((self.ieee802_11_frame_equalizer_0, 0), (self.ieee802_11_decode_mac_0, 0)) self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.ieee802_11_sync_short_0, 1)) self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.ieee802_11_sync_long_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.ieee802_11_sync_short_0, 0), (self.blocks_delay_0, 0)) self.connect((self.ieee802_11_sync_short_0, 0), (self.ieee802_11_sync_long_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_multiply_xx_0, 0))
def register_gui(form, on_change, view): # Rebin by uniform factor options _, factor = add_property_to_form('Factor', 'float', 0.5, (0.0, 1.0), on_change=on_change) factor.setSingleStep(0.05) # Rebin to target shape options shape_range = (0, 9999) _, shape_x = add_property_to_form('X', Type.INT, valid_values=shape_range, on_change=on_change) _, shape_y = add_property_to_form('Y', Type.INT, valid_values=shape_range, on_change=on_change) from PyQt5 import Qt shape_fields = Qt.QHBoxLayout() shape_fields.addWidget(shape_x) shape_fields.addWidget(shape_y) # Rebin dimension selection options rebin_by_factor_radio = Qt.QRadioButton("Rebin by Factor") def size_by_factor_toggled(enabled): factor.setEnabled(enabled) on_change() rebin_by_factor_radio.toggled.connect(size_by_factor_toggled) rebin_to_dimensions_radio = Qt.QRadioButton("Rebin to Dimensions") def size_by_dimensions_toggled(enabled): shape_x.setEnabled(enabled) shape_y.setEnabled(enabled) on_change() rebin_to_dimensions_radio.toggled.connect(size_by_dimensions_toggled) # Rebin mode options label_mode = Qt.QLabel("Mode") mode_field = Qt.QComboBox() mode_field.addItems(modes()) form.addRow(rebin_to_dimensions_radio, shape_fields) form.addRow(rebin_by_factor_radio, factor) form.addRow(label_mode, mode_field) # Ensure good default UI state rebin_to_dimensions_radio.setChecked(True) rebin_by_factor_radio.setChecked(True) return { "rebin_to_dimensions_radio": rebin_to_dimensions_radio, "shape_x": shape_x, "shape_y": shape_y, "rebin_by_factor_radio": rebin_by_factor_radio, "factor": factor, "mode_field": mode_field, }
def __init__(self): gr.top_block.__init__(self, "Hf Spectrum Simple Fosphor") Qt.QWidget.__init__(self) self.setWindowTitle("Hf Spectrum Simple Fosphor") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "hf_spectrum_simple_fosphor") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.ts_str = ts_str = dt.strftime(dt.utcnow(), "%Y-%m-%dT%H:%M:%S.%fZ") self.y_min = y_min = -140 self.y_max = y_max = -60 self.variable_qtgui_label_0 = variable_qtgui_label_0 = ts_str self.samp_rate = samp_rate = 500e3 self.rx_freq = rx_freq = 10e6 self.decim = decim = 1 self.decay_rate = decay_rate = 20e-3 self.ahfd_ant = ahfd_ant = 'A' ################################################## # Blocks ################################################## self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel('SAMP_RATE' + ": ")) self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate)) self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit) self._samp_rate_line_edit.returnPressed.connect( lambda: self.set_samp_rate( eng_notation.str_to_num(str(self._samp_rate_line_edit.text())) )) self.top_grid_layout.addWidget(self._samp_rate_tool_bar, 8, 0, 1, 1) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._rx_freq_tool_bar = Qt.QToolBar(self) self._rx_freq_tool_bar.addWidget(Qt.QLabel('FREQ' + ": ")) self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq)) self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit) self._rx_freq_line_edit.returnPressed.connect(lambda: self.set_rx_freq( eng_notation.str_to_num(str(self._rx_freq_line_edit.text())))) self.top_grid_layout.addWidget(self._rx_freq_tool_bar, 8, 1, 1, 1) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) # Create the options list self._ahfd_ant_options = ( 'A', 'B', ) # Create the labels list self._ahfd_ant_labels = ( 'N/S', 'E/W', ) # Create the combo box self._ahfd_ant_tool_bar = Qt.QToolBar(self) self._ahfd_ant_tool_bar.addWidget(Qt.QLabel('AHFD Ant' + ": ")) self._ahfd_ant_combo_box = Qt.QComboBox() self._ahfd_ant_tool_bar.addWidget(self._ahfd_ant_combo_box) for _label in self._ahfd_ant_labels: self._ahfd_ant_combo_box.addItem(_label) self._ahfd_ant_callback = lambda i: Qt.QMetaObject.invokeMethod( self._ahfd_ant_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._ahfd_ant_options.index(i))) self._ahfd_ant_callback(self.ahfd_ant) self._ahfd_ant_combo_box.currentIndexChanged.connect( lambda i: self.set_ahfd_ant(self._ahfd_ant_options[i])) # Create the radio buttons self.top_grid_layout.addWidget(self._ahfd_ant_tool_bar, 8, 3, 1, 1) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self._y_min_tool_bar = Qt.QToolBar(self) self._y_min_tool_bar.addWidget(Qt.QLabel('FREQ' + ": ")) self._y_min_line_edit = Qt.QLineEdit(str(self.y_min)) self._y_min_tool_bar.addWidget(self._y_min_line_edit) self._y_min_line_edit.returnPressed.connect(lambda: self.set_y_min( eng_notation.str_to_num(str(self._y_min_line_edit.text())))) self.top_grid_layout.addWidget(self._y_min_tool_bar, 8, 4, 1, 1) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 5): self.top_grid_layout.setColumnStretch(c, 1) self._y_max_tool_bar = Qt.QToolBar(self) self._y_max_tool_bar.addWidget(Qt.QLabel('FREQ' + ": ")) self._y_max_line_edit = Qt.QLineEdit(str(self.y_max)) self._y_max_tool_bar.addWidget(self._y_max_line_edit) self._y_max_line_edit.returnPressed.connect(lambda: self.set_y_max( eng_notation.str_to_num(str(self._y_max_line_edit.text())))) self.top_grid_layout.addWidget(self._y_max_tool_bar, 8, 5, 1, 1) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 6): self.top_grid_layout.setColumnStretch(c, 1) self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_formatter = None else: self._variable_qtgui_label_0_formatter = lambda x: str(x) self._variable_qtgui_label_0_tool_bar.addWidget( Qt.QLabel('Start Time [UTC]' + ": ")) self._variable_qtgui_label_0_label = Qt.QLabel( str( self._variable_qtgui_label_0_formatter( self.variable_qtgui_label_0))) self._variable_qtgui_label_0_tool_bar.addWidget( self._variable_qtgui_label_0_label) self.top_grid_layout.addWidget(self._variable_qtgui_label_0_tool_bar, 8, 6, 1, 2) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 8): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_source_1 = uhd.usrp_source( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", args='', channels=list(range(0, 2)), ), ) self.uhd_usrp_source_1.set_subdev_spec('A:AB B:AB', 0) self.uhd_usrp_source_1.set_time_source('gpsdo', 0) self.uhd_usrp_source_1.set_clock_source('gpsdo', 0) self.uhd_usrp_source_1.set_center_freq(uhd.tune_request(rx_freq), 0) self.uhd_usrp_source_1.set_gain(0, 0) self.uhd_usrp_source_1.set_antenna('A', 0) self.uhd_usrp_source_1.set_center_freq(uhd.tune_request(rx_freq), 1) self.uhd_usrp_source_1.set_gain(0, 1) self.uhd_usrp_source_1.set_antenna(ahfd_ant, 1) self.uhd_usrp_source_1.set_samp_rate(samp_rate) self.uhd_usrp_source_1.set_time_unknown_pps(uhd.time_spec()) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None) self.fosphor_qt_sink_c_0_0 = fosphor.qt_sink_c() self.fosphor_qt_sink_c_0_0.set_fft_window(firdes.WIN_BLACKMAN_hARRIS) self.fosphor_qt_sink_c_0_0.set_frequency_range(0, samp_rate) self._fosphor_qt_sink_c_0_0_win = sip.wrapinstance( self.fosphor_qt_sink_c_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._fosphor_qt_sink_c_0_0_win, 0, 4, 8, 4) for r in range(0, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.fosphor_qt_sink_c_0 = fosphor.qt_sink_c() self.fosphor_qt_sink_c_0.set_fft_window(firdes.WIN_BLACKMAN_hARRIS) self.fosphor_qt_sink_c_0.set_frequency_range(0, samp_rate) self._fosphor_qt_sink_c_0_win = sip.wrapinstance( self.fosphor_qt_sink_c_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._fosphor_qt_sink_c_0_win, 0, 0, 8, 4) for r in range(0, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) # Create the options list self._decay_rate_options = ( 100e-6, 65e-3, 20e-3, ) # Create the labels list self._decay_rate_labels = ( 'Fast', 'Medium', 'Slow', ) # Create the combo box # Create the radio buttons self._decay_rate_group_box = Qt.QGroupBox('decay_rate' + ": ") self._decay_rate_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._decay_rate_button_group = variable_chooser_button_group() self._decay_rate_group_box.setLayout(self._decay_rate_box) for i, _label in enumerate(self._decay_rate_labels): radio_button = Qt.QRadioButton(_label) self._decay_rate_box.addWidget(radio_button) self._decay_rate_button_group.addButton(radio_button, i) self._decay_rate_callback = lambda i: Qt.QMetaObject.invokeMethod( self._decay_rate_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._decay_rate_options.index(i))) self._decay_rate_callback(self.decay_rate) self._decay_rate_button_group.buttonClicked[int].connect( lambda i: self.set_decay_rate(self._decay_rate_options[i])) self.top_grid_layout.addWidget(self._decay_rate_group_box, 8, 2, 1, 1) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) ################################################## # Connections ################################################## self.connect((self.rational_resampler_xxx_0, 0), (self.fosphor_qt_sink_c_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.fosphor_qt_sink_c_0, 0)) self.connect((self.uhd_usrp_source_1, 1), (self.rational_resampler_xxx_0, 0)) self.connect((self.uhd_usrp_source_1, 0), (self.rational_resampler_xxx_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "NSF Watch for Events whille recording spectra") Qt.QWidget.__init__(self) self.setWindowTitle("NSF Watch for Events whille recording spectra") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "NsfWatch100") self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.ObsName = ObsName = "Integrate100" self.ConfigFile = ConfigFile = ObsName+".conf" self._Frequencys_config = ConfigParser.ConfigParser() self._Frequencys_config.read(ConfigFile) try: Frequencys = self._Frequencys_config.getfloat('main', 'Frequency') except: Frequencys = 1420.4e6 self.Frequencys = Frequencys self._Bandwidths_config = ConfigParser.ConfigParser() self._Bandwidths_config.read(ConfigFile) try: Bandwidths = self._Bandwidths_config.getfloat('main', 'Bandwidth') except: Bandwidths = 10.e6 self.Bandwidths = Bandwidths self._telescope_save_config = ConfigParser.ConfigParser() self._telescope_save_config.read(ConfigFile) try: telescope_save = self._telescope_save_config.get('main', 'telescope') except: telescope_save = 'Bubble Wrap Horn' self.telescope_save = telescope_save self._observers_save_config = ConfigParser.ConfigParser() self._observers_save_config.read(ConfigFile) try: observers_save = self._observers_save_config.get('main', 'observers') except: observers_save = 'Science Aficionado' self.observers_save = observers_save self._nAves_config = ConfigParser.ConfigParser() self._nAves_config.read(ConfigFile) try: nAves = self._nAves_config.getint('main', 'nave') except: nAves = 20 self.nAves = nAves self._fftsize_save_config = ConfigParser.ConfigParser() self._fftsize_save_config.read(ConfigFile) try: fftsize_save = self._fftsize_save_config.getint('main', 'fftsize') except: fftsize_save = 1024 self.fftsize_save = fftsize_save self._device_save_config = ConfigParser.ConfigParser() self._device_save_config.read(ConfigFile) try: device_save = self._device_save_config.get('main', 'device') except: device_save = 'airspy,bias=1,pack=1' self.device_save = device_save self._Gain1s_config = ConfigParser.ConfigParser() self._Gain1s_config.read(ConfigFile) try: Gain1s = self._Gain1s_config.getfloat('main', 'gain1') except: Gain1s = 49. self.Gain1s = Gain1s self.Frequency = Frequency = Frequencys self._Elevation_save_config = ConfigParser.ConfigParser() self._Elevation_save_config.read(ConfigFile) try: Elevation_save = self._Elevation_save_config.getfloat('main', 'elevation') except: Elevation_save = 90. self.Elevation_save = Elevation_save self.Bandwidth = Bandwidth = Bandwidths self._Azimuth_save_config = ConfigParser.ConfigParser() self._Azimuth_save_config.read(ConfigFile) try: Azimuth_save = self._Azimuth_save_config.getfloat('main', 'azimuth') except: Azimuth_save = 90. self.Azimuth_save = Azimuth_save self.observer = observer = observers_save self.numin = numin = (Frequency - (Bandwidth/2.)) self.nsigma = nsigma = 5.0 self.nAve = nAve = nAves self.fftsize = fftsize = fftsize_save self.Telescope = Telescope = telescope_save self.Record = Record = 0 self.H1 = H1 = 1420.406E6 self.Gain2 = Gain2 = 12. self.Gain1 = Gain1 = Gain1s self.EventMode = EventMode = 0 self.Elevation = Elevation = Elevation_save self.Device = Device = device_save self.Azimuth = Azimuth = Azimuth_save ################################################## # Blocks ################################################## self._observer_tool_bar = Qt.QToolBar(self) self._observer_tool_bar.addWidget(Qt.QLabel('Who'+": ")) self._observer_line_edit = Qt.QLineEdit(str(self.observer)) self._observer_tool_bar.addWidget(self._observer_line_edit) self._observer_line_edit.returnPressed.connect( lambda: self.set_observer(str(str(self._observer_line_edit.text())))) self.top_grid_layout.addWidget(self._observer_tool_bar, 0, 0, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._nsigma_range = Range(0., 10., .1, 5.0, 100) self._nsigma_win = RangeWidget(self._nsigma_range, self.set_nsigma, 'N Sigma', "counter", float) self.top_grid_layout.addWidget(self._nsigma_win, 2, 5, 1, 2) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 7): self.top_grid_layout.setColumnStretch(c, 1) self._nAve_tool_bar = Qt.QToolBar(self) self._nAve_tool_bar.addWidget(Qt.QLabel('N_Ave.'+": ")) self._nAve_line_edit = Qt.QLineEdit(str(self.nAve)) self._nAve_tool_bar.addWidget(self._nAve_line_edit) self._nAve_line_edit.returnPressed.connect( lambda: self.set_nAve(int(str(self._nAve_line_edit.text())))) self.top_grid_layout.addWidget(self._nAve_tool_bar, 0, 2, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self._fftsize_tool_bar = Qt.QToolBar(self) self._fftsize_tool_bar.addWidget(Qt.QLabel('FFT_size'+": ")) self._fftsize_line_edit = Qt.QLineEdit(str(self.fftsize)) self._fftsize_tool_bar.addWidget(self._fftsize_line_edit) self._fftsize_line_edit.returnPressed.connect( lambda: self.set_fftsize(int(str(self._fftsize_line_edit.text())))) self.top_grid_layout.addWidget(self._fftsize_tool_bar, 1, 2, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self._Telescope_tool_bar = Qt.QToolBar(self) self._Telescope_tool_bar.addWidget(Qt.QLabel('Tel'+": ")) self._Telescope_line_edit = Qt.QLineEdit(str(self.Telescope)) self._Telescope_tool_bar.addWidget(self._Telescope_line_edit) self._Telescope_line_edit.returnPressed.connect( lambda: self.set_Telescope(str(str(self._Telescope_line_edit.text())))) self.top_grid_layout.addWidget(self._Telescope_tool_bar, 1, 0, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._Record_options = (0, 1, ) self._Record_labels = ('! ! Wait ! !', 'AVERAGE', ) self._Record_tool_bar = Qt.QToolBar(self) self._Record_tool_bar.addWidget(Qt.QLabel('Spec. Mode'+": ")) self._Record_combo_box = Qt.QComboBox() self._Record_tool_bar.addWidget(self._Record_combo_box) for label in self._Record_labels: self._Record_combo_box.addItem(label) self._Record_callback = lambda i: Qt.QMetaObject.invokeMethod(self._Record_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._Record_options.index(i))) self._Record_callback(self.Record) self._Record_combo_box.currentIndexChanged.connect( lambda i: self.set_Record(self._Record_options[i])) self.top_grid_layout.addWidget(self._Record_tool_bar, 3, 2, 1, 3) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 5): self.top_grid_layout.setColumnStretch(c, 1) self._Gain1_tool_bar = Qt.QToolBar(self) self._Gain1_tool_bar.addWidget(Qt.QLabel('Gain1'+": ")) self._Gain1_line_edit = Qt.QLineEdit(str(self.Gain1)) self._Gain1_tool_bar.addWidget(self._Gain1_line_edit) self._Gain1_line_edit.returnPressed.connect( lambda: self.set_Gain1(eng_notation.str_to_num(str(self._Gain1_line_edit.text())))) self.top_grid_layout.addWidget(self._Gain1_tool_bar, 3, 0, 1, 2) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._Frequency_tool_bar = Qt.QToolBar(self) self._Frequency_tool_bar.addWidget(Qt.QLabel('Freq. Hz'+": ")) self._Frequency_line_edit = Qt.QLineEdit(str(self.Frequency)) self._Frequency_tool_bar.addWidget(self._Frequency_line_edit) self._Frequency_line_edit.returnPressed.connect( lambda: self.set_Frequency(eng_notation.str_to_num(str(self._Frequency_line_edit.text())))) self.top_grid_layout.addWidget(self._Frequency_tool_bar, 0, 5, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 7): self.top_grid_layout.setColumnStretch(c, 1) self._EventMode_options = (0, 1, ) self._EventMode_labels = ('! ! Wait ! !', 'Write', ) self._EventMode_tool_bar = Qt.QToolBar(self) self._EventMode_tool_bar.addWidget(Qt.QLabel('Event Mode'+": ")) self._EventMode_combo_box = Qt.QComboBox() self._EventMode_tool_bar.addWidget(self._EventMode_combo_box) for label in self._EventMode_labels: self._EventMode_combo_box.addItem(label) self._EventMode_callback = lambda i: Qt.QMetaObject.invokeMethod(self._EventMode_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._EventMode_options.index(i))) self._EventMode_callback(self.EventMode) self._EventMode_combo_box.currentIndexChanged.connect( lambda i: self.set_EventMode(self._EventMode_options[i])) self.top_grid_layout.addWidget(self._EventMode_tool_bar, 2, 2, 1, 3) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 5): self.top_grid_layout.setColumnStretch(c, 1) self._Elevation_tool_bar = Qt.QToolBar(self) self._Elevation_tool_bar.addWidget(Qt.QLabel('Elevation'+": ")) self._Elevation_line_edit = Qt.QLineEdit(str(self.Elevation)) self._Elevation_tool_bar.addWidget(self._Elevation_line_edit) self._Elevation_line_edit.returnPressed.connect( lambda: self.set_Elevation(eng_notation.str_to_num(str(self._Elevation_line_edit.text())))) self.top_grid_layout.addWidget(self._Elevation_tool_bar, 1, 7, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(7, 9): self.top_grid_layout.setColumnStretch(c, 1) self._Device_tool_bar = Qt.QToolBar(self) self._Device_tool_bar.addWidget(Qt.QLabel('Dev'+": ")) self._Device_line_edit = Qt.QLineEdit(str(self.Device)) self._Device_tool_bar.addWidget(self._Device_line_edit) self._Device_line_edit.returnPressed.connect( lambda: self.set_Device(str(str(self._Device_line_edit.text())))) self.top_grid_layout.addWidget(self._Device_tool_bar, 2, 0, 1, 2) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._Bandwidth_tool_bar = Qt.QToolBar(self) self._Bandwidth_tool_bar.addWidget(Qt.QLabel('Bandwidth'+": ")) self._Bandwidth_line_edit = Qt.QLineEdit(str(self.Bandwidth)) self._Bandwidth_tool_bar.addWidget(self._Bandwidth_line_edit) self._Bandwidth_line_edit.returnPressed.connect( lambda: self.set_Bandwidth(eng_notation.str_to_num(str(self._Bandwidth_line_edit.text())))) self.top_grid_layout.addWidget(self._Bandwidth_tool_bar, 1, 5, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 7): self.top_grid_layout.setColumnStretch(c, 1) self._Azimuth_tool_bar = Qt.QToolBar(self) self._Azimuth_tool_bar.addWidget(Qt.QLabel('Azimuth'+": ")) self._Azimuth_line_edit = Qt.QLineEdit(str(self.Azimuth)) self._Azimuth_tool_bar.addWidget(self._Azimuth_line_edit) self._Azimuth_line_edit.returnPressed.connect( lambda: self.set_Azimuth(eng_notation.str_to_num(str(self._Azimuth_line_edit.text())))) self.top_grid_layout.addWidget(self._Azimuth_tool_bar, 0, 7, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(7, 9): self.top_grid_layout.setColumnStretch(c, 1) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + Device ) self.rtlsdr_source_0.set_sample_rate(Bandwidth) self.rtlsdr_source_0.set_center_freq(Frequency, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(float(Gain1), 0) self.rtlsdr_source_0.set_if_gain(float(Gain2), 0) self.rtlsdr_source_0.set_bb_gain(float(Gain2), 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(Bandwidth, 0) (self.rtlsdr_source_0).set_processor_affinity([3]) self.radio_astro_vmedian_0_0_1_0 = radio_astro.vmedian(fftsize, 4) self.radio_astro_vmedian_0_0_1 = radio_astro.vmedian(fftsize, 4) self.radio_astro_vmedian_0_0_0 = radio_astro.vmedian(fftsize, 4) self.radio_astro_vmedian_0_0 = radio_astro.vmedian(fftsize, 4) self.radio_astro_vmedian_0 = radio_astro.vmedian(fftsize, 4) self.radio_astro_ra_event_sink_0 = radio_astro.ra_event_sink(ObsName+"Event.not", fftsize, Frequency*1.E-6, Bandwidth*1.E-6, EventMode, 'Event Detection', 'Observer', Telescope, Device, float(Gain1), Azimuth, Elevation) self.radio_astro_ra_ascii_sink_0 = radio_astro.ra_ascii_sink(ObsName+".not", observer, fftsize, Frequency, Bandwidth, Azimuth, Elevation, Record, 0, 4**5, nAve, telescope_save, device_save, float(Gain1), float(Gain2), float(Gain2)) self.radio_astro_detect_0 = radio_astro.detect(fftsize, nsigma, Frequency, Bandwidth, fftsize*1.e-6/Bandwidth, 2) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1 ) self.qtgui_number_sink_0.set_update_time(1.) self.qtgui_number_sink_0.set_title("") labels = ['T Remains:', '', '', '', '', '', '', '', '', ''] units = ['(s)', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, 0.) self.qtgui_number_sink_0.set_max(i, nAve * fftsize * 1024. / Bandwidth) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 3, 5, 1, 3) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f( fftsize, 100, -.4, .4, "", 2 ) self.qtgui_histogram_sink_x_0.set_update_time(1.) self.qtgui_histogram_sink_x_0.enable_autoscale(True) self.qtgui_histogram_sink_x_0.enable_accumulate(False) self.qtgui_histogram_sink_x_0.enable_grid(False) self.qtgui_histogram_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_histogram_sink_x_0.disable_legend() labels = ['I', 'Q', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_histogram_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_histogram_sink_x_0.set_line_label(i, labels[i]) self.qtgui_histogram_sink_x_0.set_line_width(i, widths[i]) self.qtgui_histogram_sink_x_0.set_line_color(i, colors[i]) self.qtgui_histogram_sink_x_0.set_line_style(i, styles[i]) self.qtgui_histogram_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_histogram_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_histogram_sink_x_0_win = sip.wrapinstance(self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_histogram_sink_x_0_win, 4, 0, 1, 5) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 5): self.top_grid_layout.setColumnStretch(c, 1) self.fft_vxx_0 = fft.fft_vcc(fftsize, True, (window.hamming(fftsize)), True, 1) self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fftsize) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(fftsize) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_histogram_sink_x_0, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_histogram_sink_x_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.radio_astro_vmedian_0_0_1, 0)) self.connect((self.blocks_stream_to_vector_0_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_stream_to_vector_0_0, 0), (self.radio_astro_detect_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.radio_astro_detect_0, 0), (self.radio_astro_ra_event_sink_0, 0)) self.connect((self.radio_astro_ra_ascii_sink_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.radio_astro_vmedian_0, 0), (self.radio_astro_ra_ascii_sink_0, 0)) self.connect((self.radio_astro_vmedian_0_0, 0), (self.radio_astro_vmedian_0, 0)) self.connect((self.radio_astro_vmedian_0_0_0, 0), (self.radio_astro_vmedian_0_0, 0)) self.connect((self.radio_astro_vmedian_0_0_1, 0), (self.radio_astro_vmedian_0_0_1_0, 0)) self.connect((self.radio_astro_vmedian_0_0_1_0, 0), (self.radio_astro_vmedian_0_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_stream_to_vector_0_0, 0))
def initUI(self): ###################################################################### # Spectrum analyzer/Diagnostics ###################################################################### self.qgroupbox_diagnostics = Qt.QGroupBox( 'Spectrum analyzer/diagnostics (all computed from raw ADC input)', self) # Create the scale which indicates the ADC fill ratio: self.qlabel_adc_fill = Qt.QLabel('ADC fill\n[bits]') self.qlabel_adc_fill.setAlignment(Qt.Qt.AlignHCenter) self.qadc0_scale = ThermometerWidget() #Qwt.QwtThermo() #self.qadc0_scale.setOrientation(Qt.Qt.Vertical, Qwt.QwtThermo.LeftScale) self.qadc0_scale.setRange(0, 16) #self.qadc0_scale.setScale(0, 16) self.qadc0_scale.setValue(0) self.qadc0_scale.setFillColor(Qt.Qt.blue) ticksListMajor = [0, 5, 10, 15] ticksListMinor = [2.5, 7.5, 12.5] ticksLabelMajor = list(map(str, ticksListMajor)) self.qadc0_scale.setTicks(ticksListMajor, ticksListMinor, ticksLabelMajor) self.qlabel_adc_fill_value = Qt.QLabel('10 bits') self.qlabel_adc_fill_value.setAlignment(Qt.Qt.AlignHCenter) # Create the scale which indicates the baseband SNR: self.qlabel_baseband_snr = Qt.QLabel('SNR\n[dB]') self.qlabel_baseband_snr.setAlignment(Qt.Qt.AlignHCenter) self.qthermo_baseband_snr = ThermometerWidget() #Qwt.QwtThermo() #self.qthermo_baseband_snr.setOrientation(Qt.Qt.Vertical, Qwt.QwtThermo.LeftScale) self.qthermo_baseband_snr.setRange(0, 50) self.qthermo_baseband_snr.setScale(0, 50) self.qthermo_baseband_snr.setValue(0) self.qthermo_baseband_snr.setFillColor(Qt.Qt.blue) ticksListMajor = [0, 10, 20, 30, 40, 50] ticksListMinor = [5, 15, 25, 35, 45] ticksLabelMajor = list(map(str, ticksListMajor)) self.qthermo_baseband_snr.setTicks(ticksListMajor, ticksListMinor, ticksLabelMajor) self.qlabel_baseband_snr_value = Qt.QLabel('20 dB') self.qlabel_baseband_snr_value.setAlignment(Qt.Qt.AlignHCenter) # Create the widgets which shows the current dac output and sets the output offset: self.qlabel_dac_current = {} self.qlabel_dac_current_value = {} self.qthermo_dac_current = {} self.qlabel_dac_offset = {} self.q_dac_offset = {} self.qlabel_dac_offset_value = {} for k in range(3): if self.output_controls[k] == True: self.qlabel_dac_current[k] = Qt.QLabel('Output\nDAC %d [V]' % k) self.qlabel_dac_current[k].setAlignment(Qt.Qt.AlignHCenter) self.qthermo_dac_current[k] = ThermometerWidget( ) #Qwt.QwtThermo() #self.qthermo_dac_current[k].setOrientation(Qt.Qt.Vertical, Qwt.QwtThermo.LeftScale) self.qthermo_dac_current[k].setRange( self.sl.convertDACCountsToVolts(k, self.sl.DACs_limit_low[k]), self.sl.convertDACCountsToVolts( k, self.sl.DACs_limit_high[k])) self.qthermo_dac_current[k].setScale( self.sl.convertDACCountsToVolts(k, self.sl.DACs_limit_low[k]), self.sl.convertDACCountsToVolts( k, self.sl.DACs_limit_high[k])) self.qthermo_dac_current[k].setValue(0) #self.qthermo_dac_current[k].setFillBrush(Qt.QBrush(Qt.QColor(0, 186, 52))) self.qthermo_dac_current[k].setFillColor(Qt.QColor(0, 186, 52)) if k == 2: ticksListMajor = [0, 1, 2, 3] ticksListMinor = [0.5, 1.5, 2.5] else: ticksListMajor = [-1, -0.5, 0, 0.5, 1] ticksListMinor = [-0.75, -0.25, 0.25, 0.75] ticksLabelMajor = list(map(str, ticksListMajor)) self.qthermo_dac_current[k].setTicks(ticksListMajor, ticksListMinor, ticksLabelMajor) self.qlabel_dac_offset[k] = Qt.QLabel('Offset\nDAC %d [V]' % k) self.qlabel_dac_offset[k].setAlignment(Qt.Qt.AlignHCenter) self.q_dac_offset[k] = Qt.QSlider() self.q_dac_offset[k].valueChanged.connect( self.setDACOffset_event) self.q_dac_offset[k].setSliderPosition(0) self.q_dac_offset[k].setOrientation(Qt.Qt.Vertical) # Units are millionth of the full range available between the min and max DAC value self.q_dac_offset[k].setMinimum(0) self.q_dac_offset[k].setMaximum(1e6) self.qlabel_dac_current_value[k] = Qt.QLabel('0 V') self.qlabel_dac_current_value[k].setAlignment( Qt.Qt.AlignHCenter) self.qlabel_dac_offset_value[k] = Qt.QLabel('0 V') self.qlabel_dac_offset_value[k].setAlignment( Qt.Qt.AlignHCenter) # Create widgets to set the number of points for the graphs: self.qlabel_rawdata_rbw = Qt.QLabel('RBW: 100 kHz; Points:') self.qedit_rawdata_length = Qt.QLineEdit('1.73e3') self.qedit_rawdata_length.setMaximumWidth(60) # Plot type select self.qlabel_adc_plot_type = Qt.QLabel('Plot type:') self.qcombo_adc_plottype = Qt.QComboBox() self.qcombo_adc_plottype.addItems([ 'Spectrum', 'Time: raw input', 'Time: Phase', 'Time: IQ', 'Time: IQ, synced' ]) # Input select self.qlabel_adc_plot_input = Qt.QLabel('Input:') self.qcombo_adc_plot = Qt.QComboBox() self.qcombo_adc_plot.addItems(['ADC0', 'ADC1', 'DAC0', 'DAC1', 'DAC2']) self.qcombo_adc_plot.setCurrentIndex(self.selected_ADC) # Set a few global PyQtGraph settings before creating plots: pg.setConfigOption('leftButtonPan', False) pg.setConfigOption('background', 'w') pg.setConfigOption('foreground', 'k') pg.setConfigOption('antialias', True) # Create the baseband IQ plot: #self.qplt_IQ = Qwt.QwtPlot() self.qplt_IQ = pg.PlotWidget() #self.qplt_IQ.move(50, 50) #self.qplt_IQ.resize(200, 200) self.qplt_IQ.setMinimumSize(50, 50) self.qplt_IQ.setMaximumSize(200, 200) self.qplt_IQ.setFixedSize(100, 100) # self.qplt_IQ.setsetHeightForWidth(True) # qPolicy = Qt.QSizePolicy(Qt.QSizePolicy.Preferred, Qt.QSizePolicy.Preferred) qPolicy = Qt.QSizePolicy(Qt.QSizePolicy.Fixed, Qt.QSizePolicy.Fixed) # qPolicy.setHeightForWidth(True) self.qplt_IQ.setSizePolicy(qPolicy) # self.qplt_IQ.setSizePolicy(Qt.QSizePolicy.setHeightForWidth(True)) # print(self.qplt_IQ.sizeHint()) #self.qplt_IQ.setTitle('', fill=None) # self.qplt_IQ.setTitle('Baseband IQ') #self.qplt_IQ.setCanvasBackground(Qt.Qt.white) #self.qplt_IQ.enableAxis(Qwt.QwtPlot.yLeft, False) #self.qplt_IQ.enableAxis(Qwt.QwtPlot.xBottom, False) self.qplt_IQ.hideAxis('left') self.qplt_IQ.hideAxis('bottom') self.lblplt_IQ_title = Qt.QLabel('Baseband IQ:') # Create the curves in the plot self.curve_IQ = self.qplt_IQ.getPlotItem().plot(pen=None, symbol='o', symbolPen=None, symbolSize=3, symbolBrush='b') # self.curve_IQ = Qwt.QwtPlotCurve('Spectrum') # self.curve_IQ.attach(self.qplt_IQ) # self.curve_IQ.setPen(Qt.QPen(Qt.Qt.NoPen)) # self.curve_IQ.setSymbol(Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, # Qt.QBrush(Qt.Qt.blue), # Qt.QPen(Qt.Qt.blue), # Qt.QSize(3, 3))) # self.curve_IQ.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased); # Create the frequency domain plot: # self.qplt_spc = Qwt.QwtPlot() # self.qplt_spc.setTitle('Spectrum') # self.qplt_spc.setCanvasBackground(Qt.Qt.white) self.plt_spc = pg.PlotWidget() # Create the curves in the plot # self.curve_spc = Qwt.QwtPlotCurve('Spectrum') # self.curve_spc.attach(self.qplt_spc) # self.curve_spc.setPen(Qt.QPen(Qt.Qt.blue)) # self.curve_filter = Qwt.QwtPlotCurve('Spectrum') # self.curve_filter.attach(self.qplt_spc) # self.curve_filter.setPen(Qt.QPen(Qt.Qt.red)) self.curve_spc = self.plt_spc.getPlotItem().plot(title='Spectrum', pen='b') self.curve_filter = self.plt_spc.getPlotItem().plot(pen='r') # Put all the widgets into a grid layout grid = QtGui.QGridLayout() grid.setSpacing(5) grid.addWidget(self.qlabel_adc_fill, 0, 0) grid.addWidget(self.qadc0_scale, 1, 0, 3, 1) grid.addWidget(self.qlabel_adc_fill_value, 4, 0, 1, 1) grid.addWidget(self.qlabel_baseband_snr, 0, 1) grid.addWidget(self.qthermo_baseband_snr, 1, 1, 3, 1) grid.addWidget(self.qlabel_baseband_snr_value, 4, 1, 1, 1) N_dac_controls = 0 for k in range(3): if self.output_controls[k] == True: grid.addWidget(self.qlabel_dac_current[k], 0, 2 + N_dac_controls) grid.addWidget(self.qthermo_dac_current[k], 1, 2 + N_dac_controls, 3, 1) grid.addWidget(self.qlabel_dac_current_value[k], 4, 2 + N_dac_controls, 1, 1) grid.addWidget(self.qlabel_dac_offset[k], 0, 3 + N_dac_controls) grid.addWidget(self.q_dac_offset[k], 1, 3 + N_dac_controls, 3, 1) grid.addWidget(self.qlabel_dac_offset_value[k], 4, 3 + N_dac_controls, 1, 1) N_dac_controls = N_dac_controls + 2 grid.setRowStretch(1, 1) # The plots: qhoriz = Qt.QHBoxLayout() qhoriz.addWidget(self.lblplt_IQ_title) qhoriz.addWidget(self.qplt_IQ) qhoriz.addStretch(1) grid.addLayout(qhoriz, 0, 2 + N_dac_controls, 2, 2) #grid.addWidget(self.qplt_IQ, 0, 2+N_dac_controls, 2, 2) grid.addWidget(self.plt_spc, 0, 4 + N_dac_controls, 5, 1) grid.setColumnStretch(4 + N_dac_controls, 1) # # The controls below the IQ plot: grid.addWidget(self.qlabel_adc_plot_input, 2, 2 + N_dac_controls) grid.addWidget(self.qlabel_adc_plot_type, 3, 2 + N_dac_controls) grid.addWidget(self.qlabel_rawdata_rbw, 4, 2 + N_dac_controls) grid.addWidget(self.qcombo_adc_plot, 2, 3 + N_dac_controls) grid.addWidget(self.qcombo_adc_plottype, 3, 3 + N_dac_controls) grid.addWidget(self.qedit_rawdata_length, 4, 3 + N_dac_controls) # grid.addItem(spacerItem, 9, 0, 1, 2) if self.PalNormal is not None: self.qgroupbox_diagnostics.setPalette(self.PalNormal) self.qgroupbox_diagnostics.setLayout(grid) self.qgroupbox_diagnostics.setAutoFillBackground(True) vbox = Qt.QVBoxLayout() vbox.addWidget(self.qgroupbox_diagnostics) self.setLayout(vbox)
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.uisigtype = uisigtype = 101 self.ui_freq = ui_freq = 50 self.samp_rate = samp_rate = 48000 ################################################## # Blocks ################################################## self._uisigtype_options = ( 101, 103, 100, 102, 104, ) self._uisigtype_labels = ( 'Sine', 'Square', 'Constant', 'Cosine', 'Triangle', ) self._uisigtype_tool_bar = Qt.QToolBar(self) self._uisigtype_tool_bar.addWidget(Qt.QLabel("uisigtype" + ": ")) self._uisigtype_combo_box = Qt.QComboBox() self._uisigtype_tool_bar.addWidget(self._uisigtype_combo_box) for label in self._uisigtype_labels: self._uisigtype_combo_box.addItem(label) self._uisigtype_callback = lambda i: Qt.QMetaObject.invokeMethod( self._uisigtype_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._uisigtype_options.index(i))) self._uisigtype_callback(self.uisigtype) self._uisigtype_combo_box.currentIndexChanged.connect( lambda i: self.set_uisigtype(self._uisigtype_options[i])) self.top_grid_layout.addWidget(self._uisigtype_tool_bar) self._ui_freq_range = Range(10, 1000, 10, 50, 200) self._ui_freq_win = RangeWidget(self._ui_freq_range, self.set_ui_freq, "ui_freq", "counter_slider", float) self.top_grid_layout.addWidget(self._ui_freq_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, uisigtype, ui_freq, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_0, 0))
def initUI(self): # Create the widgets which control the system identification module: # Input select transfer_input_label = Qt.QLabel('Input:') self.qcombo_transfer_input = Qt.QComboBox() self.qcombo_transfer_input.addItems( ['ADC 0', 'ADC 1', 'DDC 0', 'DDC 1']) self.qcombo_transfer_input.setCurrentIndex(2) # transfer_input_label.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) # self.qcombo_transfer_input.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed) # Output select transfer_output_label = Qt.QLabel('Output:') self.qcombo_transfer_output = Qt.QComboBox() self.qcombo_transfer_output.addItems(['DAC 0', 'DAC 1', 'DAC 2']) self.qcombo_transfer_output.setCurrentIndex(0) # transfer_output_label.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) # self.qcombo_transfer_output.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed) # settling_time_label = Qt.QLabel('System settling time [s]:') self.qedit_settling_time = Qt.QLineEdit('1e-3') self.qedit_settling_time.setMaximumWidth(60) self.qedit_settling_time.editingFinished.connect( self.updateIntegrationTime) # settling_time_label.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) # self.qedit_settling_time.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed) freq_start_label = Qt.QLabel('Freq start [Hz]:') self.qedit_freq_start = Qt.QLineEdit('10e3') self.qedit_freq_start.setMaximumWidth(60) self.qedit_freq_start.editingFinished.connect( self.updateIntegrationTime) # freq_start_label.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) # self.qedit_freq_start.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed) freq_end_label = Qt.QLabel('Freq end [Hz]:') self.qedit_freq_end = Qt.QLineEdit('2e6') self.qedit_freq_end.setMaximumWidth(60) # self.qedit_freq_end.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed) freq_number_label = Qt.QLabel('Number of freq [max 3276]:') self.qedit_freq_number = Qt.QLineEdit('160') self.qedit_freq_number.setMaximumWidth(60) # self.qedit_freq_number.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed) amplitude_label = Qt.QLabel('Modulation amplitude [0-1]:') self.qedit_output_amplitude = Qt.QLineEdit('0.01') self.qedit_output_amplitude.setMaximumWidth(60) # self.qedit_output_amplitude.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed) self.qlbl_integration_time = Qt.QLabel( 'Integration time per freq [s]: ') self.updateIntegrationTime() # Button which triggers the system identification self.qbtn_ident = QtGui.QPushButton('Run identification') self.qbtn_ident.clicked.connect(self.runSytemIdentification) # self.qbtn_ident.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed) self.qbtn_stop_ident = QtGui.QPushButton('Stop identification') self.qbtn_stop_ident.clicked.connect(self.stopClicked) # Progress bar which indicates the progression of the identification self.qprogress_ident = Qt.QProgressBar() self.qprogress_ident.setTextVisible(False) self.qprogress_ident.setValue(0) # self.qprogress_ident.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed) # Controls for the dither mode: # Needs: output select, frequency, amplitude, Square/Sine select, dither on/off ###################################################################### # Settings ###################################################################### self.qgroupbox_dither = Qt.QGroupBox('Continuous output', self) self.dither_output_label = Qt.QLabel('Output:') self.qcombo_dither_output = Qt.QComboBox() self.qcombo_dither_output.addItems(['DAC 0', 'DAC 1', 'DAC 2']) self.qcombo_dither_output.setCurrentIndex(0) self.qcombo_dither_output.currentIndexChanged.connect( self.ditherClicked) # Modulation frequency: self.qedit_freq_label = Qt.QLabel('Frequency [Hz]:') self.qedit_dither_freq = Qt.QLineEdit('1e6') self.qedit_dither_freq.textChanged.connect(self.ditherClicked) self.qedit_dither_freq.setMaximumWidth(60) # Amplitude: self.qlabel_dither_amplitude = Qt.QLabel('Amplitude [0-1]:') self.qedit_dither_amplitude = Qt.QLineEdit('0.01') self.qedit_dither_amplitude.textChanged.connect(self.ditherClicked) self.qedit_dither_amplitude.setMaximumWidth(60) # Sine/Square wave self.qradio_sinewave = Qt.QRadioButton('Sine wave') self.qradio_squarewave = Qt.QRadioButton('Square wave') self.qsign_group = Qt.QButtonGroup(self) self.qsign_group.addButton(self.qradio_sinewave) self.qsign_group.addButton(self.qradio_squarewave) self.qradio_sinewave.setChecked(True) self.qradio_squarewave.setChecked(False) self.qradio_sinewave.clicked.connect(self.ditherClicked) self.qradio_squarewave.clicked.connect(self.ditherClicked) # On/Off button self.qbtn_dither = QtGui.QPushButton('Activate dither') self.qbtn_dither.clicked.connect(self.ditherClicked) self.qbtn_dither.setCheckable(True) # Put all the widgets into a grid layout grid = QtGui.QGridLayout() grid.addWidget(self.dither_output_label, 0, 0) grid.addWidget(self.qcombo_dither_output, 0, 1) grid.addWidget(self.qedit_freq_label, 1, 0) grid.addWidget(self.qedit_dither_freq, 1, 1) grid.addWidget(self.qlabel_dither_amplitude, 2, 0) grid.addWidget(self.qedit_dither_amplitude, 2, 1) grid.addWidget(self.qradio_sinewave, 3, 0) grid.addWidget(self.qradio_squarewave, 3, 1) grid.addWidget(self.qbtn_dither, 4, 0, 1, 2) self.qgroupbox_dither.setLayout(grid) ###################################################################### # Settings ###################################################################### self.qgroupbox_test_osc = Qt.QGroupBox( 'Variable duty-cycle oscillator') self.qlbl_osc_freq = Qt.QLabel('Frequency [Hz]:') self.qedit_osc_freq = Qt.QLineEdit('200e3') self.qedit_osc_freq.textChanged.connect(self.oscClicked) # On/Off button self.qbtn_osc = QtGui.QPushButton('Activate output') self.qbtn_osc.setCheckable(True) self.qbtn_osc.setChecked(True) self.qbtn_osc.clicked.connect(self.oscClicked) # Polarity setting self.qchk_osc_polarity = Qt.QCheckBox('Invert polarity') self.qchk_osc_polarity.clicked.connect(self.oscClicked) # Duty cycle slider self.q_osc_duty_cyle = Qt.QSlider() self.q_osc_duty_cyle.valueChanged.connect(self.oscClicked) self.q_osc_duty_cyle.setSliderPosition(0) self.q_osc_duty_cyle.setOrientation(Qt.Qt.Horizontal) # Units are millionth of the full range available self.q_osc_duty_cyle.setMinimum(0) self.q_osc_duty_cyle.setMaximum(1e6) self.q_osc_duty_cyle.setSingleStep(1e6 / 100. / 3.) self.q_osc_duty_cyle.setPageStep(1e6 / 10.) # Put all the widgets into a grid layout grid = QtGui.QGridLayout() grid.addWidget(self.qlbl_osc_freq, 0, 0) grid.addWidget(self.qedit_osc_freq, 0, 1) grid.addWidget(self.qbtn_osc, 1, 0, 1, 2) grid.addWidget(self.qchk_osc_polarity, 2, 0, 1, 2) grid.addWidget(self.q_osc_duty_cyle, 3, 0, 1, 2) self.qgroupbox_test_osc.setLayout(grid) # Put all the widgets into a grid layout grid = QtGui.QGridLayout() grid.addWidget(transfer_input_label, 0, 0) grid.addWidget(self.qcombo_transfer_input, 0, 1) grid.addWidget(transfer_output_label, 1, 0) grid.addWidget(self.qcombo_transfer_output, 1, 1) grid.addWidget(settling_time_label, 2, 0) grid.addWidget(self.qedit_settling_time, 2, 1) grid.addWidget(freq_start_label, 3, 0) grid.addWidget(self.qedit_freq_start, 3, 1) grid.addWidget(freq_end_label, 4, 0) grid.addWidget(self.qedit_freq_end, 4, 1) grid.addWidget(freq_number_label, 5, 0) grid.addWidget(self.qedit_freq_number, 5, 1) grid.addWidget(amplitude_label, 6, 0) grid.addWidget(self.qedit_output_amplitude, 6, 1) grid.addWidget(self.qlbl_integration_time, 7, 0, 1, 2) grid.addWidget(self.qbtn_ident, 8, 0, 1, 2) grid.addWidget(self.qbtn_stop_ident, 9, 0, 1, 2) grid.addWidget(self.qprogress_ident, 10, 0, 1, 2) self.qgroupbox_vna = Qt.QGroupBox('Swept sine', self) self.qgroupbox_vna.setLayout(grid) vbox = Qt.QVBoxLayout() vbox.addWidget(self.qgroupbox_vna) vbox.addWidget(self.qgroupbox_dither) # vbox.addWidget(self.qgroupbox_test_osc) # Spacer which takes up the rest of the space: spacerItem = QtGui.QSpacerItem(1, 1, QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Expanding) vbox.addItem(spacerItem) self.setLayout(vbox) # Adjust the size and position of the window # self.resize(800, 600) self.center() self.setWindowTitle('VNA control') self.show()