def __init__(self): gr.top_block.__init__(self, "Lab 3") Qt.QWidget.__init__(self) self.setWindowTitle("Lab 3") 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", "lab3") 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.freqc = freqc = 900 self.zeta = zeta = 0.707 self.std_dev = std_dev = 0.01 self.sps = sps = 8 self.samp_rate = samp_rate = 1000 self.nat_freq = nat_freq = 10000 self.lw = lw = 2 self.gain_ = gain_ = 0.5 self.freqc_ = freqc_ = freqc self.fps = fps = 30 self.fo = fo = 0 self.const_qpsk = const_qpsk = digital.constellation_calcdist(digital.psk_4()[0], digital.psk_4()[1], 4, 1).base() self.const_bpsk = const_bpsk = digital.constellation_calcdist(digital.psk_2()[0], digital.psk_2()[1], 2, 1).base() self.bw = bw = 1 self.buff_size = buff_size = 32768 self.bSignal = bSignal = 0 self.bSelectPLL = bSelectPLL = 0 self.axis = axis = 2 ################################################## # Blocks ################################################## self._zeta_range = Range(0, 4, 0.001, 0.707, 200) self._zeta_win = RangeWidget(self._zeta_range, self.set_zeta, 'Damping Factor (Zeta)', "counter_slider", float) self.top_grid_layout.addWidget(self._zeta_win, 13, 0, 1, 1) for r in range(13, 14): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.tab0 = Qt.QTabWidget() self.tab0_widget_0 = Qt.QWidget() self.tab0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_0) self.tab0_grid_layout_0 = Qt.QGridLayout() self.tab0_layout_0.addLayout(self.tab0_grid_layout_0) self.tab0.addTab(self.tab0_widget_0, 'Loop Filter Output') self.tab0_widget_1 = Qt.QWidget() self.tab0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_1) self.tab0_grid_layout_1 = Qt.QGridLayout() self.tab0_layout_1.addLayout(self.tab0_grid_layout_1) self.tab0.addTab(self.tab0_widget_1, 'Spectrum') self.top_grid_layout.addWidget(self.tab0, 0, 0, 10, 2) for r in range(0, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._std_dev_range = Range(0, 0.1, 0.001, 0.01, 200) self._std_dev_win = RangeWidget(self._std_dev_range, self.set_std_dev, 'Noise Std. Dev', "counter_slider", float) self.top_grid_layout.addWidget(self._std_dev_win, 11, 0, 1, 1) for r in range(11, 12): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._nat_freq_range = Range(0, 100e3, 1, 10000, 200) self._nat_freq_win = RangeWidget(self._nat_freq_range, self.set_nat_freq, 'Natural Freq (Hz)', "counter_slider", float) self.top_grid_layout.addWidget(self._nat_freq_win, 13, 1, 1, 1) for r in range(13, 14): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._gain__range = Range(0.1, 1, 0.01, 0.5, 200) self._gain__win = RangeWidget(self._gain__range, self.set_gain_, 'Gain (Amp)', "counter_slider", float) self.top_grid_layout.addWidget(self._gain__win, 10, 1, 1, 1) for r in range(10, 11): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._freqc__range = Range(70, 6000, .01, freqc, 200) self._freqc__win = RangeWidget(self._freqc__range, self.set_freqc_, 'Carrier (MHz)', "counter_slider", float) self.top_grid_layout.addWidget(self._freqc__win, 10, 0, 1, 1) for r in range(10, 11): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._fo_range = Range(0, 100e3, 100, 0, 200) self._fo_win = RangeWidget(self._fo_range, self.set_fo, 'Frequency Offset (Hz)', "counter_slider", float) self.top_grid_layout.addWidget(self._fo_win, 11, 1, 1, 1) for r in range(11, 12): 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._bSignal_options = (0, 1, 2, ) # Create the labels list self._bSignal_labels = ('Tone', 'BPSK', 'QPSK', ) # Create the combo box # Create the radio buttons self._bSignal_group_box = Qt.QGroupBox('Signal Select' + ": ") self._bSignal_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._bSignal_button_group = variable_chooser_button_group() self._bSignal_group_box.setLayout(self._bSignal_box) for i, _label in enumerate(self._bSignal_labels): radio_button = Qt.QRadioButton(_label) self._bSignal_box.addWidget(radio_button) self._bSignal_button_group.addButton(radio_button, i) self._bSignal_callback = lambda i: Qt.QMetaObject.invokeMethod(self._bSignal_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._bSignal_options.index(i))) self._bSignal_callback(self.bSignal) self._bSignal_button_group.buttonClicked[int].connect( lambda i: self.set_bSignal(self._bSignal_options[i])) self.top_grid_layout.addWidget(self._bSignal_group_box, 12, 0, 1, 1) for r in range(12, 13): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) # Create the options list self._bSelectPLL_options = (0, 1, 2, 3, ) # Create the labels list self._bSelectPLL_labels = ('Standard', 'Costas', 'Costas w/ HL', 'QPSK Costas', ) # Create the combo box # Create the radio buttons self._bSelectPLL_group_box = Qt.QGroupBox('PLL Order' + ": ") self._bSelectPLL_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._bSelectPLL_button_group = variable_chooser_button_group() self._bSelectPLL_group_box.setLayout(self._bSelectPLL_box) for i, _label in enumerate(self._bSelectPLL_labels): radio_button = Qt.QRadioButton(_label) self._bSelectPLL_box.addWidget(radio_button) self._bSelectPLL_button_group.addButton(radio_button, i) self._bSelectPLL_callback = lambda i: Qt.QMetaObject.invokeMethod(self._bSelectPLL_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._bSelectPLL_options.index(i))) self._bSelectPLL_callback(self.bSelectPLL) self._bSelectPLL_button_group.buttonClicked[int].connect( lambda i: self.set_bSelectPLL(self._bSelectPLL_options[i])) self.top_grid_layout.addWidget(self._bSelectPLL_group_box, 12, 1, 1, 1) for r in range(12, 13): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.wes_costas_cc_0 = wes.costas_cc(nat_freq / (samp_rate*1000), zeta, bSelectPLL) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( 4096, #size samp_rate*1000, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-10000, 10000) self.qtgui_time_sink_x_0_0.set_y_label('Frequency (Hz)', "") self.qtgui_time_sink_x_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(True) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) labels = ['Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10'] 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(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tab0_grid_layout_0.addWidget(self._qtgui_time_sink_x_0_0_win, 5, 0, 5, 1) for r in range(5, 10): self.tab0_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.tab0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate*1e3, #bw "", #name 1 ) self.qtgui_freq_sink_x_0.set_update_time(1/fps) 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(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) labels = ['In-Phase', 'Quadrature', '', '', '', '', '', '', '', ''] 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 range(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.tab0_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_win, 5, 0, 5, 1) for r in range(5, 10): self.tab0_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.tab0_grid_layout_1.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0.set_processor_affinity([0]) self.interp_fir_filter_xxx_1_0_0 = filter.interp_fir_filter_ccc(sps, (1,1,1,1,1,1,1,1)) self.interp_fir_filter_xxx_1_0_0.declare_sample_delay(0) self.interp_fir_filter_xxx_1_0 = filter.interp_fir_filter_ccc(sps, (1,1,1,1,1,1,1,1)) self.interp_fir_filter_xxx_1_0.declare_sample_delay(0) self.iio_pluto_source_0 = iio.pluto_source(epy_module_0.RX, int(freqc_*1e6), int(samp_rate*1000), 20000000, buff_size, True, True, True, 'manual', 32, '', True) self.iio_pluto_sink_0 = iio.pluto_sink(epy_module_0.TX, int(freqc_*1e6), int(samp_rate*1000), 20000000, buff_size, False, 10.0, '', True) self.digital_chunks_to_symbols_xx_1_0 = digital.chunks_to_symbols_bc(const_qpsk.points(), 1) self.digital_chunks_to_symbols_xx_1 = digital.chunks_to_symbols_bc(const_bpsk.points(), 1) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0.set_single_key("") self.blocks_selector_0_0 = blocks.selector(gr.sizeof_gr_complex*1,bSignal,0) self.blocks_selector_0_0.set_enabled(True) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_cc(1/6.28*samp_rate*1000) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc(0) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(gain_ ) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blocks_add_const_vxx_0 = blocks.add_const_cc(1) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate*1000, analog.GR_COS_WAVE, fo, 1, 0, 0) self.analog_random_source_x_0_0 = blocks.vector_source_b(list(map(int, numpy.random.randint(0, 4, 8192))), True) self.analog_random_source_x_0 = blocks.vector_source_b(list(map(int, numpy.random.randint(0, 2, 8192))), True) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, std_dev, 0) self.analog_agc_xx_0 = analog.agc_cc(1e-4, 1.0, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.wes_costas_cc_0, 0)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_1, 0)) self.connect((self.analog_random_source_x_0_0, 0), (self.digital_chunks_to_symbols_xx_1_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_selector_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.iio_pluto_sink_0, 0)) self.connect((self.blocks_selector_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.digital_chunks_to_symbols_xx_1, 0), (self.interp_fir_filter_xxx_1_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_1_0, 0), (self.interp_fir_filter_xxx_1_0_0, 0)) self.connect((self.iio_pluto_source_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.interp_fir_filter_xxx_1_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.interp_fir_filter_xxx_1_0, 0), (self.blocks_selector_0_0, 1)) self.connect((self.interp_fir_filter_xxx_1_0_0, 0), (self.blocks_selector_0_0, 2)) self.connect((self.wes_costas_cc_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.wes_costas_cc_0, 1), (self.blocks_tag_gate_0, 0))
def __init__(self): gr.top_block.__init__(self, "Byte Construction") Qt.QWidget.__init__(self) self.setWindowTitle("Byte Construction") 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", "byte_construction") 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.sps = sps = 4 self.nfilts = nfilts = 32 self.timing_loop_bw = timing_loop_bw = 6.28 / 100.0 self.time_offset = time_offset = 1.00 self.taps = taps = [1.0, 0.25 - 0.25j, 0.50 + 0.10j, -0.3 + 0.2j] self.samp_rate = samp_rate = 32000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), 0.35, 11 * sps * nfilts) self.qpsk = qpsk = digital.constellation_rect(([ 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.phase_bw = phase_bw = 6.28 / 100.0 self.noise_volt = noise_volt = 0.0001 self.freq_offset = freq_offset = 0 self.excess_bw = excess_bw = 0.35 self.eq_gain = eq_gain = 0.01 self.delay = delay = 58 self.arity = arity = 4 ################################################## # Blocks ################################################## self.controls = Qt.QTabWidget() self.controls_widget_0 = Qt.QWidget() self.controls_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_0) self.controls_grid_layout_0 = Qt.QGridLayout() self.controls_layout_0.addLayout(self.controls_grid_layout_0) self.controls.addTab(self.controls_widget_0, 'Channel') self.controls_widget_1 = Qt.QWidget() self.controls_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_1) self.controls_grid_layout_1 = Qt.QGridLayout() self.controls_layout_1.addLayout(self.controls_grid_layout_1) self.controls.addTab(self.controls_widget_1, 'Receiver') self.top_grid_layout.addWidget(self.controls, 0, 0, 1, 2) [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, 2)] self._timing_loop_bw_range = Range(0.0, 0.2, 0.01, 6.28 / 100.0, 200) self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range, self.set_timing_loop_bw, 'Time: BW', "slider", float) self.controls_grid_layout_1.addWidget(self._timing_loop_bw_win, 0, 0, 1, 1) [self.controls_grid_layout_1.setRowStretch(r, 1) for r in range(0, 1)] [ self.controls_grid_layout_1.setColumnStretch(c, 1) for c in range(0, 1) ] self._time_offset_range = Range(0.999, 1.001, 0.0001, 1.00, 200) self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, 'Timing Offset', "counter_slider", float) self.controls_grid_layout_0.addWidget(self._time_offset_win, 0, 2, 1, 1) [self.controls_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)] [ self.controls_grid_layout_0.setColumnStretch(c, 1) for c in range(2, 3) ] self.received = Qt.QTabWidget() self.received_widget_0 = Qt.QWidget() self.received_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.received_widget_0) self.received_grid_layout_0 = Qt.QGridLayout() self.received_layout_0.addLayout(self.received_grid_layout_0) self.received.addTab(self.received_widget_0, 'Constellation') self.received_widget_1 = Qt.QWidget() self.received_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.received_widget_1) self.received_grid_layout_1 = Qt.QGridLayout() self.received_layout_1.addLayout(self.received_grid_layout_1) self.received.addTab(self.received_widget_1, 'Symbols') self.top_grid_layout.addWidget(self.received, 2, 0, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(2, 3)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 1)] self._phase_bw_range = Range(0.0, 1.0, 0.01, 6.28 / 100.0, 200) self._phase_bw_win = RangeWidget(self._phase_bw_range, self.set_phase_bw, 'Phase: Bandwidth', "slider", float) self.controls_grid_layout_1.addWidget(self._phase_bw_win, 0, 2, 1, 1) [self.controls_grid_layout_1.setRowStretch(r, 1) for r in range(0, 1)] [ self.controls_grid_layout_1.setColumnStretch(c, 1) for c in range(2, 3) ] self._noise_volt_range = Range(0, 1, 0.01, 0.0001, 200) self._noise_volt_win = RangeWidget(self._noise_volt_range, self.set_noise_volt, 'Noise Voltage', "counter_slider", float) self.controls_grid_layout_0.addWidget(self._noise_volt_win, 0, 0, 1, 1) [self.controls_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)] [ self.controls_grid_layout_0.setColumnStretch(c, 1) for c in range(0, 1) ] self._freq_offset_range = Range(-0.1, 0.1, 0.001, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Frequency Offset', "counter_slider", float) self.controls_grid_layout_0.addWidget(self._freq_offset_win, 0, 1, 1, 1) [self.controls_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)] [ self.controls_grid_layout_0.setColumnStretch(c, 1) for c in range(1, 2) ] self._eq_gain_range = Range(0.0, 0.1, 0.001, 0.01, 200) self._eq_gain_win = RangeWidget(self._eq_gain_range, self.set_eq_gain, 'Equalizer: rate', "slider", float) self.controls_grid_layout_1.addWidget(self._eq_gain_win, 0, 1, 1, 1) [self.controls_grid_layout_1.setRowStretch(r, 1) for r in range(0, 1)] [ self.controls_grid_layout_1.setColumnStretch(c, 1) for c in range(1, 2) ] self._delay_range = Range(0, 200, 1, 58, 200) self._delay_win = RangeWidget(self._delay_range, self.set_delay, 'Delay', "counter_slider", float) self.top_grid_layout.addWidget(self._delay_win, 1, 0, 1, 1) [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, 1)] self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Input mins Output stream", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1.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_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 500, #size samp_rate, #samp_rate '', #name 2 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 2) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['Rx Bits', 'Tx Bits', '', '', '', '', '', '', '', ''] 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: self.qtgui_time_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 2, 1, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(2, 3)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(1, 2)] self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 500, #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, 4) 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 = ['Symbols', '', '', '', '', '', '', '', '', ''] 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.received_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0, 0, 1, 1) [self.received_grid_layout_1.setRowStretch(r, 1) for r in range(0, 1)] [ self.received_grid_layout_1.setColumnStretch(c, 1) for c in range(0, 1) ] self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #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.received_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win, 0, 0, 1, 1) [self.received_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)] [ self.received_grid_layout_0.setColumnStretch(c, 1) for c in range(0, 1) ] self.myblocks_qpsk_demod_v2_0 = myblocks.qpsk_demod_v2(0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, timing_loop_bw, (rrc_taps), nfilts, nfilts / 2, 1.5, 2) self.digital_map_bb_0 = digital.map_bb(([0, 3, 2, 1])) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( phase_bw, arity, False) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc( 15, 1, eq_gain, 2) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_volt, frequency_offset=freq_offset, epsilon=time_offset, taps=(taps), noise_seed=0, block_tags=False) self.blocks_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 2, 8, "", False, gr.GR_LSB_FIRST) self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, int(delay)) self.blocks_char_to_float_0_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 256, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_unpack_k_bits_bb_0_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_char_to_float_0_0_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0_0, 0), (self.blocks_char_to_float_0_0_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.myblocks_qpsk_demod_v2_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.myblocks_qpsk_demod_v2_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.myblocks_qpsk_demod_v2_0, 0), (self.digital_map_bb_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.samp_rate = samp_rate = 960000 ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'Orig') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'Mod') self.top_layout.addWidget(self.tab) self.qtgui_sink_x_1 = qtgui.sink_f( 1024, #fftsize firdes.WIN_HAMMING, #wintype 0, #fc samp_rate, #bw "", #name True, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_1.set_update_time(1.0/10) self._qtgui_sink_x_1_win = sip.wrapinstance(self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget) self.tab_layout_1.addWidget(self._qtgui_sink_x_1_win) self.qtgui_sink_x_1.enable_rf_freq(False) self.m = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0.8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True) self.blocks_multiply_xx_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.analog_sig_source_x_1 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 100000, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 10000, 1, 0) self.analog_const_source_x_1 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 1) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_sink_x_1, 0)) self.connect((self.m, 0), (self.blocks_multiply_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "AM_Demod") Qt.QWidget.__init__(self) self.setWindowTitle("AM_Demod") 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", "AM_Demod") 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.seek = seek = 0 self.freq = freq = 415 self.vol = vol = 1 self.variable_qtgui_label_0 = variable_qtgui_label_0 = ((freq * 1e6) + (seek * 1e3)) self.samp_rate = samp_rate = 2e6 self.rf_gain = rf_gain = 60 self.passband = passband = 10 self.decimate = decimate = 10 self.audio_low_cutoff = audio_low_cutoff = 250 self.audio_high_cutoff = audio_high_cutoff = 1500 ################################################## # Blocks ################################################## self.Tabs = Qt.QTabWidget() self.Tabs_widget_0 = Qt.QWidget() self.Tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.Tabs_widget_0) self.Tabs_grid_layout_0 = Qt.QGridLayout() self.Tabs_layout_0.addLayout(self.Tabs_grid_layout_0) self.Tabs.addTab(self.Tabs_widget_0, 'input') self.Tabs_widget_1 = Qt.QWidget() self.Tabs_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.Tabs_widget_1) self.Tabs_grid_layout_1 = Qt.QGridLayout() self.Tabs_layout_1.addLayout(self.Tabs_grid_layout_1) self.Tabs.addTab(self.Tabs_widget_1, 'output') self.top_layout.addWidget(self.Tabs) self._vol_range = Range(0, 100, 1, 1, 100) self._vol_win = RangeWidget(self._vol_range, self.set_vol, 'volume', "counter_slider", float) self.top_layout.addWidget(self._vol_win) self._seek_range = Range(-100, 500, 0.5, 0, 100) self._seek_win = RangeWidget(self._seek_range, self.set_seek, 'Seek in kHz', "counter_slider", float) self.Tabs_grid_layout_0.addWidget(self._seek_win, 2, 2, 1, 1) [self.Tabs_grid_layout_0.setRowStretch(r, 1) for r in range(2, 3)] [self.Tabs_grid_layout_0.setColumnStretch(c, 1) for c in range(2, 3)] self._rf_gain_range = Range(10, 70, 1, 60, 100) self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain, 'RF Gain dB', "counter_slider", int) self.Tabs_grid_layout_0.addWidget(self._rf_gain_win, 0, 2, 1, 1) [self.Tabs_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)] [self.Tabs_grid_layout_0.setColumnStretch(c, 1) for c in range(2, 3)] self._passband_range = Range(3, 30, 1, 10, 100) self._passband_win = RangeWidget(self._passband_range, self.set_passband, 'Filter kHz', "counter_slider", int) self.Tabs_grid_layout_0.addWidget(self._passband_win, 4, 2, 1, 1) [self.Tabs_grid_layout_0.setRowStretch(r, 1) for r in range(4, 5)] [self.Tabs_grid_layout_0.setColumnStretch(c, 1) for c in range(2, 3)] self._freq_range = Range(24, 1766, 0.5, 415, 100) self._freq_win = RangeWidget(self._freq_range, self.set_freq, 'Frequency in MHz', "counter_slider", float) self.Tabs_grid_layout_0.addWidget(self._freq_win, 1, 2, 1, 1) [self.Tabs_grid_layout_0.setRowStretch(r, 1) for r in range(1, 2)] [self.Tabs_grid_layout_0.setColumnStretch(c, 1) for c in range(2, 3)] self._audio_low_cutoff_range = Range(20, 400, 1, 250, 200) self._audio_low_cutoff_win = RangeWidget(self._audio_low_cutoff_range, self.set_audio_low_cutoff, 'Audio low Cutoff Hz', "counter_slider", float) self.Tabs_grid_layout_1.addWidget(self._audio_low_cutoff_win, 2, 1, 1, 1) [self.Tabs_grid_layout_1.setRowStretch(r, 1) for r in range(2, 3)] [self.Tabs_grid_layout_1.setColumnStretch(c, 1) for c in range(1, 2)] self._audio_high_cutoff_range = Range(500, 20000, 1, 1500, 200) self._audio_high_cutoff_win = RangeWidget( self._audio_high_cutoff_range, self.set_audio_high_cutoff, 'Audio high Cutoff Hz', "counter_slider", float) self.Tabs_grid_layout_1.addWidget(self._audio_high_cutoff_win, 1, 1, 1, 1) [self.Tabs_grid_layout_1.setRowStretch(r, 1) for r in range(1, 2)] [self.Tabs_grid_layout_1.setColumnStretch(c, 1) for c in range(1, 2)] 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: eng_notation.num_to_str( x) self._variable_qtgui_label_0_tool_bar.addWidget( Qt.QLabel("Frequency" + ": ")) 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.Tabs_grid_layout_0.addWidget( self._variable_qtgui_label_0_tool_bar, 3, 2, 1, 1) [self.Tabs_grid_layout_0.setRowStretch(r, 1) for r in range(3, 4)] [self.Tabs_grid_layout_0.setColumnStretch(c, 1) for c in range(2, 3)] 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 * 1e6) + (seek * 1e3)), 0) self.rtlsdr_source_0.set_freq_corr(80, 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(True, 0) self.rtlsdr_source_0.set_gain(rf_gain, 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(2e6, 0) self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=48, decimation=200, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decimate, taps=None, fractional_bw=None, ) 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(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(True) 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.Tabs_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0, 1, 1, 1) [self.Tabs_grid_layout_1.setRowStretch(r, 1) for r in range(0, 1)] [self.Tabs_grid_layout_1.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 freq + (seek * 1e-3), #fc 50000, #bw "Filter", #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.2) 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.Tabs_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 5, 2, 1, 1) [self.Tabs_grid_layout_0.setRowStretch(r, 1) for r in range(5, 6)] [self.Tabs_grid_layout_0.setColumnStretch(c, 1) for c in range(2, 3)] self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate / decimate, passband * 1000, 200, firdes.WIN_HAMMING, 6.76)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( ((vol / 100) * 100, )) self.band_pass_filter_0 = filter.fir_filter_fff( 1, firdes.band_pass(1, 48e3, audio_low_cutoff, audio_high_cutoff, 10, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0 = audio.sink(48000, '', True) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=samp_rate / decimate, audio_decim=1, audio_pass=20000, audio_stop=21000, ) self.Output_Frequency_graph = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 48e3, #bw "Output Frequency Graph", #name 1 #number of inputs ) self.Output_Frequency_graph.set_update_time(0.10) self.Output_Frequency_graph.set_y_axis(-100, -20) self.Output_Frequency_graph.set_y_label('Relative Gain', 'dB') self.Output_Frequency_graph.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.Output_Frequency_graph.enable_autoscale(False) self.Output_Frequency_graph.enable_grid(False) self.Output_Frequency_graph.set_fft_average(0.2) self.Output_Frequency_graph.enable_axis_labels(True) self.Output_Frequency_graph.enable_control_panel(True) if not True: self.Output_Frequency_graph.disable_legend() if "float" == "float" or "float" == "msg_float": self.Output_Frequency_graph.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.Output_Frequency_graph.set_line_label( i, "Data {0}".format(i)) else: self.Output_Frequency_graph.set_line_label(i, labels[i]) self.Output_Frequency_graph.set_line_width(i, widths[i]) self.Output_Frequency_graph.set_line_color(i, colors[i]) self.Output_Frequency_graph.set_line_alpha(i, alphas[i]) self._Output_Frequency_graph_win = sip.wrapinstance( self.Output_Frequency_graph.pyqwidget(), Qt.QWidget) self.Tabs_grid_layout_1.addWidget(self._Output_Frequency_graph_win, 0, 0, 3, 1) [self.Tabs_grid_layout_1.setRowStretch(r, 1) for r in range(0, 3)] [self.Tabs_grid_layout_1.setColumnStretch(c, 1) for c in range(0, 1)] self.Input_Waterfall = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype ((freq * 1e6) + (seek * 1e3)), #fc samp_rate / decimate, #bw "", #name 1 #number of inputs ) self.Input_Waterfall.set_update_time(0.10) self.Input_Waterfall.enable_grid(False) self.Input_Waterfall.enable_axis_labels(True) if not True: self.Input_Waterfall.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.Input_Waterfall.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.Input_Waterfall.set_line_label(i, "Data {0}".format(i)) else: self.Input_Waterfall.set_line_label(i, labels[i]) self.Input_Waterfall.set_color_map(i, colors[i]) self.Input_Waterfall.set_line_alpha(i, alphas[i]) self.Input_Waterfall.set_intensity_range(-140, 10) self._Input_Waterfall_win = sip.wrapinstance( self.Input_Waterfall.pyqwidget(), Qt.QWidget) self.Tabs_grid_layout_0.addWidget(self._Input_Waterfall_win, 5, 0, 1, 2) [self.Tabs_grid_layout_0.setRowStretch(r, 1) for r in range(5, 6)] [self.Tabs_grid_layout_0.setColumnStretch(c, 1) for c in range(0, 2)] self.Input = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype ((freq * 1e6) + (seek * 1e3)), #fc samp_rate / decimate, #bw "Input Frequency Graph", #name 1 #number of inputs ) self.Input.set_update_time(0.05) self.Input.set_y_axis(-140, 10) self.Input.set_y_label('Relative Gain', 'dB') self.Input.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.Input.enable_autoscale(False) self.Input.enable_grid(True) self.Input.set_fft_average(0.2) self.Input.enable_axis_labels(True) self.Input.enable_control_panel(True) if not True: self.Input.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.Input.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.Input.set_line_label(i, "Data {0}".format(i)) else: self.Input.set_line_label(i, labels[i]) self.Input.set_line_width(i, widths[i]) self.Input.set_line_color(i, colors[i]) self.Input.set_line_alpha(i, alphas[i]) self._Input_win = sip.wrapinstance(self.Input.pyqwidget(), Qt.QWidget) self.Tabs_grid_layout_0.addWidget(self._Input_win, 0, 0, 4, 2) [self.Tabs_grid_layout_0.setRowStretch(r, 1) for r in range(0, 4)] [self.Tabs_grid_layout_0.setColumnStretch(c, 1) for c in range(0, 2)] ################################################## # Connections ################################################## self.connect((self.analog_am_demod_cf_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.band_pass_filter_0, 0), (self.Output_Frequency_graph, 0)) self.connect((self.band_pass_filter_0, 0), (self.audio_sink_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.Input, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.Input_Waterfall, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.rational_resampler_xxx_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") 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.bb_decim = bb_decim = 4 self.freq_offset = freq_offset = 250000 self.freq = freq = 90.9e6 self.baseband_rate = baseband_rate = samp_rate / bb_decim self.audio_decim = audio_decim = 5 self.xlate_bandwidth = xlate_bandwidth = 100000 self.gain = gain = 20 self.freq_tune = freq_tune = freq - freq_offset self.audio_rate = audio_rate = 48000 self.audio_decim_rate = audio_decim_rate = baseband_rate / audio_decim ################################################## # Blocks ################################################## self.nb = Qt.QTabWidget() self.nb_widget_0 = Qt.QWidget() self.nb_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.nb_widget_0) self.nb_grid_layout_0 = Qt.QGridLayout() self.nb_layout_0.addLayout(self.nb_grid_layout_0) self.nb.addTab(self.nb_widget_0, 'Baseband') self.nb_widget_1 = Qt.QWidget() self.nb_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.nb_widget_1) self.nb_grid_layout_1 = Qt.QGridLayout() self.nb_layout_1.addLayout(self.nb_grid_layout_1) self.nb.addTab(self.nb_widget_1, 'Demod') self.nb_widget_2 = Qt.QWidget() self.nb_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.nb_widget_2) self.nb_grid_layout_2 = Qt.QGridLayout() self.nb_layout_2.addLayout(self.nb_grid_layout_2) self.nb.addTab(self.nb_widget_2, 'L+R') self.nb_widget_3 = Qt.QWidget() self.nb_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.nb_widget_3) self.nb_grid_layout_3 = Qt.QGridLayout() self.nb_layout_3.addLayout(self.nb_grid_layout_3) self.nb.addTab(self.nb_widget_3, 'Subcarrier') self.top_grid_layout.addWidget(self.nb) self._gain_range = Range(0, 75, 1, 20, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, 'gain', "counter_slider", float) self.top_grid_layout.addWidget(self._gain_win) self.qtgui_waterfall_sink_x_1_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc baseband_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_1_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_1_0.enable_grid(False) self.qtgui_waterfall_sink_x_1_0.enable_axis_labels(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 range(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_1_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_1_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_1_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_1_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_1_0.pyqwidget(), Qt.QWidget) self.nb_layout_3.addWidget(self._qtgui_waterfall_sink_x_1_0_win) self.qtgui_waterfall_sink_x_1 = qtgui.waterfall_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_1.set_update_time(0.10) self.qtgui_waterfall_sink_x_1.enable_grid(False) self.qtgui_waterfall_sink_x_1.enable_axis_labels(True) self.qtgui_waterfall_sink_x_1.set_plot_pos_half(not True) labels = ['Demod', '', '', '', '', '', '', '', '', ''] 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 range(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_1.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_1.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_1.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_1.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_1_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_1.pyqwidget(), Qt.QWidget) self.nb_layout_1.addWidget(self._qtgui_waterfall_sink_x_1_win) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_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) 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 range(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.nb_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) self.qtgui_freq_sink_x_1.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 range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.nb_layout_2.addWidget(self._qtgui_freq_sink_x_1_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc baseband_rate, #bw "", #name 1) 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) 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 range(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.nb_layout_1.addWidget(self._qtgui_freq_sink_x_0_win) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') 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(freq_tune, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_gain(gain, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.freq_xlating_fir_filter_xxx_1 = filter.freq_xlating_fir_filter_fcc( audio_decim, firdes.low_pass(2500.0, baseband_rate, 3e3, 2e3, firdes.WIN_HAMMING), 67e3, baseband_rate) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 1, firdes.low_pass(1, samp_rate, xlate_bandwidth, 100000), freq_offset, samp_rate) self._freq_range = Range(88.5e6, 108e6, 200e3, 90.9e6, 200) self._freq_win = RangeWidget(self._freq_range, self.set_freq, 'freq', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_win) self.fir_filter_xxx_1 = filter.fir_filter_fff( audio_decim, firdes.low_pass(1.0, baseband_rate, 13e3, 3e3, firdes.WIN_HAMMING)) self.fir_filter_xxx_1.declare_sample_delay(0) self.audio_sink_0 = audio.sink(audio_rate, '', True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=samp_rate, audio_decimation=bb_decim, ) self.analog_fm_demod_cf_0 = analog.fm_demod_cf( channel_rate=audio_decim_rate, audio_decim=1, deviation=5000, audio_pass=15000, audio_stop=16000, gain=1.0, tau=75e-6, ) ################################################## # Connections ################################################## self.connect((self.analog_fm_demod_cf_0, 0), (self.audio_sink_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.fir_filter_xxx_1, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.freq_xlating_fir_filter_xxx_1, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.qtgui_waterfall_sink_x_1, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.analog_fm_demod_cf_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.qtgui_waterfall_sink_x_1_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self, fft_size=1024, freq=89.5, gain=32, samp_rate=1000, update_rate=.03): gr.top_block.__init__(self, "Pluto FFT") Qt.QWidget.__init__(self) self.setWindowTitle("Pluto FFT") 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", "pluto_fft") 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 ################################################## # Parameters ################################################## self.fft_size = fft_size self.freq = freq self.gain = gain self.samp_rate = samp_rate self.update_rate = update_rate ################################################## # Variables ################################################## self.samp_rate_ = samp_rate_ = samp_rate self.gain_ = gain_ = gain self.freq_c = freq_c = freq ################################################## # Blocks ################################################## self._samp_rate__tool_bar = Qt.QToolBar(self) self._samp_rate__tool_bar.addWidget(Qt.QLabel('Passband Bandwidth (kHz)' + ": ")) 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, 3, 2, 1, 2) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self._gain__range = Range(0, 100, 1, gain, 200) self._gain__win = RangeWidget(self._gain__range, self.set_gain_, 'RX Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._gain__win, 2, 0, 1, 4) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self._freq_c_tool_bar = Qt.QToolBar(self) self._freq_c_tool_bar.addWidget(Qt.QLabel('Carrier Frequency (MHz)' + ": ")) self._freq_c_line_edit = Qt.QLineEdit(str(self.freq_c)) self._freq_c_tool_bar.addWidget(self._freq_c_line_edit) self._freq_c_line_edit.returnPressed.connect( lambda: self.set_freq_c(eng_notation.str_to_num(str(self._freq_c_line_edit.text())))) self.top_grid_layout.addWidget(self._freq_c_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.display = Qt.QTabWidget() self.display_widget_0 = Qt.QWidget() self.display_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.display_widget_0) self.display_grid_layout_0 = Qt.QGridLayout() self.display_layout_0.addLayout(self.display_grid_layout_0) self.display.addTab(self.display_widget_0, 'Spectrum') self.display_widget_1 = Qt.QWidget() self.display_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.display_widget_1) self.display_grid_layout_1 = Qt.QGridLayout() self.display_layout_1.addLayout(self.display_grid_layout_1) self.display.addTab(self.display_widget_1, 'Waterfall') self.display_widget_2 = Qt.QWidget() self.display_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.display_widget_2) self.display_grid_layout_2 = Qt.QGridLayout() self.display_layout_2.addLayout(self.display_grid_layout_2) self.display.addTab(self.display_widget_2, 'Scope') self.top_grid_layout.addWidget(self.display, 0, 0, 1, 4) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc samp_rate_*1000, #bw '', #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(update_rate) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(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 range(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.display_grid_layout_1.addWidget(self._qtgui_waterfall_sink_x_0_win, 0, 0, 1, 4) for r in range(0, 1): self.display_grid_layout_1.setRowStretch(r, 1) for c in range(0, 4): self.display_grid_layout_1.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate_*1000, #samp_rate '', #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(update_rate) 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(True) 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(True) self.qtgui_time_sink_x_0.enable_stem_plot(False) 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', '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(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.display_grid_layout_2.addWidget(self._qtgui_time_sink_x_0_win, 0, 0, 1, 4) for r in range(0, 1): self.display_grid_layout_2.setRowStretch(r, 1) for c in range(0, 4): self.display_grid_layout_2.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( fft_size, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc samp_rate_*1000, #bw '', #name 1 ) self.qtgui_freq_sink_x_0.set_update_time(update_rate) 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(True) 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(True) self.qtgui_freq_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", "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 range(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.display_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 1, 4) for r in range(0, 1): self.display_grid_layout_0.setRowStretch(r, 1) for c in range(0, 4): self.display_grid_layout_0.setColumnStretch(c, 1) self.iio_pluto_source_0 = iio.pluto_source('', int(freq_c*1e6), int(samp_rate_*1000), 20000000, 32768, True, True, True, 'manual', gain_, '', True) ################################################## # Connections ################################################## self.connect((self.iio_pluto_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.iio_pluto_source_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.iio_pluto_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Lab 5 Task 3a") Qt.QWidget.__init__(self) self.setWindowTitle("Lab 5 Task 3a") 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", "lab5_task3a") 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.sps = sps = 4 self.nfilts = nfilts = 32 self.ntaps = ntaps = 11 * nfilts * sps self.excess_bw = excess_bw = 0.45 self.timing_bw = timing_bw = 2 * pi / 100 self.samp_rate = samp_rate = 25000 self.rx_taps = rx_taps = firdes.root_raised_cosine( nfilts, nfilts * sps, 1.0, excess_bw, ntaps) self.freq_bw = freq_bw = 2 * pi / 100 self.fll_ntaps = fll_ntaps = 55 ################################################## # Blocks ################################################## self.tab_widget = Qt.QTabWidget() self.tab_widget_widget_0 = Qt.QWidget() self.tab_widget_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_widget_0) self.tab_widget_grid_layout_0 = Qt.QGridLayout() self.tab_widget_layout_0.addLayout(self.tab_widget_grid_layout_0) self.tab_widget.addTab(self.tab_widget_widget_0, 'Complex Baseband') self.tab_widget_widget_1 = Qt.QWidget() self.tab_widget_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_widget_1) self.tab_widget_grid_layout_1 = Qt.QGridLayout() self.tab_widget_layout_1.addLayout(self.tab_widget_grid_layout_1) self.tab_widget.addTab(self.tab_widget_widget_1, 'Before Costas') self.tab_widget_widget_2 = Qt.QWidget() self.tab_widget_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_widget_2) self.tab_widget_grid_layout_2 = Qt.QGridLayout() self.tab_widget_layout_2.addLayout(self.tab_widget_grid_layout_2) self.tab_widget.addTab(self.tab_widget_widget_2, 'After Costas') self.top_grid_layout.addWidget(self.tab_widget) self.qtgui_sink_x_0_0_0_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw 'Output of Pulse Shape Filter', #name True, #plotfreq True, #plotwaterfall True, #plottime True #plotconst ) self.qtgui_sink_x_0_0_0_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.qtgui_sink_x_0_0_0_0.enable_rf_freq(False) self.tab_widget_layout_2.addWidget(self._qtgui_sink_x_0_0_0_0_win) self.qtgui_sink_x_0_0_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw 'Output of Pulse Shape Filter', #name True, #plotfreq True, #plotwaterfall True, #plottime True #plotconst ) self.qtgui_sink_x_0_0_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.qtgui_sink_x_0_0_0.enable_rf_freq(False) self.tab_widget_layout_1.addWidget(self._qtgui_sink_x_0_0_0_win) self.qtgui_sink_x_0_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate * sps, #bw 'Output of Pulse Shape Filter', #name True, #plotfreq True, #plotwaterfall True, #plottime True #plotconst ) self.qtgui_sink_x_0_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_0_win = sip.wrapinstance( self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget) self.qtgui_sink_x_0_0.enable_rf_freq(False) self.tab_widget_layout_0.addWidget(self._qtgui_sink_x_0_0_win) self.pfb_arb_resampler_xxx_0_0_0 = pfb.arb_resampler_ccf(sps, taps=rx_taps, flt_size=32) self.pfb_arb_resampler_xxx_0_0_0.declare_sample_delay(0) self.pfb_arb_resampler_xxx_0_0 = pfb.arb_resampler_ccf(sps, taps=rx_taps, flt_size=32) self.pfb_arb_resampler_xxx_0_0.declare_sample_delay(0) self.low_pass_filter_1 = filter.fir_filter_fff( 5, firdes.low_pass(1, 500000, 100000, 10000, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_fff( 5, firdes.low_pass(1, 500000, 100000, 10000, firdes.WIN_HAMMING, 6.76)) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( 4, timing_bw, rx_taps, 32, 16, 1.5, 1) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( freq_bw, 4, False) self.blocks_throttle_0_0_0_1 = blocks.throttle( gr.sizeof_gr_complex * 1, samp_rate * sps, True) self.blocks_throttle_0_0_0_0 = blocks.throttle( gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_throttle_0_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_float * 1, '/home/ipsit/Documents/EE 340/Lab 5/input2.bin', True, 0, 0) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.analog_sig_source_x_0_0 = analog.sig_source_f( 500000, analog.GR_SIN_WAVE, 1000, 1, 0, 0) self.analog_sig_source_x_0 = analog.sig_source_f( 500000, analog.GR_COS_WAVE, 1000, 1, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.blocks_file_source_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_file_source_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_throttle_0_0_0_1, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.blocks_throttle_0_0_0, 0), (self.qtgui_sink_x_0_0_0, 0)) self.connect((self.blocks_throttle_0_0_0_0, 0), (self.qtgui_sink_x_0_0_0_0, 0)) self.connect((self.blocks_throttle_0_0_0_1, 0), (self.qtgui_sink_x_0_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.pfb_arb_resampler_xxx_0_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.pfb_arb_resampler_xxx_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.pfb_arb_resampler_xxx_0_0, 0), (self.blocks_throttle_0_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0_0_0, 0), (self.blocks_throttle_0_0_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Lab 4") Qt.QWidget.__init__(self) self.setWindowTitle("Lab 4") 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", "lab4") 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.echo_gain_iir = echo_gain_iir = 0 self.delay_limit = delay_limit = 64 self.delay_iir = delay_iir = 1 self.sps = sps = 4 self.pn6 = pn6 = [1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1 -1 -1] self.pn5 = pn5 = [1,-1,1,-1,1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1] self.iir_taps_2 = iir_taps_2 = np.concatenate( ([1], np.zeros(int(delay_iir-1)),[-echo_gain_iir],np.zeros(int(delay_limit-delay_iir))) ) self.h_filt = h_filt = [1,1,1,1] self.freqc = freqc = 900 self.samp_rate = samp_rate = 1000 self.pn6_up = pn6_up = sp.upfirdn( h_filt, pn6, sps ) self.pn5_up = pn5_up = sp.upfirdn( h_filt, pn5, sps ) self.phase_shift = phase_shift = 1 self.lw = lw = 2 self.iir_taps = iir_taps = iir_taps_2 self.gain_ = gain_ = 0.5 self.freqc_ = freqc_ = freqc self.fps = fps = 30 self.fo = fo = 800 self.equalize_on = equalize_on = 0 self.echo_gain = echo_gain = 0 self.delay = delay = 0 self.const_qpsk = const_qpsk = digital.constellation_calcdist(digital.psk_4()[0], digital.psk_4()[1], 4, 1).base() self.const_bpsk = const_bpsk = digital.constellation_calcdist(digital.psk_2()[0], digital.psk_2()[1], 2, 1).base() self.bw = bw = 1 self.buff_size = buff_size = 32768 self.axis = axis = 2 self.PLL_ON = PLL_ON = 0 ################################################## # Blocks ################################################## self.tab0 = Qt.QTabWidget() self.tab0_widget_0 = Qt.QWidget() self.tab0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_0) self.tab0_grid_layout_0 = Qt.QGridLayout() self.tab0_layout_0.addLayout(self.tab0_grid_layout_0) self.tab0.addTab(self.tab0_widget_0, 'Cross-Correlation') self.tab0_widget_1 = Qt.QWidget() self.tab0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_1) self.tab0_grid_layout_1 = Qt.QGridLayout() self.tab0_layout_1.addLayout(self.tab0_grid_layout_1) self.tab0.addTab(self.tab0_widget_1, 'Spectrum') self.top_grid_layout.addWidget(self.tab0, 0, 0, 10, 2) for r in range(0, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) _phase_shift_check_box = Qt.QCheckBox('PI Phase Shift') self._phase_shift_choices = {True: 1, False: 0} self._phase_shift_choices_inv = dict((v,k) for k,v in self._phase_shift_choices.items()) self._phase_shift_callback = lambda i: Qt.QMetaObject.invokeMethod(_phase_shift_check_box, "setChecked", Qt.Q_ARG("bool", self._phase_shift_choices_inv[i])) self._phase_shift_callback(self.phase_shift) _phase_shift_check_box.stateChanged.connect(lambda i: self.set_phase_shift(self._phase_shift_choices[bool(i)])) self.top_grid_layout.addWidget(_phase_shift_check_box, 12, 1, 1, 1) for r in range(12, 13): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._gain__range = Range(0.1, 1, 0.01, 0.5, 200) self._gain__win = RangeWidget(self._gain__range, self.set_gain_, 'Gain (Amp)', "counter_slider", float) self.top_grid_layout.addWidget(self._gain__win, 10, 1, 1, 1) for r in range(10, 11): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._freqc__range = Range(70, 6000, .01, freqc, 200) self._freqc__win = RangeWidget(self._freqc__range, self.set_freqc_, 'Carrier (MHz)', "counter_slider", float) self.top_grid_layout.addWidget(self._freqc__win, 10, 0, 1, 1) for r in range(10, 11): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._fo_range = Range(-10000, 10000, 1, 800, 200) self._fo_win = RangeWidget(self._fo_range, self.set_fo, 'Frequency Offset (Hz)', "counter_slider", float) self.top_grid_layout.addWidget(self._fo_win, 12, 0, 1, 1) for r in range(12, 13): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) # Create the options list self._equalize_on_options = (0, 1, ) # Create the labels list self._equalize_on_labels = ('Equalizer Off', 'Equalizer On', ) # Create the combo box self._equalize_on_tool_bar = Qt.QToolBar(self) self._equalize_on_tool_bar.addWidget(Qt.QLabel('Equalizer Select' + ": ")) self._equalize_on_combo_box = Qt.QComboBox() self._equalize_on_tool_bar.addWidget(self._equalize_on_combo_box) for _label in self._equalize_on_labels: self._equalize_on_combo_box.addItem(_label) self._equalize_on_callback = lambda i: Qt.QMetaObject.invokeMethod(self._equalize_on_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._equalize_on_options.index(i))) self._equalize_on_callback(self.equalize_on) self._equalize_on_combo_box.currentIndexChanged.connect( lambda i: self.set_equalize_on(self._equalize_on_options[i])) # Create the radio buttons self.top_grid_layout.addWidget(self._equalize_on_tool_bar, 13, 0, 1, 1) for r in range(13, 14): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._echo_gain_range = Range(0, 1, 0.01, 0, 200) self._echo_gain_win = RangeWidget(self._echo_gain_range, self.set_echo_gain, 'Echo Path Gain (A)', "counter_slider", float) self.top_grid_layout.addWidget(self._echo_gain_win, 11, 0, 1, 1) for r in range(11, 12): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._delay_range = Range(0, delay_limit, 1, 0, 200) self._delay_win = RangeWidget(self._delay_range, self.set_delay, 'Delay (samples)', "counter_slider", float) self.top_grid_layout.addWidget(self._delay_win, 11, 1, 1, 1) for r in range(11, 12): 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._PLL_ON_options = (0, 1, ) # Create the labels list self._PLL_ON_labels = ('PLL ON', 'PLL OFF', ) # Create the combo box self._PLL_ON_tool_bar = Qt.QToolBar(self) self._PLL_ON_tool_bar.addWidget(Qt.QLabel('PLL Select' + ": ")) self._PLL_ON_combo_box = Qt.QComboBox() self._PLL_ON_tool_bar.addWidget(self._PLL_ON_combo_box) for _label in self._PLL_ON_labels: self._PLL_ON_combo_box.addItem(_label) self._PLL_ON_callback = lambda i: Qt.QMetaObject.invokeMethod(self._PLL_ON_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._PLL_ON_options.index(i))) self._PLL_ON_callback(self.PLL_ON) self._PLL_ON_combo_box.currentIndexChanged.connect( lambda i: self.set_PLL_ON(self._PLL_ON_options[i])) # Create the radio buttons self.top_grid_layout.addWidget(self._PLL_ON_tool_bar, 13, 1, 1, 1) for r in range(13, 14): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 4096, #size samp_rate*1000, #samp_rate "Cross Correlation", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(True) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) labels = ['Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10'] 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_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tab0_grid_layout_0.addWidget(self._qtgui_time_sink_x_0_0_win, 5, 0, 5, 1) for r in range(5, 10): self.tab0_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.tab0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate*1e3, #bw "", #name 1 ) self.qtgui_freq_sink_x_0.set_update_time(1/fps) 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(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(True) labels = ['In-Phase', 'Quadrature', '', '', '', '', '', '', '', ''] 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 range(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.tab0_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_win, 5, 0, 5, 1) for r in range(5, 10): self.tab0_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.tab0_grid_layout_1.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0.set_processor_affinity([0]) self.interp_fir_filter_xxx_1_0 = filter.interp_fir_filter_ccc(sps, (1,1,1,1)) self.interp_fir_filter_xxx_1_0.declare_sample_delay(0) self.iir_filter_xxx_0 = filter.iir_filter_ccz([(1)], iir_taps, True) self.iio_pluto_source_0 = iio.pluto_source(epy_module_0.RX, int(freqc_*1e6), int(samp_rate*1000), 20000000, buff_size, True, True, True, 'manual', 32, '', True) self.iio_pluto_sink_0 = iio.pluto_sink(epy_module_0.TX, int(freqc_*1e6), int(samp_rate*1000), 20000000, buff_size, False, 10.0, '', True) self._echo_gain_iir_range = Range(0, 1, 0.01, 0, 200) self._echo_gain_iir_win = RangeWidget(self._echo_gain_iir_range, self.set_echo_gain_iir, 'Equalizer Gain (A)', "counter_slider", float) self.top_grid_layout.addWidget(self._echo_gain_iir_win, 14, 0, 1, 1) for r in range(14, 15): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.digital_glfsr_source_x_0 = digital.glfsr_source_b(6, True, 0, 1) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(3.14/100, 2, False) self.digital_corr_est_cc_0 = digital.corr_est_cc(pn6_up, sps, 0, 0.7, digital.THRESHOLD_ABSOLUTE) self.digital_chunks_to_symbols_xx_1 = digital.chunks_to_symbols_bc(const_bpsk.points(), 1) self._delay_iir_range = Range(1, delay_limit, 1, 1, 200) self._delay_iir_win = RangeWidget(self._delay_iir_range, self.set_delay_iir, 'Equalizer Delay (samples)', "counter_slider", float) self.top_grid_layout.addWidget(self._delay_iir_win, 14, 1, 1, 1) for r in range(14, 15): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.blocks_tag_gate_0_0_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0_0_0.set_single_key("time_est") self.blocks_tag_gate_0_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0_0.set_single_key("corr_est") self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0.set_single_key("amp_est") self.blocks_selector_0_0 = blocks.selector(gr.sizeof_gr_complex*1,equalize_on,0) self.blocks_selector_0_0.set_enabled(True) self.blocks_selector_0 = blocks.selector(gr.sizeof_gr_complex*1,PLL_ON,0) self.blocks_selector_0.set_enabled(True) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_cc((1/63/sps)*np.exp(1j*pi*phase_shift)) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc(echo_gain) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(gain_ ) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, delay) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate*1000, analog.GR_COS_WAVE, fo, 1, 0, 0) self.analog_agc_xx_0 = analog.agc_cc(1e-4, 1.0, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.blocks_selector_0, 1)) self.connect((self.analog_agc_xx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.iio_pluto_sink_0, 0)) self.connect((self.blocks_selector_0, 0), (self.blocks_selector_0_0, 0)) self.connect((self.blocks_selector_0, 0), (self.iir_filter_xxx_0, 0)) self.connect((self.blocks_selector_0_0, 0), (self.digital_corr_est_cc_0, 0)) self.connect((self.blocks_selector_0_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_tag_gate_0_0, 0)) self.connect((self.blocks_tag_gate_0_0, 0), (self.blocks_tag_gate_0_0_0, 0)) self.connect((self.blocks_tag_gate_0_0_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_1, 0), (self.interp_fir_filter_xxx_1_0, 0)) self.connect((self.digital_corr_est_cc_0, 1), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.digital_corr_est_cc_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_selector_0, 0)) self.connect((self.digital_glfsr_source_x_0, 0), (self.digital_chunks_to_symbols_xx_1, 0)) self.connect((self.iio_pluto_source_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.iir_filter_xxx_0, 0), (self.blocks_selector_0_0, 1)) self.connect((self.interp_fir_filter_xxx_1_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.interp_fir_filter_xxx_1_0, 0), (self.blocks_delay_0, 0))
def __init__(self): gr.top_block.__init__(self, "WWV Cross Correlation Monitor") Qt.QWidget.__init__(self) self.setWindowTitle("WWV Cross Correlation Monitor") 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", "wwv_xcorr_uhd_1") 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 = 500e3 self.rx_freq = rx_freq = 20e6 self.ns_ant_label = ns_ant_label = 'North/South' self.ew_ant_label = ew_ant_label = 'East/West' ################################################## # Blocks ################################################## self.main_tab = Qt.QTabWidget() self.main_tab_widget_0 = Qt.QWidget() self.main_tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.main_tab_widget_0) self.main_tab_grid_layout_0 = Qt.QGridLayout() self.main_tab_layout_0.addLayout(self.main_tab_grid_layout_0) self.main_tab.addTab(self.main_tab_widget_0, 'Channel') self.main_tab_widget_1 = Qt.QWidget() self.main_tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.main_tab_widget_1) self.main_tab_grid_layout_1 = Qt.QGridLayout() self.main_tab_layout_1.addLayout(self.main_tab_grid_layout_1) self.main_tab.addTab(self.main_tab_widget_1, 'Polarized') self.main_tab_widget_2 = Qt.QWidget() self.main_tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.main_tab_widget_2) self.main_tab_grid_layout_2 = Qt.QGridLayout() self.main_tab_layout_2.addLayout(self.main_tab_grid_layout_2) self.main_tab.addTab(self.main_tab_widget_2, 'Audio') self.main_tab_widget_3 = Qt.QWidget() self.main_tab_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.main_tab_widget_3) self.main_tab_grid_layout_3 = Qt.QGridLayout() self.main_tab_layout_3.addLayout(self.main_tab_grid_layout_3) self.main_tab.addTab(self.main_tab_widget_3, 'Power') self.top_grid_layout.addWidget(self.main_tab, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) 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.main_tab_grid_layout_0.addWidget(self._samp_rate_tool_bar, 5, 0, 1, 2) for r in range(5, 6): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 2): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self._rx_freq_tool_bar = Qt.QToolBar(self) self._rx_freq_tool_bar.addWidget(Qt.QLabel('Freq [Hz]' + ": ")) 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.main_tab_grid_layout_0.addWidget(self._rx_freq_tool_bar, 5, 2, 1, 2) for r in range(5, 6): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(2, 4): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("addr=10.41.1.11", "")), uhd.stream_args( cpu_format="fc32", args='', channels=list(range(0,2)), ), ) self.uhd_usrp_source_0.set_subdev_spec('A:A A:B', 0) self.uhd_usrp_source_0.set_time_source('gpsdo', 0) self.uhd_usrp_source_0.set_clock_source('gpsdo', 0) self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(rx_freq, samp_rate/2), 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(rx_freq, samp_rate/2), 1) self.uhd_usrp_source_0.set_gain(0, 1) self.uhd_usrp_source_0.set_antenna('RX2', 1) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_time_unknown_pps(uhd.time_spec()) self.qtgui_waterfall_sink_x_0_1_0 = qtgui.waterfall_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate, #bw "RHCP", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0_1_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0_1_0.enable_grid(False) self.qtgui_waterfall_sink_x_0_1_0.enable_axis_labels(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 range(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0_1_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0_1_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0_1_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0_1_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_1_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0_1_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_1.addWidget(self._qtgui_waterfall_sink_x_0_1_0_win, 4, 4, 2, 4) for r in range(4, 6): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(4, 8): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.qtgui_waterfall_sink_x_0_0_0_0 = qtgui.waterfall_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate, #bw "LHCP", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0_0_0_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0_0_0_0.enable_grid(False) self.qtgui_waterfall_sink_x_0_0_0_0.enable_axis_labels(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 range(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0_0_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0_0_0_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0_0_0_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_0_0_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_1.addWidget(self._qtgui_waterfall_sink_x_0_0_0_0_win, 6, 4, 2, 4) for r in range(6, 8): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(4, 8): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate, #bw "E/W", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0_0.enable_grid(False) self.qtgui_waterfall_sink_x_0_0.enable_axis_labels(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 range(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_1.addWidget(self._qtgui_waterfall_sink_x_0_0_win, 2, 4, 2, 4) for r in range(2, 4): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(4, 8): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate, #bw "N/S", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(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 range(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.main_tab_grid_layout_1.addWidget(self._qtgui_waterfall_sink_x_0_win, 0, 4, 2, 4) for r in range(0, 2): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(4, 8): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate, #bw "", #name 4 ) self.qtgui_freq_sink_x_0.set_update_time(0.010) 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(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) labels = ['N/S', 'E/W', '', '', '', '', '', '', '', ''] 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 range(4): 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.main_tab_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 4, 4) for r in range(0, 4): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 4): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self._ns_ant_label_tool_bar = Qt.QToolBar(self) if None: self._ns_ant_label_formatter = None else: self._ns_ant_label_formatter = lambda x: str(x) self._ns_ant_label_tool_bar.addWidget(Qt.QLabel('Antenna' + ": ")) self._ns_ant_label_label = Qt.QLabel(str(self._ns_ant_label_formatter(self.ns_ant_label))) self._ns_ant_label_tool_bar.addWidget(self._ns_ant_label_label) self.main_tab_grid_layout_0.addWidget(self._ns_ant_label_tool_bar, 0, 0, 1, 4) for r in range(0, 1): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 4): self.main_tab_grid_layout_0.setColumnStretch(c, 1) 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(rx_freq, samp_rate) self._fosphor_qt_sink_c_0_0_win = sip.wrapinstance(self.fosphor_qt_sink_c_0_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_0.addWidget(self._fosphor_qt_sink_c_0_0_win, 1, 4, 3, 4) for r in range(1, 4): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(4, 8): self.main_tab_grid_layout_0.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(rx_freq, samp_rate) self._fosphor_qt_sink_c_0_win = sip.wrapinstance(self.fosphor_qt_sink_c_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_0.addWidget(self._fosphor_qt_sink_c_0_win, 1, 0, 3, 4) for r in range(1, 4): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 4): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self._ew_ant_label_tool_bar = Qt.QToolBar(self) if None: self._ew_ant_label_formatter = None else: self._ew_ant_label_formatter = lambda x: str(x) self._ew_ant_label_tool_bar.addWidget(Qt.QLabel('Antenna' + ": ")) self._ew_ant_label_label = Qt.QLabel(str(self._ew_ant_label_formatter(self.ew_ant_label))) self._ew_ant_label_tool_bar.addWidget(self._ew_ant_label_label) self.main_tab_grid_layout_0.addWidget(self._ew_ant_label_tool_bar, 0, 4, 1, 4) for r in range(0, 1): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(4, 8): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self.blocks_multiply_const_vxx_1_0_1 = blocks.multiply_const_cc(complex(0,1)) self.blocks_multiply_const_vxx_1_0_0_0 = blocks.multiply_const_cc(complex(0,-1)) self.blocks_add_xx_0_0 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vcc(1) ################################################## # Connections ################################################## self.connect((self.blocks_add_xx_0, 0), (self.qtgui_freq_sink_x_0, 2)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_waterfall_sink_x_0_1_0, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.qtgui_freq_sink_x_0, 3)) self.connect((self.blocks_add_xx_0_0, 0), (self.qtgui_waterfall_sink_x_0_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0_0_0, 0), (self.blocks_add_xx_0_0, 1)) self.connect((self.blocks_multiply_const_vxx_1_0_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_add_xx_0_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.blocks_multiply_const_vxx_1_0_0_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.blocks_multiply_const_vxx_1_0_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.fosphor_qt_sink_c_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.fosphor_qt_sink_c_0_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.qtgui_waterfall_sink_x_0_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") 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.LO_freq = LO_freq = 9500 self.Center_freq = Center_freq = 10109 self.BW = BW = 0 self.variable_qtgui_label_0_0_0_0_0_0 = variable_qtgui_label_0_0_0_0_0_0 = ("%d" % (Center_freq)).rjust(16) self.variable_qtgui_label_0_0_0_0_0 = variable_qtgui_label_0_0_0_0_0 = ("%d" % ((Center_freq-BW))).rjust(10) self.variable_qtgui_label_0_0_0_0 = variable_qtgui_label_0_0_0_0 = ("%d" % (BW)).rjust(28) self.variable_qtgui_label_0_0_0 = variable_qtgui_label_0_0_0 = ("%d" % ((Center_freq - LO_freq))).rjust(27) self.variable_qtgui_label_0_0 = variable_qtgui_label_0_0 = ("%d" % (LO_freq)).rjust(32) self.variable_qtgui_label_0 = variable_qtgui_label_0 = ("%d" % (Center_freq)).rjust(20) self.samp_rate = samp_rate = 40000000 self.Times_To_Average = Times_To_Average = 1 self.SymmetricTaper = SymmetricTaper = 0 self.Rx_gain = Rx_gain = 0 self.Rx8_Cal = Rx8_Cal = 0 self.Rx8Gain = Rx8Gain = 127 self.Rx7_Cal = Rx7_Cal = 0 self.Rx7Gain = Rx7Gain = 127 self.Rx6_Cal = Rx6_Cal = 0 self.Rx6Gain = Rx6Gain = 127 self.Rx5_Cal = Rx5_Cal = 0 self.Rx5Gain = Rx5Gain = 127 self.Rx4_Cal = Rx4_Cal = 0 self.Rx4Gain = Rx4Gain = 127 self.Rx3_Cal = Rx3_Cal = 0 self.Rx3Gain = Rx3Gain = 127 self.Rx2_Cal = Rx2_Cal = 0 self.Rx2Gain = Rx2Gain = 127 self.Rx1_to_Rx2_Offset = Rx1_to_Rx2_Offset = 0 self.Rx1_Cal = Rx1_Cal = 0 self.Rx1Gain = Rx1Gain = 127 self.IgnorePhaseCals = IgnorePhaseCals = 0 self.BeamTaper = BeamTaper = 0 ################################################## # Blocks ################################################## self.ControlTab = Qt.QTabWidget() self.ControlTab_widget_0 = Qt.QWidget() self.ControlTab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.ControlTab_widget_0) self.ControlTab_grid_layout_0 = Qt.QGridLayout() self.ControlTab_layout_0.addLayout(self.ControlTab_grid_layout_0) self.ControlTab.addTab(self.ControlTab_widget_0, 'Pluto_Controls') self.ControlTab_widget_1 = Qt.QWidget() self.ControlTab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.ControlTab_widget_1) self.ControlTab_grid_layout_1 = Qt.QGridLayout() self.ControlTab_layout_1.addLayout(self.ControlTab_grid_layout_1) self.ControlTab.addTab(self.ControlTab_widget_1, 'Gain') self.ControlTab_widget_2 = Qt.QWidget() self.ControlTab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.ControlTab_widget_2) self.ControlTab_grid_layout_2 = Qt.QGridLayout() self.ControlTab_layout_2.addLayout(self.ControlTab_grid_layout_2) self.ControlTab.addTab(self.ControlTab_widget_2, 'Phase') self.ControlTab_widget_3 = Qt.QWidget() self.ControlTab_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.ControlTab_widget_3) self.ControlTab_grid_layout_3 = Qt.QGridLayout() self.ControlTab_layout_3.addLayout(self.ControlTab_grid_layout_3) self.ControlTab.addTab(self.ControlTab_widget_3, 'Bandwidth') self.top_grid_layout.addWidget(self.ControlTab, 0, 0, 6, 2) for r in range(0, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._Times_To_Average_range = Range(1, 50, 1, 1, 10) self._Times_To_Average_win = RangeWidget(self._Times_To_Average_range, self.set_Times_To_Average, 'Times_To_Average', "counter_slider", int) self.ControlTab_grid_layout_0.addWidget(self._Times_To_Average_win, 2, 0, 1, 2) for r in range(2, 3): self.ControlTab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_0.setColumnStretch(c, 1) _SymmetricTaper_check_box = Qt.QCheckBox('SymmetricTaper') self._SymmetricTaper_choices = {True: 1, False: 0} self._SymmetricTaper_choices_inv = dict((v,k) for k,v in self._SymmetricTaper_choices.items()) self._SymmetricTaper_callback = lambda i: Qt.QMetaObject.invokeMethod(_SymmetricTaper_check_box, "setChecked", Qt.Q_ARG("bool", self._SymmetricTaper_choices_inv[i])) self._SymmetricTaper_callback(self.SymmetricTaper) _SymmetricTaper_check_box.stateChanged.connect(lambda i: self.set_SymmetricTaper(self._SymmetricTaper_choices[bool(i)])) self.ControlTab_grid_layout_1.addWidget(_SymmetricTaper_check_box, 9, 0, 1, 1) for r in range(9, 10): self.ControlTab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.ControlTab_grid_layout_1.setColumnStretch(c, 1) self._Rx_gain_range = Range(0, 60, 1, 0, 10) self._Rx_gain_win = RangeWidget(self._Rx_gain_range, self.set_Rx_gain, 'Rx_gain', "counter_slider", int) self.ControlTab_grid_layout_0.addWidget(self._Rx_gain_win, 1, 0, 1, 2) for r in range(1, 2): self.ControlTab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_0.setColumnStretch(c, 1) self._Rx8_Cal_range = Range(-180, 180, 2.8125, 0, 10) self._Rx8_Cal_win = RangeWidget(self._Rx8_Cal_range, self.set_Rx8_Cal, 'Rx8_Cal', "counter_slider", float) self.ControlTab_grid_layout_2.addWidget(self._Rx8_Cal_win, 7, 0, 1, 2) for r in range(7, 8): self.ControlTab_grid_layout_2.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_2.setColumnStretch(c, 1) self._Rx8Gain_range = Range(0, 127, 1, 127, 20) self._Rx8Gain_win = RangeWidget(self._Rx8Gain_range, self.set_Rx8Gain, 'Rx8Gain', "counter_slider", int) self.ControlTab_grid_layout_1.addWidget(self._Rx8Gain_win, 7, 0, 1, 2) for r in range(7, 8): self.ControlTab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_1.setColumnStretch(c, 1) self._Rx7_Cal_range = Range(-180, 180, 2.8125, 0, 10) self._Rx7_Cal_win = RangeWidget(self._Rx7_Cal_range, self.set_Rx7_Cal, 'Rx7_Cal', "counter_slider", float) self.ControlTab_grid_layout_2.addWidget(self._Rx7_Cal_win, 6, 0, 1, 2) for r in range(6, 7): self.ControlTab_grid_layout_2.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_2.setColumnStretch(c, 1) self._Rx7Gain_range = Range(0, 127, 1, 127, 20) self._Rx7Gain_win = RangeWidget(self._Rx7Gain_range, self.set_Rx7Gain, 'Rx7Gain', "counter_slider", int) self.ControlTab_grid_layout_1.addWidget(self._Rx7Gain_win, 6, 0, 1, 2) for r in range(6, 7): self.ControlTab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_1.setColumnStretch(c, 1) self._Rx6_Cal_range = Range(-180, 180, 2.8125, 0, 10) self._Rx6_Cal_win = RangeWidget(self._Rx6_Cal_range, self.set_Rx6_Cal, 'Rx6_Cal', "counter_slider", float) self.ControlTab_grid_layout_2.addWidget(self._Rx6_Cal_win, 5, 0, 1, 2) for r in range(5, 6): self.ControlTab_grid_layout_2.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_2.setColumnStretch(c, 1) self._Rx6Gain_range = Range(0, 127, 1, 127, 20) self._Rx6Gain_win = RangeWidget(self._Rx6Gain_range, self.set_Rx6Gain, 'Rx6Gain', "counter_slider", int) self.ControlTab_grid_layout_1.addWidget(self._Rx6Gain_win, 5, 0, 1, 2) for r in range(5, 6): self.ControlTab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_1.setColumnStretch(c, 1) self._Rx5_Cal_range = Range(-180, 180, 2.8125, 0, 10) self._Rx5_Cal_win = RangeWidget(self._Rx5_Cal_range, self.set_Rx5_Cal, 'Rx5_Cal', "counter_slider", float) self.ControlTab_grid_layout_2.addWidget(self._Rx5_Cal_win, 4, 0, 1, 2) for r in range(4, 5): self.ControlTab_grid_layout_2.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_2.setColumnStretch(c, 1) self._Rx5Gain_range = Range(0, 127, 1, 127, 20) self._Rx5Gain_win = RangeWidget(self._Rx5Gain_range, self.set_Rx5Gain, 'Rx5Gain', "counter_slider", int) self.ControlTab_grid_layout_1.addWidget(self._Rx5Gain_win, 4, 0, 1, 2) for r in range(4, 5): self.ControlTab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_1.setColumnStretch(c, 1) self._Rx4_Cal_range = Range(-180, 180, 2.8125, 0, 10) self._Rx4_Cal_win = RangeWidget(self._Rx4_Cal_range, self.set_Rx4_Cal, 'Rx4_Cal', "counter_slider", float) self.ControlTab_grid_layout_2.addWidget(self._Rx4_Cal_win, 3, 0, 1, 2) for r in range(3, 4): self.ControlTab_grid_layout_2.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_2.setColumnStretch(c, 1) self._Rx4Gain_range = Range(0, 127, 1, 127, 20) self._Rx4Gain_win = RangeWidget(self._Rx4Gain_range, self.set_Rx4Gain, 'Rx4Gain', "counter_slider", int) self.ControlTab_grid_layout_1.addWidget(self._Rx4Gain_win, 3, 0, 1, 2) for r in range(3, 4): self.ControlTab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_1.setColumnStretch(c, 1) self._Rx3_Cal_range = Range(-180, 180, 2.8125, 0, 10) self._Rx3_Cal_win = RangeWidget(self._Rx3_Cal_range, self.set_Rx3_Cal, 'Rx3_Cal', "counter_slider", float) self.ControlTab_grid_layout_2.addWidget(self._Rx3_Cal_win, 2, 0, 1, 2) for r in range(2, 3): self.ControlTab_grid_layout_2.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_2.setColumnStretch(c, 1) self._Rx3Gain_range = Range(0, 127, 1, 127, 20) self._Rx3Gain_win = RangeWidget(self._Rx3Gain_range, self.set_Rx3Gain, 'Rx3Gain', "counter_slider", int) self.ControlTab_grid_layout_1.addWidget(self._Rx3Gain_win, 2, 0, 1, 2) for r in range(2, 3): self.ControlTab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_1.setColumnStretch(c, 1) self._Rx2_Cal_range = Range(-180, 180, 2.8125, 0, 10) self._Rx2_Cal_win = RangeWidget(self._Rx2_Cal_range, self.set_Rx2_Cal, 'Rx2_Cal', "counter_slider", float) self.ControlTab_grid_layout_2.addWidget(self._Rx2_Cal_win, 1, 0, 1, 2) for r in range(1, 2): self.ControlTab_grid_layout_2.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_2.setColumnStretch(c, 1) self._Rx2Gain_range = Range(0, 127, 1, 127, 20) self._Rx2Gain_win = RangeWidget(self._Rx2Gain_range, self.set_Rx2Gain, 'Rx2Gain', "counter_slider", int) self.ControlTab_grid_layout_1.addWidget(self._Rx2Gain_win, 1, 0, 1, 2) for r in range(1, 2): self.ControlTab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_1.setColumnStretch(c, 1) self._Rx1_to_Rx2_Offset_range = Range(-180, 180, 2.8125, 0, 10) self._Rx1_to_Rx2_Offset_win = RangeWidget(self._Rx1_to_Rx2_Offset_range, self.set_Rx1_to_Rx2_Offset, 'Rx1_to_Rx2_Offset', "counter_slider", float) self.ControlTab_grid_layout_2.addWidget(self._Rx1_to_Rx2_Offset_win, 8, 0, 1, 2) for r in range(8, 9): self.ControlTab_grid_layout_2.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_2.setColumnStretch(c, 1) self._Rx1_Cal_range = Range(-180, 180, 2.8125, 0, 10) self._Rx1_Cal_win = RangeWidget(self._Rx1_Cal_range, self.set_Rx1_Cal, 'Rx1_Cal', "counter_slider", float) self.ControlTab_grid_layout_2.addWidget(self._Rx1_Cal_win, 0, 0, 1, 2) for r in range(0, 1): self.ControlTab_grid_layout_2.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_2.setColumnStretch(c, 1) self._Rx1Gain_range = Range(0, 127, 1, 127, 20) self._Rx1Gain_win = RangeWidget(self._Rx1Gain_range, self.set_Rx1Gain, 'Rx1Gain', "counter_slider", int) self.ControlTab_grid_layout_1.addWidget(self._Rx1Gain_win, 0, 0, 1, 2) for r in range(0, 1): self.ControlTab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_1.setColumnStretch(c, 1) _IgnorePhaseCals_check_box = Qt.QCheckBox('Set All Phase Cals to 0 deg') self._IgnorePhaseCals_choices = {True: 1, False: 0} self._IgnorePhaseCals_choices_inv = dict((v,k) for k,v in self._IgnorePhaseCals_choices.items()) self._IgnorePhaseCals_callback = lambda i: Qt.QMetaObject.invokeMethod(_IgnorePhaseCals_check_box, "setChecked", Qt.Q_ARG("bool", self._IgnorePhaseCals_choices_inv[i])) self._IgnorePhaseCals_callback(self.IgnorePhaseCals) _IgnorePhaseCals_check_box.stateChanged.connect(lambda i: self.set_IgnorePhaseCals(self._IgnorePhaseCals_choices[bool(i)])) self.ControlTab_grid_layout_2.addWidget(_IgnorePhaseCals_check_box, 9, 0, 1, 2) for r in range(9, 10): self.ControlTab_grid_layout_2.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_2.setColumnStretch(c, 1) self._Center_freq_range = Range(10000, 11000, 0.1, 10109, 10) self._Center_freq_win = RangeWidget(self._Center_freq_range, self.set_Center_freq, 'Signal Freq (MHz)', "counter_slider", float) self.ControlTab_grid_layout_0.addWidget(self._Center_freq_win, 0, 0, 1, 2) for r in range(0, 1): self.ControlTab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_0.setColumnStretch(c, 1) _BeamTaper_check_box = Qt.QCheckBox('Set All Element Gains to Max (127)') self._BeamTaper_choices = {True: 1, False: 0} self._BeamTaper_choices_inv = dict((v,k) for k,v in self._BeamTaper_choices.items()) self._BeamTaper_callback = lambda i: Qt.QMetaObject.invokeMethod(_BeamTaper_check_box, "setChecked", Qt.Q_ARG("bool", self._BeamTaper_choices_inv[i])) self._BeamTaper_callback(self.BeamTaper) _BeamTaper_check_box.stateChanged.connect(lambda i: self.set_BeamTaper(self._BeamTaper_choices[bool(i)])) self.ControlTab_grid_layout_1.addWidget(_BeamTaper_check_box, 8, 0, 1, 1) for r in range(8, 9): self.ControlTab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.ControlTab_grid_layout_1.setColumnStretch(c, 1) self._BW_range = Range(0, 2000, 100, 0, 10) self._BW_win = RangeWidget(self._BW_range, self.set_BW, 'Signal BW (MHz)', "counter_slider", float) self.ControlTab_grid_layout_3.addWidget(self._BW_win, 0, 0, 1, 1) for r in range(0, 1): self.ControlTab_grid_layout_3.setRowStretch(r, 1) for c in range(0, 1): self.ControlTab_grid_layout_3.setColumnStretch(c, 1) self._variable_qtgui_label_0_0_0_0_0_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_0_0_0_0_0_formatter = None else: self._variable_qtgui_label_0_0_0_0_0_0_formatter = lambda x: str(x) self._variable_qtgui_label_0_0_0_0_0_0_tool_bar.addWidget(Qt.QLabel('Angle Measured at (MHz)' + ": ")) self._variable_qtgui_label_0_0_0_0_0_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_0_0_0_0_0_formatter(self.variable_qtgui_label_0_0_0_0_0_0))) self._variable_qtgui_label_0_0_0_0_0_0_tool_bar.addWidget(self._variable_qtgui_label_0_0_0_0_0_0_label) self.ControlTab_grid_layout_3.addWidget(self._variable_qtgui_label_0_0_0_0_0_0_tool_bar, 6, 0, 1, 1) for r in range(6, 7): self.ControlTab_grid_layout_3.setRowStretch(r, 1) for c in range(0, 1): self.ControlTab_grid_layout_3.setColumnStretch(c, 1) self._variable_qtgui_label_0_0_0_0_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_0_0_0_0_formatter = None else: self._variable_qtgui_label_0_0_0_0_0_formatter = lambda x: str(x) self._variable_qtgui_label_0_0_0_0_0_tool_bar.addWidget(Qt.QLabel('Beam Weights Calc at (MHz)' + ": ")) self._variable_qtgui_label_0_0_0_0_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_0_0_0_0_formatter(self.variable_qtgui_label_0_0_0_0_0))) self._variable_qtgui_label_0_0_0_0_0_tool_bar.addWidget(self._variable_qtgui_label_0_0_0_0_0_label) self.ControlTab_grid_layout_3.addWidget(self._variable_qtgui_label_0_0_0_0_0_tool_bar, 5, 0, 1, 1) for r in range(5, 6): self.ControlTab_grid_layout_3.setRowStretch(r, 1) for c in range(0, 1): self.ControlTab_grid_layout_3.setColumnStretch(c, 1) self._variable_qtgui_label_0_0_0_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_0_0_0_formatter = None else: self._variable_qtgui_label_0_0_0_0_formatter = lambda x: str(x) self._variable_qtgui_label_0_0_0_0_tool_bar.addWidget(Qt.QLabel('Signal BW (MHz)' + ": ")) self._variable_qtgui_label_0_0_0_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_0_0_0_formatter(self.variable_qtgui_label_0_0_0_0))) self._variable_qtgui_label_0_0_0_0_tool_bar.addWidget(self._variable_qtgui_label_0_0_0_0_label) self.ControlTab_grid_layout_3.addWidget(self._variable_qtgui_label_0_0_0_0_tool_bar, 4, 0, 1, 1) for r in range(4, 5): self.ControlTab_grid_layout_3.setRowStretch(r, 1) for c in range(0, 1): self.ControlTab_grid_layout_3.setColumnStretch(c, 1) self._variable_qtgui_label_0_0_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_0_0_formatter = None else: self._variable_qtgui_label_0_0_0_formatter = lambda x: str(x) self._variable_qtgui_label_0_0_0_tool_bar.addWidget(Qt.QLabel('Pluto Rx LO (MHz)' + ": ")) self._variable_qtgui_label_0_0_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_0_0_formatter(self.variable_qtgui_label_0_0_0))) self._variable_qtgui_label_0_0_0_tool_bar.addWidget(self._variable_qtgui_label_0_0_0_label) self.ControlTab_grid_layout_3.addWidget(self._variable_qtgui_label_0_0_0_tool_bar, 3, 0, 1, 1) for r in range(3, 4): self.ControlTab_grid_layout_3.setRowStretch(r, 1) for c in range(0, 1): self.ControlTab_grid_layout_3.setColumnStretch(c, 1) self._variable_qtgui_label_0_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_0_formatter = None else: self._variable_qtgui_label_0_0_formatter = lambda x: str(x) self._variable_qtgui_label_0_0_tool_bar.addWidget(Qt.QLabel('Mixer LO (MHz)' + ": ")) self._variable_qtgui_label_0_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_0_formatter(self.variable_qtgui_label_0_0))) self._variable_qtgui_label_0_0_tool_bar.addWidget(self._variable_qtgui_label_0_0_label) self.ControlTab_grid_layout_3.addWidget(self._variable_qtgui_label_0_0_tool_bar, 2, 0, 1, 1) for r in range(2, 3): self.ControlTab_grid_layout_3.setRowStretch(r, 1) for c in range(0, 1): self.ControlTab_grid_layout_3.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: repr(x) self._variable_qtgui_label_0_tool_bar.addWidget(Qt.QLabel('Received Signal (MHz)' + ": ")) 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.ControlTab_grid_layout_3.addWidget(self._variable_qtgui_label_0_tool_bar, 1, 0, 1, 1) for r in range(1, 2): self.ControlTab_grid_layout_3.setRowStretch(r, 1) for c in range(0, 1): self.ControlTab_grid_layout_3.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 140, #size "Error and Phase vs Steering Angle", #name 2 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-1.5, 1.5) self.qtgui_const_sink_x_0_0.set_x_axis(-80, 80) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(True) self.qtgui_const_sink_x_0_0.enable_axis_labels(True) labels = ['Error', 'Phase', '', '', '', '', '', '', '', ''] 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(2): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 5, 2, 4, 5) for r in range(5, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 7): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 140, #size "Peak Signal vs Steering Angle", #name 2 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-50, 0) self.qtgui_const_sink_x_0.set_x_axis(-80, 80) 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(True) self.qtgui_const_sink_x_0.enable_axis_labels(True) labels = ['SUM', 'DELTA', '', '', '', '', '', '', '', ''] 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(2): 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_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 0, 2, 5, 5) for r in range(0, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 7): self.top_grid_layout.setColumnStretch(c, 1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_float*1) self.ADAR1000_8_sweeper = ADAR1000_8_sweeper.blk(IP=[192, 168, 0, 3], LO_freq=int((Center_freq-LO_freq)*1000000), TX_freq=int(LO_freq*1000000), SampleRate=int(samp_rate), Rx_gain=int(Rx_gain), Averages=int(Times_To_Average), Taper=int(BeamTaper), SymTaper=int(SymmetricTaper), PhaseCal=int(IgnorePhaseCals), SignalFreq=int((Center_freq-BW)*1000000), RxGain1=Rx1Gain, RxGain2=Rx2Gain, RxGain3=Rx3Gain, RxGain4=Rx4Gain, RxGain5=Rx5Gain, RxGain6=Rx6Gain, RxGain7=Rx7Gain, RxGain8=Rx8Gain, Rx1_cal=Rx1_Cal+33.75, Rx2_cal=Rx2_Cal+30.9375, Rx3_cal=Rx3_Cal+11.25, Rx4_cal=Rx4_Cal, Rx5_cal=Rx5_Cal+Rx1_to_Rx2_Offset+75.9375, Rx6_cal=Rx6_Cal+Rx1_to_Rx2_Offset+101.25, Rx7_cal=Rx7_Cal+Rx1_to_Rx2_Offset+112.5, Rx8_cal=Rx8_Cal+Rx1_to_Rx2_Offset+109.6875) ################################################## # Connections ################################################## self.connect((self.ADAR1000_8_sweeper, 4), (self.blocks_throttle_0, 0)) self.connect((self.ADAR1000_8_sweeper, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.ADAR1000_8_sweeper, 1), (self.qtgui_const_sink_x_0, 1)) self.connect((self.ADAR1000_8_sweeper, 2), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.ADAR1000_8_sweeper, 3), (self.qtgui_const_sink_x_0_0, 1)) self.connect((self.blocks_throttle_0, 0), (self.blocks_null_sink_1, 0))
def __init__(self): gr.top_block.__init__(self, "Lab 2") Qt.QWidget.__init__(self) self.setWindowTitle("Lab 2") 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", "lab2") 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.sps = sps = 8 self.roll_off = roll_off = 0.5 self.freqc = freqc = 900 self.std_dev = std_dev = 0.05 self.samp_rate = samp_rate = 1024 self.rrc_filter = rrc_filter = firdes.root_raised_cosine(4, sps, 1, roll_off, 32*sps+1) self.phase = phase = 0 self.lw = lw = 2 self.gain_ = gain_ = 0.5 self.freqc_ = freqc_ = freqc self.fps = fps = 30 self.const = const = digital.constellation_calcdist(digital.psk_2()[0], digital.psk_2()[1], 2, 1).base() self.bw = bw = 1 self.buff_size = buff_size = 32768 self.bNoise = bNoise = 0 self.bFilter = bFilter = 0 self.axis = axis = 2 self.N = N = 0 ################################################## # Blocks ################################################## self.tab0 = Qt.QTabWidget() self.tab0_widget_0 = Qt.QWidget() self.tab0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_0) self.tab0_grid_layout_0 = Qt.QGridLayout() self.tab0_layout_0.addLayout(self.tab0_grid_layout_0) self.tab0.addTab(self.tab0_widget_0, 'Spectrum/Constellation') self.tab0_widget_1 = Qt.QWidget() self.tab0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_1) self.tab0_grid_layout_1 = Qt.QGridLayout() self.tab0_layout_1.addLayout(self.tab0_grid_layout_1) self.tab0.addTab(self.tab0_widget_1, 'Eye Diagram') self.top_grid_layout.addWidget(self.tab0, 0, 0, 10, 2) for r in range(0, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._std_dev_range = Range(0, 1, 0.01, 0.05, 200) self._std_dev_win = RangeWidget(self._std_dev_range, self.set_std_dev, 'Noise Std. Dev', "counter_slider", float) self.top_grid_layout.addWidget(self._std_dev_win, 11, 0, 1, 1) for r in range(11, 12): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._phase_range = Range(-180*2, 180*2, 0.1, 0, 200) self._phase_win = RangeWidget(self._phase_range, self.set_phase, 'Phase Offset (Degrees)', "counter_slider", float) self.top_grid_layout.addWidget(self._phase_win, 11, 1, 1, 1) for r in range(11, 12): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._gain__range = Range(0.1, 1, 0.01, 0.5, 200) self._gain__win = RangeWidget(self._gain__range, self.set_gain_, 'Gain (Amp)', "counter_slider", float) self.top_grid_layout.addWidget(self._gain__win, 10, 1, 1, 1) for r in range(10, 11): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._freqc__range = Range(70, 6000, .01, freqc, 200) self._freqc__win = RangeWidget(self._freqc__range, self.set_freqc_, 'Carrier (MHz)', "counter_slider", float) self.top_grid_layout.addWidget(self._freqc__win, 10, 0, 1, 1) for r in range(10, 11): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) # Create the options list self._bNoise_options = (0, 1, ) # Create the labels list self._bNoise_labels = ('Noise Only', 'Signal + Noise', ) # Create the combo box # Create the radio buttons self._bNoise_group_box = Qt.QGroupBox('Waveform Select' + ": ") self._bNoise_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._bNoise_button_group = variable_chooser_button_group() self._bNoise_group_box.setLayout(self._bNoise_box) for i, _label in enumerate(self._bNoise_labels): radio_button = Qt.QRadioButton(_label) self._bNoise_box.addWidget(radio_button) self._bNoise_button_group.addButton(radio_button, i) self._bNoise_callback = lambda i: Qt.QMetaObject.invokeMethod(self._bNoise_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._bNoise_options.index(i))) self._bNoise_callback(self.bNoise) self._bNoise_button_group.buttonClicked[int].connect( lambda i: self.set_bNoise(self._bNoise_options[i])) self.top_grid_layout.addWidget(self._bNoise_group_box, 12, 1, 1, 1) for r in range(12, 13): 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._bFilter_options = (0, 1, ) # Create the labels list self._bFilter_labels = ('Rectangular', 'Raised Cosine', ) # Create the combo box # Create the radio buttons self._bFilter_group_box = Qt.QGroupBox('Pulse Shaping Select' + ": ") self._bFilter_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._bFilter_button_group = variable_chooser_button_group() self._bFilter_group_box.setLayout(self._bFilter_box) for i, _label in enumerate(self._bFilter_labels): radio_button = Qt.QRadioButton(_label) self._bFilter_box.addWidget(radio_button) self._bFilter_button_group.addButton(radio_button, i) self._bFilter_callback = lambda i: Qt.QMetaObject.invokeMethod(self._bFilter_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._bFilter_options.index(i))) self._bFilter_callback(self.bFilter) self._bFilter_button_group.buttonClicked[int].connect( lambda i: self.set_bFilter(self._bFilter_options[i])) self.top_grid_layout.addWidget(self._bFilter_group_box, 12, 0, 1, 1) for r in range(12, 13): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._N_range = Range(0, 7, 1, 0, 200) self._N_win = RangeWidget(self._N_range, self.set_N, 'Nth Sample', "counter_slider", float) self.top_grid_layout.addWidget(self._N_win, 13, 1, 1, 1) for r in range(13, 14): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._roll_off_range = Range(0.01, 0.99, 0.01, 0.5, 200) self._roll_off_win = RangeWidget(self._roll_off_range, self.set_roll_off, 'Beta (Roll-Off-Factor)', "counter_slider", float) self.top_grid_layout.addWidget(self._roll_off_win, 13, 0, 1, 1) for r in range(13, 14): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 2*sps, #size 1, #samp_rate "", #name 10 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(1/fps) self.qtgui_time_sink_x_0.set_y_axis(-2, 2) 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, "buffer_start") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(True) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = ['Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10'] widths = [lw, lw, lw, lw, lw, lw, lw, lw, lw, lw] colors = ['blue', 'red', 'yellow', '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(10): 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.tab0_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0, 0, 5, 1) for r in range(0, 5): self.tab0_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.tab0_grid_layout_1.setColumnStretch(c, 1) self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f( int(1e5), 400, -axis, axis, "", 1 ) self.qtgui_histogram_sink_x_0.set_update_time(1/fps) 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(True) self.qtgui_histogram_sink_x_0.enable_axis_labels(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"] 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 range(1): 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.tab0_grid_layout_0.addWidget(self._qtgui_histogram_sink_x_0_win, 5, 1, 5, 1) for r in range(5, 10): self.tab0_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.tab0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate*1e3, #bw "", #name 1 ) self.qtgui_freq_sink_x_0_0.set_update_time(1/fps) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(True) self.qtgui_freq_sink_x_0_0.set_fft_average(0.05) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) labels = ['Magnitude', '', '', '', '', '', '', '', '', ''] 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 range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tab0_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 0, 5, 1) for r in range(0, 5): self.tab0_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.tab0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0.set_processor_affinity([0]) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate*1e3, #bw "", #name 2 ) self.qtgui_freq_sink_x_0.set_update_time(1/fps) 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(True) self.qtgui_freq_sink_x_0.set_fft_average(0.05) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['In-Phase', 'Quadrature', '', '', '', '', '', '', '', ''] 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 range(2): 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.tab0_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 5, 0, 5, 1) for r in range(5, 10): self.tab0_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.tab0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0.set_processor_affinity([0]) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 2 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(1/fps) self.qtgui_const_sink_x_0.set_y_axis(-axis, axis) self.qtgui_const_sink_x_0.set_x_axis(-axis, axis) 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(True) 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, 1, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, -1, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(2): 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.tab0_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win, 0, 1, 5, 1) for r in range(0, 5): self.tab0_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.tab0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_const_sink_x_0.set_processor_affinity([0]) self.interp_fir_filter_xxx_1_0 = filter.interp_fir_filter_ccc(sps, (1,1,1,1,1,1,1,1)) self.interp_fir_filter_xxx_1_0.declare_sample_delay(0) self.interp_fir_filter_xxx_1 = filter.interp_fir_filter_ccc(sps, rrc_filter) self.interp_fir_filter_xxx_1.declare_sample_delay(0) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(1, rrc_filter) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.iio_pluto_source_0 = iio.pluto_source('', int(freqc_*1e6), int(samp_rate*1000), 20000000, buff_size, True, True, True, 'manual', 32, '', True) self.iio_pluto_sink_0 = iio.pluto_sink('', int(freqc_*1e6), int(samp_rate*1000), 20000000, buff_size, False, 10.0, '', True) self.digital_chunks_to_symbols_xx_1 = digital.chunks_to_symbols_bc(const.points(), 1) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0.set_single_key("") self.blocks_selector_0_0 = blocks.selector(gr.sizeof_gr_complex*1,bFilter,0) self.blocks_selector_0_0.set_enabled(True) self.blocks_selector_0 = blocks.selector(gr.sizeof_gr_complex*1,N,0) self.blocks_selector_0.set_enabled(True) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc(np.exp(1j*2*pi*phase/360)) self.blocks_multiply_const_vxx_0_0_0 = blocks.multiply_const_cc(2) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_cc(bNoise) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(gain_ ) self.blocks_delay_0_2 = blocks.delay(gr.sizeof_float*1, -N+1024) self.blocks_delay_0_1 = blocks.delay(gr.sizeof_float*1, sps) self.blocks_delay_0_0_1 = blocks.delay(gr.sizeof_float*1, sps) self.blocks_delay_0_0_0_1_0 = blocks.delay(gr.sizeof_float*1, sps) self.blocks_delay_0_0_0_1 = blocks.delay(gr.sizeof_float*1, sps) self.blocks_delay_0_0_0_0_0 = blocks.delay(gr.sizeof_float*1, sps) self.blocks_delay_0_0_0_0 = blocks.delay(gr.sizeof_float*1, sps) self.blocks_delay_0_0_0 = blocks.delay(gr.sizeof_float*1, sps) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_float*1, sps) self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, sps) self.blocks_deinterleave_0 = blocks.deinterleave(gr.sizeof_gr_complex*1, 1) self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_random_source_x_0 = blocks.vector_source_b(list(map(int, numpy.random.randint(0, 2, 8192))), True) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, std_dev, 0) self.analog_agc_xx_0 = analog.agc_cc(1e-4, 1.0, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.blocks_deinterleave_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_1, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_complex_to_imag_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_delay_0_2, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_complex_to_real_0_0, 0), (self.qtgui_histogram_sink_x_0, 0)) self.connect((self.blocks_deinterleave_0, 7), (self.blocks_selector_0, 7)) self.connect((self.blocks_deinterleave_0, 4), (self.blocks_selector_0, 4)) self.connect((self.blocks_deinterleave_0, 3), (self.blocks_selector_0, 3)) self.connect((self.blocks_deinterleave_0, 6), (self.blocks_selector_0, 6)) self.connect((self.blocks_deinterleave_0, 5), (self.blocks_selector_0, 5)) self.connect((self.blocks_deinterleave_0, 0), (self.blocks_selector_0, 0)) self.connect((self.blocks_deinterleave_0, 1), (self.blocks_selector_0, 1)) self.connect((self.blocks_deinterleave_0, 2), (self.blocks_selector_0, 2)) self.connect((self.blocks_delay_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_delay_0_0_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.qtgui_time_sink_x_0, 2)) self.connect((self.blocks_delay_0_0_0, 0), (self.blocks_delay_0_0_0_0, 0)) self.connect((self.blocks_delay_0_0_0, 0), (self.qtgui_time_sink_x_0, 3)) self.connect((self.blocks_delay_0_0_0_0, 0), (self.blocks_delay_0_1, 0)) self.connect((self.blocks_delay_0_0_0_0, 0), (self.qtgui_time_sink_x_0, 4)) self.connect((self.blocks_delay_0_0_0_0_0, 0), (self.blocks_delay_0_0_0_1_0, 0)) self.connect((self.blocks_delay_0_0_0_0_0, 0), (self.qtgui_time_sink_x_0, 8)) self.connect((self.blocks_delay_0_0_0_1, 0), (self.blocks_delay_0_0_0_0_0, 0)) self.connect((self.blocks_delay_0_0_0_1, 0), (self.qtgui_time_sink_x_0, 7)) self.connect((self.blocks_delay_0_0_0_1_0, 0), (self.qtgui_time_sink_x_0, 9)) self.connect((self.blocks_delay_0_0_1, 0), (self.blocks_delay_0_0_0_1, 0)) self.connect((self.blocks_delay_0_0_1, 0), (self.qtgui_time_sink_x_0, 6)) self.connect((self.blocks_delay_0_1, 0), (self.blocks_delay_0_0_1, 0)) self.connect((self.blocks_delay_0_1, 0), (self.qtgui_time_sink_x_0, 5)) self.connect((self.blocks_delay_0_2, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_delay_0_2, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.iio_pluto_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0_0, 0), (self.blocks_selector_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.analog_agc_xx_0, 0)) self.connect((self.blocks_selector_0, 0), (self.blocks_complex_to_real_0_0, 0)) self.connect((self.blocks_selector_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_selector_0, 0), (self.qtgui_const_sink_x_0, 1)) self.connect((self.blocks_selector_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_complex_to_imag_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_1, 0), (self.interp_fir_filter_xxx_1, 0)) self.connect((self.digital_chunks_to_symbols_xx_1, 0), (self.interp_fir_filter_xxx_1_0, 0)) self.connect((self.iio_pluto_source_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_selector_0_0, 1)) self.connect((self.interp_fir_filter_xxx_1, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.interp_fir_filter_xxx_1_0, 0), (self.blocks_multiply_const_vxx_0_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Beamformer_Ex4") Qt.QWidget.__init__(self) self.setWindowTitle("Beamformer_Ex4") 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") 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.Center_freq = Center_freq = 10508.0 self.BW = BW = 0 self.variable_qtgui_label_0_0_0_0_0_0 = variable_qtgui_label_0_0_0_0_0_0 = ("%d" % (Center_freq)).rjust(16) self.variable_qtgui_label_0_0_0_0_0 = variable_qtgui_label_0_0_0_0_0 = ("%d" % ((Center_freq-BW))).rjust(10) self.variable_qtgui_label_0_0_0_0 = variable_qtgui_label_0_0_0_0 = ("%d" % (BW)).rjust(28) self.variable_qtgui_label_0_0_0 = variable_qtgui_label_0_0_0 = ("%d" % ((Center_freq - 5810))).rjust(27) self.variable_qtgui_label_0_0 = variable_qtgui_label_0_0 = ("%d" % (5810)).rjust(32) self.variable_qtgui_label_0 = variable_qtgui_label_0 = ("%d" % (Center_freq)).rjust(20) self.samp_rate = samp_rate = 40000000 self.Times_To_Average = Times_To_Average = 1 self.SymmetricTaper = SymmetricTaper = 0 self.Rx_gain = Rx_gain = 20 self.Rx4_Cal = Rx4_Cal = 0 self.Rx4Gain = Rx4Gain = 127 self.Rx3_Cal = Rx3_Cal = 0 self.Rx3Gain = Rx3Gain = 127 self.Rx2_Cal = Rx2_Cal = 0 self.Rx2Gain = Rx2Gain = 127 self.Rx1_Cal = Rx1_Cal = 0 self.Rx1Gain = Rx1Gain = 127 self.IgnorePhaseCals = IgnorePhaseCals = 0 self.BeamTaper = BeamTaper = 0 ################################################## # Blocks ################################################## self.ControlTab = Qt.QTabWidget() self.ControlTab_widget_0 = Qt.QWidget() self.ControlTab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.ControlTab_widget_0) self.ControlTab_grid_layout_0 = Qt.QGridLayout() self.ControlTab_layout_0.addLayout(self.ControlTab_grid_layout_0) self.ControlTab.addTab(self.ControlTab_widget_0, 'Pluto_Controls') self.ControlTab_widget_1 = Qt.QWidget() self.ControlTab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.ControlTab_widget_1) self.ControlTab_grid_layout_1 = Qt.QGridLayout() self.ControlTab_layout_1.addLayout(self.ControlTab_grid_layout_1) self.ControlTab.addTab(self.ControlTab_widget_1, 'Gain') self.ControlTab_widget_2 = Qt.QWidget() self.ControlTab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.ControlTab_widget_2) self.ControlTab_grid_layout_2 = Qt.QGridLayout() self.ControlTab_layout_2.addLayout(self.ControlTab_grid_layout_2) self.ControlTab.addTab(self.ControlTab_widget_2, 'Phase') self.ControlTab_widget_3 = Qt.QWidget() self.ControlTab_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.ControlTab_widget_3) self.ControlTab_grid_layout_3 = Qt.QGridLayout() self.ControlTab_layout_3.addLayout(self.ControlTab_grid_layout_3) self.ControlTab.addTab(self.ControlTab_widget_3, 'Bandwidth') self.top_grid_layout.addWidget(self.ControlTab, 0, 0, 6, 2) for r in range(0, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._Times_To_Average_range = Range(1, 50, 1, 1, 10) self._Times_To_Average_win = RangeWidget(self._Times_To_Average_range, self.set_Times_To_Average, 'Times_To_Average', "counter_slider", int) self.ControlTab_grid_layout_0.addWidget(self._Times_To_Average_win, 2, 0, 1, 2) for r in range(2, 3): self.ControlTab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_0.setColumnStretch(c, 1) _SymmetricTaper_check_box = Qt.QCheckBox('Set Rx4Gain = Rx1Gain (Symmetric Taper)') self._SymmetricTaper_choices = {True: 1, False: 0} self._SymmetricTaper_choices_inv = dict((v,k) for k,v in self._SymmetricTaper_choices.items()) self._SymmetricTaper_callback = lambda i: Qt.QMetaObject.invokeMethod(_SymmetricTaper_check_box, "setChecked", Qt.Q_ARG("bool", self._SymmetricTaper_choices_inv[i])) self._SymmetricTaper_callback(self.SymmetricTaper) _SymmetricTaper_check_box.stateChanged.connect(lambda i: self.set_SymmetricTaper(self._SymmetricTaper_choices[bool(i)])) self.ControlTab_grid_layout_1.addWidget(_SymmetricTaper_check_box, 5, 0, 1, 1) for r in range(5, 6): self.ControlTab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.ControlTab_grid_layout_1.setColumnStretch(c, 1) self._Rx_gain_range = Range(0, 60, 1, 20, 10) self._Rx_gain_win = RangeWidget(self._Rx_gain_range, self.set_Rx_gain, 'Rx_gain', "counter_slider", int) self.ControlTab_grid_layout_0.addWidget(self._Rx_gain_win, 1, 0, 1, 2) for r in range(1, 2): self.ControlTab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_0.setColumnStretch(c, 1) self._Rx4_Cal_range = Range(-180, 180, 2.8125, 0, 10) self._Rx4_Cal_win = RangeWidget(self._Rx4_Cal_range, self.set_Rx4_Cal, 'Rx4_Cal', "counter_slider", float) self.ControlTab_grid_layout_2.addWidget(self._Rx4_Cal_win, 3, 0, 1, 2) for r in range(3, 4): self.ControlTab_grid_layout_2.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_2.setColumnStretch(c, 1) self._Rx4Gain_range = Range(0, 127, 1, 127, 20) self._Rx4Gain_win = RangeWidget(self._Rx4Gain_range, self.set_Rx4Gain, 'Rx4Gain', "counter_slider", int) self.ControlTab_grid_layout_1.addWidget(self._Rx4Gain_win, 3, 0, 1, 2) for r in range(3, 4): self.ControlTab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_1.setColumnStretch(c, 1) self._Rx3_Cal_range = Range(-180, 180, 2.8125, 0, 10) self._Rx3_Cal_win = RangeWidget(self._Rx3_Cal_range, self.set_Rx3_Cal, 'Rx3_Cal', "counter_slider", float) self.ControlTab_grid_layout_2.addWidget(self._Rx3_Cal_win, 2, 0, 1, 2) for r in range(2, 3): self.ControlTab_grid_layout_2.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_2.setColumnStretch(c, 1) self._Rx3Gain_range = Range(0, 127, 1, 127, 20) self._Rx3Gain_win = RangeWidget(self._Rx3Gain_range, self.set_Rx3Gain, 'Rx3Gain', "counter_slider", int) self.ControlTab_grid_layout_1.addWidget(self._Rx3Gain_win, 2, 0, 1, 2) for r in range(2, 3): self.ControlTab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_1.setColumnStretch(c, 1) self._Rx2_Cal_range = Range(-180, 180, 2.8125, 0, 10) self._Rx2_Cal_win = RangeWidget(self._Rx2_Cal_range, self.set_Rx2_Cal, 'Rx2_Cal', "counter_slider", float) self.ControlTab_grid_layout_2.addWidget(self._Rx2_Cal_win, 1, 0, 1, 2) for r in range(1, 2): self.ControlTab_grid_layout_2.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_2.setColumnStretch(c, 1) self._Rx2Gain_range = Range(0, 127, 1, 127, 20) self._Rx2Gain_win = RangeWidget(self._Rx2Gain_range, self.set_Rx2Gain, 'Rx2Gain', "counter_slider", int) self.ControlTab_grid_layout_1.addWidget(self._Rx2Gain_win, 1, 0, 1, 2) for r in range(1, 2): self.ControlTab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_1.setColumnStretch(c, 1) self._Rx1_Cal_range = Range(-180, 180, 2.8125, 0, 10) self._Rx1_Cal_win = RangeWidget(self._Rx1_Cal_range, self.set_Rx1_Cal, 'Rx1_Cal', "counter_slider", float) self.ControlTab_grid_layout_2.addWidget(self._Rx1_Cal_win, 0, 0, 1, 2) for r in range(0, 1): self.ControlTab_grid_layout_2.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_2.setColumnStretch(c, 1) self._Rx1Gain_range = Range(0, 127, 1, 127, 20) self._Rx1Gain_win = RangeWidget(self._Rx1Gain_range, self.set_Rx1Gain, 'Rx1Gain', "counter_slider", int) self.ControlTab_grid_layout_1.addWidget(self._Rx1Gain_win, 0, 0, 1, 2) for r in range(0, 1): self.ControlTab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_1.setColumnStretch(c, 1) _IgnorePhaseCals_check_box = Qt.QCheckBox('Set All Phase Cals to 0 deg') self._IgnorePhaseCals_choices = {True: 1, False: 0} self._IgnorePhaseCals_choices_inv = dict((v,k) for k,v in self._IgnorePhaseCals_choices.items()) self._IgnorePhaseCals_callback = lambda i: Qt.QMetaObject.invokeMethod(_IgnorePhaseCals_check_box, "setChecked", Qt.Q_ARG("bool", self._IgnorePhaseCals_choices_inv[i])) self._IgnorePhaseCals_callback(self.IgnorePhaseCals) _IgnorePhaseCals_check_box.stateChanged.connect(lambda i: self.set_IgnorePhaseCals(self._IgnorePhaseCals_choices[bool(i)])) self.ControlTab_grid_layout_2.addWidget(_IgnorePhaseCals_check_box, 4, 0, 1, 2) for r in range(4, 5): self.ControlTab_grid_layout_2.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_2.setColumnStretch(c, 1) self._Center_freq_range = Range(10000, 11000, 0.1, 10508.0, 10) self._Center_freq_win = RangeWidget(self._Center_freq_range, self.set_Center_freq, 'Signal Freq (MHz)', "counter_slider", float) self.ControlTab_grid_layout_0.addWidget(self._Center_freq_win, 0, 0, 1, 2) for r in range(0, 1): self.ControlTab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 2): self.ControlTab_grid_layout_0.setColumnStretch(c, 1) _BeamTaper_check_box = Qt.QCheckBox('Set All Element Gains to Max (127)') self._BeamTaper_choices = {True: 1, False: 0} self._BeamTaper_choices_inv = dict((v,k) for k,v in self._BeamTaper_choices.items()) self._BeamTaper_callback = lambda i: Qt.QMetaObject.invokeMethod(_BeamTaper_check_box, "setChecked", Qt.Q_ARG("bool", self._BeamTaper_choices_inv[i])) self._BeamTaper_callback(self.BeamTaper) _BeamTaper_check_box.stateChanged.connect(lambda i: self.set_BeamTaper(self._BeamTaper_choices[bool(i)])) self.ControlTab_grid_layout_1.addWidget(_BeamTaper_check_box, 4, 0, 1, 1) for r in range(4, 5): self.ControlTab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.ControlTab_grid_layout_1.setColumnStretch(c, 1) self._BW_range = Range(0, 2000, 100, 0, 10) self._BW_win = RangeWidget(self._BW_range, self.set_BW, 'Signal BW (MHz)', "counter_slider", float) self.ControlTab_grid_layout_3.addWidget(self._BW_win, 0, 0, 1, 1) for r in range(0, 1): self.ControlTab_grid_layout_3.setRowStretch(r, 1) for c in range(0, 1): self.ControlTab_grid_layout_3.setColumnStretch(c, 1) self._variable_qtgui_label_0_0_0_0_0_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_0_0_0_0_0_formatter = None else: self._variable_qtgui_label_0_0_0_0_0_0_formatter = lambda x: str(x) self._variable_qtgui_label_0_0_0_0_0_0_tool_bar.addWidget(Qt.QLabel('Angle Measured at (MHz)' + ": ")) self._variable_qtgui_label_0_0_0_0_0_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_0_0_0_0_0_formatter(self.variable_qtgui_label_0_0_0_0_0_0))) self._variable_qtgui_label_0_0_0_0_0_0_tool_bar.addWidget(self._variable_qtgui_label_0_0_0_0_0_0_label) self.ControlTab_grid_layout_3.addWidget(self._variable_qtgui_label_0_0_0_0_0_0_tool_bar, 6, 0, 1, 1) for r in range(6, 7): self.ControlTab_grid_layout_3.setRowStretch(r, 1) for c in range(0, 1): self.ControlTab_grid_layout_3.setColumnStretch(c, 1) self._variable_qtgui_label_0_0_0_0_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_0_0_0_0_formatter = None else: self._variable_qtgui_label_0_0_0_0_0_formatter = lambda x: str(x) self._variable_qtgui_label_0_0_0_0_0_tool_bar.addWidget(Qt.QLabel('Beam Weights Calc at (MHz)' + ": ")) self._variable_qtgui_label_0_0_0_0_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_0_0_0_0_formatter(self.variable_qtgui_label_0_0_0_0_0))) self._variable_qtgui_label_0_0_0_0_0_tool_bar.addWidget(self._variable_qtgui_label_0_0_0_0_0_label) self.ControlTab_grid_layout_3.addWidget(self._variable_qtgui_label_0_0_0_0_0_tool_bar, 5, 0, 1, 1) for r in range(5, 6): self.ControlTab_grid_layout_3.setRowStretch(r, 1) for c in range(0, 1): self.ControlTab_grid_layout_3.setColumnStretch(c, 1) self._variable_qtgui_label_0_0_0_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_0_0_0_formatter = None else: self._variable_qtgui_label_0_0_0_0_formatter = lambda x: str(x) self._variable_qtgui_label_0_0_0_0_tool_bar.addWidget(Qt.QLabel('Signal BW (MHz)' + ": ")) self._variable_qtgui_label_0_0_0_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_0_0_0_formatter(self.variable_qtgui_label_0_0_0_0))) self._variable_qtgui_label_0_0_0_0_tool_bar.addWidget(self._variable_qtgui_label_0_0_0_0_label) self.ControlTab_grid_layout_3.addWidget(self._variable_qtgui_label_0_0_0_0_tool_bar, 4, 0, 1, 1) for r in range(4, 5): self.ControlTab_grid_layout_3.setRowStretch(r, 1) for c in range(0, 1): self.ControlTab_grid_layout_3.setColumnStretch(c, 1) self._variable_qtgui_label_0_0_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_0_0_formatter = None else: self._variable_qtgui_label_0_0_0_formatter = lambda x: str(x) self._variable_qtgui_label_0_0_0_tool_bar.addWidget(Qt.QLabel('Pluto Rx LO (MHz)' + ": ")) self._variable_qtgui_label_0_0_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_0_0_formatter(self.variable_qtgui_label_0_0_0))) self._variable_qtgui_label_0_0_0_tool_bar.addWidget(self._variable_qtgui_label_0_0_0_label) self.ControlTab_grid_layout_3.addWidget(self._variable_qtgui_label_0_0_0_tool_bar, 3, 0, 1, 1) for r in range(3, 4): self.ControlTab_grid_layout_3.setRowStretch(r, 1) for c in range(0, 1): self.ControlTab_grid_layout_3.setColumnStretch(c, 1) self._variable_qtgui_label_0_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_0_formatter = None else: self._variable_qtgui_label_0_0_formatter = lambda x: str(x) self._variable_qtgui_label_0_0_tool_bar.addWidget(Qt.QLabel('Mixer LO (MHz)' + ": ")) self._variable_qtgui_label_0_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_0_formatter(self.variable_qtgui_label_0_0))) self._variable_qtgui_label_0_0_tool_bar.addWidget(self._variable_qtgui_label_0_0_label) self.ControlTab_grid_layout_3.addWidget(self._variable_qtgui_label_0_0_tool_bar, 2, 0, 1, 1) for r in range(2, 3): self.ControlTab_grid_layout_3.setRowStretch(r, 1) for c in range(0, 1): self.ControlTab_grid_layout_3.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: repr(x) self._variable_qtgui_label_0_tool_bar.addWidget(Qt.QLabel('Received Signal (MHz)' + ": ")) 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.ControlTab_grid_layout_3.addWidget(self._variable_qtgui_label_0_tool_bar, 1, 0, 1, 1) for r in range(1, 2): self.ControlTab_grid_layout_3.setRowStretch(r, 1) for c in range(0, 1): self.ControlTab_grid_layout_3.setColumnStretch(c, 1) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 1, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_0.set_update_time(0.1) self.qtgui_number_sink_0.set_title('Elevation') labels = [' ', '', '', '', '', '', '', '', '', ''] units = ['deg', '', '', '', '', '', '', '', '', ''] 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 range(1): self.qtgui_number_sink_0.set_min(i, -80) self.qtgui_number_sink_0.set_max(i, 80) 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, 5, 2, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 140, #size "Peak Signal vs Steering Angle", #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(-50, 0) self.qtgui_const_sink_x_0.set_x_axis(-80, 80) 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(True) self.qtgui_const_sink_x_0.enable_axis_labels(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 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_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 0, 2, 5, 3) for r in range(0, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 5): self.top_grid_layout.setColumnStretch(c, 1) self.epy_block_0 = epy_block_0.blk(SDR_ip='ip:192.168.2.1', LO_freq=int(Center_freq*1000000 - 5810000000), TX_freq=5810000000, SampleRate=int(samp_rate), Rx_gain=int(Rx_gain), Averages=int(Times_To_Average), Taper=int(BeamTaper), SymTaper=int(SymmetricTaper), PhaseCal=int(IgnorePhaseCals), SignalFreq=int((Center_freq-BW)*1000000), RxGain1=int(Rx1Gain), RxGain2=int(Rx2Gain), RxGain3=int(Rx3Gain), RxGain4=int(Rx4Gain), Rx1_cal=Rx1_Cal, Rx2_cal=Rx2_Cal, Rx3_cal=Rx3_Cal, Rx4_cal=Rx4_Cal) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(1000, 0.001, samp_rate, 1) ################################################## # Connections ################################################## self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.epy_block_0, 1), (self.blocks_throttle_0, 0)) self.connect((self.epy_block_0, 0), (self.qtgui_const_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Dvbs2 Tx") Qt.QWidget.__init__(self) self.setWindowTitle("Dvbs2 Tx") 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", "dvbs2_tx") 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.symbol_rate = symbol_rate = 5000000 self.tx_gain = tx_gain = 0 self.taps = taps = 100 self.samp_rate = samp_rate = symbol_rate * 2 self.rolloff = rolloff = 0.2 self.qtgui_variable = qtgui_variable = '"labul' self.pilots = pilots = 0 self.noise_type = noise_type = "Gaussian" self.noise = noise = 0.1 self.code_rate_qpsk = code_rate_qpsk = "9/10" self.code_rate_8psk = code_rate_8psk = "9/10" self.code_rate_32apsk = code_rate_32apsk = "9/10" self.code_rate_16apsk = code_rate_16apsk = "9/10" self.center_freq = center_freq = 1280e6 self.browse_button = browse_button = 0 self.FEC_Frame_size = FEC_Frame_size = 'Normal' ################################################## # Blocks ################################################## self._tx_gain_range = Range(0, 89, 1, 0, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, 'TX Gain (dB)', "counter_slider", float) self.top_grid_layout.addWidget(self._tx_gain_win, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._rolloff_options = (0.2, 0.25, 0.35, ) self._rolloff_labels = (str(self._rolloff_options[0]), str(self._rolloff_options[1]), str(self._rolloff_options[2]), ) self._rolloff_tool_bar = Qt.QToolBar(self) self._rolloff_tool_bar.addWidget(Qt.QLabel('Rolloff'+": ")) self._rolloff_combo_box = Qt.QComboBox() self._rolloff_tool_bar.addWidget(self._rolloff_combo_box) for label in self._rolloff_labels: self._rolloff_combo_box.addItem(label) self._rolloff_callback = lambda i: Qt.QMetaObject.invokeMethod(self._rolloff_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._rolloff_options.index(i))) self._rolloff_callback(self.rolloff) self._rolloff_combo_box.currentIndexChanged.connect( lambda i: self.set_rolloff(self._rolloff_options[i])) self.top_grid_layout.addWidget(self._rolloff_tool_bar, 0, 1, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.constellation_tab = Qt.QTabWidget() self.constellation_tab_widget_0 = Qt.QWidget() self.constellation_tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.constellation_tab_widget_0) self.constellation_tab_grid_layout_0 = Qt.QGridLayout() self.constellation_tab_layout_0.addLayout(self.constellation_tab_grid_layout_0) self.constellation_tab.addTab(self.constellation_tab_widget_0, 'QPSK') self.constellation_tab_widget_1 = Qt.QWidget() self.constellation_tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.constellation_tab_widget_1) self.constellation_tab_grid_layout_1 = Qt.QGridLayout() self.constellation_tab_layout_1.addLayout(self.constellation_tab_grid_layout_1) self.constellation_tab.addTab(self.constellation_tab_widget_1, '8PSK') self.constellation_tab_widget_2 = Qt.QWidget() self.constellation_tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.constellation_tab_widget_2) self.constellation_tab_grid_layout_2 = Qt.QGridLayout() self.constellation_tab_layout_2.addLayout(self.constellation_tab_grid_layout_2) self.constellation_tab.addTab(self.constellation_tab_widget_2, '16APSK') self.constellation_tab_widget_3 = Qt.QWidget() self.constellation_tab_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.constellation_tab_widget_3) self.constellation_tab_grid_layout_3 = Qt.QGridLayout() self.constellation_tab_layout_3.addLayout(self.constellation_tab_grid_layout_3) self.constellation_tab.addTab(self.constellation_tab_widget_3, '32APSK') self.top_grid_layout.addWidget(self.constellation_tab, 2, 0, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_sink = uhd.usrp_sink( ",".join(('', '')), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink.set_samp_rate(samp_rate) self.uhd_usrp_sink.set_center_freq(center_freq, 0) self.uhd_usrp_sink.set_gain(tx_gain, 0) self._qtgui_variable_tool_bar = Qt.QToolBar(self) if None: self._qtgui_variable_formatter = None else: self._qtgui_variable_formatter = lambda x: str(x) self._qtgui_variable_tool_bar.addWidget(Qt.QLabel('label'+": ")) self._qtgui_variable_label = Qt.QLabel(str(self._qtgui_variable_formatter(self.qtgui_variable))) self._qtgui_variable_tool_bar.addWidget(self._qtgui_variable_label) self.top_grid_layout.addWidget(self._qtgui_variable_tool_bar, 3, 0, 1, 1) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype center_freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink.set_update_time(0.10) self.qtgui_freq_sink.set_y_axis(-140, 10) self.qtgui_freq_sink.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink.enable_autoscale(False) self.qtgui_freq_sink.enable_grid(True) self.qtgui_freq_sink.set_fft_average(0.2) self.qtgui_freq_sink.enable_axis_labels(True) self.qtgui_freq_sink.enable_control_panel(False) if not True: self.qtgui_freq_sink.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink.set_plot_pos_half(not True) labels = ['DVB-S2', '', '', '', '', '', '', '', '', ''] 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.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink.set_line_label(i, labels[i]) self.qtgui_freq_sink.set_line_width(i, widths[i]) self.qtgui_freq_sink.set_line_color(i, colors[i]) self.qtgui_freq_sink.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_win = sip.wrapinstance(self.qtgui_freq_sink.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_win, 4, 0, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._pilots_options = (1, 0, ) self._pilots_labels = ("On", "Off", ) self._pilots_group_box = Qt.QGroupBox('Pilots') self._pilots_box = Qt.QVBoxLayout() 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._pilots_button_group = variable_chooser_button_group() self._pilots_group_box.setLayout(self._pilots_box) for i, label in enumerate(self._pilots_labels): radio_button = Qt.QRadioButton(label) self._pilots_box.addWidget(radio_button) self._pilots_button_group.addButton(radio_button, i) self._pilots_callback = lambda i: Qt.QMetaObject.invokeMethod(self._pilots_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._pilots_options.index(i))) self._pilots_callback(self.pilots) self._pilots_button_group.buttonClicked[int].connect( lambda i: self.set_pilots(self._pilots_options[i])) self.top_grid_layout.addWidget(self._pilots_group_box, 3, 1, 1, 1) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._noise_type_options = ("Uniform", "Gaussian", "Laplacian", "Impulse", ) self._noise_type_labels = (str(self._noise_type_options[0]), str(self._noise_type_options[1]), str(self._noise_type_options[2]), str(self._noise_type_options[3]), ) self._noise_type_tool_bar = Qt.QToolBar(self) self._noise_type_tool_bar.addWidget(Qt.QLabel('Noise Type'+": ")) self._noise_type_combo_box = Qt.QComboBox() self._noise_type_tool_bar.addWidget(self._noise_type_combo_box) for label in self._noise_type_labels: self._noise_type_combo_box.addItem(label) self._noise_type_callback = lambda i: Qt.QMetaObject.invokeMethod(self._noise_type_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._noise_type_options.index(i))) self._noise_type_callback(self.noise_type) self._noise_type_combo_box.currentIndexChanged.connect( lambda i: self.set_noise_type(self._noise_type_options[i])) self.top_grid_layout.addWidget(self._noise_type_tool_bar, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.noise_source = analog.noise_source_c(analog.GR_GAUSSIAN, 0, 0) self._noise_range = Range(0, 1, 0.01, 0.1, 200) self._noise_win = RangeWidget(self._noise_range, self.set_noise, 'Noise', "counter", float) self.top_grid_layout.addWidget(self._noise_win, 2, 1, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.file_source = blocks.file_source(gr.sizeof_char*1, '/home/anisan/videos/The_Maker/900.ts', True) self.file_source.set_begin_tag(pmt.PMT_NIL) self.fft_filter = filter.fft_filter_ccc(1, (firdes.root_raised_cosine(1.0, samp_rate, samp_rate/2, rolloff, taps)), 1) self.fft_filter.declare_sample_delay(0) self.dvbs2_physical = dvbs2.physical_cc(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_16APSK, dvbs2.PILOTS_OFF, 0) self.dvbs2_modulator = dvbs2.modulator_bc(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_16APSK) self.dvbs2_ldpc = dvbs2.ldpc_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_OTHER) self.dvbs2_interleaver = dvbs2.interleaver_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_16APSK) self.dvbs2_bbscrambler = dvbs2.bbscrambler_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10) self.dvbs2_bbheader = dvbs2.bbheader_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.RO_0_20) self.dvb_bch = dtv.dvb_bch_bb(dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10) self._code_rate_qpsk_options = ["1/4", "1/3", "2/5", "1/2", "3/5", "2/3", "3/4", "4/5", "5/6", "8/9", "9/10"] self._code_rate_qpsk_labels = map(str, self._code_rate_qpsk_options) self._code_rate_qpsk_group_box = Qt.QGroupBox('Code Rate') self._code_rate_qpsk_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._code_rate_qpsk_button_group = variable_chooser_button_group() self._code_rate_qpsk_group_box.setLayout(self._code_rate_qpsk_box) for i, label in enumerate(self._code_rate_qpsk_labels): radio_button = Qt.QRadioButton(label) self._code_rate_qpsk_box.addWidget(radio_button) self._code_rate_qpsk_button_group.addButton(radio_button, i) self._code_rate_qpsk_callback = lambda i: Qt.QMetaObject.invokeMethod(self._code_rate_qpsk_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._code_rate_qpsk_options.index(i))) self._code_rate_qpsk_callback(self.code_rate_qpsk) self._code_rate_qpsk_button_group.buttonClicked[int].connect( lambda i: self.set_code_rate_qpsk(self._code_rate_qpsk_options[i])) self.constellation_tab_layout_0.addWidget(self._code_rate_qpsk_group_box) self._code_rate_8psk_options = ["3/5", "2/3", "3/4", "4/5", "5/6", "8/9", "9/10"] self._code_rate_8psk_labels = map(str, self._code_rate_8psk_options) self._code_rate_8psk_group_box = Qt.QGroupBox('Code Rate') self._code_rate_8psk_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._code_rate_8psk_button_group = variable_chooser_button_group() self._code_rate_8psk_group_box.setLayout(self._code_rate_8psk_box) for i, label in enumerate(self._code_rate_8psk_labels): radio_button = Qt.QRadioButton(label) self._code_rate_8psk_box.addWidget(radio_button) self._code_rate_8psk_button_group.addButton(radio_button, i) self._code_rate_8psk_callback = lambda i: Qt.QMetaObject.invokeMethod(self._code_rate_8psk_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._code_rate_8psk_options.index(i))) self._code_rate_8psk_callback(self.code_rate_8psk) self._code_rate_8psk_button_group.buttonClicked[int].connect( lambda i: self.set_code_rate_8psk(self._code_rate_8psk_options[i])) self.constellation_tab_layout_1.addWidget(self._code_rate_8psk_group_box) self._code_rate_32apsk_options = ["3/4", "4/5", "5/6", "8/9", "9/10"] self._code_rate_32apsk_labels = map(str, self._code_rate_32apsk_options) self._code_rate_32apsk_group_box = Qt.QGroupBox('Code Rate') self._code_rate_32apsk_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._code_rate_32apsk_button_group = variable_chooser_button_group() self._code_rate_32apsk_group_box.setLayout(self._code_rate_32apsk_box) for i, label in enumerate(self._code_rate_32apsk_labels): radio_button = Qt.QRadioButton(label) self._code_rate_32apsk_box.addWidget(radio_button) self._code_rate_32apsk_button_group.addButton(radio_button, i) self._code_rate_32apsk_callback = lambda i: Qt.QMetaObject.invokeMethod(self._code_rate_32apsk_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._code_rate_32apsk_options.index(i))) self._code_rate_32apsk_callback(self.code_rate_32apsk) self._code_rate_32apsk_button_group.buttonClicked[int].connect( lambda i: self.set_code_rate_32apsk(self._code_rate_32apsk_options[i])) self.constellation_tab_layout_3.addWidget(self._code_rate_32apsk_group_box) self._code_rate_16apsk_options = [ "2/3", "3/4", "4/5", "5/6", "8/9", "9/10"] self._code_rate_16apsk_labels = map(str, self._code_rate_16apsk_options) self._code_rate_16apsk_group_box = Qt.QGroupBox('Code Rate') self._code_rate_16apsk_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._code_rate_16apsk_button_group = variable_chooser_button_group() self._code_rate_16apsk_group_box.setLayout(self._code_rate_16apsk_box) for i, label in enumerate(self._code_rate_16apsk_labels): radio_button = Qt.QRadioButton(label) self._code_rate_16apsk_box.addWidget(radio_button) self._code_rate_16apsk_button_group.addButton(radio_button, i) self._code_rate_16apsk_callback = lambda i: Qt.QMetaObject.invokeMethod(self._code_rate_16apsk_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._code_rate_16apsk_options.index(i))) self._code_rate_16apsk_callback(self.code_rate_16apsk) self._code_rate_16apsk_button_group.buttonClicked[int].connect( lambda i: self.set_code_rate_16apsk(self._code_rate_16apsk_options[i])) self.constellation_tab_grid_layout_2.addWidget(self._code_rate_16apsk_group_box) _browse_button_push_button = Qt.QPushButton('Browse') self._browse_button_choices = {'Pressed': 1, 'Released': 0} _browse_button_push_button.pressed.connect(lambda: self.set_browse_button(self._browse_button_choices['Pressed'])) _browse_button_push_button.released.connect(lambda: self.set_browse_button(self._browse_button_choices['Released'])) self.top_grid_layout.addWidget(_browse_button_push_button, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.add_bloc = blocks.add_vcc(1) self._FEC_Frame_size_options = ('Normal', 'Short', ) self._FEC_Frame_size_labels = (str(self._FEC_Frame_size_options[0]), str(self._FEC_Frame_size_options[1]), ) self._FEC_Frame_size_group_box = Qt.QGroupBox('FEC Frame Size') self._FEC_Frame_size_box = Qt.QVBoxLayout() 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._FEC_Frame_size_button_group = variable_chooser_button_group() self._FEC_Frame_size_group_box.setLayout(self._FEC_Frame_size_box) for i, label in enumerate(self._FEC_Frame_size_labels): radio_button = Qt.QRadioButton(label) self._FEC_Frame_size_box.addWidget(radio_button) self._FEC_Frame_size_button_group.addButton(radio_button, i) self._FEC_Frame_size_callback = lambda i: Qt.QMetaObject.invokeMethod(self._FEC_Frame_size_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._FEC_Frame_size_options.index(i))) self._FEC_Frame_size_callback(self.FEC_Frame_size) self._FEC_Frame_size_button_group.buttonClicked[int].connect( lambda i: self.set_FEC_Frame_size(self._FEC_Frame_size_options[i])) self.top_grid_layout.addWidget(self._FEC_Frame_size_group_box, 4, 1, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) ################################################## # Connections ################################################## self.connect((self.add_bloc, 0), (self.qtgui_freq_sink, 0)) self.connect((self.dvb_bch, 0), (self.dvbs2_ldpc, 0)) self.connect((self.dvbs2_bbheader, 0), (self.dvbs2_bbscrambler, 0)) self.connect((self.dvbs2_bbscrambler, 0), (self.dvb_bch, 0)) self.connect((self.dvbs2_interleaver, 0), (self.dvbs2_modulator, 0)) self.connect((self.dvbs2_ldpc, 0), (self.dvbs2_interleaver, 0)) self.connect((self.dvbs2_modulator, 0), (self.dvbs2_physical, 0)) self.connect((self.dvbs2_physical, 0), (self.fft_filter, 0)) self.connect((self.fft_filter, 0), (self.add_bloc, 0)) self.connect((self.file_source, 0), (self.dvbs2_bbheader, 0)) self.connect((self.noise_source, 0), (self.add_bloc, 1))
def __init__(self): gr.top_block.__init__(self, "Uhd Packet Rx") Qt.QWidget.__init__(self) self.setWindowTitle("Uhd Packet 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", "uhd_packet_rx") self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.sps = sps = 2 self.rate = rate = 2 self.polys = polys = [109, 79] self.nfilts = nfilts = 32 self.k = k = 7 self.eb = eb = 0.22 self.Const_PLD = Const_PLD = digital.constellation_calcdist( (digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base() self.Const_PLD.gen_soft_dec_lut(8) self.samp_rate = samp_rate = 1000e3 self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine( nfilts, sps * nfilts, 1.0, eb, 11 * sps * nfilts) self.rep = rep = 3 self.on = on = 0 self.hdr_format = hdr_format = digital.header_format_counter( digital.packet_utils.default_access_code, 3, Const_PLD.bits_per_symbol()) self.gain = gain = 20 self.freq = freq = 484e6 self.dec_hdr = dec_hdr = fec.dummy_decoder.make(8000) self.dec = dec = fec.cc_decoder.make(8000, k, rate, (polys), 0, -1, fec.CC_TERMINATED, False) self.amp = amp = 500 self.Const_HDR = Const_HDR = digital.constellation_calcdist( (digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base() self.Const_HDR.gen_soft_dec_lut(8) ################################################## # Blocks ################################################## self.tab1 = Qt.QTabWidget() self.tab1_widget_0 = Qt.QWidget() self.tab1_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab1_widget_0) self.tab1_grid_layout_0 = Qt.QGridLayout() self.tab1_layout_0.addLayout(self.tab1_grid_layout_0) self.tab1.addTab(self.tab1_widget_0, 'Const') self.tab1_widget_1 = Qt.QWidget() self.tab1_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab1_widget_1) self.tab1_grid_layout_1 = Qt.QGridLayout() self.tab1_layout_1.addLayout(self.tab1_grid_layout_1) self.tab1.addTab(self.tab1_widget_1, 'Time') self.top_grid_layout.addWidget(self.tab1, 2, 0, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.tab0 = Qt.QTabWidget() self.tab0_widget_0 = Qt.QWidget() self.tab0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_0) self.tab0_grid_layout_0 = Qt.QGridLayout() self.tab0_layout_0.addLayout(self.tab0_grid_layout_0) self.tab0.addTab(self.tab0_widget_0, 'Time') self.tab0_widget_1 = Qt.QWidget() self.tab0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_1) self.tab0_grid_layout_1 = Qt.QGridLayout() self.tab0_layout_1.addLayout(self.tab0_grid_layout_1) self.tab0.addTab(self.tab0_widget_1, 'Const.') self.top_grid_layout.addWidget(self.tab0, 2, 1, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._samp_rate_range = Range(200e3, 10e6, 200e3, 1000e3, 200) self._samp_rate_win = RangeWidget(self._samp_rate_range, self.set_samp_rate, 'Sample Rate', "counter_slider", float) self.top_grid_layout.addWidget(self._samp_rate_win, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) _on_check_box = Qt.QCheckBox('On') self._on_choices = {True: 1, False: 0} self._on_choices_inv = dict( (v, k) for k, v in self._on_choices.iteritems()) self._on_callback = lambda i: Qt.QMetaObject.invokeMethod( _on_check_box, "setChecked", Qt.Q_ARG("bool", self._on_choices_inv[i])) self._on_callback(self.on) _on_check_box.stateChanged.connect( lambda i: self.set_on(self._on_choices[bool(i)])) self.top_grid_layout.addWidget(_on_check_box) self._gain_range = Range(0, 31.5, 0.5, 20, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, 'Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._gain_win, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._freq_range = Range(480e6, 490e6, 100, 484e6, 200) self._freq_win = RangeWidget(self._freq_range, self.set_freq, 'Frequency', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_win, 0, 1, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._amp_range = Range(0, 15000, 10, 500, 200) self._amp_win = RangeWidget(self._amp_range, self.set_amp, 'Amplitude', "counter_slider", float) self.top_grid_layout.addWidget(self._amp_win, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(('addr=192.168.10.2', "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_clock_source('gpsdo', 0) self.uhd_usrp_source_0.set_time_source('gpsdo', 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq( uhd.tune_request(freq, samp_rate / 2.0), 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna('TX/RX', 0) self.uhd_usrp_source_0.set_auto_dc_offset("", 0) self.uhd_usrp_source_0.set_auto_iq_balance("", 0) self.qtgui_time_sink_x_1_0_0_1 = qtgui.time_sink_c( 1250, #size 1, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0_0_1.set_update_time(0.10) self.qtgui_time_sink_x_1_0_0_1.set_y_axis(-2, 2) self.qtgui_time_sink_x_1_0_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_1_0_0_1.set_trigger_mode( qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 25, 0, "time_est") self.qtgui_time_sink_x_1_0_0_1.enable_autoscale(False) self.qtgui_time_sink_x_1_0_0_1.enable_grid(False) self.qtgui_time_sink_x_1_0_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_1_0_0_1.enable_control_panel(False) self.qtgui_time_sink_x_1_0_0_1.enable_stem_plot(False) if not False: self.qtgui_time_sink_x_1_0_0_1.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 = [3, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [0, -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_1_0_0_1.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0_0_1.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1_0_0_1.pyqwidget(), Qt.QWidget) self.tab0_grid_layout_0.addWidget(self._qtgui_time_sink_x_1_0_0_1_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.01) self.qtgui_time_sink_x_0.set_y_axis(-2, 2) 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_NORM, qtgui.TRIG_SLOPE_POS, 0.5, 0.5e-3, 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.tab1_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c( 800, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True) if not False: self.qtgui_const_sink_x_0_0_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_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.tab0_grid_layout_1.addWidget(self._qtgui_const_sink_x_0_0_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.01) 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_NORM, qtgui.TRIG_SLOPE_POS, 0.5, 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 False: 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.tab1_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win) self.packet_rx_0 = packet_rx( eb=eb, hdr_const=Const_HDR, hdr_format=digital.header_format_default( digital.packet_utils.default_access_code, 0), pld_const=Const_PLD, psf_taps=rx_rrc_taps, puncpat='11', samp_rate=250000, sps=sps, ) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc( sps, eb, 44, 0.05) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((on, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((amp, )) self.blocks_message_debug_0_0_0 = blocks.message_debug() ################################################## # Connections ################################################## self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.packet_rx_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.packet_rx_0, 1), (self.qtgui_const_sink_x_0_0_0, 0)) self.connect((self.packet_rx_0, 2), (self.qtgui_time_sink_x_1_0_0_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_fll_band_edge_cc_0, 0))
def __init__(self): gr.top_block.__init__(self, "Recepteur ADSB -Mode-S") Qt.QWidget.__init__(self) self.setWindowTitle("Recepteur ADSB -Mode-S") 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", "adsb_receiver") 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.seuil = seuil = 0.003 self.samp_rate = samp_rate = 2000000 self.freq = freq = 1090000000 ################################################## # Blocks ################################################## self._seuil_range = Range(0.0001, 0.3, 0.0001, 0.003, 200) self._seuil_win = RangeWidget(self._seuil_range, self.set_seuil, 'Seuil', "counter_slider", float) self.top_grid_layout.addWidget(self._seuil_win, 0, 1, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._freq_range = Range(950000000, 1093000000, 10000, 1090000000, 200) self._freq_win = RangeWidget(self._freq_range, self.set_freq, 'Frequency', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_win, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.figures = Qt.QTabWidget() self.figures_widget_0 = Qt.QWidget() self.figures_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.figures_widget_0) self.figures_grid_layout_0 = Qt.QGridLayout() self.figures_layout_0.addLayout(self.figures_grid_layout_0) self.figures.addTab(self.figures_widget_0, 'Waterfall (recu)') self.figures_widget_1 = Qt.QWidget() self.figures_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.figures_widget_1) self.figures_grid_layout_1 = Qt.QGridLayout() self.figures_layout_1.addLayout(self.figures_grid_layout_1) self.figures.addTab(self.figures_widget_1, 'Spectre (recu)') self.figures_widget_2 = Qt.QWidget() self.figures_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.figures_widget_2) self.figures_grid_layout_2 = Qt.QGridLayout() self.figures_layout_2.addLayout(self.figures_grid_layout_2) self.figures.addTab(self.figures_widget_2, 'Rx: temporel / bits') self.top_grid_layout.addWidget(self.figures, 1, 0, 3, 2) for r in range(1, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self.rtlsdr_source_0_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' ) self.rtlsdr_source_0_0.set_time_unknown_pps(osmosdr.time_spec_t()) self.rtlsdr_source_0_0.set_sample_rate(samp_rate) self.rtlsdr_source_0_0.set_center_freq(freq, 0) self.rtlsdr_source_0_0.set_freq_corr(0, 0) self.rtlsdr_source_0_0.set_gain(14, 0) self.rtlsdr_source_0_0.set_if_gain(24, 0) self.rtlsdr_source_0_0.set_bb_gain(20, 0) self.rtlsdr_source_0_0.set_antenna('', 0) self.rtlsdr_source_0_0.set_bandwidth(samp_rate, 0) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Spectre", #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) 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 range(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.figures_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_time_sink_x_0_2 = qtgui.time_sink_f( 250, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_2.set_update_time(0.10) self.qtgui_time_sink_x_0_2.set_y_axis(-0.1, 1.1) self.qtgui_time_sink_x_0_2.set_y_label('Manchester bits', "") self.qtgui_time_sink_x_0_2.enable_tags(True) self.qtgui_time_sink_x_0_2.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0.000008, 0, "burst") self.qtgui_time_sink_x_0_2.enable_autoscale(False) self.qtgui_time_sink_x_0_2.enable_grid(False) self.qtgui_time_sink_x_0_2.enable_axis_labels(True) self.qtgui_time_sink_x_0_2.enable_control_panel(True) self.qtgui_time_sink_x_0_2.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 = [8, -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_2.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_2_win = sip.wrapinstance(self.qtgui_time_sink_x_0_2.pyqwidget(), Qt.QWidget) self.figures_grid_layout_2.addWidget(self._qtgui_time_sink_x_0_2_win, 0, 1, 1, 1) for r in range(0, 1): self.figures_grid_layout_2.setRowStretch(r, 1) for c in range(1, 2): self.figures_grid_layout_2.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label('Rx mag2', "") self.qtgui_time_sink_x_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(True) self.qtgui_time_sink_x_0_0.enable_stem_plot(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] 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_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.figures_grid_layout_2.addWidget(self._qtgui_time_sink_x_0_0_win, 0, 0, 1, 1) for r in range(0, 1): self.figures_grid_layout_2.setRowStretch(r, 1) for c in range(0, 1): self.figures_grid_layout_2.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc samp_rate, #bw "", #name 1 ) 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) 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 range(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.figures_layout_1.addWidget(self._qtgui_freq_sink_x_0_win) self.digital_correlate_access_code_tag_xx_0 = digital.correlate_access_code_tag_bb('010100001010000001001010110', 0, 'burst') self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_threshold_ff_0 = blocks.threshold_ff(seuil, seuil, 0) self.blocks_tagged_file_sink_0 = blocks.tagged_file_sink(gr.sizeof_char*1, samp_rate) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char*1) self.blocks_float_to_uchar_0 = blocks.float_to_uchar() self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_burst_tagger_0 = blocks.burst_tagger(gr.sizeof_char) self.blocks_burst_tagger_0.set_true_tag('',True) self.blocks_burst_tagger_0.set_false_tag('burst',False) self.analog_sig_source_x_1 = analog.sig_source_s(samp_rate, analog.GR_COS_WAVE, 80, 1, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_1, 0), (self.blocks_burst_tagger_0, 1)) self.connect((self.blocks_burst_tagger_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_burst_tagger_0, 0), (self.blocks_tagged_file_sink_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_float_to_uchar_0, 0), (self.digital_correlate_access_code_tag_xx_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_float_to_uchar_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_0_2, 0)) self.connect((self.digital_correlate_access_code_tag_xx_0, 0), (self.blocks_burst_tagger_0, 0)) self.connect((self.digital_correlate_access_code_tag_xx_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.rtlsdr_source_0_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.rtlsdr_source_0_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rtlsdr_source_0_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "OFDM Transceiver") Qt.QWidget.__init__(self) self.setWindowTitle("OFDM Transceiver") 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", "rx_ofdm") 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.pilot_symbols = pilot_symbols = (( 1, 1, 1, -1, ), ) self.pilot_carriers = pilot_carriers = (( -21, -7, 7, 21, ), ) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_length_tag_key = packet_length_tag_key = "packet_len" self.occupied_carriers = occupied_carriers = ( list(range(-26, -21)) + list(range(-20, -7)) + list(range(-6, 0)) + list(range(1, 7)) + list(range(8, 21)) + list(range(22, 27)), ) self.num_syms = num_syms = 1 self.length_tag_key = length_tag_key = "frame_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = 64 self.tx_amp = tx_amp = 0.034 self.sync_word2 = sync_word2 = [ 0j, 0j, 0j, 0j, 0j, 0j, (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), 0j, (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), 0j, 0j, 0j, 0j, 0j ] self.sync_word1 = sync_word1 = [ 0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0. ] self.sc_select = sc_select = 0 self.samp_rate = samp_rate = 1e6 self.rx_gain = rx_gain = 30 self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_static( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, 0, True) self.packet_len = packet_len = int(96 / 8 * num_syms) self.offset = offset = 8 self.mp_gain = mp_gain = 0 self.mp_delay = mp_delay = 0 self.header_formatter = header_formatter = digital.packet_header_ofdm( occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=False) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_static( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, 0, True) self.freqc = freqc = 900e6 self.cp_delay = cp_delay = 0 ################################################## # Blocks ################################################## self._tx_amp_range = Range(0.001, 0.1, .001, 0.034, 200) self._tx_amp_win = RangeWidget(self._tx_amp_range, self.set_tx_amp, 'TX Amplitude', "counter_slider", float) self.top_grid_layout.addWidget(self._tx_amp_win, 1, 0, 1, 8) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 8): self.top_grid_layout.setColumnStretch(c, 1) self.tab_const = Qt.QTabWidget() self.tab_const_widget_0 = Qt.QWidget() self.tab_const_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_const_widget_0) self.tab_const_grid_layout_0 = Qt.QGridLayout() self.tab_const_layout_0.addLayout(self.tab_const_grid_layout_0) self.tab_const.addTab(self.tab_const_widget_0, 'Pre-Equalization (Single-Subcarrier)') self.tab_const_widget_1 = Qt.QWidget() self.tab_const_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_const_widget_1) self.tab_const_grid_layout_1 = Qt.QGridLayout() self.tab_const_layout_1.addLayout(self.tab_const_grid_layout_1) self.tab_const.addTab(self.tab_const_widget_1, 'Pre-Equalization (All Subcarriers)') self.tab_const_widget_2 = Qt.QWidget() self.tab_const_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_const_widget_2) self.tab_const_grid_layout_2 = Qt.QGridLayout() self.tab_const_layout_2.addLayout(self.tab_const_grid_layout_2) self.tab_const.addTab(self.tab_const_widget_2, 'Post-Equalization (All Subcarriers)') self.top_grid_layout.addWidget(self.tab_const, 2, 0, 8, 4) for r in range(2, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self._sc_select_range = Range(0, fft_len - 1, 1, 0, 200) self._sc_select_win = RangeWidget(self._sc_select_range, self.set_sc_select, 'Sub Carrier Select', "counter_slider", float) self.top_grid_layout.addWidget(self._sc_select_win, 12, 0, 1, 4) for r in range(12, 13): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self._rx_gain_range = Range(0, 64, 1, 30, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, 'RX Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._rx_gain_win, 0, 0, 1, 8) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 8): self.top_grid_layout.setColumnStretch(c, 1) self._mp_gain_range = Range(0, 1, 0.001, 0, 200) self._mp_gain_win = RangeWidget(self._mp_gain_range, self.set_mp_gain, 'Multipath Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._mp_gain_win, 13, 0, 1, 4) for r in range(13, 14): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self._mp_delay_range = Range(0, 32, 1, 0, 200) self._mp_delay_win = RangeWidget(self._mp_delay_range, self.set_mp_delay, 'Multipath Delay (Samples)', "counter_slider", float) self.top_grid_layout.addWidget(self._mp_delay_win, 13, 4, 1, 4) for r in range(13, 14): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self._cp_delay_range = Range(0, 3, 1, 0, 200) self._cp_delay_win = RangeWidget(self._cp_delay_range, self.set_cp_delay, 'CP Delay (samples)', "counter_slider", float) self.top_grid_layout.addWidget(self._cp_delay_win, 12, 4, 1, 4) for r in range(12, 13): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( fft_len, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Channel Response", #name 1) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-100, 0) 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(True) 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(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [2, 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 range(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, 4, 8, 4) for r in range(2, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_1 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_1.set_update_time(0.10) self.qtgui_const_sink_x_0_1.set_y_axis(-2.5, 2.5) self.qtgui_const_sink_x_0_1.set_x_axis(-2.5, 2.5) self.qtgui_const_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_1.enable_autoscale(False) self.qtgui_const_sink_x_0_1.enable_grid(True) self.qtgui_const_sink_x_0_1.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_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_1_win = sip.wrapinstance( self.qtgui_const_sink_x_0_1.pyqwidget(), Qt.QWidget) self.tab_const_layout_1.addWidget(self._qtgui_const_sink_x_0_1_win) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2.5, 2.5) self.qtgui_const_sink_x_0_0.set_x_axis(-2.5, 2.5) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, '') self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(True) self.qtgui_const_sink_x_0_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_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tab_const_layout_0.addWidget(self._qtgui_const_sink_x_0_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #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.5, 2.5) self.qtgui_const_sink_x_0.set_x_axis(-2.5, 2.5) 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(True) 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.tab_const_layout_2.addWidget(self._qtgui_const_sink_x_0_win) self._num_syms_range = Range(1, 20, 1, 1, 200) self._num_syms_win = RangeWidget(self._num_syms_range, self.set_num_syms, '# of Symbols per Pkt', "counter_slider", float) self.top_grid_layout.addWidget(self._num_syms_win, 11, 0, 1, 8) for r in range(11, 12): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 8): self.top_grid_layout.setColumnStretch(c, 1) self.iio_pluto_source_0 = iio.pluto_source('usb:1.4.5', int(freqc), int(samp_rate), 20000000, 32768, True, True, True, 'manual', rx_gain, '', True) self.iio_pluto_sink_0 = iio.pluto_sink('usb:1.3.5', int(freqc), int(samp_rate), 20000000, 32768, False, 10.0, '', True) self.fft_vxx_1 = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_0 = fft.fft_vcc(fft_len, True, (), True, 1) self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b( header_formatter.base()) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len // 4, packet_length_tag_key=packet_length_tag_key, occupied_carriers=occupied_carriers, pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=sync_word1, sync_word2=sync_word2, bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=False) self.digital_ofdm_sync_sc_cfb_0 = digital.ofdm_sync_sc_cfb( fft_len, fft_len // 4, False, 0.9) self.digital_ofdm_serializer_vcc_payload = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, packet_length_tag_key, 1, '', True) self.digital_ofdm_serializer_vcc_header = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, '', 0, '', True) self.digital_ofdm_frame_equalizer_vcvc_1 = digital.ofdm_frame_equalizer_vcvc( payload_equalizer.base(), fft_len // 4, length_tag_key, True, 0) self.digital_ofdm_frame_equalizer_vcvc_0 = digital.ofdm_frame_equalizer_vcvc( header_equalizer.base(), fft_len // 4, length_tag_key, True, 1) self.digital_ofdm_chanest_vcvc_0 = digital.ofdm_chanest_vcvc( sync_word1, sync_word2, 1, 0, 3, False) self.digital_header_payload_demux_0 = digital.header_payload_demux( 3, fft_len, fft_len // 4, length_tag_key, "", True, gr.sizeof_gr_complex, "rx_time", int(samp_rate), (), 0) self.digital_crc32_bb_0 = digital.crc32_bb(True, packet_length_tag_key, True) self.digital_constellation_decoder_cb_1 = digital.constellation_decoder_cb( payload_mod.base()) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( header_mod.base()) self.blocks_vector_to_stream_0_0_1 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, 64) self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, 64) self.blocks_tag_debug_1 = blocks.tag_debug(gr.sizeof_char * 1, 'Rx Bytes', "") self.blocks_tag_debug_1.set_display(False) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, 64) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, packet_length_tag_key) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( payload_mod.bits_per_symbol(), 8, packet_length_tag_key, True, gr.GR_LSB_FIRST) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc(mp_gain) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(tx_amp) self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_gr_complex, 1, fft_len, sc_select) self.blocks_delay_2 = blocks.delay(gr.sizeof_gr_complex * 1, mp_delay) self.blocks_delay_1 = blocks.delay(gr.sizeof_gr_complex * 1, cp_delay) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, fft_len + fft_len // 4) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_random_source_x_0 = blocks.vector_source_b( list(map(int, numpy.random.randint(0, 255, 1000))), True) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc( -2.0 / fft_len) ################################################## # Connections ################################################## self.msg_connect((self.digital_packet_headerparser_b_0, 'header_data'), (self.digital_header_payload_demux_0, 'header_data')) self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_ofdm_sync_sc_cfb_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_1, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_delay_2, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_keep_m_in_n_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.iio_pluto_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.digital_header_payload_demux_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_1, 0)) self.connect((self.blocks_vector_to_stream_0_0, 0), (self.blocks_delay_1, 0)) self.connect((self.blocks_vector_to_stream_0_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_vector_to_stream_0_0_1, 0), (self.blocks_keep_m_in_n_0, 0)) self.connect((self.blocks_vector_to_stream_0_0_1, 0), (self.qtgui_const_sink_x_0_1, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_packet_headerparser_b_0, 0)) self.connect((self.digital_constellation_decoder_cb_1, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.blocks_tag_debug_1, 0)) self.connect((self.digital_header_payload_demux_0, 1), (self.blocks_vector_to_stream_0_0, 0)) self.connect((self.digital_header_payload_demux_0, 0), (self.fft_vxx_0, 0)) self.connect((self.digital_ofdm_chanest_vcvc_0, 0), (self.digital_ofdm_frame_equalizer_vcvc_0, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_0, 0), (self.digital_ofdm_serializer_vcc_header, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_1, 0), (self.digital_ofdm_serializer_vcc_payload, 0)) self.connect((self.digital_ofdm_serializer_vcc_header, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_ofdm_serializer_vcc_payload, 0), (self.digital_constellation_decoder_cb_1, 0)) self.connect((self.digital_ofdm_serializer_vcc_payload, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 1), (self.digital_header_payload_demux_0, 1)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_chanest_vcvc_0, 0)) self.connect((self.fft_vxx_1, 0), (self.blocks_vector_to_stream_0_0_1, 0)) self.connect((self.fft_vxx_1, 0), (self.digital_ofdm_frame_equalizer_vcvc_1, 0)) self.connect((self.iio_pluto_source_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.iio_pluto_source_0, 0), (self.blocks_delay_2, 0))
def __init__(self): gr.top_block.__init__(self, "FM Sender") Qt.QWidget.__init__(self) self.setWindowTitle("FM Sender") 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", "fm_transmitter") 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.osr_rf = osr_rf = 4 self.osr_mod = osr_mod = 5 self.fs_file = fs_file = 48000 self.tx_gain_db = tx_gain_db = 0.8 self.outbuffer = outbuffer = 10 self.n_filter_delay = n_filter_delay = 289 // 2 self.gain_rds = gain_rds = 0.05 self.gain_pilot = gain_pilot = 0.05 self.gain_mono = gain_mono = 0.3 self.gain_lrdiff = gain_lrdiff = 0.5 self.gain_hinz = gain_hinz = 0.05 self.fs_rf = fs_rf = fs_file * osr_mod * osr_rf self.fs_mod = fs_mod = fs_file * osr_mod self.fc_pirate = fc_pirate = 99e6 ################################################## # Blocks ################################################## self._tx_gain_db_range = Range(0, 1, 0.01, 0.8, 200) self._tx_gain_db_win = RangeWidget(self._tx_gain_db_range, self.set_tx_gain_db, 'tx_gain_db', "counter_slider", float) self.top_grid_layout.addWidget(self._tx_gain_db_win, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_tab_widget_0 = Qt.QTabWidget() self.qtgui_tab_widget_0_widget_0 = Qt.QWidget() self.qtgui_tab_widget_0_layout_0 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_0) self.qtgui_tab_widget_0_grid_layout_0 = Qt.QGridLayout() self.qtgui_tab_widget_0_layout_0.addLayout( self.qtgui_tab_widget_0_grid_layout_0) self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_0, 'Tab 0') self.qtgui_tab_widget_0_widget_1 = Qt.QWidget() self.qtgui_tab_widget_0_layout_1 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_1) self.qtgui_tab_widget_0_grid_layout_1 = Qt.QGridLayout() self.qtgui_tab_widget_0_layout_1.addLayout( self.qtgui_tab_widget_0_grid_layout_1) self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_1, 'Tab 1') self.qtgui_tab_widget_0_widget_2 = Qt.QWidget() self.qtgui_tab_widget_0_layout_2 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_2) self.qtgui_tab_widget_0_grid_layout_2 = Qt.QGridLayout() self.qtgui_tab_widget_0_layout_2.addLayout( self.qtgui_tab_widget_0_grid_layout_2) self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_2, 'Tab 2') self.top_grid_layout.addWidget(self.qtgui_tab_widget_0, 5, 0, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._n_filter_delay_range = Range(0, 400, 1, 289 // 2, 200) self._n_filter_delay_win = RangeWidget(self._n_filter_delay_range, self.set_n_filter_delay, 'n_filter_delay', "counter_slider", int) self.top_grid_layout.addWidget(self._n_filter_delay_win, 9, 0, 1, 1) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._gain_rds_range = Range(0, 1, 0.05, 0.05, 200) self._gain_rds_win = RangeWidget(self._gain_rds_range, self.set_gain_rds, 'gain_rds', "counter_slider", float) self.top_grid_layout.addWidget(self._gain_rds_win, 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._gain_pilot_range = Range(0, 1, 0.05, 0.05, 200) self._gain_pilot_win = RangeWidget(self._gain_pilot_range, self.set_gain_pilot, 'gain_pilot', "counter_slider", float) self.top_grid_layout.addWidget(self._gain_pilot_win, 3, 0, 1, 1) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._gain_mono_range = Range(0, 1, 0.05, 0.3, 200) self._gain_mono_win = RangeWidget(self._gain_mono_range, self.set_gain_mono, 'gain_mono', "counter_slider", float) self.top_grid_layout.addWidget(self._gain_mono_win, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._gain_lrdiff_range = Range(0, 1, 0.05, 0.5, 200) self._gain_lrdiff_win = RangeWidget(self._gain_lrdiff_range, self.set_gain_lrdiff, 'gain_lrdiff', "counter_slider", float) self.top_grid_layout.addWidget(self._gain_lrdiff_win, 2, 0, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._gain_hinz_range = Range(0, 0.5, 0.05, 0.05, 200) self._gain_hinz_win = RangeWidget(self._gain_hinz_range, self.set_gain_hinz, 'gain_hinz', "counter_slider", float) self.top_grid_layout.addWidget(self._gain_hinz_win, 4, 0, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_sink_1 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", args='', channels=list(range(0, 1)), ), '', ) self.uhd_usrp_sink_1.set_center_freq(fc_pirate, 0) self.uhd_usrp_sink_1.set_normalized_gain(tx_gain_db, 0) self.uhd_usrp_sink_1.set_antenna('TX/RX', 0) self.uhd_usrp_sink_1.set_bandwidth(200e3, 0) self.uhd_usrp_sink_1.set_samp_rate(fs_rf) self.uhd_usrp_sink_1.set_time_unknown_pps(uhd.time_spec()) self.rds_encoder_0 = rds.encoder(0, 20, True, 'PIRAT 17', 47.11e6, True, False, 13, 3, 147, 'SAALFELDEN TESTING') self.rational_resampler_xxx_0_0_0_0 = filter.rational_resampler_fff( interpolation=osr_mod, decimation=1, taps=None, fractional_bw=None) self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_fff( interpolation=osr_mod, decimation=1, taps=None, fractional_bw=None) self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff( interpolation=osr_mod, decimation=1, taps=None, fractional_bw=None) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=osr_rf, decimation=1, taps=None, fractional_bw=None) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 4096 * 2, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc fs_mod, #bw "fmChannelData", #name 1) 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(True) 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) self.qtgui_freq_sink_x_0.set_plot_pos_half(not 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] for i in range(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.qtgui_tab_widget_0_layout_0.addWidget( self._qtgui_freq_sink_x_0_win) self.low_pass_filter_0 = filter.interp_fir_filter_fff( 1, firdes.low_pass(1, fs_mod, 2.5e3, .5e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0.set_max_output_buffer(10) self.gr_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) self.gr_unpack_k_bits_bb_0.set_max_output_buffer(10) self.gr_sig_source_x_0_0 = analog.sig_source_f(fs_mod, analog.GR_COS_WAVE, 57e3, 1, 0, 0) self.gr_multiply_xx_0 = blocks.multiply_vff(1) self.gr_multiply_xx_0.set_max_output_buffer(10) self.gr_map_bb_1 = digital.map_bb([1, 2]) self.gr_map_bb_1.set_max_output_buffer(10) self.gr_map_bb_0 = digital.map_bb([-1, 1]) self.gr_map_bb_0.set_max_output_buffer(10) self.gr_diff_encoder_bb_0 = digital.diff_encoder_bb(2) self.gr_diff_encoder_bb_0.set_max_output_buffer(10) self.gr_char_to_float_0 = blocks.char_to_float(1, 1) self.gr_char_to_float_0.set_max_output_buffer(10) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float * 1, int(fs_mod / 2.375 / 1000)) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_xx_0_2 = blocks.multiply_const_ff( gain_hinz, 1) self.blocks_multiply_const_xx_0_0_0 = blocks.multiply_const_ff( gain_pilot, 1) self.blocks_multiply_const_xx_0_0 = blocks.multiply_const_ff( gain_lrdiff, 1) self.blocks_multiply_const_xx_0 = blocks.multiply_const_ff( gain_mono, 1) self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_ff(1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_ff(gain_rds) self.blocks_multiply_const_vxx_0_0.set_max_output_buffer(10) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(1) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_float * 1, n_filter_delay) self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, n_filter_delay) self.blocks_add_xx_0_0 = blocks.add_vff(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.band_pass_filter_1_0 = filter.fir_filter_fff( 1, firdes.band_pass(1, fs_mod, 30, 15e3, 100, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_1 = filter.fir_filter_fff( 1, firdes.band_pass(1, fs_mod, 30, 15e3, 100, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.fir_filter_fff( 1, firdes.band_pass(1, fs_mod, 23e3, 53e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0.set_block_alias("filter_bp_lrdiff") self.audio_source_0_0 = audio.source(48000, 'pulse_monitor', False) self.analog_sig_source_x_0_0 = analog.sig_source_f( fs_mod, analog.GR_COS_WAVE, 19e3, 1, 0, 0) self.analog_sig_source_x_0 = analog.sig_source_f( fs_mod, analog.GR_COS_WAVE, 38e3, 1, 0, 0) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc( 75e3 / fs_mod * 2 * math.pi) self.analog_fm_preemph_0_0 = analog.fm_preemph(fs=fs_file, tau=50e-6, fh=-1.0) self.analog_fm_preemph_0 = analog.fm_preemph(fs=fs_file, tau=50e-6, fh=-1.0) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.rational_resampler_xxx_0_0_0_0, 0)) self.connect((self.analog_fm_preemph_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_fm_preemph_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.analog_fm_preemph_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_fm_preemph_0_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.analog_frequency_modulator_fc_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_delay_0, 0)) self.connect((self.audio_source_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.audio_source_0_0, 1), (self.blocks_multiply_const_vxx_0_1, 0)) self.connect((self.band_pass_filter_0, 0), (self.blocks_multiply_const_xx_0_0, 0)) self.connect((self.band_pass_filter_1, 0), (self.blocks_delay_0_0, 0)) self.connect((self.band_pass_filter_1_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_const_xx_0_0_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_multiply_const_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_fm_preemph_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_xx_0_0, 4)) self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.analog_fm_preemph_0_0, 0)) self.connect((self.blocks_multiply_const_xx_0, 0), (self.blocks_add_xx_0_0, 0)) self.connect((self.blocks_multiply_const_xx_0_0, 0), (self.blocks_add_xx_0_0, 1)) self.connect((self.blocks_multiply_const_xx_0_0_0, 0), (self.blocks_add_xx_0_0, 2)) self.connect((self.blocks_multiply_const_xx_0_2, 0), (self.blocks_add_xx_0_0, 3)) self.connect((self.blocks_multiply_xx_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.rational_resampler_xxx_0_0_0, 0)) self.connect((self.gr_char_to_float_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.gr_diff_encoder_bb_0, 0), (self.gr_map_bb_1, 0)) self.connect((self.gr_map_bb_0, 0), (self.gr_char_to_float_0, 0)) self.connect((self.gr_map_bb_1, 0), (self.gr_unpack_k_bits_bb_0, 0)) self.connect((self.gr_multiply_xx_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.gr_sig_source_x_0_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.gr_unpack_k_bits_bb_0, 0), (self.gr_map_bb_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.uhd_usrp_sink_1, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.band_pass_filter_1, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.band_pass_filter_1_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0_0, 0), (self.blocks_multiply_const_xx_0_2, 0)) self.connect((self.rds_encoder_0, 0), (self.gr_diff_encoder_bb_0, 0))
def __init__(self): gr.top_block.__init__(self, "Packet Loopback Hier") Qt.QWidget.__init__(self) self.setWindowTitle("Packet Loopback Hier") 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", "packet_loopback_hier") self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.sps = sps = 2 self.nfilts = nfilts = 32 self.eb = eb = 0.22 self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0, eb, 5*sps*nfilts) self.time_offset = time_offset = 1.0 self.samp_rate = samp_rate = 200000 self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine(nfilts, nfilts*sps, 1.0, eb, 11*sps*nfilts) self.rep = rep = 3 self.rate = rate = 2 self.polys = polys = [109, 79] self.noise = noise = 0.0 self.k = k = 7 self.freq_offset = freq_offset = 0 self.amp = amp = 1.0 self.Const_PLD = Const_PLD = digital.constellation_calcdist((digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base() self.Const_PLD.gen_soft_dec_lut(8) self.Const_HDR = Const_HDR = digital.constellation_calcdist((digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base() self.Const_HDR.gen_soft_dec_lut(8) ################################################## # Blocks ################################################## self._time_offset_range = Range(0.99, 1.01, 0.00001, 1.0, 200) self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, 'Time Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._time_offset_win, 0, 2, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.tab1 = Qt.QTabWidget() self.tab1_widget_0 = Qt.QWidget() self.tab1_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab1_widget_0) self.tab1_grid_layout_0 = Qt.QGridLayout() self.tab1_layout_0.addLayout(self.tab1_grid_layout_0) self.tab1.addTab(self.tab1_widget_0, 'Time') self.tab1_widget_1 = Qt.QWidget() self.tab1_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab1_widget_1) self.tab1_grid_layout_1 = Qt.QGridLayout() self.tab1_layout_1.addLayout(self.tab1_grid_layout_1) self.tab1.addTab(self.tab1_widget_1, 'Freq.') self.tab1_widget_2 = Qt.QWidget() self.tab1_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab1_widget_2) self.tab1_grid_layout_2 = Qt.QGridLayout() self.tab1_layout_2.addLayout(self.tab1_grid_layout_2) self.tab1.addTab(self.tab1_widget_2, 'Const.') self.top_grid_layout.addWidget(self.tab1, 1, 2, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.tab0 = Qt.QTabWidget() self.tab0_widget_0 = Qt.QWidget() self.tab0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_0) self.tab0_grid_layout_0 = Qt.QGridLayout() self.tab0_layout_0.addLayout(self.tab0_grid_layout_0) self.tab0.addTab(self.tab0_widget_0, 'Time') self.tab0_widget_1 = Qt.QWidget() self.tab0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_1) self.tab0_grid_layout_1 = Qt.QGridLayout() self.tab0_layout_1.addLayout(self.tab0_grid_layout_1) self.tab0.addTab(self.tab0_widget_1, 'Freq.') self.tab0_widget_2 = Qt.QWidget() self.tab0_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_2) self.tab0_grid_layout_2 = Qt.QGridLayout() self.tab0_layout_2.addLayout(self.tab0_grid_layout_2) self.tab0.addTab(self.tab0_widget_2, 'Const.') self.top_grid_layout.addWidget(self.tab0, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._noise_range = Range(0, 5, 0.01, 0.0, 200) self._noise_win = RangeWidget(self._noise_range, self.set_noise, 'Noise Amp', "counter_slider", float) self.top_grid_layout.addWidget(self._noise_win, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._freq_offset_range = Range(-0.5, 0.5, 0.0001, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Freq. Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_offset_win, 0, 1, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._amp_range = Range(0, 2, 0.01, 1.0, 200) self._amp_win = RangeWidget(self._amp_range, self.set_amp, 'Amplitude', "counter_slider", float) self.top_grid_layout.addWidget(self._amp_win) self.qtgui_time_sink_x_1_0_0_1 = qtgui.time_sink_c( 125, #size 1, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0_0_1.set_update_time(0.10) self.qtgui_time_sink_x_1_0_0_1.set_y_axis(-2, 2) self.qtgui_time_sink_x_1_0_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_1_0_0_1.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 25, 0, "payload symbols") self.qtgui_time_sink_x_1_0_0_1.enable_autoscale(False) self.qtgui_time_sink_x_1_0_0_1.enable_grid(False) self.qtgui_time_sink_x_1_0_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_1_0_0_1.enable_control_panel(False) self.qtgui_time_sink_x_1_0_0_1.enable_stem_plot(False) if not False: self.qtgui_time_sink_x_1_0_0_1.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 = [3, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [0, -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_1_0_0_1.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_1_0_0_1.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_1_0_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_0_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0_0_1.pyqwidget(), Qt.QWidget) self.tab1_grid_layout_0.addWidget(self._qtgui_time_sink_x_1_0_0_1_win) self.qtgui_time_sink_x_1_0_0_0 = qtgui.time_sink_c( 1250, #size 1, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0_0_0.set_y_axis(-150, 150) self.qtgui_time_sink_x_1_0_0_0.set_y_label('Correlation', "") self.qtgui_time_sink_x_1_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 50, 0, "corr_est") self.qtgui_time_sink_x_1_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0_0_0.enable_grid(False) self.qtgui_time_sink_x_1_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0_0_0.enable_control_panel(False) self.qtgui_time_sink_x_1_0_0_0.enable_stem_plot(False) if not False: self.qtgui_time_sink_x_1_0_0_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_1_0_0_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_1_0_0_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_1_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_0_0_win, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_1 = qtgui.time_sink_c( 2500, #size 1, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-2, 2) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, 'packet_len') self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not False: self.qtgui_time_sink_x_1.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_1.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_1.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.tab0_grid_layout_0.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 100*2, #size samp_rate, #samp_rate 'Tx Data', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 256) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, 'packet_length_tag_key') self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_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_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 100*2, #size samp_rate, #samp_rate 'Rx Data', #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, 256) 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, 'packet_length_tag_key') self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(True) 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_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 1, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_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_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tab1_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 1, #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 False: 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.tab0_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_win) self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c( 800, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True) if not False: self.qtgui_const_sink_x_0_0_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_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.tab1_grid_layout_2.addWidget(self._qtgui_const_sink_x_0_0_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #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, 'packet_len') 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 False: 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.tab0_grid_layout_2.addWidget(self._qtgui_const_sink_x_0_win) self.packet_tx_0 = packet_tx( hdr_const=Const_HDR, pkt_len=42, pld_const=Const_PLD, psf_taps=tx_rrc_taps, puncpat='11', samp_rate=samp_rate, sps=sps, ) self.packet_rx_0 = packet_rx( eb=eb, hdr_const=Const_HDR, pkt_len=42, pld_const=Const_PLD, psf_taps=rx_rrc_taps, puncpat='11', samp_rate=samp_rate, sps=sps, ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise, frequency_offset=freq_offset, epsilon=time_offset, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=True ) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((amp, )) self.blocks_file_source_0_0_1 = blocks.file_source(gr.sizeof_char*1, '/home/andre/Desktop/book.txt', False) self.blocks_file_source_0_0_1.set_begin_tag(pmt.PMT_NIL) self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_char*1, '/home/andre/Desktop/transmitido/depois.txt', False) self.blocks_file_sink_0_0_0.set_unbuffered(False) self.blocks_char_to_float_1_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_1_0 = blocks.char_to_float(1, 1) ################################################## # Connections ################################################## self.connect((self.blocks_char_to_float_1_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_char_to_float_1_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_file_source_0_0_1, 0), (self.blocks_char_to_float_1_0_0, 0)) self.connect((self.blocks_file_source_0_0_1, 0), (self.packet_tx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.packet_rx_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.packet_rx_0, 0), (self.blocks_char_to_float_1_0, 0)) self.connect((self.packet_rx_0, 0), (self.blocks_file_sink_0_0_0, 0)) self.connect((self.packet_rx_0, 1), (self.qtgui_const_sink_x_0_0_0, 0)) self.connect((self.packet_rx_0, 1), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.packet_rx_0, 1), (self.qtgui_time_sink_x_1_0_0_0, 0)) self.connect((self.packet_rx_0, 1), (self.qtgui_time_sink_x_1_0_0_1, 0)) self.connect((self.packet_tx_0, 0), (self.channels_channel_model_0, 0))
def __init__(self): gr.top_block.__init__(self, "Lab 6 Task 1") Qt.QWidget.__init__(self) self.setWindowTitle("Lab 6 Task 1") 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", "lab6_task1") 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.sps = sps = 4 self.nfilts = nfilts = 32 self.ntaps = ntaps = 11*nfilts*sps self.tx_taps = tx_taps = firdes.root_raised_cosine(nfilts,nfilts,1.0,0.4,ntaps) self.timing_bw = timing_bw = 2*pi/100 self.samp_rate = samp_rate = 32000 self.rx_taps = rx_taps = firdes.root_raised_cosine(nfilts,nfilts*sps,1.0,0.4,ntaps) ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'Before Multipath') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'After Multipath') self.top_grid_layout.addWidget(self.tab) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(False) self.qtgui_const_sink_x_0_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_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tab_layout_1.addWidget(self._qtgui_const_sink_x_0_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #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.tab_layout_0.addWidget(self._qtgui_const_sink_x_0_win) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( sps, taps=tx_taps, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.iir_filter_xxx_0 = filter.iir_filter_ccf([1, 1], [1], True) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(8, timing_bw, rx_taps, 32, 16, 1.5, 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(((-0.707-0.707j),(-1-0j),(-0.707+0.707j),(0+1j),(0.707+0.707j),(1+0j),(0.707-0.707j),(0-1j)), 1) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.analog_random_source_x_0 = blocks.vector_source_b(list(map(int, numpy.random.randint(0, 8, 1000))), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.iir_filter_xxx_0, 0)) self.connect((self.iir_filter_xxx_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Lab 1") Qt.QWidget.__init__(self) self.setWindowTitle("Lab 1") 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", "lab1") 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.freqc = freqc = 900 self.sps = sps = 8 self.samp_rate = samp_rate = 1000 self.phase = phase = 0 self.mod_M = mod_M = 0 self.gain_ = gain_ = 0.5 self.freqc_ = freqc_ = freqc self.fps = fps = 30 self.foffset = foffset = 0 self.bw = bw = 1 self.buff_size = buff_size = 32768 self.analog_gain = analog_gain = 32 ################################################## # Blocks ################################################## self.tab0 = Qt.QTabWidget() self.tab0_widget_0 = Qt.QWidget() self.tab0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_0) self.tab0_grid_layout_0 = Qt.QGridLayout() self.tab0_layout_0.addLayout(self.tab0_grid_layout_0) self.tab0.addTab(self.tab0_widget_0, 'Spectrum/Constellation') self.tab0_widget_1 = Qt.QWidget() self.tab0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_1) self.tab0_grid_layout_1 = Qt.QGridLayout() self.tab0_layout_1.addLayout(self.tab0_grid_layout_1) self.tab0.addTab(self.tab0_widget_1, 'Time-Series') self.top_grid_layout.addWidget(self.tab0, 0, 0, 10, 2) for r in range(0, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._phase_range = Range(-180*2, 180*2, 0.1, 0, 200) self._phase_win = RangeWidget(self._phase_range, self.set_phase, 'Phase Offset (Degrees)', "counter_slider", float) self.top_grid_layout.addWidget(self._phase_win, 11, 1, 1, 1) for r in range(11, 12): 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._mod_M_options = (0, 1, ) # Create the labels list self._mod_M_labels = ('BPSK', 'QPSK', ) # Create the combo box # Create the radio buttons self._mod_M_group_box = Qt.QGroupBox('Modulation Select' + ": ") self._mod_M_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._mod_M_button_group = variable_chooser_button_group() self._mod_M_group_box.setLayout(self._mod_M_box) for i, _label in enumerate(self._mod_M_labels): radio_button = Qt.QRadioButton(_label) self._mod_M_box.addWidget(radio_button) self._mod_M_button_group.addButton(radio_button, i) self._mod_M_callback = lambda i: Qt.QMetaObject.invokeMethod(self._mod_M_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._mod_M_options.index(i))) self._mod_M_callback(self.mod_M) self._mod_M_button_group.buttonClicked[int].connect( lambda i: self.set_mod_M(self._mod_M_options[i])) self.top_grid_layout.addWidget(self._mod_M_group_box, 12, 1, 1, 1) for r in range(12, 13): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._gain__range = Range(0.1, 1, 0.01, 0.5, 200) self._gain__win = RangeWidget(self._gain__range, self.set_gain_, 'Gain (Amp)', "counter_slider", float) self.top_grid_layout.addWidget(self._gain__win, 10, 1, 1, 1) for r in range(10, 11): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._freqc__range = Range(70, 6000, .01, freqc, 200) self._freqc__win = RangeWidget(self._freqc__range, self.set_freqc_, 'Carrier (MHz)', "counter_slider", float) self.top_grid_layout.addWidget(self._freqc__win, 10, 0, 1, 1) for r in range(10, 11): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._foffset_range = Range(-10, 10, 1, 0, 10) self._foffset_win = RangeWidget(self._foffset_range, self.set_foffset, 'Frequency Offset (Hz)', "counter_slider", float) self.top_grid_layout.addWidget(self._foffset_win, 12, 0, 1, 1) for r in range(12, 13): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._analog_gain_range = Range(0, 64, 1, 32, 200) self._analog_gain_win = RangeWidget(self._analog_gain_range, self.set_analog_gain, 'Gain (Analog)', "counter_slider", float) self.top_grid_layout.addWidget(self._analog_gain_win, 11, 0, 1, 1) for r in range(11, 12): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 131072, #size samp_rate*1000, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(1/fps) 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(True) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = ['Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10'] 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(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.tab0_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0, 0, 10, 2) for r in range(0, 10): self.tab0_grid_layout_1.setRowStretch(r, 1) for c in range(0, 2): self.tab0_grid_layout_1.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate*1e3, #bw "", #name 1 ) self.qtgui_freq_sink_x_0_0.set_update_time(1/fps) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(True) self.qtgui_freq_sink_x_0_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) labels = ['Magnitude', '', '', '', '', '', '', '', '', ''] 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 range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tab0_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 0, 5, 1) for r in range(0, 5): self.tab0_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.tab0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0.set_processor_affinity([0]) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate*1e3, #bw "", #name 2 ) self.qtgui_freq_sink_x_0.set_update_time(1/fps) 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(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) self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['In-Phase', 'Quadrature', '', '', '', '', '', '', '', ''] 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 range(2): 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.tab0_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 5, 0, 5, 1) for r in range(5, 10): self.tab0_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.tab0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0.set_processor_affinity([0]) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 2 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(1/fps) self.qtgui_const_sink_x_0.set_y_axis(-3, 3) self.qtgui_const_sink_x_0.set_x_axis(-3, 3) 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(True) 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, 1, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, -1, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(2): 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.tab0_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win, 0, 1, 10, 1) for r in range(0, 10): self.tab0_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.tab0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_const_sink_x_0.set_processor_affinity([0]) self.iio_pluto_source_0 = iio.pluto_source('', int(freqc_*1e6), int(samp_rate*1000), 20000000, buff_size, True, True, True, 'manual', analog_gain, '', True) self.iio_pluto_sink_0 = iio.pluto_sink('', int(freqc_*1e6)+foffset, int(samp_rate*1000), 20000000, buff_size, False, 10.0, '', True) self.digital_psk_mod_0_0 = digital.psk.psk_mod( constellation_points=4, mod_code="gray", differential=True, samples_per_symbol=sps, excess_bw=1, verbose=False, log=False) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc(np.exp(1j*2*pi*phase/360)) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_ff(mod_M) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(gain_ * np.exp(1j * pi / 4)) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_real_1 = blocks.complex_to_real(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_imag_1 = blocks.complex_to_imag(1) self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1) self.analog_random_source_x_0 = blocks.vector_source_b(list(map(int, numpy.random.randint(0, 4, 8192))), True) self.analog_agc_xx_0 = analog.agc_cc(1e-4, ( 1.0 + mod_M), 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.blocks_complex_to_imag_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.qtgui_const_sink_x_0, 1)) self.connect((self.analog_agc_xx_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.digital_psk_mod_0_0, 0)) self.connect((self.blocks_complex_to_imag_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.blocks_complex_to_imag_1, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_complex_to_real_1, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.iio_pluto_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_complex_to_imag_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_complex_to_real_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.analog_agc_xx_0, 0)) self.connect((self.digital_psk_mod_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.iio_pluto_source_0, 0), (self.blocks_multiply_const_vxx_1, 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") 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.Rx4_Cal = Rx4_Cal = 0 self.Rx3_Cal = Rx3_Cal = 0 self.Rx2_Cal = Rx2_Cal = 0 self.Rx1_Cal = Rx1_Cal = 0 self.Phase_Delta = Phase_Delta = 0 self.samp_rate = samp_rate = int(40000000) self.TX_freq = TX_freq = 5.81 self.RxGain = RxGain = 15 self.Rx4 = Rx4 = ((Phase_Delta*3+Rx4_Cal) % 360) self.Rx3 = Rx3 = ((Phase_Delta*2+Rx3_Cal) % 360) self.Rx2 = Rx2 = ((Phase_Delta*1+Rx2_Cal) % 360) self.Rx1 = Rx1 = ((Phase_Delta*0+Rx1_Cal) % 360) self.Center_freq = Center_freq = 10510.0 self.BlankSpacerToFormatTab = BlankSpacerToFormatTab = " " ################################################## # Blocks ################################################## self.ControlTab = Qt.QTabWidget() self.ControlTab_widget_0 = Qt.QWidget() self.ControlTab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.ControlTab_widget_0) self.ControlTab_grid_layout_0 = Qt.QGridLayout() self.ControlTab_layout_0.addLayout(self.ControlTab_grid_layout_0) self.ControlTab.addTab(self.ControlTab_widget_0, 'Pluto Control') self.ControlTab_widget_1 = Qt.QWidget() self.ControlTab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.ControlTab_widget_1) self.ControlTab_grid_layout_1 = Qt.QGridLayout() self.ControlTab_layout_1.addLayout(self.ControlTab_grid_layout_1) self.ControlTab.addTab(self.ControlTab_widget_1, 'ADAR1000 Phase Control') self.top_grid_layout.addWidget(self.ControlTab, 7, 0, 7, 7) for r in range(7, 14): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 7): self.top_grid_layout.setColumnStretch(c, 1) self._RxGain_range = Range(0, 60, 1, 15, 200) self._RxGain_win = RangeWidget(self._RxGain_range, self.set_RxGain, 'RxGain', "counter_slider", float) self.ControlTab_grid_layout_0.addWidget(self._RxGain_win, 1, 0, 1, 5) for r in range(1, 2): self.ControlTab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 5): self.ControlTab_grid_layout_0.setColumnStretch(c, 1) self._Rx4_Cal_range = Range(0, 357.1875, 2.8125, 0, 200) self._Rx4_Cal_win = RangeWidget(self._Rx4_Cal_range, self.set_Rx4_Cal, 'Rx4_Phase', "counter_slider", float) self.ControlTab_grid_layout_1.addWidget(self._Rx4_Cal_win, 4, 1, 1, 5) for r in range(4, 5): self.ControlTab_grid_layout_1.setRowStretch(r, 1) for c in range(1, 6): self.ControlTab_grid_layout_1.setColumnStretch(c, 1) self._Rx3_Cal_range = Range(0, 357.1875, 2.8125, 0, 200) self._Rx3_Cal_win = RangeWidget(self._Rx3_Cal_range, self.set_Rx3_Cal, 'Rx3_Phase', "counter_slider", float) self.ControlTab_grid_layout_1.addWidget(self._Rx3_Cal_win, 3, 1, 1, 5) for r in range(3, 4): self.ControlTab_grid_layout_1.setRowStretch(r, 1) for c in range(1, 6): self.ControlTab_grid_layout_1.setColumnStretch(c, 1) self._Rx2_Cal_range = Range(0, 357.1875, 2.8125, 0, 200) self._Rx2_Cal_win = RangeWidget(self._Rx2_Cal_range, self.set_Rx2_Cal, 'Rx2_Phase', "counter_slider", float) self.ControlTab_grid_layout_1.addWidget(self._Rx2_Cal_win, 2, 1, 1, 5) for r in range(2, 3): self.ControlTab_grid_layout_1.setRowStretch(r, 1) for c in range(1, 6): self.ControlTab_grid_layout_1.setColumnStretch(c, 1) self._Rx1_Cal_range = Range(0, 357.1875, 2.8125, 0, 200) self._Rx1_Cal_win = RangeWidget(self._Rx1_Cal_range, self.set_Rx1_Cal, 'Rx1_Phase', "counter_slider", float) self.ControlTab_grid_layout_1.addWidget(self._Rx1_Cal_win, 1, 1, 1, 5) for r in range(1, 2): self.ControlTab_grid_layout_1.setRowStretch(r, 1) for c in range(1, 6): self.ControlTab_grid_layout_1.setColumnStretch(c, 1) self._Phase_Delta_range = Range(-199.6875, 199.6875, 2.8125, 0, 200) self._Phase_Delta_win = RangeWidget(self._Phase_Delta_range, self.set_Phase_Delta, 'Phase_Delta', "counter_slider", float) self.ControlTab_grid_layout_1.addWidget(self._Phase_Delta_win, 0, 1, 1, 5) for r in range(0, 1): self.ControlTab_grid_layout_1.setRowStretch(r, 1) for c in range(1, 6): self.ControlTab_grid_layout_1.setColumnStretch(c, 1) self._Center_freq_range = Range(10000, 11000, 0.1, 10510.0, 10) self._Center_freq_win = RangeWidget(self._Center_freq_range, self.set_Center_freq, 'Signal Freq (MHz)', "counter_slider", float) self.ControlTab_grid_layout_0.addWidget(self._Center_freq_win, 0, 0, 1, 5) for r in range(0, 1): self.ControlTab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 5): self.ControlTab_grid_layout_0.setColumnStretch(c, 1) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype int(Center_freq*1000000), #fc int(samp_rate), #bw "", #name True, #plotfreq False, #plotwaterfall True, #plottime True #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0/10) self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.qtgui_sink_x_0.enable_rf_freq(False) self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win, 0, 0, 6, 8) for r in range(0, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_number_sink_1 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_1.set_update_time(0.10) self.qtgui_number_sink_1.set_title('SteeringAngle') labels = ['', '', '', '', '', '', '', '', '', ''] units = ['deg', '', '', '', '', '', '', '', '', ''] 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 range(1): self.qtgui_number_sink_1.set_min(i, -90) self.qtgui_number_sink_1.set_max(i, 90) self.qtgui_number_sink_1.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_1.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_1.set_label(i, labels[i]) self.qtgui_number_sink_1.set_unit(i, units[i]) self.qtgui_number_sink_1.set_factor(i, factor[i]) self.qtgui_number_sink_1.enable_autoscale(False) self._qtgui_number_sink_1_win = sip.wrapinstance(self.qtgui_number_sink_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_1_win) self.iio_pluto_source_0 = iio.pluto_source('', int(Center_freq*1000000-TX_freq*1000000000), int(samp_rate), 20000000, 32768, True, True, True, 'manual', int(RxGain), '', True) self.iio_pluto_sink_0 = iio.pluto_sink('', int(TX_freq*1000000000), int(samp_rate), 20000000, 32768, True, 3, '', True) self.epy_block_0 = epy_block_0.blk(PhaseDelta=Phase_Delta, SignalFreq=int(Center_freq*1000000), UpdateRate=0.1, Rx1_Phase_Cal=Rx1_Cal, Rx2_Phase_Cal=Rx2_Cal, Rx3_Phase_Cal=Rx3_Cal, Rx4_Phase_Cal=Rx4_Cal) self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, int(10000), 1, 0, 0) self._Rx4_tool_bar = Qt.QToolBar(self) if None: self._Rx4_formatter = None else: self._Rx4_formatter = lambda x: str(x) self._Rx4_tool_bar.addWidget(Qt.QLabel('Rx4' + ": ")) self._Rx4_label = Qt.QLabel(str(self._Rx4_formatter(self.Rx4))) self._Rx4_tool_bar.addWidget(self._Rx4_label) self.ControlTab_grid_layout_1.addWidget(self._Rx4_tool_bar, 4, 0, 1, 1) for r in range(4, 5): self.ControlTab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.ControlTab_grid_layout_1.setColumnStretch(c, 1) self._Rx3_tool_bar = Qt.QToolBar(self) if None: self._Rx3_formatter = None else: self._Rx3_formatter = lambda x: str(x) self._Rx3_tool_bar.addWidget(Qt.QLabel('Rx3' + ": ")) self._Rx3_label = Qt.QLabel(str(self._Rx3_formatter(self.Rx3))) self._Rx3_tool_bar.addWidget(self._Rx3_label) self.ControlTab_grid_layout_1.addWidget(self._Rx3_tool_bar, 3, 0, 1, 1) for r in range(3, 4): self.ControlTab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.ControlTab_grid_layout_1.setColumnStretch(c, 1) self._Rx2_tool_bar = Qt.QToolBar(self) if None: self._Rx2_formatter = None else: self._Rx2_formatter = lambda x: str(x) self._Rx2_tool_bar.addWidget(Qt.QLabel('Rx2' + ": ")) self._Rx2_label = Qt.QLabel(str(self._Rx2_formatter(self.Rx2))) self._Rx2_tool_bar.addWidget(self._Rx2_label) self.ControlTab_grid_layout_1.addWidget(self._Rx2_tool_bar, 2, 0, 1, 1) for r in range(2, 3): self.ControlTab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.ControlTab_grid_layout_1.setColumnStretch(c, 1) self._Rx1_tool_bar = Qt.QToolBar(self) if None: self._Rx1_formatter = None else: self._Rx1_formatter = lambda x: str(x) self._Rx1_tool_bar.addWidget(Qt.QLabel('Rx1' + ": ")) self._Rx1_label = Qt.QLabel(str(self._Rx1_formatter(self.Rx1))) self._Rx1_tool_bar.addWidget(self._Rx1_label) self.ControlTab_grid_layout_1.addWidget(self._Rx1_tool_bar, 1, 0, 1, 1) for r in range(1, 2): self.ControlTab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.ControlTab_grid_layout_1.setColumnStretch(c, 1) self._BlankSpacerToFormatTab_tool_bar = Qt.QToolBar(self) if None: self._BlankSpacerToFormatTab_formatter = None else: self._BlankSpacerToFormatTab_formatter = lambda x: str(x) self._BlankSpacerToFormatTab_tool_bar.addWidget(Qt.QLabel(" " + ": ")) self._BlankSpacerToFormatTab_label = Qt.QLabel(str(self._BlankSpacerToFormatTab_formatter(self.BlankSpacerToFormatTab))) self._BlankSpacerToFormatTab_tool_bar.addWidget(self._BlankSpacerToFormatTab_label) self.ControlTab_grid_layout_0.addWidget(self._BlankSpacerToFormatTab_tool_bar, 2, 0, 4, 5) for r in range(2, 6): self.ControlTab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 5): self.ControlTab_grid_layout_0.setColumnStretch(c, 1) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_1, 0), (self.iio_pluto_sink_0, 0)) self.connect((self.epy_block_0, 0), (self.qtgui_number_sink_1, 0)) self.connect((self.iio_pluto_source_0, 0), (self.qtgui_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Exemplo transmissão digital ") Qt.QWidget.__init__(self) self.setWindowTitle("Exemplo transmissão digital ") 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", "digital_tx") self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.sps = sps = 4 self.samp_rate = samp_rate = 200000 self.fc = fc = 920e6 self.excess_bw = excess_bw = 0.35 self.const = const = digital.constellation_qpsk().base() ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'Transmissor') self.top_grid_layout.addWidget(self.tab) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_HAMMING, #wintype fc, #fc samp_rate, #bw "Espectro do sinal transmitido", #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(True) self.qtgui_freq_sink_x_0.set_fft_average(0.05) 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.tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 1, 1) for r in range(0, 1): self.tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.tab_grid_layout_0.setColumnStretch(c, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "Constelacao - saida do transmissor", #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.tab_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win, 0, 1, 1, 1) for r in range(0, 1): self.tab_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.tab_grid_layout_0.setColumnStretch(c, 1) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=const, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 10000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_0, 0))
def __init__(self): gr.top_block.__init__(self, "twodimension_simulation") Qt.QWidget.__init__(self) self.setWindowTitle("twodimension_simulation") 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", "twodimension_simulation") 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.maxtheta = maxtheta = 120 self.columns = columns = 100 self.shiftarrL = shiftarrL = np.radians( np.linspace(start=maxtheta, stop=0, num=int(columns / 2), endpoint=False)) self.left = left = np.pad(shiftarrL, (0, int(columns / 2)), 'constant') self.right = right = np.flip(left, axis=0) self.degreesTXT = degreesTXT = 0 self.degreesTXR = degreesTXR = 0 self.degreesTXL = degreesTXL = 0 self.degreesTXB = degreesTXB = 0 self.variable_qtgui_label_0_0 = variable_qtgui_label_0_0 = left self.variable_qtgui_label_0 = variable_qtgui_label_0 = right self.scale = scale = 15 self.samp_rate = samp_rate = 32000 self.keep = keep = 32 self.displayscale = displayscale = 8 self.angle_radiansStartT = angle_radiansStartT = (math.pi / 180) * degreesTXT self.angle_radiansStartR = angle_radiansStartR = (math.pi / 180) * degreesTXR self.angle_radiansStartL = angle_radiansStartL = (math.pi / 180) * degreesTXL self.angle_radiansStartB = angle_radiansStartB = (math.pi / 180) * degreesTXB ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'Time rasters') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'Steering vectors') self.top_grid_layout.addWidget(self.tab) self._scale_range = Range(0, 100, 5, 15, 200) self._scale_win = RangeWidget(self._scale_range, self.set_scale, 'scale', "counter_slider", float) self.top_grid_layout.addWidget(self._scale_win) self.video_sdl_sink_1_1_0 = video_sdl.sink_s(0, columns, columns, 0, columns * displayscale, columns * displayscale) self._variable_qtgui_label_0_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_0_formatter = None else: self._variable_qtgui_label_0_0_formatter = lambda x: repr(x) self._variable_qtgui_label_0_0_tool_bar.addWidget( Qt.QLabel('Left' + ": ")) self._variable_qtgui_label_0_0_label = Qt.QLabel( str( self._variable_qtgui_label_0_0_formatter( self.variable_qtgui_label_0_0))) self._variable_qtgui_label_0_0_tool_bar.addWidget( self._variable_qtgui_label_0_0_label) self.tab_layout_1.addWidget(self._variable_qtgui_label_0_0_tool_bar) 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: repr(x) self._variable_qtgui_label_0_tool_bar.addWidget( Qt.QLabel('Right' + ": ")) 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.tab_layout_1.addWidget(self._variable_qtgui_label_0_tool_bar) self.qtgui_time_raster_sink_x_0_0 = qtgui.time_raster_sink_f( samp_rate / keep, columns, columns, [], [], "Elevation", 1) self.qtgui_time_raster_sink_x_0_0.set_update_time(0.01) self.qtgui_time_raster_sink_x_0_0.set_intensity_range(0, 5) self.qtgui_time_raster_sink_x_0_0.enable_grid(False) self.qtgui_time_raster_sink_x_0_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [1, 1, 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_time_raster_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_raster_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_raster_sink_x_0_0.set_color_map(i, colors[i]) self.qtgui_time_raster_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_raster_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_raster_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tab_layout_0.addWidget(self._qtgui_time_raster_sink_x_0_0_win) self.qtgui_time_raster_sink_x_0 = qtgui.time_raster_sink_f( samp_rate / keep, columns, columns, [], [], "Azimuth", 1) self.qtgui_time_raster_sink_x_0.set_update_time(0.01) self.qtgui_time_raster_sink_x_0.set_intensity_range(0, 5) self.qtgui_time_raster_sink_x_0.enable_grid(False) self.qtgui_time_raster_sink_x_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [1, 1, 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_time_raster_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_raster_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_raster_sink_x_0.set_color_map(i, colors[i]) self.qtgui_time_raster_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_raster_sink_x_0_win = sip.wrapinstance( self.qtgui_time_raster_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_0.addWidget(self._qtgui_time_raster_sink_x_0_win) self._degreesTXT_range = Range(0, maxtheta, 5, 0, 200) self._degreesTXT_win = RangeWidget(self._degreesTXT_range, self.set_degreesTXT, 'degreesTXT', "counter_slider", float) self.top_grid_layout.addWidget(self._degreesTXT_win) self._degreesTXR_range = Range(0, maxtheta, 5, 0, 200) self._degreesTXR_win = RangeWidget(self._degreesTXR_range, self.set_degreesTXR, 'degreesTXR', "counter_slider", float) self.top_grid_layout.addWidget(self._degreesTXR_win) self._degreesTXL_range = Range(0, maxtheta, 5, 0, 200) self._degreesTXL_win = RangeWidget(self._degreesTXL_range, self.set_degreesTXL, 'degreesTXL', "counter_slider", float) self.top_grid_layout.addWidget(self._degreesTXL_win) self._degreesTXB_range = Range(0, maxtheta, 5, 0, 200) self._degreesTXB_win = RangeWidget(self._degreesTXB_range, self.set_degreesTXB, 'degreesTXB', "counter_slider", float) self.top_grid_layout.addWidget(self._degreesTXB_win) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, columns) self.blocks_vector_source_x_0_0_0_1 = blocks.vector_source_f( left, True, 1, []) self.blocks_vector_source_x_0_0_0_0_0 = blocks.vector_source_f( right, True, 1, []) self.blocks_vector_source_x_0_0_0_0 = blocks.vector_source_f( right, True, 1, []) self.blocks_vector_source_x_0_0_0 = blocks.vector_source_f( left, True, 1, []) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_sub_xx_0_0_1 = blocks.sub_ff(1) self.blocks_sub_xx_0_0_0_0 = blocks.sub_ff(1) self.blocks_sub_xx_0_0_0 = blocks.sub_ff(1) self.blocks_sub_xx_0_0 = blocks.sub_ff(1) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, columns) self.blocks_repeat_0_0_0_0_2 = blocks.repeat(gr.sizeof_float * 1, columns) self.blocks_repeat_0_0_0_0_1_0 = blocks.repeat(gr.sizeof_float * 1, columns) self.blocks_repeat_0_0_0_0_1 = blocks.repeat(gr.sizeof_float * 1, columns) self.blocks_repeat_0_0_0_0_0_1_0 = blocks.repeat( gr.sizeof_float * 1, columns) self.blocks_repeat_0_0_0_0_0_1 = blocks.repeat(gr.sizeof_float * 1, columns) self.blocks_repeat_0_0_0_0_0_0 = blocks.repeat(gr.sizeof_float * 1, columns) self.blocks_repeat_0_0_0_0_0 = blocks.repeat(gr.sizeof_float * 1, columns) self.blocks_repeat_0_0_0_0 = blocks.repeat(gr.sizeof_float * 1, columns) self.blocks_repeat_0_0 = blocks.repeat(gr.sizeof_gr_complex * columns, columns) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 1, columns) self.blocks_multiply_const_vxx_0_0_1_0 = blocks.multiply_const_cc( complex(math.cos(angle_radiansStartT), math.sin(angle_radiansStartT))) self.blocks_multiply_const_vxx_0_0_1 = blocks.multiply_const_cc( complex(math.cos(angle_radiansStartR), math.sin(angle_radiansStartR))) self.blocks_multiply_const_vxx_0_0_0_0_0 = blocks.multiply_const_cc( complex(math.cos(angle_radiansStartB), math.sin(angle_radiansStartB))) self.blocks_multiply_const_vxx_0_0_0_0 = blocks.multiply_const_cc( complex(math.cos(angle_radiansStartL), math.sin(angle_radiansStartL))) self.blocks_magphase_to_complex_0_0_0_0_1 = blocks.magphase_to_complex( 1) self.blocks_magphase_to_complex_0_0_0_0_0_0 = blocks.magphase_to_complex( 1) self.blocks_magphase_to_complex_0_0_0_0_0 = blocks.magphase_to_complex( 1) self.blocks_magphase_to_complex_0_0_0_0 = blocks.magphase_to_complex(1) self.blocks_keep_one_in_n_0_2 = blocks.keep_one_in_n( gr.sizeof_gr_complex * 1, keep) self.blocks_keep_one_in_n_0_1 = blocks.keep_one_in_n( gr.sizeof_gr_complex * 1, keep) self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n( gr.sizeof_gr_complex * 1, keep) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_gr_complex * 1, keep) self.blocks_float_to_short_0_1_0 = blocks.float_to_short(1, scale) self.blocks_complex_to_magphase_0_0_0_1 = blocks.complex_to_magphase(1) self.blocks_complex_to_magphase_0_0_0_0_0 = blocks.complex_to_magphase( 1) self.blocks_complex_to_magphase_0_0_0_0 = blocks.complex_to_magphase(1) self.blocks_complex_to_magphase_0_0_0 = blocks.complex_to_magphase(1) self.blocks_complex_to_mag_squared_0_1_0 = blocks.complex_to_mag_squared( 1) self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared( 1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_add_xx_1 = blocks.add_vcc(1) self.blocks_add_xx_0_0 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_sig_source_x_0_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 400, 1, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_complex_to_mag_squared_0_0, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_complex_to_mag_squared_0_1_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.qtgui_time_raster_sink_x_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0_0, 0), (self.qtgui_time_raster_sink_x_0_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0_1_0, 0), (self.blocks_float_to_short_0_1_0, 0)) self.connect((self.blocks_complex_to_magphase_0_0_0, 0), (self.blocks_repeat_0_0_0_0, 0)) self.connect((self.blocks_complex_to_magphase_0_0_0, 1), (self.blocks_repeat_0_0_0_0_0, 0)) self.connect((self.blocks_complex_to_magphase_0_0_0_0, 1), (self.blocks_repeat_0_0_0_0_0_1, 0)) self.connect((self.blocks_complex_to_magphase_0_0_0_0, 0), (self.blocks_repeat_0_0_0_0_1, 0)) self.connect((self.blocks_complex_to_magphase_0_0_0_0_0, 1), (self.blocks_repeat_0_0_0_0_0_1_0, 0)) self.connect((self.blocks_complex_to_magphase_0_0_0_0_0, 0), (self.blocks_repeat_0_0_0_0_1_0, 0)) self.connect((self.blocks_complex_to_magphase_0_0_0_1, 1), (self.blocks_repeat_0_0_0_0_0_0, 0)) self.connect((self.blocks_complex_to_magphase_0_0_0_1, 0), (self.blocks_repeat_0_0_0_0_2, 0)) self.connect((self.blocks_float_to_short_0_1_0, 0), (self.video_sdl_sink_1_1_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_multiply_const_vxx_0_0_1, 0)) self.connect((self.blocks_keep_one_in_n_0_0, 0), (self.blocks_multiply_const_vxx_0_0_0_0, 0)) self.connect((self.blocks_keep_one_in_n_0_1, 0), (self.blocks_multiply_const_vxx_0_0_1_0, 0)) self.connect((self.blocks_keep_one_in_n_0_2, 0), (self.blocks_multiply_const_vxx_0_0_0_0_0, 0)) self.connect((self.blocks_magphase_to_complex_0_0_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_magphase_to_complex_0_0_0_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_magphase_to_complex_0_0_0_0_0_0, 0), (self.blocks_add_xx_0_0, 1)) self.connect((self.blocks_magphase_to_complex_0_0_0_0_1, 0), (self.blocks_add_xx_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0_0_0, 0), (self.blocks_complex_to_magphase_0_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0_0_0_0, 0), (self.blocks_complex_to_magphase_0_0_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0_1, 0), (self.blocks_complex_to_magphase_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0_1_0, 0), (self.blocks_complex_to_magphase_0_0_0_1, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.blocks_repeat_0_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.blocks_repeat_0_0_0_0, 0), (self.blocks_magphase_to_complex_0_0_0_0, 0)) self.connect((self.blocks_repeat_0_0_0_0_0, 0), (self.blocks_sub_xx_0_0, 0)) self.connect((self.blocks_repeat_0_0_0_0_0_0, 0), (self.blocks_sub_xx_0_0_1, 0)) self.connect((self.blocks_repeat_0_0_0_0_0_1, 0), (self.blocks_sub_xx_0_0_0, 0)) self.connect((self.blocks_repeat_0_0_0_0_0_1_0, 0), (self.blocks_sub_xx_0_0_0_0, 0)) self.connect((self.blocks_repeat_0_0_0_0_1, 0), (self.blocks_magphase_to_complex_0_0_0_0_0, 0)) self.connect((self.blocks_repeat_0_0_0_0_1_0, 0), (self.blocks_magphase_to_complex_0_0_0_0_0_0, 0)) self.connect((self.blocks_repeat_0_0_0_0_2, 0), (self.blocks_magphase_to_complex_0_0_0_0_1, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_repeat_0_0, 0)) self.connect((self.blocks_sub_xx_0_0, 0), (self.blocks_magphase_to_complex_0_0_0_0, 1)) self.connect((self.blocks_sub_xx_0_0_0, 0), (self.blocks_magphase_to_complex_0_0_0_0_0, 1)) self.connect((self.blocks_sub_xx_0_0_0_0, 0), (self.blocks_magphase_to_complex_0_0_0_0_0_0, 1)) self.connect((self.blocks_sub_xx_0_0_1, 0), (self.blocks_magphase_to_complex_0_0_0_0_1, 1)) self.connect((self.blocks_throttle_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_keep_one_in_n_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_keep_one_in_n_0_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_keep_one_in_n_0_2, 0)) self.connect((self.blocks_vector_source_x_0_0_0, 0), (self.blocks_sub_xx_0_0, 1)) self.connect((self.blocks_vector_source_x_0_0_0_0, 0), (self.blocks_sub_xx_0_0_0, 1)) self.connect((self.blocks_vector_source_x_0_0_0_0_0, 0), (self.blocks_sub_xx_0_0_0_0, 1)) self.connect((self.blocks_vector_source_x_0_0_0_1, 0), (self.blocks_sub_xx_0_0_1, 1)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_add_xx_1, 0))
def __init__(self): gr.top_block.__init__(self, "Mpsk Stage4") Qt.QWidget.__init__(self) self.setWindowTitle("Mpsk Stage4") 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", "mpsk_stage4") 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.sps = sps = 4 self.nfilts = nfilts = 32 self.timing_loop_bw = timing_loop_bw = 6.28/100.0 self.time_offset = time_offset = 1.00 self.taps = taps = [1.0, 0.25-0.25j, 0.50 + 0.10j, -0.3 + 0.2j] self.samp_rate = samp_rate = 32000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts) self.qpsk_0 = qpsk_0 = digital.constellation_rect([1+1j, -1+1j, -1-1j, 1-1j], [0, 1, 3, 2], 4, 2, 2, 1, 1).base() self.qpsk = qpsk = digital.constellation_rect([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j], [0, 1, 2, 3], 4, 2, 2, 1, 1).base() self.noise_volt = noise_volt = 0.0001 self.freq_offset = freq_offset = 0 self.excess_bw = excess_bw = 0.35 self.eq_gain = eq_gain = 0.01 self.arity = arity = 4 ################################################## # Blocks ################################################## self.controls = Qt.QTabWidget() self.controls_widget_0 = Qt.QWidget() self.controls_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_0) self.controls_grid_layout_0 = Qt.QGridLayout() self.controls_layout_0.addLayout(self.controls_grid_layout_0) self.controls.addTab(self.controls_widget_0, 'Channel') self.controls_widget_1 = Qt.QWidget() self.controls_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_1) self.controls_grid_layout_1 = Qt.QGridLayout() self.controls_layout_1.addLayout(self.controls_grid_layout_1) self.controls.addTab(self.controls_widget_1, 'Receiver') self.top_grid_layout.addWidget(self.controls, 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._timing_loop_bw_range = Range(0.0, 0.2, 0.01, 6.28/100.0, 200) self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range, self.set_timing_loop_bw, 'Time: BW', "slider", float) self.controls_grid_layout_1.addWidget(self._timing_loop_bw_win, 0, 0, 1, 1) for r in range(0, 1): self.controls_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.controls_grid_layout_1.setColumnStretch(c, 1) self._time_offset_range = Range(0.999, 1.001, 0.0001, 1.00, 200) self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, 'Timing Offset', "counter_slider", float) self.controls_grid_layout_0.addWidget(self._time_offset_win, 0, 2, 1, 1) for r in range(0, 1): self.controls_grid_layout_0.setRowStretch(r, 1) for c in range(2, 3): self.controls_grid_layout_0.setColumnStretch(c, 1) self._noise_volt_range = Range(0, 1, 0.01, 0.0001, 200) self._noise_volt_win = RangeWidget(self._noise_volt_range, self.set_noise_volt, 'Noise Voltage', "counter_slider", float) self.controls_grid_layout_0.addWidget(self._noise_volt_win, 0, 0, 1, 1) for r in range(0, 1): self.controls_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.controls_grid_layout_0.setColumnStretch(c, 1) self._freq_offset_range = Range(-0.1, 0.1, 0.001, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Frequency Offset', "counter_slider", float) self.controls_grid_layout_0.addWidget(self._freq_offset_win, 0, 1, 1, 1) for r in range(0, 1): self.controls_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.controls_grid_layout_0.setColumnStretch(c, 1) self._eq_gain_range = Range(0.0, 0.1, 0.001, 0.01, 200) self._eq_gain_win = RangeWidget(self._eq_gain_range, self.set_eq_gain, 'Equalizer: rate', "slider", float) self.controls_grid_layout_1.addWidget(self._eq_gain_win, 0, 1, 1, 1) for r in range(0, 1): self.controls_grid_layout_1.setRowStretch(r, 1) for c in range(1, 2): self.controls_grid_layout_1.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw '', #name 1 ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) labels = ['Equalized', '', '', '', '', '', '', '', '', ''] widths = [2, 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, 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_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 2, 1, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw '', #name 1 ) 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) labels = ['Timing Recov.', '', '', '', '', '', '', '', '', ''] widths = [2, 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 range(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, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size '', #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(False) self.qtgui_const_sink_x_1.enable_grid(False) self.qtgui_const_sink_x_1.enable_axis_labels(True) labels = ['Timing Recov.', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [0.6, 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_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_win = sip.wrapinstance(self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_1_win, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #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 = ['Equalized', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [0.6, 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_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, rrc_taps, nfilts, nfilts/2, 1.5, 2) self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc(11, eq_gain, 2, qpsk_0) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_volt, frequency_offset=freq_offset, epsilon=time_offset, taps=taps, noise_seed=0, block_tags=False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.analog_random_source_x_0 = blocks.vector_source_b(list(map(int, numpy.random.randint(0, 256, 10000))), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_lms_dd_equalizer_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Lab 2 Task 1") Qt.QWidget.__init__(self) self.setWindowTitle("Lab 2 Task 1") 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", "lab2_task1_1") 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 = 960000 ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'Message') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'Modulated') self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, 'Demodulated') self.top_grid_layout.addWidget(self.tab) self.freq = Qt.QTabWidget() self.freq_widget_0 = Qt.QWidget() self.freq_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.freq_widget_0) self.freq_grid_layout_0 = Qt.QGridLayout() self.freq_layout_0.addLayout(self.freq_grid_layout_0) self.freq.addTab(self.freq_widget_0, 'Message') self.freq_widget_1 = Qt.QWidget() self.freq_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.freq_widget_1) self.freq_grid_layout_1 = Qt.QGridLayout() self.freq_layout_1.addLayout(self.freq_grid_layout_1) self.freq.addTab(self.freq_widget_1, 'Modulated') self.freq_widget_2 = Qt.QWidget() self.freq_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.freq_widget_2) self.freq_grid_layout_2 = Qt.QGridLayout() self.freq_layout_2.addLayout(self.freq_grid_layout_2) self.freq.addTab(self.freq_widget_2, 'Demodulated') self.top_grid_layout.addWidget(self.freq) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate 'Demodulated', #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(False) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(True) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) self.qtgui_time_sink_x_1.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] 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_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.tab_layout_2.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Message", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0_0.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] 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_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.tab_layout_0.addWidget(self._qtgui_time_sink_x_0_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate 'Modulated', #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(True) 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 = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] 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.tab_layout_1.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_2 = qtgui.freq_sink_f( 1024, #size firdes.WIN_KAISER, #wintype 0, #fc samp_rate, #bw 'Demodulated', #name 1) self.qtgui_freq_sink_x_2.set_update_time(0.10) self.qtgui_freq_sink_x_2.set_y_axis(-140, 10) self.qtgui_freq_sink_x_2.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_2.enable_autoscale(True) self.qtgui_freq_sink_x_2.enable_grid(False) self.qtgui_freq_sink_x_2.set_fft_average(1.0) self.qtgui_freq_sink_x_2.enable_axis_labels(True) self.qtgui_freq_sink_x_2.enable_control_panel(False) self.qtgui_freq_sink_x_2.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 range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_2.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_2.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_2.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_2.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_2_win = sip.wrapinstance( self.qtgui_freq_sink_x_2.pyqwidget(), Qt.QWidget) self.freq_layout_2.addWidget(self._qtgui_freq_sink_x_2_win) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_f( 1024, #size firdes.WIN_KAISER, #wintype 0, #fc samp_rate, #bw 'Message', #name 1) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(True) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) self.qtgui_freq_sink_x_1.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 range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.freq_layout_0.addWidget(self._qtgui_freq_sink_x_1_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_KAISER, #wintype 0, #fc samp_rate, #bw 'Modulated', #name 1) 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(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) 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 range(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.freq_layout_1.addWidget(self._qtgui_freq_sink_x_0_win) self.low_pass_filter_0 = filter.interp_fir_filter_fff( 1, firdes.low_pass(2, samp_rate, 15000, 100, firdes.WIN_KAISER, 6.76)) self.dc_blocker_xx_0 = filter.dc_blocker_ff(32, True) self.blocks_throttle_0_0_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.analog_sig_source_x_1 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 100000, 1, 0, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 10000, 0.5, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0_0_0, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_xx_0_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)) self.connect((self.blocks_throttle_0_0_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.blocks_throttle_0_0_0, 0), (self.qtgui_time_sink_x_0_0_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.qtgui_freq_sink_x_2, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.dc_blocker_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Tutorial Two 3") Qt.QWidget.__init__(self) self.setWindowTitle("Tutorial Two 3") 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", "tutorial_two_3") 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.freq = freq = 2e3 self.samp_rate = samp_rate = 5 * freq ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'Time') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'Frequency') self.top_grid_layout.addWidget(self.tab) self._samp_rate_range = Range(.5 * freq, 20 * freq, 200, 5 * freq, 200) self._samp_rate_win = RangeWidget(self._samp_rate_range, self.set_samp_rate, 'samp_rate', "counter_slider", float) self.top_grid_layout.addWidget(self._samp_rate_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.tab_layout_0.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw '', #name 1) 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) 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 range(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.tab_layout_1.addWidget(self._qtgui_freq_sink_x_0_win) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, 32e3, True) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_SIN_WAVE, freq, 1, 0, 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 __init__(self): gr.top_block.__init__(self, "FloripaSat-I Simulation Test") Qt.QWidget.__init__(self) self.setWindowTitle("FloripaSat-I Simulation Test") 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", "fsat_simulation_test") 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.symbol_rate = symbol_rate = 1.2e3 self.samples_per_symbol = samples_per_symbol = 40 self.sample_rate_tx = sample_rate_tx = symbol_rate * samples_per_symbol * 25 / 6 self.nfilts = nfilts = 32 self.sample_rate_rx = sample_rate_rx = sample_rate_tx * 6 / 5 self.sample_rate = sample_rate = symbol_rate * samples_per_symbol self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(40), 0.35, 45 * nfilts) self.pi = pi = numpy.pi self.phase_shift = phase_shift = 0 self.noise_amp = noise_amp = 1e-6 self.modulation_sensitivity = modulation_sensitivity = 4e3 self.freq_shift = freq_shift = 1e3 ################################################## # Blocks ################################################## self.tabs = Qt.QTabWidget() self.tabs_widget_0 = Qt.QWidget() self.tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_0) self.tabs_grid_layout_0 = Qt.QGridLayout() self.tabs_layout_0.addLayout(self.tabs_grid_layout_0) self.tabs.addTab(self.tabs_widget_0, 'Spectrum') self.tabs_widget_1 = Qt.QWidget() self.tabs_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_1) self.tabs_grid_layout_1 = Qt.QGridLayout() self.tabs_layout_1.addLayout(self.tabs_grid_layout_1) self.tabs.addTab(self.tabs_widget_1, 'Time') self.top_layout.addWidget(self.tabs) self.qtgui_time_sink_x_0_0_0_0 = qtgui.time_sink_f( 11200, #size symbol_rate * samples_per_symbol, #samp_rate "Signal", #name 2 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0_0.set_y_axis(-1.2, 1.2) self.qtgui_time_sink_x_0_0_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0_0_0.disable_legend() labels = [ "Transmitted", "Received", "Transmitted", '', '', '', '', '', '', '' ] 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: self.qtgui_time_sink_x_0_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_0_0_0_win, 3, 0, 7, 1) [self.tabs_grid_layout_1.setRowStretch(r, 1) for r in range(3, 10)] [self.tabs_grid_layout_1.setColumnStretch(c, 1) for c in range(0, 1)] self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f( 280, #size symbol_rate * samples_per_symbol, #samp_rate "Message", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0.set_y_axis(-1.2, 1.2) self.qtgui_time_sink_x_0_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0_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 = [0, -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_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_0_0_win, 10, 0, 7, 1) [self.tabs_grid_layout_1.setRowStretch(r, 1) for r in range(10, 17)] [self.tabs_grid_layout_1.setColumnStretch(c, 1) for c in range(0, 1)] self.qtgui_freq_sink_x_0_0_0 = qtgui.freq_sink_c( 8192, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc sample_rate, #bw "Received Signal", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0_0.set_y_axis(-180, 10) self.qtgui_freq_sink_x_0_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0_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_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_0_win, 1, 0, 1, 1) [self.tabs_grid_layout_0.setRowStretch(r, 1) for r in range(1, 2)] [self.tabs_grid_layout_0.setColumnStretch(c, 1) for c in range(0, 1)] self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 8192, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc sample_rate, #bw "Transmitted Signal", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-180, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_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_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 0, 1, 1) [self.tabs_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)] [self.tabs_grid_layout_0.setColumnStretch(c, 1) for c in range(0, 1)] self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 8192, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc symbol_rate * samples_per_symbol, #bw "Demodulated Signal", #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(-180, 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 "float" == "float" or "float" == "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.tabs_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 2, 0, 1, 1) [self.tabs_grid_layout_0.setRowStretch(r, 1) for r in range(2, 3)] [self.tabs_grid_layout_0.setColumnStretch(c, 1) for c in range(0, 1)] self._phase_shift_range = Range(0, 2 * pi, 0.01, 0, 200) self._phase_shift_win = RangeWidget(self._phase_shift_range, self.set_phase_shift, "Channel Phase Shift", "counter_slider", float) self.tabs_grid_layout_1.addWidget(self._phase_shift_win, 1, 0, 1, 1) [self.tabs_grid_layout_1.setRowStretch(r, 1) for r in range(1, 2)] [self.tabs_grid_layout_1.setColumnStretch(c, 1) for c in range(0, 1)] self._noise_amp_range = Range(1e-6, 0.1, 1e-6, 1e-6, 200) self._noise_amp_win = RangeWidget(self._noise_amp_range, self.set_noise_amp, "Channel Noise Amplitude", "counter_slider", float) self.tabs_grid_layout_1.addWidget(self._noise_amp_win, 2, 0, 1, 1) [self.tabs_grid_layout_1.setRowStretch(r, 1) for r in range(2, 3)] [self.tabs_grid_layout_1.setColumnStretch(c, 1) for c in range(0, 1)] self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff( 1, (firdes.gaussian(1, samples_per_symbol / 2, 0.25, 100))) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self._freq_shift_range = Range(0, 100e3, 1e3, 1e3, 200) self._freq_shift_win = RangeWidget(self._freq_shift_range, self.set_freq_shift, "Channel Frequency Shift", "counter_slider", float) self.tabs_grid_layout_1.addWidget(self._freq_shift_win, 0, 0, 1, 1) [self.tabs_grid_layout_1.setRowStretch(r, 1) for r in range(0, 1)] [self.tabs_grid_layout_1.setColumnStretch(c, 1) for c in range(0, 1)] self.fm_modulator_0 = fm_modulator( modulation_sensitivity=modulation_sensitivity, samp_rate=symbol_rate * samples_per_symbol, ) self.fm_demodulator_0 = fm_demodulator( modulation_sensitivity=modulation_sensitivity, samp_rate=sample_rate, ) self.custom_symbol_sync_early_late_fb_0 = custom.symbol_sync_early_late_fb( samples_per_symbol, 1 / sample_rate, 0.01 * sample_rate, 0.707, 3.22) self.custom_rect_encoder_bf_0 = custom.rect_encoder_bf( samples_per_symbol) self.custom_frame_sync_bb_0 = custom.frame_sync_bb(([ 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0 ]), 32, 3) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, sample_rate, True) self.blocks_file_source_0_0 = blocks.file_source( gr.sizeof_char * 1, '/home/rpa/code/FloripaSat-I-SDR-Receiver/Binary-Files/fsat-hello.bin', True) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) ################################################## # Connections ################################################## self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0_0_0, 0)) self.connect((self.blocks_file_source_0_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.fm_demodulator_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0_0_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.custom_rect_encoder_bf_0, 0)) self.connect((self.custom_frame_sync_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.custom_rect_encoder_bf_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.custom_symbol_sync_early_late_fb_0, 0), (self.custom_frame_sync_bb_0, 0)) self.connect((self.fm_demodulator_0, 0), (self.custom_symbol_sync_early_late_fb_0, 0)) self.connect((self.fm_demodulator_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.fm_demodulator_0, 0), (self.qtgui_time_sink_x_0_0_0_0, 1)) self.connect((self.fm_modulator_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.fm_modulator_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.qtgui_time_sink_x_0_0_0_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.samp_rate_usrp = samp_rate_usrp = 100e6 self.Kd_max = Kd_max = 512 self.B_d = B_d = 200e3 self.Kd_d = Kd_d = min(samp_rate_usrp/B_d, Kd_max) self.Kd = Kd = int(math.pow(2,int(math.log(Kd_d,2)))) self.samp_rate = samp_rate = samp_rate_usrp/Kd self.samp_rate_d = samp_rate_d = B_d self.Gain_rx_min = Gain_rx_min = -20 self.Gain_rx_max = Gain_rx_max = 100 self.Gain_rx = Gain_rx = 15 self.Fc_min = Fc_min = 50e6 self.Fc_max = Fc_max = 2.4e9 self.Fc = Fc = 99.7e6 self.B = B = samp_rate ################################################## # Blocks ################################################## self.menu = Qt.QTabWidget() self.menu_widget_0 = Qt.QWidget() self.menu_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.menu_widget_0) self.menu_grid_layout_0 = Qt.QGridLayout() self.menu_layout_0.addLayout(self.menu_grid_layout_0) self.menu.addTab(self.menu_widget_0, 'Espectro') self.menu_widget_1 = Qt.QWidget() self.menu_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.menu_widget_1) self.menu_grid_layout_1 = Qt.QGridLayout() self.menu_layout_1.addLayout(self.menu_grid_layout_1) self.menu.addTab(self.menu_widget_1, 'Envolvente compleja Polar') self.top_layout.addWidget(self.menu) self._Gain_rx_range = Range(Gain_rx_min, Gain_rx_max, (Gain_rx_max-Gain_rx_min)/100, 15, 200) self._Gain_rx_win = RangeWidget(self._Gain_rx_range, self.set_Gain_rx, 'Gain_rx', "counter_slider", float) self.top_grid_layout.addWidget(self._Gain_rx_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._Fc_range = Range(Fc_min, Fc_max, (Fc_max-Fc_min)/100000, 99.7e6, 200) self._Fc_win = RangeWidget(self._Fc_range, self.set_Fc, 'Fc', "counter_slider", float) self.top_grid_layout.addWidget(self._Fc_win, 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.uhd_usrp_source_0 = uhd.usrp_source( ",".join(('', "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(Fc, 0) self.uhd_usrp_source_0.set_gain(Gain_rx, 0) self.uhd_usrp_source_0.set_antenna('TX/RX', 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=int(B_d), decimation=int(B), taps=None, fractional_bw=None, ) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype Fc, #fc B_d, #bw "Deseado", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(True) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_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_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.menu_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win, 1, 0, 1, 1) [self.menu_grid_layout_0.setRowStretch(r,1) for r in range(1,2)] [self.menu_grid_layout_0.setColumnStretch(c,1) for c in range(0,1)] self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype Fc, #fc samp_rate, #bw "Recibido", #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(True) 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.menu_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 1, 1) [self.menu_grid_layout_0.setRowStretch(r,1) for r in range(0,1)] [self.menu_grid_layout_0.setColumnStretch(c,1) for c in range(0,1)] self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #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(-0.05, 0.05) self.qtgui_const_sink_x_0.set_x_axis(-0.05, 0.05) 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.menu_grid_layout_1.addWidget(self._qtgui_const_sink_x_0_win, 0, 0, 1, 1) [self.menu_grid_layout_1.setRowStretch(r,1) for r in range(0,1)] [self.menu_grid_layout_1.setColumnStretch(c,1) for c in range(0,1)] ################################################## # Connections ################################################## self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.rational_resampler_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Lab8") Qt.QWidget.__init__(self) self.setWindowTitle("Lab8") 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", "lab8") 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.std_dev = std_dev = 0.05 self.samp_rate = samp_rate = 32000 self.p_xy = p_xy = 0 self.npts = npts = 8192 self.mimo_option = mimo_option = 0 self.lw = lw = 0.5 self.const_qam = const_qam = digital.constellation_calcdist( digital.qam_16()[0], digital.qam_16()[1], 2, 1).base() self.const_psk = const_psk = digital.constellation_calcdist( digital.psk_4()[0], digital.psk_4()[1], 2, 1).base() ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'Transmitted') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'Received') self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, 'Histogram') self.top_grid_layout.addWidget(self.tab, 1, 0, 8, 7) for r in range(1, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 7): self.top_grid_layout.setColumnStretch(c, 1) self._std_dev_range = Range(0, 1, 0.001, 0.05, 200) self._std_dev_win = RangeWidget(self._std_dev_range, self.set_std_dev, 'Noise Std. Dev', "counter_slider", float) self.top_grid_layout.addWidget(self._std_dev_win, 0, 0, 1, 3) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 3): self.top_grid_layout.setColumnStretch(c, 1) self._p_xy_range = Range(0, 0.99, 0.001, 0, 200) self._p_xy_win = RangeWidget(self._p_xy_range, self.set_p_xy, 'Correlation Pxy', "counter_slider", float) self.top_grid_layout.addWidget(self._p_xy_win, 0, 3, 1, 3) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 6): self.top_grid_layout.setColumnStretch(c, 1) # Create the options list self._mimo_option_options = ( 0, 1, ) # Create the labels list self._mimo_option_labels = ( 'Alamouti', 'MIMO', ) # Create the combo box # Create the radio buttons self._mimo_option_group_box = Qt.QGroupBox('MIMO Option' + ": ") self._mimo_option_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._mimo_option_button_group = variable_chooser_button_group() self._mimo_option_group_box.setLayout(self._mimo_option_box) for i, _label in enumerate(self._mimo_option_labels): radio_button = Qt.QRadioButton(_label) self._mimo_option_box.addWidget(radio_button) self._mimo_option_button_group.addButton(radio_button, i) self._mimo_option_callback = lambda i: Qt.QMetaObject.invokeMethod( self._mimo_option_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._mimo_option_options.index(i))) self._mimo_option_callback(self.mimo_option) self._mimo_option_button_group.buttonClicked[int].connect( lambda i: self.set_mimo_option(self._mimo_option_options[i])) self.top_grid_layout.addWidget(self._mimo_option_group_box, 0, 6, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 4096, #size 1, #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(0, 20) self.qtgui_time_sink_x_0.set_y_label('Eigenvalue Ratio (dB)', "") 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(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(True) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] 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_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 9, 0, 2, 8) for r in range(9, 11): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f( npts, 200, -2, 2, "Histogram", 1) self.qtgui_histogram_sink_x_0.set_update_time(0.10) 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(True) self.qtgui_histogram_sink_x_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [3, 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 range(1): 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.tab_layout_2.addWidget(self._qtgui_histogram_sink_x_0_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "De-Correlated Constellation", #name 2 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-1.5, 1.5) self.qtgui_const_sink_x_1.set_x_axis(-1.5, 1.5) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(False) self.qtgui_const_sink_x_1.enable_grid(True) self.qtgui_const_sink_x_1.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, 2, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, -1, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 0.2, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(2): if len(labels[i]) == 0: self.qtgui_const_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_win = sip.wrapinstance( self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget) self.tab_layout_1.addWidget(self._qtgui_const_sink_x_1_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "Correlated Constellation", #name 2 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-4, 4) self.qtgui_const_sink_x_0.set_x_axis(-4, 4) 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(True) 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, 2, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, -1, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 0.2, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(2): 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.tab_layout_0.addWidget(self._qtgui_const_sink_x_0_win) self.ofdm_alamouti_cc_0 = ofdm.alamouti_cc(p_xy, std_dev, mimo_option) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( const_psk.points(), 1) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( 4096, 1 / 4096, 4096, 1) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_deinterleave_0 = blocks.deinterleave( gr.sizeof_float * 1, 1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_random_source_x_0 = blocks.vector_source_b( list(map(int, numpy.random.randint(0, 4, 1000))), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_histogram_sink_x_0, 0)) self.connect((self.blocks_deinterleave_0, 1), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_deinterleave_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.ofdm_alamouti_cc_0, 0)) self.connect((self.ofdm_alamouti_cc_0, 1), (self.blocks_complex_to_real_0, 0)) self.connect((self.ofdm_alamouti_cc_0, 2), (self.blocks_deinterleave_0, 0)) self.connect((self.ofdm_alamouti_cc_0, 0), (self.qtgui_const_sink_x_0, 1)) self.connect((self.ofdm_alamouti_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.ofdm_alamouti_cc_0, 1), (self.qtgui_const_sink_x_1, 0)) self.connect((self.ofdm_alamouti_cc_0, 1), (self.qtgui_const_sink_x_1, 1))
def __init__(self): gr.top_block.__init__(self, "Fm Receiver") Qt.QWidget.__init__(self) self.setWindowTitle("Fm Receiver") 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", "fm_receiver") 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.rf_rate = rf_rate = 2400000 self.rf_freq = rf_freq = 145000000 self.freq = freq = 144791400 self.channel_filter = channel_filter = firdes.low_pass(1.0, rf_rate, 9000, 1000, firdes.WIN_HAMMING, 6.76) self.channel_decim = channel_decim = 20 self.audio_rate = audio_rate = 48000 self.Decay = Decay = 0.1 self.Attack = Attack = 0.8 ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'RF') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'Channel') self.top_layout.addWidget(self.tab) self._freq_range = Range(rf_freq - rf_rate/2, rf_freq + rf_rate/2, 1000, 144791400, 1000) self._freq_win = RangeWidget(self._freq_range, self.set_freq, "freq", "counter_slider", float) self.top_layout.addWidget(self._freq_win) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rf_freq, #fc rf_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.tab_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win, 1,0,1,1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc rf_rate/channel_decim, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_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_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tab_layout_1.addWidget(self._qtgui_freq_sink_x_0_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rf_freq, #fc rf_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.tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0,0,1,1) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( 48000.0/rf_rate*channel_decim, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(channel_decim, (channel_filter), freq - rf_freq, int(rf_rate)) self.detectMarkSpace_1_0 = detectMarkSpace( decay=Decay, samp_rate=48000, attack=Attack, Frequency=2200, ) self.detectMarkSpace_0_0 = detectMarkSpace( decay=Decay, samp_rate=48000, attack=Attack, Frequency=1200, ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, rf_rate,True) self.blocks_sub_xx_0_0_0 = blocks.sub_ff(1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, '/home/basti/src/gr-workshop/iq-145M-2M4.cf32', True) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, '/tmp/aprs.txt', False) self.blocks_file_sink_0_0.set_unbuffered(True) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=48000, quad_rate=48000, tau=75e-6, max_dev=5e3, ) self.afsk_ax25decode_1 = afsk.ax25decode(48000, 5) ################################################## # Connections ################################################## self.connect((self.afsk_ax25decode_1, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.analog_nbfm_rx_0, 0), (self.detectMarkSpace_0_0, 0)) self.connect((self.analog_nbfm_rx_0, 0), (self.detectMarkSpace_1_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_sub_xx_0_0_0, 0), (self.afsk_ax25decode_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_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_waterfall_sink_x_0, 0)) self.connect((self.detectMarkSpace_0_0, 0), (self.blocks_sub_xx_0_0_0, 0)) self.connect((self.detectMarkSpace_1_0, 0), (self.blocks_sub_xx_0_0_0, 1)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.analog_nbfm_rx_0, 0))