Ejemplo n.º 1
0
    def __init__(self, alpha=0):
        gr.hier_block2.__init__(
            self, "Amplitude Balance",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.alpha = alpha

        ##################################################
        # Blocks
        ##################################################
        self.blocks_rms_xx0 = blocks.rms_ff(alpha)
        self.blocks_rms_xx = blocks.rms_ff(alpha)
        self.blocks_multiply_vxx1 = blocks.multiply_vff(1)
        self.blocks_float_to_complex = blocks.float_to_complex(1)
        self.blocks_divide_xx = blocks.divide_ff(1)
        self.blocks_complex_to_float = blocks.complex_to_float(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_float_to_complex, 0), (self, 0))
        self.connect((self, 0), (self.blocks_complex_to_float, 0))
        self.connect((self.blocks_complex_to_float, 0), (self.blocks_rms_xx, 0))
        self.connect((self.blocks_complex_to_float, 1), (self.blocks_rms_xx0, 0))
        self.connect((self.blocks_rms_xx, 0), (self.blocks_divide_xx, 0))
        self.connect((self.blocks_rms_xx0, 0), (self.blocks_divide_xx, 1))
        self.connect((self.blocks_complex_to_float, 0), (self.blocks_float_to_complex, 0))
        self.connect((self.blocks_complex_to_float, 1), (self.blocks_multiply_vxx1, 1))
        self.connect((self.blocks_divide_xx, 0), (self.blocks_multiply_vxx1, 0))
        self.connect((self.blocks_multiply_vxx1, 0), (self.blocks_float_to_complex, 1))
Ejemplo n.º 2
0
    def __init__(self, alpha=1e-2, reference=0.5):
        gr.hier_block2.__init__(
            self,
            "RMS AGC",
            gr.io_signature(1, 1, gr.sizeof_float * 1),
            gr.io_signature(1, 1, gr.sizeof_float * 1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.alpha = alpha
        self.reference = reference

        ##################################################
        # Blocks
        ##################################################
        self.blocks_rms_xx_0 = blocks.rms_ff(alpha)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(1.0 /
                                                                    reference)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_ff(1e-20)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_divide_xx_0, 0), (self, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_rms_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self, 0), (self.blocks_divide_xx_0, 0))
        self.connect((self, 0), (self.blocks_rms_xx_0, 0))
Ejemplo n.º 3
0
    def __init__(self, alpha=0):
        gr.hier_block2.__init__(
            self,
            "Amplitude Balance",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.alpha = alpha

        ##################################################
        # Blocks
        ##################################################
        self.blocks_rms_xx0 = blocks.rms_ff(alpha)
        self.blocks_rms_xx = blocks.rms_ff(alpha)
        self.blocks_multiply_vxx1 = blocks.multiply_vff(1)
        self.blocks_float_to_complex = blocks.float_to_complex(1)
        self.blocks_divide_xx = blocks.divide_ff(1)
        self.blocks_complex_to_float = blocks.complex_to_float(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_float_to_complex, 0), (self, 0))
        self.connect((self, 0), (self.blocks_complex_to_float, 0))
        self.connect((self.blocks_complex_to_float, 0),
                     (self.blocks_rms_xx, 0))
        self.connect((self.blocks_complex_to_float, 1),
                     (self.blocks_rms_xx0, 0))
        self.connect((self.blocks_rms_xx, 0), (self.blocks_divide_xx, 0))
        self.connect((self.blocks_rms_xx0, 0), (self.blocks_divide_xx, 1))
        self.connect((self.blocks_complex_to_float, 0),
                     (self.blocks_float_to_complex, 0))
        self.connect((self.blocks_complex_to_float, 1),
                     (self.blocks_multiply_vxx1, 1))
        self.connect((self.blocks_divide_xx, 0),
                     (self.blocks_multiply_vxx1, 0))
        self.connect((self.blocks_multiply_vxx1, 0),
                     (self.blocks_float_to_complex, 1))
Ejemplo n.º 4
0
    def test_ff(self):
        amp = 2
        src_data = sig_source_f(1, 0.01, amp, 200)
        N = 750000

        expected_data = amp/math.sqrt(2.0)

        src = blocks.vector_source_f(src_data, True)
        head = blocks.head(gr.sizeof_float, N)
        op = blocks.rms_ff(0.0001)
        dst = blocks.vector_sink_f()

        self.tb.connect(src, head, op, dst)
        self.tb.run()

        dst_data = dst.data()
        self.assertAlmostEqual(dst_data[-1], expected_data, 4)
Ejemplo n.º 5
0
    def test_ff(self):
        amp = 2
        src_data = sig_source_f(1, 0.01, amp, 200)
        N = 750000

        expected_data = amp / math.sqrt(2.0)

        src = blocks.vector_source_f(src_data, True)
        head = blocks.head(gr.sizeof_float, N)
        op = blocks.rms_ff(0.0001)
        dst = blocks.vector_sink_f()

        self.tb.connect(src, head, op, dst)
        self.tb.run()

        dst_data = dst.data()
        self.assertAlmostEqual(dst_data[-1], expected_data, 4)
Ejemplo n.º 6
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Received Signal")

        ##################################################
        # Variables
        ##################################################
        self.samples_per_bit = samples_per_bit = 40960
        self.samp_rate = samp_rate = 800000
        self._b_power_config = ConfigParser.ConfigParser()
        self._b_power_config.read(
            '/Users/jaredweinstein/Desktop/CS434Project/src/config')
        try:
            b_power = self._b_power_config.getfloat('power', 'b')
        except:
            b_power = 1
        self.b_power = b_power
        self._a_power_config = ConfigParser.ConfigParser()
        self._a_power_config.read(
            '/Users/jaredweinstein/Desktop/CS434Project/src/config')
        try:
            a_power = self._a_power_config.getfloat('power', 'a')
        except:
            a_power = .5
        self.a_power = a_power

        ##################################################
        # Blocks
        ##################################################
        self.n = self.n = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.n.AddPage(grc_wxgui.Panel(self.n), "carrier")
        self.n.AddPage(grc_wxgui.Panel(self.n), "a")
        self.n.AddPage(grc_wxgui.Panel(self.n), "ab")
        self.Add(self.n)
        self.wxgui_scopesink2_4 = scopesink2.scope_sink_f(
            self.n.GetPage(2).GetWin(),
            title='A+B backscatter signal',
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.n.GetPage(2).Add(self.wxgui_scopesink2_4.win)
        self.wxgui_scopesink2_3 = scopesink2.scope_sink_f(
            self.n.GetPage(2).GetWin(),
            title='B source data',
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.n.GetPage(2).Add(self.wxgui_scopesink2_3.win)
        self.wxgui_scopesink2_2 = scopesink2.scope_sink_f(
            self.n.GetPage(1).GetWin(),
            title='A source data',
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.n.GetPage(1).Add(self.wxgui_scopesink2_2.win)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_f(
            self.n.GetPage(0).GetWin(),
            title='Carrier Wave',
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.n.GetPage(0).Add(self.wxgui_scopesink2_1.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.n.GetPage(1).GetWin(),
            title='A Backscatter Signal',
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.n.GetPage(1).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_numbersink2_1 = numbersink2.number_sink_f(
            self.n.GetPage(0).GetWin(),
            unit='Units',
            minval=-100,
            maxval=100,
            factor=1.0,
            decimal_places=10,
            ref_level=0,
            sample_rate=samp_rate,
            number_rate=15,
            average=False,
            avg_alpha=None,
            label='A Power',
            peak_hold=False,
            show_gauge=True,
        )
        self.n.GetPage(0).Add(self.wxgui_numbersink2_1.win)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
            self.n.GetPage(0).GetWin(),
            unit='Units',
            minval=-100,
            maxval=100,
            factor=1.0,
            decimal_places=10,
            ref_level=0,
            sample_rate=samp_rate,
            number_rate=15,
            average=False,
            avg_alpha=None,
            label='Ivan Number Sink',
            peak_hold=False,
            show_gauge=True,
        )
        self.n.GetPage(0).Add(self.wxgui_numbersink2_0.win)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
                                                 samp_rate, True)
        self.blocks_rms_xx_0 = blocks.rms_ff(0.0001)
        self.blocks_repeat_3 = blocks.repeat(gr.sizeof_int * 1, 3)
        self.blocks_repeat_2 = blocks.repeat(gr.sizeof_int * 1, 2)
        self.blocks_repeat_1 = blocks.repeat(gr.sizeof_float * 1, 40960)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float * 1, 40960)
        self.blocks_multiply_xx_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((1, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff(
            (a_power, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (b_power, ))
        self.blocks_int_to_float_1 = blocks.int_to_float(1, 1)
        self.blocks_int_to_float_0 = blocks.int_to_float(1, 1)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_float * 1,
            '/Users/jaredweinstein/Desktop/CS434Project/src/carrier', True)
        self.blocks_file_sink_4 = blocks.file_sink(
            gr.sizeof_float * 1,
            '/Users/jaredweinstein/Desktop/CS434Project/output/b_srcdata',
            False)
        self.blocks_file_sink_4.set_unbuffered(False)
        self.blocks_file_sink_3 = blocks.file_sink(
            gr.sizeof_float * 1,
            '/Users/jaredweinstein/Desktop/CS434Project/output/ab_backscatter',
            False)
        self.blocks_file_sink_3.set_unbuffered(False)
        self.blocks_file_sink_2 = blocks.file_sink(
            gr.sizeof_float * 1,
            '/Users/jaredweinstein/Desktop/CS434Project/output/a_srcdata',
            False)
        self.blocks_file_sink_2.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_float * 1,
            '/Users/jaredweinstein/Desktop/CS434Project/output/a_backscatter',
            False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_add_xx_1 = blocks.add_vff(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.blocks_abs_xx_0 = blocks.abs_ff(1)
        self.analog_random_source_x_1 = blocks.vector_source_i(
            map(int, numpy.random.randint(0, 2, 1000)), True)
        self.analog_random_source_x_0 = blocks.vector_source_i(
            map(int, numpy.random.randint(0, 2, 1000)), True)
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, a_power)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.wxgui_numbersink2_1, 0))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blocks_repeat_3, 0))
        self.connect((self.analog_random_source_x_1, 0),
                     (self.blocks_repeat_2, 0))
        self.connect((self.blocks_abs_xx_0, 0),
                     (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_add_xx_1, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.blocks_file_sink_3, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.wxgui_scopesink2_4, 0))
        self.connect((self.blocks_file_source_0, 0), (self.blocks_abs_xx_0, 0))
        self.connect((self.blocks_int_to_float_0, 0),
                     (self.blocks_file_sink_2, 0))
        self.connect((self.blocks_int_to_float_0, 0),
                     (self.blocks_repeat_0, 0))
        self.connect((self.blocks_int_to_float_0, 0),
                     (self.wxgui_scopesink2_2, 0))
        self.connect((self.blocks_int_to_float_1, 0),
                     (self.blocks_file_sink_4, 0))
        self.connect((self.blocks_int_to_float_1, 0),
                     (self.blocks_repeat_1, 0))
        self.connect((self.blocks_int_to_float_1, 0),
                     (self.wxgui_scopesink2_3, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_add_xx_1, 1))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_2, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_2, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_2, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_2, 0),
                     (self.blocks_rms_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_2, 0),
                     (self.wxgui_scopesink2_1, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_multiply_xx_1, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_repeat_1, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_repeat_2, 0),
                     (self.blocks_int_to_float_1, 0))
        self.connect((self.blocks_repeat_3, 0),
                     (self.blocks_int_to_float_0, 0))
        self.connect((self.blocks_rms_xx_0, 0), (self.wxgui_numbersink2_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_scopesink2_0, 0))
Ejemplo n.º 7
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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


        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 64000
        self.n = n = 1

        ##################################################
        # Blocks
        ##################################################
        self._n_range = Range(1, 16, 1, 1, 200)
        self._n_win = RangeWidget(self._n_range, self.set_n, "n", "counter_slider", float)
        self.top_grid_layout.addWidget(self._n_win)
        self.aba = Qt.QTabWidget()
        self.aba_widget_0 = Qt.QWidget()
        self.aba_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.aba_widget_0)
        self.aba_grid_layout_0 = Qt.QGridLayout()
        self.aba_layout_0.addLayout(self.aba_grid_layout_0)
        self.aba.addTab(self.aba_widget_0, 'Time')
        self.aba_widget_1 = Qt.QWidget()
        self.aba_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.aba_widget_1)
        self.aba_grid_layout_1 = Qt.QGridLayout()
        self.aba_layout_1.addLayout(self.aba_grid_layout_1)
        self.aba.addTab(self.aba_widget_1, 'Freq')
        self.aba_widget_2 = Qt.QWidget()
        self.aba_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.aba_widget_2)
        self.aba_grid_layout_2 = Qt.QGridLayout()
        self.aba_layout_2.addLayout(self.aba_grid_layout_2)
        self.aba.addTab(self.aba_widget_2, 'RSR')
        self.top_grid_layout.addWidget(self.aba)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
        	1024, #size
        	samp_rate, #samp_rate
        	"Sinais no Tempo", #name
        	3 #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-1, 1)

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

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

        if not True:
          self.qtgui_time_sink_x_1.disable_legend()

        labels = ['x(t)', 'x^(kTs)', 'x^(t)', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

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

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.aba_grid_layout_0.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	1024, #size
        	samp_rate, #samp_rate
        	"Erro de Quant.", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        if not True:
          self.qtgui_time_sink_x_0.disable_legend()

        labels = ['q(kTs)', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.aba_grid_layout_2.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_number_sink_0 = qtgui.number_sink(
            gr.sizeof_float,
            0,
            qtgui.NUM_GRAPH_HORIZ,
            2
        )
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("RSR da Quant.")

        labels = ['RSR_q', 'Pot_x', '', '', '',
                  '', '', '', '', '']
        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(2):
            self.qtgui_number_sink_0.set_min(i, -1)
            self.qtgui_number_sink_0.set_max(i, 100)
            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.aba_grid_layout_2.addWidget(self._qtgui_number_sink_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"", #name
        	3 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(True)

        if not True:
          self.qtgui_freq_sink_x_0.disable_legend()

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

        labels = ['x(t)', 'x^(kTs)', 'x^(t)', '', '',
                  '', '', '', '', '']
        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(3):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.aba_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_win)
        self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass(
        	1, samp_rate, 4000, 500, firdes.WIN_HAMMING, 6.76))
        self.channels_quantizer_0 = channels.quantizer(n)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_rms_xx_0_0 = blocks.rms_ff(0.0001)
        self.blocks_rms_xx_0 = blocks.rms_ff(0.0001)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(20, 1, 0)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.analog_sig_source_x_0_1_1 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 3000, 0.2, 0)
        self.analog_sig_source_x_0_1_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 2400, 0.2, 0)
        self.analog_sig_source_x_0_1 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1800, 0.2, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1200, 0.2, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 600, 0.2, 0)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.analog_sig_source_x_0_1, 0), (self.blocks_add_xx_0, 2))
        self.connect((self.analog_sig_source_x_0_1_0, 0), (self.blocks_add_xx_0, 3))
        self.connect((self.analog_sig_source_x_0_1_1, 0), (self.blocks_add_xx_0, 4))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_rms_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.qtgui_time_sink_x_1, 0))
        self.connect((self.blocks_divide_xx_0, 0), (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0), (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_rms_xx_0, 0), (self.blocks_divide_xx_0, 0))
        self.connect((self.blocks_rms_xx_0, 0), (self.qtgui_number_sink_0, 1))
        self.connect((self.blocks_rms_xx_0_0, 0), (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_sub_xx_0, 0), (self.blocks_rms_xx_0_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.channels_quantizer_0, 0))
        self.connect((self.channels_quantizer_0, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.channels_quantizer_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.channels_quantizer_0, 0), (self.qtgui_freq_sink_x_0, 1))
        self.connect((self.channels_quantizer_0, 0), (self.qtgui_time_sink_x_1, 1))
        self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_0, 2))
        self.connect((self.low_pass_filter_0, 0), (self.qtgui_time_sink_x_1, 2))
Ejemplo n.º 8
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 200000
        self.R = R = .25
        self.fcut = fcut = R * samp_rate / 2
        self.An = An = 1

        ##################################################
        # Blocks
        ##################################################
        self._An_range = Range(0, 5, 0.2, 1, 200)
        self._An_win = RangeWidget(self._An_range, self.set_An, "An",
                                   "counter_slider", float)
        self.top_grid_layout.addWidget(self._An_win)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0_0.disable_legend()

        labels = ['n(t)', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

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

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

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

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['n_f(t)', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "red", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 1, 2, 1,
                                       1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_number_sink_0_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                       qtgui.NUM_GRAPH_VERT, 1)
        self.qtgui_number_sink_0_0.set_update_time(0.10)
        self.qtgui_number_sink_0_0.set_title("")

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

        self.qtgui_number_sink_0_0.enable_autoscale(False)
        self._qtgui_number_sink_0_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_win, 0, 3,
                                       1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_VERT, 1)
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("")

        labels = ['RMS filtered', '', '', '', '', '', '', '', '', '']
        units = ['', '', '', '', '', '', '', '', '', '']
        colors = [("blue", "red"), ("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, -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, 1, 3, 1,
                                       1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_histogram_sink_x_0_0 = qtgui.histogram_sink_f(
            1024, 100, -10, 10, "", 1)

        self.qtgui_histogram_sink_x_0_0.set_update_time(0.10)
        self.qtgui_histogram_sink_x_0_0.enable_autoscale(False)
        self.qtgui_histogram_sink_x_0_0.enable_accumulate(False)
        self.qtgui_histogram_sink_x_0_0.enable_grid(False)
        self.qtgui_histogram_sink_x_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_histogram_sink_x_0_0.disable_legend()

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

        self._qtgui_histogram_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_histogram_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_histogram_sink_x_0_0_win, 0,
                                       0, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f(
            1024, 100, -10, 10, "", 1)

        self.qtgui_histogram_sink_x_0.set_update_time(0.10)
        self.qtgui_histogram_sink_x_0.enable_autoscale(False)
        self.qtgui_histogram_sink_x_0.enable_accumulate(False)
        self.qtgui_histogram_sink_x_0.enable_grid(False)
        self.qtgui_histogram_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_histogram_sink_x_0.disable_legend()

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

        self._qtgui_histogram_sink_x_0_win = sip.wrapinstance(
            self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_histogram_sink_x_0_win, 1,
                                       0, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_f(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_0.set_y_axis(-160, 10)
        self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0.enable_grid(False)
        self.qtgui_freq_sink_x_0_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(True)

        if not True:
            self.qtgui_freq_sink_x_0_0.disable_legend()

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

        labels = ['N(f)', '', '', '', '', '', '', '', '', '']
        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, 0, 1,
                                       1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-160, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(True)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 1, 1, 1,
                                       1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.low_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate, fcut, 100, firdes.WIN_HAMMING, 6.76))
        self.blocks_rms_xx_0_0 = blocks.rms_ff(0.0001)
        self.blocks_rms_xx_0 = blocks.rms_ff(0.0001)
        self.analog_noise_source_x_0 = analog.noise_source_f(
            analog.GR_GAUSSIAN, An, 0)
        self._R_range = Range(0, 1, 0.05, .25, 200)
        self._R_win = RangeWidget(self._R_range, self.set_R, "R",
                                  "counter_slider", float)
        self.top_grid_layout.addWidget(self._R_win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_rms_xx_0_0, 0))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.qtgui_histogram_sink_x_0_0, 0))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_rms_xx_0, 0), (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_rms_xx_0_0, 0),
                     (self.qtgui_number_sink_0_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.blocks_rms_xx_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.qtgui_histogram_sink_x_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
Ejemplo n.º 9
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        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.samp_rate = samp_rate = 200000
        self.Gain = Gain = 1

        ##################################################
        # Blocks
        ##################################################
        self.aba = Qt.QTabWidget()
        self.aba_widget_0 = Qt.QWidget()
        self.aba_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.aba_widget_0)
        self.aba_grid_layout_0 = Qt.QGridLayout()
        self.aba_layout_0.addLayout(self.aba_grid_layout_0)
        self.aba.addTab(self.aba_widget_0, "X")
        self.aba_widget_1 = Qt.QWidget()
        self.aba_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.aba_widget_1)
        self.aba_grid_layout_1 = Qt.QGridLayout()
        self.aba_layout_1.addLayout(self.aba_grid_layout_1)
        self.aba.addTab(self.aba_widget_1, "I")
        self.aba_widget_2 = Qt.QWidget()
        self.aba_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.aba_widget_2)
        self.aba_grid_layout_2 = Qt.QGridLayout()
        self.aba_layout_2.addLayout(self.aba_grid_layout_2)
        self.aba.addTab(self.aba_widget_2, "RMS")
        self.top_layout.addWidget(self.aba)
        self._Gain_range = Range(1, 10, 0.5, 1, 200)
        self._Gain_win = RangeWidget(self._Gain_range, self.set_Gain, "Gain",
                                     "counter_slider", float)
        self.aba_layout_0.addWidget(self._Gain_win)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-10, 10)

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

        self.qtgui_time_sink_x_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_AUTO,
                                                    qtgui.TRIG_SLOPE_POS, 0.0,
                                                    0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0_0.enable_grid(True)
        self.qtgui_time_sink_x_0_0.enable_control_panel(True)

        if not True:
            self.qtgui_time_sink_x_0_0.disable_legend()

        labels = ["I", "", "", "", "", "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "red", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

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

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.aba_layout_0.addWidget(self._qtgui_time_sink_x_0_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-10, 10)

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

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_AUTO,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(True)
        self.qtgui_time_sink_x_0.enable_control_panel(True)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ["I", "", "", "", "", "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "red", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.aba_layout_1.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_freq_sink_x_0_1_0 = qtgui.freq_sink_f(
            4096,  #size
            firdes.WIN_RECTANGULAR,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_1_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_1_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                      0.0, 0, "")
        self.qtgui_freq_sink_x_0_1_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_1_0.enable_grid(True)
        self.qtgui_freq_sink_x_0_1_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_1_0.enable_control_panel(True)

        if not True:
            self.qtgui_freq_sink_x_0_1_0.disable_legend()

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

        labels = ["", "", "", "", "", "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "red", "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_1_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_1_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_1_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_1_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_1_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_1_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_1_0.pyqwidget(), Qt.QWidget)
        self.aba_layout_0.addWidget(self._qtgui_freq_sink_x_0_1_0_win)
        self.qtgui_freq_sink_x_0_1 = qtgui.freq_sink_f(
            4096,  #size
            firdes.WIN_RECTANGULAR,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_1.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_1.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_0_1.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_1.enable_grid(True)
        self.qtgui_freq_sink_x_0_1.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_1.enable_control_panel(True)

        if not True:
            self.qtgui_freq_sink_x_0_1.disable_legend()

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

        labels = ["", "", "", "", "", "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "red", "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_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_1.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_1.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_1.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.aba_layout_1.addWidget(self._qtgui_freq_sink_x_0_1_win)
        self.low_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.low_pass(Gain, samp_rate, 2000, 200, firdes.WIN_HAMMING,
                            6.76))
        self.blocks_rms_xx_0_0_3_1_0_1 = blocks.rms_ff(0.0001)
        self.blocks_rms_xx_0_0_3_1_0_0_1_0 = blocks.rms_ff(0.0001)
        self.blocks_rms_xx_0_0_3_1_0_0_1 = blocks.rms_ff(0.0001)
        self.blocks_rms_xx_0_0_3_1_0_0_0_1 = blocks.rms_ff(0.0001)
        self.blocks_rms_xx_0_0_3_1_0_0_0_0_0 = blocks.rms_ff(0.0001)
        self.blocks_rms_xx_0_0_3_1_0_0_0_0 = blocks.rms_ff(0.0001)
        self.blocks_rms_xx_0_0_3_1_0_0_0 = blocks.rms_ff(0.0001)
        self.blocks_rms_xx_0_0_3_1_0_0 = blocks.rms_ff(0.0001)
        self.blocks_rms_xx_0_0_3_1_0 = blocks.rms_ff(0.0001)
        self.blocks_multiply_xx_0_0_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.band_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.band_pass(1, samp_rate, 15000, 17000, 200,
                             firdes.WIN_HAMMING, 6.76))
        self.analog_sig_source_x_1_0_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, 16000, 4, 0)
        self.analog_sig_source_x_1_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, 10000, 2, 0)
        self.analog_sig_source_x_1 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, 6000, 5, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_TRI_WAVE, 100, 2, -1)
        self.RMS_1 = qtgui.number_sink(gr.sizeof_float, 0,
                                       qtgui.NUM_GRAPH_HORIZ, 1)
        self.RMS_1.set_update_time(0.10)
        self.RMS_1.set_title("")

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

        self.RMS_1.enable_autoscale(True)
        self._RMS_1_win = sip.wrapinstance(self.RMS_1.pyqwidget(), Qt.QWidget)
        self.aba_layout_0.addWidget(self._RMS_1_win)
        self.RMS_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                       qtgui.NUM_GRAPH_HORIZ, 7)
        self.RMS_0.set_update_time(0.10)
        self.RMS_0.set_title("")

        labels = ["A", "B", "C", "D", "E", "F", "G", "", "", ""]
        units = ["V", "V", "V", "V", "V", "V", "V", "", "", ""]
        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(7):
            self.RMS_0.set_min(i, 0)
            self.RMS_0.set_max(i, 4)
            self.RMS_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.RMS_0.set_label(i, "Data {0}".format(i))
            else:
                self.RMS_0.set_label(i, labels[i])
            self.RMS_0.set_unit(i, units[i])
            self.RMS_0.set_factor(i, factor[i])

        self.RMS_0.enable_autoscale(False)
        self._RMS_0_win = sip.wrapinstance(self.RMS_0.pyqwidget(), Qt.QWidget)
        self.aba_layout_2.addWidget(self._RMS_0_win)
        self.RMS = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ,
                                     1)
        self.RMS.set_update_time(0.10)
        self.RMS.set_title("")

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

        self.RMS.enable_autoscale(True)
        self._RMS_win = sip.wrapinstance(self.RMS.pyqwidget(), Qt.QWidget)
        self.aba_layout_1.addWidget(self._RMS_win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_rms_xx_0_0_3_1_0_0, 0))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_rms_xx_0_0_3_1_0_0_0, 0))
        self.connect((self.analog_sig_source_x_1_0, 0),
                     (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.analog_sig_source_x_1_0, 0),
                     (self.blocks_rms_xx_0_0_3_1_0_0_0_0, 0))
        self.connect((self.analog_sig_source_x_1_0_0, 0),
                     (self.blocks_multiply_xx_0_0_0, 1))
        self.connect((self.analog_sig_source_x_1_0_0, 0),
                     (self.blocks_rms_xx_0_0_3_1_0_0_0_0_0, 0))
        self.connect((self.band_pass_filter_0, 0),
                     (self.blocks_multiply_xx_0_0_0, 0))
        self.connect((self.band_pass_filter_0, 0),
                     (self.blocks_rms_xx_0_0_3_1_0_0_1_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_rms_xx_0_0_3_1_0_0_1, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.band_pass_filter_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.blocks_rms_xx_0_0_3_1_0_0_0_1, 0))
        self.connect((self.blocks_multiply_xx_0_0_0, 0),
                     (self.blocks_rms_xx_0_0_3_1_0_1, 0))
        self.connect((self.blocks_multiply_xx_0_0_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_multiply_xx_0_0_0, 0),
                     (self.qtgui_freq_sink_x_0_1_0, 0))
        self.connect((self.blocks_multiply_xx_0_0_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_rms_xx_0_0_3_1_0, 0), (self.RMS, 0))
        self.connect((self.blocks_rms_xx_0_0_3_1_0_0, 0), (self.RMS_0, 0))
        self.connect((self.blocks_rms_xx_0_0_3_1_0_0_0, 0), (self.RMS_0, 1))
        self.connect((self.blocks_rms_xx_0_0_3_1_0_0_0_0, 0), (self.RMS_0, 3))
        self.connect((self.blocks_rms_xx_0_0_3_1_0_0_0_0_0, 0),
                     (self.RMS_0, 6))
        self.connect((self.blocks_rms_xx_0_0_3_1_0_0_0_1, 0), (self.RMS_0, 4))
        self.connect((self.blocks_rms_xx_0_0_3_1_0_0_1, 0), (self.RMS_0, 2))
        self.connect((self.blocks_rms_xx_0_0_3_1_0_0_1_0, 0), (self.RMS_0, 5))
        self.connect((self.blocks_rms_xx_0_0_3_1_0_1, 0), (self.RMS_1, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_rms_xx_0_0_3_1_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.qtgui_freq_sink_x_0_1, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
Ejemplo n.º 10
0
 def init(self, alpha=0.01):
     self.gr_block = blocks.rms_ff(alpha)
Ejemplo n.º 11
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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


        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 10000
        self.atraso = atraso = 190
        self.K = K = 1000

        ##################################################
        # Blocks
        ##################################################
        self._atraso_range = Range(0, 200, 1, 190, 200)
        self._atraso_win = RangeWidget(self._atraso_range, self.set_atraso, "atraso", "counter_slider", float)
        self.top_grid_layout.addWidget(self._atraso_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._K_range = Range(0, 2000, 1, 1000, 200)
        self._K_win = RangeWidget(self._K_range, self.set_K, "K", "counter_slider", float)
        self.top_grid_layout.addWidget(self._K_win, 2, 0, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f(
        	512, #size
        	samp_rate, #samp_rate
        	"DPCM", #name
        	3 #number of inputs
        )
        self.qtgui_time_sink_x_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1)

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

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

        if not True:
          self.qtgui_time_sink_x_1_0.disable_legend()

        labels = ['RX', 'TX', 'erro', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "black", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

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

        self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win, 0, 1, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
        	512, #size
        	samp_rate, #samp_rate
        	"PCM", #name
        	3 #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-1, 1)

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

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

        if not True:
          self.qtgui_time_sink_x_1.disable_legend()

        labels = ['RX', 'TX', 'erro', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

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

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win, 0, 0, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	512, #size
        	samp_rate, #samp_rate
        	"Residuos", #name
        	2 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        if not True:
          self.qtgui_time_sink_x_0.disable_legend()

        labels = ['Delta[k]', 'Delta_quant[k]', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 1, 0, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_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("SNR PCM")

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

        self.qtgui_number_sink_0_0.enable_autoscale(False)
        self._qtgui_number_sink_0_0_win = sip.wrapinstance(self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_win, 3, 1, 1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.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("SNR DPCM")

        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 xrange(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, 2, 1, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
        	1024, #size
        	"Quantizador", #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_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 1, 1, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.iir_filter_xxx_0 = filter.iir_filter_ffd(([1.0/K]), ([1.0, -1.99, 0.990025]), False)
        self.fir_filter_xxx_0 = filter.fir_filter_fff(1, (0,2,-1))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.channels_quantizer_0_0 = channels.quantizer(3)
        self.channels_quantizer_0 = channels.quantizer(7)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True)
        self.blocks_sub_xx_2 = blocks.sub_ff(1)
        self.blocks_sub_xx_1 = blocks.sub_ff(1)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_rms_xx_0_1 = blocks.rms_ff(0.0001)
        self.blocks_rms_xx_0_0_0 = blocks.rms_ff(0.0001)
        self.blocks_rms_xx_0_0 = blocks.rms_ff(0.0001)
        self.blocks_rms_xx_0 = blocks.rms_ff(0.0001)
        self.blocks_nlog10_ff_0_0 = blocks.nlog10_ff(20, 1, 0)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(20, 1, 0)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((K, ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_divide_xx_0_0 = blocks.divide_ff(1)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, atraso)
        self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 50, 1, 0)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_rms_xx_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_sub_xx_2, 1))
        self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_1_0, 1))
        self.connect((self.blocks_divide_xx_0, 0), (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_divide_xx_0_0, 0), (self.blocks_nlog10_ff_0_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_const_sink_x_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.channels_quantizer_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0), (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_nlog10_ff_0_0, 0), (self.qtgui_number_sink_0_0, 0))
        self.connect((self.blocks_rms_xx_0, 0), (self.blocks_divide_xx_0, 0))
        self.connect((self.blocks_rms_xx_0_0, 0), (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_rms_xx_0_0_0, 0), (self.blocks_divide_xx_0_0, 1))
        self.connect((self.blocks_rms_xx_0_1, 0), (self.blocks_divide_xx_0_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_sub_xx_1, 0), (self.blocks_rms_xx_0_0_0, 0))
        self.connect((self.blocks_sub_xx_1, 0), (self.qtgui_time_sink_x_1, 2))
        self.connect((self.blocks_sub_xx_2, 0), (self.blocks_rms_xx_0_0, 0))
        self.connect((self.blocks_sub_xx_2, 0), (self.qtgui_time_sink_x_1_0, 2))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_rms_xx_0_1, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_sub_xx_1, 0))
        self.connect((self.blocks_throttle_0, 0), (self.channels_quantizer_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.fir_filter_xxx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_1, 1))
        self.connect((self.channels_quantizer_0, 0), (self.blocks_sub_xx_1, 1))
        self.connect((self.channels_quantizer_0, 0), (self.qtgui_time_sink_x_1, 0))
        self.connect((self.channels_quantizer_0_0, 0), (self.blocks_float_to_complex_0, 1))
        self.connect((self.channels_quantizer_0_0, 0), (self.iir_filter_xxx_0, 0))
        self.connect((self.channels_quantizer_0_0, 0), (self.qtgui_time_sink_x_0, 1))
        self.connect((self.fir_filter_xxx_0, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.iir_filter_xxx_0, 0), (self.blocks_sub_xx_2, 0))
        self.connect((self.iir_filter_xxx_0, 0), (self.qtgui_time_sink_x_1_0, 0))
Ejemplo n.º 12
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        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.samp_rate = samp_rate = 16000
        self.repeat = repeat = samp_rate/80

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
        	1024, #size
        	samp_rate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)
        
        self.qtgui_time_sink_x_0_0.set_y_label("Amplitude", "")
        
        self.qtgui_time_sink_x_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0_0.enable_grid(False)
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win)
        self.blocks_unpacked_to_packed_xx_1 = blocks.unpacked_to_packed_bb(8, gr.GR_MSB_FIRST)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8)
        self.blocks_uchar_to_float_0_0_0 = blocks.uchar_to_float()
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 1)
        self.blocks_short_to_char_0 = blocks.short_to_char(1)
        self.blocks_rms_xx_0_0 = blocks.rms_ff(1)
        self.blocks_rms_xx_0 = blocks.rms_ff(1)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char*1, repeat)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(1, 8, "", False, gr.GR_MSB_FIRST)
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_short*1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1)
        self.blocks_multiply_xx_0_2 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vss((256, ))
        self.blocks_integrate_xx_1 = blocks.integrate_ff(repeat)
        self.blocks_integrate_xx_0_1 = blocks.integrate_ff(repeat)
        self.blocks_integrate_xx_0_0 = blocks.integrate_ff(repeat)
        self.blocks_integrate_xx_0 = blocks.integrate_ff(repeat)
        self.blocks_float_to_uchar_0 = blocks.float_to_uchar()
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_short*1, "/home/sidekiq/Documents/Documentation_SDR/sdr.in", True)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, "/home/sidekiq/Documents/Documentation_SDR/text_output", False)
        self.blocks_file_sink_0_0.set_unbuffered(True)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_argmax_xx_0 = blocks.argmax_fs(1)
        self.blocks_add_xx_0_0 = blocks.add_vff(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((1, ))
        self.blocks_abs_xx_0_2 = blocks.abs_ff(1)
        self.blocks_abs_xx_0_1 = blocks.abs_ff(1)
        self.blocks_abs_xx_0_0 = blocks.abs_ff(1)
        self.blocks_abs_xx_0 = blocks.abs_ff(1)
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder(
        		samples_per_symbol=1,
        		bits_per_symbol=1,
        		preamble="11111000",
        		access_code="11111111",
        		pad_for_usrp=False,
        	),
        	payload_length=1,
        )
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder(
        		access_code="",
        		threshold=-1,
        		callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload),
        	),
        )
        self.audio_sink_1 = audio.sink(16000, "", True)
        self.analog_sig_source_x_1 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1330, 1, 0)
        self.analog_sig_source_x_0_1 = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE, 1330, 1, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE, 2720, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 2720, 1, 0)
        self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(100)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_complex_to_float_0, 0))    
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0_0, 0))    
        self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_2, 0))    
        self.connect((self.analog_sig_source_x_0_1, 0), (self.blocks_multiply_xx_0_1, 0))    
        self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_unpacked_to_packed_xx_1, 0))    
        self.connect((self.blks2_packet_encoder_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))    
        self.connect((self.blocks_abs_xx_0, 0), (self.blocks_add_xx_0, 0))    
        self.connect((self.blocks_abs_xx_0_0, 0), (self.blocks_add_xx_0_0, 0))    
        self.connect((self.blocks_abs_xx_0_1, 0), (self.blocks_add_xx_0, 1))    
        self.connect((self.blocks_abs_xx_0_2, 0), (self.blocks_add_xx_0_0, 1))    
        self.connect((self.blocks_add_const_vxx_0, 0), (self.analog_frequency_modulator_fc_0, 0))    
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_rms_xx_0, 0))    
        self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_rms_xx_0_0, 0))    
        self.connect((self.blocks_argmax_xx_0, 0), (self.blocks_null_sink_1, 0))    
        self.connect((self.blocks_argmax_xx_0, 1), (self.blocks_short_to_float_0, 0))    
        self.connect((self.blocks_complex_to_float_0, 1), (self.audio_sink_1, 0))    
        self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0_0, 1))    
        self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0_1, 1))    
        self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0_2, 1))    
        self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_null_sink_0, 0))    
        self.connect((self.blocks_file_source_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_float_to_uchar_0, 0), (self.blks2_packet_decoder_0, 0))    
        self.connect((self.blocks_integrate_xx_0, 0), (self.blocks_abs_xx_0_2, 0))    
        self.connect((self.blocks_integrate_xx_0_0, 0), (self.blocks_abs_xx_0, 0))    
        self.connect((self.blocks_integrate_xx_0_1, 0), (self.blocks_abs_xx_0_0, 0))    
        self.connect((self.blocks_integrate_xx_1, 0), (self.blocks_abs_xx_0_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_short_to_char_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_integrate_xx_0, 0))    
        self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_integrate_xx_1, 0))    
        self.connect((self.blocks_multiply_xx_0_1, 0), (self.blocks_integrate_xx_0_1, 0))    
        self.connect((self.blocks_multiply_xx_0_2, 0), (self.blocks_integrate_xx_0_0, 0))    
        self.connect((self.blocks_repack_bits_bb_0, 0), (self.blks2_packet_encoder_0, 0))    
        self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_uchar_to_float_0_0_0, 0))    
        self.connect((self.blocks_repeat_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_rms_xx_0, 0), (self.blocks_argmax_xx_0, 1))    
        self.connect((self.blocks_rms_xx_0_0, 0), (self.blocks_argmax_xx_0, 0))    
        self.connect((self.blocks_short_to_char_0, 0), (self.blocks_repack_bits_bb_0, 0))    
        self.connect((self.blocks_short_to_float_0, 0), (self.blocks_float_to_uchar_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.blocks_uchar_to_float_0, 0))    
        self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_add_const_vxx_0, 0))    
        self.connect((self.blocks_uchar_to_float_0_0_0, 0), (self.qtgui_time_sink_x_0_0, 0))    
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_repeat_0, 0))    
        self.connect((self.blocks_unpacked_to_packed_xx_1, 0), (self.blocks_file_sink_0_0, 0))    
Ejemplo n.º 13
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        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.samp_rate = samp_rate = 16000

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	1024, #size
        	samp_rate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)
        
        self.qtgui_time_sink_x_0.set_y_label("Amplitude", "")
        
        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_0.disable_legend()
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_number_sink_1 = qtgui.number_sink(
                gr.sizeof_float,
                0,
                qtgui.NUM_GRAPH_HORIZ,
        	1
        )
        self.qtgui_number_sink_1.set_update_time(0.10)
        self.qtgui_number_sink_1.set_title("after float")
        
        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 xrange(1):
            self.qtgui_number_sink_1.set_min(i, -1)
            self.qtgui_number_sink_1.set_max(i, 1)
            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_layout.addWidget(self._qtgui_number_sink_1_win)
        self.qtgui_number_sink_0 = qtgui.number_sink(
                gr.sizeof_char,
                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 xrange(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_layout.addWidget(self._qtgui_number_sink_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_freq_sink_x_0.disable_legend()
        
        if float == type(float()):
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.blocks_unpacked_to_packed_xx_1 = blocks.unpacked_to_packed_bb(8, gr.GR_MSB_FIRST)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 1)
        self.blocks_rms_xx_0_0 = blocks.rms_ff(1)
        self.blocks_rms_xx_0 = blocks.rms_ff(1)
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_short*1)
        self.blocks_multiply_xx_0_2 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_integrate_xx_1 = blocks.integrate_ff(samp_rate/80, 1)
        self.blocks_integrate_xx_0_1 = blocks.integrate_ff(samp_rate/80, 1)
        self.blocks_integrate_xx_0_0 = blocks.integrate_ff(samp_rate/80, 1)
        self.blocks_integrate_xx_0 = blocks.integrate_ff(samp_rate/80, 1)
        self.blocks_float_to_uchar_0 = blocks.float_to_uchar()
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, "/home/sidekiq/SDR_output", False)
        self.blocks_file_sink_0_0.set_unbuffered(True)
        self.blocks_argmax_xx_0 = blocks.argmax_fs(1)
        self.blocks_add_xx_0_0 = blocks.add_vff(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.blocks_abs_xx_0_2 = blocks.abs_ff(1)
        self.blocks_abs_xx_0_1 = blocks.abs_ff(1)
        self.blocks_abs_xx_0_0 = blocks.abs_ff(1)
        self.blocks_abs_xx_0 = blocks.abs_ff(1)
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder(
        		access_code="11111111",
        		threshold=-1,
        		callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload),
        	),
        )
        self.audio_source_0 = audio.source(16000, "", True)
        self.analog_sig_source_x_1 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1330, 1, 0)
        self.analog_sig_source_x_0_1 = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE, 1330, 1, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE, 2720, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 2720, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0_0, 0))    
        self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_2, 0))    
        self.connect((self.analog_sig_source_x_0_1, 0), (self.blocks_multiply_xx_0_1, 0))    
        self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.audio_source_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.audio_source_0, 0), (self.blocks_multiply_xx_0_0, 1))    
        self.connect((self.audio_source_0, 0), (self.blocks_multiply_xx_0_1, 1))    
        self.connect((self.audio_source_0, 0), (self.blocks_multiply_xx_0_2, 1))    
        self.connect((self.audio_source_0, 0), (self.qtgui_freq_sink_x_0, 0))    
        self.connect((self.audio_source_0, 0), (self.qtgui_time_sink_x_0, 0))    
        self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_unpacked_to_packed_xx_1, 0))    
        self.connect((self.blocks_abs_xx_0, 0), (self.blocks_add_xx_0, 0))    
        self.connect((self.blocks_abs_xx_0_0, 0), (self.blocks_add_xx_0_0, 0))    
        self.connect((self.blocks_abs_xx_0_1, 0), (self.blocks_add_xx_0, 1))    
        self.connect((self.blocks_abs_xx_0_2, 0), (self.blocks_add_xx_0_0, 1))    
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_rms_xx_0, 0))    
        self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_rms_xx_0_0, 0))    
        self.connect((self.blocks_argmax_xx_0, 0), (self.blocks_null_sink_1, 0))    
        self.connect((self.blocks_argmax_xx_0, 1), (self.blocks_short_to_float_0, 0))    
        self.connect((self.blocks_float_to_uchar_0, 0), (self.blks2_packet_decoder_0, 0))    
        self.connect((self.blocks_float_to_uchar_0, 0), (self.qtgui_number_sink_0, 0))    
        self.connect((self.blocks_integrate_xx_0, 0), (self.blocks_abs_xx_0_2, 0))    
        self.connect((self.blocks_integrate_xx_0_0, 0), (self.blocks_abs_xx_0, 0))    
        self.connect((self.blocks_integrate_xx_0_1, 0), (self.blocks_abs_xx_0_0, 0))    
        self.connect((self.blocks_integrate_xx_1, 0), (self.blocks_abs_xx_0_1, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_integrate_xx_0, 0))    
        self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_integrate_xx_1, 0))    
        self.connect((self.blocks_multiply_xx_0_1, 0), (self.blocks_integrate_xx_0_1, 0))    
        self.connect((self.blocks_multiply_xx_0_2, 0), (self.blocks_integrate_xx_0_0, 0))    
        self.connect((self.blocks_rms_xx_0, 0), (self.blocks_argmax_xx_0, 1))    
        self.connect((self.blocks_rms_xx_0_0, 0), (self.blocks_argmax_xx_0, 0))    
        self.connect((self.blocks_short_to_float_0, 0), (self.blocks_float_to_uchar_0, 0))    
        self.connect((self.blocks_short_to_float_0, 0), (self.qtgui_number_sink_1, 0))    
        self.connect((self.blocks_unpacked_to_packed_xx_1, 0), (self.blocks_file_sink_0_0, 0))    
    def __init__(self):
        gr.top_block.__init__(self, "Testaudiostreamport")
        self.freq_wavelength = 8000

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 48000
        self.fundamental_wavelength_samples = fundamental_wavelength_samples = 800
        self.freq_wavelength = freq_wavelength = 8000
        self.myVectorLength = myVectorLength = 32
        self.lowpass_cutoff_freq = 4000
        self.n_keep = (self.samp_rate/2)/self.lowpass_cutoff_freq

        # allow the rms post suppression thread to track if changes aren't happening, which suggests a dead flowgraph.
        self.rmspostsup_nochange_count = 0

        ##################################################
        # Blocks
        ##################################################
        self.probe_avg_frequency = blocks.probe_signal_f()

        if ("getfreq_alpha" in SETTINGS["streamer"]):
            myGetfreqAlpha = SETTINGS["streamer"]["getfreq_alpha"]
        else:
            myGetfreqAlpha = 0.1

        self.powerquality_getfreqcpp_0 = powerquality.getfreqcpp(myGetfreqAlpha)
        self.fractional_interpolator_xx_0_0 = filter.fractional_interpolator_ff(0, 0.1)
        self.fractional_interpolator_xx_0 = filter.fractional_interpolator_ff(0, 0.1)
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink('/dev/stdout', 2, samp_rate, 16)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_float*1, samp_rate*10,True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate*10,True)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((-1, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((-1, ))
        # self.blocks_getfreq_average_value = blocks.moving_average_ff(1000, 0.001, 40)
        self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n(gr.sizeof_float*1, 10)
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_float*1, 10)
        self.blocks_delay_1 = blocks.delay(gr.sizeof_float*1, int(round(freq_wavelength)))
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, int(round(freq_wavelength)))
        self.blocks_add_xx_1 = blocks.add_vff(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)


        # Calculation of RMS power post-suppression (amplitude of harmonics), also will vary based on effectiveness of the muting.
        rmsPostSuppressionAlpha = SETTINGS["streamer"]["rmsPostSuppressionAlpha"] # TODO: tune this
        rmsPostSuppressionAverageLength = SETTINGS["streamer"]["rmsPostSuppressionAverageLength"] # TODO: tune this
        rmsPostSuppressionAverageScale = SETTINGS["streamer"]["rmsPostSuppressionAverageScale"] # TODO: tune this
        log("TODO: Tune the Post suppression Alpha value for both RMS and average RMS. Or even remove the averaging if possible.")
        # Channel 1: Define the blocks needed to calculate and probe the average RMS harmonic power
        self.blocks_rmsPostSuppression_ch1 = blocks.rms_ff(rmsPostSuppressionAlpha)
        self.blocks_averagePostSuppression_ch1 = blocks.moving_average_ff(rmsPostSuppressionAverageLength,rmsPostSuppressionAverageScale,4000) # TODO: tune this
        self.probe_rmsPostSuppression_ch1 = blocks.probe_signal_f()
        # Channel 2: Define the blocks needed to calculate and probe the average RMS harmonic power
        self.blocks_rmsPostSuppression_ch2 = blocks.rms_ff(rmsPostSuppressionAlpha)
        self.blocks_averagePostSuppression_ch2 = blocks.moving_average_ff(rmsPostSuppressionAverageLength,rmsPostSuppressionAverageScale,4000) # TODO: tune this
        self.probe_rmsPostSuppression_ch2 = blocks.probe_signal_f()
        # channel 1: Connect the RMS harmonic blocks
        self.connect((self.blocks_rmsPostSuppression_ch1,0),(self.blocks_averagePostSuppression_ch1,0))
        self.connect((self.blocks_averagePostSuppression_ch1,0),(self.probe_rmsPostSuppression_ch1,0))
        # Channel 2: Connect the RMS harmonic blocks
        self.connect((self.blocks_rmsPostSuppression_ch2,0),(self.blocks_averagePostSuppression_ch2,0))
        self.connect((self.blocks_averagePostSuppression_ch2,0),(self.probe_rmsPostSuppression_ch2,0))

        # Connect Channels 1 and 2 to the larger flow.
        self.connect((self.blocks_keep_one_in_n_0,0),(self.blocks_rmsPostSuppression_ch1,0))
        self.connect((self.blocks_keep_one_in_n_0_0,0),(self.blocks_rmsPostSuppression_ch2,0))




        # Left channel TCP connection
        # log("Connecting to " + getConfigValue("pqserver") + ":" + str(getConfigValue("left_channel_tap_port")))
        # self.blocks_socket_pdu_left_inputchannel = blocks.socket_pdu(
        #     "TCP_CLIENT",
        #     getConfigValue("pqserver"),
        #     str(getConfigValue("left_channel_tap_port")),
        #     10000, # this arg is unused because we are client
        #     False) # this arg is unused because we are client
        # self.blocks_pdu_to_tagged_stream_left = blocks.pdu_to_tagged_stream(
        #     blocks.float_t,
        #     SETTINGS["networking_tap1"]["length_tag_name"])

        self.zeromq_sub_source_left  = zeromq.sub_source(gr.sizeof_float, 1, SETTINGS["streamer"]["zmq_server_uri_left_channel"], 5000, True, -1)

        # optimization: if left and right channels are specified as the same source then make a single connection to the source.
        if SETTINGS["streamer"]["zmq_server_uri_left_channel"] == SETTINGS["streamer"]["zmq_server_uri_right_channel"]:
            self.zeromq_sub_source_right = self.zeromq_sub_source_left
            log("Optimization: Only making a single connection to PQ server since left and right streamer channels have same ZMQ URI.")
        else:
            # Connection URI/address to server is different for left and right channel so make a second connection for right channel.
            self.zeromq_sub_source_right = zeromq.sub_source(gr.sizeof_float, 1, SETTINGS["streamer"]["zmq_server_uri_right_channel"], 5000, True, -1)


        # self.msg_connect((self.blocks_socket_pdu_left_inputchannel,"pdus"),(self.blocks_pdu_to_tagged_stream_left,"pdus"))
        #
        # # Right Channel TCP connection
        # log("Connecting to " + getConfigValue("pqserver") + ":" + str(getConfigValue("right_channel_tap_port")))
        # self.blocks_socket_pdu_right_inputchannel = blocks.socket_pdu(
        #     "TCP_CLIENT",
        #     getConfigValue("pqserver"),
        #     str(getConfigValue("right_channel_tap_port")),
        #     10000, # this arg is unused because we are client
        #     False) # this arg is unused because we are client
        # self.blocks_pdu_to_tagged_stream_right = blocks.pdu_to_tagged_stream(
        #     blocks.float_t,
        #     SETTINGS["networking_tap1"]["length_tag_name"])
        # self.msg_connect((self.blocks_socket_pdu_right_inputchannel, "pdus"), (self.blocks_pdu_to_tagged_stream_right, "pdus"))

        self.analog_rail_ff_1 = analog.rail_ff(-0.8, 0.8)
        self.analog_rail_ff_0 = analog.rail_ff(-0.8, 0.8)
        # myDecay of 1e-2 (0.01) sounds great when input voltage to the Pi is clean (dirty rectifier voltage can introduce periodic bumps and thumbs that mess up AGC).
        # myDecay of 0.1: pretty quick. Useful for exposing the thumb phenomenon that I'm currently investigating. 1e-2 (0.01) gets drown down due to thump but thump not very audible.

        # Sensible default
        myDecay = 1e-2
        # Allow overriding in config file.
        if ("agc_decay_rate" in SETTINGS["streamer"]):
            myDecay = SETTINGS["streamer"]["agc_decay_rate"]
        self.analog_agc2_xx_1 = analog.agc2_ff(0.1, myDecay, 0.1, 1.0)
        self.analog_agc2_xx_1.set_max_gain(65536)
        self.analog_agc2_xx_0 = analog.agc2_ff(0.1, myDecay, 0.1, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0), (self.analog_rail_ff_0, 0))
        self.connect((self.analog_agc2_xx_1, 0), (self.analog_rail_ff_1, 0))
        self.connect((self.analog_rail_ff_0, 0), (self.blocks_wavfile_sink_0, 0))
        self.connect((self.analog_rail_ff_1, 0), (self.blocks_wavfile_sink_0, 1))
        self.connect((self.zeromq_sub_source_left, 0), (self.fractional_interpolator_xx_0, 0))
        self.connect((self.zeromq_sub_source_right, 0), (self.fractional_interpolator_xx_0_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.blocks_keep_one_in_n_0_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_delay_1, 0), (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.blocks_keep_one_in_n_0_0, 0), (self.analog_agc2_xx_1, 0))
        self.connect((self.powerquality_getfreqcpp_0, 0), (self.probe_avg_frequency, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_xx_1, 1))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.powerquality_getfreqcpp_0, 0))
        self.connect((self.blocks_throttle_0_0, 0), (self.blocks_add_xx_1, 0))
        self.connect((self.blocks_throttle_0_0, 0), (self.blocks_delay_1, 0))
        self.connect((self.fractional_interpolator_xx_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.fractional_interpolator_xx_0_0, 0), (self.blocks_throttle_0_0, 0))
        # self.connect((self.powerquality_getfreqcpp_0, 0), (self.blocks_getfreq_average_value, 0))

        ### Define FFT related blocks LEFT-CHANNEL ONLY FOR NOW.
        self.fft_vxx_0 = fft.fft_vfc(myVectorLength, True, (window.blackmanharris(myVectorLength)), 1)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_float*1, myVectorLength)
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_float*1, self.n_keep)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(myVectorLength)
        self.blocks_throttle = blocks.throttle(gr.sizeof_float * 1, self.samp_rate, True)
        self.blocks_fft_vector_sink_0 = blocks.vector_sink_f(self.myVectorLength)

        ### Connect FFT BLOCKS.
        # Down-sample / decimate the input. We pick up the flowgraph after AGC but before the rail.
        self.connect((self.analog_agc2_xx_0, 0), (self.blocks_keep_one_in_n_0, 0))
        # Convert the stream to a vector in preparation for FFT
        self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_stream_to_vector_0, 0))
        # Perform FFT analysis of the stream.
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        # Send FFT data (phase and magnitude) into a mag^2 block to get strength of each bin
        self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
        # Send the final result (magnitudes in each fft bin) into vector sink.
        # self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_fft_vector_sink_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_fft_vector_sink_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "THD Analyser")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("THD Analyser")
        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", "THD_analyser")
        self.restoreGeometry(
            self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.frequency = frequency = 1000
        self.cut_off = cut_off = frequency / 10
        self.transition_width = transition_width = cut_off / 10
        self.samp_rate = samp_rate = 44100

        ##################################################
        # Blocks
        ##################################################
        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 xrange(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.low_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate,
                            frequency + cut_off - transition_width,
                            transition_width, firdes.WIN_BLACKMAN, 6.76))
        self.high_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.high_pass(1, samp_rate,
                             frequency + cut_off + (transition_width * 1.1),
                             transition_width, firdes.WIN_BLACKMAN, 6.76))
        self.dc_blocker_xx_0_0 = filter.dc_blocker_ff(32, True)
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(32, True)
        self.blocks_rms_xx_0_0 = blocks.rms_ff(0.0001)
        self.blocks_rms_xx_0 = blocks.rms_ff(0.0001)
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_float * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((100, ))
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.audio_source_0 = audio.source(samp_rate, '', True)
        self.audio_sink_0 = audio.sink(samp_rate, '', True)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_SIN_WAVE, frequency, 0.5, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.audio_sink_0, 1))
        self.connect((self.audio_source_0, 1), (self.blocks_null_sink_0, 0))
        self.connect((self.audio_source_0, 0), (self.high_pass_filter_0, 0))
        self.connect((self.audio_source_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_null_source_0, 0), (self.audio_sink_0, 0))
        self.connect((self.blocks_rms_xx_0, 0), (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_rms_xx_0_0, 0), (self.blocks_divide_xx_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.blocks_rms_xx_0_0, 0))
        self.connect((self.dc_blocker_xx_0_0, 0), (self.blocks_rms_xx_0, 0))
        self.connect((self.high_pass_filter_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.dc_blocker_xx_0_0, 0))
Ejemplo n.º 16
0
    def __init__(self):
        gr.top_block.__init__(self, "OOK Receiver")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("OOK Receiver")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

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

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 10e6
        self.baseband_freq = baseband_freq = 500
        self.threshold = threshold = 0.03
        self.samples_per_symbol = samples_per_symbol = int(samp_rate /
                                                           baseband_freq)
        self.carrier_freq = carrier_freq = 432.867e6
        self.alpha = alpha = 0.00328

        ##################################################
        # Blocks
        ##################################################
        self._threshold_range = Range(0, 1, 0.01, 0.03, 200)
        self._threshold_win = RangeWidget(self._threshold_range,
                                          self.set_threshold, 'Threshold',
                                          "counter_slider", float)
        self.top_grid_layout.addWidget(self._threshold_win)
        self._alpha_range = Range(0.00001, 0.01, 0.00001, 0.00328, 200)
        self._alpha_win = RangeWidget(self._alpha_range, self.set_alpha,
                                      'alpha', "counter_slider", float)
        self.top_grid_layout.addWidget(self._alpha_win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=1,
            decimation=int(samples_per_symbol / 4),
            taps=[1],
            fractional_bw=None)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-1, 1)

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

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

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

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

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            600000,  #size
            samp_rate,  #samp_rate
            "",  #name
            3  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(0, 0.15)

        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_NORM,
                                                  qtgui.TRIG_SLOPE_POS, 0.07,
                                                  0, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(True)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            carrier_freq,  #fc
            samp_rate,  #bw
            "",  #name
            1)
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "soapy=0,driver=lime")
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(carrier_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_gain(0, 0)
        self.osmosdr_source_0.set_if_gain(0, 0)
        self.osmosdr_source_0.set_bb_gain(0, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
        self.blocks_threshold_ff_0_0 = blocks.threshold_ff(
            threshold, threshold, 0)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(0.04, 0.06, 0)
        self.blocks_rms_xx_0 = blocks.rms_ff(alpha)
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(4)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(0.1)
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 1)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/run/media/gpellaeon/ubuntu20_04/home/pellaeon/Development/SDR/GRFlowgraphs/ook/digital_output.txt',
            False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_rms_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_float_to_char_0, 0),
                     (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_pack_k_bits_bb_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_rms_xx_0, 0),
                     (self.blocks_threshold_ff_0_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_threshold_ff_0_0, 0),
                     (self.qtgui_time_sink_x_0, 2))
        self.connect((self.blocks_threshold_ff_0_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_float_to_char_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.qtgui_time_sink_x_1, 0))
Ejemplo n.º 17
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Threshold")

        ##################################################
        # Variables
        ##################################################
        self.samples_per_bit = samples_per_bit = 40960
        self.samp_rate = samp_rate = 32000
        self._b_power_config = ConfigParser.ConfigParser()
        self._b_power_config.read(
            '/Users/jaredweinstein/Desktop/CS434Project/src/config')
        try:
            b_power = self._b_power_config.getfloat('power', 'b')
        except:
            b_power = 1
        self.b_power = b_power
        self._a_power_config = ConfigParser.ConfigParser()
        self._a_power_config.read(
            '/Users/jaredweinstein/Desktop/CS434Project/src/config')
        try:
            a_power = self._a_power_config.getfloat('power', 'a')
        except:
            a_power = .5
        self.a_power = a_power

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_numbersink2_4 = numbersink2.number_sink_f(
            self.GetWin(),
            unit='Units',
            minval=-100,
            maxval=100,
            factor=1.0,
            decimal_places=10,
            ref_level=0,
            sample_rate=samp_rate,
            number_rate=15,
            average=False,
            avg_alpha=None,
            label='Number Plot',
            peak_hold=False,
            show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_4.win)
        self.wxgui_numbersink2_3 = numbersink2.number_sink_f(
            self.GetWin(),
            unit='',
            minval=-100,
            maxval=100,
            factor=1.0,
            decimal_places=10,
            ref_level=0,
            sample_rate=samp_rate,
            number_rate=15,
            average=False,
            avg_alpha=.001,
            label='Neither',
            peak_hold=False,
            show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_3.win)
        self.wxgui_numbersink2_2 = numbersink2.number_sink_f(
            self.GetWin(),
            unit='',
            minval=-100,
            maxval=100,
            factor=1.0,
            decimal_places=10,
            ref_level=0,
            sample_rate=samp_rate,
            number_rate=15,
            average=False,
            avg_alpha=.001,
            label='B',
            peak_hold=False,
            show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_2.win)
        self.wxgui_numbersink2_1 = numbersink2.number_sink_f(
            self.GetWin(),
            unit='',
            minval=-100,
            maxval=100,
            factor=1.0,
            decimal_places=10,
            ref_level=0,
            sample_rate=samp_rate,
            number_rate=15,
            average=False,
            avg_alpha=.001,
            label='A',
            peak_hold=False,
            show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_1.win)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
            self.GetWin(),
            unit='',
            minval=-100,
            maxval=100,
            factor=1.0,
            decimal_places=10,
            ref_level=0,
            sample_rate=samp_rate,
            number_rate=15,
            average=False,
            avg_alpha=.001,
            label='A + B',
            peak_hold=False,
            show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0.win)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
                                                 samp_rate, True)
        self.blocks_rms_xx_3 = blocks.rms_ff(0.0001)
        self.blocks_rms_xx_2 = blocks.rms_ff(0.0001)
        self.blocks_rms_xx_1 = blocks.rms_ff(0.0001)
        self.blocks_rms_xx_0 = blocks.rms_ff(0.0001)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff(
            (b_power, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (a_power, ))
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_float * 1,
            '/Users/jaredweinstein/Desktop/CS434Project/src/carrier', True)
        self.blocks_file_sink_3 = blocks.file_sink(
            gr.sizeof_float * 1,
            '/Users/jaredweinstein/Desktop/CS434Project/output/avg_b', False)
        self.blocks_file_sink_3.set_unbuffered(False)
        self.blocks_file_sink_2 = blocks.file_sink(
            gr.sizeof_float * 1,
            '/Users/jaredweinstein/Desktop/CS434Project/output/avg_both',
            False)
        self.blocks_file_sink_2.set_unbuffered(False)
        self.blocks_file_sink_1 = blocks.file_sink(
            gr.sizeof_float * 1,
            '/Users/jaredweinstein/Desktop/CS434Project/output/avg_a', False)
        self.blocks_file_sink_1.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_float * 1,
            '/Users/jaredweinstein/Desktop/CS434Project/output/avg_neither',
            False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_divide_xx_3 = blocks.divide_ff(1)
        self.blocks_divide_xx_2 = blocks.divide_ff(1)
        self.blocks_divide_xx_1 = blocks.divide_ff(1)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_add_xx_2 = blocks.add_vff(1)
        self.blocks_add_xx_1 = blocks.add_vff(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.blocks_abs_xx_0 = blocks.abs_ff(1)
        self.analog_const_source_x_2 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, a_power)
        self.analog_const_source_x_1 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 1)
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_divide_xx_1, 1))
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_divide_xx_2, 1))
        self.connect((self.analog_const_source_x_1, 0),
                     (self.blocks_divide_xx_3, 1))
        self.connect((self.analog_const_source_x_2, 0),
                     (self.wxgui_numbersink2_4, 0))
        self.connect((self.blocks_abs_xx_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_abs_xx_0, 0), (self.blocks_add_xx_2, 1))
        self.connect((self.blocks_abs_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_abs_xx_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_abs_xx_0, 0), (self.blocks_rms_xx_3, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_add_xx_1, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_rms_xx_0, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.blocks_rms_xx_1, 0))
        self.connect((self.blocks_add_xx_2, 0), (self.blocks_rms_xx_2, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.blocks_file_sink_1, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.wxgui_numbersink2_1, 0))
        self.connect((self.blocks_divide_xx_1, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_divide_xx_2, 0),
                     (self.blocks_file_sink_3, 0))
        self.connect((self.blocks_divide_xx_2, 0),
                     (self.wxgui_numbersink2_2, 0))
        self.connect((self.blocks_divide_xx_3, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_divide_xx_3, 0),
                     (self.wxgui_numbersink2_3, 0))
        self.connect((self.blocks_file_source_0, 0), (self.blocks_abs_xx_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_1, 1))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_add_xx_2, 0))
        self.connect((self.blocks_rms_xx_0, 0), (self.blocks_divide_xx_0, 0))
        self.connect((self.blocks_rms_xx_1, 0), (self.blocks_divide_xx_1, 0))
        self.connect((self.blocks_rms_xx_2, 0), (self.blocks_divide_xx_2, 0))
        self.connect((self.blocks_rms_xx_3, 0), (self.blocks_divide_xx_3, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_file_sink_2, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.wxgui_numbersink2_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "HF channel simulation")

        ##################################################
        # Variables
        ##################################################
        self.snr = snr = 40
        self.vol = vol = [1, 1]
        self.tau_a = tau_a = 1 / 100.
        self.tau = tau = 0.1
        self.snrVecOut = snrVecOut = ([0] * 3)
        self.samp_rate = samp_rate = 48000
        self.outSigRMSVec = outSigRMSVec = ([0] * 2)
        self.noSpread = noSpread = 0
        self.kN = kN = pow(10.0, (-snr / 20.0))
        self.freqShift = freqShift = 0.0
        self.fd = fd = 1
        self.en_noise = en_noise = [0, 0]
        self.doppler_ir = doppler_ir = [
            0.0016502763167573274, 0.0018854799389366934, 0.002149957633383614,
            0.0024466994528029662, 0.002778907461425479, 0.003149998028185868,
            0.003563602180973301, 0.00402356375450247, 0.004533935060796761,
            0.0050989698117900155, 0.005723113028669535, 0.006410987682800636,
            0.007167377828853199, 0.007997208012493867, 0.008905518763040982,
            0.00989743801603955, 0.010978148351927763, 0.012152849984840378,
            0.013426719489994542, 0.014804864318746317, 0.016292273216847054,
            0.01789376273305468, 0.019613920081278834, 0.021457042698902442,
            0.023427074925696508, 0.025527542310538734, 0.027761484135525694,
            0.030131384827462734, 0.03263910500345486, 0.035285812968654906,
            0.03807191754835305, 0.04099700319171279, 0.04405976832879332,
            0.04725796799434838, 0.050588361749672524, 0.05404666793605477,
            0.057627525278984175, 0.06132446283016882, 0.06512987918400244,
            0.0690350318359975, 0.073030037462906, 0.07710388379815894,
            0.08124445365265866, 0.08543856149104095, 0.08967200281887802,
            0.0939296164688993, 0.09819535969651079, 0.10245239580938088,
            0.10668319386560887, 0.1108696397832219, 0.11499315801386097,
            0.11903484274903825, 0.12297559745183839, 0.12679628134392928,
            0.1304778613306593, 0.13400156771907581, 0.1373490519778611,
            0.14050254470705797, 0.14344501193124823, 0.14616030780428022,
            0.14863332181791858, 0.15085011864154488, 0.1527980687853246,
            0.154465968374505, 0.15584414644656272, 0.15692455833401583,
            0.15770086387153975, 0.1581684893637365, 0.15832467246620405,
            0.1581684893637365, 0.15770086387153975, 0.15692455833401583,
            0.15584414644656272, 0.154465968374505, 0.1527980687853246,
            0.15085011864154488, 0.14863332181791858, 0.14616030780428022,
            0.14344501193124823, 0.14050254470705797, 0.1373490519778611,
            0.13400156771907581, 0.1304778613306593, 0.12679628134392928,
            0.12297559745183839, 0.11903484274903825, 0.11499315801386097,
            0.1108696397832219, 0.10668319386560887, 0.10245239580938088,
            0.09819535969651079, 0.0939296164688993, 0.08967200281887802,
            0.08543856149104095, 0.08124445365265866, 0.07710388379815894,
            0.073030037462906, 0.0690350318359975, 0.06512987918400244,
            0.06132446283016882, 0.057627525278984175, 0.05404666793605477,
            0.050588361749672524, 0.04725796799434838, 0.04405976832879332,
            0.04099700319171279, 0.03807191754835305, 0.035285812968654906,
            0.03263910500345486, 0.030131384827462734, 0.027761484135525694,
            0.025527542310538734, 0.023427074925696508, 0.021457042698902442,
            0.019613920081278834, 0.01789376273305468, 0.016292273216847054,
            0.014804864318746317, 0.013426719489994542, 0.012152849984840378,
            0.010978148351927763, 0.00989743801603955, 0.008905518763040982,
            0.007997208012493867, 0.007167377828853199, 0.006410987682800636,
            0.005723113028669535, 0.0050989698117900155, 0.004533935060796761,
            0.00402356375450247, 0.003563602180973301, 0.003149998028185868,
            0.002778907461425479, 0.0024466994528029662, 0.002149957633383614,
            0.0018854799389366934, 0.0016502763167573274
        ]
        self.ampl = ampl = [[1.0, 1.0], [1.0, 1.0]]

        ##################################################
        # Blocks
        ##################################################
        self.snrOut = blocks.probe_signal_vf(4)
        self.outSigRMS = blocks.probe_signal_vf(2)

        def _snrVecOut_probe():
            while True:

                val = self.snrOut.level()
                try:
                    self.set_snrVecOut(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))

        _snrVecOut_thread = threading.Thread(target=_snrVecOut_probe)
        _snrVecOut_thread.daemon = True
        _snrVecOut_thread.start()

        self.single_pole_iir_filter_xx_0_1 = filter.single_pole_iir_filter_ff(
            2 * pi * tau_a / samp_rate, 1)
        self.single_pole_iir_filter_xx_0_0_0 = filter.single_pole_iir_filter_ff(
            2 * pi * tau_a / samp_rate, 1)
        self.single_pole_iir_filter_xx_0_0 = filter.single_pole_iir_filter_ff(
            2 * pi * tau_a / samp_rate, 1)
        self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(
            2 * pi * tau_a / samp_rate, 1)

        def _outSigRMSVec_probe():
            while True:

                val = self.outSigRMS.level()
                try:
                    self.set_outSigRMSVec(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))

        _outSigRMSVec_thread = threading.Thread(target=_outSigRMSVec_probe)
        _outSigRMSVec_thread.daemon = True
        _outSigRMSVec_thread.start()

        self.low_pass_filter_2_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 1550, 100, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_2 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 1550, 100, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_1_1 = filter.interp_fir_filter_ccf(
            int(samp_rate / 100),
            firdes.low_pass(ampl[1][0] * (samp_rate / 100.0), samp_rate, 50,
                            25, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_1_0_0 = filter.interp_fir_filter_ccf(
            int(samp_rate / 100),
            firdes.low_pass(ampl[1][1] * (samp_rate / 100.0), samp_rate, 50,
                            25, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_1_0 = filter.interp_fir_filter_ccf(
            int(samp_rate / 100),
            firdes.low_pass(ampl[0][1] * (samp_rate / 100.0), samp_rate, 50,
                            25, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_1 = filter.interp_fir_filter_ccf(
            int(samp_rate / 100),
            firdes.low_pass(ampl[0][0] * (samp_rate / 100.0), samp_rate, 50,
                            25, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 1750 + 100, 600, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 1750 + 100, 600, firdes.WIN_HAMMING,
                            6.76))
        self.epy_block_0_0_0_0 = epy_block_0_0_0_0.blk(fd=fd)
        self.epy_block_0_0_0 = epy_block_0_0_0.blk(fd=fd)
        self.epy_block_0_0 = epy_block_0_0.blk(fd=fd)
        self.epy_block_0 = epy_block_0.blk(fd=fd)
        self.blocks_streams_to_vector_0_0 = blocks.streams_to_vector(
            gr.sizeof_float * 1, 2)
        self.blocks_streams_to_vector_0 = blocks.streams_to_vector(
            gr.sizeof_float * 1, 4)
        self.blocks_selector_0_1 = blocks.selector(gr.sizeof_gr_complex * 1,
                                                   noSpread, 0)
        self.blocks_selector_0_1.set_enabled(True)
        self.blocks_selector_0_0_0 = blocks.selector(gr.sizeof_gr_complex * 1,
                                                     noSpread, 0)
        self.blocks_selector_0_0_0.set_enabled(True)
        self.blocks_selector_0_0 = blocks.selector(gr.sizeof_gr_complex * 1,
                                                   noSpread, 0)
        self.blocks_selector_0_0.set_enabled(True)
        self.blocks_selector_0 = blocks.selector(gr.sizeof_gr_complex * 1,
                                                 noSpread, 0)
        self.blocks_selector_0.set_enabled(True)
        self.blocks_rms_xx_0_1 = blocks.rms_cf(2 * pi * tau_a * 100 /
                                               samp_rate)
        self.blocks_rms_xx_0_0_0 = blocks.rms_ff(2 * pi * tau_a * 10 /
                                                 samp_rate)
        self.blocks_rms_xx_0_0 = blocks.rms_ff(2 * pi * tau_a * 10 / samp_rate)
        self.blocks_rms_xx_0 = blocks.rms_cf(2 * pi * tau_a * 100 / samp_rate)
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_float * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_nlog10_ff_0_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_multiply_xx_1_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0_0_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0_0_0_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0_0_0_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0_0_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0_0 = 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_3_0 = blocks.multiply_const_ff(
            en_noise[1])
        self.blocks_multiply_const_vxx_3 = blocks.multiply_const_ff(
            en_noise[0])
        self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_cc(vol[1])
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_cc(vol[0])
        self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_ff(
            2 * sqrt(ampl[1][0]**2 + ampl[1][1]**2) * 2)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_ff(
            2 * sqrt(ampl[0][0]**2 + ampl[0][1]**2) * 2)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_ff(0.5)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(0.5)
        self.blocks_float_to_complex_1_0 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_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_divide_xx_1_0 = blocks.divide_ff(1)
        self.blocks_divide_xx_1 = blocks.divide_ff(1)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                             int(tau * samp_rate))
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                           int(tau * samp_rate))
        self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_mag_squared_2_1 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_mag_squared_2_0_0 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_mag_squared_2_0 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_mag_squared_2 = blocks.complex_to_mag_squared(1)
        self.blocks_add_xx_1_0 = blocks.add_vff(1)
        self.blocks_add_xx_1 = blocks.add_vff(1)
        self.blocks_add_xx_0_1 = blocks.add_vcc(1)
        self.blocks_add_xx_0_0_0 = blocks.add_vcc(1)
        self.blocks_add_xx_0_0 = blocks.add_vcc(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.audio_source_0 = audio.source(samp_rate, 'hw:CARD=Rubix44,DEV=0',
                                           False)
        self.audio_sink_0 = audio.sink(samp_rate, 'hw:CARD=Rubix44,DEV=0',
                                       False)
        self.analog_sig_source_x_3 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, 1000, 0.3, 0, 0)
        self.analog_sig_source_x_2_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 1850, 1, 0, 0)
        self.analog_sig_source_x_2 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 1850, 1, 0, 0)
        self.analog_sig_source_x_1_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, freqShift, 1, 0, 0)
        self.analog_sig_source_x_1 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, freqShift, 1, 0, 0)
        self.analog_sig_source_x_0_0_1 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -1850, 1, 0, 0)
        self.analog_sig_source_x_0_0_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 1850, 1, 0, 0)
        self.analog_sig_source_x_0_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 1850, 1, 0, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -1850, 1, 0, 0)
        self.analog_noise_source_x_1_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1e-0 * kN, 13)
        self.analog_noise_source_x_1 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1e-0 * kN, 3)
        self.analog_noise_source_x_0_1 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1, 10)
        self.analog_noise_source_x_0_0_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1, 11)
        self.analog_noise_source_x_0_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1, 1)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1, 0)
        self.analog_const_source_x_2_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_2 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_1_1 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, ampl[1][0])
        self.analog_const_source_x_1_0_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, ampl[1][1])
        self.analog_const_source_x_1_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, ampl[0][1])
        self.analog_const_source_x_1 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, ampl[0][0])
        self.analog_const_source_x_0_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.analog_const_source_x_0_0, 0),
                     (self.blocks_float_to_complex_0_0, 1))
        self.connect((self.analog_const_source_x_1, 0),
                     (self.blocks_selector_0, 1))
        self.connect((self.analog_const_source_x_1_0, 0),
                     (self.blocks_selector_0_0, 1))
        self.connect((self.analog_const_source_x_1_0_0, 0),
                     (self.blocks_selector_0_0_0, 1))
        self.connect((self.analog_const_source_x_1_1, 0),
                     (self.blocks_selector_0_1, 1))
        self.connect((self.analog_const_source_x_2, 0),
                     (self.blocks_float_to_complex_1, 1))
        self.connect((self.analog_const_source_x_2_0, 0),
                     (self.blocks_float_to_complex_1_0, 1))
        self.connect((self.analog_noise_source_x_0, 0), (self.epy_block_0, 0))
        self.connect((self.analog_noise_source_x_0_0, 0),
                     (self.epy_block_0_0, 0))
        self.connect((self.analog_noise_source_x_0_0_0, 0),
                     (self.epy_block_0_0_0_0, 0))
        self.connect((self.analog_noise_source_x_0_1, 0),
                     (self.epy_block_0_0_0, 0))
        self.connect((self.analog_noise_source_x_1, 0),
                     (self.low_pass_filter_2, 0))
        self.connect((self.analog_noise_source_x_1_0, 0),
                     (self.low_pass_filter_2_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.analog_sig_source_x_0_0_0_0, 0),
                     (self.blocks_multiply_xx_0_0_1, 1))
        self.connect((self.analog_sig_source_x_0_0_1, 0),
                     (self.blocks_multiply_xx_0_1, 1))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.analog_sig_source_x_1_0, 0),
                     (self.blocks_multiply_xx_1_0, 0))
        self.connect((self.analog_sig_source_x_2, 0),
                     (self.blocks_multiply_xx_0_0_0_0_0, 1))
        self.connect((self.analog_sig_source_x_2_0, 0),
                     (self.blocks_multiply_xx_0_0_0_0_0_0, 1))
        self.connect((self.analog_sig_source_x_3, 0),
                     (self.blocks_multiply_const_vxx_3, 0))
        self.connect((self.analog_sig_source_x_3, 0),
                     (self.blocks_multiply_const_vxx_3_0, 0))
        self.connect((self.audio_source_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.audio_source_0, 1),
                     (self.blocks_float_to_complex_0_0, 0))
        self.connect((self.audio_source_0, 2), (self.blocks_null_sink_0, 0))
        self.connect((self.audio_source_0, 3), (self.blocks_null_sink_0, 1))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_add_xx_0_0, 0),
                     (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.blocks_add_xx_0_0_0, 0),
                     (self.blocks_multiply_const_vxx_2_0, 0))
        self.connect((self.blocks_add_xx_0_1, 0),
                     (self.blocks_multiply_xx_1_0, 1))
        self.connect((self.blocks_add_xx_1, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_add_xx_1_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_2, 0),
                     (self.single_pole_iir_filter_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_2_0, 0),
                     (self.single_pole_iir_filter_xx_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_2_0_0, 0),
                     (self.single_pole_iir_filter_xx_0_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_2_1, 0),
                     (self.single_pole_iir_filter_xx_0_1, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_add_xx_1, 0))
        self.connect((self.blocks_complex_to_real_0_0, 0),
                     (self.blocks_add_xx_1_0, 1))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_multiply_xx_0_0_0_0, 0))
        self.connect((self.blocks_delay_0_0, 0),
                     (self.blocks_multiply_xx_0_0_0_0_1, 0))
        self.connect((self.blocks_divide_xx_1, 0),
                     (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_divide_xx_1_0, 0),
                     (self.blocks_nlog10_ff_0_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_float_to_complex_0_0, 0),
                     (self.blocks_multiply_xx_0_1, 0))
        self.connect((self.blocks_float_to_complex_1, 0),
                     (self.blocks_multiply_xx_0_0_0_0_0, 2))
        self.connect((self.blocks_float_to_complex_1_0, 0),
                     (self.blocks_multiply_xx_0_0_0_0_0_0, 2))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_rms_xx_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.blocks_rms_xx_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_float_to_complex_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.blocks_float_to_complex_1_0, 0))
        self.connect((self.blocks_multiply_const_vxx_2, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_multiply_const_vxx_2_0, 0),
                     (self.blocks_complex_to_real_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_3, 0),
                     (self.blocks_add_xx_1, 1))
        self.connect((self.blocks_multiply_const_vxx_3_0, 0),
                     (self.blocks_add_xx_1_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.blocks_multiply_xx_0_0_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.blocks_rms_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0_0_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0_0_0_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_xx_0_0_0_0_0, 0),
                     (self.blocks_add_xx_0_0, 1))
        self.connect((self.blocks_multiply_xx_0_0_0_0_0, 0),
                     (self.blocks_complex_to_mag_squared_2_0, 0))
        self.connect((self.blocks_multiply_xx_0_0_0_0_0_0, 0),
                     (self.blocks_add_xx_0_0_0, 1))
        self.connect((self.blocks_multiply_xx_0_0_0_0_0_0, 0),
                     (self.blocks_complex_to_mag_squared_2_0_0, 0))
        self.connect((self.blocks_multiply_xx_0_0_0_0_1, 0),
                     (self.blocks_add_xx_0_1, 1))
        self.connect((self.blocks_multiply_xx_0_0_0_1, 0),
                     (self.blocks_add_xx_0_1, 0))
        self.connect((self.blocks_multiply_xx_0_0_1, 0),
                     (self.blocks_delay_0_0, 0))
        self.connect((self.blocks_multiply_xx_0_0_1, 0),
                     (self.blocks_multiply_xx_0_0_0_1, 0))
        self.connect((self.blocks_multiply_xx_0_0_1, 0),
                     (self.blocks_rms_xx_0_1, 0))
        self.connect((self.blocks_multiply_xx_0_1, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0),
                     (self.blocks_add_xx_0_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0),
                     (self.blocks_complex_to_mag_squared_2, 0))
        self.connect((self.blocks_multiply_xx_1_0, 0),
                     (self.blocks_add_xx_0_0_0, 0))
        self.connect((self.blocks_multiply_xx_1_0, 0),
                     (self.blocks_complex_to_mag_squared_2_1, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.blocks_streams_to_vector_0, 2))
        self.connect((self.blocks_nlog10_ff_0_0, 0),
                     (self.blocks_streams_to_vector_0, 3))
        self.connect((self.blocks_null_source_0, 0), (self.audio_sink_0, 2))
        self.connect((self.blocks_null_source_0, 1), (self.audio_sink_0, 3))
        self.connect((self.blocks_rms_xx_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_rms_xx_0_0, 0),
                     (self.blocks_streams_to_vector_0_0, 0))
        self.connect((self.blocks_rms_xx_0_0_0, 0),
                     (self.blocks_streams_to_vector_0_0, 1))
        self.connect((self.blocks_rms_xx_0_1, 0),
                     (self.blocks_multiply_const_vxx_1_0, 0))
        self.connect((self.blocks_selector_0, 0),
                     (self.blocks_multiply_xx_0_0_0, 1))
        self.connect((self.blocks_selector_0_0, 0),
                     (self.blocks_multiply_xx_0_0_0_0, 1))
        self.connect((self.blocks_selector_0_0_0, 0),
                     (self.blocks_multiply_xx_0_0_0_0_1, 1))
        self.connect((self.blocks_selector_0_1, 0),
                     (self.blocks_multiply_xx_0_0_0_1, 1))
        self.connect((self.blocks_streams_to_vector_0, 0), (self.snrOut, 0))
        self.connect((self.blocks_streams_to_vector_0_0, 0),
                     (self.outSigRMS, 0))
        self.connect((self.epy_block_0, 0), (self.low_pass_filter_1, 0))
        self.connect((self.epy_block_0_0, 0), (self.low_pass_filter_1_0, 0))
        self.connect((self.epy_block_0_0_0, 0), (self.low_pass_filter_1_1, 0))
        self.connect((self.epy_block_0_0_0_0, 0),
                     (self.low_pass_filter_1_0_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_multiply_xx_0_0_1, 0))
        self.connect((self.low_pass_filter_1, 0), (self.blocks_selector_0, 0))
        self.connect((self.low_pass_filter_1_0, 0),
                     (self.blocks_selector_0_0, 0))
        self.connect((self.low_pass_filter_1_0_0, 0),
                     (self.blocks_selector_0_0_0, 0))
        self.connect((self.low_pass_filter_1_1, 0),
                     (self.blocks_selector_0_1, 0))
        self.connect((self.low_pass_filter_2, 0),
                     (self.blocks_multiply_xx_0_0_0_0_0, 0))
        self.connect((self.low_pass_filter_2_0, 0),
                     (self.blocks_multiply_xx_0_0_0_0_0_0, 0))
        self.connect((self.single_pole_iir_filter_xx_0, 0),
                     (self.blocks_divide_xx_1, 0))
        self.connect((self.single_pole_iir_filter_xx_0, 0),
                     (self.blocks_streams_to_vector_0, 0))
        self.connect((self.single_pole_iir_filter_xx_0_0, 0),
                     (self.blocks_divide_xx_1, 1))
        self.connect((self.single_pole_iir_filter_xx_0_0, 0),
                     (self.blocks_streams_to_vector_0, 1))
        self.connect((self.single_pole_iir_filter_xx_0_0_0, 0),
                     (self.blocks_divide_xx_1_0, 1))
        self.connect((self.single_pole_iir_filter_xx_0_1, 0),
                     (self.blocks_divide_xx_1_0, 0))
Ejemplo n.º 19
0
    def __init__(self):
        gr.top_block.__init__(self, "Not titled yet")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Not titled yet")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

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

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 10e6
        self.fsk_deviation_hz = fsk_deviation_hz = 10e3
        self.Vc = Vc = 10

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "DEMOD",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0.set_y_axis(-10, 10)

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

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

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

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

        self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win, 0, 0,
                                       1, 2)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_NONE, 1)
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("RMS")

        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.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_rms_xx_0 = blocks.rms_ff(0.0001)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(1 / Vc)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            '/home/fran/Documents/UCA/4to año/Radiodifusión/git/Radiodifusion/TP1/Parte 3/FM.dat',
            True, 0, 0)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf(
            samp_rate / (2 * math.pi * fsk_deviation_hz / 8.0))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_rms_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_time_sink_x_1_0, 0))
        self.connect((self.blocks_rms_xx_0, 0), (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.analog_quadrature_demod_cf_0_0, 0))
Ejemplo n.º 20
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Acpmeter")
        _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 = 96000

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=9600,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Power [Watts]",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
        	self.GetWin(),
        	unit="Units",
        	minval=-100,
        	maxval=1000,
        	factor=1.0,
        	decimal_places=10,
        	ref_level=0,
        	sample_rate=samp_rate,
        	number_rate=15,
        	average=False,
        	avg_alpha=None,
        	label="Number Plot",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0.win)
        self.fir_filter_xxx_0 = filter.fir_filter_fff(10, (firdes.low_pass(1, samp_rate, 100, 100, firdes.WIN_BLACKMAN_HARRIS)))
        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_rms_xx_0 = blocks.rms_ff(0.1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((1, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1, ))
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_abs_xx_0 = blocks.abs_ff(1)
        self.blks2_tcp_source_0 = grc_blks2.tcp_source(
        	itemsize=gr.sizeof_gr_complex*1,
        	addr="127.0.0.1",
        	port=3701,
        	server=False,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_tcp_source_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_abs_xx_0, 0), (self.blocks_rms_xx_0, 0))    
        self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_const_vxx_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_abs_xx_0, 0))    
        self.connect((self.blocks_rms_xx_0, 0), (self.fir_filter_xxx_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.blocks_complex_to_float_0, 0))    
        self.connect((self.fir_filter_xxx_0, 0), (self.wxgui_numbersink2_0, 0))    
        self.connect((self.fir_filter_xxx_0, 0), (self.wxgui_scopesink2_0, 0))    
Ejemplo n.º 21
0
 def init(self, alpha=0.0001):
     self.gr_block = blocks.rms_ff(alpha)