Exemplo n.º 1
0
    def __init__(
        self,
        const_1_name="BPSK",
        const_2_name="QPSK",
        element_separation=0,
        file_name="eigenvalues5.csv",
        noise_voltage_1=0,
        noise_voltage_2=0,
        phi_1=70,
        phi_2=41,
        theta_1=45,
        theta_2=75,
    ):
        gr.top_block.__init__(self, "Eigenvalues Grabber")

        ##################################################
        # Parameters
        ##################################################
        self.const_1_name = const_1_name
        self.const_2_name = const_2_name
        self.element_separation = element_separation
        self.file_name = file_name
        self.noise_voltage_1 = noise_voltage_1
        self.noise_voltage_2 = noise_voltage_2
        self.phi_1 = phi_1
        self.phi_2 = phi_2
        self.theta_1 = theta_1
        self.theta_2 = theta_2

        ##################################################
        # Variables
        ##################################################
        if const_1_name == "bpsk":
            self.const_1 = const_1 = digital.constellation_bpsk().base()
        elif const_1_name == "qpsk":
            self.const_1 = const_1 = digital.constellation_qpsk().base()
        elif const_1_name == "dqpsk":
            self.const_1 = const_1 = digital.constellation_dqpsk().base()
        elif const_1_name == "8psk":
            self.const_1 = const_1 = digital.constellation_8psk().base()
        elif const_1_name == "16qam":
            self.const_1 = const_1 = digital.constellation_16qam().base()

        if const_2_name == "bpsk":
            self.const_2 = const_2 = digital.constellation_bpsk().base()
        elif const_2_name == "qpsk":
            self.const_2 = const_2 = digital.constellation_qpsk().base()
        elif const_2_name == "dqpsk":
            self.const_2 = const_2 = digital.constellation_dqpsk().base()
        elif const_2_name == "8psk":
            self.const_2 = const_2 = digital.constellation_8psk().base()
        elif const_2_name == "16qam":
            self.const_2 = const_2 = digital.constellation_16qam().base()

        self.samp_rate = samp_rate = 150000
        self.n = n = 2
        self.my = my = 4
        self.mx = mx = 4
        self.fc = fc = 436e6
        self.bps_2 = bps_2 = const_2.bits_per_symbol()
        self.bps_1 = bps_1 = const_1.bits_per_symbol()

        ##################################################
        # Blocks
        ##################################################
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(
            const_2.points(), 1
        )
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            const_1.points(), 1
        )
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True)
        self.blocks_packed_to_unpacked_xx_0_0 = blocks.packed_to_unpacked_bb(
            bps_2, gr.GR_MSB_FIRST
        )
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            bps_1, gr.GR_MSB_FIRST
        )
        self.blocks_add_xx_1 = blocks.add_vcc(mx * my)
        self.blocks_add_xx_0_0 = blocks.add_vcc(mx * my)
        self.blocks_add_xx_0 = blocks.add_vcc(mx * my)
        self.beamforming_randomsampler_0 = beamforming.randomsampler(mx * my, 8)
        self.beamforming_phasedarray_0_0 = beamforming.phasedarray(
            mx, my, theta_2, phi_2, 436e6, (299792458 / (2 * fc)), element_separation
        )
        self.beamforming_phasedarray_0 = beamforming.phasedarray(
            mx, my, theta_1, phi_1, 436e6, (299792458 / (2 * fc)), element_separation
        )
        self.beamforming_doaesprit_py_cf_0 = beamforming.doaesprit_py_cf(
            mx, my, fc, (299792458 / (2 * fc)), n, 128, file_name
        )
        self.analog_vectornoise_source_0_0 = analog.vectornoise_source(
            noise_voltage_2, mx * my
        )
        self.analog_vectornoise_source_0 = analog.vectornoise_source(
            noise_voltage_1, mx * my
        )
        self.analog_random_source_x_0_0 = blocks.vector_source_b(
            list(map(int, numpy.random.randint(0, 256, 1000))), False
        )
        self.analog_random_source_x_0 = blocks.vector_source_b(
            list(map(int, numpy.random.randint(0, 256, 1000))), False
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0, 0))
        self.connect(
            (self.analog_random_source_x_0_0, 0), (self.blocks_throttle_0_0, 0)
        )
        self.connect((self.analog_vectornoise_source_0, 0), (self.blocks_add_xx_0, 1))
        self.connect(
            (self.analog_vectornoise_source_0_0, 0), (self.blocks_add_xx_0_0, 1)
        )
        self.connect((self.beamforming_phasedarray_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.beamforming_phasedarray_0_0, 0), (self.blocks_add_xx_0_0, 0))
        self.connect(
            (self.beamforming_randomsampler_0, 0),
            (self.beamforming_doaesprit_py_cf_0, 0),
        )
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_add_xx_1, 0))
        self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_add_xx_1, 1))
        self.connect((self.blocks_add_xx_1, 0), (self.beamforming_randomsampler_0, 0))
        self.connect(
            (self.blocks_packed_to_unpacked_xx_0, 0),
            (self.digital_chunks_to_symbols_xx_0, 0),
        )
        self.connect(
            (self.blocks_packed_to_unpacked_xx_0_0, 0),
            (self.digital_chunks_to_symbols_xx_0_0, 0),
        )
        self.connect(
            (self.blocks_throttle_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)
        )
        self.connect(
            (self.blocks_throttle_0_0, 0), (self.blocks_packed_to_unpacked_xx_0_0, 0)
        )
        self.connect(
            (self.digital_chunks_to_symbols_xx_0, 0),
            (self.beamforming_phasedarray_0, 0),
        )
        self.connect(
            (self.digital_chunks_to_symbols_xx_0_0, 0),
            (self.beamforming_phasedarray_0_0, 0),
        )
    def __init__(self, fc=436e6, mx=4, my=4, n=1, noise=0, phi=50, theta=45):
        gr.top_block.__init__(self, "BER Curve Generator")

        ##################################################
        # Parameters
        ##################################################
        self.fc = fc
        self.mx = mx
        self.my = my
        self.n = n
        self.noise = noise
        self.phi = phi
        self.theta = theta

        ##################################################
        # Variables
        ##################################################
        self.const = const = digital.constellation_bpsk().base()
        self.samp_rate = samp_rate = 32000
        self.packet_len = packet_len = 1
        self.bps = bps = const.bits_per_symbol()

        ##################################################
        # Blocks
        ##################################################
        self.fec_ber_bf_0 = fec.ber_bf(False, 100, -7.0)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            const.base())
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            const.points(), 1)
        self.blocks_vector_sink_x_0_1 = blocks.vector_sink_f(1, 128)
        self.blocks_vector_sink_x_0_0 = blocks.vector_sink_b(1, 128)
        self.blocks_vector_sink_x_0 = blocks.vector_sink_b(1, 128)
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(
            bps, gr.GR_MSB_FIRST)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            bps, gr.GR_MSB_FIRST)
        self.beamforming_randomsampler_py_cc_0_0 = beamforming.randomsampler_py_cc(
            mx * my, 8)
        self.beamforming_phasedarray_py_cc_0 = beamforming.phasedarray_py_cc(
            mx, my, theta, phi, fc, noise)
        self.beamforming_doaesprit_py_cf_0 = beamforming.doaesprit_py_cf(
            128, mx, my, fc, n)
        self.beamforming_beamformer_py_cc_0 = beamforming.beamformer_py_cc(
            mx, my, fc, 0, 0, 8 * 128)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            list(map(int, numpy.random.randint(0, const.arity(), int(1e2)))),
            False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blocks_vector_sink_x_0_0, 0))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.fec_ber_bf_0, 0))
        self.connect((self.beamforming_beamformer_py_cc_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.beamforming_doaesprit_py_cf_0, 1),
                     (self.beamforming_beamformer_py_cc_0, 2))
        self.connect((self.beamforming_doaesprit_py_cf_0, 0),
                     (self.beamforming_beamformer_py_cc_0, 1))
        self.connect((self.beamforming_phasedarray_py_cc_0, 0),
                     (self.beamforming_beamformer_py_cc_0, 0))
        self.connect((self.beamforming_phasedarray_py_cc_0, 0),
                     (self.beamforming_randomsampler_py_cc_0_0, 0))
        self.connect((self.beamforming_randomsampler_py_cc_0_0, 0),
                     (self.beamforming_doaesprit_py_cf_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0),
                     (self.blocks_vector_sink_x_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0),
                     (self.fec_ber_bf_0, 1))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.beamforming_phasedarray_py_cc_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.blocks_unpacked_to_packed_xx_0, 0))
        self.connect((self.fec_ber_bf_0, 0),
                     (self.blocks_vector_sink_x_0_1, 0))
    def __init__(self, fc=436e6, mx=4, my=4, n=2, phi_2=41, theta_2=75):
        gr.top_block.__init__(self, "Eigenvalues Grabber")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Eigenvalues Grabber")
        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", "eigenvalues_grabber")

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

        ##################################################
        # Parameters
        ##################################################
        self.fc = fc
        self.mx = mx
        self.my = my
        self.n = n
        self.phi_2 = phi_2
        self.theta_2 = theta_2

        ##################################################
        # Variables
        ##################################################
        self.const_2 = const_2 = digital.constellation_16qam().base()
        self.const_1 = const_1 = digital.constellation_qpsk().base()
        self.theta_1 = theta_1 = 45
        self.samp_rate = samp_rate = 150000
        self.phi_1 = phi_1 = 70
        self.noise_voltage_2 = noise_voltage_2 = 0.05
        self.noise_voltage_1 = noise_voltage_1 = 0.05
        self.element_separation = element_separation = 0
        self.bps_2 = bps_2 = const_2.bits_per_symbol()
        self.bps_1 = bps_1 = const_1.bits_per_symbol()

        ##################################################
        # Blocks
        ##################################################
        self._theta_1_range = Range(0, 90, 1, 45, 200)
        self._theta_1_win = RangeWidget(self._theta_1_range, self.set_theta_1,
                                        'Elevation Angle', "counter_slider",
                                        float)
        self.top_grid_layout.addWidget(self._theta_1_win, 0, 0, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._phi_1_range = Range(-180, 180, 1, 70, 200)
        self._phi_1_win = RangeWidget(self._phi_1_range, self.set_phi_1,
                                      'Azimut Angle', "counter_slider", float)
        self.top_grid_layout.addWidget(self._phi_1_win, 1, 0, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._noise_voltage_2_range = Range(0, 10, 0.001, 0.05, 200)
        self._noise_voltage_2_win = RangeWidget(self._noise_voltage_2_range,
                                                self.set_noise_voltage_2,
                                                'Noise Voltage 2',
                                                "counter_slider", float)
        self.top_grid_layout.addWidget(self._noise_voltage_2_win, 3, 0, 1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._noise_voltage_1_range = Range(0, 10, 0.001, 0.05, 200)
        self._noise_voltage_1_win = RangeWidget(self._noise_voltage_1_range,
                                                self.set_noise_voltage_1,
                                                'Noise Voltage 1',
                                                "counter_slider", float)
        self.top_grid_layout.addWidget(self._noise_voltage_1_win, 2, 0, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._element_separation_range = Range(0, 10, 0.01, 0, 200)
        self._element_separation_win = RangeWidget(
            self._element_separation_range, self.set_element_separation,
            'Element separation distance [%', "counter_slider", float)
        self.top_grid_layout.addWidget(self._element_separation_win, 4, 0, 1,
                                       1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c(
            1024,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                     qtgui.TRIG_SLOPE_POS, 0.0,
                                                     0, "")
        self.qtgui_const_sink_x_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0.enable_axis_labels(True)

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

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

        self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 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)
        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, 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.digital_constellation_decoder_cb_0_0 = digital.constellation_decoder_cb(
            const_2.base())
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            const_1.base())
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(
            const_2.points(), 1)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            const_1.points(), 1)
        self.blocks_unpacked_to_packed_xx_0_0 = blocks.unpacked_to_packed_bb(
            bps_2, gr.GR_MSB_FIRST)
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(
            bps_1, gr.GR_MSB_FIRST)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_char * 1,
                                                   samp_rate, True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate,
                                                 True)
        self.blocks_packed_to_unpacked_xx_0_0 = blocks.packed_to_unpacked_bb(
            bps_2, gr.GR_MSB_FIRST)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            bps_1, gr.GR_MSB_FIRST)
        self.blocks_file_sink_0_0_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/home/grigosback/Documents/GNURadio/examples/sink2.txt', False)
        self.blocks_file_sink_0_0_0.set_unbuffered(False)
        self.blocks_file_sink_0_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/home/grigosback/Documents/GNURadio/examples/sink1.txt', False)
        self.blocks_file_sink_0_0.set_unbuffered(False)
        self.blocks_add_xx_1 = blocks.add_vcc(mx * my)
        self.blocks_add_xx_0_0 = blocks.add_vcc(mx * my)
        self.blocks_add_xx_0 = blocks.add_vcc(mx * my)
        self.beamforming_randomsampler_0 = beamforming.randomsampler(
            mx * my, 8)
        self.beamforming_phasedarray_0_0 = beamforming.phasedarray(
            mx, my, theta_2, phi_2, 436e6, (299792458 / (2 * fc)),
            element_separation)
        self.beamforming_phasedarray_0 = beamforming.phasedarray(
            mx, my, theta_1, phi_1, 436e6, (299792458 / (2 * fc)),
            element_separation)
        self.beamforming_doaesprit_py_cf_0 = beamforming.doaesprit_py_cf(
            mx, my, fc, (299792458 / (2 * fc)), n, 128)
        self.beamforming_beamformer_0_0 = beamforming.beamformer(mx, my, 1)
        self.beamforming_beamformer_0 = beamforming.beamformer(mx, my, 0)
        self.analog_vectornoise_source_0_0 = analog.vectornoise_source(
            noise_voltage_2, mx * my)
        self.analog_vectornoise_source_0 = analog.vectornoise_source(
            noise_voltage_1, mx * my)
        self.analog_random_source_x_0_0 = blocks.vector_source_b(
            list(map(int, numpy.random.randint(0, 256, 100))), True)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            list(map(int, numpy.random.randint(0, 256, 1000))), True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.beamforming_doaesprit_py_cf_0, 'doa_port'),
                         (self.beamforming_beamformer_0, 'doa_port'))
        self.msg_connect((self.beamforming_doaesprit_py_cf_0, 'doa_port'),
                         (self.beamforming_beamformer_0_0, 'doa_port'))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.analog_random_source_x_0_0, 0),
                     (self.blocks_throttle_0_0, 0))
        self.connect((self.analog_vectornoise_source_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.analog_vectornoise_source_0_0, 0),
                     (self.blocks_add_xx_0_0, 1))
        self.connect((self.beamforming_beamformer_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.beamforming_beamformer_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.beamforming_beamformer_0_0, 0),
                     (self.digital_constellation_decoder_cb_0_0, 0))
        self.connect((self.beamforming_beamformer_0_0, 0),
                     (self.qtgui_const_sink_x_0_0, 0))
        self.connect((self.beamforming_phasedarray_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.beamforming_phasedarray_0_0, 0),
                     (self.blocks_add_xx_0_0, 0))
        self.connect((self.beamforming_randomsampler_0, 0),
                     (self.beamforming_doaesprit_py_cf_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_add_xx_1, 0))
        self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_add_xx_1, 1))
        self.connect((self.blocks_add_xx_1, 0),
                     (self.beamforming_beamformer_0, 0))
        self.connect((self.blocks_add_xx_1, 0),
                     (self.beamforming_beamformer_0_0, 0))
        self.connect((self.blocks_add_xx_1, 0),
                     (self.beamforming_randomsampler_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0_0, 0),
                     (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_throttle_0_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0),
                     (self.blocks_file_sink_0_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0_0, 0),
                     (self.blocks_file_sink_0_0_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.beamforming_phasedarray_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0),
                     (self.beamforming_phasedarray_0_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.blocks_unpacked_to_packed_xx_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0_0, 0),
                     (self.blocks_unpacked_to_packed_xx_0_0, 0))
Exemplo n.º 4
0
    def __init__(self, fc=436e6, mx=4, my=4, n=1):
        gr.top_block.__init__(self, "DoA Esprit Estimation - Test")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("DoA Esprit Estimation - Test")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "doaesprit_test")

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

        ##################################################
        # Parameters
        ##################################################
        self.fc = fc
        self.mx = mx
        self.my = my
        self.n = n

        ##################################################
        # Variables
        ##################################################
        self.const = const = digital.constellation_qpsk().base()
        self.theta = theta = 45
        self.samp_rate = samp_rate = 150000
        self.phi = phi = 70
        self.noise_voltage = noise_voltage = 0
        self.element_separation = element_separation = 0
        self.bps = bps = const.bits_per_symbol()

        ##################################################
        # Blocks
        ##################################################
        self._theta_range = Range(0, 90, 1, 45, 200)
        self._theta_win = RangeWidget(self._theta_range, self.set_theta, 'Elevation Angle', "counter_slider", float)
        self.top_grid_layout.addWidget(self._theta_win, 0, 0, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._phi_range = Range(-180, 180, 1, 70, 200)
        self._phi_win = RangeWidget(self._phi_range, self.set_phi, 'Azimut Angle', "counter_slider", float)
        self.top_grid_layout.addWidget(self._phi_win, 2, 0, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._noise_voltage_range = Range(0, 10, 0.001, 0, 200)
        self._noise_voltage_win = RangeWidget(self._noise_voltage_range, self.set_noise_voltage, 'Noise Voltage', "counter_slider", float)
        self.top_grid_layout.addWidget(self._noise_voltage_win, 4, 0, 1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._element_separation_range = Range(0, 10, 0.01, 0, 200)
        self._element_separation_win = RangeWidget(self._element_separation_range, self.set_element_separation, 'Element separation distance [%', "counter_slider", float)
        self.top_grid_layout.addWidget(self._element_separation_win, 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_time_sink_x_0_0 = qtgui.time_sink_c(
            128, #size
            samp_rate, #samp_rate
            "", #name
            1 #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)

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

        self.qtgui_time_sink_x_0_0.enable_tags(True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0_0.enable_grid(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 = ['Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5',
            'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10']
        widths = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]
        colors = ['blue', 'red', 'green', 'black', 'cyan',
            'magenta', 'yellow', 'dark red', 'dark green', 'dark blue']
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
            1.0, 1.0, 1.0, 1.0, 1.0]
        styles = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
            -1, -1, -1, -1, -1]


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

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 6, 0, 1, 1)
        for r in range(6, 7):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
            128, #size
            samp_rate, #samp_rate
            "", #name
            1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

        self.qtgui_time_sink_x_0.enable_tags(True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)


        labels = ['Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5',
            'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10']
        widths = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]
        colors = ['blue', 'red', 'green', 'black', 'cyan',
            'magenta', 'yellow', 'dark red', 'dark green', 'dark blue']
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
            1.0, 1.0, 1.0, 1.0, 1.0]
        styles = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
            -1, -1, -1, -1, -1]


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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 7, 0, 1, 1)
        for r in range(7, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024, #size
            "", #name
            1 #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)


        labels = ['', '', '', '', '',
            '', '', '', '', '']
        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, 8, 0, 1, 1)
        for r in range(8, 9):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.digital_probe_mpsk_snr_est_c_0 = digital.probe_mpsk_snr_est_c(0, 10000, 0.001)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(const.base())
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(const.points(), 1)
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(bps, gr.GR_MSB_FIRST)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(bps, gr.GR_MSB_FIRST)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_file_source_0_0 = blocks.file_source(gr.sizeof_char*1, '/home/grigosback/Documents/GNURadio/examples/source.txt', True, 0, 0)
        self.blocks_file_source_0_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, '/home/grigosback/Documents/GNURadio/examples/sink.txt', False)
        self.blocks_file_sink_0_0.set_unbuffered(False)
        self.blocks_add_xx_0 = blocks.add_vcc(mx*my)
        self.beamforming_randomsampler_0 = beamforming.randomsampler(mx*my, 8)
        self.beamforming_phasedarray_0 = beamforming.phasedarray(mx, my, theta, phi, 436e6, (299792458/(2*fc)), element_separation)
        self.beamforming_doaesprit_py_cf_0 = beamforming.doaesprit_py_cf(mx, my, fc, (299792458/(2*fc)), n, 128)
        self.beamforming_beamformer_0 = beamforming.beamformer(mx, my, 0)
        self.analog_vectornoise_source_0 = analog.vectornoise_source(noise_voltage, mx*my)



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.beamforming_doaesprit_py_cf_0, 'doa_port'), (self.beamforming_beamformer_0, 'doa_port'))
        self.msg_connect((self.digital_probe_mpsk_snr_est_c_0, 'snr'), (self.blocks_message_debug_0, 'print'))
        self.connect((self.analog_vectornoise_source_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.beamforming_beamformer_0, 0), (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.beamforming_beamformer_0, 0), (self.digital_probe_mpsk_snr_est_c_0, 0))
        self.connect((self.beamforming_beamformer_0, 0), (self.qtgui_const_sink_x_0, 0))
        self.connect((self.beamforming_beamformer_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.beamforming_phasedarray_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.beamforming_randomsampler_0, 0), (self.beamforming_doaesprit_py_cf_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.beamforming_beamformer_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.beamforming_randomsampler_0, 0))
        self.connect((self.blocks_file_source_0_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_file_sink_0_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.beamforming_phasedarray_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0))
    def __init__(self, fc=436e6, mx=4, my=4, n=1, noise=0, phi=50, theta=45):
        gr.top_block.__init__(self, "BER Curve Generator")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("BER Curve Generator")
        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", "bercurve_test")

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

        ##################################################
        # Parameters
        ##################################################
        self.fc = fc
        self.mx = mx
        self.my = my
        self.n = n
        self.noise = noise
        self.phi = phi
        self.theta = theta

        ##################################################
        # Variables
        ##################################################
        self.const = const = digital.constellation_qpsk().base()
        self.samp_rate = samp_rate = 32000
        self.bps = bps = const.bits_per_symbol()

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

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

        self.qtgui_time_sink_x_0_0.enable_tags(True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0_0.enable_grid(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 = ['Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5',
            'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10']
        widths = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]
        colors = ['blue', 'red', 'green', 'black', 'cyan',
            'magenta', 'yellow', 'dark red', 'dark green', 'dark blue']
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
            1.0, 1.0, 1.0, 1.0, 1.0]
        styles = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
            -1, -1, -1, -1, -1]


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

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 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_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("")

        labels = ['', '', '', '', '',
            '', '', '', '', '']
        units = ['', '', '', '', '',
            '', '', '', '', '']
        colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"),
            ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")]
        factor = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]

        for i in range(1):
            self.qtgui_number_sink_0.set_min(i, -1)
            self.qtgui_number_sink_0.set_max(i, 1)
            self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0.set_label(i, labels[i])
            self.qtgui_number_sink_0.set_unit(i, units[i])
            self.qtgui_number_sink_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win)
        self.fec_ber_bf_0 = fec.ber_bf(False, 100, -7.0)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(const.base())
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(const.points(), 1)
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(bps, gr.GR_MSB_FIRST)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(bps, gr.GR_MSB_FIRST)
        self.beamforming_randomsampler_py_cc_0_0 = beamforming.randomsampler_py_cc(mx*my,8)
        self.beamforming_phasedarray_py_cc_0 = beamforming.phasedarray_py_cc(mx, my, theta, phi, fc, noise)
        self.beamforming_doaesprit_py_cf_0 = beamforming.doaesprit_py_cf(128, mx, my, fc, n)
        self.beamforming_beamformer_py_cc_0 = beamforming.beamformer_py_cc(mx, my, fc, 0, 0, 8*128)
        self.analog_random_source_x_0 = blocks.vector_source_b(list(map(int, numpy.random.randint(0, const.arity(), int(1e6)))), True)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.beamforming_beamformer_py_cc_0, 0), (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.beamforming_doaesprit_py_cf_0, 1), (self.beamforming_beamformer_py_cc_0, 2))
        self.connect((self.beamforming_doaesprit_py_cf_0, 0), (self.beamforming_beamformer_py_cc_0, 1))
        self.connect((self.beamforming_phasedarray_py_cc_0, 0), (self.beamforming_beamformer_py_cc_0, 0))
        self.connect((self.beamforming_phasedarray_py_cc_0, 0), (self.beamforming_randomsampler_py_cc_0_0, 0))
        self.connect((self.beamforming_randomsampler_py_cc_0_0, 0), (self.beamforming_doaesprit_py_cf_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.fec_ber_bf_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.fec_ber_bf_0, 1))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.beamforming_phasedarray_py_cc_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0))
        self.connect((self.fec_ber_bf_0, 0), (self.qtgui_number_sink_0, 0))
    def __init__(
        self,
        EbN0=0,
        esprit_decimation=128,
        fc=436e6,
        mx=4,
        my=4,
        n=1,
        phi=50,
        rs_decimation=8,
        theta=30,
    ):
        gr.top_block.__init__(self, "BER Simulation")

        ##################################################
        # Parameters
        ##################################################
        self.EbN0 = EbN0
        self.esprit_decimation = esprit_decimation
        self.fc = fc
        self.mx = mx
        self.my = my
        self.n = n
        self.phi = phi
        self.rs_decimation = rs_decimation
        self.theta = theta

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 5
        self.N_BITS = N_BITS = 1e5
        self.samp_rate = samp_rate = 32000
        self.noise_voltage = noise_voltage = 1.0 / math.sqrt(
            1 / float(sps) * 10**(float(EbN0) / 10))
        self.intdump_decim = intdump_decim = min(int(N_BITS / 10), 100000)
        self.const = const = digital.constellation_bpsk().base()
        self.alpha = alpha = 0.35
        self.SKIP = SKIP = 1000
        self.RAND_SEED = RAND_SEED = 42

        ##################################################
        # Blocks
        ##################################################
        self.lilacsat1_ber_bpsk_0 = lilacsat1_ber_bpsk(
            bfo=12000,
            callsign="",
            ip="::",
            latitude=0,
            longitude=0,
            port=7355,
            recstart="",
        )
        self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x0, 16)
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x00, 16)
        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=const,
            differential=False,
            samples_per_symbol=sps,
            pre_diff_code=True,
            excess_bw=alpha,
            verbose=False,
            log=False,
        )
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=noise_voltage,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=(
                0,
                0,
                (1 + 1j) / numpy.sqrt(2),
            ),
            noise_seed=RAND_SEED,
            block_tags=False,
        )
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, mx * my)
        self.blocks_vector_source_x_0 = blocks.vector_source_b([1], True, 1,
                                                               [])
        self.blocks_vector_sink_x_0_0_0 = blocks.vector_sink_f(1, 1024)
        self.blocks_vector_sink_x_0_0 = blocks.vector_sink_f(1, 1024)
        self.blocks_vector_sink_x_0 = blocks.vector_sink_f(1, 1024)
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, mx * my)
        self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_char * 1, SKIP)
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)
        self.blocks_not_xx_0 = blocks.not_bb()
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc(0.1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(
            1.0 / intdump_decim)
        self.blocks_integrate_xx_0 = blocks.integrate_ff(intdump_decim, 1)
        self.blocks_head_0 = blocks.head(gr.sizeof_char * 1, int(N_BITS))
        self.blocks_and_const_xx_0 = blocks.and_const_bb(1)
        self.beamforming_randomsampler_py_cc_0_0 = beamforming.randomsampler_py_cc(
            mx * my, rs_decimation)
        self.beamforming_phasedarray_py_cc_0 = beamforming.phasedarray_py_cc(
            mx, my, theta, phi, fc, 0)
        self.beamforming_doaesprit_py_cf_0 = beamforming.doaesprit_py_cf(
            128, mx, my, fc, n)
        self.beamforming_beamformer_py_cc_0 = beamforming.beamformer_py_cc(
            mx, my, fc, 0, 0, 8 * 128)

        ##################################################
        # Connections
        ##################################################
        self.connect(
            (self.beamforming_beamformer_py_cc_0, 0),
            (self.blocks_multiply_const_vxx_1, 0),
        )
        self.connect(
            (self.beamforming_doaesprit_py_cf_0, 0),
            (self.beamforming_beamformer_py_cc_0, 1),
        )
        self.connect(
            (self.beamforming_doaesprit_py_cf_0, 1),
            (self.beamforming_beamformer_py_cc_0, 2),
        )
        self.connect((self.beamforming_doaesprit_py_cf_0, 0),
                     (self.blocks_vector_sink_x_0_0, 0))
        self.connect(
            (self.beamforming_doaesprit_py_cf_0, 1),
            (self.blocks_vector_sink_x_0_0_0, 0),
        )
        self.connect(
            (self.beamforming_phasedarray_py_cc_0, 0),
            (self.blocks_vector_to_stream_0, 0),
        )
        self.connect(
            (self.beamforming_randomsampler_py_cc_0_0, 0),
            (self.beamforming_doaesprit_py_cf_0, 0),
        )
        self.connect((self.blocks_and_const_xx_0, 0),
                     (self.blocks_uchar_to_float_0, 0))
        self.connect((self.blocks_head_0, 0), (self.digital_scrambler_bb_0, 0))
        self.connect((self.blocks_integrate_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_vector_sink_x_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.lilacsat1_ber_bpsk_0, 0))
        self.connect((self.blocks_not_xx_0, 0),
                     (self.blocks_and_const_xx_0, 0))
        self.connect(
            (self.blocks_pack_k_bits_bb_0, 0),
            (self.digital_constellation_modulator_0, 0),
        )
        self.connect((self.blocks_skiphead_0, 0), (self.blocks_not_xx_0, 0))
        self.connect(
            (self.blocks_stream_to_vector_0, 0),
            (self.beamforming_beamformer_py_cc_0, 0),
        )
        self.connect(
            (self.blocks_stream_to_vector_0, 0),
            (self.beamforming_randomsampler_py_cc_0_0, 0),
        )
        self.connect((self.blocks_uchar_to_float_0, 0),
                     (self.blocks_integrate_xx_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_head_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect(
            (self.digital_constellation_modulator_0, 0),
            (self.beamforming_phasedarray_py_cc_0, 0),
        )
        self.connect((self.digital_descrambler_bb_0, 0),
                     (self.blocks_skiphead_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.digital_descrambler_bb_0, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0),
                     (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.digital_scrambler_bb_0, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.lilacsat1_ber_bpsk_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))