Exemple #1
0
    def test_parallelism0_02(self):
        frame_size = 30
        rep = 3
        enc = fec.repetition_encoder_make(frame_size * 8, rep)
        dec = fec.repetition_decoder.make(frame_size * 8, rep)
        threading = 'capillary'
        self.test = _qa_helper(10 * frame_size, enc, dec, threading)
        self.tb.connect(self.test)
        self.tb.run()

        data_in = self.test.snk_input.data()
        data_out = self.test.snk_output.data()

        self.assertEqual(data_in, data_out)
    def test_parallelism1_01(self):
        frame_size = 30
        rep = 3
        enc = list(map((lambda a: fec.repetition_encoder_make(frame_size*8, rep)), list(range(0,1))))
        dec = list(map((lambda a: fec.repetition_decoder.make(frame_size*8, rep)), list(range(0,1))))
        threading = 'ordinary'
        self.test = _qa_helper(10*frame_size, enc, dec, threading)
        self.tb.connect(self.test)
        self.tb.run()

        data_in = self.test.snk_input.data()
        data_out =self.test.snk_output.data()

        self.assertEqual(data_in, data_out)
Exemple #3
0
    def test_parallelism1_04(self):
        frame_size = 30
        rep = 3
        dims = 16
        enc = list(
            map((lambda a: fec.repetition_encoder_make(frame_size * 8, rep)),
                list(range(0, dims))))
        dec = list(
            map((lambda a: fec.repetition_decoder.make(frame_size * 8, rep)),
                list(range(0, dims))))
        threading = 'capillary'
        self.test = _qa_helper(dims * frame_size, enc, dec, threading)
        self.tb.connect(self.test)
        self.tb.run()

        data_in = self.test.snk_input.data()
        data_out = self.test.snk_output.data()

        self.assertSequenceEqualGR(data_in, data_out)
Exemple #4
0
    def __init__(self):
        gr.top_block.__init__(self, "Packet Loopback Hier")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Packet Loopback Hier")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        
        self.Const_PLD = Const_PLD = digital.constellation_calcdist((digital.psk_4()[0]), (digital.psk_4()[1]), 4, 1).base()
        
        self.Const_PLD.gen_soft_dec_lut(8)
        self.sps = sps = 2
        self.rep = rep = 3
        self.rate = rate = 2
        self.polys = polys = [109, 79]
        self.nfilts = nfilts = 32
        self.k = k = 7
        self.hdr_format = hdr_format = digital.header_format_counter(digital.packet_utils.default_access_code, 3, Const_PLD.bits_per_symbol())
        self.eb = eb = 0.22
        
        self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0, eb, 5*sps*nfilts)
          
        self.time_offset = time_offset = 1.0
        
        self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine(nfilts, nfilts*sps, 1.0, eb, 11*sps*nfilts)
          
        self.noise = noise = 0.0
        self.freq_offset = freq_offset = 0
        
        
        self.enc_hdr = enc_hdr = fec.repetition_encoder_make(8000, rep)
            
        
        
        self.enc = enc = fec.cc_encoder_make(8000, k, rate, (polys), 0, fec.CC_TERMINATED, False)
            
        
        
        self.dec_hdr = dec_hdr = fec.repetition_decoder.make(hdr_format.header_nbits(), rep, 0.5)
            
        
        
        self.dec = dec = fec.cc_decoder.make(8000, k, rate, (polys), 0, -1, fec.CC_TERMINATED, False)
            
        self.amp = amp = 1.0
        
        self.Const_HDR = Const_HDR = digital.constellation_calcdist((digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base()
        
        self.Const_HDR.gen_soft_dec_lut(8)

        ##################################################
        # Blocks
        ##################################################
        self._time_offset_range = Range(0.99, 1.01, 0.00001, 1.0, 200)
        self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, 'Time Offset', "counter_slider", float)
        self.top_grid_layout.addWidget(self._time_offset_win, 0,2,1,1)
        self.tab1 = Qt.QTabWidget()
        self.tab1_widget_0 = Qt.QWidget()
        self.tab1_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab1_widget_0)
        self.tab1_grid_layout_0 = Qt.QGridLayout()
        self.tab1_layout_0.addLayout(self.tab1_grid_layout_0)
        self.tab1.addTab(self.tab1_widget_0, 'Time')
        self.tab1_widget_1 = Qt.QWidget()
        self.tab1_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab1_widget_1)
        self.tab1_grid_layout_1 = Qt.QGridLayout()
        self.tab1_layout_1.addLayout(self.tab1_grid_layout_1)
        self.tab1.addTab(self.tab1_widget_1, 'Freq.')
        self.tab1_widget_2 = Qt.QWidget()
        self.tab1_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab1_widget_2)
        self.tab1_grid_layout_2 = Qt.QGridLayout()
        self.tab1_layout_2.addLayout(self.tab1_grid_layout_2)
        self.tab1.addTab(self.tab1_widget_2, 'Const.')
        self.top_grid_layout.addWidget(self.tab1, 1,2,1,1)
        self.tab0 = Qt.QTabWidget()
        self.tab0_widget_0 = Qt.QWidget()
        self.tab0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_0)
        self.tab0_grid_layout_0 = Qt.QGridLayout()
        self.tab0_layout_0.addLayout(self.tab0_grid_layout_0)
        self.tab0.addTab(self.tab0_widget_0, 'Time')
        self.tab0_widget_1 = Qt.QWidget()
        self.tab0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_1)
        self.tab0_grid_layout_1 = Qt.QGridLayout()
        self.tab0_layout_1.addLayout(self.tab0_grid_layout_1)
        self.tab0.addTab(self.tab0_widget_1, 'Freq.')
        self.tab0_widget_2 = Qt.QWidget()
        self.tab0_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_2)
        self.tab0_grid_layout_2 = Qt.QGridLayout()
        self.tab0_layout_2.addLayout(self.tab0_grid_layout_2)
        self.tab0.addTab(self.tab0_widget_2, 'Const.')
        self.top_grid_layout.addWidget(self.tab0, 1,1,1,1)
        self._noise_range = Range(0, 5, 0.01, 0.0, 200)
        self._noise_win = RangeWidget(self._noise_range, self.set_noise, 'Noise Amp', "counter_slider", float)
        self.top_grid_layout.addWidget(self._noise_win, 0,0,1,1)
        self._freq_offset_range = Range(-0.5, 0.5, 0.0001, 0, 200)
        self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Freq. Offset', "counter_slider", float)
        self.top_grid_layout.addWidget(self._freq_offset_win, 0,1,1,1)
        self._amp_range = Range(0, 2, 0.01, 1.0, 200)
        self._amp_win = RangeWidget(self._amp_range, self.set_amp, 'Amplitude', "counter_slider", float)
        self.top_layout.addWidget(self._amp_win)
        self.qtgui_time_sink_x_1_0_0_1 = qtgui.time_sink_c(
        	125, #size
        	1, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_1_0_0_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0_0_1.set_y_axis(-2, 2)
        
        self.qtgui_time_sink_x_1_0_0_1.set_y_label('Amplitude', "")
        
        self.qtgui_time_sink_x_1_0_0_1.enable_tags(-1, True)
        self.qtgui_time_sink_x_1_0_0_1.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 25, 0, "payload symbols")
        self.qtgui_time_sink_x_1_0_0_1.enable_autoscale(False)
        self.qtgui_time_sink_x_1_0_0_1.enable_grid(False)
        self.qtgui_time_sink_x_1_0_0_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_1_0_0_1.enable_control_panel(False)
        
        if not False:
          self.qtgui_time_sink_x_1_0_0_1.disable_legend()
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [3, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [0, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(2*1):
            if len(labels[i]) == 0:
                if(i % 2 == 0):
                    self.qtgui_time_sink_x_1_0_0_1.set_line_label(i, "Re{{Data {0}}}".format(i/2))
                else:
                    self.qtgui_time_sink_x_1_0_0_1.set_line_label(i, "Im{{Data {0}}}".format(i/2))
            else:
                self.qtgui_time_sink_x_1_0_0_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_0_0_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_0_0_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_0_0_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_0_0_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_0_0_1.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_1_0_0_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0_0_1.pyqwidget(), Qt.QWidget)
        self.tab1_layout_0.addWidget(self._qtgui_time_sink_x_1_0_0_1_win)
        self.qtgui_time_sink_x_1_0_0_0 = qtgui.time_sink_c(
        	1250, #size
        	1, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_1_0_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0_0_0.set_y_axis(-150, 150)
        
        self.qtgui_time_sink_x_1_0_0_0.set_y_label('Correlation', "")
        
        self.qtgui_time_sink_x_1_0_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_1_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 50, 0, "corr_est")
        self.qtgui_time_sink_x_1_0_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_1_0_0_0.enable_grid(False)
        self.qtgui_time_sink_x_1_0_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_1_0_0_0.enable_control_panel(False)
        
        if not False:
          self.qtgui_time_sink_x_1_0_0_0.disable_legend()
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(2*1):
            if len(labels[i]) == 0:
                if(i % 2 == 0):
                    self.qtgui_time_sink_x_1_0_0_0.set_line_label(i, "Re{{Data {0}}}".format(i/2))
                else:
                    self.qtgui_time_sink_x_1_0_0_0.set_line_label(i, "Im{{Data {0}}}".format(i/2))
            else:
                self.qtgui_time_sink_x_1_0_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_0_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_0_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_0_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_0_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_0_0_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_1_0_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_0_0_win, 1,0,1,1)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_c(
        	2500, #size
        	1, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-2, 2)
        
        self.qtgui_time_sink_x_1.set_y_label('Amplitude', "")
        
        self.qtgui_time_sink_x_1.enable_tags(-1, True)
        self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, 'packet_len')
        self.qtgui_time_sink_x_1.enable_autoscale(False)
        self.qtgui_time_sink_x_1.enable_grid(False)
        self.qtgui_time_sink_x_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_1.enable_control_panel(False)
        
        if not False:
          self.qtgui_time_sink_x_1.disable_legend()
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(2*1):
            if len(labels[i]) == 0:
                if(i % 2 == 0):
                    self.qtgui_time_sink_x_1.set_line_label(i, "Re{{Data {0}}}".format(i/2))
                else:
                    self.qtgui_time_sink_x_1.set_line_label(i, "Im{{Data {0}}}".format(i/2))
            else:
                self.qtgui_time_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.tab0_layout_0.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	1, #bw
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0.enable_grid(False)
        self.qtgui_freq_sink_x_0_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)
        
        if not False:
          self.qtgui_freq_sink_x_0_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True)
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.tab1_layout_1.addWidget(self._qtgui_freq_sink_x_0_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	1, #bw
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)
        
        if not False:
          self.qtgui_freq_sink_x_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab0_layout_1.addWidget(self._qtgui_freq_sink_x_0_win)
        self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c(
        	800, #size
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True)
        
        if not False:
          self.qtgui_const_sink_x_0_0_0.disable_legend()
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "red", "red", "red",
                  "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
                   0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.tab1_layout_2.addWidget(self._qtgui_const_sink_x_0_0_0_win)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
        	1024, #size
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 'packet_len')
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)
        
        if not False:
          self.qtgui_const_sink_x_0.disable_legend()
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "red", "red", "red",
                  "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
                   0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab0_layout_2.addWidget(self._qtgui_const_sink_x_0_win)
        self.packet_tx_0 = packet_tx(
            hdr_const=Const_HDR,
            hdr_enc=enc_hdr,
            hdr_format=hdr_format,
            pld_const=Const_PLD,
            pld_enc=enc,
            psf_taps=tx_rrc_taps,
            sps=sps,
        )
        self.packet_rx_0 = packet_rx(
            eb=eb,
            hdr_const=Const_HDR,
            hdr_dec=dec_hdr,
            hdr_format=hdr_format,
            pld_const=Const_PLD,
            pld_dec=dec,
            psf_taps=rx_rrc_taps,
            sps=sps,
        )
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage=noise,
        	frequency_offset=freq_offset,
        	epsilon=time_offset,
        	taps=(1.0, ),
        	noise_seed=0,
        	block_tags=True
        )
        self.blocks_random_pdu_0 = blocks.random_pdu(20, 200, chr(0xFF), 2)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((amp, ))
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("TEST"), 1000)
        self.blocks_message_debug_0_0_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.blocks_random_pdu_0, 'generate'))    
        self.msg_connect((self.blocks_random_pdu_0, 'pdus'), (self.packet_tx_0, 'in'))    
        self.msg_connect((self.packet_rx_0, 'pkt out'), (self.blocks_message_debug_0_0_0, 'print_pdu'))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.packet_rx_0, 0))    
        self.connect((self.channels_channel_model_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.channels_channel_model_0, 0), (self.qtgui_const_sink_x_0, 0))    
        self.connect((self.channels_channel_model_0, 0), (self.qtgui_freq_sink_x_0, 0))    
        self.connect((self.channels_channel_model_0, 0), (self.qtgui_time_sink_x_1, 0))    
        self.connect((self.packet_rx_0, 1), (self.qtgui_const_sink_x_0_0_0, 0))    
        self.connect((self.packet_rx_0, 1), (self.qtgui_freq_sink_x_0_0, 0))    
        self.connect((self.packet_rx_0, 4), (self.qtgui_time_sink_x_1_0_0_0, 0))    
        self.connect((self.packet_rx_0, 1), (self.qtgui_time_sink_x_1_0_0_1, 0))    
        self.connect((self.packet_tx_0, 0), (self.channels_channel_model_0, 0))    
Exemple #5
0
    def __init__(self):
        gr.top_block.__init__(self, "Ber Curve Gen")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Ber Curve Gen")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.rate = rate = 2
        self.polys = polys = [79, 109]
        self.k = k = 7
        self.framebits = framebits = 4096
        self.esno_0 = esno_0 = numpy.arange(0, 8, .5)
        self.samp_rate_0 = samp_rate_0 = 35000000

        self.enc_tpc = enc_tpc = map((lambda b: map(
            (lambda a: fec.tpc_encoder_make(
                ([3]), ([43]), 26, 6, 9, 3)), range(0, 1))),
                                     range(0, len(esno_0)))

        self.enc_rep = enc_rep = map((lambda b: map(
            (lambda a: fec.repetition_encoder_make(framebits, 3)), range(0, 1))
                                      ), range(0, len(esno_0)))

        self.enc_ldpc = enc_ldpc = map((lambda b: map(
            (lambda a: fec.ldpc_encoder_make(
                '/usr/share/gnuradio/fec/ldpc/271.127.3.112')), range(0, 1))),
                                       range(0, len(esno_0)))

        self.enc_dummy = enc_dummy = map((lambda b: map(
            (lambda a: fec.dummy_encoder_make(framebits)), range(0, 1))),
                                         range(0, len(esno_0)))

        self.enc_cc = enc_cc = map((lambda b: map(
            (lambda a: fec.cc_encoder_make(framebits, k, rate, (
                polys), 0, fec.CC_STREAMING, False)), range(0, 1))),
                                   range(0, len(esno_0)))

        self.dec_tpc = dec_tpc = map((lambda b: map(
            (lambda a: fec.tpc_decoder_make(
                ([3]), ([43]), 26, 6, 9, 3, 6, 1)), range(0, 1))),
                                     range(0, len(esno_0)))

        self.dec_rep = dec_rep = map((lambda b: map(
            (lambda a: fec.repetition_decoder.make(framebits, 3, 0.5)),
            range(0, 1))), range(0, len(esno_0)))

        self.dec_ldpc = dec_ldpc = map((lambda b: map(
            (lambda a: fec.ldpc_decoder.make(
                '/usr/share/gnuradio/fec/ldpc/271.127.3.112', 0.5, 50)),
            range(0, 1))), range(0, len(esno_0)))

        self.dec_dummy = dec_dummy = map((lambda b: map(
            (lambda a: fec.dummy_decoder.make(framebits)), range(0, 1))),
                                         range(0, len(esno_0)))

        self.dec_cc = dec_cc = map((lambda b: map(
            (lambda a: fec.cc_decoder.make(framebits, k, rate, (
                polys), 0, -1, fec.CC_STREAMING, False)), range(0, 1))),
                                   range(0, len(esno_0)))

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_bercurve_sink_0 = qtgui.ber_sink_b(
            esno_0,  #range of esnos
            5,  #number of curves
            1000,  #ensure at least
            -10,  #cutoff
            [],  #indiv. curve names
        )
        self.qtgui_bercurve_sink_0.set_update_time(0.10)
        self.qtgui_bercurve_sink_0.set_y_axis(-10, 0)
        self.qtgui_bercurve_sink_0.set_x_axis(esno_0[0], esno_0[-1])

        labels = [
            'None', 'Rep. (Rate=3)', 'CC (K=7, Rate=2)', 'LDPC', 'TPC', '', '',
            '', '', ''
        ]
        widths = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "magenta", "dark red", "Dark Blue", "red", "red",
            "red", "red", "red"
        ]
        styles = [1, 2, 5, 5, 4, 0, 0, 0, 0, 0]
        markers = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1, 1, 1, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(5):
            if len(labels[i]) == 0:
                self.qtgui_bercurve_sink_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_bercurve_sink_0.set_line_label(i, labels[i])
            self.qtgui_bercurve_sink_0.set_line_width(i, widths[i])
            self.qtgui_bercurve_sink_0.set_line_color(i, colors[i])
            self.qtgui_bercurve_sink_0.set_line_style(i, styles[i])
            self.qtgui_bercurve_sink_0.set_line_marker(i, markers[i])
            self.qtgui_bercurve_sink_0.set_line_alpha(i, alphas[i])

        self._qtgui_bercurve_sink_0_win = sip.wrapinstance(
            self.qtgui_bercurve_sink_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_bercurve_sink_0_win)
        self.fec_bercurve_generator_0_1_0 = fec.bercurve_generator(
            enc_tpc,  #size
            dec_tpc,  #name
            esno_0,  #range of esnos
            samp_rate_0,  #throttle
            "capillary",  #threading mode
            '11',  #puncture pattern
            -100  # noise gen. seed
        )

        self.fec_bercurve_generator_0_1 = fec.bercurve_generator(
            enc_ldpc,  #size
            dec_ldpc,  #name
            esno_0,  #range of esnos
            samp_rate_0,  #throttle
            "capillary",  #threading mode
            '11',  #puncture pattern
            -100  # noise gen. seed
        )

        self.fec_bercurve_generator_0_0_0 = fec.bercurve_generator(
            enc_dummy,  #size
            dec_dummy,  #name
            esno_0,  #range of esnos
            samp_rate_0,  #throttle
            "capillary",  #threading mode
            '11',  #puncture pattern
            -100  # noise gen. seed
        )

        self.fec_bercurve_generator_0_0 = fec.bercurve_generator(
            enc_rep,  #size
            dec_rep,  #name
            esno_0,  #range of esnos
            samp_rate_0,  #throttle
            "capillary",  #threading mode
            '11',  #puncture pattern
            -100  # noise gen. seed
        )

        self.fec_bercurve_generator_0 = fec.bercurve_generator(
            enc_cc,  #size
            dec_cc,  #name
            esno_0,  #range of esnos
            samp_rate_0,  #throttle
            "capillary",  #threading mode
            '11',  #puncture pattern
            -100  # noise gen. seed
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.fec_bercurve_generator_0, 0),
                     (self.qtgui_bercurve_sink_0, 64))
        self.connect((self.fec_bercurve_generator_0, 1),
                     (self.qtgui_bercurve_sink_0, 65))
        self.connect((self.fec_bercurve_generator_0, 2),
                     (self.qtgui_bercurve_sink_0, 66))
        self.connect((self.fec_bercurve_generator_0, 3),
                     (self.qtgui_bercurve_sink_0, 67))
        self.connect((self.fec_bercurve_generator_0, 4),
                     (self.qtgui_bercurve_sink_0, 68))
        self.connect((self.fec_bercurve_generator_0, 5),
                     (self.qtgui_bercurve_sink_0, 69))
        self.connect((self.fec_bercurve_generator_0, 6),
                     (self.qtgui_bercurve_sink_0, 70))
        self.connect((self.fec_bercurve_generator_0, 7),
                     (self.qtgui_bercurve_sink_0, 71))
        self.connect((self.fec_bercurve_generator_0, 8),
                     (self.qtgui_bercurve_sink_0, 72))
        self.connect((self.fec_bercurve_generator_0, 9),
                     (self.qtgui_bercurve_sink_0, 73))
        self.connect((self.fec_bercurve_generator_0, 10),
                     (self.qtgui_bercurve_sink_0, 74))
        self.connect((self.fec_bercurve_generator_0, 11),
                     (self.qtgui_bercurve_sink_0, 75))
        self.connect((self.fec_bercurve_generator_0, 12),
                     (self.qtgui_bercurve_sink_0, 76))
        self.connect((self.fec_bercurve_generator_0, 13),
                     (self.qtgui_bercurve_sink_0, 77))
        self.connect((self.fec_bercurve_generator_0, 14),
                     (self.qtgui_bercurve_sink_0, 78))
        self.connect((self.fec_bercurve_generator_0, 15),
                     (self.qtgui_bercurve_sink_0, 79))
        self.connect((self.fec_bercurve_generator_0, 16),
                     (self.qtgui_bercurve_sink_0, 80))
        self.connect((self.fec_bercurve_generator_0, 17),
                     (self.qtgui_bercurve_sink_0, 81))
        self.connect((self.fec_bercurve_generator_0, 18),
                     (self.qtgui_bercurve_sink_0, 82))
        self.connect((self.fec_bercurve_generator_0, 19),
                     (self.qtgui_bercurve_sink_0, 83))
        self.connect((self.fec_bercurve_generator_0, 20),
                     (self.qtgui_bercurve_sink_0, 84))
        self.connect((self.fec_bercurve_generator_0, 21),
                     (self.qtgui_bercurve_sink_0, 85))
        self.connect((self.fec_bercurve_generator_0, 22),
                     (self.qtgui_bercurve_sink_0, 86))
        self.connect((self.fec_bercurve_generator_0, 23),
                     (self.qtgui_bercurve_sink_0, 87))
        self.connect((self.fec_bercurve_generator_0, 24),
                     (self.qtgui_bercurve_sink_0, 88))
        self.connect((self.fec_bercurve_generator_0, 25),
                     (self.qtgui_bercurve_sink_0, 89))
        self.connect((self.fec_bercurve_generator_0, 26),
                     (self.qtgui_bercurve_sink_0, 90))
        self.connect((self.fec_bercurve_generator_0, 27),
                     (self.qtgui_bercurve_sink_0, 91))
        self.connect((self.fec_bercurve_generator_0, 28),
                     (self.qtgui_bercurve_sink_0, 92))
        self.connect((self.fec_bercurve_generator_0, 29),
                     (self.qtgui_bercurve_sink_0, 93))
        self.connect((self.fec_bercurve_generator_0, 30),
                     (self.qtgui_bercurve_sink_0, 94))
        self.connect((self.fec_bercurve_generator_0, 31),
                     (self.qtgui_bercurve_sink_0, 95))
        self.connect((self.fec_bercurve_generator_0_0, 0),
                     (self.qtgui_bercurve_sink_0, 32))
        self.connect((self.fec_bercurve_generator_0_0, 1),
                     (self.qtgui_bercurve_sink_0, 33))
        self.connect((self.fec_bercurve_generator_0_0, 2),
                     (self.qtgui_bercurve_sink_0, 34))
        self.connect((self.fec_bercurve_generator_0_0, 3),
                     (self.qtgui_bercurve_sink_0, 35))
        self.connect((self.fec_bercurve_generator_0_0, 4),
                     (self.qtgui_bercurve_sink_0, 36))
        self.connect((self.fec_bercurve_generator_0_0, 5),
                     (self.qtgui_bercurve_sink_0, 37))
        self.connect((self.fec_bercurve_generator_0_0, 6),
                     (self.qtgui_bercurve_sink_0, 38))
        self.connect((self.fec_bercurve_generator_0_0, 7),
                     (self.qtgui_bercurve_sink_0, 39))
        self.connect((self.fec_bercurve_generator_0_0, 8),
                     (self.qtgui_bercurve_sink_0, 40))
        self.connect((self.fec_bercurve_generator_0_0, 9),
                     (self.qtgui_bercurve_sink_0, 41))
        self.connect((self.fec_bercurve_generator_0_0, 10),
                     (self.qtgui_bercurve_sink_0, 42))
        self.connect((self.fec_bercurve_generator_0_0, 11),
                     (self.qtgui_bercurve_sink_0, 43))
        self.connect((self.fec_bercurve_generator_0_0, 12),
                     (self.qtgui_bercurve_sink_0, 44))
        self.connect((self.fec_bercurve_generator_0_0, 13),
                     (self.qtgui_bercurve_sink_0, 45))
        self.connect((self.fec_bercurve_generator_0_0, 14),
                     (self.qtgui_bercurve_sink_0, 46))
        self.connect((self.fec_bercurve_generator_0_0, 15),
                     (self.qtgui_bercurve_sink_0, 47))
        self.connect((self.fec_bercurve_generator_0_0, 16),
                     (self.qtgui_bercurve_sink_0, 48))
        self.connect((self.fec_bercurve_generator_0_0, 17),
                     (self.qtgui_bercurve_sink_0, 49))
        self.connect((self.fec_bercurve_generator_0_0, 18),
                     (self.qtgui_bercurve_sink_0, 50))
        self.connect((self.fec_bercurve_generator_0_0, 19),
                     (self.qtgui_bercurve_sink_0, 51))
        self.connect((self.fec_bercurve_generator_0_0, 20),
                     (self.qtgui_bercurve_sink_0, 52))
        self.connect((self.fec_bercurve_generator_0_0, 21),
                     (self.qtgui_bercurve_sink_0, 53))
        self.connect((self.fec_bercurve_generator_0_0, 22),
                     (self.qtgui_bercurve_sink_0, 54))
        self.connect((self.fec_bercurve_generator_0_0, 23),
                     (self.qtgui_bercurve_sink_0, 55))
        self.connect((self.fec_bercurve_generator_0_0, 24),
                     (self.qtgui_bercurve_sink_0, 56))
        self.connect((self.fec_bercurve_generator_0_0, 25),
                     (self.qtgui_bercurve_sink_0, 57))
        self.connect((self.fec_bercurve_generator_0_0, 26),
                     (self.qtgui_bercurve_sink_0, 58))
        self.connect((self.fec_bercurve_generator_0_0, 27),
                     (self.qtgui_bercurve_sink_0, 59))
        self.connect((self.fec_bercurve_generator_0_0, 28),
                     (self.qtgui_bercurve_sink_0, 60))
        self.connect((self.fec_bercurve_generator_0_0, 29),
                     (self.qtgui_bercurve_sink_0, 61))
        self.connect((self.fec_bercurve_generator_0_0, 30),
                     (self.qtgui_bercurve_sink_0, 62))
        self.connect((self.fec_bercurve_generator_0_0, 31),
                     (self.qtgui_bercurve_sink_0, 63))
        self.connect((self.fec_bercurve_generator_0_0_0, 0),
                     (self.qtgui_bercurve_sink_0, 0))
        self.connect((self.fec_bercurve_generator_0_0_0, 1),
                     (self.qtgui_bercurve_sink_0, 1))
        self.connect((self.fec_bercurve_generator_0_0_0, 2),
                     (self.qtgui_bercurve_sink_0, 2))
        self.connect((self.fec_bercurve_generator_0_0_0, 3),
                     (self.qtgui_bercurve_sink_0, 3))
        self.connect((self.fec_bercurve_generator_0_0_0, 4),
                     (self.qtgui_bercurve_sink_0, 4))
        self.connect((self.fec_bercurve_generator_0_0_0, 5),
                     (self.qtgui_bercurve_sink_0, 5))
        self.connect((self.fec_bercurve_generator_0_0_0, 6),
                     (self.qtgui_bercurve_sink_0, 6))
        self.connect((self.fec_bercurve_generator_0_0_0, 7),
                     (self.qtgui_bercurve_sink_0, 7))
        self.connect((self.fec_bercurve_generator_0_0_0, 8),
                     (self.qtgui_bercurve_sink_0, 8))
        self.connect((self.fec_bercurve_generator_0_0_0, 9),
                     (self.qtgui_bercurve_sink_0, 9))
        self.connect((self.fec_bercurve_generator_0_0_0, 10),
                     (self.qtgui_bercurve_sink_0, 10))
        self.connect((self.fec_bercurve_generator_0_0_0, 11),
                     (self.qtgui_bercurve_sink_0, 11))
        self.connect((self.fec_bercurve_generator_0_0_0, 12),
                     (self.qtgui_bercurve_sink_0, 12))
        self.connect((self.fec_bercurve_generator_0_0_0, 13),
                     (self.qtgui_bercurve_sink_0, 13))
        self.connect((self.fec_bercurve_generator_0_0_0, 14),
                     (self.qtgui_bercurve_sink_0, 14))
        self.connect((self.fec_bercurve_generator_0_0_0, 15),
                     (self.qtgui_bercurve_sink_0, 15))
        self.connect((self.fec_bercurve_generator_0_0_0, 16),
                     (self.qtgui_bercurve_sink_0, 16))
        self.connect((self.fec_bercurve_generator_0_0_0, 17),
                     (self.qtgui_bercurve_sink_0, 17))
        self.connect((self.fec_bercurve_generator_0_0_0, 18),
                     (self.qtgui_bercurve_sink_0, 18))
        self.connect((self.fec_bercurve_generator_0_0_0, 19),
                     (self.qtgui_bercurve_sink_0, 19))
        self.connect((self.fec_bercurve_generator_0_0_0, 20),
                     (self.qtgui_bercurve_sink_0, 20))
        self.connect((self.fec_bercurve_generator_0_0_0, 21),
                     (self.qtgui_bercurve_sink_0, 21))
        self.connect((self.fec_bercurve_generator_0_0_0, 22),
                     (self.qtgui_bercurve_sink_0, 22))
        self.connect((self.fec_bercurve_generator_0_0_0, 23),
                     (self.qtgui_bercurve_sink_0, 23))
        self.connect((self.fec_bercurve_generator_0_0_0, 24),
                     (self.qtgui_bercurve_sink_0, 24))
        self.connect((self.fec_bercurve_generator_0_0_0, 25),
                     (self.qtgui_bercurve_sink_0, 25))
        self.connect((self.fec_bercurve_generator_0_0_0, 26),
                     (self.qtgui_bercurve_sink_0, 26))
        self.connect((self.fec_bercurve_generator_0_0_0, 27),
                     (self.qtgui_bercurve_sink_0, 27))
        self.connect((self.fec_bercurve_generator_0_0_0, 28),
                     (self.qtgui_bercurve_sink_0, 28))
        self.connect((self.fec_bercurve_generator_0_0_0, 29),
                     (self.qtgui_bercurve_sink_0, 29))
        self.connect((self.fec_bercurve_generator_0_0_0, 30),
                     (self.qtgui_bercurve_sink_0, 30))
        self.connect((self.fec_bercurve_generator_0_0_0, 31),
                     (self.qtgui_bercurve_sink_0, 31))
        self.connect((self.fec_bercurve_generator_0_1, 0),
                     (self.qtgui_bercurve_sink_0, 96))
        self.connect((self.fec_bercurve_generator_0_1, 1),
                     (self.qtgui_bercurve_sink_0, 97))
        self.connect((self.fec_bercurve_generator_0_1, 2),
                     (self.qtgui_bercurve_sink_0, 98))
        self.connect((self.fec_bercurve_generator_0_1, 3),
                     (self.qtgui_bercurve_sink_0, 99))
        self.connect((self.fec_bercurve_generator_0_1, 4),
                     (self.qtgui_bercurve_sink_0, 100))
        self.connect((self.fec_bercurve_generator_0_1, 5),
                     (self.qtgui_bercurve_sink_0, 101))
        self.connect((self.fec_bercurve_generator_0_1, 6),
                     (self.qtgui_bercurve_sink_0, 102))
        self.connect((self.fec_bercurve_generator_0_1, 7),
                     (self.qtgui_bercurve_sink_0, 103))
        self.connect((self.fec_bercurve_generator_0_1, 8),
                     (self.qtgui_bercurve_sink_0, 104))
        self.connect((self.fec_bercurve_generator_0_1, 9),
                     (self.qtgui_bercurve_sink_0, 105))
        self.connect((self.fec_bercurve_generator_0_1, 10),
                     (self.qtgui_bercurve_sink_0, 106))
        self.connect((self.fec_bercurve_generator_0_1, 11),
                     (self.qtgui_bercurve_sink_0, 107))
        self.connect((self.fec_bercurve_generator_0_1, 12),
                     (self.qtgui_bercurve_sink_0, 108))
        self.connect((self.fec_bercurve_generator_0_1, 13),
                     (self.qtgui_bercurve_sink_0, 109))
        self.connect((self.fec_bercurve_generator_0_1, 14),
                     (self.qtgui_bercurve_sink_0, 110))
        self.connect((self.fec_bercurve_generator_0_1, 15),
                     (self.qtgui_bercurve_sink_0, 111))
        self.connect((self.fec_bercurve_generator_0_1, 16),
                     (self.qtgui_bercurve_sink_0, 112))
        self.connect((self.fec_bercurve_generator_0_1, 17),
                     (self.qtgui_bercurve_sink_0, 113))
        self.connect((self.fec_bercurve_generator_0_1, 18),
                     (self.qtgui_bercurve_sink_0, 114))
        self.connect((self.fec_bercurve_generator_0_1, 19),
                     (self.qtgui_bercurve_sink_0, 115))
        self.connect((self.fec_bercurve_generator_0_1, 20),
                     (self.qtgui_bercurve_sink_0, 116))
        self.connect((self.fec_bercurve_generator_0_1, 21),
                     (self.qtgui_bercurve_sink_0, 117))
        self.connect((self.fec_bercurve_generator_0_1, 22),
                     (self.qtgui_bercurve_sink_0, 118))
        self.connect((self.fec_bercurve_generator_0_1, 23),
                     (self.qtgui_bercurve_sink_0, 119))
        self.connect((self.fec_bercurve_generator_0_1, 24),
                     (self.qtgui_bercurve_sink_0, 120))
        self.connect((self.fec_bercurve_generator_0_1, 25),
                     (self.qtgui_bercurve_sink_0, 121))
        self.connect((self.fec_bercurve_generator_0_1, 26),
                     (self.qtgui_bercurve_sink_0, 122))
        self.connect((self.fec_bercurve_generator_0_1, 27),
                     (self.qtgui_bercurve_sink_0, 123))
        self.connect((self.fec_bercurve_generator_0_1, 28),
                     (self.qtgui_bercurve_sink_0, 124))
        self.connect((self.fec_bercurve_generator_0_1, 29),
                     (self.qtgui_bercurve_sink_0, 125))
        self.connect((self.fec_bercurve_generator_0_1, 30),
                     (self.qtgui_bercurve_sink_0, 126))
        self.connect((self.fec_bercurve_generator_0_1, 31),
                     (self.qtgui_bercurve_sink_0, 127))
        self.connect((self.fec_bercurve_generator_0_1_0, 0),
                     (self.qtgui_bercurve_sink_0, 128))
        self.connect((self.fec_bercurve_generator_0_1_0, 1),
                     (self.qtgui_bercurve_sink_0, 129))
        self.connect((self.fec_bercurve_generator_0_1_0, 2),
                     (self.qtgui_bercurve_sink_0, 130))
        self.connect((self.fec_bercurve_generator_0_1_0, 3),
                     (self.qtgui_bercurve_sink_0, 131))
        self.connect((self.fec_bercurve_generator_0_1_0, 4),
                     (self.qtgui_bercurve_sink_0, 132))
        self.connect((self.fec_bercurve_generator_0_1_0, 5),
                     (self.qtgui_bercurve_sink_0, 133))
        self.connect((self.fec_bercurve_generator_0_1_0, 6),
                     (self.qtgui_bercurve_sink_0, 134))
        self.connect((self.fec_bercurve_generator_0_1_0, 7),
                     (self.qtgui_bercurve_sink_0, 135))
        self.connect((self.fec_bercurve_generator_0_1_0, 8),
                     (self.qtgui_bercurve_sink_0, 136))
        self.connect((self.fec_bercurve_generator_0_1_0, 9),
                     (self.qtgui_bercurve_sink_0, 137))
        self.connect((self.fec_bercurve_generator_0_1_0, 10),
                     (self.qtgui_bercurve_sink_0, 138))
        self.connect((self.fec_bercurve_generator_0_1_0, 11),
                     (self.qtgui_bercurve_sink_0, 139))
        self.connect((self.fec_bercurve_generator_0_1_0, 12),
                     (self.qtgui_bercurve_sink_0, 140))
        self.connect((self.fec_bercurve_generator_0_1_0, 13),
                     (self.qtgui_bercurve_sink_0, 141))
        self.connect((self.fec_bercurve_generator_0_1_0, 14),
                     (self.qtgui_bercurve_sink_0, 142))
        self.connect((self.fec_bercurve_generator_0_1_0, 15),
                     (self.qtgui_bercurve_sink_0, 143))
        self.connect((self.fec_bercurve_generator_0_1_0, 16),
                     (self.qtgui_bercurve_sink_0, 144))
        self.connect((self.fec_bercurve_generator_0_1_0, 17),
                     (self.qtgui_bercurve_sink_0, 145))
        self.connect((self.fec_bercurve_generator_0_1_0, 18),
                     (self.qtgui_bercurve_sink_0, 146))
        self.connect((self.fec_bercurve_generator_0_1_0, 19),
                     (self.qtgui_bercurve_sink_0, 147))
        self.connect((self.fec_bercurve_generator_0_1_0, 20),
                     (self.qtgui_bercurve_sink_0, 148))
        self.connect((self.fec_bercurve_generator_0_1_0, 21),
                     (self.qtgui_bercurve_sink_0, 149))
        self.connect((self.fec_bercurve_generator_0_1_0, 22),
                     (self.qtgui_bercurve_sink_0, 150))
        self.connect((self.fec_bercurve_generator_0_1_0, 23),
                     (self.qtgui_bercurve_sink_0, 151))
        self.connect((self.fec_bercurve_generator_0_1_0, 24),
                     (self.qtgui_bercurve_sink_0, 152))
        self.connect((self.fec_bercurve_generator_0_1_0, 25),
                     (self.qtgui_bercurve_sink_0, 153))
        self.connect((self.fec_bercurve_generator_0_1_0, 26),
                     (self.qtgui_bercurve_sink_0, 154))
        self.connect((self.fec_bercurve_generator_0_1_0, 27),
                     (self.qtgui_bercurve_sink_0, 155))
        self.connect((self.fec_bercurve_generator_0_1_0, 28),
                     (self.qtgui_bercurve_sink_0, 156))
        self.connect((self.fec_bercurve_generator_0_1_0, 29),
                     (self.qtgui_bercurve_sink_0, 157))
        self.connect((self.fec_bercurve_generator_0_1_0, 30),
                     (self.qtgui_bercurve_sink_0, 158))
        self.connect((self.fec_bercurve_generator_0_1_0, 31),
                     (self.qtgui_bercurve_sink_0, 159))
Exemple #6
0
    def __init__(self):
        gr.top_block.__init__(self, "Ber Curve Gen Ldpc")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Ber Curve Gen Ldpc")
        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", "ber_curve_gen_ldpc")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.framebits = framebits = 4096
        self.esno_0 = esno_0 = numpy.arange(0, 8.1, .5)
        self.H = H = fec.ldpc_H_matrix(
            gr.prefix() +
            "/share/gnuradio/fec/ldpc/n_1800_k_0902_gap_28.alist", 28)
        self.G = G = fec.ldpc_G_matrix(
            gr.prefix() + "/share/gnuradio/fec/ldpc/simple_g_matrix.alist")
        self.samp_rate_0 = samp_rate_0 = 35000000
        self.k = k = 7

        self.enc_rep = enc_rep = map((lambda b: map(
            (lambda a: fec.repetition_encoder_make(framebits, 3)), range(0, 1))
                                      ), range(0, len(esno_0)))

        self.enc_ldpc_G = enc_ldpc_G = map((lambda b: map(
            (lambda a: fec.ldpc_gen_mtrx_encoder_make(G)), range(0, 1))),
                                           range(0, len(esno_0)))

        self.enc_ldpc = enc_ldpc = map((lambda b: map(
            (lambda a: fec.ldpc_par_mtrx_encoder_make_H(H)), range(0, 1))),
                                       range(0, len(esno_0)))

        self.enc_dummy = enc_dummy = map((lambda b: map(
            (lambda a: fec.dummy_encoder_make(framebits)), range(0, 1))),
                                         range(0, len(esno_0)))

        self.dec_rep = dec_rep = map((lambda b: map(
            (lambda a: fec.repetition_decoder.make(framebits, 3, 0.5)),
            range(0, 1))), range(0, len(esno_0)))

        self.dec_ldpc_G = dec_ldpc_G = map((lambda b: map(
            (lambda a: fec.ldpc_bit_flip_decoder.make(G.get_base_sptr(), 100)),
            range(0, 1))), range(0, len(esno_0)))

        self.dec_ldpc = dec_ldpc = map((lambda b: map(
            (lambda a: fec.ldpc_bit_flip_decoder.make(H.get_base_sptr(), 100)),
            range(0, 1))), range(0, len(esno_0)))

        self.dec_dummy = dec_dummy = map((lambda b: map(
            (lambda a: fec.dummy_decoder.make(framebits)), range(0, 1))),
                                         range(0, len(esno_0)))

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_bercurve_sink_0 = qtgui.ber_sink_b(
            esno_0,  #range of esnos
            4,  #number of curves
            1000,  #ensure at least
            -10,  #cutoff
            [],  #indiv. curve names
        )
        self.qtgui_bercurve_sink_0.set_update_time(0.10)
        self.qtgui_bercurve_sink_0.set_y_axis(-10, 0)
        self.qtgui_bercurve_sink_0.set_x_axis(esno_0[0], esno_0[-1])

        labels = [
            'None', 'Rep. (Rate=3)', 'LDPC (H matrix)', 'LDPC (Gen. matrix)',
            '', '', '', '', '', ''
        ]
        widths = [2, 2, 2, 2, 1, 1, 1, 1, 1, 1]
        colors = [
            "black", "blue", "green", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [3, 2, 4, 1, 0, 0, 0, 0, 0, 0]
        markers = [8, 1, 2, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1, 1, 1, 1, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(4):
            if len(labels[i]) == 0:
                self.qtgui_bercurve_sink_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_bercurve_sink_0.set_line_label(i, labels[i])
            self.qtgui_bercurve_sink_0.set_line_width(i, widths[i])
            self.qtgui_bercurve_sink_0.set_line_color(i, colors[i])
            self.qtgui_bercurve_sink_0.set_line_style(i, styles[i])
            self.qtgui_bercurve_sink_0.set_line_marker(i, markers[i])
            self.qtgui_bercurve_sink_0.set_line_alpha(i, alphas[i])

        self._qtgui_bercurve_sink_0_win = sip.wrapinstance(
            self.qtgui_bercurve_sink_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_bercurve_sink_0_win)
        self.fec_bercurve_generator_1 = fec.bercurve_generator(
            enc_ldpc,  #size
            dec_ldpc,  #name
            esno_0,  #range of esnos
            samp_rate_0,  #throttle
            "capillary",  #threading mode
            '11',  #puncture pattern
            -100  # noise gen. seed
        )

        self.fec_bercurve_generator_0_0_0 = fec.bercurve_generator(
            enc_dummy,  #size
            dec_dummy,  #name
            esno_0,  #range of esnos
            samp_rate_0,  #throttle
            "capillary",  #threading mode
            '11',  #puncture pattern
            -100  # noise gen. seed
        )

        self.fec_bercurve_generator_0_0 = fec.bercurve_generator(
            enc_rep,  #size
            dec_rep,  #name
            esno_0,  #range of esnos
            samp_rate_0,  #throttle
            "capillary",  #threading mode
            '11',  #puncture pattern
            -100  # noise gen. seed
        )

        self.fec_bercurve_generator_0 = fec.bercurve_generator(
            enc_ldpc_G,  #size
            dec_ldpc_G,  #name
            esno_0,  #range of esnos
            samp_rate_0,  #throttle
            "capillary",  #threading mode
            '11',  #puncture pattern
            -100  # noise gen. seed
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.fec_bercurve_generator_0, 0),
                     (self.qtgui_bercurve_sink_0, 102))
        self.connect((self.fec_bercurve_generator_0, 1),
                     (self.qtgui_bercurve_sink_0, 103))
        self.connect((self.fec_bercurve_generator_0, 2),
                     (self.qtgui_bercurve_sink_0, 104))
        self.connect((self.fec_bercurve_generator_0, 3),
                     (self.qtgui_bercurve_sink_0, 105))
        self.connect((self.fec_bercurve_generator_0, 4),
                     (self.qtgui_bercurve_sink_0, 106))
        self.connect((self.fec_bercurve_generator_0, 5),
                     (self.qtgui_bercurve_sink_0, 107))
        self.connect((self.fec_bercurve_generator_0, 6),
                     (self.qtgui_bercurve_sink_0, 108))
        self.connect((self.fec_bercurve_generator_0, 7),
                     (self.qtgui_bercurve_sink_0, 109))
        self.connect((self.fec_bercurve_generator_0, 8),
                     (self.qtgui_bercurve_sink_0, 110))
        self.connect((self.fec_bercurve_generator_0, 9),
                     (self.qtgui_bercurve_sink_0, 111))
        self.connect((self.fec_bercurve_generator_0, 10),
                     (self.qtgui_bercurve_sink_0, 112))
        self.connect((self.fec_bercurve_generator_0, 11),
                     (self.qtgui_bercurve_sink_0, 113))
        self.connect((self.fec_bercurve_generator_0, 12),
                     (self.qtgui_bercurve_sink_0, 114))
        self.connect((self.fec_bercurve_generator_0, 13),
                     (self.qtgui_bercurve_sink_0, 115))
        self.connect((self.fec_bercurve_generator_0, 14),
                     (self.qtgui_bercurve_sink_0, 116))
        self.connect((self.fec_bercurve_generator_0, 15),
                     (self.qtgui_bercurve_sink_0, 117))
        self.connect((self.fec_bercurve_generator_0, 16),
                     (self.qtgui_bercurve_sink_0, 118))
        self.connect((self.fec_bercurve_generator_0, 17),
                     (self.qtgui_bercurve_sink_0, 119))
        self.connect((self.fec_bercurve_generator_0, 18),
                     (self.qtgui_bercurve_sink_0, 120))
        self.connect((self.fec_bercurve_generator_0, 19),
                     (self.qtgui_bercurve_sink_0, 121))
        self.connect((self.fec_bercurve_generator_0, 20),
                     (self.qtgui_bercurve_sink_0, 122))
        self.connect((self.fec_bercurve_generator_0, 21),
                     (self.qtgui_bercurve_sink_0, 123))
        self.connect((self.fec_bercurve_generator_0, 22),
                     (self.qtgui_bercurve_sink_0, 124))
        self.connect((self.fec_bercurve_generator_0, 23),
                     (self.qtgui_bercurve_sink_0, 125))
        self.connect((self.fec_bercurve_generator_0, 24),
                     (self.qtgui_bercurve_sink_0, 126))
        self.connect((self.fec_bercurve_generator_0, 25),
                     (self.qtgui_bercurve_sink_0, 127))
        self.connect((self.fec_bercurve_generator_0, 26),
                     (self.qtgui_bercurve_sink_0, 128))
        self.connect((self.fec_bercurve_generator_0, 27),
                     (self.qtgui_bercurve_sink_0, 129))
        self.connect((self.fec_bercurve_generator_0, 28),
                     (self.qtgui_bercurve_sink_0, 130))
        self.connect((self.fec_bercurve_generator_0, 29),
                     (self.qtgui_bercurve_sink_0, 131))
        self.connect((self.fec_bercurve_generator_0, 30),
                     (self.qtgui_bercurve_sink_0, 132))
        self.connect((self.fec_bercurve_generator_0, 31),
                     (self.qtgui_bercurve_sink_0, 133))
        self.connect((self.fec_bercurve_generator_0, 32),
                     (self.qtgui_bercurve_sink_0, 134))
        self.connect((self.fec_bercurve_generator_0, 33),
                     (self.qtgui_bercurve_sink_0, 135))
        self.connect((self.fec_bercurve_generator_0_0, 0),
                     (self.qtgui_bercurve_sink_0, 34))
        self.connect((self.fec_bercurve_generator_0_0, 1),
                     (self.qtgui_bercurve_sink_0, 35))
        self.connect((self.fec_bercurve_generator_0_0, 2),
                     (self.qtgui_bercurve_sink_0, 36))
        self.connect((self.fec_bercurve_generator_0_0, 3),
                     (self.qtgui_bercurve_sink_0, 37))
        self.connect((self.fec_bercurve_generator_0_0, 4),
                     (self.qtgui_bercurve_sink_0, 38))
        self.connect((self.fec_bercurve_generator_0_0, 5),
                     (self.qtgui_bercurve_sink_0, 39))
        self.connect((self.fec_bercurve_generator_0_0, 6),
                     (self.qtgui_bercurve_sink_0, 40))
        self.connect((self.fec_bercurve_generator_0_0, 7),
                     (self.qtgui_bercurve_sink_0, 41))
        self.connect((self.fec_bercurve_generator_0_0, 8),
                     (self.qtgui_bercurve_sink_0, 42))
        self.connect((self.fec_bercurve_generator_0_0, 9),
                     (self.qtgui_bercurve_sink_0, 43))
        self.connect((self.fec_bercurve_generator_0_0, 10),
                     (self.qtgui_bercurve_sink_0, 44))
        self.connect((self.fec_bercurve_generator_0_0, 11),
                     (self.qtgui_bercurve_sink_0, 45))
        self.connect((self.fec_bercurve_generator_0_0, 12),
                     (self.qtgui_bercurve_sink_0, 46))
        self.connect((self.fec_bercurve_generator_0_0, 13),
                     (self.qtgui_bercurve_sink_0, 47))
        self.connect((self.fec_bercurve_generator_0_0, 14),
                     (self.qtgui_bercurve_sink_0, 48))
        self.connect((self.fec_bercurve_generator_0_0, 15),
                     (self.qtgui_bercurve_sink_0, 49))
        self.connect((self.fec_bercurve_generator_0_0, 16),
                     (self.qtgui_bercurve_sink_0, 50))
        self.connect((self.fec_bercurve_generator_0_0, 17),
                     (self.qtgui_bercurve_sink_0, 51))
        self.connect((self.fec_bercurve_generator_0_0, 18),
                     (self.qtgui_bercurve_sink_0, 52))
        self.connect((self.fec_bercurve_generator_0_0, 19),
                     (self.qtgui_bercurve_sink_0, 53))
        self.connect((self.fec_bercurve_generator_0_0, 20),
                     (self.qtgui_bercurve_sink_0, 54))
        self.connect((self.fec_bercurve_generator_0_0, 21),
                     (self.qtgui_bercurve_sink_0, 55))
        self.connect((self.fec_bercurve_generator_0_0, 22),
                     (self.qtgui_bercurve_sink_0, 56))
        self.connect((self.fec_bercurve_generator_0_0, 23),
                     (self.qtgui_bercurve_sink_0, 57))
        self.connect((self.fec_bercurve_generator_0_0, 24),
                     (self.qtgui_bercurve_sink_0, 58))
        self.connect((self.fec_bercurve_generator_0_0, 25),
                     (self.qtgui_bercurve_sink_0, 59))
        self.connect((self.fec_bercurve_generator_0_0, 26),
                     (self.qtgui_bercurve_sink_0, 60))
        self.connect((self.fec_bercurve_generator_0_0, 27),
                     (self.qtgui_bercurve_sink_0, 61))
        self.connect((self.fec_bercurve_generator_0_0, 28),
                     (self.qtgui_bercurve_sink_0, 62))
        self.connect((self.fec_bercurve_generator_0_0, 29),
                     (self.qtgui_bercurve_sink_0, 63))
        self.connect((self.fec_bercurve_generator_0_0, 30),
                     (self.qtgui_bercurve_sink_0, 64))
        self.connect((self.fec_bercurve_generator_0_0, 31),
                     (self.qtgui_bercurve_sink_0, 65))
        self.connect((self.fec_bercurve_generator_0_0, 32),
                     (self.qtgui_bercurve_sink_0, 66))
        self.connect((self.fec_bercurve_generator_0_0, 33),
                     (self.qtgui_bercurve_sink_0, 67))
        self.connect((self.fec_bercurve_generator_0_0_0, 0),
                     (self.qtgui_bercurve_sink_0, 0))
        self.connect((self.fec_bercurve_generator_0_0_0, 1),
                     (self.qtgui_bercurve_sink_0, 1))
        self.connect((self.fec_bercurve_generator_0_0_0, 2),
                     (self.qtgui_bercurve_sink_0, 2))
        self.connect((self.fec_bercurve_generator_0_0_0, 3),
                     (self.qtgui_bercurve_sink_0, 3))
        self.connect((self.fec_bercurve_generator_0_0_0, 4),
                     (self.qtgui_bercurve_sink_0, 4))
        self.connect((self.fec_bercurve_generator_0_0_0, 5),
                     (self.qtgui_bercurve_sink_0, 5))
        self.connect((self.fec_bercurve_generator_0_0_0, 6),
                     (self.qtgui_bercurve_sink_0, 6))
        self.connect((self.fec_bercurve_generator_0_0_0, 7),
                     (self.qtgui_bercurve_sink_0, 7))
        self.connect((self.fec_bercurve_generator_0_0_0, 8),
                     (self.qtgui_bercurve_sink_0, 8))
        self.connect((self.fec_bercurve_generator_0_0_0, 9),
                     (self.qtgui_bercurve_sink_0, 9))
        self.connect((self.fec_bercurve_generator_0_0_0, 10),
                     (self.qtgui_bercurve_sink_0, 10))
        self.connect((self.fec_bercurve_generator_0_0_0, 11),
                     (self.qtgui_bercurve_sink_0, 11))
        self.connect((self.fec_bercurve_generator_0_0_0, 12),
                     (self.qtgui_bercurve_sink_0, 12))
        self.connect((self.fec_bercurve_generator_0_0_0, 13),
                     (self.qtgui_bercurve_sink_0, 13))
        self.connect((self.fec_bercurve_generator_0_0_0, 14),
                     (self.qtgui_bercurve_sink_0, 14))
        self.connect((self.fec_bercurve_generator_0_0_0, 15),
                     (self.qtgui_bercurve_sink_0, 15))
        self.connect((self.fec_bercurve_generator_0_0_0, 16),
                     (self.qtgui_bercurve_sink_0, 16))
        self.connect((self.fec_bercurve_generator_0_0_0, 17),
                     (self.qtgui_bercurve_sink_0, 17))
        self.connect((self.fec_bercurve_generator_0_0_0, 18),
                     (self.qtgui_bercurve_sink_0, 18))
        self.connect((self.fec_bercurve_generator_0_0_0, 19),
                     (self.qtgui_bercurve_sink_0, 19))
        self.connect((self.fec_bercurve_generator_0_0_0, 20),
                     (self.qtgui_bercurve_sink_0, 20))
        self.connect((self.fec_bercurve_generator_0_0_0, 21),
                     (self.qtgui_bercurve_sink_0, 21))
        self.connect((self.fec_bercurve_generator_0_0_0, 22),
                     (self.qtgui_bercurve_sink_0, 22))
        self.connect((self.fec_bercurve_generator_0_0_0, 23),
                     (self.qtgui_bercurve_sink_0, 23))
        self.connect((self.fec_bercurve_generator_0_0_0, 24),
                     (self.qtgui_bercurve_sink_0, 24))
        self.connect((self.fec_bercurve_generator_0_0_0, 25),
                     (self.qtgui_bercurve_sink_0, 25))
        self.connect((self.fec_bercurve_generator_0_0_0, 26),
                     (self.qtgui_bercurve_sink_0, 26))
        self.connect((self.fec_bercurve_generator_0_0_0, 27),
                     (self.qtgui_bercurve_sink_0, 27))
        self.connect((self.fec_bercurve_generator_0_0_0, 28),
                     (self.qtgui_bercurve_sink_0, 28))
        self.connect((self.fec_bercurve_generator_0_0_0, 29),
                     (self.qtgui_bercurve_sink_0, 29))
        self.connect((self.fec_bercurve_generator_0_0_0, 30),
                     (self.qtgui_bercurve_sink_0, 30))
        self.connect((self.fec_bercurve_generator_0_0_0, 31),
                     (self.qtgui_bercurve_sink_0, 31))
        self.connect((self.fec_bercurve_generator_0_0_0, 32),
                     (self.qtgui_bercurve_sink_0, 32))
        self.connect((self.fec_bercurve_generator_0_0_0, 33),
                     (self.qtgui_bercurve_sink_0, 33))
        self.connect((self.fec_bercurve_generator_1, 0),
                     (self.qtgui_bercurve_sink_0, 68))
        self.connect((self.fec_bercurve_generator_1, 1),
                     (self.qtgui_bercurve_sink_0, 69))
        self.connect((self.fec_bercurve_generator_1, 2),
                     (self.qtgui_bercurve_sink_0, 70))
        self.connect((self.fec_bercurve_generator_1, 3),
                     (self.qtgui_bercurve_sink_0, 71))
        self.connect((self.fec_bercurve_generator_1, 4),
                     (self.qtgui_bercurve_sink_0, 72))
        self.connect((self.fec_bercurve_generator_1, 5),
                     (self.qtgui_bercurve_sink_0, 73))
        self.connect((self.fec_bercurve_generator_1, 6),
                     (self.qtgui_bercurve_sink_0, 74))
        self.connect((self.fec_bercurve_generator_1, 7),
                     (self.qtgui_bercurve_sink_0, 75))
        self.connect((self.fec_bercurve_generator_1, 8),
                     (self.qtgui_bercurve_sink_0, 76))
        self.connect((self.fec_bercurve_generator_1, 9),
                     (self.qtgui_bercurve_sink_0, 77))
        self.connect((self.fec_bercurve_generator_1, 10),
                     (self.qtgui_bercurve_sink_0, 78))
        self.connect((self.fec_bercurve_generator_1, 11),
                     (self.qtgui_bercurve_sink_0, 79))
        self.connect((self.fec_bercurve_generator_1, 12),
                     (self.qtgui_bercurve_sink_0, 80))
        self.connect((self.fec_bercurve_generator_1, 13),
                     (self.qtgui_bercurve_sink_0, 81))
        self.connect((self.fec_bercurve_generator_1, 14),
                     (self.qtgui_bercurve_sink_0, 82))
        self.connect((self.fec_bercurve_generator_1, 15),
                     (self.qtgui_bercurve_sink_0, 83))
        self.connect((self.fec_bercurve_generator_1, 16),
                     (self.qtgui_bercurve_sink_0, 84))
        self.connect((self.fec_bercurve_generator_1, 17),
                     (self.qtgui_bercurve_sink_0, 85))
        self.connect((self.fec_bercurve_generator_1, 18),
                     (self.qtgui_bercurve_sink_0, 86))
        self.connect((self.fec_bercurve_generator_1, 19),
                     (self.qtgui_bercurve_sink_0, 87))
        self.connect((self.fec_bercurve_generator_1, 20),
                     (self.qtgui_bercurve_sink_0, 88))
        self.connect((self.fec_bercurve_generator_1, 21),
                     (self.qtgui_bercurve_sink_0, 89))
        self.connect((self.fec_bercurve_generator_1, 22),
                     (self.qtgui_bercurve_sink_0, 90))
        self.connect((self.fec_bercurve_generator_1, 23),
                     (self.qtgui_bercurve_sink_0, 91))
        self.connect((self.fec_bercurve_generator_1, 24),
                     (self.qtgui_bercurve_sink_0, 92))
        self.connect((self.fec_bercurve_generator_1, 25),
                     (self.qtgui_bercurve_sink_0, 93))
        self.connect((self.fec_bercurve_generator_1, 26),
                     (self.qtgui_bercurve_sink_0, 94))
        self.connect((self.fec_bercurve_generator_1, 27),
                     (self.qtgui_bercurve_sink_0, 95))
        self.connect((self.fec_bercurve_generator_1, 28),
                     (self.qtgui_bercurve_sink_0, 96))
        self.connect((self.fec_bercurve_generator_1, 29),
                     (self.qtgui_bercurve_sink_0, 97))
        self.connect((self.fec_bercurve_generator_1, 30),
                     (self.qtgui_bercurve_sink_0, 98))
        self.connect((self.fec_bercurve_generator_1, 31),
                     (self.qtgui_bercurve_sink_0, 99))
        self.connect((self.fec_bercurve_generator_1, 32),
                     (self.qtgui_bercurve_sink_0, 100))
        self.connect((self.fec_bercurve_generator_1, 33),
                     (self.qtgui_bercurve_sink_0, 101))
    def __init__(self, frame_size=30, puncpat='11'):
        gr.top_block.__init__(self, "Fecapi Decoders")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Fecapi Decoders")
        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", "fecapi_decoders")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.frame_size = frame_size
        self.puncpat = puncpat

        ##################################################
        # Variables
        ##################################################
        self.rate = rate = 2
        self.polys = polys = [109, 79]
        self.k = k = 7
        self.samp_rate = samp_rate = 50000

        self.enc_rep = enc_rep = fec.repetition_encoder_make(frame_size * 8, 3)

        self.enc_dummy = enc_dummy = fec.dummy_encoder_make(frame_size * 8)

        self.enc_ccsds = enc_ccsds = fec.ccsds_encoder_make(
            frame_size * 8, 0, fec.CC_TAILBITING)

        self.dec_rep = dec_rep = fec.repetition_decoder.make(
            frame_size * 8, 3, 0.5)

        self.dec_dummy = dec_dummy = fec.dummy_decoder.make(frame_size * 8)

        self.dec_cc = dec_cc = fec.cc_decoder.make(frame_size * 8, k, rate,
                                                   (polys), 0, -1,
                                                   fec.CC_TAILBITING, False)

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            2048,  #size
            samp_rate,  #samp_rate
            '',  #name
            4  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.01)
        self.qtgui_time_sink_x_0.set_y_axis(-0.5, 1.5)

        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 = [
            'Input', 'Dummy', 'Rep. (Rate=3)', 'CC (K=7, Rate=2)', 'CCSDS', '',
            '', '', '', ''
        ]
        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, 0.6, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(4):
            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.fec_extended_encoder_1_0_0 = fec.extended_encoder(
            encoder_obj_list=enc_dummy, threading='capillary', puncpat=puncpat)
        self.fec_extended_encoder_1_0 = fec.extended_encoder(
            encoder_obj_list=enc_rep, threading='capillary', puncpat=puncpat)
        self.fec_extended_encoder_1 = fec.extended_encoder(
            encoder_obj_list=enc_ccsds, threading='capillary', puncpat=puncpat)
        self.fec_extended_decoder_0_1_0 = fec.extended_decoder(
            decoder_obj_list=dec_dummy,
            threading=None,
            ann=None,
            puncpat=puncpat,
            integration_period=10000)
        self.fec_extended_decoder_0_1 = fec.extended_decoder(
            decoder_obj_list=dec_rep,
            threading=None,
            ann=None,
            puncpat=puncpat,
            integration_period=10000)
        self.fec_extended_decoder_0 = fec.extended_decoder(
            decoder_obj_list=dec_cc,
            threading=None,
            ann=None,
            puncpat=puncpat,
            integration_period=10000)
        self.digital_map_bb_0_0_0_0 = digital.map_bb(([-1, 1]))
        self.digital_map_bb_0_0_0 = digital.map_bb(([-1, 1]))
        self.digital_map_bb_0_0 = digital.map_bb(([-1, 1]))
        self.blocks_vector_source_x_0_1_0 = blocks.vector_source_b(
            (frame_size / 15) *
            [0, 0, 1, 0, 3, 0, 7, 0, 15, 0, 31, 0, 63, 0, 127], True, 1, [])
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate,
                                                 True)
        self.blocks_char_to_float_0_2_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_2 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_1 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_0_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.fec_extended_decoder_0, 0))
        self.connect((self.blocks_char_to_float_0_0, 0),
                     (self.qtgui_time_sink_x_0, 3))
        self.connect((self.blocks_char_to_float_0_0_0, 0),
                     (self.qtgui_time_sink_x_0, 2))
        self.connect((self.blocks_char_to_float_0_0_0_0, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_char_to_float_0_1, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_char_to_float_0_2, 0),
                     (self.fec_extended_decoder_0_1, 0))
        self.connect((self.blocks_char_to_float_0_2_0, 0),
                     (self.fec_extended_decoder_0_1_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                     (self.blocks_char_to_float_0_1, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                     (self.fec_extended_encoder_1, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                     (self.fec_extended_encoder_1_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                     (self.fec_extended_encoder_1_0_0, 0))
        self.connect((self.blocks_vector_source_x_0_1_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.digital_map_bb_0_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.digital_map_bb_0_0_0, 0),
                     (self.blocks_char_to_float_0_2, 0))
        self.connect((self.digital_map_bb_0_0_0_0, 0),
                     (self.blocks_char_to_float_0_2_0, 0))
        self.connect((self.fec_extended_decoder_0, 0),
                     (self.blocks_char_to_float_0_0, 0))
        self.connect((self.fec_extended_decoder_0_1, 0),
                     (self.blocks_char_to_float_0_0_0, 0))
        self.connect((self.fec_extended_decoder_0_1_0, 0),
                     (self.blocks_char_to_float_0_0_0_0, 0))
        self.connect((self.fec_extended_encoder_1, 0),
                     (self.digital_map_bb_0_0, 0))
        self.connect((self.fec_extended_encoder_1_0, 0),
                     (self.digital_map_bb_0_0_0, 0))
        self.connect((self.fec_extended_encoder_1_0_0, 0),
                     (self.digital_map_bb_0_0_0_0, 0))
Exemple #8
0
    def __init__(self, frame_size=4096, puncpat='11'):
        gr.top_block.__init__(self, "Hamming and n-Repetition")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Hamming and n-Repetition")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

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

        ##################################################
        # Parameters
        ##################################################
        self.frame_size = frame_size
        self.puncpat = puncpat

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32e3
        self.reset_ber = reset_ber = 0
        self.enc_rep = enc_rep = fec.repetition_encoder_make(frame_size, 3)
        self.eb_no_db = eb_no_db = 10
        self.dec_rep = dec_rep = fec.repetition_decoder.make(frame_size,3, 0.5)
        self.R_rep = R_rep = 1/3
        self.R_hamming = R_hamming = 4/7

        ##################################################
        # Blocks
        ##################################################
        _reset_ber_push_button = Qt.QPushButton('Reset BER')
        _reset_ber_push_button = Qt.QPushButton('Reset BER')
        self._reset_ber_choices = {'Pressed': 1, 'Released': 0}
        _reset_ber_push_button.pressed.connect(lambda: self.set_reset_ber(self._reset_ber_choices['Pressed']))
        _reset_ber_push_button.released.connect(lambda: self.set_reset_ber(self._reset_ber_choices['Released']))
        self.top_grid_layout.addWidget(_reset_ber_push_button)
        self._eb_no_db_range = Range(0, 20, 0.5, 10, 200)
        self._eb_no_db_win = RangeWidget(self._eb_no_db_range, self.set_eb_no_db, 'Eb/No (dB)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._eb_no_db_win)
        self.wes_hamming_encoder_0 = wes.hamming_encoder(frame_size)
        self.wes_hamming_decoder_0 = wes.hamming_decoder(int(frame_size *7/4))
        self.wes_ber_0_0_0_0 = wes.ber(1, reset_ber)
        self.wes_ber_0_0_0 = wes.ber(1, reset_ber)
        self.wes_ber_0 = wes.ber(1, reset_ber)
        self.qtgui_number_sink_0_0_0_0 = qtgui.number_sink(
            gr.sizeof_float,
            0,
            qtgui.NUM_GRAPH_NONE,
            2
        )
        self.qtgui_number_sink_0_0_0_0.set_update_time(0.10)
        self.qtgui_number_sink_0_0_0_0.set_title("Uncoded")

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

        self.qtgui_number_sink_0_0_0_0.enable_autoscale(False)
        self._qtgui_number_sink_0_0_0_0_win = sip.wrapinstance(self.qtgui_number_sink_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_win)
        self.qtgui_number_sink_0_0_0 = qtgui.number_sink(
            gr.sizeof_float,
            0,
            qtgui.NUM_GRAPH_NONE,
            2
        )
        self.qtgui_number_sink_0_0_0.set_update_time(0.10)
        self.qtgui_number_sink_0_0_0.set_title("Hamming (7,4)")

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

        self.qtgui_number_sink_0_0_0.enable_autoscale(False)
        self._qtgui_number_sink_0_0_0_win = sip.wrapinstance(self.qtgui_number_sink_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_win)
        self.qtgui_number_sink_0 = qtgui.number_sink(
            gr.sizeof_float,
            0,
            qtgui.NUM_GRAPH_NONE,
            2
        )
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("n-Repetition")

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

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win)
        self.fec_extended_encoder_1_0_0 = fec.extended_encoder(encoder_obj_list=enc_rep, threading= None, puncpat=puncpat)
        self.fec_extended_decoder_0_1_0 = fec.extended_decoder(decoder_obj_list=dec_rep, threading= None, ann=None, puncpat=puncpat, integration_period=10000)
        self.digital_map_bb_0_0_1_1_0 = digital.map_bb([-1, 1])
        self.digital_map_bb_0_0_1_1 = digital.map_bb([-1, 1])
        self.digital_map_bb_0_0_0_0 = digital.map_bb([-1, 1])
        self.digital_map_bb_0 = digital.map_bb([-1, 1])
        self.digital_binary_slicer_fb_0_0_0_0 = digital.binary_slicer_fb()
        self.digital_binary_slicer_fb_0_0_0 = digital.binary_slicer_fb()
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_char_to_float_0_2_0_0_0_0_1_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_2_0_0_0_0_1 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_2_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_2_0 = blocks.char_to_float(1, 1)
        self.blocks_add_xx_0_0_0_0 = blocks.add_vff(1)
        self.blocks_add_xx_0_0_0 = blocks.add_vff(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.analog_random_source_x_0 = blocks.vector_source_b(list(map(int, numpy.random.randint(0, 2, frame_size))), True)
        self.analog_random_source_x_0.set_min_output_buffer(4096)
        self.analog_random_source_x_0.set_max_output_buffer(4096)
        self.analog_noise_source_x_0_0_0_0 = analog.noise_source_f(analog.GR_GAUSSIAN, math.sqrt( 0.5 / ( 1* math.pow(10, eb_no_db/10) ) ), 0)
        self.analog_noise_source_x_0_0_0 = analog.noise_source_f(analog.GR_GAUSSIAN, math.sqrt( 0.5 / ( R_hamming * math.pow(10, eb_no_db/10) ) ), 0)
        self.analog_noise_source_x_0 = analog.noise_source_f(analog.GR_GAUSSIAN, math.sqrt( 0.5 / ( R_rep * math.pow(10, eb_no_db/10) ) ), 0)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.analog_noise_source_x_0_0_0, 0), (self.blocks_add_xx_0_0_0, 1))
        self.connect((self.analog_noise_source_x_0_0_0_0, 0), (self.blocks_add_xx_0_0_0_0, 1))
        self.connect((self.analog_random_source_x_0, 0), (self.digital_map_bb_0_0_1_1_0, 0))
        self.connect((self.analog_random_source_x_0, 0), (self.fec_extended_encoder_1_0_0, 0))
        self.connect((self.analog_random_source_x_0, 0), (self.wes_ber_0, 1))
        self.connect((self.analog_random_source_x_0, 0), (self.wes_ber_0_0_0, 1))
        self.connect((self.analog_random_source_x_0, 0), (self.wes_ber_0_0_0_0, 0))
        self.connect((self.analog_random_source_x_0, 0), (self.wes_hamming_encoder_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.blocks_add_xx_0_0_0, 0), (self.digital_binary_slicer_fb_0_0_0, 0))
        self.connect((self.blocks_add_xx_0_0_0_0, 0), (self.digital_binary_slicer_fb_0_0_0_0, 0))
        self.connect((self.blocks_char_to_float_0_2_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_char_to_float_0_2_0_0, 0), (self.fec_extended_decoder_0_1_0, 0))
        self.connect((self.blocks_char_to_float_0_2_0_0_0_0_1, 0), (self.blocks_add_xx_0_0_0, 0))
        self.connect((self.blocks_char_to_float_0_2_0_0_0_0_1_0, 0), (self.blocks_add_xx_0_0_0_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_map_bb_0, 0))
        self.connect((self.digital_binary_slicer_fb_0_0_0, 0), (self.wes_hamming_decoder_0, 0))
        self.connect((self.digital_binary_slicer_fb_0_0_0_0, 0), (self.wes_ber_0_0_0_0, 1))
        self.connect((self.digital_map_bb_0, 0), (self.blocks_char_to_float_0_2_0_0, 0))
        self.connect((self.digital_map_bb_0_0_0_0, 0), (self.blocks_char_to_float_0_2_0, 0))
        self.connect((self.digital_map_bb_0_0_1_1, 0), (self.blocks_char_to_float_0_2_0_0_0_0_1, 0))
        self.connect((self.digital_map_bb_0_0_1_1_0, 0), (self.blocks_char_to_float_0_2_0_0_0_0_1_0, 0))
        self.connect((self.fec_extended_decoder_0_1_0, 0), (self.wes_ber_0, 0))
        self.connect((self.fec_extended_encoder_1_0_0, 0), (self.digital_map_bb_0_0_0_0, 0))
        self.connect((self.wes_ber_0, 1), (self.qtgui_number_sink_0, 1))
        self.connect((self.wes_ber_0, 0), (self.qtgui_number_sink_0, 0))
        self.connect((self.wes_ber_0_0_0, 0), (self.qtgui_number_sink_0_0_0, 0))
        self.connect((self.wes_ber_0_0_0, 1), (self.qtgui_number_sink_0_0_0, 1))
        self.connect((self.wes_ber_0_0_0_0, 1), (self.qtgui_number_sink_0_0_0_0, 1))
        self.connect((self.wes_ber_0_0_0_0, 0), (self.qtgui_number_sink_0_0_0_0, 0))
        self.connect((self.wes_hamming_decoder_0, 0), (self.wes_ber_0_0_0, 0))
        self.connect((self.wes_hamming_encoder_0, 0), (self.digital_map_bb_0_0_1_1, 0))
Exemple #9
0
    def __init__(self, MTU=1500, frame_size=30, puncpat='11'):
        gr.top_block.__init__(self, "Fecapi Tagged Decoders")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Fecapi Tagged Decoders")
        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", "fecapi_tagged_decoders")
        self.restoreGeometry(
            self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Parameters
        ##################################################
        self.MTU = MTU
        self.frame_size = frame_size
        self.puncpat = puncpat

        ##################################################
        # Variables
        ##################################################
        self.rep = rep = 3
        self.rate = rate = 2
        self.polys = polys = [109, 79]
        self.k = k = 7
        self.samp_rate = samp_rate = 50000
        self.length_tag = length_tag = "packet_len"

        self.enc_rep = enc_rep = map(
            (lambda a: fec.repetition_encoder_make(MTU * 8, rep)), range(0, 1))

        self.enc_dummy = enc_dummy = map(
            (lambda a: fec.repetition_encoder_make(MTU * 8, 3)), range(0, 1))

        self.enc_cc = enc_cc = fec.cc_encoder_make(MTU * 8, k, rate, (polys),
                                                   0, fec.CC_TERMINATED, True)

        self.dec_rep = dec_rep = map(
            (lambda a: fec.repetition_decoder.make(MTU * 8, rep, 0.5)),
            range(0, 1))

        self.dec_dummy = dec_dummy = map(
            (lambda a: fec.dummy_decoder.make(MTU * 8)), range(0, 1))

        self.dec_cc = dec_cc = map((lambda a: fec.cc_decoder.make(
            MTU * 8, k, rate, (polys), 0, -1, fec.CC_TERMINATED, True)),
                                   range(0, 1))

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
            2048,  #size
            samp_rate,  #samp_rate
            '',  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.01)
        self.qtgui_time_sink_x_1.set_y_axis(-0.5, 1.5)

        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_NORM,
                                                  qtgui.TRIG_SLOPE_POS, 0.1, 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 = [
            'None', 'Rep (Rate=3)', 'CC (K=7, Rate=2)', '', '', '', '', '', '',
            ''
        ]
        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_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.fec_extended_tagged_encoder_0_1 = fec.extended_tagged_encoder(
            encoder_obj_list=enc_cc,
            puncpat='11',
            lentagname=length_tag,
            mtu=MTU)
        self.fec_extended_tagged_encoder_0 = fec.extended_tagged_encoder(
            encoder_obj_list=enc_dummy,
            puncpat=puncpat,
            lentagname=length_tag,
            mtu=MTU)
        self.fec_extended_tagged_decoder_0_1 = self.fec_extended_tagged_decoder_0_1 = fec_extended_tagged_decoder_0_1 = fec.extended_tagged_decoder(
            decoder_obj_list=dec_cc,
            ann=None,
            puncpat=puncpat,
            integration_period=10000,
            lentagname=length_tag,
            mtu=MTU)
        self.fec_extended_tagged_decoder_0 = self.fec_extended_tagged_decoder_0 = fec_extended_tagged_decoder_0 = fec.extended_tagged_decoder(
            decoder_obj_list=dec_dummy,
            ann=None,
            puncpat=puncpat,
            integration_period=10000,
            lentagname=length_tag,
            mtu=MTU)
        self.digital_map_bb_0_1 = digital.map_bb(([-1, 1]))
        self.digital_map_bb_0_0 = digital.map_bb(([-1, 1]))
        self.blocks_vector_source_x_0_1_0 = blocks.vector_source_b(
            4 * [0, 0, 1, 0, 3, 0, 7, 0, 15, 0, 31, 0, 63, 0, 127], True, 1,
            [])
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate,
                                                 True)
        self.blocks_stream_to_tagged_stream_0_0_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, frame_size, length_tag)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            8, 1, 'packet_len', False, gr.GR_LSB_FIRST)
        self.blocks_char_to_float_1_2 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_1_1 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_1_0_1 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_1_0_0 = blocks.char_to_float(1, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_char_to_float_1_0_0, 0),
                     (self.qtgui_time_sink_x_1, 1))
        self.connect((self.blocks_char_to_float_1_0_1, 0),
                     (self.qtgui_time_sink_x_1, 0))
        self.connect((self.blocks_char_to_float_1_1, 0),
                     (self.fec_extended_tagged_decoder_0_1, 0))
        self.connect((self.blocks_char_to_float_1_2, 0),
                     (self.fec_extended_tagged_decoder_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.fec_extended_tagged_encoder_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.fec_extended_tagged_encoder_0_1, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0_0_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_stream_to_tagged_stream_0_0_0, 0))
        self.connect((self.blocks_vector_source_x_0_1_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.digital_map_bb_0_0, 0),
                     (self.blocks_char_to_float_1_1, 0))
        self.connect((self.digital_map_bb_0_1, 0),
                     (self.blocks_char_to_float_1_2, 0))
        self.connect((self.fec_extended_tagged_decoder_0, 0),
                     (self.blocks_char_to_float_1_0_1, 0))
        self.connect((self.fec_extended_tagged_decoder_0_1, 0),
                     (self.blocks_char_to_float_1_0_0, 0))
        self.connect((self.fec_extended_tagged_encoder_0, 0),
                     (self.digital_map_bb_0_1, 0))
        self.connect((self.fec_extended_tagged_encoder_0_1, 0),
                     (self.digital_map_bb_0_0, 0))
Exemple #10
0
    def __init__(self, MTU=10000, bw=100e3, frequency_rx=2.4505e9 + 1e6, frequency_tx=2.4505e9, ip_pub='tcp://192.168.5.134:7001', ip_sub='tcp://192.168.5.109:7000', offset=-250e3):
        gr.top_block.__init__(self, "Lora Side1")

        ##################################################
        # Parameters
        ##################################################
        self.MTU = MTU
        self.bw = bw
        self.frequency_rx = frequency_rx
        self.frequency_tx = frequency_tx
        self.ip_pub = ip_pub
        self.ip_sub = ip_sub
        self.offset = offset

        ##################################################
        # Variables
        ##################################################
        self.rep = rep = 3
        self.spreading_factor = spreading_factor = 8
        self.samp_rate = samp_rate = 500e3
        self.ldr = ldr = True
        self.header = header = False


        self.enc_rep = enc_rep = fec.repetition_encoder_make(480, rep)



        self.enc_dummy = enc_dummy = fec.dummy_encoder_make(MTU*8)



        self.enc_ccsds = enc_ccsds = fec.ccsds_encoder_make(MTU*8, 0, fec.CC_TERMINATED)



        self.dec_rep = dec_rep = fec.repetition_decoder.make(480, rep, 0.5)



        self.dec_dummy = dec_dummy = fec.dummy_decoder.make(MTU*8)



        self.dec_cc = dec_cc = fec.cc_decoder.make(8000, 7, 2, ([109,79]), 0, -1, fec.CC_TERMINATED, False)

        self.code_rate = code_rate = 4

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_push_sink_0 = zeromq.push_sink(gr.sizeof_gr_complex, 1, ip_pub, 100, False, -1)
        self.zeromq_pull_source_0 = zeromq.pull_source(gr.sizeof_gr_complex, 1, ip_sub, 100, False, -1)
        self.pfb_arb_resampler_xxx_0_0 = pfb.arb_resampler_ccf(
        	  bw/samp_rate,
                  taps=None,
        	  flt_size=32)
        self.pfb_arb_resampler_xxx_0_0.declare_sample_delay(0)

        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
        	  samp_rate/bw,
                  taps=None,
        	  flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.lora_mod_0 = lora.mod(spreading_factor, 0x12)
        self.lora_encode_0 = lora.encode(spreading_factor, code_rate, ldr, header)
        self.lora_demod_0 = lora.demod(spreading_factor, ldr, 25.0, 2)
        self.lora_decode_0 = lora.decode(spreading_factor, code_rate, ldr, header)
        self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu('tap0', MTU, False)
        self.blocks_message_debug_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.lora_encode_0, 'in'))
        self.msg_connect((self.lora_decode_0, 'out'), (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.lora_decode_0, 'out'), (self.blocks_tuntap_pdu_0, 'pdus'))
        self.msg_connect((self.lora_demod_0, 'out'), (self.lora_decode_0, 'in'))
        self.msg_connect((self.lora_encode_0, 'out'), (self.lora_mod_0, 'in'))
        self.connect((self.lora_mod_0, 0), (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.zeromq_push_sink_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0_0, 0), (self.lora_demod_0, 0))
        self.connect((self.zeromq_pull_source_0, 0), (self.pfb_arb_resampler_xxx_0_0, 0))
    def __init__(self,
                 input_port_num="55555",
                 output_port_num="55556",
                 rx_bw=0.5e6,
                 rx_freq=2e9,
                 rx_gain=0.8,
                 serial_num="31C9237",
                 tx_bw=0.5e6,
                 tx_freq=2.0e9,
                 tx_gain=1):
        gr.top_block.__init__(self, "tranceiver_ofdm_usrp")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("tranceiver_ofdm_usrp")
        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", "tranceiver_ofdm_usrp")

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

        ##################################################
        # Parameters
        ##################################################
        self.input_port_num = input_port_num
        self.output_port_num = output_port_num
        self.rx_bw = rx_bw
        self.rx_freq = rx_freq
        self.rx_gain = rx_gain
        self.serial_num = serial_num
        self.tx_bw = tx_bw
        self.tx_freq = tx_freq
        self.tx_gain = tx_gain

        ##################################################
        # Variables
        ##################################################
        self.rep = rep = 3
        self.pilot_symbols = pilot_symbols = ((
            1,
            1,
            1,
            -1,
        ), )
        self.pilot_carriers = pilot_carriers = ((
            -21,
            -7,
            7,
            21,
        ), )
        self.payload_mod = payload_mod = digital.constellation_qpsk()
        self.packet_length_tag_key = packet_length_tag_key = "packet_len"
        self.occupied_carriers = occupied_carriers = (
            list(range(-26, -21)) + list(range(-20, -7)) + list(range(-6, 0)) +
            list(range(1, 7)) + list(range(8, 21)) + list(range(22, 27)), )
        self.length_tag_key = length_tag_key = "frame_len"
        self.header_mod = header_mod = digital.constellation_bpsk()
        self.fft_len = fft_len = 64
        self.sync_word2 = sync_word2 = [
            0j, 0j, 0j, 0j, 0j, 0j, (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j),
            (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j),
            (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j),
            (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j),
            (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), 0j, (1 + 0j), (-1 + 0j),
            (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j),
            (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j),
            (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j),
            (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j),
            0j, 0j, 0j, 0j, 0j
        ]
        self.sync_word1 = sync_word1 = [
            0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0.,
            -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            0., 0., 0., 0., 0.
        ]
        self.samp_rate = samp_rate = 10000
        self.rolloff = rolloff = 0
        self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe(
            fft_len, payload_mod.base(), occupied_carriers, pilot_carriers,
            pilot_symbols, 1)
        self.packet_len = packet_len = 256
        self.out_buf_size = out_buf_size = 15000
        self.header_formatter = header_formatter = digital.packet_header_ofdm(
            occupied_carriers,
            n_syms=1,
            len_tag_key=packet_length_tag_key,
            frame_len_tag_key=length_tag_key,
            bits_per_header_sym=header_mod.bits_per_symbol(),
            bits_per_payload_sym=payload_mod.bits_per_symbol(),
            scramble_header=False)
        self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(
            fft_len, header_mod.base(), occupied_carriers, pilot_carriers,
            pilot_symbols)
        self.hdr_format = hdr_format = digital.header_format_ofdm(
            occupied_carriers,
            1,
            length_tag_key,
        )
        self.enc_rep = enc_rep = fec.repetition_encoder_make(8000, rep)
        self.dec_rep = dec_rep = fec.repetition_decoder.make(8000, rep, 0.5)
        self.FEC_rate = FEC_rate = 1 / 2

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_sub_source_0 = zeromq.sub_source(
            gr.sizeof_char, 1, "tcp://127.0.0.1:" + input_port_num, 100, False,
            -1, '')
        self.zeromq_pub_sink_0 = zeromq.pub_sink(gr.sizeof_char, 1,
                                                 "tcp://127.0.0.1:55556", 100,
                                                 False, -1, '')
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0, 1)),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(rx_bw)
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)

        self.uhd_usrp_source_0.set_center_freq(rx_freq, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_0.set_power_reference(rx_gain, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0, 1)),
            ),
            packet_length_tag_key,
        )
        self.uhd_usrp_sink_0.set_samp_rate(tx_bw)
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()),
                                          uhd.ALL_MBOARDS)

        self.uhd_usrp_sink_0.set_center_freq(tx_freq, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.uhd_usrp_sink_0.set_power_reference(tx_gain, 0)
        self.fft_vxx_1 = fft.fft_vcc(fft_len, True, (), True, 1)
        self.fft_vxx_0_0 = fft.fft_vcc(fft_len, False, (), True, 1)
        self.fft_vxx_0 = fft.fft_vcc(fft_len, True, (), True, 1)
        self.fec_async_encoder_0 = fec.async_encoder(enc_rep, True, True, True,
                                                     1500)
        self.fec_async_decoder_0 = fec.async_decoder(dec_rep, True, True, 1500)
        self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb(
            hdr_format, packet_length_tag_key)
        self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b(
            header_formatter.base())
        self.digital_ofdm_sync_sc_cfb_0 = digital.ofdm_sync_sc_cfb(
            fft_len, fft_len // 4, False, 0.9)
        self.digital_ofdm_serializer_vcc_payload = digital.ofdm_serializer_vcc(
            fft_len, occupied_carriers, length_tag_key, packet_length_tag_key,
            1, '', True)
        self.digital_ofdm_serializer_vcc_header = digital.ofdm_serializer_vcc(
            fft_len, occupied_carriers, length_tag_key, '', 0, '', True)
        self.digital_ofdm_frame_equalizer_vcvc_1 = digital.ofdm_frame_equalizer_vcvc(
            payload_equalizer.base(), fft_len // 4, length_tag_key, True, 0)
        self.digital_ofdm_frame_equalizer_vcvc_1.set_min_output_buffer(15000)
        self.digital_ofdm_frame_equalizer_vcvc_0 = digital.ofdm_frame_equalizer_vcvc(
            header_equalizer.base(), fft_len // 4, length_tag_key, True, 1)
        self.digital_ofdm_frame_equalizer_vcvc_0.set_min_output_buffer(15000)
        self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(
            fft_len, fft_len + fft_len // 4, rolloff, packet_length_tag_key)
        self.digital_ofdm_cyclic_prefixer_0.set_min_output_buffer(15000)
        self.digital_ofdm_chanest_vcvc_0 = digital.ofdm_chanest_vcvc(
            sync_word1, sync_word2, 1, 0, 3, False)
        self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc(
            fft_len, occupied_carriers, pilot_carriers, pilot_symbols,
            (sync_word1, sync_word2), packet_length_tag_key, True)
        self.digital_ofdm_carrier_allocator_cvc_0.set_min_output_buffer(15000)
        self.digital_map_bb_0 = digital.map_bb([-1, 1])
        self.digital_header_payload_demux_0 = digital.header_payload_demux(
            3, fft_len, fft_len // 4, length_tag_key, "", True,
            gr.sizeof_gr_complex, "rx_time", samp_rate, (), 0)
        self.digital_header_payload_demux_0.set_min_output_buffer(15000)
        self.digital_crc32_bb_0_0 = digital.crc32_bb(False,
                                                     packet_length_tag_key,
                                                     True)
        self.digital_crc32_bb_0 = digital.crc32_bb(True, packet_length_tag_key,
                                                   True)
        self.digital_constellation_decoder_cb_1 = digital.constellation_decoder_cb(
            payload_mod.base())
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            header_mod.base())
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(
            payload_mod.points(), 1)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            header_mod.points(), 1)
        self.blocks_tagged_stream_to_pdu_1 = blocks.tagged_stream_to_pdu(
            blocks.float_t, packet_length_tag_key)
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(
            blocks.byte_t, packet_length_tag_key)
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(
            gr.sizeof_gr_complex * 1, packet_length_tag_key, 0)
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, packet_len, packet_length_tag_key)
        self.blocks_repack_bits_bb_0_3_1 = blocks.repack_bits_bb(
            8, 1, 'packet_len', True, gr.GR_LSB_FIRST)
        self.blocks_repack_bits_bb_0_1 = blocks.repack_bits_bb(
            8, payload_mod.bits_per_symbol(), packet_length_tag_key, False,
            gr.GR_LSB_FIRST)
        self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(
            8, 1, packet_length_tag_key, False, gr.GR_LSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            payload_mod.bits_per_symbol(), 8, packet_length_tag_key, True,
            gr.GR_LSB_FIRST)
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, packet_length_tag_key)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, packet_length_tag_key)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(0.05)
        self.blocks_file_sink_0_0_0_0_0_0_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/root/repos/usrp-utils/archive/post_encoding.bin', False)
        self.blocks_file_sink_0_0_0_0_0_0_0.set_unbuffered(True)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                           fft_len + fft_len // 4)
        self.blocks_char_to_float_0_1 = blocks.char_to_float(1, 1)
        self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(
            -2.0 / fft_len)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'),
                         (self.fec_async_encoder_0, 'in'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_1, 'pdus'),
                         (self.fec_async_decoder_0, 'in'))
        self.msg_connect((self.digital_packet_headerparser_b_0, 'header_data'),
                         (self.digital_header_payload_demux_0, 'header_data'))
        self.msg_connect((self.fec_async_decoder_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.msg_connect((self.fec_async_encoder_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.connect((self.analog_frequency_modulator_fc_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_char_to_float_0_1, 0),
                     (self.blocks_tagged_stream_to_pdu_1, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.digital_header_payload_demux_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0),
                     (self.blocks_file_sink_0_0_0_0_0_0_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0),
                     (self.blocks_repack_bits_bb_0_1, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0),
                     (self.digital_protocol_formatter_bb_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0),
                     (self.digital_crc32_bb_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.blocks_repack_bits_bb_0_3_1, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_1, 0),
                     (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_3_1, 0),
                     (self.digital_map_bb_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0),
                     (self.digital_crc32_bb_0_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0),
                     (self.digital_ofdm_carrier_allocator_cvc_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_tagged_stream_mux_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0),
                     (self.blocks_tagged_stream_mux_0, 1))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_packet_headerparser_b_0, 0))
        self.connect((self.digital_constellation_decoder_cb_1, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_crc32_bb_0, 0), (self.zeromq_pub_sink_0, 0))
        self.connect((self.digital_crc32_bb_0_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.digital_header_payload_demux_0, 0),
                     (self.fft_vxx_0, 0))
        self.connect((self.digital_header_payload_demux_0, 1),
                     (self.fft_vxx_1, 0))
        self.connect((self.digital_map_bb_0, 0),
                     (self.blocks_char_to_float_0_1, 0))
        self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0),
                     (self.fft_vxx_0_0, 0))
        self.connect((self.digital_ofdm_chanest_vcvc_0, 0),
                     (self.digital_ofdm_frame_equalizer_vcvc_0, 0))
        self.connect((self.digital_ofdm_cyclic_prefixer_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.digital_ofdm_frame_equalizer_vcvc_0, 0),
                     (self.digital_ofdm_serializer_vcc_header, 0))
        self.connect((self.digital_ofdm_frame_equalizer_vcvc_1, 0),
                     (self.digital_ofdm_serializer_vcc_payload, 0))
        self.connect((self.digital_ofdm_serializer_vcc_header, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_ofdm_serializer_vcc_payload, 0),
                     (self.digital_constellation_decoder_cb_1, 0))
        self.connect((self.digital_ofdm_sync_sc_cfb_0, 0),
                     (self.analog_frequency_modulator_fc_0, 0))
        self.connect((self.digital_ofdm_sync_sc_cfb_0, 1),
                     (self.digital_header_payload_demux_0, 1))
        self.connect((self.digital_protocol_formatter_bb_0, 0),
                     (self.blocks_repack_bits_bb_0_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.digital_ofdm_chanest_vcvc_0, 0))
        self.connect((self.fft_vxx_0_0, 0),
                     (self.digital_ofdm_cyclic_prefixer_0, 0))
        self.connect((self.fft_vxx_1, 0),
                     (self.digital_ofdm_frame_equalizer_vcvc_1, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.digital_ofdm_sync_sc_cfb_0, 0))
        self.connect((self.zeromq_sub_source_0, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
Exemple #12
0
    def __init__(self):
        gr.top_block.__init__(self, "Evolucao")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Evolucao")
        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", "evolucao")
        self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray))


        ##################################################
        # Variables
        ##################################################

        self.pld_const = pld_const = digital.constellation_calcdist((digital.psk_4()[0]), (digital.psk_4()[1]), 4, 1).base()

        self.pld_const.gen_soft_dec_lut(8)
        self.sps = sps = 2
        self.rep = rep = 3
        self.preamble_rep = preamble_rep = [0xe3, 0x8f, 0xc0, 0xfc, 0x7f, 0xc7, 0xe3, 0x81, 0xc0, 0xff, 0x80, 0x38, 0xff, 0xf0, 0x38, 0xe0, 0x0f, 0xc0, 0x03, 0x80, 0x00, 0xff, 0xff, 0xc0]
        self.preamble_dummy = preamble_dummy = [0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc]
        self.nfilts = nfilts = 32
        self.hdr_format = hdr_format = digital.header_format_counter(digital.packet_utils.default_access_code, 3, pld_const.bits_per_symbol())
        self.eb = eb = 0.22

        self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0, eb, 5*sps*nfilts)

        self.rate = rate = 2
        self.preamble_select = preamble_select = {1: preamble_dummy, 3: preamble_rep}

        self.hdr_const = hdr_const = digital.constellation_calcdist((digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base()

        self.hdr_const.gen_soft_dec_lut(8)


        self.dec_hdr = dec_hdr = fec.repetition_decoder.make(hdr_format.header_nbits(), rep, 0.5)

        self.taps_per_filt = taps_per_filt = len(tx_rrc_taps)/nfilts
        self.rxmod = rxmod = digital.generic_mod(hdr_const, False, sps, True, eb, False, False)
        self.preamble = preamble = preamble_select[int(1.0/dec_hdr.rate())]
        self.polys = polys = [109, 79]
        self.mark_delays = mark_delays = [0, 0, 34, 56, 87, 119]
        self.k = k = 7
        self.time_offset = time_offset = 1.0
        self.sps_0 = sps_0 = 2
        self.samp_rate = samp_rate = 32000

        self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine(nfilts, nfilts*sps, 1.0, eb, 11*sps*nfilts)

        self.noise = noise = 0.0
        self.modulated_sync_word = modulated_sync_word = digital.modulate_vector_bc(rxmod .to_basic_block(), (preamble), ([1]))
        self.mark_delay = mark_delay = mark_delays[sps]
        self.freq_offset = freq_offset = 0
        self.filt_delay = filt_delay = 1+(taps_per_filt-1)/2


        self.enc_hdr = enc_hdr = fec.repetition_encoder_make(8000, rep)



        self.enc = enc = fec.cc_encoder_make(8000, k, rate, (polys), 0, fec.CC_TERMINATED, False)



        self.dec = dec = fec.cc_decoder.make(8000, k, rate, (polys), 0, -1, fec.CC_TERMINATED, False)

        self.amp = amp = 1.0

        ##################################################
        # Blocks
        ##################################################
        self._time_offset_range = Range(0.99, 1.01, 0.00001, 1.0, 200)
        self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, 'Time Offset', "counter_slider", float)
        self.top_grid_layout.addWidget(self._time_offset_win, 0, 2, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._noise_range = Range(0, 5, 0.01, 0.0, 200)
        self._noise_win = RangeWidget(self._noise_range, self.set_noise, 'Noise Amp', "counter_slider", float)
        self.top_grid_layout.addWidget(self._noise_win, 0, 0, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._freq_offset_range = Range(-0.5, 0.5, 0.0001, 0, 200)
        self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Freq. Offset', "counter_slider", float)
        self.top_grid_layout.addWidget(self._freq_offset_win, 0, 1, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._amp_range = Range(0, 2, 0.01, 1.0, 200)
        self._amp_win = RangeWidget(self._amp_range, self.set_amp, 'Amplitude', "counter_slider", float)
        self.top_grid_layout.addWidget(self._amp_win)
        self.tab1 = Qt.QTabWidget()
        self.tab1_widget_0 = Qt.QWidget()
        self.tab1_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab1_widget_0)
        self.tab1_grid_layout_0 = Qt.QGridLayout()
        self.tab1_layout_0.addLayout(self.tab1_grid_layout_0)
        self.tab1.addTab(self.tab1_widget_0, 'Time')
        self.tab1_widget_1 = Qt.QWidget()
        self.tab1_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab1_widget_1)
        self.tab1_grid_layout_1 = Qt.QGridLayout()
        self.tab1_layout_1.addLayout(self.tab1_grid_layout_1)
        self.tab1.addTab(self.tab1_widget_1, 'Freq.')
        self.tab1_widget_2 = Qt.QWidget()
        self.tab1_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab1_widget_2)
        self.tab1_grid_layout_2 = Qt.QGridLayout()
        self.tab1_layout_2.addLayout(self.tab1_grid_layout_2)
        self.tab1.addTab(self.tab1_widget_2, 'Const.')
        self.top_grid_layout.addWidget(self.tab1, 1, 2, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
        	  sps,
                  taps=(tx_rrc_taps),
        	  flt_size=nfilts)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(filt_delay)

        self.fec_generic_decoder_0 = fec.decoder(dec_hdr, gr.sizeof_float, gr.sizeof_char)
        self.fec_async_encoder_0_0 = fec.async_encoder(enc, True, False, False, 1500)
        self.fec_async_encoder_0 = fec.async_encoder(enc, True, False, False, 1500)
        self.fec_async_decoder_0 = fec.async_decoder(dec_hdr, True, False, 1500*8)
        self.digital_protocol_parser_b_0 = digital.protocol_parser_b(hdr_format)
        self.digital_protocol_formatter_async_0 = digital.protocol_formatter_async(hdr_format)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 6.28/400.0, (rx_rrc_taps), nfilts, nfilts/2, 1.5, 1)
        self.digital_map_bb_1_0 = digital.map_bb((pld_const.pre_diff_code()))
        self.digital_map_bb_1 = digital.map_bb((hdr_const.pre_diff_code()))
        self.digital_header_payload_demux_0 = digital.header_payload_demux(
        	  (hdr_format.header_nbits() * int(1.0/dec_hdr.rate())) /  hdr_const.bits_per_symbol(),
        	  1,
        	  0,
        	  "payload symbols",
        	  "time_est",
        	  True,
        	  gr.sizeof_gr_complex,
        	  "rx_time",
                  1,
                  "",
                  0,
            )
        self.digital_crc32_async_bb_1 = digital.crc32_async_bb(False)
        self.digital_crc32_async_bb_0 = digital.crc32_async_bb(True)
        self.digital_costas_loop_cc_0_0_0 = digital.costas_loop_cc(6.28/200.0, pld_const.arity(), False)
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(6.28/200.0, hdr_const.arity(), False)
        self.digital_corr_est_cc_0 = digital.corr_est_cc((modulated_sync_word), sps, mark_delay, 0.999)
        self.digital_constellation_soft_decoder_cf_0_0 = digital.constellation_soft_decoder_cf(hdr_const)
        self.digital_constellation_soft_decoder_cf_0 = digital.constellation_soft_decoder_cf(pld_const)
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc((pld_const.points()), 1)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((hdr_const.points()), 1)
        self.digital_burst_shaper_xx_0 = digital.burst_shaper_cc((firdes.window(firdes.WIN_HANN, 20, 0)), 0, filt_delay, True, 'packet_len')
        (self.digital_burst_shaper_xx_0).set_block_alias("burst_shaper0")
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage=noise,
        	frequency_offset=freq_offset,
        	epsilon=time_offset,
        	taps=(1.0, ),
        	noise_seed=0,
        	block_tags=True
        )
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True)
        self.blocks_tagged_stream_to_pdu_0_0 = blocks.tagged_stream_to_pdu(blocks.float_t, "payload symbols")
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, 'pacote')
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, 'packet_len', 0)
        self.blocks_tagged_stream_multiply_length_0_0 = blocks.tagged_stream_multiply_length(gr.sizeof_float*1, "payload symbols", pld_const.bits_per_symbol())
        self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(gr.sizeof_gr_complex*1, 'packet_len', sps)
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 100, 'pacote')
        self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(8, pld_const.bits_per_symbol(), 'packet_len', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, hdr_const.bits_per_symbol(), 'packet_len', False, gr.GR_MSB_FIRST)
        self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((amp, ))
        self.blocks_multiply_by_tag_value_cc_0 = blocks.multiply_by_tag_value_cc("amp_est", 1)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, '/home/andre/Desktop/transmit_maior.txt', True)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_char*1, '/home/andre/Desktop/transmitido/depois.txt', False)
        self.blocks_file_sink_0_0_0.set_unbuffered(False)



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.digital_crc32_async_bb_1, 'in'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'), (self.fec_async_decoder_0, 'in'))
        self.msg_connect((self.digital_crc32_async_bb_0, 'out'), (self.blocks_pdu_to_tagged_stream_1, 'pdus'))
        self.msg_connect((self.digital_crc32_async_bb_1, 'out'), (self.fec_async_encoder_0, 'in'))
        self.msg_connect((self.digital_protocol_formatter_async_0, 'payload'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.msg_connect((self.digital_protocol_formatter_async_0, 'header'), (self.fec_async_encoder_0_0, 'in'))
        self.msg_connect((self.digital_protocol_parser_b_0, 'info'), (self.digital_header_payload_demux_0, 'header_data'))
        self.msg_connect((self.fec_async_decoder_0, 'out'), (self.digital_crc32_async_bb_0, 'in'))
        self.msg_connect((self.fec_async_encoder_0, 'out'), (self.digital_protocol_formatter_async_0, 'in'))
        self.msg_connect((self.fec_async_encoder_0_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_multiply_by_tag_value_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.digital_corr_est_cc_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_repack_bits_bb_0_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.blocks_file_sink_0_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_map_bb_1, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_map_bb_1_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.channels_channel_model_0, 0))
        self.connect((self.blocks_tagged_stream_multiply_length_0_0, 0), (self.blocks_tagged_stream_to_pdu_0_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_burst_shaper_xx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.channels_channel_model_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.digital_burst_shaper_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_tagged_stream_mux_0, 1))
        self.connect((self.digital_constellation_soft_decoder_cf_0, 0), (self.blocks_tagged_stream_multiply_length_0_0, 0))
        self.connect((self.digital_constellation_soft_decoder_cf_0_0, 0), (self.fec_generic_decoder_0, 0))
        self.connect((self.digital_corr_est_cc_0, 0), (self.blocks_multiply_by_tag_value_cc_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0), (self.digital_constellation_soft_decoder_cf_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self.digital_constellation_soft_decoder_cf_0, 0))
        self.connect((self.digital_header_payload_demux_0, 0), (self.digital_costas_loop_cc_0_0, 0))
        self.connect((self.digital_header_payload_demux_0, 1), (self.digital_costas_loop_cc_0_0_0, 0))
        self.connect((self.digital_map_bb_1, 0), (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.digital_map_bb_1_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_header_payload_demux_0, 0))
        self.connect((self.fec_generic_decoder_0, 0), (self.digital_protocol_parser_b_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0))
Exemple #13
0
    def __init__(self, frame_size=30, puncpat='11'):
        gr.top_block.__init__(self, "Fecapi Async Encoders")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Fecapi Async Encoders")
        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", "fecapi_async_encoders")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.frame_size = frame_size
        self.puncpat = puncpat

        ##################################################
        # Variables
        ##################################################
        self.rate = rate = 2
        self.polys = polys = [109, 79]
        self.k = k = 7
        self.samp_rate = samp_rate = 50000

        self.enc_rep_0 = enc_rep_0 = fec.repetition_encoder_make(8000, 3)

        self.enc_rep = enc_rep = fec.repetition_encoder_make(8000, 3)

        self.enc_dummy_0 = enc_dummy_0 = fec.dummy_encoder_make(8000)

        self.enc_dummy = enc_dummy = fec.dummy_encoder_make(8000)

        self.enc_cc_0 = enc_cc_0 = fec.cc_encoder_make(8000, k, rate, (polys),
                                                       0, fec.CC_STREAMING,
                                                       False)

        self.enc_cc = enc_cc = fec.cc_encoder_make(8000, k, rate, (polys), 0,
                                                   fec.CC_STREAMING, False)

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            2048,  #size
            1,  #samp_rate
            '',  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.01)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 2)

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

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_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)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = [
            'Async Encoder', 'Tagged Encoder', 'Rep. (Rate=3)',
            'CC (K=7, Rate=2)', 'CCSDS', '', '', '', '', ''
        ]
        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, 0.6, 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_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.fec_extended_tagged_encoder_0 = fec.extended_tagged_encoder(
            encoder_obj_list=enc_cc,
            puncpat=puncpat,
            lentagname='pkt_len',
            mtu=1500)
        self.fec_async_encoder_0 = fec.async_encoder(enc_cc, True, True, True,
                                                     1500)
        self.blocks_vector_source_x_0_1_0 = blocks.vector_source_b(
            (frame_size / 15) *
            [0, 0, 1, 0, 3, 0, 7, 0, 15, 0, 31, 0, 63, 0, 127], True, 1, [])
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate,
                                                 True)
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(
            blocks.byte_t, 'pkt_len')
        self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, frame_size, 'pkt_len')
        self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(
            8, 1, 'pkt_len', False, gr.GR_LSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            8, 1, 'pkt_len', True, gr.GR_LSB_FIRST)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'pkt_len')
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_char_to_float_1 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_1 = blocks.char_to_float(1, 1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'),
                         (self.fec_async_encoder_0, 'in'))
        self.msg_connect((self.fec_async_encoder_0, 'out'),
                         (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.fec_async_encoder_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.connect((self.blocks_char_to_float_0_1, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_char_to_float_1, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.blocks_char_to_float_0_1, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0),
                     (self.fec_extended_tagged_encoder_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0_0, 0),
                     (self.blocks_repack_bits_bb_0_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_stream_to_tagged_stream_0_0, 0))
        self.connect((self.blocks_vector_source_x_0_1_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.fec_extended_tagged_encoder_0, 0),
                     (self.blocks_char_to_float_1, 0))