コード例 #1
0
 def test_sub_cc(self):
     src1_data = (1,  2, 3, 4, 5)
     src2_data = (8, -3, 4, 8, 2)
     expected_result = (-7, 5, -1, -4, 3)
     op = blocks.sub_cc()
     self.help_cc((src1_data, src2_data),
                   expected_result, op)
コード例 #2
0
 def test_sub_cc(self):
     src1_data = (1,  2, 3, 4, 5)
     src2_data = (8, -3, 4, 8, 2)
     expected_result = (-7, 5, -1, -4, 3)
     op = blocks.sub_cc()
     self.help_cc((src1_data, src2_data),
                   expected_result, op)
コード例 #3
0
 def test_sub_cc(self):
     src1_data = [1,  2, 3, 4, 5]
     src2_data = [8, -3, 4, 8, 2]
     expected_result = [-7, 5, -1, -4, 3]
     op = blocks.sub_cc()
     self.help_cc((src1_data, src2_data),
                   expected_result, op)
コード例 #4
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1000000

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
            self.GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=True,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.blocks_sub_xx_0 = blocks.sub_cc(1)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_sig_source_x_0_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_SIN_WAVE, 50000, 1, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 50000, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_SQR_WAVE, 5000, 1, 0)
        self.analog_const_source_x_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_sub_xx_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_0_0_0, 0),
                     (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.blocks_add_xx_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.blocks_multiply_xx_0_0, 0))
コード例 #5
0
    def __init__(self):
        gr.hier_block2.__init__(
            self,
            "BER Computation",
            gr.io_signaturev(
                2, 2, [gr.sizeof_gr_complex * 1, gr.sizeof_gr_complex * 1]),
            gr.io_signaturev(2, 2, [gr.sizeof_float * 1, gr.sizeof_float * 1]),
        )

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self.iir_filter_xxx_0_0 = filter.iir_filter_ffd([1], [1, 1], True)
        self.iir_filter_xxx_0 = filter.iir_filter_ffd([1], [1, 1], True)
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1,
                                                 False)
        self.blocks_tag_gate_0.set_single_key("")
        self.blocks_sub_xx_0 = blocks.sub_cc(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_cc(0)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(0.5)
        self.blocks_max_xx_0_0 = blocks.max_ff(1, 1)
        self.blocks_max_xx_0 = blocks.max_ff(1, 1)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_cc(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_complex_to_mag_0_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.iir_filter_xxx_0, 0))
        self.connect((self.blocks_complex_to_mag_0_0, 0),
                     (self.iir_filter_xxx_0_0, 0))
        self.connect((self.blocks_divide_xx_0, 0), (self, 0))
        self.connect((self.blocks_max_xx_0, 0), (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_max_xx_0_0, 0), (self.blocks_divide_xx_0, 0))
        self.connect((self.blocks_max_xx_0_0, 0), (self, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.blocks_tag_gate_0, 0))
        self.connect((self.blocks_tag_gate_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_tag_gate_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.iir_filter_xxx_0, 0), (self.blocks_max_xx_0_0, 0))
        self.connect((self.iir_filter_xxx_0_0, 0), (self.blocks_max_xx_0, 0))
        self.connect((self, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self, 1), (self.blocks_sub_xx_0, 1))
コード例 #6
0
def test_sub_cc():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    sub = blocks.sub_cc()
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect((src, 0), (sub, 0))
    top.connect((src, 0), (sub, 1))
    top.connect(sub, probe)

    return top, probe
コード例 #7
0
def test_sub_cc():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    sub = blocks.sub_cc()
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect((src, 0), (sub, 0))
    top.connect((src, 0), (sub, 1))
    top.connect(sub, probe)

    return top, probe
コード例 #8
0
    def test_sub_cc1(self):
        src1_data = (1, 2, 3, 4, 5)
        expected_result = (1, 2, 3, 4, 5)

        src = blocks.vector_source_c(src1_data)
        op = blocks.sub_cc()
        dst = blocks.vector_sink_c()
        self.tb.connect(src, op, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(expected_result, result_data)
コード例 #9
0
    def test_sub_cc1(self):
        src1_data = (1, 2, 3, 4, 5)
        expected_result = (1, 2, 3, 4, 5)

        src = blocks.vector_source_c(src1_data)
        op = blocks.sub_cc()
        dst = blocks.vector_sink_c()
        self.tb.connect(src, op, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(expected_result, result_data)
コード例 #10
0
    def __init__(self):
        gr.top_block.__init__(self, "sic_mpsk_sim")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("sic_mpsk_sim")
        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", "sic_mpsk_sim")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.snr_db = snr_db = 10
        self.const_type = const_type = 1
        self.variable_qtgui_label_0 = variable_qtgui_label_0 = {
            0: 'BPSK',
            1: 'QPSK',
            2: '8-PSK'
        }[const_type] + " - Change const_type for different constellation types!"
        self.noisevar = noisevar = 10**(-snr_db / 10)
        self.const = const = (digital.constellation_bpsk(),
                              digital.constellation_qpsk(),
                              digital.constellation_8psk())
        self.block = block = 1000
        self.alpha = alpha = .1
        self.R = R = 100e3

        ##################################################
        # Blocks
        ##################################################
        self._alpha_range = Range(0, 1, .01, .1, 200)
        self._alpha_win = RangeWidget(self._alpha_range, self.set_alpha,
                                      'Alpha (P1/P)', "counter_slider", float)
        self.top_layout.addWidget(self._alpha_win)
        self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self)

        if None:
            self._variable_qtgui_label_0_formatter = None
        else:
            self._variable_qtgui_label_0_formatter = lambda x: x

        self._variable_qtgui_label_0_tool_bar.addWidget(
            Qt.QLabel('Constellation Type' + ": "))
        self._variable_qtgui_label_0_label = Qt.QLabel(
            str(
                self._variable_qtgui_label_0_formatter(
                    self.variable_qtgui_label_0)))
        self._variable_qtgui_label_0_tool_bar.addWidget(
            self._variable_qtgui_label_0_label)
        self.top_layout.addWidget(self._variable_qtgui_label_0_tool_bar)

        self._snr_db_range = Range(0, 20, 1, 10, 200)
        self._snr_db_win = RangeWidget(self._snr_db_range, self.set_snr_db,
                                       'P/sigma^2 (dB)', "counter_slider",
                                       float)
        self.top_layout.addWidget(self._snr_db_win)
        self.qtgui_number_sink_0_0_0_0 = qtgui.number_sink(
            gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1)
        self.qtgui_number_sink_0_0_0_0.set_update_time(0.10)
        self.qtgui_number_sink_0_0_0_0.set_title(
            'BER 1 (after cancelling user 2)')

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

        self.qtgui_number_sink_0_0_0_0.enable_autoscale(False)
        self._qtgui_number_sink_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_win, 1,
                                       0, 1, 1)
        self.qtgui_number_sink_0_0_0 = qtgui.number_sink(
            gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1)
        self.qtgui_number_sink_0_0_0.set_update_time(0.10)
        self.qtgui_number_sink_0_0_0.set_title(
            "BER 2 (after cancelling user 1)")

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

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

        labels = ['BER', '', '', '', '', '', '', '', '', '']
        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 xrange(1):
            self.qtgui_number_sink_0_0.set_min(i, 0)
            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, 0, 1,
                                       1, 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("BER1 (Without Cancellation)")

        labels = ['BER', '', '', '', '', '', '', '', '', '']
        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 xrange(1):
            self.qtgui_number_sink_0.set_min(i, 0)
            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, 0, 0, 1,
                                       1)
        self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c(
            1024,  #size
            "Constellation",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                     qtgui.TRIG_SLOPE_POS, 0.0,
                                                     0, "")
        self.qtgui_const_sink_x_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0.disable_legend()

        labels = [
            "Constellation: " + str(const[const_type].arity()) + "-PSK", '',
            '', '', '', '', '', '', '', ''
        ]
        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 = [0.6, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0_0.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_layout.addWidget(self._qtgui_const_sink_x_0_0_win)
        self.digital_constellation_decoder_cb_0_0_0_0 = digital.constellation_decoder_cb(
            const[const_type].base())
        self.digital_constellation_decoder_cb_0_0_0 = digital.constellation_decoder_cb(
            const[const_type].base())
        self.digital_constellation_decoder_cb_0_0 = digital.constellation_decoder_cb(
            const[const_type].base())
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            const[const_type].base())
        self.digital_chunks_to_symbols_xx_2 = digital.chunks_to_symbols_bc(
            (const[const_type].points()), 1)
        self.digital_chunks_to_symbols_xx_1_0 = digital.chunks_to_symbols_bc(
            (const[const_type].points()), 1)
        self.digital_chunks_to_symbols_xx_1 = digital.chunks_to_symbols_bc(
            (const[const_type].points()), 1)
        self.digital_chunks_to_symbols_xx = digital.chunks_to_symbols_bc(
            (const[const_type].points()), 1)
        self.blocks_throttle_0_1 = blocks.throttle(gr.sizeof_char * 1, R, True)
        self.blocks_sub_xx_2_0 = blocks.sub_cc(1)
        self.blocks_sub_xx_2 = blocks.sub_cc(1)
        self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_vcc(
            ((1 - alpha)**0.5, ))
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vcc(
            (alpha**0.5, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc(
            ((1 - alpha)**0.5, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(
            (alpha**0.5, ))
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.blks2_error_rate_0_0_0_0 = grc_blks2.error_rate(
            type='BER',
            win_size=block * 100,
            bits_per_symbol=2,
        )
        self.blks2_error_rate_0_0_0 = grc_blks2.error_rate(
            type='BER',
            win_size=block * 100,
            bits_per_symbol=2,
        )
        self.blks2_error_rate_0_0 = grc_blks2.error_rate(
            type='BER',
            win_size=block * 100,
            bits_per_symbol=2,
        )
        self.blks2_error_rate_0 = grc_blks2.error_rate(
            type='BER',
            win_size=block * 100,
            bits_per_symbol=2,
        )
        self.analog_random_source_x_1 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, const[const_type].arity(),
                                          block)), True)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, const[const_type].arity(),
                                          block)), True)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, noisevar, -42)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_0, 2))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blks2_error_rate_0, 0))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blks2_error_rate_0_0_0_0, 0))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blocks_throttle_0_1, 0))
        self.connect((self.analog_random_source_x_1, 0),
                     (self.blks2_error_rate_0_0, 0))
        self.connect((self.analog_random_source_x_1, 0),
                     (self.blks2_error_rate_0_0_0, 0))
        self.connect((self.analog_random_source_x_1, 0),
                     (self.digital_chunks_to_symbols_xx_2, 0))
        self.connect((self.blks2_error_rate_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blks2_error_rate_0_0, 0),
                     (self.qtgui_number_sink_0_0, 0))
        self.connect((self.blks2_error_rate_0_0_0, 0),
                     (self.qtgui_number_sink_0_0_0, 0))
        self.connect((self.blks2_error_rate_0_0_0_0, 0),
                     (self.qtgui_number_sink_0_0_0_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_sub_xx_2, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_sub_xx_2_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.digital_constellation_decoder_cb_0_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.qtgui_const_sink_x_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_add_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_sub_xx_2, 1))
        self.connect((self.blocks_multiply_const_vxx_2_0, 0),
                     (self.blocks_sub_xx_2_0, 1))
        self.connect((self.blocks_sub_xx_2, 0),
                     (self.digital_constellation_decoder_cb_0_0_0, 0))
        self.connect((self.blocks_sub_xx_2_0, 0),
                     (self.digital_constellation_decoder_cb_0_0_0_0, 0))
        self.connect((self.blocks_throttle_0_1, 0),
                     (self.digital_chunks_to_symbols_xx, 0))
        self.connect((self.digital_chunks_to_symbols_xx, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_1, 0),
                     (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.digital_chunks_to_symbols_xx_1_0, 0),
                     (self.blocks_multiply_const_vxx_2_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_2, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.blks2_error_rate_0, 1))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_chunks_to_symbols_xx_1, 0))
        self.connect((self.digital_constellation_decoder_cb_0_0, 0),
                     (self.blks2_error_rate_0_0, 1))
        self.connect((self.digital_constellation_decoder_cb_0_0, 0),
                     (self.digital_chunks_to_symbols_xx_1_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0_0_0, 0),
                     (self.blks2_error_rate_0_0_0, 1))
        self.connect((self.digital_constellation_decoder_cb_0_0_0_0, 0),
                     (self.blks2_error_rate_0_0_0_0, 1))
コード例 #11
0
    def __init__(self):
        gr.top_block.__init__(self, "Pal Transmit")

        ##################################################
        # Variables
        ##################################################
        self.samp_visual = samp_visual = 702
        self.samp_rate = samp_rate = samp_visual / (52e-6)
        self.samp_line = samp_line = int((64e-6) * samp_rate)
        self.sub_freq = sub_freq = 4433618.75
        self.samp_visual_delay = samp_visual_delay = int(2.5 / 64 * samp_line)
        self.samp_h_sync = samp_h_sync = int(4.7 / 64 * samp_line)
        self.samp_burst_delay = samp_burst_delay = int(0.9 / 64 * samp_line)
        self.samp_burst = samp_burst = int(2.25 / 64 * samp_line)
        self.rf_gain = rf_gain = 14
        self.lines_visual = lines_visual = 576
        self.lines_half_frame = lines_half_frame = 305
        self.level_blank = level_blank = 0.285
        self.level_black = level_black = 0.339
        self.if_gain = if_gain = 48

        ##################################################
        # Blocks
        ##################################################
        self.stdin = blocks.file_source(gr.sizeof_char * 1, '/dev/stdin',
                                        False)
        self.stdin.set_begin_tag(pmt.PMT_NIL)
        self.short_sync_pulse_0_3_0_1 = short_sync_pulse(
            samp_half_line=samp_line / 2, )
        self.short_sync_pulse_0_3_0_0_0 = short_sync_pulse(
            samp_half_line=samp_line / 2, )
        self.short_sync_pulse_0_3_0_0 = short_sync_pulse(
            samp_half_line=samp_line / 2, )
        self.short_sync_pulse_0_3_0 = short_sync_pulse(
            samp_half_line=samp_line / 2, )
        self.osmosdr_sink_0_0 = osmosdr.sink(args="numchan=" + str(1) + " " +
                                             'hackrf=0')
        self.osmosdr_sink_0_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0_0.set_center_freq(55e6, 0)
        self.osmosdr_sink_0_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0_0.set_gain(rf_gain, 0)
        self.osmosdr_sink_0_0.set_if_gain(if_gain, 0)
        self.osmosdr_sink_0_0.set_bb_gain(24, 0)
        self.osmosdr_sink_0_0.set_antenna('', 0)
        self.osmosdr_sink_0_0.set_bandwidth(0, 0)

        self.long_sync_pulse_0_0 = long_sync_pulse(samp_line=samp_line / 2, )
        self.long_sync_pulse_0 = long_sync_pulse(samp_line=samp_line / 2, )
        self.blocks_vector_to_stream_2_1_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, samp_visual)
        self.blocks_vector_to_stream_2_1 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, samp_visual)
        self.blocks_vector_to_stream_2_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, lines_half_frame * samp_visual)
        self.blocks_vector_to_stream_2 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, lines_half_frame * samp_visual)
        self.blocks_vector_to_stream_1_1 = blocks.vector_to_stream(
            gr.sizeof_float * samp_visual, 3 * lines_visual)
        self.blocks_vector_to_stream_1_0_1 = blocks.vector_to_stream(
            gr.sizeof_float * 1, lines_half_frame * samp_visual)
        self.blocks_vector_to_stream_1_0 = blocks.vector_to_stream(
            gr.sizeof_float * 1, lines_half_frame * samp_visual)
        self.blocks_vector_to_stream_1 = blocks.vector_to_stream(
            gr.sizeof_float * samp_visual, 3 * lines_visual)
        self.blocks_vector_to_stream_0_1 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, samp_burst)
        self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, samp_line)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, samp_line / 2)
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.blocks_sub_xx_0 = blocks.sub_cc(1)
        self.blocks_stream_to_vector_1_0_0_1_1 = blocks.stream_to_vector(
            gr.sizeof_float * 1, samp_visual)
        self.blocks_stream_to_vector_1_0_0_1_0_0 = blocks.stream_to_vector(
            gr.sizeof_float * 1, samp_visual)
        self.blocks_stream_to_vector_1_0_0_1_0 = blocks.stream_to_vector(
            gr.sizeof_float * 1, samp_visual)
        self.blocks_stream_to_vector_1_0_0_1 = blocks.stream_to_vector(
            gr.sizeof_float * 1, samp_visual)
        self.blocks_stream_to_vector_1_0_0_0_0 = blocks.stream_to_vector(
            gr.sizeof_float * samp_visual, lines_half_frame)
        self.blocks_stream_to_vector_1_0_0_0 = blocks.stream_to_vector(
            gr.sizeof_float * samp_visual, lines_half_frame)
        self.blocks_stream_to_vector_1_0_0 = blocks.stream_to_vector(
            gr.sizeof_float * 1, 3 * samp_visual * lines_visual)
        self.blocks_stream_to_vector_0_1_1_2_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, samp_burst)
        self.blocks_stream_to_vector_0_1_1_2 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, samp_burst)
        self.blocks_stream_to_vector_0_1_1_1 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, samp_burst)
        self.blocks_stream_to_vector_0_1_1_0_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, samp_burst)
        self.blocks_stream_to_vector_0_1_1_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, samp_burst)
        self.blocks_stream_to_vector_0_1_1 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, samp_burst)
        self.blocks_stream_to_vector_0_1_0_0_0_0_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, samp_visual)
        self.blocks_stream_to_vector_0_1_0_0_0_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, samp_visual)
        self.blocks_stream_to_vector_0_1_0_0_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, samp_visual)
        self.blocks_stream_to_vector_0_1_0_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, samp_visual)
        self.blocks_stream_to_vector_0_0_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, samp_line)
        self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, samp_line / 2)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, samp_line / 2)
        self.blocks_stream_to_streams_2 = blocks.stream_to_streams(
            gr.sizeof_gr_complex * samp_visual, 2)
        self.blocks_stream_to_streams_1 = blocks.stream_to_streams(
            gr.sizeof_float * samp_visual * lines_visual * 3, 2)
        self.blocks_stream_to_streams_0_0_0_0 = blocks.stream_to_streams(
            gr.sizeof_float * samp_visual, 2)
        self.blocks_stream_to_streams_0_0_0 = blocks.stream_to_streams(
            gr.sizeof_float * samp_visual, 2)
        self.blocks_stream_to_streams_0_0 = blocks.stream_to_streams(
            gr.sizeof_float * lines_half_frame * samp_visual, 3)
        self.blocks_stream_to_streams_0 = blocks.stream_to_streams(
            gr.sizeof_float * lines_half_frame * samp_visual, 3)
        self.blocks_stream_mux_4 = blocks.stream_mux(
            gr.sizeof_gr_complex * samp_burst, (8, 305, 7, 305))
        self.blocks_stream_mux_3_0 = blocks.stream_mux(
            gr.sizeof_float * 702, (9, lines_visual / 2, 8))
        self.blocks_stream_mux_3 = blocks.stream_mux(gr.sizeof_float * 702,
                                                     (8, lines_visual / 2, 9))
        self.blocks_stream_mux_2_1 = blocks.stream_mux(
            gr.sizeof_gr_complex * 1,
            (samp_h_sync + samp_burst_delay, samp_burst, samp_visual_delay,
             samp_visual, samp_line -
             (samp_h_sync + samp_burst_delay + samp_burst + samp_visual_delay +
              samp_visual)))
        self.blocks_stream_mux_2_0 = blocks.stream_mux(
            gr.sizeof_gr_complex * 1,
            (samp_h_sync, samp_burst_delay + samp_burst + samp_visual_delay,
             samp_visual, samp_line -
             (samp_h_sync + samp_burst_delay + samp_burst + samp_visual_delay +
              samp_visual)))
        self.blocks_stream_mux_2 = blocks.stream_mux(
            gr.sizeof_gr_complex * 1,
            (samp_h_sync, samp_burst_delay + samp_burst + samp_visual_delay,
             samp_visual, samp_line -
             (samp_h_sync + samp_burst_delay + samp_burst + samp_visual_delay +
              samp_visual)))
        self.blocks_stream_mux_1_1_0 = blocks.stream_mux(
            gr.sizeof_gr_complex * samp_visual, (8, 305, 7, 305))
        self.blocks_stream_mux_1_0_0_0_1 = blocks.stream_mux(
            gr.sizeof_gr_complex * samp_burst, (1, 1))
        self.blocks_stream_mux_1 = blocks.stream_mux(
            gr.sizeof_gr_complex * samp_line / 2,
            (6, 5, 5, 2 * 305, 5, 5, 4, 2 * 305))
        self.blocks_stream_mux_0 = blocks.stream_mux(
            gr.sizeof_gr_complex * 1, (samp_visual, samp_visual))
        self.blocks_null_sink_1_0 = blocks.null_sink(gr.sizeof_float *
                                                     samp_visual)
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_float *
                                                   samp_visual)
        self.blocks_multiply_xx_2 = blocks.multiply_vcc(samp_burst)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (0.00390625 / 2, ))
        self.blocks_float_to_complex_1_0 = blocks.float_to_complex(
            lines_half_frame * samp_visual)
        self.blocks_float_to_complex_1 = blocks.float_to_complex(
            lines_half_frame * samp_visual)
        self.blocks_float_to_complex_0_0 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.blocks_add_const_vxx_0_0 = blocks.add_const_vcc((level_black, ))
        self.blocks_add_const_vxx_0 = blocks.add_const_vcc((level_black, ))
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 4433618.75, 0.68, 0)
        self.analog_const_source_x_3_0_0_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, 1)
        self.analog_const_source_x_3_0_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, 1)
        self.analog_const_source_x_3_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_3 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_0_0_3_2 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_0_0_3_1_1_1 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_0_0_3_1_1_0_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_0_0_3_1_1_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_0_0_3_1_1 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_0_0_3_1_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_0_0_3_1 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_0_0_3_0_1 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, level_blank)
        self.analog_const_source_x_0_0_3_0_0_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, level_blank)
        self.analog_const_source_x_0_0_3_0_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, level_blank)
        self.analog_const_source_x_0_0_3_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, level_blank)
        self.analog_const_source_x_0_0_3 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_0_0_2_0_0_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, (-1 + 1j) / sqrt(2))
        self.analog_const_source_x_0_0_1_0_0_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, (-1 - 1j) / sqrt(2))
        self.analog_const_source_x_0_0_0_0_0_1_0_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_0_0_0_0_0_1_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_0_0_0_0_0_1 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_0_0_0_0_0_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_0_0_0_0_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_sub_xx_0, 0))
        self.connect((self.analog_const_source_x_0_0_0_0_0, 0),
                     (self.blocks_stream_to_vector_0_1_0_0_0_0, 0))
        self.connect((self.analog_const_source_x_0_0_0_0_0_0, 0),
                     (self.blocks_stream_to_vector_0_1_0_0_0_0_0, 0))
        self.connect((self.analog_const_source_x_0_0_0_0_0_1, 0),
                     (self.blocks_stream_mux_2_1, 0))
        self.connect((self.analog_const_source_x_0_0_0_0_0_1_0, 0),
                     (self.blocks_stream_mux_2_1, 4))
        self.connect((self.analog_const_source_x_0_0_0_0_0_1_0_0, 0),
                     (self.blocks_stream_mux_2_1, 2))
        self.connect((self.analog_const_source_x_0_0_1_0_0_0, 0),
                     (self.blocks_stream_to_vector_0_1_1_2_0, 0))
        self.connect((self.analog_const_source_x_0_0_2_0_0_0, 0),
                     (self.blocks_stream_to_vector_0_1_1_2, 0))
        self.connect((self.analog_const_source_x_0_0_3, 0),
                     (self.blocks_stream_mux_2, 0))
        self.connect((self.analog_const_source_x_0_0_3_0, 0),
                     (self.blocks_stream_mux_2, 1))
        self.connect((self.analog_const_source_x_0_0_3_0_0, 0),
                     (self.blocks_stream_mux_2, 3))
        self.connect((self.analog_const_source_x_0_0_3_0_0_0, 0),
                     (self.blocks_stream_mux_2_0, 3))
        self.connect((self.analog_const_source_x_0_0_3_0_1, 0),
                     (self.blocks_stream_mux_2_0, 1))
        self.connect((self.analog_const_source_x_0_0_3_1, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.analog_const_source_x_0_0_3_1_0, 0),
                     (self.blocks_float_to_complex_0_0, 1))
        self.connect((self.analog_const_source_x_0_0_3_1_1, 0),
                     (self.blocks_stream_to_vector_1_0_0_1, 0))
        self.connect((self.analog_const_source_x_0_0_3_1_1_0, 0),
                     (self.blocks_stream_to_vector_1_0_0_1_0, 0))
        self.connect((self.analog_const_source_x_0_0_3_1_1_0_0, 0),
                     (self.blocks_stream_to_vector_1_0_0_1_0_0, 0))
        self.connect((self.analog_const_source_x_0_0_3_1_1_1, 0),
                     (self.blocks_stream_to_vector_1_0_0_1_1, 0))
        self.connect((self.analog_const_source_x_0_0_3_2, 0),
                     (self.blocks_stream_mux_2_0, 0))
        self.connect((self.analog_const_source_x_3, 0),
                     (self.blocks_stream_to_vector_0_1_1, 0))
        self.connect((self.analog_const_source_x_3_0, 0),
                     (self.blocks_stream_to_vector_0_1_1_0, 0))
        self.connect((self.analog_const_source_x_3_0_0, 0),
                     (self.blocks_stream_to_vector_0_1_1_1, 0))
        self.connect((self.analog_const_source_x_3_0_0_0, 0),
                     (self.blocks_stream_to_vector_0_1_1_0_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_stream_mux_2, 2))
        self.connect((self.blocks_add_const_vxx_0_0, 0),
                     (self.blocks_stream_mux_2_0, 2))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_stream_to_vector_0_0_0, 0))
        self.connect((self.blocks_conjugate_cc_0, 0),
                     (self.blocks_stream_mux_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_float_to_complex_0_0, 0),
                     (self.blocks_add_const_vxx_0_0, 0))
        self.connect((self.blocks_float_to_complex_1, 0),
                     (self.blocks_vector_to_stream_2, 0))
        self.connect((self.blocks_float_to_complex_1_0, 0),
                     (self.blocks_vector_to_stream_2_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_stream_to_vector_1_0_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_xx_2, 0),
                     (self.blocks_vector_to_stream_0_1, 0))
        self.connect((self.blocks_stream_mux_0, 0),
                     (self.blocks_stream_mux_2_1, 3))
        self.connect((self.blocks_stream_mux_1, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_stream_mux_1_0_0_0_1, 0),
                     (self.blocks_multiply_xx_2, 0))
        self.connect((self.blocks_stream_mux_1_1_0, 0),
                     (self.blocks_stream_to_streams_2, 0))
        self.connect((self.blocks_stream_mux_2, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_stream_mux_2_0, 0),
                     (self.blocks_stream_to_vector_0_0, 0))
        self.connect((self.blocks_stream_mux_2_1, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_stream_mux_3, 0),
                     (self.blocks_stream_to_vector_1_0_0_0, 0))
        self.connect((self.blocks_stream_mux_3_0, 0),
                     (self.blocks_stream_to_vector_1_0_0_0_0, 0))
        self.connect((self.blocks_stream_mux_4, 0),
                     (self.blocks_multiply_xx_2, 1))
        self.connect((self.blocks_stream_to_streams_0, 1),
                     (self.blocks_float_to_complex_1, 0))
        self.connect((self.blocks_stream_to_streams_0, 2),
                     (self.blocks_float_to_complex_1, 1))
        self.connect((self.blocks_stream_to_streams_0, 0),
                     (self.blocks_vector_to_stream_1_0, 0))
        self.connect((self.blocks_stream_to_streams_0_0, 1),
                     (self.blocks_float_to_complex_1_0, 0))
        self.connect((self.blocks_stream_to_streams_0_0, 2),
                     (self.blocks_float_to_complex_1_0, 1))
        self.connect((self.blocks_stream_to_streams_0_0, 0),
                     (self.blocks_vector_to_stream_1_0_1, 0))
        self.connect((self.blocks_stream_to_streams_0_0_0, 1),
                     (self.blocks_null_sink_1, 0))
        self.connect((self.blocks_stream_to_streams_0_0_0, 0),
                     (self.blocks_stream_mux_3, 1))
        self.connect((self.blocks_stream_to_streams_0_0_0_0, 0),
                     (self.blocks_null_sink_1_0, 0))
        self.connect((self.blocks_stream_to_streams_0_0_0_0, 1),
                     (self.blocks_stream_mux_3_0, 1))
        self.connect((self.blocks_stream_to_streams_1, 0),
                     (self.blocks_vector_to_stream_1, 0))
        self.connect((self.blocks_stream_to_streams_1, 1),
                     (self.blocks_vector_to_stream_1_1, 0))
        self.connect((self.blocks_stream_to_streams_2, 1),
                     (self.blocks_vector_to_stream_2_1, 0))
        self.connect((self.blocks_stream_to_streams_2, 0),
                     (self.blocks_vector_to_stream_2_1_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0),
                     (self.blocks_stream_mux_1, 3))
        self.connect((self.blocks_stream_to_vector_0_0, 0),
                     (self.blocks_stream_mux_1, 7))
        self.connect((self.blocks_stream_to_vector_0_0_0, 0),
                     (self.blocks_vector_to_stream_0_0, 0))
        self.connect((self.blocks_stream_to_vector_0_1_0_0, 0),
                     (self.blocks_stream_mux_1_1_0, 3))
        self.connect((self.blocks_stream_to_vector_0_1_0_0_0, 0),
                     (self.blocks_stream_mux_1_1_0, 1))
        self.connect((self.blocks_stream_to_vector_0_1_0_0_0_0, 0),
                     (self.blocks_stream_mux_1_1_0, 0))
        self.connect((self.blocks_stream_to_vector_0_1_0_0_0_0_0, 0),
                     (self.blocks_stream_mux_1_1_0, 2))
        self.connect((self.blocks_stream_to_vector_0_1_1, 0),
                     (self.blocks_stream_mux_4, 0))
        self.connect((self.blocks_stream_to_vector_0_1_1_0, 0),
                     (self.blocks_stream_mux_4, 2))
        self.connect((self.blocks_stream_to_vector_0_1_1_0_0, 0),
                     (self.blocks_stream_mux_4, 3))
        self.connect((self.blocks_stream_to_vector_0_1_1_1, 0),
                     (self.blocks_stream_mux_4, 1))
        self.connect((self.blocks_stream_to_vector_0_1_1_2, 0),
                     (self.blocks_stream_mux_1_0_0_0_1, 0))
        self.connect((self.blocks_stream_to_vector_0_1_1_2_0, 0),
                     (self.blocks_stream_mux_1_0_0_0_1, 1))
        self.connect((self.blocks_stream_to_vector_1_0_0, 0),
                     (self.blocks_stream_to_streams_1, 0))
        self.connect((self.blocks_stream_to_vector_1_0_0_0, 0),
                     (self.blocks_stream_to_streams_0, 0))
        self.connect((self.blocks_stream_to_vector_1_0_0_0_0, 0),
                     (self.blocks_stream_to_streams_0_0, 0))
        self.connect((self.blocks_stream_to_vector_1_0_0_1, 0),
                     (self.blocks_stream_mux_3, 0))
        self.connect((self.blocks_stream_to_vector_1_0_0_1_0, 0),
                     (self.blocks_stream_mux_3, 2))
        self.connect((self.blocks_stream_to_vector_1_0_0_1_0_0, 0),
                     (self.blocks_stream_mux_3_0, 2))
        self.connect((self.blocks_stream_to_vector_1_0_0_1_1, 0),
                     (self.blocks_stream_mux_3_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_uchar_to_float_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_vector_to_stream_0_0, 0),
                     (self.osmosdr_sink_0_0, 0))
        self.connect((self.blocks_vector_to_stream_0_1, 0),
                     (self.blocks_stream_mux_2_1, 1))
        self.connect((self.blocks_vector_to_stream_1, 0),
                     (self.blocks_stream_to_streams_0_0_0, 0))
        self.connect((self.blocks_vector_to_stream_1_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_vector_to_stream_1_0_1, 0),
                     (self.blocks_float_to_complex_0_0, 0))
        self.connect((self.blocks_vector_to_stream_1_1, 0),
                     (self.blocks_stream_to_streams_0_0_0_0, 0))
        self.connect((self.blocks_vector_to_stream_2, 0),
                     (self.blocks_stream_to_vector_0_1_0_0_0, 0))
        self.connect((self.blocks_vector_to_stream_2_0, 0),
                     (self.blocks_stream_to_vector_0_1_0_0, 0))
        self.connect((self.blocks_vector_to_stream_2_1, 0),
                     (self.blocks_conjugate_cc_0, 0))
        self.connect((self.blocks_vector_to_stream_2_1_0, 0),
                     (self.blocks_stream_mux_0, 0))
        self.connect((self.long_sync_pulse_0, 0),
                     (self.blocks_stream_mux_1, 1))
        self.connect((self.long_sync_pulse_0_0, 0),
                     (self.blocks_stream_mux_1, 5))
        self.connect((self.short_sync_pulse_0_3_0, 0),
                     (self.blocks_stream_mux_1, 0))
        self.connect((self.short_sync_pulse_0_3_0_0, 0),
                     (self.blocks_stream_mux_1, 2))
        self.connect((self.short_sync_pulse_0_3_0_0_0, 0),
                     (self.blocks_stream_mux_1, 6))
        self.connect((self.short_sync_pulse_0_3_0_1, 0),
                     (self.blocks_stream_mux_1, 4))
        self.connect((self.stdin, 0), (self.blocks_uchar_to_float_0, 0))
コード例 #12
0
import gnuradio
from gnuradio import gr
from gnuradio import blocks as grblocks
import sys

if __name__ == '__main__':

    duration = float(sys.argv[1])

    tb = gr.top_block()
    src = gr.null_source(8)
    b0 = gr.copy(8)
    b1 = grblocks.sub_cc()
    b2 = gr.copy(8)
    b3 = grblocks.divide_cc()
    b4 = gr.copy(8)
    sink = gr.null_sink(8)

    tb.connect(src, b0, b1, b2, b3, b4, sink)

    import time
    tb.start()
    time.sleep(duration)
    print '##RESULT##', sink.nitems_read(0) / duration
    import sys
    sys.stdout.flush()
    tb.stop()
    tb.wait()
コード例 #13
0
    def __init__(self):
        gr.top_block.__init__(self, "DL Demod training")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("DL Demod training")
        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", "ofdm_base")

        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_length"
        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.length_tag_key_0 = length_tag_key_0 = "frame_len"
        self.length_tag_key = length_tag_key = "packet_len"
        self.header_mod = header_mod = digital.constellation_bpsk()
        self.fft_len = fft_len = 64
        self.errors = errors = 0
        self.variable_qtgui_label_0 = variable_qtgui_label_0 = errors
        self.training_mod = training_mod = 10
        self.sync_word2 = sync_word2 = [
            0, 0, 0, 0, 0, 0, -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, 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
        ]
        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.stop_button = stop_button = 0
        self.stop_button_args = stop_button_args = None
        self.start_button = start_button = 0
        self.start_button_args = start_button_args = None
        self.snr_stop = snr_stop = 12
        self.snr_step = snr_step = 0.2
        self.snr_start = snr_start = -4
        self.samp_rate = samp_rate = 1e6
        self.rolloff = rolloff = 0
        self.reset_ber = reset_ber = 0
        self.reset_ber_args = reset_ber_args = None
        self.reset = reset = 0
        self.reset_args = reset_args = None
        self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe(
            fft_len, payload_mod.base(), occupied_carriers, pilot_carriers,
            pilot_symbols, 1)
        self.packet_len = packet_len = 256
        self.mag = mag = -4
        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_0,
            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_simpledfe(
            fft_len, header_mod.base(), occupied_carriers, pilot_carriers,
            pilot_symbols)
        self.hdr_format = hdr_format = digital.header_format_ofdm(
            occupied_carriers,
            1,
            length_tag_key,
        )
        self.gain_rx = gain_rx = 0
        self.gain = gain = 30
        self.freq = freq = 900e6

        ##################################################
        # Blocks
        ##################################################
        self._training_mod_tool_bar = Qt.QToolBar(self)
        self._training_mod_tool_bar.addWidget(
            Qt.QLabel('Alternate training every' + ": "))
        self._training_mod_line_edit = Qt.QLineEdit(str(self.training_mod))
        self._training_mod_tool_bar.addWidget(self._training_mod_line_edit)
        self._training_mod_line_edit.returnPressed.connect(
            lambda: self.set_training_mod(
                int(str(self._training_mod_line_edit.text()))))
        self.top_grid_layout.addWidget(self._training_mod_tool_bar, 4, 0, 1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._mag_range = Range(snr_start, 20, 0.01, -4, 200)
        self._mag_win = RangeWidget(self._mag_range, self.set_mag, 'Magnitude',
                                    "counter_slider", float)
        self.top_grid_layout.addWidget(self._mag_win, 2, 0, 2, 2)
        for r in range(2, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.learning_sweeper_0 = learning.sweeper(
            self, np.arange(snr_start, snr_stop, snr_step), 200,
            'learning_ber_bf_0', 'blocks_probe_signal_x_0', self.set_mag)
        self.learning_dl_demod_0 = learning.dl_demod('packet_num',
                                                     packet_len * 4, 16,
                                                     training_mod, 0.05)
        self.learning_ber_bf_0 = learning.ber_bf(False, 100, -7.0, 2)
        self._gain_rx_range = Range(0, 90, .2, 0, 200)
        self._gain_rx_win = RangeWidget(self._gain_rx_range, self.set_gain_rx,
                                        'Amplitude Rx', "counter_slider",
                                        float)
        self.top_grid_layout.addWidget(self._gain_rx_win, 0, 2, 2, 1)
        for r in range(0, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._gain_range = Range(0, 90, .2, 30, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain,
                                     'Amplitude', "counter_slider", float)
        self.top_grid_layout.addWidget(self._gain_win, 0, 0, 2, 2)
        for r in range(0, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self)

        if None:
            self._variable_qtgui_label_0_formatter = None
        else:
            self._variable_qtgui_label_0_formatter = lambda x: str(x)

        self._variable_qtgui_label_0_tool_bar.addWidget(
            Qt.QLabel('Error count' + ": "))
        self._variable_qtgui_label_0_label = Qt.QLabel(
            str(
                self._variable_qtgui_label_0_formatter(
                    self.variable_qtgui_label_0)))
        self._variable_qtgui_label_0_tool_bar.addWidget(
            self._variable_qtgui_label_0_label)
        self.top_grid_layout.addWidget(self._variable_qtgui_label_0_tool_bar,
                                       4, 1, 1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=[],
            ),
        )
        self.uhd_usrp_source_0.set_center_freq(freq, 0)
        self.uhd_usrp_source_0.set_rx_agc(False, 0)
        self.uhd_usrp_source_0.set_gain(gain_rx, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=[],
            ),
            '',
        )
        self.uhd_usrp_sink_0.set_center_freq(freq, 0)
        self.uhd_usrp_sink_0.set_gain(gain, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()),
                                          uhd.ALL_MBOARDS)
        _stop_button_push_button = Qt.QPushButton('&Stop sweep')

        def stop_button_handler():
            if self.stop_button_args is not None:
                self.set_stop_button(self.learning_sweeper_0.stop_sweep())
            else:
                self.set_stop_button(self.learning_sweeper_0.stop_sweep())

        _stop_button_push_button.clicked.connect(stop_button_handler)
        self.top_grid_layout.addWidget(_stop_button_push_button, 9, 0, 1, 1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        _start_button_push_button = Qt.QPushButton('&Start sweep')

        def start_button_handler():
            if self.start_button_args is not None:
                self.set_start_button(self.learning_sweeper_0.start_sweep())
            else:
                self.set_start_button(self.learning_sweeper_0.start_sweep())

        _start_button_push_button.clicked.connect(start_button_handler)
        self.top_grid_layout.addWidget(_start_button_push_button, 8, 0, 1, 1)
        for r in range(8, 9):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        _reset_ber_push_button = Qt.QPushButton(
            "Reset &BER last: {}".format(reset_ber))

        def reset_ber_handler():
            if self.reset_ber_args is not None:
                self.set_reset_ber(self.learning_ber_bf_0.reset_counters())
            else:
                self.set_reset_ber(self.learning_ber_bf_0.reset_counters())

        _reset_ber_push_button.clicked.connect(reset_ber_handler)
        self.top_grid_layout.addWidget(_reset_ber_push_button, 5, 1, 1, 1)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        _reset_push_button = Qt.QPushButton('&Reset model state')

        def reset_handler():
            if self.reset_args is not None:
                self.set_reset(self.learning_dl_demod_0.reset())
            else:
                self.set_reset(self.learning_dl_demod_0.reset())

        _reset_push_button.clicked.connect(reset_handler)
        self.top_grid_layout.addWidget(_reset_push_button, 5, 0, 1, 1)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_vector_sink_f_0 = qtgui.vector_sink_f(
            len(np.arange(snr_start, snr_stop, snr_step)),
            snr_start,
            snr_step,
            "Eb/N0",
            "BER (log)",
            "BER Curve",
            2  # Number of inputs
        )
        self.qtgui_vector_sink_f_0.set_update_time(0.10)
        self.qtgui_vector_sink_f_0.set_y_axis(-7, 0)
        self.qtgui_vector_sink_f_0.enable_autoscale(False)
        self.qtgui_vector_sink_f_0.enable_grid(False)
        self.qtgui_vector_sink_f_0.set_x_axis_units("")
        self.qtgui_vector_sink_f_0.set_y_axis_units("")
        self.qtgui_vector_sink_f_0.set_ref_level(0)

        labels = ['Measure', 'Theory', '', '', '', '', '', '', '', '']
        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_vector_sink_f_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_vector_sink_f_0.set_line_label(i, labels[i])
            self.qtgui_vector_sink_f_0.set_line_width(i, widths[i])
            self.qtgui_vector_sink_f_0.set_line_color(i, colors[i])
            self.qtgui_vector_sink_f_0.set_line_alpha(i, alphas[i])

        self._qtgui_vector_sink_f_0_win = sip.wrapinstance(
            self.qtgui_vector_sink_f_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_vector_sink_f_0_win, 8, 1,
                                       2, 1)
        for r in range(8, 10):
            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(
            1024,  #size
            samp_rate,  #samp_rate
            'Scope Plot',  #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, "packet_num")
        self.qtgui_time_sink_x_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0_0.enable_grid(False)
        self.qtgui_time_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0_0.enable_stem_plot(False)

        labels = ['Scope Plot', '', '', '', '', '', '', '', '', '']
        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.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 6, 1,
                                       2, 2)
        for r in range(6, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_number_sink_1_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                       qtgui.NUM_GRAPH_HORIZ,
                                                       1)
        self.qtgui_number_sink_1_0.set_update_time(0.10)
        self.qtgui_number_sink_1_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_1_0.set_min(i, 0)
            self.qtgui_number_sink_1_0.set_max(i, 100)
            self.qtgui_number_sink_1_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_1_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_1_0.set_label(i, labels[i])
            self.qtgui_number_sink_1_0.set_unit(i, units[i])
            self.qtgui_number_sink_1_0.set_factor(i, factor[i])

        self.qtgui_number_sink_1_0.enable_autoscale(False)
        self._qtgui_number_sink_1_0_win = sip.wrapinstance(
            self.qtgui_number_sink_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_1_0_win, 4, 2,
                                       2, 1)
        for r in range(4, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_number_sink_1 = qtgui.number_sink(gr.sizeof_float, 0.8,
                                                     qtgui.NUM_GRAPH_HORIZ, 1)
        self.qtgui_number_sink_1.set_update_time(0.10)
        self.qtgui_number_sink_1.set_title("Eb/No")

        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_1.set_min(i, 0)
            self.qtgui_number_sink_1.set_max(i, 100)
            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, 2, 2, 2,
                                       1)
        for r in range(2, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

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

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 6, 0, 2,
                                       1)
        for r in range(6, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.learning_tag_numerotation_0 = learning.tag_numerotation(
            'packet_num', packet_len * 4, 4096, "bb")
        self.fft_vxx_1 = fft.fft_vcc(fft_len, True, (), True, 1)
        self.fft_vxx_0_0 = fft.fft_vcc(fft_len, False, (), True, 1)
        self.fft_vxx_0 = fft.fft_vcc(fft_len, True, (), True, 1)

        def _errors_probe():
            while True:

                val = self.learning_ber_bf_0.total_errors()
                try:
                    self.set_errors(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))

        _errors_thread = threading.Thread(target=_errors_probe)
        _errors_thread.daemon = True
        _errors_thread.start()

        self.epy_block_0 = epy_block_0.alignement(tag_name="packet_num",
                                                  frame_size=packet_len * 4)
        self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb(
            hdr_format, length_tag_key)
        self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b(
            header_formatter.base())
        self.digital_ofdm_sync_sc_cfb_0 = digital.ofdm_sync_sc_cfb(
            fft_len, fft_len // 4, False, 0.95)
        self.digital_ofdm_serializer_vcc_payload = digital.ofdm_serializer_vcc(
            fft_len, occupied_carriers, length_tag_key_0,
            packet_length_tag_key, 1, '', True)
        self.digital_ofdm_serializer_vcc_header = digital.ofdm_serializer_vcc(
            fft_len, occupied_carriers, length_tag_key_0, '', 0, '', True)
        self.digital_ofdm_frame_equalizer_vcvc_1 = digital.ofdm_frame_equalizer_vcvc(
            payload_equalizer.base(), fft_len // 4, length_tag_key_0, True, 0)
        self.digital_ofdm_frame_equalizer_vcvc_0 = digital.ofdm_frame_equalizer_vcvc(
            header_equalizer.base(), fft_len // 4, length_tag_key_0, True, 1)
        self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(
            fft_len, fft_len + fft_len // 4, rolloff, length_tag_key)
        self.digital_ofdm_chanest_vcvc_0 = digital.ofdm_chanest_vcvc(
            sync_word1, sync_word2, 1, 0, 3, False)
        self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc(
            fft_len, occupied_carriers, pilot_carriers, pilot_symbols,
            (sync_word1, sync_word2), length_tag_key, True)
        self.digital_header_payload_demux_0 = digital.header_payload_demux(
            3, fft_len, fft_len // 4, length_tag_key_0, "", True,
            gr.sizeof_gr_complex, "rx_time", int(samp_rate), (), 0)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            header_mod.base())
        self.digital_chunks_to_symbols_xx_0_0_0 = digital.chunks_to_symbols_bc(
            payload_mod.points(), 1)
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(
            payload_mod.points(), 1)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            header_mod.points(), 1)
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(
            gr.sizeof_gr_complex * 1, length_tag_key, 0)
        self.blocks_sub_xx_0_0 = blocks.sub_cc(1)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, packet_len, length_tag_key)
        self.blocks_repack_bits_bb_0_0_0 = blocks.repack_bits_bb(
            8, 1, length_tag_key, False, gr.GR_LSB_FIRST)
        self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(
            8, payload_mod.bits_per_symbol(), length_tag_key, False,
            gr.GR_LSB_FIRST)
        self.blocks_probe_signal_x_0 = blocks.probe_signal_f()
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(-10, 1,
                                                   10 * np.log10(4 / 2))
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_xx_0 = blocks.multiply_const_cc(0.05, 1)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            5000, 1.0 / 5000, 4000, 1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                           fft_len + fft_len // 4)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_char_to_float_0_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_random_source_x_0_0 = blocks.vector_source_b(
            list(map(int, numpy.random.randint(0, 255, 1000))), True)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN,
            np.sqrt(10**(np.log10(2) - (mag / 10.0))) * 1, -1)
        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, 1))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.analog_random_source_x_0_0, 0),
                     (self.blocks_stream_to_tagged_stream_0_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.epy_block_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.qtgui_const_sink_x_0, 0))
        self.connect((self.blocks_char_to_float_0_0, 0),
                     (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_char_to_float_0_0_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_multiply_const_xx_0, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.digital_header_payload_demux_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.qtgui_number_sink_1, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0),
                     (self.learning_tag_numerotation_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0_0, 0),
                     (self.blocks_repack_bits_bb_0_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0_0, 0),
                     (self.digital_protocol_formatter_bb_0, 0))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_sub_xx_0_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0),
                     (self.digital_ofdm_carrier_allocator_cvc_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_tagged_stream_mux_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0),
                     (self.blocks_tagged_stream_mux_0, 1))
        self.connect((self.digital_chunks_to_symbols_xx_0_0_0, 0),
                     (self.blocks_sub_xx_0_0, 1))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_packet_headerparser_b_0, 0))
        self.connect((self.digital_header_payload_demux_0, 0),
                     (self.fft_vxx_0, 0))
        self.connect((self.digital_header_payload_demux_0, 1),
                     (self.fft_vxx_1, 0))
        self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0),
                     (self.fft_vxx_0_0, 0))
        self.connect((self.digital_ofdm_chanest_vcvc_0, 0),
                     (self.digital_ofdm_frame_equalizer_vcvc_0, 0))
        self.connect((self.digital_ofdm_cyclic_prefixer_0, 0),
                     (self.blocks_multiply_const_xx_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.blocks_add_xx_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_protocol_formatter_bb_0, 0),
                     (self.blocks_repack_bits_bb_0_0_0, 0))
        self.connect((self.epy_block_0, 0), (self.blocks_sub_xx_0_0, 0))
        self.connect((self.epy_block_0, 1),
                     (self.digital_chunks_to_symbols_xx_0_0_0, 0))
        self.connect((self.epy_block_0, 0), (self.learning_dl_demod_0, 0))
        self.connect((self.epy_block_0, 1), (self.learning_dl_demod_0, 1))
        self.connect((self.fft_vxx_0, 0),
                     (self.digital_ofdm_chanest_vcvc_0, 0))
        self.connect((self.fft_vxx_0_0, 0),
                     (self.digital_ofdm_cyclic_prefixer_0, 0))
        self.connect((self.fft_vxx_1, 0),
                     (self.digital_ofdm_frame_equalizer_vcvc_1, 0))
        self.connect((self.learning_ber_bf_0, 0),
                     (self.blocks_probe_signal_x_0, 0))
        self.connect((self.learning_ber_bf_0, 0),
                     (self.qtgui_number_sink_1_0, 0))
        self.connect((self.learning_dl_demod_0, 0),
                     (self.blocks_char_to_float_0_0, 0))
        self.connect((self.learning_dl_demod_0, 1),
                     (self.blocks_char_to_float_0_0_0, 0))
        self.connect((self.learning_dl_demod_0, 0),
                     (self.learning_ber_bf_0, 0))
        self.connect((self.learning_dl_demod_0, 1),
                     (self.learning_ber_bf_0, 1))
        self.connect((self.learning_sweeper_0, 0),
                     (self.qtgui_vector_sink_f_0, 0))
        self.connect((self.learning_sweeper_0, 1),
                     (self.qtgui_vector_sink_f_0, 1))
        self.connect((self.learning_tag_numerotation_0, 0),
                     (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.learning_tag_numerotation_0, 0),
                     (self.epy_block_0, 1))
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.digital_ofdm_sync_sc_cfb_0, 0))
コード例 #14
0
    def __init__(self, options):
        gr.top_block.__init__(self)

        self.options = options
        self.show_debug_info = True

        self.qapp = QtGui.QApplication(sys.argv)

        self.u = uhd.usrp_source(device_addr=options.address, stream_args=uhd.stream_args('fc32'))

        if(options.antenna):
            self.u.set_antenna(options.antenna, 0)

        self.set_bandwidth(options.samp_rate)

        if options.gain is None:
            # if no gain was specified, use the mid-point in dB
            g = self.u.get_gain_range()
            options.gain = float(g.start()+g.stop()) / 2
        self.set_gain(options.gain)

        if options.freq is None:
            # if no freq was specified, use the mid-point
            r = self.u.get_freq_range()
            options.freq = float(r.start()+r.stop()) / 2
        self.set_frequency(options.freq)

        self._fftsize = options.fft_size

        self.snk = qtgui.sink_c(options.fft_size,
                                fft.window.WIN_BLACKMAN_hARRIS,
                                self._freq, self._bandwidth,
                                "UHD Display",
                                True, True, True, False)

        # Set up internal amplifier
        self.amp = blocks.multiply_const_cc(0.0)
        self.set_amplifier_gain(100)

        # Create a single-pole IIR filter to remove DC
        #   but don't connect it yet
        self.dc_gain = 0.001
        self.dc = filter.single_pole_iir_filter_cc(self.dc_gain)
        self.dc_sub = blocks.sub_cc()

        self.connect(self.u, self.amp, self.snk)

        if self.show_debug_info:
            print("Bandwidth: ", self.u.get_samp_rate())
            print("Center Freq: ", self.u.get_center_freq())
            print("Freq Range: ", self.u.get_freq_range())

        # Get the reference pointer to the SpectrumDisplayForm QWidget
        # Wrap the pointer as a PyQt SIP object
        #     This can now be manipulated as a PyQt5.QtGui.QWidget
        self.pysink = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget)

        self.main_win = main_window(self.pysink, self)

        self.main_win.set_frequency(self._freq)
        self.main_win.set_gain(self._gain)
        self.main_win.set_bandwidth(self._bandwidth)
        self.main_win.set_amplifier(self._amp_value)

        self.main_win.show()
コード例 #15
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block Mfsk")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 44100

        ##################################################
        # Blocks
        ##################################################
        self.notebook_2 = self.notebook_2 = wx.Notebook(self.GetWin(),
                                                        style=wx.NB_TOP)
        self.notebook_2.AddPage(grc_wxgui.Panel(self.notebook_2), "FFT")
        self.notebook_2.AddPage(grc_wxgui.Panel(self.notebook_2), "SCOPE")
        self.Add(self.notebook_2)
        self.notebook_1 = self.notebook_1 = wx.Notebook(
            self.notebook_2.GetPage(0).GetWin(), style=wx.NB_TOP)
        self.notebook_1.AddPage(grc_wxgui.Panel(self.notebook_1), "fftSource")
        self.notebook_1.AddPage(grc_wxgui.Panel(self.notebook_1),
                                "fftDemodulated")
        self.notebook_2.GetPage(0).Add(self.notebook_1)
        self.notebook_0 = self.notebook_0 = wx.Notebook(
            self.notebook_2.GetPage(1).GetWin(), style=wx.NB_TOP)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "ScopeRx")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0),
                                "ScopeSource")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0),
                                "Constellation")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0),
                                "ScopeConstellation")
        self.notebook_2.GetPage(1).Add(self.notebook_0)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_c(
            self.notebook_0.GetPage(1).GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=True,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.notebook_0.GetPage(1).Add(self.wxgui_scopesink2_1.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.notebook_0.GetPage(0).GetWin(),
            title="Scope Plot - Source - Modulated - Demodulated",
            sample_rate=samp_rate,
            v_scale=4,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=3,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.notebook_0.GetPage(0).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c(
            self.notebook_1.GetPage(0).GetWin(),
            baseband_freq=0,
            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=False,
            avg_alpha=None,
            title="FFT Plot Source",
            peak_hold=False,
        )
        self.notebook_1.GetPage(0).Add(self.wxgui_fftsink2_0_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_f(
            self.notebook_1.GetPage(1).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=30,
            ref_scale=4,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="FFT Plot Demodulated",
            peak_hold=False,
        )
        self.notebook_1.GetPage(1).Add(self.wxgui_fftsink2_0.win)
        self.wxgui_constellationsink2_0_0 = constsink_gl.const_sink_c(
            self.notebook_0.GetPage(2).GetWin(),
            title="Constellation Plot Modulated",
            sample_rate=samp_rate,
            frame_rate=5,
            const_size=2048,
            M=4,
            theta=0,
            loop_bw=6.28 / 100.0,
            fmax=0.06,
            mu=0.5,
            gain_mu=0.005,
            symbol_rate=samp_rate / 4.,
            omega_limit=0.005,
        )
        self.notebook_0.GetPage(2).Add(self.wxgui_constellationsink2_0_0.win)
        self.wxgui_constellationsink2_0 = constsink_gl.const_sink_c(
            self.notebook_0.GetPage(3).GetWin(),
            title="Constellation Plot Demodulated",
            sample_rate=samp_rate,
            frame_rate=5,
            const_size=2048,
            M=4,
            theta=0,
            loop_bw=6.28 / 100.0,
            fmax=0.06,
            mu=0.5,
            gain_mu=0.005,
            symbol_rate=samp_rate / 4.,
            omega_limit=0.005,
        )
        self.notebook_0.GetPage(3).Add(self.wxgui_constellationsink2_0.win)
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 8000, 1000, firdes.WIN_HAMMING,
                            6.76))
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_vector_source_x_0_0_0_2 = blocks.vector_source_b(
            (1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0), True, 1, [])
        self.blocks_vector_source_x_0_0_0_1 = blocks.vector_source_b(
            (1, 1), True, 1, [])
        self.blocks_vector_source_x_0_0_0_0 = blocks.vector_source_b(
            (1, 0), True, 1, [])
        self.blocks_vector_source_x_0_0_0 = blocks.vector_source_b((0, 1),
                                                                   True, 1, [])
        self.blocks_vector_source_x_0_0 = blocks.vector_source_b((0, 0), True,
                                                                 1, [])
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_sub_xx_1 = blocks.sub_ff(1)
        self.blocks_sub_xx_0 = blocks.sub_cc(1)
        self.blocks_repeat_0_2 = blocks.repeat(gr.sizeof_char * 1, 100)
        self.blocks_repeat_0_1_0 = blocks.repeat(gr.sizeof_char * 1, 100)
        self.blocks_repeat_0_1 = blocks.repeat(gr.sizeof_char * 1, 100)
        self.blocks_repeat_0_0 = blocks.repeat(gr.sizeof_char * 1, 100)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char * 1, 100)
        self.blocks_multiply_xx_0_1_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_1_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((-1, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((-1, ))
        self.blocks_float_to_complex_1 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0_2 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0_1_0 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0_1 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0_0 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_char_to_float_1 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_2 = blocks.char_to_float(1, 2)
        self.blocks_char_to_float_0_1_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_1 = blocks.char_to_float(1, 2)
        self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 2)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 2)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_sig_source_x_0_0_1 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, samp_rate / 100, 1, 0)
        self.analog_sig_source_x_0_0_0_2 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, samp_rate / 50, 1, 0)
        self.analog_sig_source_x_0_0_0_1_1 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, samp_rate, 1, 0)
        self.analog_sig_source_x_0_0_0_1_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, samp_rate / 10, 1, 0)
        self.analog_sig_source_x_0_0_0_1 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, samp_rate / 25, 1, 0)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(-100)
        self.analog_const_source_x_0_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 3)
        self.analog_const_source_x_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.analog_const_source_x_0_0, 0),
                     (self.blocks_sub_xx_1, 1))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.wxgui_fftsink2_0, 0))
        self.connect((self.analog_sig_source_x_0_0_0_1, 0),
                     (self.blocks_multiply_xx_0_1_0_0, 0))
        self.connect((self.analog_sig_source_x_0_0_0_1_0, 0),
                     (self.blocks_multiply_xx_0_1, 0))
        self.connect((self.analog_sig_source_x_0_0_0_1_1, 0),
                     (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.analog_sig_source_x_0_0_0_2, 0),
                     (self.blocks_multiply_xx_0_1_0, 0))
        self.connect((self.analog_sig_source_x_0_0_1, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.wxgui_constellationsink2_0_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.wxgui_fftsink2_0_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.wxgui_scopesink2_1, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_char_to_float_0_0, 0),
                     (self.blocks_float_to_complex_0_0, 0))
        self.connect((self.blocks_char_to_float_0_1, 0),
                     (self.blocks_float_to_complex_0_1, 0))
        self.connect((self.blocks_char_to_float_0_1_0, 0),
                     (self.blocks_float_to_complex_0_1_0, 0))
        self.connect((self.blocks_char_to_float_0_1_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_char_to_float_0_2, 0),
                     (self.blocks_float_to_complex_0_2, 0))
        self.connect((self.blocks_char_to_float_1, 0),
                     (self.blocks_float_to_complex_1, 0))
        self.connect((self.blocks_char_to_float_1, 0),
                     (self.wxgui_scopesink2_0, 1))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.wxgui_scopesink2_0, 2))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_float_to_complex_0_0, 0),
                     (self.blocks_multiply_xx_0_1_0, 1))
        self.connect((self.blocks_float_to_complex_0_1, 0),
                     (self.blocks_multiply_xx_0_1_0_0, 1))
        self.connect((self.blocks_float_to_complex_0_1_0, 0),
                     (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_float_to_complex_0_2, 0),
                     (self.blocks_multiply_xx_0_1, 1))
        self.connect((self.blocks_float_to_complex_1, 0),
                     (self.wxgui_constellationsink2_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_sub_xx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.blocks_add_xx_0, 4))
        self.connect((self.blocks_multiply_xx_0_1, 0),
                     (self.blocks_add_xx_0, 2))
        self.connect((self.blocks_multiply_xx_0_1_0, 0),
                     (self.blocks_add_xx_0, 3))
        self.connect((self.blocks_multiply_xx_0_1_0_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_repeat_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.blocks_repeat_0_0, 0),
                     (self.blocks_char_to_float_0_0, 0))
        self.connect((self.blocks_repeat_0_1, 0),
                     (self.blocks_char_to_float_0_1, 0))
        self.connect((self.blocks_repeat_0_1_0, 0),
                     (self.blocks_char_to_float_0_1_0, 0))
        self.connect((self.blocks_repeat_0_2, 0),
                     (self.blocks_char_to_float_0_2, 0))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.blocks_sub_xx_1, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.blocks_vector_source_x_0_0, 0),
                     (self.blocks_repeat_0, 0))
        self.connect((self.blocks_vector_source_x_0_0_0, 0),
                     (self.blocks_repeat_0_1, 0))
        self.connect((self.blocks_vector_source_x_0_0_0_0, 0),
                     (self.blocks_repeat_0_2, 0))
        self.connect((self.blocks_vector_source_x_0_0_0_1, 0),
                     (self.blocks_repeat_0_0, 0))
        self.connect((self.blocks_vector_source_x_0_0_0_2, 0),
                     (self.blocks_repeat_0_1_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_char_to_float_1, 0))
        self.connect((self.low_pass_filter_0, 0), (self.blocks_throttle_0, 0))
コード例 #16
0
import gnuradio
from gnuradio import gr
from gnuradio import blocks as grblocks
import sys

if __name__ == '__main__':

    duration = float(sys.argv[1])

    tb = gr.top_block()
    src = gr.null_source(8)
    b0 = gr.copy(8)
    b1 = grblocks.sub_cc()
    b2 = gr.copy(8)
    b3 = grblocks.divide_cc()
    b4 = gr.copy(8)
    sink = gr.null_sink(8)

    tb.connect(src, b0, b1, b2, b3, b4, sink)

    import time
    tb.start()
    time.sleep(duration)
    print '##RESULT##', sink.nitems_read(0)/duration
    import sys; sys.stdout.flush()
    tb.stop()
    tb.wait()
コード例 #17
0
    def __init__(self):
        gr.top_block.__init__(self, "Superposition Coding")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Superposition Coding")
        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", "int_cancellation")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.snr_db = snr_db = 10
        self.prefix = prefix = "/opt/usr/src/gnuradio/gr-trellis/examples/python/fsm_files/"
        self.noisevar = noisevar = 10**(-snr_db / 10)
        self.fsm2 = fsm2 = "awgn1o2_4.fsm"
        self.fsm1 = fsm1 = "awgn1o2_16.fsm"
        self.block = block = 1000
        self.alpha = alpha = .1
        self.R = R = 100e3

        ##################################################
        # Blocks
        ##################################################
        self._alpha_range = Range(0, 1, .01, .1, 200)
        self._alpha_win = RangeWidget(self._alpha_range, self.set_alpha,
                                      'P1/P', "counter_slider", float)
        self.top_layout.addWidget(self._alpha_win)
        self.trellis_viterbi_combined_xx_2 = trellis.viterbi_combined_cb(
            trellis.fsm(prefix + fsm2), block, -1, -1, 1,
            ((1 - alpha)**0.5 * 1, (1 - alpha)**0.5 * 1j,
             (1 - alpha)**0.5 * (-1j), (1 - alpha)**0.5 * (-1)),
            digital.TRELLIS_EUCLIDEAN)
        self.trellis_viterbi_combined_xx_1 = trellis.viterbi_combined_cb(
            trellis.fsm(prefix + fsm1), block, -1, -1, 1,
            (alpha**0.5 * 1, alpha**0.5 * 1j, alpha**0.5 * (-1j), alpha**0.5 *
             (-1)), digital.TRELLIS_EUCLIDEAN)
        self.trellis_viterbi_combined_xx_0_0 = trellis.viterbi_combined_cb(
            trellis.fsm(prefix + fsm1), block, -1, -1, 1,
            (alpha**0.5 * 1, alpha**0.5 * 1j, alpha**0.5 * (-1j), alpha**0.5 *
             (-1)), digital.TRELLIS_EUCLIDEAN)
        self.trellis_viterbi_combined_xx_0 = trellis.viterbi_combined_cb(
            trellis.fsm(prefix + fsm2), block, -1, -1, 1,
            ((1 - alpha)**0.5 * 1, (1 - alpha)**0.5 * 1j,
             (1 - alpha)**0.5 * (-1j), (1 - alpha)**0.5 * (-1)),
            digital.TRELLIS_EUCLIDEAN)
        self.trellis_encoder_xx_2_0 = trellis.encoder_bb(
            trellis.fsm(prefix + fsm2), 0, 0) if False else trellis.encoder_bb(
                trellis.fsm(prefix + fsm2), 0)
        self.trellis_encoder_xx_2 = trellis.encoder_bb(
            trellis.fsm(prefix + fsm1), 0, 0) if False else trellis.encoder_bb(
                trellis.fsm(prefix + fsm1), 0)
        self.trellis_encoder_xx_1 = trellis.encoder_bb(
            trellis.fsm(prefix + fsm2), 0, 0) if False else trellis.encoder_bb(
                trellis.fsm(prefix + fsm2), 0)
        self.trellis_encoder_xx_0 = trellis.encoder_bb(
            trellis.fsm(prefix + fsm1), 0, 0) if False else trellis.encoder_bb(
                trellis.fsm(prefix + fsm1), 0)
        self._snr_db_range = Range(0, 20, 1, 10, 200)
        self._snr_db_win = RangeWidget(self._snr_db_range, self.set_snr_db,
                                       'P/sigma^2 (dB)', "counter_slider",
                                       float)
        self.top_layout.addWidget(self._snr_db_win)
        self.qtgui_number_sink_0_0_0_0 = qtgui.number_sink(
            gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1)
        self.qtgui_number_sink_0_0_0_0.set_update_time(0.10)
        self.qtgui_number_sink_0_0_0_0.set_title(
            'BER 1 (after cancelling user 2)')

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

        self.qtgui_number_sink_0_0_0_0.enable_autoscale(False)
        self._qtgui_number_sink_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_win, 1,
                                       0, 1, 1)
        self.qtgui_number_sink_0_0_0 = qtgui.number_sink(
            gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1)
        self.qtgui_number_sink_0_0_0.set_update_time(0.10)
        self.qtgui_number_sink_0_0_0.set_title(
            "BER 2 (after cancelling user 1)")

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

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

        labels = ['BER', '', '', '', '', '', '', '', '', '']
        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 xrange(1):
            self.qtgui_number_sink_0_0.set_min(i, 0)
            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, 0, 1,
                                       1, 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("BER1 (Raw)")

        labels = ['BER', '', '', '', '', '', '', '', '', '']
        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 xrange(1):
            self.qtgui_number_sink_0.set_min(i, 0)
            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, 0, 0, 1,
                                       1)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0.disable_legend()

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

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.digital_chunks_to_symbols_xx_0_0_1 = digital.chunks_to_symbols_bc(
            (1, 1j, -1j, -1), 1)
        self.digital_chunks_to_symbols_xx_0_0_0 = digital.chunks_to_symbols_bc(
            (1, 1j, -1j, -1), 1)
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(
            (1, 1j, -1j, -1), 1)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            (1, 1j, -1j, -1), 1)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, R, True)
        self.blocks_sub_xx_2_0 = blocks.sub_cc(1)
        self.blocks_sub_xx_2 = blocks.sub_cc(1)
        self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_vcc(
            ((1 - alpha)**0.5, ))
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vcc(
            (alpha**0.5, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc(
            ((1 - alpha)**0.5, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(
            (alpha**0.5, ))
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.blks2_error_rate_0_0_0_0 = grc_blks2.error_rate(
            type='BER',
            win_size=block * 100,
            bits_per_symbol=2,
        )
        self.blks2_error_rate_0_0_0 = grc_blks2.error_rate(
            type='BER',
            win_size=block * 100,
            bits_per_symbol=2,
        )
        self.blks2_error_rate_0_0 = grc_blks2.error_rate(
            type='BER',
            win_size=block * 100,
            bits_per_symbol=2,
        )
        self.blks2_error_rate_0 = grc_blks2.error_rate(
            type='BER',
            win_size=block * 100,
            bits_per_symbol=2,
        )
        self.analog_random_source_x_1 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 2, block)), True)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 2, block)), True)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, noisevar, -42)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_0, 2))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blks2_error_rate_0, 0))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blks2_error_rate_0_0_0_0, 0))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.trellis_encoder_xx_0, 0))
        self.connect((self.analog_random_source_x_1, 0),
                     (self.blks2_error_rate_0_0, 0))
        self.connect((self.analog_random_source_x_1, 0),
                     (self.blks2_error_rate_0_0_0, 0))
        self.connect((self.analog_random_source_x_1, 0),
                     (self.trellis_encoder_xx_1, 0))
        self.connect((self.blks2_error_rate_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blks2_error_rate_0_0, 0),
                     (self.qtgui_number_sink_0_0, 0))
        self.connect((self.blks2_error_rate_0_0_0, 0),
                     (self.qtgui_number_sink_0_0_0, 0))
        self.connect((self.blks2_error_rate_0_0_0_0, 0),
                     (self.qtgui_number_sink_0_0_0_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_sub_xx_2, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_sub_xx_2_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.trellis_viterbi_combined_xx_1, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.trellis_viterbi_combined_xx_2, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_add_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_sub_xx_2, 1))
        self.connect((self.blocks_multiply_const_vxx_2_0, 0),
                     (self.blocks_sub_xx_2_0, 1))
        self.connect((self.blocks_sub_xx_2, 0),
                     (self.trellis_viterbi_combined_xx_0, 0))
        self.connect((self.blocks_sub_xx_2_0, 0),
                     (self.trellis_viterbi_combined_xx_0_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0_0, 0),
                     (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0_1, 0),
                     (self.blocks_multiply_const_vxx_2_0, 0))
        self.connect((self.trellis_encoder_xx_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.trellis_encoder_xx_1, 0),
                     (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.trellis_encoder_xx_2, 0),
                     (self.digital_chunks_to_symbols_xx_0_0_0, 0))
        self.connect((self.trellis_encoder_xx_2_0, 0),
                     (self.digital_chunks_to_symbols_xx_0_0_1, 0))
        self.connect((self.trellis_viterbi_combined_xx_0, 0),
                     (self.blks2_error_rate_0_0_0, 1))
        self.connect((self.trellis_viterbi_combined_xx_0_0, 0),
                     (self.blks2_error_rate_0_0_0_0, 1))
        self.connect((self.trellis_viterbi_combined_xx_1, 0),
                     (self.blks2_error_rate_0, 1))
        self.connect((self.trellis_viterbi_combined_xx_1, 0),
                     (self.trellis_encoder_xx_2, 0))
        self.connect((self.trellis_viterbi_combined_xx_2, 0),
                     (self.blks2_error_rate_0_0, 1))
        self.connect((self.trellis_viterbi_combined_xx_2, 0),
                     (self.trellis_encoder_xx_2_0, 0))
コード例 #18
0
    def __init__(self):
        gr.top_block.__init__(self, "Konzerv Rx Atan")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Konzerv Rx Atan")
        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", "konzerv_rx_atan")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1800000
        self.center_freq = center_freq = 0
        self.audio_rate = audio_rate = 44100

        ##################################################
        # Blocks
        ##################################################
        self._center_freq_range = Range(-samp_rate / 2, samp_rate / 2, 1, 0,
                                        200)
        self._center_freq_win = RangeWidget(self._center_freq_range,
                                            self.set_center_freq,
                                            "center_freq", "counter_slider",
                                            float)
        self.top_layout.addWidget(self._center_freq_win)
        self.qtgui_waterfall_sink_x_1 = qtgui.waterfall_sink_f(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "Demod signal",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_1.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_1.enable_grid(False)

        if not True:
            self.qtgui_waterfall_sink_x_1.disable_legend()

        if "float" == "float" or "float" == "msg_float":
            self.qtgui_waterfall_sink_x_1.set_plot_pos_half(not True)

        labels = ["", "", "", "", "", "", "", "", "", ""]
        colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_1.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_1.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_1.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_1_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_waterfall_sink_x_1_win)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "Rx signal",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)

        if not True:
            self.qtgui_waterfall_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)

        labels = ["", "", "", "", "", "", "", "", "", ""]
        colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (firdes.low_pass(1.0, samp_rate, 1.5e5, 1e4)), center_freq,
            samp_rate)
        self.fir_filter_xxx_0 = filter.fir_filter_fff(
            samp_rate / audio_rate,
            (firdes.low_pass(1.0, samp_rate, audio_rate / 2 - 1000, 1000)))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_sub_xx_0 = blocks.sub_cc(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            "/home/mero/kafu/grc_demo_2021/konzerv.iq", True)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_float_1 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.audio_sink_0 = audio.sink(audio_rate, "", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_divide_xx_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_complex_to_float_1, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_complex_to_float_1, 1),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.qtgui_waterfall_sink_x_1, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_divide_xx_0, 0), (self.fir_filter_xxx_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.blocks_complex_to_float_1, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.fir_filter_xxx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.blocks_sub_xx_0, 0))
コード例 #19
0
ファイル: top_block.py プロジェクト: FaustoBrenner/LabPrincom
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.z = z = 0.2
        self.p = p = 10
        self.W = W = 2e3
        self.c = c = 1450
        self.Tp = Tp = 0.025
        self.N = N = p * z * W
        self.n = n = np.arange(0, N)
        self.min_range = min_range = (Tp) * c / 2
        self.max_range = max_range = (z - Tp) / 2 * c
        self.alpha = alpha = 1 / (2 * p * p * z * W)
        self.samp_rate = samp_rate = p * W
        self.fc = fc = 50e3
        self.chirp = chirp = np.exp(1j * 2 * np.pi * alpha * (n - 0.5 * N)**2)
        self.R3 = R3 = max_range - min_range
        self.R2 = R2 = 85
        self.R1 = R1 = 60
        self.Np = Np = 5
        self.AN = AN = 2

        ##################################################
        # Blocks
        ##################################################
        self._R1_range = Range(min_range, max_range, 0.05, 60, 200)
        self._R1_win = RangeWidget(self._R1_range, self.set_R1, "R1",
                                   "counter_slider", float)
        self.top_grid_layout.addWidget(self._R1_win)
        self._z_range = Range(0.2, 1.45, 0.05, 0.2, 200)
        self._z_win = RangeWidget(self._z_range, self.set_z, "z",
                                  "counter_slider", float)
        self.top_grid_layout.addWidget(self._z_win)
        self.qtgui_vector_sink_f_0 = qtgui.vector_sink_f(
            int(N * Np),
            0,
            1.0,
            "x-Axis",
            "y-Axis",
            "",
            1  # Number of inputs
        )
        self.qtgui_vector_sink_f_0.set_update_time(0.10)
        self.qtgui_vector_sink_f_0.set_y_axis(-140, 10)
        self.qtgui_vector_sink_f_0.enable_autoscale(False)
        self.qtgui_vector_sink_f_0.enable_grid(False)
        self.qtgui_vector_sink_f_0.set_x_axis_units("")
        self.qtgui_vector_sink_f_0.set_y_axis_units("")
        self.qtgui_vector_sink_f_0.set_ref_level(0)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_vector_sink_f_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_vector_sink_f_0.set_line_label(i, labels[i])
            self.qtgui_vector_sink_f_0.set_line_width(i, widths[i])
            self.qtgui_vector_sink_f_0.set_line_color(i, colors[i])
            self.qtgui_vector_sink_f_0.set_line_alpha(i, alphas[i])

        self._qtgui_vector_sink_f_0_win = sip.wrapinstance(
            self.qtgui_vector_sink_f_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_vector_sink_f_0_win)
        self.qtgui_freq_sink_x_0_0_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "RX",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_0_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                      0.0, 0, "")
        self.qtgui_freq_sink_x_0_0_0.enable_autoscale(True)
        self.qtgui_freq_sink_x_0_0_0.enable_grid(True)
        self.qtgui_freq_sink_x_0_0_0.set_fft_average(0.05)
        self.qtgui_freq_sink_x_0_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0_0_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0_0_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_0_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_0_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_0_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_0_win)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "TX",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(True)
        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)

        if not True:
            self.qtgui_freq_sink_x_0_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win)
        self.fft_vxx_0_0 = fft.fft_vcc(int(N * Np), True,
                                       (window.blackmanharris(1024)), True, 1)
        self.fft_vxx_0 = fft.fft_vcc(int(N * Np), True,
                                     (window.blackmanharris(1024)), True, 1)
        self.blocks_vector_source_x_0 = blocks.vector_source_c(
            np.tile(chirp, Np), False, 1, [])
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_sub_xx_0 = blocks.sub_cc(int(N * Np))
        self.blocks_stream_to_vector_1 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, int(N * Np))
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, int(N * Np))
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(1, int(N * Np), 0)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                           int(2 * R1 / (c / samp_rate)))
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(int(N * Np))
        self._R3_range = Range(min_range, max_range, 0.05,
                               max_range - min_range, 200)
        self._R3_win = RangeWidget(self._R3_range, self.set_R3, "R3",
                                   "counter_slider", float)
        self.top_grid_layout.addWidget(self._R3_win)
        self._R2_range = Range(min_range, max_range, 0.05, 85, 200)
        self._R2_win = RangeWidget(self._R2_range, self.set_R2, "R2",
                                   "counter_slider", float)
        self.top_grid_layout.addWidget(self._R2_win)
        self._AN_range = Range(0, 7, 0.5, 2, 200)
        self._AN_win = RangeWidget(self._AN_range, self.set_AN, "AN",
                                   "counter_slider", float)
        self.top_grid_layout.addWidget(self._AN_win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.qtgui_freq_sink_x_0_0_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.qtgui_vector_sink_f_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_stream_to_vector_1, 0),
                     (self.fft_vxx_0_0, 0))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_stream_to_vector_1, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.fft_vxx_0_0, 0), (self.blocks_sub_xx_0, 0))
コード例 #20
0
ファイル: uhd_display.py プロジェクト: 232675/gnuradio
    def __init__(self, options):
        gr.top_block.__init__(self)

        self.options = options
        self.show_debug_info = True

        self.qapp = QtGui.QApplication(sys.argv)

        self.u = uhd.usrp_source(device_addr=options.address, stream_args=uhd.stream_args('fc32'))

        if(options.antenna):
            self.u.set_antenna(options.antenna, 0)

        self.set_bandwidth(options.samp_rate)

        if options.gain is None:
            # if no gain was specified, use the mid-point in dB
            g = self.u.get_gain_range()
            options.gain = float(g.start()+g.stop())/2
        self.set_gain(options.gain)

        if options.freq is None:
            # if no freq was specified, use the mid-point
            r = self.u.get_freq_range()
            options.freq = float(r.start()+r.stop())/2
        self.set_frequency(options.freq)

        self._fftsize = options.fft_size

        self.snk = qtgui.sink_c(options.fft_size,
                                filter.firdes.WIN_BLACKMAN_hARRIS,
                                self._freq, self._bandwidth,
                                "UHD Display",
                                True, True, True, False)

        # Set up internal amplifier
        self.amp = blocks.multiply_const_cc(0.0)
        self.set_amplifier_gain(100)

        # Create a single-pole IIR filter to remove DC
        #   but don't connect it yet
        self.dc_gain = 0.001
        self.dc = filter.single_pole_iir_filter_cc(self.dc_gain)
        self.dc_sub = blocks.sub_cc()

        self.connect(self.u, self.amp, self.snk)

        if self.show_debug_info:
            print "Bandwidth: ", self.u.get_samp_rate()
            print "Center Freq: ", self.u.get_center_freq()
            print "Freq Range: ", self.u.get_freq_range()

        # Get the reference pointer to the SpectrumDisplayForm QWidget
        # Wrap the pointer as a PyQt SIP object
        #     This can now be manipulated as a PyQt4.QtGui.QWidget
        self.pysink = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget)

        self.main_win = main_window(self.pysink, self)

        self.main_win.set_frequency(self._freq)
        self.main_win.set_gain(self._gain)
        self.main_win.set_bandwidth(self._bandwidth)
        self.main_win.set_amplifier(self._amp_value)

        self.main_win.show()
コード例 #21
0
ファイル: dvbs2_tx.py プロジェクト: tuyenic/dvb_fpga
    def __init__(self, constellation, frame_type, code_rate):
        gr.top_block.__init__(self, "Dvbs2 Tx")

        ##################################################
        # Parameters
        ##################################################
        # Header is 10 bytes
        try:
            frame_length = 1.0 * BBFRAME_LENGTH[frame_type][code_rate] - 80
        except KeyError:
            raise UnknownFrameLength(frame_type, code_rate)

        #  print("Base frame length: %s" % frame_length)
        frame_length /= 8
        #  print("Base frame length: %s" % frame_length)
        assert int(
            frame_length
        ) == 1.0 * frame_length, "Frame length {0} won't work because {0}/8 = {1}!".format(
            frame_length, frame_length / 8.0)
        frame_length = int(frame_length)
        self.frame_length = frame_length

        bits_per_input, bits_per_output = get_ratio(constellation)

        ##################################################
        # Variables
        ##################################################
        self.symbol_rate = symbol_rate = 5000000
        self.taps = taps = 100
        self.samp_rate = samp_rate = symbol_rate * 2
        self.rolloff = rolloff = 0.2
        self.noise = noise = 0
        self.gain = gain = 1
        self.center_freq = center_freq = 1280e6

        ##################################################
        # Blocks
        ##################################################
        self.ldpc_encoder_input = blocks.file_sink(gr.sizeof_char * 1,
                                                   'ldpc_encoder_input.bin',
                                                   False)
        self.ldpc_encoder_input.set_unbuffered(False)
        self.fir_filter_xxx_0_0 = filter.fir_filter_ccc(
            1, (numpy.conj([
                0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 -
                1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 +
                1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 +
                1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 -
                1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 -
                1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 +
                1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 +
                1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 +
                1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 +
                1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 -
                1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j
            ] + [
                0,
            ] * (89 - 32))))
        self.fir_filter_xxx_0_0.declare_sample_delay(0)
        self.fir_filter_xxx_0 = filter.fir_filter_ccc(1, (numpy.conj([
            0,
        ] * (89 - 25) + [
            0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 +
            1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 +
            1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 +
            1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 +
            1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 -
            1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 -
            1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 +
            1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 +
            1.00000j, 0.00000 + 0.00000j
        ])))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.fft_filter_xxx_0 = filter.fft_filter_ccc(
            1, (firdes.root_raised_cosine(1.0, samp_rate, samp_rate / 2,
                                          rolloff, taps)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.dtv_dvbs2_physical_cc_0 = dtv.dvbs2_physical_cc(
            frame_type, code_rate, dtv.MOD_BPSK, dtv.PILOTS_ON, 0)
        self.dtv_dvbs2_modulator_bc_0 = dtv.dvbs2_modulator_bc(
            frame_type, code_rate, dtv.MOD_BPSK, dtv.INTERPOLATION_OFF)
        self.dtv_dvbs2_interleaver_bb_0 = dtv.dvbs2_interleaver_bb(
            frame_type, code_rate, constellation)
        self.dtv_dvb_ldpc_bb_0 = dtv.dvb_ldpc_bb(dtv.STANDARD_DVBS2,
                                                 frame_type, code_rate,
                                                 dtv.MOD_OTHER)
        self.dtv_dvb_bch_bb_0 = dtv.dvb_bch_bb(dtv.STANDARD_DVBS2, frame_type,
                                               code_rate)
        self.dtv_dvb_bbscrambler_bb_0 = dtv.dvb_bbscrambler_bb(
            dtv.STANDARD_DVBS2, frame_type, code_rate)
        self.dtv_dvb_bbheader_bb_0 = dtv.dvb_bbheader_bb(
            dtv.STANDARD_DVBS2, frame_type, code_rate, dtv.RO_0_20,
            dtv.INPUTMODE_NORMAL, dtv.INBAND_OFF, 168, 4000000)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            2, math.pi / 100.0, (firdes.root_raised_cosine(
                2 * 32, 32, 1.0 / float(2), 0.35, 11 * 2 * 32)), 32, 16, 1.5,
            1)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            math.pi / 100.0, 4, False)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
                                                 samp_rate / 10, True)
        self.blocks_sub_xx_0 = blocks.sub_cc(1)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            bits_per_input, bits_per_output, "", False, gr.GR_MSB_FIRST)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((gain, ))
        self.blocks_max_xx_0 = blocks.max_ff(1, 1)
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_float * 1,
                                                   'output.bin', False)
        self.blocks_file_sink_1.set_unbuffered(False)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_add_xx_2 = blocks.add_vcc(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.bit_interleaver_output_packed = blocks.file_sink(
            gr.sizeof_char * 1, 'bit_interleaver_output_packed.bin', False)
        self.bit_interleaver_output_packed.set_unbuffered(False)
        self.bit_interleaver_output = blocks.file_sink(
            gr.sizeof_char * 1, 'bit_interleaver_output.bin', False)
        self.bit_interleaver_output.set_unbuffered(False)
        self.bit_interleaver_input = blocks.file_sink(
            gr.sizeof_char * 1, 'bit_interleaver_input.bin', False)
        self.bit_interleaver_input.set_unbuffered(False)
        self.bch_encoder_input = blocks.file_sink(gr.sizeof_char * 1,
                                                  'bch_encoder_input.bin',
                                                  False)
        self.bch_encoder_input.set_unbuffered(False)
        self.bb_scrambler_input_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                     'bb_scrambler_input.bin',
                                                     False)
        self.bb_scrambler_input_0.set_unbuffered(False)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 255, frame_length)), False)
        self.analog_noise_source_x_1 = analog.noise_source_c(
            analog.GR_GAUSSIAN, noise, 0)
        self.analog_agc_xx_0 = analog.agc_cc(1e-4, 1.0, 1.0)
        self.analog_agc_xx_0.set_max_gain(8192)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.analog_noise_source_x_1, 0),
                     (self.blocks_add_xx_2, 1))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.dtv_dvb_bbheader_bb_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_add_xx_2, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_max_xx_0, 1))
        self.connect((self.blocks_complex_to_mag_0_0, 0),
                     (self.blocks_max_xx_0, 0))
        self.connect((self.blocks_conjugate_cc_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_max_xx_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.fft_filter_xxx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.fir_filter_xxx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.fir_filter_xxx_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.bit_interleaver_output_packed, 0))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.blocks_complex_to_mag_0_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_file_sink_1, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.blocks_conjugate_cc_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.dtv_dvb_bbheader_bb_0, 0),
                     (self.bb_scrambler_input_0, 0))
        self.connect((self.dtv_dvb_bbheader_bb_0, 0),
                     (self.dtv_dvb_bbscrambler_bb_0, 0))
        self.connect((self.dtv_dvb_bbscrambler_bb_0, 0),
                     (self.bch_encoder_input, 0))
        self.connect((self.dtv_dvb_bbscrambler_bb_0, 0),
                     (self.dtv_dvb_bch_bb_0, 0))
        self.connect((self.dtv_dvb_bch_bb_0, 0), (self.dtv_dvb_ldpc_bb_0, 0))
        self.connect((self.dtv_dvb_bch_bb_0, 0), (self.ldpc_encoder_input, 0))
        self.connect((self.dtv_dvb_ldpc_bb_0, 0),
                     (self.bit_interleaver_input, 0))
        self.connect((self.dtv_dvb_ldpc_bb_0, 0),
                     (self.dtv_dvbs2_interleaver_bb_0, 0))
        self.connect((self.dtv_dvbs2_interleaver_bb_0, 0),
                     (self.bit_interleaver_output, 0))
        self.connect((self.dtv_dvbs2_interleaver_bb_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.dtv_dvbs2_interleaver_bb_0, 0),
                     (self.dtv_dvbs2_modulator_bc_0, 0))
        self.connect((self.dtv_dvbs2_modulator_bc_0, 0),
                     (self.dtv_dvbs2_physical_cc_0, 0))
        self.connect((self.dtv_dvbs2_physical_cc_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.fft_filter_xxx_0, 0), (self.blocks_add_xx_2, 0))
        self.connect((self.fir_filter_xxx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.fir_filter_xxx_0, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.fir_filter_xxx_0_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.fir_filter_xxx_0_0, 0), (self.blocks_sub_xx_0, 1))
コード例 #22
0
    def __init__(self):
        gr.top_block.__init__(self,
                              "Superposition coding with MPSK modulation")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Superposition coding with MPSK modulation")
        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())

        ##################################################
        # Variables
        ##################################################
        self.snr_db = snr_db = 10
        self.noisevar = noisevar = 10**(-snr_db / 10)
        self.block = block = 1000
        self.alpha = alpha = .1
        self.R = R = 100e3

        ##################################################
        # Blocks
        ##################################################
        self._alpha_range = Range(0, 1, .01, .1, 200)
        self._alpha_win = RangeWidget(self._alpha_range, self.set_alpha,
                                      'P1/P', "counter_slider", float)
        self.top_layout.addWidget(self._alpha_win)
        self._snr_db_range = Range(0, 20, 1, 10, 200)
        self._snr_db_win = RangeWidget(self._snr_db_range, self.set_snr_db,
                                       'P/sigma^2 (dB)', "counter_slider",
                                       float)
        self.top_layout.addWidget(self._snr_db_win)
        self.qtgui_number_sink_0_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                       qtgui.NUM_GRAPH_HORIZ,
                                                       1)
        self.qtgui_number_sink_0_0.set_update_time(0.10)
        self.qtgui_number_sink_0_0.set_title("BER 2 (Raw)")

        labels = ['BER', '', '', '', '', '', '', '', '', '']
        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 xrange(1):
            self.qtgui_number_sink_0_0.set_min(i, 0)
            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, 0, 1,
                                       1, 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("BER1 (Raw)")

        labels = ['BER', '', '', '', '', '', '', '', '', '']
        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 xrange(1):
            self.qtgui_number_sink_0.set_min(i, 0)
            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, 0, 0, 1,
                                       1)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0.disable_legend()

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

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.digital_scrambler_bb_0_1 = digital.scrambler_bb(0x8A, 0x7F, 7)
        self.digital_scrambler_bb_0_0 = digital.scrambler_bb(0xDA, 0x7F, 7)
        self.digital_scrambler_bb_0 = digital.scrambler_bb(0x8A, 0x7F, 7)
        self.digital_psk_mod_0_1 = digital.psk.psk_mod(
            constellation_points=4,
            mod_code="gray",
            differential=True,
            samples_per_symbol=2,
            excess_bw=0.35,
            verbose=False,
            log=False,
        )
        self.digital_psk_mod_0_0 = digital.psk.psk_mod(
            constellation_points=4,
            mod_code="gray",
            differential=True,
            samples_per_symbol=2,
            excess_bw=0.35,
            verbose=False,
            log=False,
        )
        self.digital_psk_mod_0 = digital.psk.psk_mod(
            constellation_points=4,
            mod_code="gray",
            differential=True,
            samples_per_symbol=2,
            excess_bw=0.35,
            verbose=False,
            log=False,
        )
        self.digital_psk_demod_0_0 = digital.psk.psk_demod(
            constellation_points=4,
            differential=True,
            samples_per_symbol=2,
            excess_bw=0.35,
            phase_bw=6.28 / 100.0,
            timing_bw=6.28 / 100.0,
            mod_code="gray",
            verbose=False,
            log=False,
        )
        self.digital_psk_demod_0 = digital.psk.psk_demod(
            constellation_points=4,
            differential=True,
            samples_per_symbol=2,
            excess_bw=0.35,
            phase_bw=6.28 / 100.0,
            timing_bw=6.28 / 100.0,
            mod_code="gray",
            verbose=False,
            log=False,
        )
        self.digital_descrambler_bb_0_1 = digital.descrambler_bb(0xDA, 0x7F, 7)
        self.digital_descrambler_bb_0 = digital.descrambler_bb(0x8A, 0x7F, 7)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_char * 1, R, True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, R, True)
        self.blocks_sub_xx_2 = blocks.sub_cc(1)
        self.blocks_null_sink_0_1 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vcc(
            (alpha**0.5, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc(
            ((1 - alpha)**0.5, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(
            (alpha**0.5, ))
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.blks2_error_rate_0_0 = grc_blks2.error_rate(
            type='BER',
            win_size=block * 100,
            bits_per_symbol=2,
        )
        self.blks2_error_rate_0 = grc_blks2.error_rate(
            type='BER',
            win_size=block * 100,
            bits_per_symbol=2,
        )
        self.analog_random_source_x_1 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 2, block)), True)
        self.analog_random_source_x_0_0_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 2, block)), True)
        self.analog_random_source_x_0_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 2, block)), True)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 2, block)), True)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, noisevar, -42)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_0, 2))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.digital_scrambler_bb_0, 0))
        self.connect((self.analog_random_source_x_0_0, 0),
                     (self.blks2_error_rate_0, 0))
        self.connect((self.analog_random_source_x_0_0_0, 0),
                     (self.blks2_error_rate_0_0, 0))
        self.connect((self.analog_random_source_x_1, 0),
                     (self.digital_scrambler_bb_0_0, 0))
        self.connect((self.blks2_error_rate_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blks2_error_rate_0_0, 0),
                     (self.qtgui_number_sink_0_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_sub_xx_2, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.digital_psk_demod_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.digital_psk_demod_0_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.qtgui_const_sink_x_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_add_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_sub_xx_2, 1))
        self.connect((self.blocks_sub_xx_2, 0), (self.blocks_null_sink_0_1, 0))
        self.connect((self.blocks_throttle_0, 0), (self.digital_psk_mod_0, 0))
        self.connect((self.blocks_throttle_0_0, 0),
                     (self.digital_psk_mod_0_0, 0))
        self.connect((self.digital_descrambler_bb_0, 0),
                     (self.blks2_error_rate_0, 1))
        self.connect((self.digital_descrambler_bb_0, 0),
                     (self.digital_scrambler_bb_0_1, 0))
        self.connect((self.digital_descrambler_bb_0_1, 0),
                     (self.blks2_error_rate_0_0, 1))
        self.connect((self.digital_psk_demod_0, 0),
                     (self.digital_descrambler_bb_0, 0))
        self.connect((self.digital_psk_demod_0_0, 0),
                     (self.digital_descrambler_bb_0_1, 0))
        self.connect((self.digital_psk_mod_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.digital_psk_mod_0_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.digital_psk_mod_0_1, 0),
                     (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.digital_scrambler_bb_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.digital_scrambler_bb_0_0, 0),
                     (self.blocks_throttle_0_0, 0))
        self.connect((self.digital_scrambler_bb_0_1, 0),
                     (self.digital_psk_mod_0_1, 0))