Beispiel #1
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, "multitone_gen")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("multitone_gen")
        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", "mutlitone_gen")

        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.waveform = waveform = 0
        self.tone_freq = tone_freq = 100
        self.sdr_freq = sdr_freq = 136050000
        self.samp_rate = samp_rate = 30000000
        self.num_tones = num_tones = 3
        self.jam_button = jam_button = 0
        self.freq_spacing = freq_spacing = 1000000

        ##################################################
        # Blocks
        ##################################################
        # Create the options list
        self._waveform_options = (
            0,
            1,
            2,
        )
        # Create the labels list
        self._waveform_labels = (
            'Square',
            'Sawtooth',
            'Sine',
        )
        # Create the combo box
        # Create the radio buttons
        self._waveform_group_box = Qt.QGroupBox('Select Waveform ' + ": ")
        self._waveform_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._waveform_button_group = variable_chooser_button_group()
        self._waveform_group_box.setLayout(self._waveform_box)
        for i, _label in enumerate(self._waveform_labels):
            radio_button = Qt.QRadioButton(_label)
            self._waveform_box.addWidget(radio_button)
            self._waveform_button_group.addButton(radio_button, i)
        self._waveform_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._waveform_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._waveform_options.index(i)))
        self._waveform_callback(self.waveform)
        self._waveform_button_group.buttonClicked[int].connect(
            lambda i: self.set_waveform(self._waveform_options[i]))
        self.top_grid_layout.addWidget(self._waveform_group_box, 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._tone_freq_range = Range(100, 10000000, 100, 100, 200)
        self._tone_freq_win = RangeWidget(self._tone_freq_range,
                                          self.set_tone_freq, 'Tone Frequency',
                                          "counter_slider", int)
        self.top_grid_layout.addWidget(self._tone_freq_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._sdr_freq_range = Range(60000000, 6000000000, 10000, 136050000,
                                     200)
        self._sdr_freq_win = RangeWidget(self._sdr_freq_range,
                                         self.set_sdr_freq, 'SDR frequency',
                                         "counter_slider", int)
        self.top_grid_layout.addWidget(self._sdr_freq_win, 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._num_tones_range = Range(1, 100, 1, 3, 200)
        self._num_tones_win = RangeWidget(self._num_tones_range,
                                          self.set_num_tones,
                                          'Number of Tones', "counter_slider",
                                          int)
        self.top_grid_layout.addWidget(self._num_tones_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)
        _jam_button_push_button = Qt.QPushButton('JAM')
        _jam_button_push_button = Qt.QPushButton('JAM')
        self._jam_button_choices = {'Pressed': 1, 'Released': 0}
        _jam_button_push_button.pressed.connect(
            lambda: self.set_jam_button(self._jam_button_choices['Pressed']))
        _jam_button_push_button.released.connect(
            lambda: self.set_jam_button(self._jam_button_choices['Released']))
        self.top_grid_layout.addWidget(_jam_button_push_button, 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._freq_spacing_range = Range(25000, 10000000, 25000, 1000000, 200)
        self._freq_spacing_win = RangeWidget(self._freq_spacing_range,
                                             self.set_freq_spacing,
                                             'Spacing of Tones',
                                             "counter_slider", int)
        self.top_grid_layout.addWidget(self._freq_spacing_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.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            tone_freq,  #fc
            (num_tones * freq_spacing),  #bw
            "",  #name
            2)
        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)

        labels = ['rx_data', 'tx_data', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "yellow", "magenta", "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.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 2, 0, 2,
                                       3)
        for r in range(2, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.iio_pluto_source_0 = iio.pluto_source('', int(sdr_freq),
                                                   int(samp_rate),
                                                   int(20000000), 32768, True,
                                                   True, True, 'manual', 60,
                                                   '', True)
        self.iio_pluto_sink_0 = iio.pluto_sink('',
                                               int(sdr_freq), int(samp_rate),
                                               int(20000000), 32768, False,
                                               10.0, '', True)
        self.epy_block_0 = epy_block_0.blk(waveform=waveform,
                                           samp_rate=samp_rate,
                                           ctr_freq=10000000,
                                           num_tones=num_tones,
                                           freq_spacing=freq_spacing)
        self.blocks_mute_xx_0 = blocks.mute_cc(bool(not (jam_button)))
        self.analog_sig_source_x_0_0_0_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_SIN_WAVE, tone_freq, 1, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0_0_0_0_0, 0),
                     (self.epy_block_0, 0))
        self.connect((self.blocks_mute_xx_0, 0), (self.iio_pluto_sink_0, 0))
        self.connect((self.blocks_mute_xx_0, 0), (self.qtgui_freq_sink_x_0, 1))
        self.connect((self.epy_block_0, 0), (self.blocks_mute_xx_0, 0))
        self.connect((self.iio_pluto_source_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
Beispiel #3
0
    def __init__(self):
        gr.top_block.__init__(self, "TX OFDM")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("TX OFDM")
        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", "tx_ofdm_papr")

        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.fft_len = fft_len = 256
        self.fft2 = fft2 = int(fft_len / 2)
        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(-fft2, 0)) + list(range(1, fft2 + 1)), )
        self.num_syms = num_syms = 16
        self.length_tag_key = length_tag_key = "frame_len"
        self.header_mod = header_mod = digital.constellation_bpsk()
        self.tx_amp = tx_amp = 1
        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.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.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.frame_len = frame_len = 4096

        ##################################################
        # Blocks
        ##################################################
        self._tx_amp_range = Range(0, 2, .001, 1, 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._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.wes_max_ff_0 = wes.max_ff(frame_len)
        self.qtgui_number_sink_0_1 = qtgui.number_sink(gr.sizeof_float, 0,
                                                       qtgui.NUM_GRAPH_HORIZ,
                                                       1)
        self.qtgui_number_sink_0_1.set_update_time(0.10)
        self.qtgui_number_sink_0_1.set_title('PAPR (dB)')

        labels = ['', '', '', '', '', '', '', '', '', '']
        units = ['', '', '', '', '', '', '', '', '', '']
        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_1.set_min(i, -1)
            self.qtgui_number_sink_0_1.set_max(i, 1)
            self.qtgui_number_sink_0_1.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0_1.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0_1.set_label(i, labels[i])
            self.qtgui_number_sink_0_1.set_unit(i, units[i])
            self.qtgui_number_sink_0_1.set_factor(i, factor[i])

        self.qtgui_number_sink_0_1.enable_autoscale(False)
        self._qtgui_number_sink_0_1_win = sip.wrapinstance(
            self.qtgui_number_sink_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_1_win, 11, 4,
                                       1, 4)
        for r in range(11, 12):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_HORIZ, 1)
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title('PAPR')

        labels = ['', '', '', '', '', '', '', '', '', '']
        units = ['', '', '', '', '', '', '', '', '', '']
        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, -1)
            self.qtgui_number_sink_0.set_max(i, 1)
            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, 11, 0, 1,
                                       4)
        for r in range(11, 12):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            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 * 2,  #bw
            "",  #name
            1)
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-120, -40)
        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 = [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.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 2, 0, 8,
                                       8)
        for r in range(2, 10):
            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 * 2),
                                                   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.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,
            bps_header=2,
            bps_payload=2,
            rolloff=0,
            debug_log=False,
            scramble_bits=False)
        self.blocks_vector_source_x_0 = blocks.vector_source_b((1, 1, 1, 1),
                                                               True, 1, [])
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, packet_len, packet_length_tag_key)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(tx_amp /
                                                                    30)
        self.blocks_moving_average_xx_0_0 = blocks.moving_average_ff(
            frame_len, 1 / frame_len, frame_len * 4, 1)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            frame_len, 1 / frame_len, frame_len * 4, 1)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.wes_max_ff_0, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.blocks_moving_average_xx_0_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_moving_average_xx_0_0, 0),
                     (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_moving_average_xx_0_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.iio_pluto_sink_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.qtgui_number_sink_0_1, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0),
                     (self.digital_ofdm_tx_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.digital_ofdm_tx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.iio_pluto_source_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.wes_max_ff_0, 0), (self.blocks_divide_xx_0, 0))
Beispiel #4
0
    def __init__(self):
        gr.top_block.__init__(self, "TX Single-Carrier")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("TX Single-Carrier")
        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", "tx_sc")

        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.tx_amp = tx_amp = 0.2
        self.signal_select = signal_select = 0
        self.samp_rate = samp_rate = 4e6
        self.rx_gain = rx_gain = 30
        self.freqc = freqc = 900e6
        self.beta = beta = 0.5

        ##################################################
        # Blocks
        ##################################################
        self._tx_amp_range = Range(0, 0.5, .001, 0.2, 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)
        # Create the options list
        self._signal_select_options = (0, 1, 2, )
        # Create the labels list
        self._signal_select_labels = ('Rectangular', 'Raised Cosine', 'Root-Raised Cosine', )
        # Create the combo box
        self._signal_select_tool_bar = Qt.QToolBar(self)
        self._signal_select_tool_bar.addWidget(Qt.QLabel('Signal Select' + ": "))
        self._signal_select_combo_box = Qt.QComboBox()
        self._signal_select_tool_bar.addWidget(self._signal_select_combo_box)
        for _label in self._signal_select_labels: self._signal_select_combo_box.addItem(_label)
        self._signal_select_callback = lambda i: Qt.QMetaObject.invokeMethod(self._signal_select_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._signal_select_options.index(i)))
        self._signal_select_callback(self.signal_select)
        self._signal_select_combo_box.currentIndexChanged.connect(
            lambda i: self.set_signal_select(self._signal_select_options[i]))
        # Create the radio buttons
        self.top_grid_layout.addWidget(self._signal_select_tool_bar, 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._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._beta_range = Range(0.01, 0.99, 0.01, 0.5, 200)
        self._beta_win = RangeWidget(self._beta_range, self.set_beta, 'Beta (Excess BW)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._beta_win, 10, 0, 1, 8)
        for r in range(10, 11):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 8):
            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/2, #bw
            "", #name
            1
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-120, -20)
        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 = [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.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 2, 0, 8, 8)
        for r in range(2, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.pulse_shape_hier_0 = pulse_shape_hier(
            bFilter=signal_select,
            rect_taps=(1,1,1,1),
            roll_off=beta,
            sps=4,
        )
        self.iio_pluto_source_0 = iio.pluto_source('usb:1.4.5', int(freqc), int(samp_rate/2), 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.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((-1-1j,-1+1j,1-1j,1+1j), 1)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, 2, "", False, gr.GR_LSB_FIRST)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(tx_amp)
        self.analog_random_source_x_0 = blocks.vector_source_b(list(map(int, numpy.random.randint(0, 255, 1000))), True)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0), (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.iio_pluto_sink_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.pulse_shape_hier_0, 0))
        self.connect((self.iio_pluto_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.pulse_shape_hier_0, 0), (self.blocks_multiply_const_vxx_0, 0))
Beispiel #5
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))
Beispiel #6
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Dvbs Tx")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.symbol_rate = symbol_rate = 1000000
        self.username = username = os.environ.get('USER')
        self.samp_rate = samp_rate = symbol_rate * 2
        self.rrc_taps = rrc_taps = 100
        self.frequency = frequency = 2440000000

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=frequency,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=True,
            avg_alpha=0.13333,
            title='FFT Plot',
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.trellis_encoder_xx_0 = trellis.encoder_bb(
            trellis.fsm(1, 2,
                        (0171, 0133)), 0, 0) if False else trellis.encoder_bb(
                            trellis.fsm(1, 2, (0171, 0133)), 0)
        self._symbol_rate_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.symbol_rate,
            callback=self.set_symbol_rate,
            label='symbol_rate',
            choices=[250000, 333000, 500000, 1000000, 1200000, 1500000],
            labels=[
                "250kS/s", "333kS/s", "500 kS/s", "1000kS/s", "1200kS/s",
                "1500kS/s"
            ],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._symbol_rate_chooser)
        self.pluto_sink_0 = iio.pluto_sink('', frequency, samp_rate, 20000000,
                                           0x8000, False, 10.0, '', True)
        self.fft_filter_xxx_0 = filter.fft_filter_ccc(
            1, (firdes.root_raised_cosine(1.0, samp_rate, samp_rate / 2, 0.35,
                                          rrc_taps)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.fec_puncture_xx_0 = fec.puncture_bb(14, 0b11010101100110, 0)
        self.dtv_dvbt_reed_solomon_enc_0 = dtv.dvbt_reed_solomon_enc(
            2, 8, 0x11d, 255, 239, 8, 51, 8)
        self.dtv_dvbt_energy_dispersal_0 = dtv.dvbt_energy_dispersal(1)
        self.dtv_dvbt_convolutional_interleaver_0 = dtv.dvbt_convolutional_interleaver(
            136, 12, 17)
        self.dtv_dvbs2_modulator_bc_0 = dtv.dvbs2_modulator_bc(
            dtv.FECFRAME_NORMAL, dtv.C5_6, dtv.MOD_QPSK, dtv.INTERPOLATION_ON)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(2)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1, "/media/" + username + "/PlutoSDR/rpidatv.ts",
            True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0),
                     (self.dtv_dvbt_energy_dispersal_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_0, 0),
                     (self.dtv_dvbs2_modulator_bc_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.trellis_encoder_xx_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                     (self.fec_puncture_xx_0, 0))
        self.connect((self.dtv_dvbs2_modulator_bc_0, 0),
                     (self.fft_filter_xxx_0, 0))
        self.connect((self.dtv_dvbt_convolutional_interleaver_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.dtv_dvbt_energy_dispersal_0, 0),
                     (self.dtv_dvbt_reed_solomon_enc_0, 0))
        self.connect((self.dtv_dvbt_reed_solomon_enc_0, 0),
                     (self.dtv_dvbt_convolutional_interleaver_0, 0))
        self.connect((self.fec_puncture_xx_0, 0),
                     (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.fft_filter_xxx_0, 0), (self.pluto_sink_0, 0))
        self.connect((self.fft_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.trellis_encoder_xx_0, 0),
                     (self.blocks_unpack_k_bits_bb_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Not titled yet")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = int(2.2e6)
        self.f = f = int(700e6)
        self.N = N = 140000
        self.plutopow = plutopow = 30.0

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_pub_sink_0 = zeromq.pub_sink(gr.sizeof_gr_complex, N,
                                                 'tcp://192.168.0.165:5555',
                                                 100, False, -1)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0, 2)),
            ),
        )
        self.uhd_usrp_source_0.set_center_freq(f, 0)
        self.uhd_usrp_source_0.set_gain(70, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_0.set_center_freq(f, 1)
        self.uhd_usrp_source_0.set_gain(40, 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.iio_pluto_sink_0 = iio.pluto_sink('', f, samp_rate, 20000000,
                                               32768, False, plutopow, '',
                                               True)
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(32, True)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, N)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(3.1415)
        self.blocks_magphase_to_complex_0 = blocks.magphase_to_complex(1)
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(
            gr.sizeof_gr_complex * N, 1)
        self.blocks_interleave_0 = blocks.interleave(gr.sizeof_gr_complex * 1,
                                                     1)
        self.blocks_int_to_float_0 = blocks.int_to_float(1, 1)
        self.analog_random_source_x_0 = blocks.vector_source_i(
            list(map(int, numpy.random.randint(0, 2, N))), True)
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_magphase_to_complex_0, 0))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blocks_int_to_float_0, 0))
        self.connect((self.blocks_int_to_float_0, 0),
                     (self.dc_blocker_xx_0, 0))
        self.connect((self.blocks_interleave_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0),
                     (self.zeromq_pub_sink_0, 0))
        self.connect((self.blocks_magphase_to_complex_0, 0),
                     (self.iio_pluto_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_magphase_to_complex_0, 1))
        self.connect((self.blocks_stream_to_vector_0, 0),
                     (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.uhd_usrp_source_0, 1),
                     (self.blocks_interleave_0, 1))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.blocks_interleave_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Not titled yet")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Not titled yet")
        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", "m2k_am_if_to_fm_pluto_tx")

        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.tx_samp_rate = tx_samp_rate = 600000
        self.tx_freq = tx_freq = 90e6
        self.samp_rate = samp_rate = 10000000
        self.rr_interp = rr_interp = 8
        self.rr_decim = rr_decim = 5
        self.osr = osr = 5
        self.lp_decim = lp_decim = 10
        self.if_freq = if_freq = 475000
        self.fx_decim = fx_decim = 10

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=rr_interp,
            decimation=rr_decim,
            taps=[128],
            fractional_bw=0.8)
        self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f(
            4096,  #size
            samp_rate / (osr * fx_decim),  #samp_rate
            "Demodulated Baseband",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_1.set_update_time(0.10)
        self.qtgui_time_sink_x_0_1.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0_1.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0_1.enable_tags(True)
        self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                    qtgui.TRIG_SLOPE_POS, 0.0,
                                                    0, 0, "")
        self.qtgui_time_sink_x_0_1.enable_autoscale(True)
        self.qtgui_time_sink_x_0_1.enable_grid(True)
        self.qtgui_time_sink_x_0_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_1.enable_control_panel(True)
        self.qtgui_time_sink_x_0_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_0_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c(
            4096,  #size
            samp_rate / (osr * fx_decim),  #samp_rate
            "Translated I.F.",  #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('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(True)
        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.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win)
        self.m2k_analog_in_source_0 = m2k.analog_in_source(
            'ip:192.168.3.1', 16384, [True, False], [0, 0], samp_rate, osr, 4,
            True, True, [2, 0], [0, 0], 0, 0, [0, 0])
        self.low_pass_filter_0 = filter.fir_filter_fff(
            lp_decim,
            firdes.low_pass(1, samp_rate / (osr * fx_decim), 3000, 500,
                            firdes.WIN_HAMMING, 6.76))
        self.iio_pluto_sink_0 = iio.pluto_sink('ip:192.168.2.1', int(tx_freq),
                                               tx_samp_rate, 200000, 32768,
                                               False, 0, '', True)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_fcc(
            fx_decim,
            firdes.low_pass(1, (samp_rate / osr),
                            (samp_rate / osr) / (2 * fx_decim), 20000),
            if_freq, samp_rate / osr)
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(32, True)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(1)
        self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1)
        self.audio_sink_0 = audio.sink(32000, '', False)
        self.analog_wfm_tx_0 = analog.wfm_tx(
            audio_rate=int(samp_rate / (osr * fx_decim * lp_decim)),
            quad_rate=tx_samp_rate,
            tau=75e-6,
            max_dev=150e3,
            fh=-1.0,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_tx_0, 0), (self.iio_pluto_sink_0, 0))
        self.connect((self.blocks_complex_to_mag_1, 0),
                     (self.dc_blocker_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_1, 0),
                     (self.qtgui_time_sink_x_0_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 1))
        self.connect((self.dc_blocker_xx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.blocks_complex_to_mag_1, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_tx_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.m2k_analog_in_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
Beispiel #9
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))
Beispiel #10
0
    def __init__(self):
        gr.top_block.__init__(self, "Not titled yet")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Not titled yet")
        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", "sim_tx")

        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.symbol_rate = symbol_rate = 500000
        self.tx_gain = tx_gain = 50
        self.samp_rate = samp_rate = symbol_rate * 2
        self.constel = constel = digital.constellation_calcdist([
            +0.70711 + +0.70711j, +1.0 + +0.0j, -1.0 + +0.0j,
            -0.70711 + -0.70711j, +0.0 + +1.0j, +0.70711 + -0.70711j,
            -0.70711 + +0.70711j, -0.0 + -1.0j
        ], list(range(0, 8)), 8, 1).base()
        self.constel.gen_soft_dec_lut(8)
        self.center_freq = center_freq = 1279e6

        ##################################################
        # Blocks
        ##################################################
        self._tx_gain_range = Range(0, 60, 1, 50, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        'TX Gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._tx_gain_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            center_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(True)
        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)

        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.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c(
            1024,  #size
            "EVM Constellation",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0.set_update_time(0.001)
        self.qtgui_const_sink_x_0_0.set_y_axis(-1.5, 1.5)
        self.qtgui_const_sink_x_0_0.set_x_axis(-1.5, 1.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 = [
            'Reclocked', 'Reference', 'Filtered', 'Raw', '', '', '', '', '', ''
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "cyan", "yellow", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [2, 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.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 0, 0,
                                       2, 1)
        for r in range(0, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.iio_pluto_sink_0 = iio.pluto_sink('', int(center_freq),
                                               int(samp_rate), 2000000, 32768,
                                               False, 60 - tx_gain, '', True)
        self.digital_symbol_sync_xx_0 = digital.symbol_sync_cc(
            digital.TED_MOD_MUELLER_AND_MULLER, 2, 2 * 3.14159 / 100 * 0.6,
            1.0, 1.0, 1.5, 1, constel, digital.IR_MMSE_8TAP, 128, [])
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc(2**-12)
        self.blocks_interleaved_short_to_complex_0 = blocks.interleaved_short_to_complex(
            False, False)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_short * 1,
            '/Users/iracigt/Developer/DVB_hat/hdl/iq_bytes.bin',
            True,
            0 * 21690 * 2,
        )
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_add_const_vxx_0 = blocks.add_const_cc(-3.8 * (1 + 1j))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.digital_symbol_sync_xx_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.iio_pluto_sink_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_interleaved_short_to_complex_0, 0))
        self.connect((self.blocks_interleaved_short_to_complex_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.digital_symbol_sync_xx_0, 0),
                     (self.qtgui_const_sink_x_0_0, 0))
Beispiel #11
0
    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, "Example: Simple Transmit and Receive")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Example: Simple Transmit and Receive")
        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_simple_tx_rx")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = int(2.2e6)
        self.freq = freq = int(2e9)

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_2 = qtgui.time_sink_c(
            100, #size
            samp_rate, #samp_rate
            "", #name
            1 #number of inputs
        )
        self.qtgui_time_sink_x_2.set_update_time(0.10)
        self.qtgui_time_sink_x_2.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_2.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_2.enable_tags(True)
        self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_2.enable_autoscale(False)
        self.qtgui_time_sink_x_2.enable_grid(False)
        self.qtgui_time_sink_x_2.enable_axis_labels(True)
        self.qtgui_time_sink_x_2.enable_control_panel(False)
        self.qtgui_time_sink_x_2.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_2.set_line_label(i, "Re{{Data {0}}}".format(i/2))
                else:
                    self.qtgui_time_sink_x_2.set_line_label(i, "Im{{Data {0}}}".format(i/2))
            else:
                self.qtgui_time_sink_x_2.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_2.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_2.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_2.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_2.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_2_win = sip.wrapinstance(self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_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.qtgui_time_sink_x_1 = qtgui.time_sink_f(
            100, #size
            samp_rate, #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(-1, 1)

        self.qtgui_time_sink_x_1.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_1.enable_tags(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)


        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.top_grid_layout.addWidget(self._qtgui_time_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_time_sink_x_0_0 = qtgui.time_sink_c(
            80, #size
            samp_rate, #samp_rate
            'Tx Signal, Time Domain', #name
            1 #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.1)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)

        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(False)
        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.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_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_time_sink_x_0 = qtgui.time_sink_c(
            100, #size
            samp_rate, #samp_rate
            'Rx Signal, Time Domain', #name
            1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.1)
        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(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)


        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.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_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.iio_pluto_source_0 = iio.pluto_source('ip:192.168.2.1', 1200000000, samp_rate, 20000000, 32768, True, True, True, 'fast_attack', 90, '', True)
        self.iio_pluto_sink_0 = iio.pluto_sink('ip:192.168.2.1', 1200000000, samp_rate, 2000000, 32768, False, 20.0, '', True)
        self.digital_pn_correlator_cc_1 = digital.pn_correlator_cc(5, 0, 1)
        self.digital_glfsr_source_x_0 = digital.glfsr_source_f(5, True, 0, 1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        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.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0), (self.iio_pluto_sink_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.digital_glfsr_source_x_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.digital_glfsr_source_x_0, 0), (self.qtgui_time_sink_x_1, 0))
        self.connect((self.digital_pn_correlator_cc_1, 0), (self.qtgui_time_sink_x_2, 0))
        self.connect((self.iio_pluto_source_0, 0), (self.digital_pn_correlator_cc_1, 0))
        self.connect((self.iio_pluto_source_0, 0), (self.qtgui_time_sink_x_0, 0))
Beispiel #13
0
    def __init__(self):
        gr.top_block.__init__(self, "Pulse Radar")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Pulse Radar")
        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", "pulse_radar")

        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.tgt_pw = tgt_pw = 10e-3
        self.samp_rate = samp_rate = 2000000
        self.tgt_pw_tau = tgt_pw_tau = round(tgt_pw/(1/samp_rate))
        self.tgt_pri = tgt_pri = 10e-2
        self.percent_tracks = percent_tracks = 50
        self.track_spacing = track_spacing = round((tgt_pri/tgt_pw)*((100-percent_tracks)/100)*(tgt_pw_tau))
        self.tgt_pri_tau = tgt_pri_tau = round(tgt_pri/(1/samp_rate))
        self.pulse_vector = pulse_vector = [1]*tgt_pw_tau+[0]*(track_spacing)
        self.pulse_freq = pulse_freq = 200
        self.freq = freq = 136050000

        ##################################################
        # Blocks
        ##################################################
        self._pulse_freq_range = Range(10, 10e3, 100, 200, 200)
        self._pulse_freq_win = RangeWidget(self._pulse_freq_range, self.set_pulse_freq, 'Pulse Freq', "counter_slider", float)
        self.top_grid_layout.addWidget(self._pulse_freq_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._tgt_pw_range = Range(1e-6, 1, 0.5e-6, 10e-3, 200)
        self._tgt_pw_win = RangeWidget(self._tgt_pw_range, self.set_tgt_pw, 'target radar PW', "counter_slider", float)
        self.top_grid_layout.addWidget(self._tgt_pw_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._tgt_pri_range = Range(2e-6, 1, 0.5e-6, 10e-2, 200)
        self._tgt_pri_win = RangeWidget(self._tgt_pri_range, self.set_tgt_pri, 'target radar PRI', "counter_slider", float)
        self.top_grid_layout.addWidget(self._tgt_pri_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_time_sink_x_1 = qtgui.time_sink_c(
            100000, #size
            samp_rate/2, #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(-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, 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(True)
        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(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.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win, 2, 0, 1, 3)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024, #size
            firdes.WIN_BLACKMAN_hARRIS, #wintype
            pulse_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.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 3, 0, 1, 3)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._percent_tracks_range = Range(0, 100, 1, 50, 200)
        self._percent_tracks_win = RangeWidget(self._percent_tracks_range, self.set_percent_tracks, 'percent_tracks', "counter_slider", float)
        self.top_grid_layout.addWidget(self._percent_tracks_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.iio_pluto_source_0 = iio.pluto_source('', int(freq), int(2084000), int(20000000), 32768, True, True, True, 'manual', 35, '', True)
        self.iio_pluto_sink_0 = iio.pluto_sink('', int(freq), int(samp_rate), int(20000000), 32768, False, 10.0, '', True)
        self.blocks_vector_source_x_0 = blocks.vector_source_c(pulse_vector, True, 1, [])
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_SIN_WAVE, pulse_freq, 1, 0, 0)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_multiply_xx_1, 0), (self.iio_pluto_sink_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_multiply_xx_1, 0))
        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_1, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Pluto Msg Tx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Pluto Msg Tx")
        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_msg_tx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 10
        self.samp_rate = samp_rate = 10e6
        self.pdu_length = pdu_length = 1500
        self.out_buf_size = out_buf_size = 96000
        self.lo_offset = lo_offset = 0
        self.interval = interval = 10
        self.freq = freq = 3500000000
        self.encoding = encoding = 0
        ##################################################
        # Blocks
        ##################################################
        self._tx_gain_range = Range(0, 20, 0.01, 10, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        "tx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._tx_gain_win)
        self._interval_range = Range(10, 10000, 1, 10, 200)
        self._interval_win = RangeWidget(self._interval_range,
                                         self.set_interval, "interval",
                                         "counter_slider", int)
        self.top_layout.addWidget(self._interval_win)
        self._freq_options = [
            3500000000.0, 2412000000.0, 2417000000.0, 2422000000.0,
            2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0,
            2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0,
            2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0,
            5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0,
            5220000000.0, 5230000000.0, 5240000000.0, 5250000000.0,
            5260000000.0, 5270000000.0, 5280000000.0, 5290000000.0,
            5300000000.0, 5310000000.0, 5320000000.0, 5500000000.0,
            5510000000.0, 5520000000.0, 5530000000.0, 5540000000.0,
            5550000000.0, 5560000000.0, 5570000000.0, 5580000000.0,
            5590000000.0, 5600000000.0, 5610000000.0, 5620000000.0,
            5630000000.0, 5640000000.0, 5660000000.0, 5670000000.0,
            5680000000.0, 5690000000.0, 5700000000.0, 5710000000.0,
            5720000000.0, 5745000000.0, 5755000000.0, 5765000000.0,
            5775000000.0, 5785000000.0, 5795000000.0, 5805000000.0,
            5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0,
            5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0
        ]
        self._freq_labels = [
            ' 0|3.5G', '  1 | 2412.0 | 11g', '  2 | 2417.0 | 11g',
            '  3 | 2422.0 | 11g', '  4 | 2427.0 | 11g', '  5 | 2432.0 | 11g',
            '  6 | 2437.0 | 11g', '  7 | 2442.0 | 11g', '  8 | 2447.0 | 11g',
            '  9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g',
            ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g',
            ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a',
            ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a',
            ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a',
            ' 52 | 5260.0 | 11a', ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a',
            ' 58 | 5290.0 | 11a', ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a',
            ' 64 | 5320.0 | 11a', '100 | 5500.0 | 11a', '102 | 5510.0 | 11a',
            '104 | 5520.0 | 11a', '106 | 5530.0 | 11a', '108 | 5540.0 | 11a',
            '110 | 5550.0 | 11a', '112 | 5560.0 | 11a', '114 | 5570.0 | 11a',
            '116 | 5580.0 | 11a', '118 | 5590.0 | 11a', '120 | 5600.0 | 11a',
            '122 | 5610.0 | 11a', '124 | 5620.0 | 11a', '126 | 5630.0 | 11a',
            '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '134 | 5670.0 | 11a',
            '136 | 5680.0 | 11a', '138 | 5690.0 | 11a', '140 | 5700.0 | 11a',
            '142 | 5710.0 | 11a', '144 | 5720.0 | 11a',
            '149 | 5745.0 | 11a (SRD)', '151 | 5755.0 | 11a (SRD)',
            '153 | 5765.0 | 11a (SRD)', '155 | 5775.0 | 11a (SRD)',
            '157 | 5785.0 | 11a (SRD)', '159 | 5795.0 | 11a (SRD)',
            '161 | 5805.0 | 11a (SRD)', '165 | 5825.0 | 11a (SRD)',
            '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p',
            '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p',
            '184 | 5920.0 | 11p'
        ]
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel("freq" + ": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels:
            self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._freq_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
            lambda i: self.set_freq(self._freq_options[i]))
        self.top_layout.addWidget(self._freq_tool_bar)
        self._encoding_options = [0, 1, 2, 3, 4, 5, 6, 7]
        self._encoding_labels = [
            "BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2",
            "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"
        ]
        self._encoding_group_box = Qt.QGroupBox("encoding")
        self._encoding_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._encoding_button_group = variable_chooser_button_group()
        self._encoding_group_box.setLayout(self._encoding_box)
        for i, label in enumerate(self._encoding_labels):
            radio_button = Qt.QRadioButton(label)
            self._encoding_box.addWidget(radio_button)
            self._encoding_button_group.addButton(radio_button, i)
        self._encoding_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._encoding_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._encoding_options.index(i)))
        self._encoding_callback(self.encoding)
        self._encoding_button_group.buttonClicked[int].connect(
            lambda i: self.set_encoding(self._encoding_options[i]))
        self.top_layout.addWidget(self._encoding_group_box)
        self.wifi_phy_hier_0 = wifi_phy_hier(
            bandwidth=10e6,
            chan_est=0,
            encoding=encoding,
            frequency=5.89e9,
            sensitivity=0.56,
        )
        self._samp_rate_options = [5e6, 10e6, 20e6]
        self._samp_rate_labels = ["5 MHz", "10 MHz", "20 MHz"]
        self._samp_rate_tool_bar = Qt.QToolBar(self)
        self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate" + ": "))
        self._samp_rate_combo_box = Qt.QComboBox()
        self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box)
        for label in self._samp_rate_labels:
            self._samp_rate_combo_box.addItem(label)
        self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._samp_rate_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._samp_rate_options.index(i)))
        self._samp_rate_callback(self.samp_rate)
        self._samp_rate_combo_box.currentIndexChanged.connect(
            lambda i: self.set_samp_rate(self._samp_rate_options[i]))
        self.top_layout.addWidget(self._samp_rate_tool_bar)
        self.pluto_sink_0 = iio.pluto_sink('', freq, 10000000, 20000000,
                                           0x8000, False, tx_gain, '', True)
        self._pdu_length_range = Range(0, 1500, 1, 1500, 200)
        self._pdu_length_win = RangeWidget(self._pdu_length_range,
                                           self.set_pdu_length, "pdu_length",
                                           "counter_slider", int)
        self.top_layout.addWidget(self._pdu_length_win)
        self._lo_offset_options = (
            0,
            6e6,
            11e6,
        )
        self._lo_offset_labels = (
            str(self._lo_offset_options[0]),
            str(self._lo_offset_options[1]),
            str(self._lo_offset_options[2]),
        )
        self._lo_offset_tool_bar = Qt.QToolBar(self)
        self._lo_offset_tool_bar.addWidget(Qt.QLabel("lo_offset" + ": "))
        self._lo_offset_combo_box = Qt.QComboBox()
        self._lo_offset_tool_bar.addWidget(self._lo_offset_combo_box)
        for label in self._lo_offset_labels:
            self._lo_offset_combo_box.addItem(label)
        self._lo_offset_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._lo_offset_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._lo_offset_options.index(i)))
        self._lo_offset_callback(self.lo_offset)
        self._lo_offset_combo_box.currentIndexChanged.connect(
            lambda i: self.set_lo_offset(self._lo_offset_options[i]))
        self.top_layout.addWidget(self._lo_offset_tool_bar)
        self.ieee802_11_mac_0 = ieee802_11.mac(
            ([0x32, 0x32, 0x32, 0x32, 0x32, 0x32]),
            ([0x29, 0x29, 0x29, 0x29, 0x29, 0x29]),
            ([0xff, 0xff, 0xff, 0xff, 0xff, 255]))
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.01, 100, 1000)
        (self.foo_packet_pad2_0).set_min_output_buffer(96000)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", '', '52001',
                                                     10000, False)
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_gr_complex *
                                                       1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.6, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        ###Set Text Message Below.
        self.blocks_message_strobe_0_0 = blocks.message_strobe(
            pmt.intern("".join(a)), interval)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'),
                         (self.ieee802_11_mac_0, 'app in'))
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'),
                         (self.ieee802_11_mac_0, 'app in'))
        self.msg_connect((self.ieee802_11_mac_0, 'phy out'),
                         (self.wifi_phy_hier_0, 'mac_in'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.ieee802_11_mac_0, 'phy in'))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.foo_packet_pad2_0, 0))
        self.connect((self.blocks_null_source_0, 0), (self.wifi_phy_hier_0, 0))
        self.connect((self.foo_packet_pad2_0, 0), (self.pluto_sink_0, 0))
        self.connect((self.wifi_phy_hier_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
Beispiel #15
0
    def __init__(self, uri='ip:192.168.2.1'):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.uri = uri

        ##################################################
        # Variables
        ##################################################
        self.sampsym = sampsym = 16
        self.samp_rate = samp_rate = 1000000
        self.period_samples = period_samples = 0x8000
        self.constellations = constellations = 4

        ##################################################
        # Blocks
        ##################################################
        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(920e6, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(10, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna('', 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)

        self.qtgui_sink_x_0_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #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.top_layout.addWidget(self._qtgui_sink_x_0_0_win)

        self.qtgui_sink_x_0_0.enable_rf_freq(False)

        self.pluto_sink_0 = iio.pluto_sink('ip:pluto.local', 920000000,
                                           samp_rate, 20000000, 0x4000, False,
                                           10.0, '', True)
        self.digital_qam_mod_0 = digital.qam.qam_mod(
            constellation_points=constellations,
            mod_code="gray",
            differential=True,
            samples_per_symbol=sampsym,
            excess_bw=0.35,
            verbose=False,
            log=False,
        )
        self.digital_qam_demod_0 = digital.qam.qam_demod(
            constellation_points=constellations,
            differential=True,
            samples_per_symbol=sampsym,
            excess_bw=0.35,
            freq_bw=6.28 / 100.0,
            timing_bw=6.28 / 100.0,
            phase_bw=6.28 / 100.0,
            mod_code="gray",
            verbose=False,
            log=False,
        )
        self.blocks_unpacked_to_packed_xx_0_0 = blocks.unpacked_to_packed_bb(
            4, gr.GR_MSB_FIRST)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1,
            '/home/dchaffee/gnuradio/latency/TimeStamp.bin', True)
        self.blocks_file_sink_0_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/home/dchaffee/gnuradio/latency/TSTestReceive', False)
        self.blocks_file_sink_0_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0),
                     (self.digital_qam_mod_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0_0, 0),
                     (self.blocks_file_sink_0_0, 0))
        self.connect((self.digital_qam_demod_0, 0),
                     (self.blocks_unpacked_to_packed_xx_0_0, 0))
        self.connect((self.digital_qam_mod_0, 0), (self.pluto_sink_0, 0))
        self.connect((self.digital_qam_mod_0, 0), (self.qtgui_sink_x_0_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.digital_qam_demod_0, 0))
Beispiel #16
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))
Beispiel #17
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))
Beispiel #18
0
    def __init__(self, corr_tag_delay=131):
        gr.top_block.__init__(self, "Lab3 BER")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Lab3 BER")
        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_ber")

        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.corr_tag_delay = corr_tag_delay

        ##################################################
        # Variables
        ##################################################
        self.rolloff = rolloff = 0.5
        self.sps = sps = 4
        self.snr_default = snr_default = 8.5
        self.rolloff_ = rolloff_ = rolloff
        self.payload_len = payload_len = 31
        self.num_tag_key = num_tag_key = "packet_num"
        self.nfilts_pfb = nfilts_pfb = 32
        self.mark_delays = mark_delays = [0, 0, 34, 56, 87, 119]
        self.len_tag_key = len_tag_key = "packet_length"
        self.header_len = header_len = 32
        self.cw_len = cw_len = 32
        self.tag_s = tag_s = gr.tag_utils.python_to_tag(
            (0, pmt.intern(len_tag_key), pmt.from_long(payload_len),
             pmt.intern("vect_test_src")))
        self.tag0 = tag0 = gr.tag_utils.python_to_tag(
            (0, pmt.intern(len_tag_key), pmt.from_long(cw_len),
             pmt.intern("vect_cw_src")))
        self.sync_seq = sync_seq = [
            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, 1
        ]
        self.snr_db = snr_db = snr_default
        self.samp_rate = samp_rate = 1e3
        self.rrc_filter = rrc_filter = firdes.root_raised_cosine(
            4, sps, 1, rolloff_, 32 * sps + 1)
        self.reset_ber = reset_ber = 0
        self.pn_order = pn_order = np.round(np.log2(payload_len + 1))
        self.pn6_padded = pn6_padded = [
            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, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        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.pi = pi = np.pi
        self.pfb_filter = pfb_filter = firdes.root_raised_cosine(
            nfilts_pfb, nfilts_pfb * sps, 1, rolloff_,
            nfilts_pfb * 11 * sps + 1)
        self.mark_delay = mark_delay = mark_delays[sps]
        self.header_formatter_0 = header_formatter_0 = digital.packet_header_default(
            header_len, len_tag_key, num_tag_key, 1)
        self.header_formatter = header_formatter = digital.packet_header_default(
            header_len, len_tag_key, num_tag_key, 1)
        self.fc = fc = 900e6
        self.const = const = digital.constellation_calcdist(
            digital.psk_2()[0],
            digital.psk_2()[1], 2, 1).base()
        self.buffer_size = buffer_size = 32768
        self.bFilter = bFilter = 1
        self.agc_rate = agc_rate = 1e-4

        ##################################################
        # Blocks
        ##################################################
        self._snr_db_range = Range(0, 20, 0.5, snr_default, 200)
        self._snr_db_win = RangeWidget(self._snr_db_range, self.set_snr_db,
                                       'SNR (dB)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._snr_db_win)
        self._rolloff__range = Range(0.01, 0.99, 0.01, rolloff, 200)
        self._rolloff__win = RangeWidget(self._rolloff__range,
                                         self.set_rolloff_, 'Beta (Excess BW)',
                                         "counter_slider", float)
        self.top_grid_layout.addWidget(self._rolloff__win)
        _reset_ber_push_button = Qt.QPushButton('Reset BER')
        _reset_ber_push_button = Qt.QPushButton('Reset BER')
        self._reset_ber_choices = {'Pressed': 1, 'Released': 0}
        _reset_ber_push_button.pressed.connect(
            lambda: self.set_reset_ber(self._reset_ber_choices['Pressed']))
        _reset_ber_push_button.released.connect(
            lambda: self.set_reset_ber(self._reset_ber_choices['Released']))
        self.top_grid_layout.addWidget(_reset_ber_push_button)
        # Create the options list
        self._bFilter_options = (
            1,
            2,
        )
        # Create the labels list
        self._bFilter_labels = (
            'Raised Cosine (Mis-Matched)',
            'Root Raised Cosine (Matched)',
        )
        # Create the combo box
        self._bFilter_tool_bar = Qt.QToolBar(self)
        self._bFilter_tool_bar.addWidget(Qt.QLabel('TX Filter Select' + ": "))
        self._bFilter_combo_box = Qt.QComboBox()
        self._bFilter_tool_bar.addWidget(self._bFilter_combo_box)
        for _label in self._bFilter_labels:
            self._bFilter_combo_box.addItem(_label)
        self._bFilter_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._bFilter_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._bFilter_options.index(i)))
        self._bFilter_callback(self.bFilter)
        self._bFilter_combo_box.currentIndexChanged.connect(
            lambda i: self.set_bFilter(self._bFilter_options[i]))
        # Create the radio buttons
        self.top_grid_layout.addWidget(self._bFilter_tool_bar)
        self._agc_rate_range = Range(1e-4, 1e-3, 1e-4, 1e-4, 200)
        self._agc_rate_win = RangeWidget(self._agc_rate_range,
                                         self.set_agc_rate, 'AGC Decay Rate',
                                         "counter_slider", float)
        self.top_grid_layout.addWidget(self._agc_rate_win)
        self.wes_packet_tx_0 = wes_packet_tx(
            cw_len=cw_len,
            payload_len=payload_len,
            samp_rate=samp_rate,
        )
        self.wes_ber_0 = wes.ber(1, reset_ber)
        self.qtgui_number_sink_0_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                       qtgui.NUM_GRAPH_NONE, 1)
        self.qtgui_number_sink_0_0.set_update_time(0.10)
        self.qtgui_number_sink_0_0.set_title("# of Errors")

        labels = ['', '', '', '', '', '', '', '', '', '']
        units = ['', '', '', '', '', '', '', '', '', '']
        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_0.set_min(i, -1)
            self.qtgui_number_sink_0_0.set_max(i, 1)
            self.qtgui_number_sink_0_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0_0.set_label(i, labels[i])
            self.qtgui_number_sink_0_0.set_unit(i, units[i])
            self.qtgui_number_sink_0_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0_0.enable_autoscale(False)
        self._qtgui_number_sink_0_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_win)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_HORIZ, 1)
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("BER")

        labels = ['', '', '', '', '', '', '', '', '', '']
        units = ['', '', '', '', '', '', '', '', '', '']
        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, -1)
            self.qtgui_number_sink_0.set_max(i, 1)
            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)
        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(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(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.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.pulse_shape_hier_0 = pulse_shape_hier(
            bFilter=bFilter,
            rect_taps=(1, 1, 1, 1),
            roll_off=rolloff_,
            sps=sps,
        )
        self.iio_pluto_source_0 = iio.pluto_source('', int(fc),
                                                   int(samp_rate * 1e3),
                                                   20000000, buffer_size, True,
                                                   True, True, 'manual', 18,
                                                   '', True)
        self.iio_pluto_sink_0 = iio.pluto_sink('', int(fc),
                                               int(samp_rate * 1e3), 20000000,
                                               buffer_size, False, 10.0, '',
                                               True)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, 2 * pi / 200, pfb_filter, nfilts_pfb, int(nfilts_pfb / 2),
            0.5, 1)
        self.digital_packet_headerparser_b_0_0 = digital.packet_headerparser_b(
            header_formatter.formatter())
        self.digital_header_payload_demux_0 = digital.header_payload_demux(
            header_len, 1, 0, "packet_length", "corr_est", False,
            gr.sizeof_gr_complex, "rx_time", 1, (), 0)
        self.digital_glfsr_source_x_0 = digital.glfsr_source_b(
            int(pn_order), True, 0, 1)
        self.digital_diff_decoder_bb_0_0 = digital.diff_decoder_bb(2)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            2 * pi / 200, 2, False)
        self.digital_corr_est_cc_0 = digital.corr_est_cc(
            pn6_padded, 1, 64, 0.7, digital.THRESHOLD_ABSOLUTE)
        self.digital_constellation_decoder_cb_0_0_0_0_0 = digital.constellation_decoder_cb(
            const)
        self.digital_constellation_decoder_cb_0_0_0_0 = digital.constellation_decoder_cb(
            const)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN,
            np.sqrt(2) * np.sqrt(0.5 / np.power(10, snr_db / 10)), 0)
        self.analog_agc_xx_0 = analog.agc_cc(agc_rate, 1.0, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect(
            (self.digital_packet_headerparser_b_0_0, 'header_data'),
            (self.digital_header_payload_demux_0, 'header_data'))
        self.connect((self.analog_agc_xx_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.digital_constellation_decoder_cb_0_0_0_0_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.qtgui_const_sink_x_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.qtgui_const_sink_x_0, 1))
        self.connect((self.digital_constellation_decoder_cb_0_0_0_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0_0_0_0_0, 0),
                     (self.digital_diff_decoder_bb_0_0, 0))
        self.connect((self.digital_corr_est_cc_0, 0),
                     (self.digital_header_payload_demux_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.digital_packet_headerparser_b_0_0, 0))
        self.connect((self.digital_diff_decoder_bb_0_0, 0),
                     (self.wes_ber_0, 0))
        self.connect((self.digital_glfsr_source_x_0, 0), (self.wes_ber_0, 1))
        self.connect((self.digital_glfsr_source_x_0, 0),
                     (self.wes_packet_tx_0, 0))
        self.connect((self.digital_header_payload_demux_0, 1),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.digital_header_payload_demux_0, 0),
                     (self.digital_constellation_decoder_cb_0_0_0_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_corr_est_cc_0, 0))
        self.connect((self.iio_pluto_source_0, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.pulse_shape_hier_0, 0), (self.iio_pluto_sink_0, 0))
        self.connect((self.wes_ber_0, 0), (self.qtgui_number_sink_0, 0))
        self.connect((self.wes_ber_0, 1), (self.qtgui_number_sink_0_0, 0))
        self.connect((self.wes_packet_tx_0, 0), (self.pulse_shape_hier_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Waterfall_Painter")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Waterfall_Painter")
        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", "Paint_spectrum")

        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 = 32000

        ##################################################
        # Blocks
        ##################################################
        self.paint_paint_bc_0 = paint.paint_bc(346, 2, paint.EQUALIZATION_OFF,
                                               paint.INTERNAL, 1)
        self.paint_image_source_0 = paint.image_source(
            '/home/gnuradio/Pictures/f16_schem_01.gif', 1, 1, 0, 0, 1)
        self.iio_pluto_source_0 = iio.pluto_source('', int(2400000000),
                                                   int(2084000), int(20000000),
                                                   32768, True, True, True,
                                                   'manual', 30, '', True)
        self.iio_pluto_sink_0 = iio.pluto_sink('',
                                               int(2400000000), int(2084000),
                                               int(20000000), 32768, False,
                                               10.0, '', True)
        self.fosphor_qt_sink_c_0 = fosphor.qt_sink_c()
        self.fosphor_qt_sink_c_0.set_fft_window(firdes.WIN_BLACKMAN_hARRIS)
        self.fosphor_qt_sink_c_0.set_frequency_range(0, samp_rate)
        self._fosphor_qt_sink_c_0_win = sip.wrapinstance(
            self.fosphor_qt_sink_c_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._fosphor_qt_sink_c_0_win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.iio_pluto_source_0, 0),
                     (self.fosphor_qt_sink_c_0, 0))
        self.connect((self.paint_image_source_0, 0),
                     (self.paint_paint_bc_0, 0))
        self.connect((self.paint_paint_bc_0, 0), (self.iio_pluto_sink_0, 0))
Beispiel #20
0
    def __init__(self):
        gr.top_block.__init__(self, "Wifi Transceiver")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Wifi Transceiver")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "wifi_transceiver")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 0.75
        self.samp_rate = samp_rate = 10e6
        self.rx_gain = rx_gain = 0.75
        self.lo_offset = lo_offset = 0
        self.freq = freq = 3500000000
        self.encoding = encoding = 0
        self.chan_est = chan_est = 0

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_options = [5e6, 10e6, 20e6]
        self._samp_rate_labels = ["5 MHz", "10 MHz", "20 MHz"]
        self._samp_rate_tool_bar = Qt.QToolBar(self)
        self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate" + ": "))
        self._samp_rate_combo_box = Qt.QComboBox()
        self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box)
        for label in self._samp_rate_labels:
            self._samp_rate_combo_box.addItem(label)
        self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._samp_rate_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._samp_rate_options.index(i)))
        self._samp_rate_callback(self.samp_rate)
        self._samp_rate_combo_box.currentIndexChanged.connect(
            lambda i: self.set_samp_rate(self._samp_rate_options[i]))
        self.top_layout.addWidget(self._samp_rate_tool_bar)
        self._freq_options = [
            3500000000.0, 2412000000.0, 2417000000.0, 2422000000.0,
            2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0,
            2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0,
            2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0,
            5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0,
            5220000000.0, 5230000000.0, 5240000000.0, 5250000000.0,
            5260000000.0, 5270000000.0, 5280000000.0, 5290000000.0,
            5300000000.0, 5310000000.0, 5320000000.0, 5500000000.0,
            5510000000.0, 5520000000.0, 5530000000.0, 5540000000.0,
            5550000000.0, 5560000000.0, 5570000000.0, 5580000000.0,
            5590000000.0, 5600000000.0, 5610000000.0, 5620000000.0,
            5630000000.0, 5640000000.0, 5660000000.0, 5670000000.0,
            5680000000.0, 5690000000.0, 5700000000.0, 5710000000.0,
            5720000000.0, 5745000000.0, 5755000000.0, 5765000000.0,
            5775000000.0, 5785000000.0, 5795000000.0, 5805000000.0,
            5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0,
            5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0
        ]
        self._freq_labels = [
            ' 0|3.5G', '  1 | 2412.0 | 11g', '  2 | 2417.0 | 11g',
            '  3 | 2422.0 | 11g', '  4 | 2427.0 | 11g', '  5 | 2432.0 | 11g',
            '  6 | 2437.0 | 11g', '  7 | 2442.0 | 11g', '  8 | 2447.0 | 11g',
            '  9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g',
            ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g',
            ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a',
            ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a',
            ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a',
            ' 52 | 5260.0 | 11a', ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a',
            ' 58 | 5290.0 | 11a', ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a',
            ' 64 | 5320.0 | 11a', '100 | 5500.0 | 11a', '102 | 5510.0 | 11a',
            '104 | 5520.0 | 11a', '106 | 5530.0 | 11a', '108 | 5540.0 | 11a',
            '110 | 5550.0 | 11a', '112 | 5560.0 | 11a', '114 | 5570.0 | 11a',
            '116 | 5580.0 | 11a', '118 | 5590.0 | 11a', '120 | 5600.0 | 11a',
            '122 | 5610.0 | 11a', '124 | 5620.0 | 11a', '126 | 5630.0 | 11a',
            '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '134 | 5670.0 | 11a',
            '136 | 5680.0 | 11a', '138 | 5690.0 | 11a', '140 | 5700.0 | 11a',
            '142 | 5710.0 | 11a', '144 | 5720.0 | 11a',
            '149 | 5745.0 | 11a (SRD)', '151 | 5755.0 | 11a (SRD)',
            '153 | 5765.0 | 11a (SRD)', '155 | 5775.0 | 11a (SRD)',
            '157 | 5785.0 | 11a (SRD)', '159 | 5795.0 | 11a (SRD)',
            '161 | 5805.0 | 11a (SRD)', '165 | 5825.0 | 11a (SRD)',
            '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p',
            '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p',
            '184 | 5920.0 | 11p'
        ]
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel("freq" + ": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels:
            self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._freq_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
            lambda i: self.set_freq(self._freq_options[i]))
        self.top_layout.addWidget(self._freq_tool_bar)
        self._encoding_options = [0, 1, 2, 3, 4, 5, 6, 7]
        self._encoding_labels = [
            "BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2",
            "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"
        ]
        self._encoding_group_box = Qt.QGroupBox("encoding")
        self._encoding_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._encoding_button_group = variable_chooser_button_group()
        self._encoding_group_box.setLayout(self._encoding_box)
        for i, label in enumerate(self._encoding_labels):
            radio_button = Qt.QRadioButton(label)
            self._encoding_box.addWidget(radio_button)
            self._encoding_button_group.addButton(radio_button, i)
        self._encoding_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._encoding_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._encoding_options.index(i)))
        self._encoding_callback(self.encoding)
        self._encoding_button_group.buttonClicked[int].connect(
            lambda i: self.set_encoding(self._encoding_options[i]))
        self.top_layout.addWidget(self._encoding_group_box)
        self._chan_est_options = [
            ieee802_11.LS, ieee802_11.LMS, ieee802_11.STA, ieee802_11.COMB
        ]
        self._chan_est_labels = ["LS", "LMS", "STA", "Linear Comb"]
        self._chan_est_group_box = Qt.QGroupBox("chan_est")
        self._chan_est_box = Qt.QHBoxLayout()

        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)

            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)

        self._chan_est_button_group = variable_chooser_button_group()
        self._chan_est_group_box.setLayout(self._chan_est_box)
        for i, label in enumerate(self._chan_est_labels):
            radio_button = Qt.QRadioButton(label)
            self._chan_est_box.addWidget(radio_button)
            self._chan_est_button_group.addButton(radio_button, i)
        self._chan_est_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._chan_est_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._chan_est_options.index(i)))
        self._chan_est_callback(self.chan_est)
        self._chan_est_button_group.buttonClicked[int].connect(
            lambda i: self.set_chan_est(self._chan_est_options[i]))
        self.top_layout.addWidget(self._chan_est_group_box)
        self.wifi_phy_hier_0 = wifi_phy_hier(
            bandwidth=samp_rate,
            chan_est=chan_est,
            encoding=encoding,
            frequency=freq,
            sensitivity=0.56,
        )
        self._tx_gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        "tx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._tx_gain_win)
        self._rx_gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        "rx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._rx_gain_win)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            48 * 10,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.pluto_source_0 = iio.pluto_source('', 3500000000, 10000000,
                                               20000000, 0x8000, True, True,
                                               True, "manual", 64.0, '', True)
        self.pluto_sink_0 = iio.pluto_sink('', 3500000000, 10000000, 20000000,
                                           0x8000, False, 10.0, '', True)
        self._lo_offset_options = (
            0,
            6e6,
            11e6,
        )
        self._lo_offset_labels = (
            str(self._lo_offset_options[0]),
            str(self._lo_offset_options[1]),
            str(self._lo_offset_options[2]),
        )
        self._lo_offset_tool_bar = Qt.QToolBar(self)
        self._lo_offset_tool_bar.addWidget(Qt.QLabel("lo_offset" + ": "))
        self._lo_offset_combo_box = Qt.QComboBox()
        self._lo_offset_tool_bar.addWidget(self._lo_offset_combo_box)
        for label in self._lo_offset_labels:
            self._lo_offset_combo_box.addItem(label)
        self._lo_offset_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._lo_offset_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._lo_offset_options.index(i)))
        self._lo_offset_callback(self.lo_offset)
        self._lo_offset_combo_box.currentIndexChanged.connect(
            lambda i: self.set_lo_offset(self._lo_offset_options[i]))
        self.top_layout.addWidget(self._lo_offset_tool_bar)
        self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(False, True)
        self.ieee802_11_mac_0 = ieee802_11.mac(
            ([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]),
            ([0x30, 0x14, 0x4a, 0xe6, 0x46, 0xe4]),
            ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]))
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(False)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000,
                                                 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(
            blocks.complex_t, 'packet_len')
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.6, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   '/tmp/wifi.pcap', True)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to wifi'),
                         (self.ieee802_11_mac_0, 'app in'))
        self.msg_connect((self.ieee802_11_mac_0, 'phy out'),
                         (self.wifi_phy_hier_0, 'mac_in'))
        self.msg_connect((self.wifi_phy_hier_0, 'carrier'),
                         (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.ieee802_11_ether_encap_0, 'from wifi'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.ieee802_11_mac_0, 'phy in'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.ieee802_11_parse_mac_0, 'in'))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.foo_packet_pad2_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.foo_packet_pad2_0, 0), (self.pluto_sink_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.pluto_source_0, 0), (self.wifi_phy_hier_0, 0))
        self.connect((self.wifi_phy_hier_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))