示例#1
0
def graph(args):

    print os.getpid()

    nargs = len(args)
    if nargs == 1:
        infile = args[0]
    else:
        sys.stderr.write('usage: interp.py input_file\n')
        sys.exit(1)

    tb = gr.top_block()

    srcf = blocks.file_source(gr.sizeof_short, infile)
    s2ss = blocks.stream_to_streams(gr.sizeof_short, 2)
    s2f1 = blocks.short_to_float()
    s2f2 = blocks.short_to_float()
    src0 = blocks.float_to_complex()

    lp_coeffs = filter.firdes.low_pass(3, 19.2e6, 3.2e6, .5e6,
                                       filter.firdes.WIN_HAMMING)
    lp = filter.interp_fir_filter_ccf(3, lp_coeffs)

    file = blocks.file_sink(gr.sizeof_gr_complex, "/tmp/atsc_pipe_1")

    tb.connect(srcf, s2ss)
    tb.connect((s2ss, 0), s2f1, (src0, 0))
    tb.connect((s2ss, 1), s2f2, (src0, 1))
    tb.connect(src0, lp, file)

    tb.start()
    raw_input('Head End: Press Enter to stop')
    tb.stop()
示例#2
0
    def test_03(self):
        tb = self.tb

        vlen = 5
        N = 10*vlen
        seed = 0
        data = make_random_float_tuple(N, 2**10)
        data = [int(d*1000) for d in data]
        src = blocks.vector_source_i(data, False)
        one_to_many = blocks.stream_to_streams(gr.sizeof_int, vlen)
        one_to_vector = blocks.stream_to_vector(gr.sizeof_int, vlen)
        many_to_vector = blocks.streams_to_vector(gr.sizeof_int, vlen)
        isolated  = [ blocks.moving_average_ii(100, 1) for i in range(vlen)]
        dut = blocks.moving_average_ii(100, 1, vlen=vlen)
        dut_dst = blocks.vector_sink_i(vlen=vlen)
        ref_dst = blocks.vector_sink_i(vlen=vlen)

        tb.connect(src, one_to_many)
        tb.connect(src, one_to_vector, dut, dut_dst)
        tb.connect(many_to_vector, ref_dst)
        for idx, single in enumerate(isolated):
            tb.connect((one_to_many,idx), single, (many_to_vector,idx))

        tb.run()

        dut_data = dut_dst.data()
        ref_data = ref_dst.data()

        # make sure result is close to zero
        self.assertTupleEqual(dut_data, ref_data)
示例#3
0
def graph (args):

    print os.getpid()

    nargs = len (args)
    if nargs == 1:
	infile = args[0]
    else:
	sys.stderr.write('usage: interp.py input_file\n')
	sys.exit (1)

    tb = gr.top_block()

    srcf = blocks.file_source(gr.sizeof_short,infile)
    s2ss = blocks.stream_to_streams(gr.sizeof_short,2)
    s2f1 = blocks.short_to_float()
    s2f2 = blocks.short_to_float()
    src0 = blocks.float_to_complex()


    lp_coeffs = filter.firdes.low_pass(3, 19.2e6, 3.2e6, .5e6,
                                       filter.firdes.WIN_HAMMING)
    lp = filter.interp_fir_filter_ccf(3, lp_coeffs)

    file = blocks.file_sink(gr.sizeof_gr_complex,"/tmp/atsc_pipe_1")

    tb.connect( srcf, s2ss )
    tb.connect( (s2ss, 0), s2f1, (src0,0) )
    tb.connect( (s2ss, 1), s2f2, (src0,1) )
    tb.connect( src0, lp, file)

    tb.start()
    raw_input ('Head End: Press Enter to stop')
    tb.stop()
示例#4
0
    def test_vector_int(self):
        tb = self.tb

        vlen = 5
        N = 10 * vlen
        data = make_random_float_tuple(N, 2**10)
        data = [int(d * 1000) for d in data]
        src = blocks.vector_source_i(data, False)
        one_to_many = blocks.stream_to_streams(gr.sizeof_int, vlen)
        one_to_vector = blocks.stream_to_vector(gr.sizeof_int, vlen)
        many_to_vector = blocks.streams_to_vector(gr.sizeof_int, vlen)
        isolated = [blocks.moving_average_ii(100, 1) for i in range(vlen)]
        dut = blocks.moving_average_ii(100, 1, vlen=vlen)
        dut_dst = blocks.vector_sink_i(vlen=vlen)
        ref_dst = blocks.vector_sink_i(vlen=vlen)

        tb.connect(src, one_to_many)
        tb.connect(src, one_to_vector, dut, dut_dst)
        tb.connect(many_to_vector, ref_dst)
        for idx, single in enumerate(isolated):
            tb.connect((one_to_many, idx), single, (many_to_vector, idx))

        tb.run()

        dut_data = dut_dst.data()
        ref_data = ref_dst.data()

        # make sure result is close to zero
        self.assertTupleEqual(dut_data, ref_data)
示例#5
0
    def __init__(self,
                 decim,
                 taps=None,
                 channel=0,
                 atten=100,
                 use_fft_rotators=True,
                 use_fft_filters=True):
        gr.hier_block2.__init__(self, "pfb_decimator_ccf",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(1, 1, gr.sizeof_gr_complex))

        self._decim = decim
        self._channel = channel

        if (taps is not None) and (len(taps) > 0):
            self._taps = taps
        else:
            self._taps = self.create_taps(self._decim, atten)

        self.s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex, self._decim)
        self.pfb = filter.pfb_decimator_ccf(self._decim, self._taps,
                                            self._channel, use_fft_rotators,
                                            use_fft_filters)

        self.connect(self, self.s2ss)

        for i in range(self._decim):
            self.connect((self.s2ss, i), (self.pfb, i))

        self.connect(self.pfb, self)
示例#6
0
def run_test(tb, channel, fft_rotate, fft_filter):
    N = 1000  # number of samples to use
    M = 5  # Number of channels
    fs = 5000.0  # baseband sampling rate
    ifs = M * fs  # input samp rate to decimator

    taps = filter.firdes.low_pass_2(1,
                                    ifs,
                                    fs / 2,
                                    fs / 10,
                                    attenuation_dB=80,
                                    window=filter.firdes.WIN_BLACKMAN_hARRIS)

    signals = list()
    add = blocks.add_cc()
    freqs = [-230., 121., 110., -513., 203.]
    Mch = ((len(freqs) - 1) // 2 + channel) % len(freqs)
    for i in range(len(freqs)):
        f = freqs[i] + (M // 2 - M + i + 1) * fs
        data = sig_source_c(ifs, f, 1, N)
        signals.append(blocks.vector_source_c(data))
        tb.connect(signals[i], (add, i))

    s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex, M)
    pfb = filter.pfb_decimator_ccf(M, taps, channel, fft_rotate, fft_filter)
    snk = blocks.vector_sink_c()

    tb.connect(add, s2ss)
    for i in range(M):
        tb.connect((s2ss, i), (pfb, i))
    tb.connect(pfb, snk)
    tb.run()

    L = len(snk.data())

    # Adjusted phase rotations for data
    phase = [
        0.11058476216852586, 4.5108246571401693, 3.9739891674564594,
        2.2820531095511924, 1.3782797467397869
    ]
    phase = phase[channel]

    # Filter delay is the normal delay of each arm
    tpf = math.ceil(len(taps) / float(M))
    delay = -(tpf - 1.0) / 2.0
    delay = int(delay)

    # Create a time scale that's delayed to match the filter delay
    t = [float(x) / fs for x in range(delay, L + delay)]

    # Create known data as complex sinusoids for the baseband freq
    # of the extracted channel is due to decimator output order.
    expected_data = [
        math.cos(2. * math.pi * freqs[Mch] * x + phase) +
        1j * math.sin(2. * math.pi * freqs[Mch] * x + phase) for x in t
    ]
    dst_data = snk.data()

    return (dst_data, expected_data)
示例#7
0
def run_test(tb, channel, fft_rotate, fft_filter):
        N = 1000         # number of samples to use
        M = 5            # Number of channels
        fs = 5000.0      # baseband sampling rate
        ifs = M*fs       # input samp rate to decimator

        taps = filter.firdes.low_pass_2(1, ifs, fs/2, fs/10,
                                        attenuation_dB=80,
                                        window=filter.firdes.WIN_BLACKMAN_hARRIS)

        signals = list()
        add = blocks.add_cc()
        freqs = [-230., 121., 110., -513., 203.]
        Mch = ((len(freqs)-1)/2 + channel) % len(freqs)
        for i in xrange(len(freqs)):
            f = freqs[i] + (M/2-M+i+1)*fs
            data = sig_source_c(ifs, f, 1, N)
            signals.append(blocks.vector_source_c(data))
            tb.connect(signals[i], (add,i))

        s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex, M)
        pfb = filter.pfb_decimator_ccf(M, taps, channel, fft_rotate, fft_filter)
        snk = blocks.vector_sink_c()

        tb.connect(add, s2ss)
        for i in xrange(M):
            tb.connect((s2ss,i), (pfb,i))
        tb.connect(pfb, snk)
        tb.run()

        L = len(snk.data())

        # Adjusted phase rotations for data
        phase = [ 0.11058476216852586,
                  4.5108246571401693,
                  3.9739891674564594,
                  2.2820531095511924,
                  1.3782797467397869]
        phase = phase[channel]

        # Filter delay is the normal delay of each arm
        tpf = math.ceil(len(taps) / float(M))
        delay = -(tpf - 1.0) / 2.0
        delay = int(delay)

        # Create a time scale that's delayed to match the filter delay
        t = map(lambda x: float(x)/fs, xrange(delay, L+delay))

        # Create known data as complex sinusoids for the baseband freq
        # of the extracted channel is due to decimator output order.
        expected_data = map(lambda x: math.cos(2.*math.pi*freqs[Mch]*x+phase) + \
                                1j*math.sin(2.*math.pi*freqs[Mch]*x+phase), t)
        dst_data = snk.data()

        return (dst_data, expected_data)
def run_test(tb, channel):
    N = 1000  # number of samples to use
    M = 5  # Number of channels
    fs = 5000.0  # baseband sampling rate
    ifs = M * fs  # input samp rate to decimator

    taps = filter.firdes.low_pass_2(1,
                                    ifs,
                                    fs / 2,
                                    fs / 10,
                                    attenuation_dB=80,
                                    window=filter.firdes.WIN_BLACKMAN_hARRIS)

    signals = list()
    add = blocks.add_cc()
    freqs = [-230., 121., 110., -513., 203.]
    Mch = ((len(freqs) - 1) / 2 + channel) % len(freqs)
    for i in xrange(len(freqs)):
        f = freqs[i] + (M / 2 - M + i + 1) * fs
        data = sig_source_c(ifs, f, 1, N)
        signals.append(blocks.vector_source_c(data))
        tb.connect(signals[i], (add, i))

    s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex, M)
    pfb = filter.pfb_decimator_ccf(M, taps, channel)
    snk = blocks.vector_sink_c()

    tb.connect(add, s2ss)
    for i in xrange(M):
        tb.connect((s2ss, i), (pfb, i))
    tb.connect(pfb, snk)
    tb.run()

    L = len(snk.data())

    # Each channel is rotated by 2pi/M
    phase = -2 * math.pi * channel / M

    # Filter delay is the normal delay of each arm
    tpf = math.ceil(len(taps) / float(M))
    delay = -(tpf - 1.0) / 2.0
    delay = int(delay)

    # Create a time scale that's delayed to match the filter delay
    t = map(lambda x: float(x) / fs, xrange(delay, L + delay))

    # Create known data as complex sinusoids for the baseband freq
    # of the extracted channel is due to decimator output order.
    expected_data = map(lambda x: math.cos(2.*math.pi*freqs[Mch]*x+phase) + \
                            1j*math.sin(2.*math.pi*freqs[Mch]*x+phase), t)
    dst_data = snk.data()

    return (dst_data, expected_data)
示例#9
0
	def __init__(self):
		gr.hier_block2.__init__(self, "interleaver",
				gr.io_signature(1, 1, gr.sizeof_char),	# Input signature
				gr.io_signature(1, 1, gr.sizeof_char))	# Output signature

		self.demux = blocks.stream_to_streams(gr.sizeof_char, INTERLEAVER_I)
		self.shift_registers = [dvb.fifo_shift_register_bb(INTERLEAVER_M * j)
				for j in range(INTERLEAVER_I)]
		self.mux = blocks.streams_to_stream(gr.sizeof_char, INTERLEAVER_I)

		self.connect(self, self.demux)
		for j in range(INTERLEAVER_I):
			self.connect((self.demux, j), self.shift_registers[j], (self.mux, j))
		self.connect(self.mux, self)
示例#10
0
    def __init__(self,
                 decim,
                 taps=None,
                 channel=0,
                 atten=100,
                 use_fft_rotators=True,
                 use_fft_filters=True):
        gr.hier_block2.__init__(self, "pfb_decimator_ccf",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(1, 1, gr.sizeof_gr_complex))

        self._decim = decim
        self._channel = channel

        if (taps is not None) and (len(taps) > 0):
            self._taps = taps
        else:
            # Create a filter that covers the full bandwidth of the input signal
            bw = 0.4
            tb = 0.2
            ripple = 0.1
            made = False
            while not made:
                try:
                    self._taps = optfir.low_pass(1, self._decim, bw, bw + tb,
                                                 ripple, atten)
                    made = True
                except RuntimeError:
                    ripple += 0.01
                    made = False
                    print(
                        "Warning: set ripple to %.4f dB. If this is a problem, adjust the attenuation or create your own filter taps."
                        % (ripple))

                    # Build in an exit strategy; if we've come this far, it ain't working.
                    if (ripple >= 1.0):
                        raise RuntimeError(
                            "optfir could not generate an appropriate filter.")

        self.s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex, self._decim)
        self.pfb = filter.pfb_decimator_ccf(self._decim, self._taps,
                                            self._channel, use_fft_rotators,
                                            use_fft_filters)

        self.connect(self, self.s2ss)

        for i in xrange(self._decim):
            self.connect((self.s2ss, i), (self.pfb, i))

        self.connect(self.pfb, self)
示例#11
0
    def __init__(self, mpoints, taps=None):
        """
        Takes 1 complex stream in, produces M complex streams out
        that runs at 1/M times the input sample rate

        Args:
            mpoints: number of freq bins/interpolation factor/subbands
            taps: filter taps for subband filter

        Same channel to frequency mapping as described above.
        """
        item_size = gr.sizeof_gr_complex
        gr.hier_block2.__init__(
            self,
            "analysis_filterbank",
            gr.io_signature(1, 1, item_size),  # Input signature
            gr.io_signature(mpoints, mpoints, item_size))  # Output signature

        if taps is None:
            taps = _generate_synthesis_taps(mpoints)

        # pad taps to multiple of mpoints
        r = len(taps) % mpoints
        if r != 0:
            taps = taps + (mpoints - r) * (0, )

        # split in mpoints separate set of taps
        sub_taps = _split_taps(taps, mpoints)

        # print(>> sys.stderr, "mpoints =", mpoints, "len(sub_taps) =", len(sub_taps))

        self.s2ss = blocks.stream_to_streams(item_size, mpoints)
        # filters here
        self.ss2v = blocks.streams_to_vector(item_size, mpoints)
        self.fft = fft.fft_vcc(mpoints, True, [])
        self.v2ss = blocks.vector_to_streams(item_size, mpoints)

        self.connect(self, self.s2ss)

        # build mpoints fir filters...
        for i in range(mpoints):
            f = fft_filter_ccc(1, sub_taps[mpoints - i - 1])
            self.connect((self.s2ss, i), f)
            self.connect(f, (self.ss2v, i))
            self.connect((self.v2ss, i), (self, i))

        self.connect(self.ss2v, self.fft, self.v2ss)
示例#12
0
def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed,P):
    tb = gr.top_block ()

    # TX
    src = blocks.lfsr_32k_source_s()
    src_head = blocks.head(gr.sizeof_short,Kb/16*P) # packet size in shorts
    s2fsmi=blocks.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the FSM input cardinality
    s2p = blocks.stream_to_streams(gr.sizeof_short,P) # serial to parallel
    enc = trellis.encoder_ss(f,0) # initiali state = 0
    mod = digital.chunks_to_symbols_sf(constellation,dimensionality)

    # CHANNEL
    add=[]
    noise=[]
    for i in range(P):
        add.append(blocks.add_ff())
        noise.append(analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed))

    # RX
    metrics = trellis.metrics_f(f.O(),dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for Viterbi
    va = trellis.viterbi_s(f,K,0,-1) # Put -1 if the Initial/Final states are not set.
    p2s = blocks.streams_to_stream(gr.sizeof_short,P) # parallel to serial
    fsmi2s=blocks.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts
    dst = blocks.check_lfsr_32k_s()

    tb.connect (src,src_head,s2fsmi,s2p)
    for i in range(P):
        tb.connect ((s2p,i),(enc,i),(mod,i))
        tb.connect ((mod,i),(add[i],0))
        tb.connect (noise[i],(add[i],1))
        tb.connect (add[i],(metrics,i))
        tb.connect ((metrics,i),(va,i),(p2s,i))
    tb.connect (p2s,fsmi2s,dst)


    tb.run()

    # A bit of cheating: run the program once and print the
    # final encoder state.
    # Then put it as the last argument in the viterbi block
    #print "final state = " , enc.ST()

    ntotal = dst.ntotal ()
    nright = dst.nright ()
    runlength = dst.runlength ()

    return (ntotal,ntotal-nright)
示例#13
0
    def __init__(self, mpoints, taps=None):
        """
        Takes 1 complex stream in, produces M complex streams out
        that runs at 1/M times the input sample rate

        Args:
            mpoints: number of freq bins/interpolation factor/subbands
            taps: filter taps for subband filter

        Same channel to frequency mapping as described above.
        """
        item_size = gr.sizeof_gr_complex
        gr.hier_block2.__init__(self, "analysis_filterbank",
                                gr.io_signature(1, 1, item_size),             # Input signature
                                gr.io_signature(mpoints, mpoints, item_size)) # Output signature

        if taps is None:
            taps = _generate_synthesis_taps(mpoints)

        # pad taps to multiple of mpoints
        r = len(taps) % mpoints
        if r != 0:
            taps = taps + (mpoints - r) * (0,)

        # split in mpoints separate set of taps
        sub_taps = _split_taps(taps, mpoints)

        # print >> sys.stderr, "mpoints =", mpoints, "len(sub_taps) =", len(sub_taps)

        self.s2ss = blocks.stream_to_streams(item_size, mpoints)
        # filters here
        self.ss2v = blocks.streams_to_vector(item_size, mpoints)
        self.fft = fft.fft_vcc(mpoints, True, [])
        self.v2ss = blocks.vector_to_streams(item_size, mpoints)

        self.connect(self, self.s2ss)

        # build mpoints fir filters...
        for i in range(mpoints):
            f = fft_filter_ccc(1, sub_taps[mpoints-i-1])
            self.connect((self.s2ss, i), f)
            self.connect(f, (self.ss2v, i))
            self.connect((self.v2ss, i), (self, i))

        self.connect(self.ss2v, self.fft, self.v2ss)
示例#14
0
    def test_000(self):
        N = 1000         # number of samples to use
        M = 5            # Number of channels
        fs = 1000        # baseband sampling rate
        ifs = M*fs       # input samp rate to decimator
        channel = 0      # Extract channel 0

        taps = filter.firdes.low_pass_2(1, ifs, fs/2, fs/10,
                                        attenuation_dB=80,
                                        window=filter.firdes.WIN_BLACKMAN_hARRIS)

        signals = list()
        add = blocks.add_cc()
        freqs = [-200, -100, 0, 100, 200]
        for i in xrange(len(freqs)):
            f = freqs[i] + (M/2-M+i+1)*fs
            data = sig_source_c(ifs, f, 1, N)
            signals.append(blocks.vector_source_c(data))
            self.tb.connect(signals[i], (add,i))

        head = blocks.head(gr.sizeof_gr_complex, N)
        s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex, M)
        pfb = filter.pfb_decimator_ccf(M, taps, channel)
        snk = blocks.vector_sink_c()

        self.tb.connect(add, head, s2ss)
        for i in xrange(M):
            self.tb.connect((s2ss,i), (pfb,i))
        self.tb.connect(pfb, snk)

        self.tb.run() 

        Ntest = 50
        L = len(snk.data())
        t = map(lambda x: float(x)/fs, xrange(L))

        # Create known data as complex sinusoids for the baseband freq
        # of the extracted channel is due to decimator output order.
        phase = 0
        expected_data = map(lambda x: math.cos(2.*math.pi*freqs[2]*x+phase) + \
                                1j*math.sin(2.*math.pi*freqs[2]*x+phase), t)

        dst_data = snk.data()

        self.assertComplexTuplesAlmostEqual(expected_data[-Ntest:], dst_data[-Ntest:], 4)
示例#15
0
	def __init__(self):
		gr.hier_block2.__init__(self, "deinterleaver",
				gr.io_signature(1, 1, gr.sizeof_char),	# Input signature
				gr.io_signature(1, 1, gr.sizeof_char))	# Output signature

		self.demux = blocks.stream_to_streams(gr.sizeof_char, INTERLEAVER_I)
		self.shift_registers = [dvb.fifo_shift_register_bb(INTERLEAVER_M * j)
				for j in range(INTERLEAVER_I)]
		# Deinterleaver shift registers are reversed compared to interleaver
		self.shift_registers.reverse()
		self.mux = blocks.streams_to_stream(gr.sizeof_char, INTERLEAVER_I)
		# Remove the uninitialised zeros that come out of the deinterleaver
		self.skip = blocks.skiphead(gr.sizeof_char, DELAY)

		self.connect(self, self.demux)
		for j in range(INTERLEAVER_I):
			self.connect((self.demux, j), self.shift_registers[j], (self.mux, j))
		self.connect(self.mux, self.skip, self)
示例#16
0
    def test_002_t(self):
        self.tb2 = gr.top_block()
        N_rb_dl = 50
        phich_dur = 0
        phich_res = 1.0
        N_ant = 2
        data = []
        test_len = 100
        my_res = []
        for i in range(test_len):
            mib = lte_test.pack_mib(N_rb_dl, phich_dur, phich_res, i)
            crc = lte_test.crc_checksum(mib, N_ant)
            conv = lte_test.convolutional_encoder_sorted(crc)
            convit = lte_test.convolutional_encoder(crc)
            my_res.extend(lte_test.nrz_encoding(convit))
            rated = lte_test.rate_match(conv)
            nrz = lte_test.nrz_encoding(rated)
            data.extend(nrz)

        srcf = blocks.vector_source_f(data, False, 120)
        snkf = blocks.file_sink(gr.sizeof_float * 120,
                                "/home/johannes/tests/rated.dat")
        self.tb2.connect(srcf, snkf)

        src1 = blocks.vector_source_f(data, False, 120)

        vts0 = blocks.vector_to_stream(40 * gr.sizeof_float, 3)
        sts0 = blocks.stream_to_streams(40 * gr.sizeof_float, 3)
        self.tb2.connect(src1, vts0, sts0)

        inter = blocks.interleave(gr.sizeof_float)
        for i in range(3):
            deint = lte.subblock_deinterleaver_vfvf(40, 1)
            vts1 = blocks.vector_to_stream(1 * gr.sizeof_float, 40)
            self.tb2.connect((sts0, i), deint, vts1, (inter, i))
        stv = blocks.stream_to_vector(1 * gr.sizeof_float, 120)
        snk = blocks.vector_sink_f(120)
        self.tb2.connect(inter, stv, snk)

        self.tb2.run()
        res = snk.data()
        print res[110:130]

        self.assertFloatTuplesAlmostEqual(tuple(my_res), res)
 def test_002_t(self):
     self.tb2 = gr.top_block()
     N_rb_dl = 50
     phich_dur = 0
     phich_res = 1.0
     N_ant = 2
     data = []
     test_len = 100
     my_res = []
     for i in range(test_len):
         mib = lte_test.pack_mib(N_rb_dl, phich_dur, phich_res, i)
         crc = lte_test.crc_checksum(mib, N_ant)
         conv = lte_test.convolutional_encoder_sorted(crc)
         convit = lte_test.convolutional_encoder(crc)
         my_res.extend(lte_test.nrz_encoding(convit) )
         rated = lte_test.rate_match(conv)
         nrz = lte_test.nrz_encoding(rated)
         data.extend(nrz)
     
     srcf = blocks.vector_source_f(data, False, 120)
     snkf = blocks.file_sink(gr.sizeof_float*120, "/home/johannes/tests/rated.dat")
     self.tb2.connect(srcf, snkf)
     
     src1 = blocks.vector_source_f(data, False, 120)
             
     vts0 = blocks.vector_to_stream(40*gr.sizeof_float, 3)
     sts0 = blocks.stream_to_streams(40*gr.sizeof_float, 3)        
     self.tb2.connect(src1, vts0, sts0)
     
     
     inter = blocks.interleave(gr.sizeof_float)
     for i in range(3):
         deint = lte.subblock_deinterleaver_vfvf(40, 1)
         vts1 = blocks.vector_to_stream(1*gr.sizeof_float, 40)
         self.tb2.connect( (sts0, i), deint, vts1, (inter, i))
     stv = blocks.stream_to_vector(1*gr.sizeof_float, 120)
     snk = blocks.vector_sink_f(120)        
     self.tb2.connect(inter, stv, snk)
     
     self.tb2.run()
     res = snk.data()
     print res[110:130]
     
     self.assertFloatTuplesAlmostEqual(tuple(my_res), res)
示例#18
0
    def __init__(self, args):
        gr.top_block.__init__(self, "Nordic Single-Channel Receiver Example")

        self.freq = 2414e6
        self.gain = args.gain
        self.symbol_rate = 2e6
        self.sample_rate = 4e6

        # Channel map
        channel_count = 3
        channel_map = [14, 18, 10]

        # Data rate index
        dr = 2  # 2M

        # SDR source (gr-osmosdr source)
        self.osmosdr_source = osmosdr.source()
        self.osmosdr_source.set_sample_rate(self.sample_rate * channel_count)
        self.osmosdr_source.set_center_freq(self.freq)
        self.osmosdr_source.set_gain(self.gain)
        self.osmosdr_source.set_antenna('TX/RX')

        # PFB channelizer
        taps = firdes.low_pass_2(1, self.sample_rate, self.symbol_rate / 2,
                                 100e3, 30)
        self.channelizer = filter.pfb_channelizer_ccf(channel_count, taps, 1)

        # Stream to streams (PFB channelizer input)
        self.s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex,
                                             channel_count)
        self.connect(self.osmosdr_source, self.s2ss)

        # Demodulators and packet deframers
        self.nordictap_printer = nordictap_printer()
        self.demods = []
        self.rxs = []
        for x in range(channel_count):
            self.connect((self.s2ss, x), (self.channelizer, x))
            self.demods.append(digital.gfsk_demod())
            self.rxs.append(nordic.nordic_rx(x, 5, 2, dr))
            self.connect((self.channelizer, x), self.demods[x])
            self.connect(self.demods[x], self.rxs[x])
            self.msg_connect(self.rxs[x], "nordictap_out",
                             self.nordictap_printer, "nordictap_in")
示例#19
0
    def __init__(self, sequence1, sequence2, samp_rate, center_freq):
        """
	Description:
	This block is functionally equivalent to a conventional frequency xlating FIR filter, with filter taps given by the kronecker product of sequence1 with sequence2.
	This block consists of two filtering steps. First, the received samples are filtered using a frequency xlating filter with frequency offset equal to center_freq and taps equal to sequence2.  Second, the output is fed into a S/P converter to generate len(sequence2) parallel substreams, and each substream is filtered with identical filter with taps equal to sequence1. Then all substreams are connected to a P/S converter to generate the output sequence. 

	Complexity discussion:
	Originally the filter taps have length len(sequence1)*len(sequence2).
	For the kronecker we have one filter of len(sequence2), followed by a bank of len(sequence2) filters, each of length len(sequence1) operating at a rate 1/len(sequence2), for a total complexity of roughly len(sequence2)+len(sequence1), thus resulting in considerable complexity reduction.

	Args:
	     sequence1: the identical taps of each parallel filter in the filter bank.
	     sequence2: the taps of the first filter.
	     samp_rate: the samp_rate of the first freq_xlating_fir filter.
	     center_freq: the center frequency of the freq_xlating_fir filter.
        """

        gr.hier_block2.__init__(
            self,
            "kronecker_filter",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),  # Input signature
            gr.io_signature(1, 1, gr.sizeof_gr_complex))  # Output signature

        self.n = n = len(sequence2)

        # Build  filterbank
        self._s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex, n)
        self._ss2s = blocks.streams_to_stream(gr.sizeof_gr_complex, n)
        self._filter2 = filter.freq_xlating_fir_filter_ccc(
            1, sequence2, center_freq, samp_rate)
        self._filter = [0] * n
        for i in range(n):
            self._filter[i] = filter.interp_fir_filter_ccc(1, sequence1)

        # Connect blocks
        self.connect(self, self._filter2)
        self.connect(self._filter2, self._s2ss)
        for i in range(n):
            self.connect((self._s2ss, i), self._filter[i])
            self.connect(self._filter[i], (self._ss2s, i))

        self.connect(self._ss2s, self)
示例#20
0
    def __init__(self, numchans, taps=None, oversample_rate=1, atten=100):
        gr.hier_block2.__init__(self, "pfb_channelizer_ccf",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(numchans, numchans, gr.sizeof_gr_complex))

        self._nchans = numchans
        self._oversample_rate = oversample_rate

        if (taps is not None) and (len(taps) > 0):
            self._taps = taps
        else:
            self._taps = self.create_taps(self._nchans, atten)

        self.s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex, self._nchans)
        self.pfb = filter.pfb_channelizer_ccf(self._nchans, self._taps,
                                              self._oversample_rate)
        self.connect(self, self.s2ss)

        for i in range(self._nchans):
            self.connect((self.s2ss,i), (self.pfb,i))
            self.connect((self.pfb,i), (self,i))
示例#21
0
    def test_002(self):

        # Test streams_to_stream (using stream_to_streams).

        n = 8
        src_len = n * 8
        src_data = tuple(range(src_len))
        expected_results = src_data

        src = blocks.vector_source_i(src_data)
        op1 = blocks.stream_to_streams(gr.sizeof_int, n)
        op2 = blocks.streams_to_stream(gr.sizeof_int, n)
        dst = blocks.vector_sink_i()

        self.tb.connect(src, op1)
        for i in range(n):
            self.tb.connect((op1, i), (op2, i))
        self.tb.connect(op2, dst)

        self.tb.run()
        self.assertEqual(expected_results, dst.data())
示例#22
0
    def test_002(self):

        # Test streams_to_stream (using stream_to_streams).

        n = 8
        src_len = n * 8
        src_data = tuple(range(src_len))
        expected_results = src_data

        src = blocks.vector_source_i(src_data)
        op1 = blocks.stream_to_streams(gr.sizeof_int, n)
        op2 = blocks.streams_to_stream(gr.sizeof_int, n)
        dst = blocks.vector_sink_i()

        self.tb.connect(src, op1)
        for i in range(n):
            self.tb.connect((op1, i), (op2, i))
        self.tb.connect(op2, dst)

        self.tb.run()
        self.assertEqual(expected_results, dst.data())
示例#23
0
    def __init__(self, sequence1, sequence2, samp_rate, center_freq):
        """
	Description:
	This block is functionally equivalent to a conventional frequency xlating FIR filter, with filter taps given by the kronecker product of sequence1 with sequence2.
	This block consists of two filtering steps. First, the received samples are filtered using a frequency xlating filter with frequency offset equal to center_freq and taps equal to sequence2.  Second, the output is fed into a S/P converter to generate len(sequence2) parallel substreams, and each substream is filtered with identical filter with taps equal to sequence1. Then all substreams are connected to a P/S converter to generate the output sequence. 

	Complexity discussion:
	Originally the filter taps have length len(sequence1)*len(sequence2).
	For the kronecker we have one filter of len(sequence2), followed by a bank of len(sequence2) filters, each of length len(sequence1) operating at a rate 1/len(sequence2), for a total complexity of roughly len(sequence2)+len(sequence1), thus resulting in considerable complexity reduction.

	Args:
	     sequence1: the identical taps of each parallel filter in the filter bank.
	     sequence2: the taps of the first filter.
	     samp_rate: the samp_rate of the first freq_xlating_fir filter.
	     center_freq: the center frequency of the freq_xlating_fir filter.
        """

        gr.hier_block2.__init__(self,
            "kronecker_filter",
            gr.io_signature(1,1, gr.sizeof_gr_complex),  # Input signature
            gr.io_signature(1,1, gr.sizeof_gr_complex)) # Output signature

        self.n = n = len(sequence2)

        # Build  filterbank
        self._s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex,n)
        self._ss2s = blocks.streams_to_stream(gr.sizeof_gr_complex,n)
        self._filter2=filter.freq_xlating_fir_filter_ccc(1,sequence2,center_freq,samp_rate)
        self._filter=[0]*n
        for i in range(n):
          self._filter[i]=filter.interp_fir_filter_ccc(1,sequence1)

        # Connect blocks             
        self.connect(self, self._filter2)
        self.connect(self._filter2, self._s2ss)
        for i in range(n):
          self.connect((self._s2ss, i),self._filter[i])
          self.connect(self._filter[i],(self._ss2s, i))

        self.connect(self._ss2s,self)
示例#24
0
文件: pfb.py 项目: Appiah/gnuradio
    def __init__(self, decim, taps=None, channel=0, atten=100,
                 use_fft_rotators=True, use_fft_filters=True):
	gr.hier_block2.__init__(self, "pfb_decimator_ccf",
				gr.io_signature(1, 1, gr.sizeof_gr_complex),
				gr.io_signature(1, 1, gr.sizeof_gr_complex))

        self._decim = decim
        self._channel = channel

        if (taps is not None) and (len(taps) > 0):
            self._taps = taps
        else:
            # Create a filter that covers the full bandwidth of the input signal
            bw = 0.4
            tb = 0.2
            ripple = 0.1
            made = False
            while not made:
                try:
                    self._taps = optfir.low_pass(1, self._decim, bw, bw+tb, ripple, atten)
                    made = True
                except RuntimeError:
                    ripple += 0.01
                    made = False
                    print("Warning: set ripple to %.4f dB. If this is a problem, adjust the attenuation or create your own filter taps." % (ripple))

                    # Build in an exit strategy; if we've come this far, it ain't working.
                    if(ripple >= 1.0):
                        raise RuntimeError("optfir could not generate an appropriate filter.")

        self.s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex, self._decim)
        self.pfb = filter.pfb_decimator_ccf(self._decim, self._taps, self._channel,
                                            use_fft_rotators, use_fft_filters)

        self.connect(self, self.s2ss)

        for i in xrange(self._decim):
            self.connect((self.s2ss,i), (self.pfb,i))

        self.connect(self.pfb, self)
示例#25
0
    def test_001(self):
        """
        Test stream_to_streams.
        """
        n = 8
        src_len = n * 8
        src_data = list(range(src_len))

        expected_results = calc_expected_result(src_data, n)
        #print "expected results: ", expected_results
        src = blocks.vector_source_i(src_data)
        op = blocks.stream_to_streams(gr.sizeof_int, n)
        self.tb.connect(src, op)

        dsts = []
        for i in range(n):
            dst = blocks.vector_sink_i()
            self.tb.connect((op, i), (dst, 0))
            dsts.append(dst)

        self.tb.run()

        for d in range(n):
            self.assertEqual(expected_results[d], dsts[d].data())
示例#26
0
    def test_001(self):
        """
        Test stream_to_streams.
        """
        n = 8
        src_len = n * 8
        src_data = list(range(src_len))

        expected_results = calc_expected_result(src_data, n)
        #print "expected results: ", expected_results
        src = blocks.vector_source_i(src_data)
        op = blocks.stream_to_streams(gr.sizeof_int, n)
        self.tb.connect(src, op)

        dsts = []
        for i in range(n):
            dst = blocks.vector_sink_i()
            self.tb.connect((op, i), (dst, 0))
            dsts.append(dst)

        self.tb.run()

        for d in range(n):
            self.assertEqual(expected_results[d], dsts[d].data())
    def test_000(self):
        N = 1000         # number of samples to use
        M = 5            # Number of channels to channelize
        fs = 1000        # baseband sampling rate
        ifs = M*fs       # input samp rate to channelizer

        taps = filter.firdes.low_pass_2(1, ifs, 500, 50,
                                        attenuation_dB=80,
                                        window=filter.firdes.WIN_BLACKMAN_hARRIS)

        signals = list()
        add = blocks.add_cc()
        freqs = [-200, -100, 0, 100, 200]
        for i in xrange(len(freqs)):
            f = freqs[i] + (M/2-M+i+1)*fs
            data = sig_source_c(ifs, f, 1, N)
            signals.append(blocks.vector_source_c(data))
            self.tb.connect(signals[i], (add,i))

        s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex, M)
        pfb = filter.pfb_channelizer_ccf(M, taps, 1)

        self.tb.connect(add, s2ss)

        snks = list()
        for i in xrange(M):
            snks.append(blocks.vector_sink_c())
            self.tb.connect((s2ss,i), (pfb,i))
            self.tb.connect((pfb, i), snks[i])

        self.tb.run() 

        Ntest = 50
        L = len(snks[0].data())
        t = map(lambda x: float(x)/fs, xrange(L))

        # Adjusted phase rotations for data
        p0 = 0
        p1 =  math.pi*0.51998885
        p2 = -math.pi*0.96002233
        p3 =  math.pi*0.96002233
        p4 = -math.pi*0.51998885

        # Create known data as complex sinusoids at the different baseband freqs
        # the different channel numbering is due to channelizer output order.
        expected0_data = map(lambda x: math.cos(2.*math.pi*freqs[2]*x+p0) + \
                                       1j*math.sin(2.*math.pi*freqs[2]*x+p0), t)
        expected1_data = map(lambda x: math.cos(2.*math.pi*freqs[3]*x+p1) + \
                                       1j*math.sin(2.*math.pi*freqs[3]*x+p1), t)
        expected2_data = map(lambda x: math.cos(2.*math.pi*freqs[4]*x+p2) + \
                                       1j*math.sin(2.*math.pi*freqs[4]*x+p2), t)
        expected3_data = map(lambda x: math.cos(2.*math.pi*freqs[0]*x+p3) + \
                                       1j*math.sin(2.*math.pi*freqs[0]*x+p3), t)
        expected4_data = map(lambda x: math.cos(2.*math.pi*freqs[1]*x+p4) + \
                                       1j*math.sin(2.*math.pi*freqs[1]*x+p4), t)

        dst0_data = snks[0].data()
        dst1_data = snks[1].data()
        dst2_data = snks[2].data()
        dst3_data = snks[3].data()
        dst4_data = snks[4].data()

        self.assertComplexTuplesAlmostEqual(expected0_data[-Ntest:], dst0_data[-Ntest:], 3)
        self.assertComplexTuplesAlmostEqual(expected1_data[-Ntest:], dst1_data[-Ntest:], 3)
        self.assertComplexTuplesAlmostEqual(expected2_data[-Ntest:], dst2_data[-Ntest:], 3)
        self.assertComplexTuplesAlmostEqual(expected3_data[-Ntest:], dst3_data[-Ntest:], 3)
        self.assertComplexTuplesAlmostEqual(expected4_data[-Ntest:], dst4_data[-Ntest:], 3)
示例#28
0
    def __init__(self, *args, **kwds):
        # begin wxGlade: MyFrame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)

        # Menu Bar
        self.frame_1_menubar = wx.MenuBar()
        self.SetMenuBar(self.frame_1_menubar)
        wxglade_tmp_menu = wx.Menu()
        self.Exit = wx.MenuItem(wxglade_tmp_menu, ID_EXIT, "Exit", "Exit",
                                wx.ITEM_NORMAL)
        wxglade_tmp_menu.AppendItem(self.Exit)
        self.frame_1_menubar.Append(wxglade_tmp_menu, "File")
        # Menu Bar end
        self.panel_1 = wx.Panel(self, -1)
        self.button_1 = wx.Button(self, ID_BUTTON_1, "LSB")
        self.button_2 = wx.Button(self, ID_BUTTON_2, "USB")
        self.button_3 = wx.Button(self, ID_BUTTON_3, "AM")
        self.button_4 = wx.Button(self, ID_BUTTON_4, "CW")
        self.button_5 = wx.ToggleButton(self, ID_BUTTON_5, "Upper")
        self.slider_fcutoff_hi = wx.Slider(self,
                                           ID_SLIDER_1,
                                           0,
                                           -15798,
                                           15799,
                                           style=wx.SL_HORIZONTAL
                                           | wx.SL_LABELS)
        self.button_6 = wx.ToggleButton(self, ID_BUTTON_6, "Lower")
        self.slider_fcutoff_lo = wx.Slider(self,
                                           ID_SLIDER_2,
                                           0,
                                           -15799,
                                           15798,
                                           style=wx.SL_HORIZONTAL
                                           | wx.SL_LABELS)
        self.panel_5 = wx.Panel(self, -1)
        self.label_1 = wx.StaticText(self, -1, " Band\nCenter")
        self.text_ctrl_1 = wx.TextCtrl(self, ID_TEXT_1, "")
        self.panel_6 = wx.Panel(self, -1)
        self.panel_7 = wx.Panel(self, -1)
        self.panel_2 = wx.Panel(self, -1)
        self.button_7 = wx.ToggleButton(self, ID_BUTTON_7, "Freq")
        self.slider_3 = wx.Slider(self, ID_SLIDER_3, 3000, 0, 6000)
        self.spin_ctrl_1 = wx.SpinCtrl(self, ID_SPIN_1, "", min=0, max=100)
        self.button_8 = wx.ToggleButton(self, ID_BUTTON_8, "Vol")
        self.slider_4 = wx.Slider(self, ID_SLIDER_4, 0, 0, 500)
        self.slider_5 = wx.Slider(self, ID_SLIDER_5, 0, 0, 20)
        self.button_9 = wx.ToggleButton(self, ID_BUTTON_9, "Time")
        self.button_11 = wx.Button(self, ID_BUTTON_11, "Rew")
        self.button_10 = wx.Button(self, ID_BUTTON_10, "Fwd")
        self.panel_3 = wx.Panel(self, -1)
        self.label_2 = wx.StaticText(self, -1, "PGA               ")
        self.panel_4 = wx.Panel(self, -1)
        self.panel_8 = wx.Panel(self, -1)
        self.panel_9 = wx.Panel(self, -1)
        self.panel_10 = wx.Panel(self, -1)
        self.panel_11 = wx.Panel(self, -1)
        self.panel_12 = wx.Panel(self, -1)

        self.__set_properties()
        self.__do_layout()
        # end wxGlade

        parser = OptionParser(option_class=eng_option)
        parser.add_option("",
                          "--args",
                          type="string",
                          default="addr=''",
                          help="Arguments for UHD device, [default=%default]")
        parser.add_option("",
                          "--spec",
                          type="string",
                          default="A:0",
                          help="UHD device subdev spec, [default=%default]")
        parser.add_option("-c",
                          "--ddc-freq",
                          type="eng_float",
                          default=3.9e6,
                          help="set Rx DDC frequency to FREQ",
                          metavar="FREQ")
        parser.add_option(
            "-s",
            "--samp-rate",
            type="eng_float",
            default=256000,
            help="set sample rate (bandwidth) [default=%default]")
        parser.add_option("-a",
                          "--audio_file",
                          default="",
                          help="audio output file",
                          metavar="FILE")
        parser.add_option("-r",
                          "--radio_file",
                          default="",
                          help="radio output file",
                          metavar="FILE")
        parser.add_option("-i",
                          "--input_file",
                          default="",
                          help="radio input file",
                          metavar="FILE")
        parser.add_option(
            "-O",
            "--audio-output",
            type="string",
            default="",
            help="audio output device name. E.g., hw:0,0, /dev/dsp, or pulse")
        parser.add_option("",
                          "--audio-rate",
                          type="int",
                          default=32000,
                          help="audio output sample rate [default=%default]")

        (options, args) = parser.parse_args()

        self.usrp_center = options.ddc_freq
        self.input_rate = input_rate = options.samp_rate
        self.slider_range = input_rate * 0.9375
        self.f_lo = self.usrp_center - (self.slider_range / 2)
        self.f_hi = self.usrp_center + (self.slider_range / 2)
        self.af_sample_rate = options.audio_rate
        self.tb = gr.top_block()

        # radio variables, initial conditions
        self.frequency = self.usrp_center
        # these map the frequency slider (0-6000) to the actual range
        self.f_slider_offset = self.f_lo
        self.f_slider_scale = 10000 / 250
        self.spin_ctrl_1.SetRange(self.f_lo, self.f_hi)
        self.text_ctrl_1.SetValue(str(int(self.usrp_center)))
        self.slider_5.SetValue(0)
        self.AM_mode = False

        self.slider_3.SetValue(
            (self.frequency - self.f_slider_offset) / self.f_slider_scale)
        self.spin_ctrl_1.SetValue(int(self.frequency))

        POWERMATE = True
        try:
            self.pm = powermate.powermate(self)
        except:
            sys.stderr.write("Unable to find PowerMate or Contour Shuttle\n")
            POWERMATE = False

        if POWERMATE:
            powermate.EVT_POWERMATE_ROTATE(self, self.on_rotate)
            powermate.EVT_POWERMATE_BUTTON(self, self.on_pmButton)
            self.active_button = 7

        # command line options
        if options.audio_file == "": SAVE_AUDIO_TO_FILE = False
        else: SAVE_AUDIO_TO_FILE = True
        if options.radio_file == "": SAVE_RADIO_TO_FILE = False
        else: SAVE_RADIO_TO_FILE = True
        if options.input_file == "": self.PLAY_FROM_USRP = True
        else: self.PLAY_FROM_USRP = False

        if self.PLAY_FROM_USRP:
            self.src = uhd.usrp_source(options.args,
                                       stream_args=uhd.stream_args('fc32'))
            self.src.set_samp_rate(input_rate)
            self.src.set_subdev_spec(options.spec)
            self.input_rate = input_rate = self.src.get_samp_rate()

            self.src.set_center_freq(self.usrp_center, 0)
            self.tune_offset = 0

            fir_decim = long(self.input_rate / self.af_sample_rate)
            rrate = self.af_sample_rate / (self.input_rate / float(fir_decim))

            print "Actual Input Rate: ", self.input_rate
            print "FIR DECIM: ", fir_decim
            print "Remaining resampling: ", rrate
            print "Sampling Rate at Audio Sink: ", (self.input_rate /
                                                    fir_decim) * rrate
            print "Request Rate at Audio Sink: ", self.af_sample_rate

        else:
            self.src = blocks.file_source(gr.sizeof_short, options.input_file)
            self.tune_offset = 2200  # 2200 works for 3.5-4Mhz band

            # convert rf data in interleaved short int form to complex
            s2ss = blocks.stream_to_streams(gr.sizeof_short, 2)
            s2f1 = blocks.short_to_float()
            s2f2 = blocks.short_to_float()
            src_f2c = blocks.float_to_complex()
            self.tb.connect(self.src, s2ss)
            self.tb.connect((s2ss, 0), s2f1)
            self.tb.connect((s2ss, 1), s2f2)
            self.tb.connect(s2f1, (src_f2c, 0))
            self.tb.connect(s2f2, (src_f2c, 1))

            fir_decim = long(self.input_rate / self.af_sample_rate)
            rrate = self.af_sample_rate / (self.input_rate / float(fir_decim))

            print "FIR DECIM: ", fir_decim
            print "Remaining resampling: ", rrate
            print "Sampling Rate at Audio Sink: ", (self.input_rate /
                                                    fir_decim) * rrate
            print "Request Rate at Audio Sink: ", self.af_sample_rate

        # save radio data to a file
        if SAVE_RADIO_TO_FILE:
            radio_file = blocks.file_sink(gr.sizeof_short, options.radio_file)
            self.tb.connect(self.src, radio_file)

        # 2nd DDC
        xlate_taps = filter.firdes.low_pass ( \
           1.0, input_rate, 16e3, 4e3, filter.firdes.WIN_HAMMING )
        self.xlate = filter.freq_xlating_fir_filter_ccf ( \
           fir_decim, xlate_taps, self.tune_offset, input_rate )

        nflts = 32
        audio_coeffs = filter.firdes.complex_band_pass(
            nflts,  # gain
            self.input_rate * nflts,  # sample rate
            -3000.0,  # low cutoff
            0.0,  # high cutoff
            100.0,  # transition
            filter.firdes.WIN_KAISER,
            7.0)  # window
        self.slider_fcutoff_hi.SetValue(0)
        self.slider_fcutoff_lo.SetValue(-3000)

        # Filter and resample based on actual radio's sample rate
        self.audio_filter = filter.pfb.arb_resampler_ccc(rrate, audio_coeffs)

        # Main +/- 16Khz spectrum display
        self.fft = fftsink2.fft_sink_c(self.panel_2,
                                       fft_size=512,
                                       sample_rate=self.af_sample_rate,
                                       average=True,
                                       size=(640, 240),
                                       baseband_freq=self.usrp_center)
        c2f = blocks.complex_to_float()

        # AM branch
        self.sel_am = blocks.multiply_const_cc(0)
        # the following frequencies turn out to be in radians/sample
        # analog.pll_refout_cc(alpha,beta,min_freq,max_freq)
        # suggested alpha = X, beta = .25 * X * X
        pll = analog.pll_refout_cc(
            .05, (2. * math.pi * 7.5e3 / self.af_sample_rate),
            (2. * math.pi * 6.5e3 / self.af_sample_rate))
        self.pll_carrier_scale = blocks.multiply_const_cc(complex(10, 0))
        am_det = blocks.multiply_cc()
        # these are for converting +7.5kHz to -7.5kHz
        # for some reason blocks.conjugate_cc() adds noise ??
        c2f2 = blocks.complex_to_float()
        c2f3 = blocks.complex_to_float()
        f2c = blocks.float_to_complex()
        phaser1 = blocks.multiply_const_ff(1)
        phaser2 = blocks.multiply_const_ff(-1)

        # filter for pll generated carrier
        pll_carrier_coeffs = filter.firdes.complex_band_pass(
            2.0,  # gain
            self.af_sample_rate,  # sample rate
            7400,  # low cutoff
            7600,  # high cutoff
            100,  # transition
            filter.firdes.WIN_HAMMING)  # window

        self.pll_carrier_filter = filter.fir_filter_ccc(1, pll_carrier_coeffs)

        self.sel_sb = blocks.multiply_const_ff(1)
        combine = blocks.add_ff()

        #AGC
        sqr1 = blocks.multiply_ff()
        intr = filter.iir_filter_ffd([.004, 0], [0, .999])
        offset = blocks.add_const_ff(1)
        agc = blocks.divide_ff()

        self.scale = blocks.multiply_const_ff(0.00001)
        dst = audio.sink(long(self.af_sample_rate), options.audio_output)

        if self.PLAY_FROM_USRP:
            self.tb.connect(self.src, self.xlate, self.fft)
        else:
            self.tb.connect(src_f2c, self.xlate, self.fft)

        self.tb.connect(self.xlate, self.audio_filter, self.sel_am,
                        (am_det, 0))
        self.tb.connect(self.sel_am, pll, self.pll_carrier_scale,
                        self.pll_carrier_filter, c2f3)
        self.tb.connect((c2f3, 0), phaser1, (f2c, 0))
        self.tb.connect((c2f3, 1), phaser2, (f2c, 1))
        self.tb.connect(f2c, (am_det, 1))
        self.tb.connect(am_det, c2f2, (combine, 0))
        self.tb.connect(self.audio_filter, c2f, self.sel_sb, (combine, 1))

        self.tb.connect(combine, self.scale)
        self.tb.connect(self.scale, (sqr1, 0))
        self.tb.connect(self.scale, (sqr1, 1))
        self.tb.connect(sqr1, intr, offset, (agc, 1))
        self.tb.connect(self.scale, (agc, 0))
        self.tb.connect(agc, blocks.null_sink(gr.sizeof_float))
        self.tb.connect(c2f3, dst)

        if SAVE_AUDIO_TO_FILE:
            f_out = blocks.file_sink(gr.sizeof_short, options.audio_file)
            sc1 = blocks.multiply_const_ff(64000)
            f2s1 = blocks.float_to_short()
            self.tb.connect(agc, sc1, f2s1, f_out)

        self.tb.start()

        # left click to re-tune
        self.fft.win.plotter.Bind(wx.EVT_LEFT_DOWN, self.Click)

        # start a timer to check for web commands
        if WEB_CONTROL:
            self.timer = UpdateTimer(self, 1000)  # every 1000 mSec, 1 Sec

        wx.EVT_BUTTON(self, ID_BUTTON_1, self.set_lsb)
        wx.EVT_BUTTON(self, ID_BUTTON_2, self.set_usb)
        wx.EVT_BUTTON(self, ID_BUTTON_3, self.set_am)
        wx.EVT_BUTTON(self, ID_BUTTON_4, self.set_cw)
        wx.EVT_BUTTON(self, ID_BUTTON_10, self.fwd)
        wx.EVT_BUTTON(self, ID_BUTTON_11, self.rew)
        wx.EVT_TOGGLEBUTTON(self, ID_BUTTON_5, self.on_button)
        wx.EVT_TOGGLEBUTTON(self, ID_BUTTON_6, self.on_button)
        wx.EVT_TOGGLEBUTTON(self, ID_BUTTON_7, self.on_button)
        wx.EVT_TOGGLEBUTTON(self, ID_BUTTON_8, self.on_button)
        wx.EVT_TOGGLEBUTTON(self, ID_BUTTON_9, self.on_button)
        wx.EVT_SLIDER(self, ID_SLIDER_1, self.set_filter)
        wx.EVT_SLIDER(self, ID_SLIDER_2, self.set_filter)
        wx.EVT_SLIDER(self, ID_SLIDER_3, self.slide_tune)
        wx.EVT_SLIDER(self, ID_SLIDER_4, self.set_volume)
        wx.EVT_SLIDER(self, ID_SLIDER_5, self.set_pga)
        wx.EVT_SPINCTRL(self, ID_SPIN_1, self.spin_tune)

        wx.EVT_MENU(self, ID_EXIT, self.TimeToQuit)
示例#29
0
    def test_000(self):
        N = 1000  # number of samples to use
        M = 5  # Number of channels to channelize
        fs = 5000  # baseband sampling rate
        ifs = M * fs  # input samp rate to channelizer

        taps = filter.firdes.low_pass_2(
            1,
            ifs,
            fs / 2,
            fs / 10,
            attenuation_dB=80,
            window=filter.firdes.WIN_BLACKMAN_hARRIS)

        signals = list()
        add = blocks.add_cc()
        freqs = [-230., 121., 110., -513., 203.]
        for i in xrange(len(freqs)):
            f = freqs[i] + (M / 2 - M + i + 1) * fs
            data = sig_source_c(ifs, f, 1, N)
            signals.append(blocks.vector_source_c(data))
            self.tb.connect(signals[i], (add, i))

        s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex, M)
        pfb = filter.pfb_channelizer_ccf(M, taps, 1)

        self.tb.connect(add, s2ss)

        snks = list()
        for i in xrange(M):
            snks.append(blocks.vector_sink_c())
            self.tb.connect((s2ss, i), (pfb, i))
            self.tb.connect((pfb, i), snks[i])

        self.tb.run()

        Ntest = 50
        L = len(snks[0].data())

        # Adjusted phase rotations for data
        p0 = -2 * math.pi * 0 / M
        p1 = -2 * math.pi * 1 / M
        p2 = -2 * math.pi * 2 / M
        p3 = -2 * math.pi * 3 / M
        p4 = -2 * math.pi * 4 / M

        # Filter delay is the normal delay of each arm
        tpf = math.ceil(len(taps) / float(M))
        delay = -(tpf - 1.0) / 2.0
        delay = int(delay)

        # Create a time scale that's delayed to match the filter delay
        t = map(lambda x: float(x) / fs, xrange(delay, L + delay))

        # Create known data as complex sinusoids at the different baseband freqs
        # the different channel numbering is due to channelizer output order.
        expected0_data = map(lambda x: math.cos(2.*math.pi*freqs[2]*x+p0) + \
                                       1j*math.sin(2.*math.pi*freqs[2]*x+p0), t)
        expected1_data = map(lambda x: math.cos(2.*math.pi*freqs[3]*x+p1) + \
                                       1j*math.sin(2.*math.pi*freqs[3]*x+p1), t)
        expected2_data = map(lambda x: math.cos(2.*math.pi*freqs[4]*x+p2) + \
                                       1j*math.sin(2.*math.pi*freqs[4]*x+p2), t)
        expected3_data = map(lambda x: math.cos(2.*math.pi*freqs[0]*x+p3) + \
                                       1j*math.sin(2.*math.pi*freqs[0]*x+p3), t)
        expected4_data = map(lambda x: math.cos(2.*math.pi*freqs[1]*x+p4) + \
                                       1j*math.sin(2.*math.pi*freqs[1]*x+p4), t)

        dst0_data = snks[0].data()
        dst1_data = snks[1].data()
        dst2_data = snks[2].data()
        dst3_data = snks[3].data()
        dst4_data = snks[4].data()

        self.assertComplexTuplesAlmostEqual(expected0_data[-Ntest:],
                                            dst0_data[-Ntest:], 3)
        self.assertComplexTuplesAlmostEqual(expected1_data[-Ntest:],
                                            dst1_data[-Ntest:], 3)
        self.assertComplexTuplesAlmostEqual(expected2_data[-Ntest:],
                                            dst2_data[-Ntest:], 3)
        self.assertComplexTuplesAlmostEqual(expected3_data[-Ntest:],
                                            dst3_data[-Ntest:], 3)
        self.assertComplexTuplesAlmostEqual(expected4_data[-Ntest:],
                                            dst4_data[-Ntest:], 3)
示例#30
0
    def __init__(self, puncpat='11'):
        gr.top_block.__init__(self, "Rx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Rx")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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


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

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.samp_rate_array_MCR = samp_rate_array_MCR = [7500000,5000000,3750000,3000000,2500000,2000000,1500000,1000000,937500,882352,833333,714285,533333,500000,421052,400000,380952]
        self.rate = rate = 2
        self.polys = polys = [109, 79]
        self.nfilts = nfilts = 32
        self.k = k = 7
        self.eb = eb = 0.22
        self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 36
        self.variable_qtgui_range_0_0 = variable_qtgui_range_0_0 = 49
        self.samp_rate = samp_rate = samp_rate_array_MCR[7]

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



        self.pld_dec = pld_dec = map( (lambda a: fec.cc_decoder.make(440, k, rate, (polys), 0, -1, fec.CC_TERMINATED, False)), range(0,8) );
        self.pld_const = pld_const = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.pld_const.gen_soft_dec_lut(8)
        self.frequencia_usrp = frequencia_usrp = 484e6
        self.MCR = MCR = "master_clock_rate=60e6"

        ##################################################
        # Blocks
        ##################################################
        self._variable_qtgui_range_0_1_range = Range(0, 73, 1, 36, 200)
        self._variable_qtgui_range_0_1_win = RangeWidget(self._variable_qtgui_range_0_1_range, self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider", float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_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._variable_qtgui_range_0_0_range = Range(0, 90, 1, 49, 200)
        self._variable_qtgui_range_0_0_win = RangeWidget(self._variable_qtgui_range_0_0_range, self.set_variable_qtgui_range_0_0, 'Gain_Jamming', "counter_slider", float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_win, 0, 3, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.uhd_usrp_source_0_0 = uhd.usrp_source(
        	",".join(("serial=F5EAC0", MCR)),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0_0.set_center_freq(frequencia_usrp, 0)
        self.uhd_usrp_source_0_0.set_gain(variable_qtgui_range_0_1, 0)
        self.uhd_usrp_source_0_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_0_0.set_auto_dc_offset(True, 0)
        self.uhd_usrp_source_0_0.set_auto_iq_balance(True, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("serial=F5EAC0", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_center_freq(frequencia_usrp, 0)
        self.uhd_usrp_sink_0.set_gain(variable_qtgui_range_0_0, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.qtgui_time_sink_x_2_0 = qtgui.time_sink_f(
        	1024, #size
        	samp_rate, #samp_rate
        	"After CAC", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_2_0.set_update_time(0.10)
        self.qtgui_time_sink_x_2_0.set_y_axis(0, 1.5)

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

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

        if not True:
          self.qtgui_time_sink_x_2_0.disable_legend()

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

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

        self._qtgui_time_sink_x_2_0_win = sip.wrapinstance(self.qtgui_time_sink_x_2_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_0_win, 2, 2, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_1_0_0 = qtgui.time_sink_c(
        	1024, #size
        	samp_rate, #samp_rate
        	"TX JAMMING USRP", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_1_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0_0.set_y_axis(-1, 1)

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

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

        if not True:
          self.qtgui_time_sink_x_1_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):
            if len(labels[i]) == 0:
                if(i % 2 == 0):
                    self.qtgui_time_sink_x_1_0_0.set_line_label(i, "Re{{Data {0}}}".format(i/2))
                else:
                    self.qtgui_time_sink_x_1_0_0.set_line_label(i, "Im{{Data {0}}}".format(i/2))
            else:
                self.qtgui_time_sink_x_1_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_0_win, 1, 1, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_1_0 = qtgui.time_sink_c(
        	1024, #size
        	samp_rate, #samp_rate
        	"RX USRP", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1)

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

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

        if not True:
          self.qtgui_time_sink_x_1_0.disable_legend()

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        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:
                if(i % 2 == 0):
                    self.qtgui_time_sink_x_1_0.set_line_label(i, "Re{{Data {0}}}".format(i/2))
                else:
                    self.qtgui_time_sink_x_1_0.set_line_label(i, "Im{{Data {0}}}".format(i/2))
            else:
                self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win, 1, 2, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f(
        	100*2, #size
        	samp_rate, #samp_rate
        	'Rx Data', #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0_1.set_update_time(0.10)
        self.qtgui_time_sink_x_0_1.set_y_axis(-1, 256)

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

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

        if not True:
          self.qtgui_time_sink_x_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 = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

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

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

        if not True:
          self.qtgui_const_sink_x_0_0_0_1.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_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0_0_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_0_1_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_win, 1, 3, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c(
        	1024, #size
        	"RX Treated", #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 True:
          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.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_win, 2, 1, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.interp_fir_filter_xxx_1 = filter.interp_fir_filter_ccc(4, ([1,0,0,0]))
        self.interp_fir_filter_xxx_1.declare_sample_delay(0)
        self.fec_extended_decoder_0_0_1_0_1_0 = fec.extended_decoder(decoder_obj_list=pld_dec, threading='capillary', ann=None, puncpat=puncpat, integration_period=10000)
        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_0_0_0_0_0 = digital.map_bb(([-1, 1]))
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(pld_const.arity())
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(6.28/100.0, pld_const.arity(), False)
        self.digital_correlate_access_code_xx_ts_0_0 = digital.correlate_access_code_bb_ts(digital.packet_utils.default_access_code,
          1, 'packet_len')
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(pld_const)
        self.custom_corr = correlate_and_delay.corr_and_delay(200*sps, 0, 0.99, sps)
        self.blocks_stream_to_streams_0 = blocks.stream_to_streams(gr.sizeof_float*1, 2)
        self.blocks_stream_mux_1_0 = blocks.stream_mux(gr.sizeof_float*1, (1, 1))
        self.blocks_stream_mux_1 = blocks.stream_mux(gr.sizeof_float*1, (1, 1))
        self.blocks_repack_bits_bb_0_0_0_1_0 = blocks.repack_bits_bb(1, 8, '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(pld_const.bits_per_symbol(), 1, '', False, gr.GR_MSB_FIRST)
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1)
        self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vcc((0.7, ))
        self.blocks_keep_m_in_n_0_0_2_0 = blocks.keep_m_in_n(gr.sizeof_char, 892, 896, 0)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_sink_0_0_0_0 = blocks.file_sink(gr.sizeof_char*1, '/home/it/Desktop/Trasmited/depois.txt', False)
        self.blocks_file_sink_0_0_0_0.set_unbuffered(False)
        self.blocks_complex_to_float_0_0 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_char_to_float_1_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_0 = blocks.char_to_float(1, 1)
        self.analog_noise_source_x_0_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 1, 0)
        self.adapt_lms_filter_xx_0 = adapt.lms_filter_ff(True, 32, 0.001, 0, 1, True, False, False)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.adapt_lms_filter_xx_0, 0), (self.blocks_null_sink_0, 0))
        self.connect((self.adapt_lms_filter_xx_0, 1), (self.blocks_stream_to_streams_0, 0))
        self.connect((self.analog_noise_source_x_0_0, 0), (self.interp_fir_filter_xxx_1, 0))
        self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_2_0, 0))
        self.connect((self.blocks_char_to_float_0_2_0_0, 0), (self.fec_extended_decoder_0_0_1_0_1_0, 0))
        self.connect((self.blocks_char_to_float_1_0_1, 0), (self.qtgui_time_sink_x_0_1, 0))
        self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_stream_mux_1, 1))
        self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_stream_mux_1, 0))
        self.connect((self.blocks_complex_to_float_0_0, 1), (self.blocks_stream_mux_1_0, 1))
        self.connect((self.blocks_complex_to_float_0_0, 0), (self.blocks_stream_mux_1_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.blocks_keep_m_in_n_0_0_2_0, 0), (self.digital_map_bb_0_0_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.custom_corr, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_time_sink_x_1_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_correlate_access_code_xx_ts_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0), (self.blocks_char_to_float_1_0_1, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0), (self.blocks_file_sink_0_0_0_0, 0))
        self.connect((self.blocks_stream_mux_1, 0), (self.adapt_lms_filter_xx_0, 1))
        self.connect((self.blocks_stream_mux_1_0, 0), (self.adapt_lms_filter_xx_0, 0))
        self.connect((self.blocks_stream_to_streams_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_stream_to_streams_0, 1), (self.blocks_float_to_complex_0, 1))
        self.connect((self.custom_corr, 0), (self.blocks_complex_to_float_0, 0))
        self.connect((self.custom_corr, 1), (self.blocks_complex_to_float_0_0, 0))
        self.connect((self.custom_corr, 2), (self.blocks_null_sink_1, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_correlate_access_code_xx_ts_0_0, 0), (self.blocks_char_to_float_0_0, 0))
        self.connect((self.digital_correlate_access_code_xx_ts_0_0, 0), (self.blocks_keep_m_in_n_0_0_2_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0), (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0), (self.qtgui_const_sink_x_0_0_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_map_bb_0_0_0_0_0, 0), (self.blocks_char_to_float_0_2_0_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0_0, 0))
        self.connect((self.fec_extended_decoder_0_0_1_0_1_0, 0), (self.blocks_repack_bits_bb_0_0_0_1_0, 0))
        self.connect((self.interp_fir_filter_xxx_1, 0), (self.blocks_multiply_const_vxx_1_0, 0))
        self.connect((self.uhd_usrp_source_0_0, 0), (self.custom_corr, 1))
        self.connect((self.uhd_usrp_source_0_0, 0), (self.qtgui_const_sink_x_0_0_0_1, 0))
        self.connect((self.uhd_usrp_source_0_0, 0), (self.qtgui_time_sink_x_1_0, 0))
示例#31
0
    def test_000(self):
        N = 1000         # number of samples to use
        M = 5            # Number of channels to channelize
        fs = 5000        # baseband sampling rate
        ifs = M*fs       # input samp rate to channelizer

        taps = filter.firdes.low_pass_2(1, ifs, fs/2, fs/10,
                                        attenuation_dB=80,
                                        window=filter.firdes.WIN_BLACKMAN_hARRIS)

        signals = list()
        add = blocks.add_cc()
        freqs = [-230., 121., 110., -513., 203.]
        for i in xrange(len(freqs)):
            f = freqs[i] + (M/2-M+i+1)*fs
            data = sig_source_c(ifs, f, 1, N)
            signals.append(blocks.vector_source_c(data))
            self.tb.connect(signals[i], (add,i))

        s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex, M)
        pfb = filter.pfb_channelizer_ccf(M, taps, 1)

        self.tb.connect(add, s2ss)

        snks = list()
        for i in xrange(M):
            snks.append(blocks.vector_sink_c())
            self.tb.connect((s2ss,i), (pfb,i))
            self.tb.connect((pfb, i), snks[i])

        self.tb.run()

        Ntest = 50
        L = len(snks[0].data())

        # Adjusted phase rotations for data
        p0 = 0.11058379158914133
        p1 = 4.5108246571401693
        p2 = 3.9739891674564594
        p3 = 2.2820531095511924
        p4 = 1.3782797467397869

        # Filter delay is the normal delay of each arm
        tpf = math.ceil(len(taps) / float(M))
        delay = -(tpf - 1.0) / 2.0
        delay = int(delay)

        # Create a time scale that's delayed to match the filter delay
        t = map(lambda x: float(x)/fs, xrange(delay, L+delay))

        # Create known data as complex sinusoids at the different baseband freqs
        # the different channel numbering is due to channelizer output order.
        expected0_data = map(lambda x: math.cos(2.*math.pi*freqs[2]*x+p0) + \
                                       1j*math.sin(2.*math.pi*freqs[2]*x+p0), t)
        expected1_data = map(lambda x: math.cos(2.*math.pi*freqs[3]*x+p1) + \
                                       1j*math.sin(2.*math.pi*freqs[3]*x+p1), t)
        expected2_data = map(lambda x: math.cos(2.*math.pi*freqs[4]*x+p2) + \
                                       1j*math.sin(2.*math.pi*freqs[4]*x+p2), t)
        expected3_data = map(lambda x: math.cos(2.*math.pi*freqs[0]*x+p3) + \
                                       1j*math.sin(2.*math.pi*freqs[0]*x+p3), t)
        expected4_data = map(lambda x: math.cos(2.*math.pi*freqs[1]*x+p4) + \
                                       1j*math.sin(2.*math.pi*freqs[1]*x+p4), t)

        dst0_data = snks[0].data()
        dst1_data = snks[1].data()
        dst2_data = snks[2].data()
        dst3_data = snks[3].data()
        dst4_data = snks[4].data()

        self.assertComplexTuplesAlmostEqual(expected0_data[-Ntest:], dst0_data[-Ntest:], 3)
        self.assertComplexTuplesAlmostEqual(expected1_data[-Ntest:], dst1_data[-Ntest:], 3)
        self.assertComplexTuplesAlmostEqual(expected2_data[-Ntest:], dst2_data[-Ntest:], 3)
        self.assertComplexTuplesAlmostEqual(expected3_data[-Ntest:], dst3_data[-Ntest:], 3)
        self.assertComplexTuplesAlmostEqual(expected4_data[-Ntest:], dst4_data[-Ntest:], 3)
示例#32
0
    def __init__(self,options):
        '''
            Constructor for top block of Power Estimator
            Creates the graph for calculating mean and variance
        '''
        gr.hier_block2.__init__(self, "periodogram", \
                                    gr.io_signature(1,1,gr.sizeof_gr_complex), \
                                    gr.io_signature(0,0,0) )

        scalarx=blocks.multiply_const_cc(1)

        ########## Node 1 - streams2vector block (input from usrp & output to fft block) ##########
        s2v = blocks.stream_to_vector(gr.sizeof_gr_complex, options.fft_size)

        #Node 3 - fft block
        mywindow = filter.window.blackmanharris(options.fft_size)
        ffter = fft.fft_vcc(options.fft_size, True, mywindow)

        #Node 4 - magnitude-squared block
        c2mag = blocks.complex_to_mag_squared(options.fft_size)

        #Node 5 - vector2stream block
        vector2stream = blocks.vector_to_stream(gr.sizeof_float,options.fft_size)

        #Node 6 - stream2streams block
        stream2streams = blocks.stream_to_streams(gr.sizeof_float, options.fft_size)

        #Node 7 - adder block
        self.sumofNstreams = blocks.add_ff()

        #Node 8 - multiplier block (used to divide the output of adder block)
        self.avgofNstreams = blocks.multiply_const_ff(1.0/options.noofbins) # TODO: will depend on the number of bins

        #Node 9 - sinks (vector and null)
        to_nullsink = blocks.streams_to_stream(gr.sizeof_float,10)
        #self.vsink = gr.vector_sink_f()
        self.fsink = blocks.file_sink(gr.sizeof_float,"fsink.dat")
        if options.fft_size != options.noofbins:
            streams2stream = blocks.streams_to_stream(gr.sizeof_float, options.fft_size-options.noofbins)
        nullsink = blocks.null_sink(gr.sizeof_float)

        #Connect Phase 1 - From USRP source to stream2streams
        self.connect(self, scalarx, s2v, ffter, c2mag, vector2stream,stream2streams)
        for index in range(options.noofbins):
            self.connect((stream2streams,index), (self.sumofNstreams, index))
        i=10
        #Connect Phase 2 - From stream2streams to adder(few) and streams2stream(remaining)
        '''for index in range(5):
            self.connect((stream2streams,index), (to_nullsink,index))
        for index in range(5,options.noofbins-5):
            self.connect((stream2streams,index), (sumofNstreams, index-5))
        for index in range(options.fft_size-5,options.fft_size):
            self.connect((stream2streams,index), (to_nullsink,i))
            i=i+1
        else:
            for index in range(5,options.noofbins+5):
                self.connect((stream2streams,index), (sumofNstreams, index-5))
            for index in range(options.noofbins+5,options.fft_size):
                self.connect((stream2streams,index), (streams2stream,index-options.noofbins))'''

        #Connect Phase 3 - (few) from adder to vector sink, (remaining) to null sink
        #self.connect(streams2stream, nullsink)
        self.connect(self.sumofNstreams,self.avgofNstreams,self.fsink)

        #self.connect(to_nullsink,nullsink)

        print "FFT size                 %d" % (options.fft_size)
        print "Nblocks considered       %d" % (options.nblocks)
        print "No.of bins considered    %d" % (options.noofbins)
    def __init__(self, puncpat='11'):
        gr.top_block.__init__(self, "Tutorial")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Tutorial")
        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", "corr_ultimapte_testing")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

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

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.samp_rate_array_MCR = samp_rate_array_MCR = [
            7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000,
            1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052,
            400000, 380952
        ]
        self.rate = rate = 2
        self.polys = polys = [109, 79]
        self.nfilts = nfilts = 32
        self.k = k = 7
        self.eb = eb = 0.22
        self.vector = vector = [int(random.random() * 4) for i in range(49600)]
        self.variable_qtgui_range_1_0 = variable_qtgui_range_1_0 = 900
        self.variable_qtgui_range_1 = variable_qtgui_range_1 = 0
        self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 38
        self.variable_qtgui_range_0 = variable_qtgui_range_0 = 50

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

        self.samp_rate = samp_rate = samp_rate_array_MCR[7]

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

        self.pld_enc = pld_enc = map((lambda a: fec.cc_encoder_make(
            440, k, rate, (polys), 0, fec.CC_TERMINATED, False)), range(0, 4))

        self.pld_dec = pld_dec = map((lambda a: fec.cc_decoder.make(
            440, k, rate, (polys), 0, -1, fec.CC_TERMINATED, False)),
                                     range(0, 8))
        self.pld_const = pld_const = digital.constellation_rect(([
            0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j
        ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.pld_const.gen_soft_dec_lut(8)
        self.frequencia_usrp = frequencia_usrp = 484e6
        self.MCR = MCR = "master_clock_rate=60e6"

        ##################################################
        # Blocks
        ##################################################
        self._variable_qtgui_range_1_range = Range(0, 5000, 1, 0, 200)
        self._variable_qtgui_range_1_win = RangeWidget(
            self._variable_qtgui_range_1_range,
            self.set_variable_qtgui_range_1, 'Delay JAMMING', "counter_slider",
            int)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_1_win, 2, 1,
                                       1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._variable_qtgui_range_1_0_range = Range(0, 5000, 1, 900, 200)
        self._variable_qtgui_range_1_0_win = RangeWidget(
            self._variable_qtgui_range_1_0_range,
            self.set_variable_qtgui_range_1_0, 'Delay SIGNAL',
            "counter_slider", int)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_1_0_win, 3,
                                       1, 1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._variable_qtgui_range_0_1_range = Range(0, 73, 1, 38, 200)
        self._variable_qtgui_range_0_1_win = RangeWidget(
            self._variable_qtgui_range_0_1_range,
            self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider",
            float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_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._variable_qtgui_range_0_range = Range(0, 90, 1, 50, 200)
        self._variable_qtgui_range_0_win = RangeWidget(
            self._variable_qtgui_range_0_range,
            self.set_variable_qtgui_range_0, 'Gain_TX', "counter_slider",
            float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_win, 0, 1,
                                       1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_2_0_1 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "MAG",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_2_0_1.set_update_time(0.10)
        self.qtgui_time_sink_x_2_0_1.set_y_axis(-1, 200)

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

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

        if not True:
            self.qtgui_time_sink_x_2_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 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

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

        self._qtgui_time_sink_x_2_0_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_2_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_0_1_win)
        self.qtgui_time_sink_x_2_0_0_1 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "Without MAG",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_2_0_0_1.set_update_time(0.10)
        self.qtgui_time_sink_x_2_0_0_1.set_y_axis(-1, 15)

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

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

        if not True:
            self.qtgui_time_sink_x_2_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 = [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:
                if (i % 2 == 0):
                    self.qtgui_time_sink_x_2_0_0_1.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_2_0_0_1.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            else:
                self.qtgui_time_sink_x_2_0_0_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_2_0_0_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_2_0_0_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_2_0_0_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_2_0_0_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_2_0_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_2_0_0_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_2_0_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_0_0_1_win)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "TX USRP",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_1.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        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:
                if (i % 2 == 0):
                    self.qtgui_time_sink_x_1.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_1.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            else:
                self.qtgui_time_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win, 1, 3, 1,
                                       1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f(
            100 * 2,  #size
            samp_rate,  #samp_rate
            'Rx Data',  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_1.set_update_time(0.10)
        self.qtgui_time_sink_x_0_1.set_y_axis(-1, 256)

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

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

        if not True:
            self.qtgui_time_sink_x_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 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

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

        self._qtgui_time_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win, 2, 3,
                                       1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            100 * 2,  #size
            samp_rate,  #samp_rate
            'Tx Data',  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 256)

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

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

        if not True:
            self.qtgui_time_sink_x_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(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i])

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

        if not True:
            self.qtgui_freq_sink_x_1.disable_legend()

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

        labels = ['OUT', 'ERROR', 'Output', 'Error', 'MIX', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "black", "red", "green", "cyan", "magenta", "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(2):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_1_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 6, 1, 1,
                                       3)
        for r in range(6, 7):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0_0_1_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "Difference Between ORIGINAL/RECOVERED",  #name
            2  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0_1_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_0_1_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_0_1_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0_1_0.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0_0_1_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0_1_0.enable_grid(False)
        self.qtgui_freq_sink_x_0_0_1_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_0_1_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0_1_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0_0_1_0.disable_legend()

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

        labels = [
            'After chunks to symbols', 'ERROR LMS', 'Error LMS', '', '', '',
            '', '', '', ''
        ]
        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(2):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0_0_1_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_0_1_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_0_1_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_0_1_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_0_1_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_0_1_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_1_0_win, 5,
                                       1, 1, 3)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0_0_1_0 = qtgui.const_sink_c(
            1024,  #size
            "RX Treated Constellation",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0_1_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0_1_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_1_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_1_0.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0_1_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0_1_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0_1_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0_0_1_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_1_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0_0_1_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0_0_1_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0_0_1_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0_0_1_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0_0_1_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0_0_1_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_0_1_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_0_win,
                                       2, 2, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0_0_0 = qtgui.const_sink_c(
            1024,  #size
            "TX Constellation",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_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_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_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_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0_0_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0_0_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0_0_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0_0_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0_0_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_0_win, 1,
                                       2, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccc(
            sps, taps=(tx_rrc_taps), flt_size=nfilts)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(sps, ([1]))
        self.interp_fir_filter_xxx_0.declare_sample_delay(0)
        self.insert_vec_cpp_new_vec_0 = insert_vec_cpp.new_vec((vector))
        self.digital_pfb_clock_sync_xxx_0_0_0 = digital.pfb_clock_sync_ccf(
            sps, 6.28 / 100.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 1)
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(
            pld_const.arity())
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(
            pld_const.arity())
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            6.28 / 100, 4, False)
        self.digital_correlate_access_code_xx_ts_0_0 = digital.correlate_access_code_bb_ts(
            digital.packet_utils.default_access_code, 1, 'packet_len')
        self.digital_constellation_decoder_cb_0_0 = digital.constellation_decoder_cb(
            pld_const)
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(
            (pld_const.points()), 1)
        self.custom_corr = correlate_and_delay.corr_and_delay(
            200 * sps, 0, 0.99, sps)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate,
                                                 True)
        self.blocks_stream_to_streams_0 = blocks.stream_to_streams(
            gr.sizeof_float * 1, 2)
        self.blocks_stream_mux_1_0 = blocks.stream_mux(gr.sizeof_float * 1,
                                                       (1, 1))
        self.blocks_stream_mux_1 = blocks.stream_mux(gr.sizeof_float * 1,
                                                     (1, 1))
        self.blocks_stream_mux_0_1_0 = blocks.stream_mux(
            gr.sizeof_char * 1, (96, 896))
        self.blocks_repack_bits_bb_1_0_0_1 = blocks.repack_bits_bb(
            8, 1, '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0_1 = blocks.repack_bits_bb(
            1, pld_const.bits_per_symbol(), '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(
            1, 8, '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            pld_const.bits_per_symbol(), 1, '', False, gr.GR_MSB_FIRST)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.3, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.7, ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0_0_1_0 = blocks.file_source(
            gr.sizeof_char * 1,
            '/home/andre/Desktop/Files_To_Transmit/trasmit_10_mb.txt', False)
        self.blocks_file_source_0_0_1_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0_0_0_2 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/andre/Desktop/Trasmited/depois.txt',
            False)
        self.blocks_file_sink_0_0_0_2.set_unbuffered(False)
        self.blocks_delay_0_0_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                               variable_qtgui_range_1)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, 900)
        self.blocks_complex_to_mag_squared_0_1_0 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_float_0_0 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(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)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1, 0)
        self.adapt_lms_filter_xx_0 = adapt.lms_filter_ff(
            True, 32, 0.0001, 0, 1, True, False, False)
        self.acode_1104 = blocks.vector_source_b([
            0x1, 0x0, 0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x0, 0x1, 0x1,
            0x1, 0x0, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1,
            0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1,
            0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0,
            0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0,
            0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0,
            0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1,
            0x1, 0x0, 0x0, 0x0, 0x0
        ], True, 1, [])

        ##################################################
        # Connections
        ##################################################
        self.connect((self.acode_1104, 0), (self.blocks_stream_mux_0_1_0, 0))
        self.connect((self.adapt_lms_filter_xx_0, 1),
                     (self.blocks_stream_to_streams_0, 0))
        self.connect((self.adapt_lms_filter_xx_0, 1),
                     (self.qtgui_freq_sink_x_1, 1))
        self.connect((self.adapt_lms_filter_xx_0, 0),
                     (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.interp_fir_filter_xxx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_delay_0_0, 0))
        self.connect((self.blocks_char_to_float_1_0_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_char_to_float_1_0_1, 0),
                     (self.qtgui_time_sink_x_0_1, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_stream_mux_1, 1))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_stream_mux_1, 0))
        self.connect((self.blocks_complex_to_float_0_0, 1),
                     (self.blocks_stream_mux_1_0, 1))
        self.connect((self.blocks_complex_to_float_0_0, 0),
                     (self.blocks_stream_mux_1_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_1_0, 0),
                     (self.qtgui_time_sink_x_2_0_1, 0))
        self.connect((self.blocks_delay_0_0, 0), (self.custom_corr, 1))
        self.connect((self.blocks_delay_0_0_0, 0), (self.custom_corr, 0))
        self.connect((self.blocks_file_source_0_0_1_0, 0),
                     (self.blocks_char_to_float_1_0_0, 0))
        self.connect((self.blocks_file_source_0_0_1_0, 0),
                     (self.blocks_repack_bits_bb_1_0_0_1, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.qtgui_const_sink_x_0_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.qtgui_time_sink_x_1, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.digital_correlate_access_code_xx_ts_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0),
                     (self.blocks_char_to_float_1_0_1, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0),
                     (self.blocks_file_sink_0_0_0_2, 0))
        self.connect((self.blocks_repack_bits_bb_0_1, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_repack_bits_bb_1_0_0_1, 0),
                     (self.blocks_stream_mux_0_1_0, 1))
        self.connect((self.blocks_stream_mux_0_1_0, 0),
                     (self.blocks_repack_bits_bb_0_1, 0))
        self.connect((self.blocks_stream_mux_1, 0),
                     (self.adapt_lms_filter_xx_0, 1))
        self.connect((self.blocks_stream_mux_1_0, 0),
                     (self.adapt_lms_filter_xx_0, 0))
        self.connect((self.blocks_stream_to_streams_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_stream_to_streams_0, 1),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_throttle_0, 0),
                     (self.insert_vec_cpp_new_vec_0, 0))
        self.connect((self.custom_corr, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.custom_corr, 1),
                     (self.blocks_complex_to_float_0_0, 0))
        self.connect((self.custom_corr, 2),
                     (self.blocks_complex_to_mag_squared_0_1_0, 0))
        self.connect((self.custom_corr, 2),
                     (self.qtgui_time_sink_x_2_0_0_1, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0),
                     (self.qtgui_freq_sink_x_0_0_1_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_correlate_access_code_xx_ts_0_0, 0),
                     (self.blocks_repack_bits_bb_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.digital_constellation_decoder_cb_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.qtgui_const_sink_x_0_0_0_1_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.qtgui_freq_sink_x_0_0_1_0, 1))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0_0_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.insert_vec_cpp_new_vec_0, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.interp_fir_filter_xxx_0, 0),
                     (self.blocks_delay_0_0_0, 0))
        self.connect((self.interp_fir_filter_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
示例#34
0
    def test_000(self):
        N = 1000  # number of samples to use
        M = 5  # Number of channels to channelize
        fs = 1000  # baseband sampling rate
        ifs = M * fs  # input samp rate to channelizer

        taps = filter.firdes.low_pass_2(
            1,
            ifs,
            500,
            50,
            attenuation_dB=80,
            window=filter.firdes.WIN_BLACKMAN_hARRIS)

        signals = list()
        add = blocks.add_cc()
        freqs = [-200, -100, 0, 100, 200]
        for i in xrange(len(freqs)):
            f = freqs[i] + (M / 2 - M + i + 1) * fs
            data = sig_source_c(ifs, f, 1, N)
            signals.append(blocks.vector_source_c(data))
            self.tb.connect(signals[i], (add, i))

        s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex, M)
        pfb = filter.pfb_channelizer_ccf(M, taps, 1)

        self.tb.connect(add, s2ss)

        snks = list()
        for i in xrange(M):
            snks.append(blocks.vector_sink_c())
            self.tb.connect((s2ss, i), (pfb, i))
            self.tb.connect((pfb, i), snks[i])

        self.tb.run()

        Ntest = 50
        L = len(snks[0].data())
        t = map(lambda x: float(x) / fs, xrange(L))

        # Adjusted phase rotations for data
        p0 = 0
        p1 = math.pi * 0.51998885
        p2 = -math.pi * 0.96002233
        p3 = math.pi * 0.96002233
        p4 = -math.pi * 0.51998885

        # Create known data as complex sinusoids at the different baseband freqs
        # the different channel numbering is due to channelizer output order.
        expected0_data = map(lambda x: math.cos(2.*math.pi*freqs[2]*x+p0) + \
                                       1j*math.sin(2.*math.pi*freqs[2]*x+p0), t)
        expected1_data = map(lambda x: math.cos(2.*math.pi*freqs[3]*x+p1) + \
                                       1j*math.sin(2.*math.pi*freqs[3]*x+p1), t)
        expected2_data = map(lambda x: math.cos(2.*math.pi*freqs[4]*x+p2) + \
                                       1j*math.sin(2.*math.pi*freqs[4]*x+p2), t)
        expected3_data = map(lambda x: math.cos(2.*math.pi*freqs[0]*x+p3) + \
                                       1j*math.sin(2.*math.pi*freqs[0]*x+p3), t)
        expected4_data = map(lambda x: math.cos(2.*math.pi*freqs[1]*x+p4) + \
                                       1j*math.sin(2.*math.pi*freqs[1]*x+p4), t)

        dst0_data = snks[0].data()
        dst1_data = snks[1].data()
        dst2_data = snks[2].data()
        dst3_data = snks[3].data()
        dst4_data = snks[4].data()

        self.assertComplexTuplesAlmostEqual(expected0_data[-Ntest:],
                                            dst0_data[-Ntest:], 3)
        self.assertComplexTuplesAlmostEqual(expected1_data[-Ntest:],
                                            dst1_data[-Ntest:], 3)
        self.assertComplexTuplesAlmostEqual(expected2_data[-Ntest:],
                                            dst2_data[-Ntest:], 3)
        self.assertComplexTuplesAlmostEqual(expected3_data[-Ntest:],
                                            dst3_data[-Ntest:], 3)
        self.assertComplexTuplesAlmostEqual(expected4_data[-Ntest:],
                                            dst4_data[-Ntest:], 3)
示例#35
0
    def __init__(self):
        gr.top_block.__init__(self, "Multi Psk")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Multi Psk")
        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", "Multi_PSK")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.timing_loop_bw = timing_loop_bw = 6.28/100.0
        self.time_offset = time_offset = 1.00
        self.taps = taps = [1.0, 0.25-0.25j, 0.50 + 0.10j, -0.3 + 0.2j]
        self.samp_rate = samp_rate = 32000
        
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts*1.0, nfilts*1.0, 1.0/float(sps), 0.35, 11*sps*nfilts)
          
        self.phase_bw = phase_bw = 6.28/100.0
        self.out_sps = out_sps = 2
        self.noise_volt = noise_volt = 0.0001 + (0.3*1)
        self.freq_offset = freq_offset = 0
        self.eq_gain = eq_gain = 0.01
        
        self.const = const = digital.constellation_calcdist((digital.psk_4()[0]), (digital.psk_4()[1]), 4, 1).base()
        

        ##################################################
        # Blocks
        ##################################################
        self._timing_loop_bw_range = Range(0.0, 0.2, 0.01, 6.28/100.0, 200)
        self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range, self.set_timing_loop_bw, 'Time: BW', "slider", float)
        self.top_grid_layout.addWidget(self._timing_loop_bw_win, 0,1,1,1)
        self._time_offset_range = Range(0.999, 1.001, 0.0001, 1.00, 200)
        self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, 'Timing Offset', "counter_slider", float)
        self.top_grid_layout.addWidget(self._time_offset_win, 2,0,1,1)
        self._phase_bw_range = Range(0.0, 1.0, 0.01, 6.28/100.0, 200)
        self._phase_bw_win = RangeWidget(self._phase_bw_range, self.set_phase_bw, 'Phase: Bandwidth', "slider", float)
        self.top_grid_layout.addWidget(self._phase_bw_win, 2,1,1,1)
        self._noise_volt_range = Range(0, 1, 0.01, 0.0001 + (0.3*1), 200)
        self._noise_volt_win = RangeWidget(self._noise_volt_range, self.set_noise_volt, 'Noise Voltage', "counter_slider", float)
        self.top_grid_layout.addWidget(self._noise_volt_win, 0,0,1,1)
        self._freq_offset_range = Range(-0.1, 0.1, 0.001, 0, 200)
        self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Frequency Offset', "counter_slider", float)
        self.top_grid_layout.addWidget(self._freq_offset_win, 1,0,1,1)
        self._eq_gain_range = Range(0.0, 0.1, 0.001, 0.01, 200)
        self._eq_gain_win = RangeWidget(self._eq_gain_range, self.set_eq_gain, 'Equalizer: rate', "slider", float)
        self.top_grid_layout.addWidget(self._eq_gain_win, 1,1,1,1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
        	256, #size
        	samp_rate, #samp_rate
        	"", #name
        	4 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-3, 3)
        
        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 = ['', '', '', '', '',
                  '', '', '', '', '']
        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*4):
            if len(labels[i]) == 0:
                if(i % 2 == 0):
                    self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2))
                else:
                    self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 3,0,1,1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"", #name
        	4 #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 True:
          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(4):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 3,1,1,1)
        self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c(
        	512, #size
        	"", #name
        	4 #number of inputs
        )
        self.qtgui_const_sink_x_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0.enable_axis_labels(True)
        
        if not True:
          self.qtgui_const_sink_x_0_0.disable_legend()
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "magenta", "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(4):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 4,1,1,1)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
        	512, #size
        	"", #name
        	4 #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)
        
        if not True:
          self.qtgui_const_sink_x_0.disable_legend()
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "magenta", "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(4):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 4,0,1,1)
        self.digital_pfb_clock_sync_xxx_0_0_0_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2.0, 1.5, out_sps)
        self.digital_pfb_clock_sync_xxx_0_0_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2.0, 1.5, out_sps)
        self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2.0, 1.5, out_sps)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2.0, 1.5, out_sps)
        self.digital_costas_loop_cc_0_0_0_0 = digital.costas_loop_cc(phase_bw, const.arity(), False)
        self.digital_costas_loop_cc_0_0_0 = digital.costas_loop_cc(phase_bw, const.arity(), False)
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(phase_bw, const.arity(), False)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(phase_bw, const.arity(), False)
        self.digital_constellation_modulator_3 = digital.generic_mod(
          constellation=const,
          differential=True,
          samples_per_symbol=sps,
          pre_diff_code=True,
          excess_bw=0.35,
          verbose=False,
          log=False,
          )
        self.digital_constellation_modulator_2 = digital.generic_mod(
          constellation=const,
          differential=True,
          samples_per_symbol=sps,
          pre_diff_code=True,
          excess_bw=0.35,
          verbose=False,
          log=False,
          )
        self.digital_constellation_modulator_1 = digital.generic_mod(
          constellation=const,
          differential=True,
          samples_per_symbol=sps,
          pre_diff_code=True,
          excess_bw=0.35,
          verbose=False,
          log=False,
          )
        self.digital_constellation_modulator_0 = digital.generic_mod(
          constellation=const,
          differential=True,
          samples_per_symbol=sps,
          pre_diff_code=True,
          excess_bw=0.35,
          verbose=False,
          log=False,
          )
        self.digital_cma_equalizer_cc_0_0_0_0 = digital.cma_equalizer_cc(15, 1, eq_gain, out_sps)
        self.digital_cma_equalizer_cc_0_0_0 = digital.cma_equalizer_cc(15, 1, eq_gain, out_sps)
        self.digital_cma_equalizer_cc_0_0 = digital.cma_equalizer_cc(15, 1, eq_gain, out_sps)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(15, 1, eq_gain, out_sps)
        self.channels_channel_model_3 = channels.channel_model(
        	noise_voltage=noise_volt,
        	frequency_offset=freq_offset,
        	epsilon=time_offset,
        	taps=(taps),
        	noise_seed=0,
        	block_tags=False
        )
        self.channels_channel_model_2 = channels.channel_model(
        	noise_voltage=noise_volt,
        	frequency_offset=freq_offset,
        	epsilon=time_offset,
        	taps=(taps),
        	noise_seed=0,
        	block_tags=False
        )
        self.channels_channel_model_1 = channels.channel_model(
        	noise_voltage=noise_volt,
        	frequency_offset=freq_offset,
        	epsilon=time_offset,
        	taps=(taps),
        	noise_seed=0,
        	block_tags=False
        )
        self.channels_channel_model_0_0 = channels.channel_model(
        	noise_voltage=noise_volt,
        	frequency_offset=freq_offset,
        	epsilon=time_offset,
        	taps=(taps),
        	noise_seed=0,
        	block_tags=False
        )
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_stream_to_streams_0 = blocks.stream_to_streams(gr.sizeof_char*1, 4)
        self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 10000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_to_streams_0, 0))    
        self.connect((self.blocks_stream_to_streams_0, 0), (self.digital_constellation_modulator_0, 0))    
        self.connect((self.blocks_stream_to_streams_0, 1), (self.digital_constellation_modulator_1, 0))    
        self.connect((self.blocks_stream_to_streams_0, 2), (self.digital_constellation_modulator_2, 0))    
        self.connect((self.blocks_stream_to_streams_0, 3), (self.digital_constellation_modulator_3, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.qtgui_const_sink_x_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_0, 0))    
        self.connect((self.channels_channel_model_0_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))    
        self.connect((self.channels_channel_model_0_0, 0), (self.qtgui_freq_sink_x_0, 0))    
        self.connect((self.channels_channel_model_1, 0), (self.digital_pfb_clock_sync_xxx_0_0, 0))    
        self.connect((self.channels_channel_model_1, 0), (self.qtgui_freq_sink_x_0, 1))    
        self.connect((self.channels_channel_model_2, 0), (self.digital_pfb_clock_sync_xxx_0_0_0, 0))    
        self.connect((self.channels_channel_model_2, 0), (self.qtgui_freq_sink_x_0, 2))    
        self.connect((self.channels_channel_model_3, 0), (self.digital_pfb_clock_sync_xxx_0_0_0_0, 0))    
        self.connect((self.channels_channel_model_3, 0), (self.qtgui_freq_sink_x_0, 3))    
        self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0))    
        self.connect((self.digital_cma_equalizer_cc_0_0, 0), (self.digital_costas_loop_cc_0_0, 0))    
        self.connect((self.digital_cma_equalizer_cc_0_0_0, 0), (self.digital_costas_loop_cc_0_0_0, 0))    
        self.connect((self.digital_cma_equalizer_cc_0_0_0_0, 0), (self.digital_costas_loop_cc_0_0_0_0, 0))    
        self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.digital_constellation_modulator_1, 0), (self.channels_channel_model_1, 0))    
        self.connect((self.digital_constellation_modulator_1, 0), (self.qtgui_const_sink_x_0, 1))    
        self.connect((self.digital_constellation_modulator_1, 0), (self.qtgui_time_sink_x_0, 1))    
        self.connect((self.digital_constellation_modulator_2, 0), (self.channels_channel_model_2, 0))    
        self.connect((self.digital_constellation_modulator_2, 0), (self.qtgui_const_sink_x_0, 2))    
        self.connect((self.digital_constellation_modulator_2, 0), (self.qtgui_time_sink_x_0, 2))    
        self.connect((self.digital_constellation_modulator_3, 0), (self.channels_channel_model_3, 0))    
        self.connect((self.digital_constellation_modulator_3, 0), (self.qtgui_const_sink_x_0, 3))    
        self.connect((self.digital_constellation_modulator_3, 0), (self.qtgui_time_sink_x_0, 3))    
        self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0_0, 0))    
        self.connect((self.digital_costas_loop_cc_0_0, 0), (self.qtgui_const_sink_x_0_0, 1))    
        self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self.qtgui_const_sink_x_0_0, 2))    
        self.connect((self.digital_costas_loop_cc_0_0_0_0, 0), (self.qtgui_const_sink_x_0_0, 3))    
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0))    
        self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0), (self.digital_cma_equalizer_cc_0_0, 0))    
        self.connect((self.digital_pfb_clock_sync_xxx_0_0_0, 0), (self.digital_cma_equalizer_cc_0_0_0, 0))    
        self.connect((self.digital_pfb_clock_sync_xxx_0_0_0_0, 0), (self.digital_cma_equalizer_cc_0_0_0_0, 0))    
示例#36
0
    def __init__(self):
        gr.top_block.__init__(self, "Pal Transmit")

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

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

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

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_sub_xx_0, 0))
        self.connect((self.analog_const_source_x_0_0_0_0_0, 0),
                     (self.blocks_stream_to_vector_0_1_0_0_0_0, 0))
        self.connect((self.analog_const_source_x_0_0_0_0_0_0, 0),
                     (self.blocks_stream_to_vector_0_1_0_0_0_0_0, 0))
        self.connect((self.analog_const_source_x_0_0_0_0_0_1, 0),
                     (self.blocks_stream_mux_2_1, 0))
        self.connect((self.analog_const_source_x_0_0_0_0_0_1_0, 0),
                     (self.blocks_stream_mux_2_1, 4))
        self.connect((self.analog_const_source_x_0_0_0_0_0_1_0_0, 0),
                     (self.blocks_stream_mux_2_1, 2))
        self.connect((self.analog_const_source_x_0_0_1_0_0_0, 0),
                     (self.blocks_stream_to_vector_0_1_1_2_0, 0))
        self.connect((self.analog_const_source_x_0_0_2_0_0_0, 0),
                     (self.blocks_stream_to_vector_0_1_1_2, 0))
        self.connect((self.analog_const_source_x_0_0_3, 0),
                     (self.blocks_stream_mux_2, 0))
        self.connect((self.analog_const_source_x_0_0_3_0, 0),
                     (self.blocks_stream_mux_2, 1))
        self.connect((self.analog_const_source_x_0_0_3_0_0, 0),
                     (self.blocks_stream_mux_2, 3))
        self.connect((self.analog_const_source_x_0_0_3_0_0_0, 0),
                     (self.blocks_stream_mux_2_0, 3))
        self.connect((self.analog_const_source_x_0_0_3_0_1, 0),
                     (self.blocks_stream_mux_2_0, 1))
        self.connect((self.analog_const_source_x_0_0_3_1, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.analog_const_source_x_0_0_3_1_0, 0),
                     (self.blocks_float_to_complex_0_0, 1))
        self.connect((self.analog_const_source_x_0_0_3_1_1, 0),
                     (self.blocks_stream_to_vector_1_0_0_1, 0))
        self.connect((self.analog_const_source_x_0_0_3_1_1_0, 0),
                     (self.blocks_stream_to_vector_1_0_0_1_0, 0))
        self.connect((self.analog_const_source_x_0_0_3_1_1_0_0, 0),
                     (self.blocks_stream_to_vector_1_0_0_1_0_0, 0))
        self.connect((self.analog_const_source_x_0_0_3_1_1_1, 0),
                     (self.blocks_stream_to_vector_1_0_0_1_1, 0))
        self.connect((self.analog_const_source_x_0_0_3_2, 0),
                     (self.blocks_stream_mux_2_0, 0))
        self.connect((self.analog_const_source_x_3, 0),
                     (self.blocks_stream_to_vector_0_1_1, 0))
        self.connect((self.analog_const_source_x_3_0, 0),
                     (self.blocks_stream_to_vector_0_1_1_0, 0))
        self.connect((self.analog_const_source_x_3_0_0, 0),
                     (self.blocks_stream_to_vector_0_1_1_1, 0))
        self.connect((self.analog_const_source_x_3_0_0_0, 0),
                     (self.blocks_stream_to_vector_0_1_1_0_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_stream_mux_2, 2))
        self.connect((self.blocks_add_const_vxx_0_0, 0),
                     (self.blocks_stream_mux_2_0, 2))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_stream_to_vector_0_0_0, 0))
        self.connect((self.blocks_conjugate_cc_0, 0),
                     (self.blocks_stream_mux_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_float_to_complex_0_0, 0),
                     (self.blocks_add_const_vxx_0_0, 0))
        self.connect((self.blocks_float_to_complex_1, 0),
                     (self.blocks_vector_to_stream_2, 0))
        self.connect((self.blocks_float_to_complex_1_0, 0),
                     (self.blocks_vector_to_stream_2_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_stream_to_vector_1_0_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_xx_2, 0),
                     (self.blocks_vector_to_stream_0_1, 0))
        self.connect((self.blocks_stream_mux_0, 0),
                     (self.blocks_stream_mux_2_1, 3))
        self.connect((self.blocks_stream_mux_1, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_stream_mux_1_0_0_0_1, 0),
                     (self.blocks_multiply_xx_2, 0))
        self.connect((self.blocks_stream_mux_1_1_0, 0),
                     (self.blocks_stream_to_streams_2, 0))
        self.connect((self.blocks_stream_mux_2, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_stream_mux_2_0, 0),
                     (self.blocks_stream_to_vector_0_0, 0))
        self.connect((self.blocks_stream_mux_2_1, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_stream_mux_3, 0),
                     (self.blocks_stream_to_vector_1_0_0_0, 0))
        self.connect((self.blocks_stream_mux_3_0, 0),
                     (self.blocks_stream_to_vector_1_0_0_0_0, 0))
        self.connect((self.blocks_stream_mux_4, 0),
                     (self.blocks_multiply_xx_2, 1))
        self.connect((self.blocks_stream_to_streams_0, 1),
                     (self.blocks_float_to_complex_1, 0))
        self.connect((self.blocks_stream_to_streams_0, 2),
                     (self.blocks_float_to_complex_1, 1))
        self.connect((self.blocks_stream_to_streams_0, 0),
                     (self.blocks_vector_to_stream_1_0, 0))
        self.connect((self.blocks_stream_to_streams_0_0, 1),
                     (self.blocks_float_to_complex_1_0, 0))
        self.connect((self.blocks_stream_to_streams_0_0, 2),
                     (self.blocks_float_to_complex_1_0, 1))
        self.connect((self.blocks_stream_to_streams_0_0, 0),
                     (self.blocks_vector_to_stream_1_0_1, 0))
        self.connect((self.blocks_stream_to_streams_0_0_0, 1),
                     (self.blocks_null_sink_1, 0))
        self.connect((self.blocks_stream_to_streams_0_0_0, 0),
                     (self.blocks_stream_mux_3, 1))
        self.connect((self.blocks_stream_to_streams_0_0_0_0, 0),
                     (self.blocks_null_sink_1_0, 0))
        self.connect((self.blocks_stream_to_streams_0_0_0_0, 1),
                     (self.blocks_stream_mux_3_0, 1))
        self.connect((self.blocks_stream_to_streams_1, 0),
                     (self.blocks_vector_to_stream_1, 0))
        self.connect((self.blocks_stream_to_streams_1, 1),
                     (self.blocks_vector_to_stream_1_1, 0))
        self.connect((self.blocks_stream_to_streams_2, 1),
                     (self.blocks_vector_to_stream_2_1, 0))
        self.connect((self.blocks_stream_to_streams_2, 0),
                     (self.blocks_vector_to_stream_2_1_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0),
                     (self.blocks_stream_mux_1, 3))
        self.connect((self.blocks_stream_to_vector_0_0, 0),
                     (self.blocks_stream_mux_1, 7))
        self.connect((self.blocks_stream_to_vector_0_0_0, 0),
                     (self.blocks_vector_to_stream_0_0, 0))
        self.connect((self.blocks_stream_to_vector_0_1_0_0, 0),
                     (self.blocks_stream_mux_1_1_0, 3))
        self.connect((self.blocks_stream_to_vector_0_1_0_0_0, 0),
                     (self.blocks_stream_mux_1_1_0, 1))
        self.connect((self.blocks_stream_to_vector_0_1_0_0_0_0, 0),
                     (self.blocks_stream_mux_1_1_0, 0))
        self.connect((self.blocks_stream_to_vector_0_1_0_0_0_0_0, 0),
                     (self.blocks_stream_mux_1_1_0, 2))
        self.connect((self.blocks_stream_to_vector_0_1_1, 0),
                     (self.blocks_stream_mux_4, 0))
        self.connect((self.blocks_stream_to_vector_0_1_1_0, 0),
                     (self.blocks_stream_mux_4, 2))
        self.connect((self.blocks_stream_to_vector_0_1_1_0_0, 0),
                     (self.blocks_stream_mux_4, 3))
        self.connect((self.blocks_stream_to_vector_0_1_1_1, 0),
                     (self.blocks_stream_mux_4, 1))
        self.connect((self.blocks_stream_to_vector_0_1_1_2, 0),
                     (self.blocks_stream_mux_1_0_0_0_1, 0))
        self.connect((self.blocks_stream_to_vector_0_1_1_2_0, 0),
                     (self.blocks_stream_mux_1_0_0_0_1, 1))
        self.connect((self.blocks_stream_to_vector_1_0_0, 0),
                     (self.blocks_stream_to_streams_1, 0))
        self.connect((self.blocks_stream_to_vector_1_0_0_0, 0),
                     (self.blocks_stream_to_streams_0, 0))
        self.connect((self.blocks_stream_to_vector_1_0_0_0_0, 0),
                     (self.blocks_stream_to_streams_0_0, 0))
        self.connect((self.blocks_stream_to_vector_1_0_0_1, 0),
                     (self.blocks_stream_mux_3, 0))
        self.connect((self.blocks_stream_to_vector_1_0_0_1_0, 0),
                     (self.blocks_stream_mux_3, 2))
        self.connect((self.blocks_stream_to_vector_1_0_0_1_0_0, 0),
                     (self.blocks_stream_mux_3_0, 2))
        self.connect((self.blocks_stream_to_vector_1_0_0_1_1, 0),
                     (self.blocks_stream_mux_3_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_uchar_to_float_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_vector_to_stream_0_0, 0),
                     (self.osmosdr_sink_0_0, 0))
        self.connect((self.blocks_vector_to_stream_0_1, 0),
                     (self.blocks_stream_mux_2_1, 1))
        self.connect((self.blocks_vector_to_stream_1, 0),
                     (self.blocks_stream_to_streams_0_0_0, 0))
        self.connect((self.blocks_vector_to_stream_1_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_vector_to_stream_1_0_1, 0),
                     (self.blocks_float_to_complex_0_0, 0))
        self.connect((self.blocks_vector_to_stream_1_1, 0),
                     (self.blocks_stream_to_streams_0_0_0_0, 0))
        self.connect((self.blocks_vector_to_stream_2, 0),
                     (self.blocks_stream_to_vector_0_1_0_0_0, 0))
        self.connect((self.blocks_vector_to_stream_2_0, 0),
                     (self.blocks_stream_to_vector_0_1_0_0, 0))
        self.connect((self.blocks_vector_to_stream_2_1, 0),
                     (self.blocks_conjugate_cc_0, 0))
        self.connect((self.blocks_vector_to_stream_2_1_0, 0),
                     (self.blocks_stream_mux_0, 0))
        self.connect((self.long_sync_pulse_0, 0),
                     (self.blocks_stream_mux_1, 1))
        self.connect((self.long_sync_pulse_0_0, 0),
                     (self.blocks_stream_mux_1, 5))
        self.connect((self.short_sync_pulse_0_3_0, 0),
                     (self.blocks_stream_mux_1, 0))
        self.connect((self.short_sync_pulse_0_3_0_0, 0),
                     (self.blocks_stream_mux_1, 2))
        self.connect((self.short_sync_pulse_0_3_0_0_0, 0),
                     (self.blocks_stream_mux_1, 6))
        self.connect((self.short_sync_pulse_0_3_0_1, 0),
                     (self.blocks_stream_mux_1, 4))
        self.connect((self.stdin, 0), (self.blocks_uchar_to_float_0, 0))
示例#37
0
def graph(args):

    nargs = len(args)
    if nargs == 2:
        infile = args[0]
        outfile = args[1]
    else:
        raise ValueError('usage: interp.py input_file output_file\n')

    tb = gr.top_block()

    # Convert to a from shorts to a stream of complex numbers.
    srcf = blocks.file_source(gr.sizeof_short, infile)
    s2ss = blocks.stream_to_streams(gr.sizeof_short, 2)
    s2f1 = blocks.short_to_float()
    s2f2 = blocks.short_to_float()
    src0 = blocks.float_to_complex()
    tb.connect(srcf, s2ss)
    tb.connect((s2ss, 0), s2f1, (src0, 0))
    tb.connect((s2ss, 1), s2f2, (src0, 1))

    # Low pass filter it and increase sample rate by a factor of 3.
    lp_coeffs = filter.firdes.low_pass(3, 19.2e6, 3.2e6, .5e6,
                                       filter.firdes.WIN_HAMMING)
    lp = filter.interp_fir_filter_ccf(3, lp_coeffs)
    tb.connect(src0, lp)

    # Upconvert it.
    duc_coeffs = filter.firdes.low_pass(1, 19.2e6, 9e6, 1e6,
                                        filter.firdes.WIN_HAMMING)
    duc = filter.freq_xlating_fir_filter_ccf(1, duc_coeffs, 5.75e6, 19.2e6)
    # Discard the imaginary component.
    c2f = blocks.complex_to_float()
    tb.connect(lp, duc, c2f)

    # Frequency Phase Lock Loop
    input_rate = 19.2e6
    IF_freq = 5.75e6
    # 1/2 as wide because we're designing lp filter
    symbol_rate = atsc.ATSC_SYMBOL_RATE / 2.
    NTAPS = 279
    tt = filter.firdes.root_raised_cosine(1.0, input_rate, symbol_rate, .115,
                                          NTAPS)
    # heterodyne the low pass coefficients up to the specified bandpass
    # center frequency.  Note that when we do this, the filter bandwidth
    # is effectively twice the low pass (2.69 * 2 = 5.38) and hence
    # matches the diagram in the ATSC spec.
    arg = 2. * math.pi * IF_freq / input_rate
    t = []
    for i in range(len(tt)):
        t += [tt[i] * 2. * math.cos(arg * i)]
    rrc = filter.fir_filter_fff(1, t)

    fpll = atsc.fpll()

    pilot_freq = IF_freq - 3e6 + 0.31e6
    lower_edge = 6e6 - 0.31e6
    upper_edge = IF_freq - 3e6 + pilot_freq
    transition_width = upper_edge - lower_edge
    lp_coeffs = filter.firdes.low_pass(1.0, input_rate,
                                       (lower_edge + upper_edge) * 0.5,
                                       transition_width,
                                       filter.firdes.WIN_HAMMING)

    lp_filter = filter.fir_filter_fff(1, lp_coeffs)

    alpha = 1e-5
    iir = filter.single_pole_iir_filter_ff(alpha)
    remove_dc = blocks.sub_ff()

    tb.connect(c2f, fpll, lp_filter)
    tb.connect(lp_filter, iir)
    tb.connect(lp_filter, (remove_dc, 0))
    tb.connect(iir, (remove_dc, 1))

    # Bit Timing Loop, Field Sync Checker and Equalizer

    btl = atsc.bit_timing_loop()
    fsc = atsc.fs_checker()
    eq = atsc.equalizer()
    fsd = atsc.field_sync_demux()

    tb.connect(remove_dc, btl)
    tb.connect((btl, 0), (fsc, 0), (eq, 0), (fsd, 0))
    tb.connect((btl, 1), (fsc, 1), (eq, 1), (fsd, 1))

    # Viterbi

    viterbi = atsc.viterbi_decoder()
    deinter = atsc.deinterleaver()
    rs_dec = atsc.rs_decoder()
    derand = atsc.derandomizer()
    depad = atsc.depad()
    dst = blocks.file_sink(gr.sizeof_char, outfile)
    tb.connect(fsd, viterbi, deinter, rs_dec, derand, depad, dst)

    dst2 = blocks.file_sink(gr.sizeof_gr_complex, "atsc_complex.data")
    tb.connect(src0, dst2)

    tb.run()
示例#38
0
文件: hfx.py 项目: UpYou/grforwarder
    def __init__(self, *args, **kwds):
        # begin wxGlade: MyFrame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)

        # Menu Bar
        self.frame_1_menubar = wx.MenuBar()
        self.SetMenuBar(self.frame_1_menubar)
        wxglade_tmp_menu = wx.Menu()
        self.Exit = wx.MenuItem(wxglade_tmp_menu, ID_EXIT, "Exit", "Exit", wx.ITEM_NORMAL)
        wxglade_tmp_menu.AppendItem(self.Exit)
        self.frame_1_menubar.Append(wxglade_tmp_menu, "File")
        # Menu Bar end
        self.panel_1 = wx.Panel(self, -1)
        self.button_1 = wx.Button(self, ID_BUTTON_1, "LSB")
        self.button_2 = wx.Button(self, ID_BUTTON_2, "USB")
        self.button_3 = wx.Button(self, ID_BUTTON_3, "AM")
        self.button_4 = wx.Button(self, ID_BUTTON_4, "CW")
        self.button_5 = wx.ToggleButton(self, ID_BUTTON_5, "Upper")
        self.slider_fcutoff_hi = wx.Slider(self, ID_SLIDER_1, 0, -15798, 15799, style=wx.SL_HORIZONTAL | wx.SL_LABELS)
        self.button_6 = wx.ToggleButton(self, ID_BUTTON_6, "Lower")
        self.slider_fcutoff_lo = wx.Slider(self, ID_SLIDER_2, 0, -15799, 15798, style=wx.SL_HORIZONTAL | wx.SL_LABELS)
        self.panel_5 = wx.Panel(self, -1)
        self.label_1 = wx.StaticText(self, -1, " Band\nCenter")
        self.text_ctrl_1 = wx.TextCtrl(self, ID_TEXT_1, "")
        self.panel_6 = wx.Panel(self, -1)
        self.panel_7 = wx.Panel(self, -1)
        self.panel_2 = wx.Panel(self, -1)
        self.button_7 = wx.ToggleButton(self, ID_BUTTON_7, "Freq")
        self.slider_3 = wx.Slider(self, ID_SLIDER_3, 3000, 0, 6000)
        self.spin_ctrl_1 = wx.SpinCtrl(self, ID_SPIN_1, "", min=0, max=100)
        self.button_8 = wx.ToggleButton(self, ID_BUTTON_8, "Vol")
        self.slider_4 = wx.Slider(self, ID_SLIDER_4, 0, 0, 500)
        self.slider_5 = wx.Slider(self, ID_SLIDER_5, 0, 0, 20)
        self.button_9 = wx.ToggleButton(self, ID_BUTTON_9, "Time")
        self.button_11 = wx.Button(self, ID_BUTTON_11, "Rew")
        self.button_10 = wx.Button(self, ID_BUTTON_10, "Fwd")
        self.panel_3 = wx.Panel(self, -1)
        self.label_2 = wx.StaticText(self, -1, "PGA               ")
        self.panel_4 = wx.Panel(self, -1)
        self.panel_8 = wx.Panel(self, -1)
        self.panel_9 = wx.Panel(self, -1)
        self.label_3 = wx.StaticText(self, -1, "AM Sync\nCarrier")
        self.slider_6 = wx.Slider(self, ID_SLIDER_6, 50, 0, 200, style=wx.SL_HORIZONTAL | wx.SL_LABELS)
        self.label_4 = wx.StaticText(self, -1, "Antenna Tune")
        self.slider_7 = wx.Slider(self, ID_SLIDER_7, 1575, 950, 2200, style=wx.SL_HORIZONTAL | wx.SL_LABELS)
        self.panel_10 = wx.Panel(self, -1)
        self.button_12 = wx.ToggleButton(self, ID_BUTTON_12, "Auto Tune")
        self.button_13 = wx.Button(self, ID_BUTTON_13, "Calibrate")
        self.button_14 = wx.Button(self, ID_BUTTON_14, "Reset")
        self.panel_11 = wx.Panel(self, -1)
        self.panel_12 = wx.Panel(self, -1)

        self.__set_properties()
        self.__do_layout()
        # end wxGlade

        parser = OptionParser(option_class=eng_option)
        parser.add_option(
            "",
            "--address",
            type="string",
            default="addr=192.168.10.2",
            help="Address of UHD device, [default=%default]",
        )
        parser.add_option(
            "-c", "--ddc-freq", type="eng_float", default=3.9e6, help="set Rx DDC frequency to FREQ", metavar="FREQ"
        )
        parser.add_option(
            "-s", "--samp-rate", type="eng_float", default=256e3, help="set sample rate (bandwidth) [default=%default]"
        )
        parser.add_option("-a", "--audio_file", default="", help="audio output file", metavar="FILE")
        parser.add_option("-r", "--radio_file", default="", help="radio output file", metavar="FILE")
        parser.add_option("-i", "--input_file", default="", help="radio input file", metavar="FILE")
        parser.add_option(
            "-O",
            "--audio-output",
            type="string",
            default="",
            help="audio output device name. E.g., hw:0,0, /dev/dsp, or pulse",
        )

        (options, args) = parser.parse_args()

        self.usrp_center = options.ddc_freq
        input_rate = options.samp_rate
        self.slider_range = input_rate * 0.9375
        self.f_lo = self.usrp_center - (self.slider_range / 2)
        self.f_hi = self.usrp_center + (self.slider_range / 2)
        self.af_sample_rate = 32000
        fir_decim = long(input_rate / self.af_sample_rate)

        # data point arrays for antenna tuner
        self.xdata = []
        self.ydata = []

        self.tb = gr.top_block()

        # radio variables, initial conditions
        self.frequency = self.usrp_center
        # these map the frequency slider (0-6000) to the actual range
        self.f_slider_offset = self.f_lo
        self.f_slider_scale = 10000
        self.spin_ctrl_1.SetRange(self.f_lo, self.f_hi)
        self.text_ctrl_1.SetValue(str(int(self.usrp_center)))
        self.slider_5.SetValue(0)
        self.AM_mode = False

        self.slider_3.SetValue((self.frequency - self.f_slider_offset) / self.f_slider_scale)
        self.spin_ctrl_1.SetValue(int(self.frequency))

        POWERMATE = True
        try:
            self.pm = powermate.powermate(self)
        except:
            sys.stderr.write("Unable to find PowerMate or Contour Shuttle\n")
            POWERMATE = False

        if POWERMATE:
            powermate.EVT_POWERMATE_ROTATE(self, self.on_rotate)
            powermate.EVT_POWERMATE_BUTTON(self, self.on_pmButton)
        self.active_button = 7

        # command line options
        if options.audio_file == "":
            SAVE_AUDIO_TO_FILE = False
        else:
            SAVE_AUDIO_TO_FILE = True
        if options.radio_file == "":
            SAVE_RADIO_TO_FILE = False
        else:
            SAVE_RADIO_TO_FILE = True
        if options.input_file == "":
            self.PLAY_FROM_USRP = True
        else:
            self.PLAY_FROM_USRP = False

        if self.PLAY_FROM_USRP:
            self.src = uhd.usrp_source(device_addr=options.address, io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1)
            self.src.set_samp_rate(input_rate)
            input_rate = self.src.get_samp_rate()

            self.src.set_center_freq(self.usrp_center, 0)
            self.tune_offset = 0

        else:
            self.src = blocks.file_source(gr.sizeof_short, options.input_file)
            self.tune_offset = 2200  # 2200 works for 3.5-4Mhz band

            # convert rf data in interleaved short int form to complex
            s2ss = blocks.stream_to_streams(gr.sizeof_short, 2)
            s2f1 = blocks.short_to_float()
            s2f2 = blocks.short_to_float()
            src_f2c = blocks.float_to_complex()
            self.tb.connect(self.src, s2ss)
            self.tb.connect((s2ss, 0), s2f1)
            self.tb.connect((s2ss, 1), s2f2)
            self.tb.connect(s2f1, (src_f2c, 0))
            self.tb.connect(s2f2, (src_f2c, 1))

        # save radio data to a file
        if SAVE_RADIO_TO_FILE:
            radio_file = blocks.file_sink(gr.sizeof_short, options.radio_file)
            self.tb.connect(self.src, radio_file)

        # 2nd DDC
        xlate_taps = filter.firdes.low_pass(1.0, input_rate, 16e3, 4e3, filter.firdes.WIN_HAMMING)
        self.xlate = filter.freq_xlating_fir_filter_ccf(fir_decim, xlate_taps, self.tune_offset, input_rate)

        # Complex Audio filter
        audio_coeffs = filter.firdes.complex_band_pass(
            1.0,  # gain
            self.af_sample_rate,  # sample rate
            -3000,  # low cutoff
            0,  # high cutoff
            100,  # transition
            filter.firdes.WIN_HAMMING,
        )  # window
        self.slider_fcutoff_hi.SetValue(0)
        self.slider_fcutoff_lo.SetValue(-3000)

        self.audio_filter = filter.fir_filter_ccc(1, audio_coeffs)

        # Main +/- 16Khz spectrum display
        self.fft = fftsink2.fft_sink_c(
            self.panel_2, fft_size=512, sample_rate=self.af_sample_rate, average=True, size=(640, 240)
        )

        # AM Sync carrier
        if AM_SYNC_DISPLAY:
            self.fft2 = fftsink.fft_sink_c(
                self.tb,
                self.panel_9,
                y_per_div=20,
                fft_size=512,
                sample_rate=self.af_sample_rate,
                average=True,
                size=(640, 240),
            )

        c2f = blocks.complex_to_float()

        # AM branch
        self.sel_am = blocks.multiply_const_cc(0)
        # the following frequencies turn out to be in radians/sample
        # analog.pll_refout_cc(alpha,beta,min_freq,max_freq)
        # suggested alpha = X, beta = .25 * X * X
        pll = analog.pll_refout_cc(
            0.5, 0.0625, (2.0 * math.pi * 7.5e3 / self.af_sample_rate), (2.0 * math.pi * 6.5e3 / self.af_sample_rate)
        )
        self.pll_carrier_scale = blocks.multiply_const_cc(complex(10, 0))
        am_det = blocks.multiply_cc()
        # these are for converting +7.5kHz to -7.5kHz
        # for some reason blocks.conjugate_cc() adds noise ??
        c2f2 = blocks.complex_to_float()
        c2f3 = blocks.complex_to_float()
        f2c = blocks.float_to_complex()
        phaser1 = blocks.multiply_const_ff(1)
        phaser2 = blocks.multiply_const_ff(-1)

        # filter for pll generated carrier
        pll_carrier_coeffs = filter.firdes.complex_band_pass(
            2.0,  # gain
            self.af_sample_rate,  # sample rate
            7400,  # low cutoff
            7600,  # high cutoff
            100,  # transition
            filter.firdes.WIN_HAMMING,
        )  # window

        self.pll_carrier_filter = filter.fir_filter_ccc(1, pll_carrier_coeffs)

        self.sel_sb = blocks.multiply_const_ff(1)
        combine = blocks.add_ff()

        # AGC
        sqr1 = blocks.multiply_ff()
        intr = filter.iir_filter_ffd([0.004, 0], [0, 0.999])
        offset = blocks.add_const_ff(1)
        agc = blocks.divide_ff()

        self.scale = blocks.multiply_const_ff(0.00001)
        dst = audio.sink(long(self.af_sample_rate), options.audio_output)

        if self.PLAY_FROM_USRP:
            self.tb.connect(self.src, self.xlate, self.fft)
        else:
            self.tb.connect(src_f2c, self.xlate, self.fft)

        self.tb.connect(self.xlate, self.audio_filter, self.sel_am, (am_det, 0))
        self.tb.connect(self.sel_am, pll, self.pll_carrier_scale, self.pll_carrier_filter, c2f3)
        self.tb.connect((c2f3, 0), phaser1, (f2c, 0))
        self.tb.connect((c2f3, 1), phaser2, (f2c, 1))
        self.tb.connect(f2c, (am_det, 1))
        self.tb.connect(am_det, c2f2, (combine, 0))
        self.tb.connect(self.audio_filter, c2f, self.sel_sb, (combine, 1))

        if AM_SYNC_DISPLAY:
            self.tb.connect(self.pll_carrier_filter, self.fft2)

        self.tb.connect(combine, self.scale)
        self.tb.connect(self.scale, (sqr1, 0))
        self.tb.connect(self.scale, (sqr1, 1))
        self.tb.connect(sqr1, intr, offset, (agc, 1))
        self.tb.connect(self.scale, (agc, 0))
        self.tb.connect(agc, dst)

        if SAVE_AUDIO_TO_FILE:
            f_out = blocks.file_sink(gr.sizeof_short, options.audio_file)
            sc1 = blocks.multiply_const_ff(64000)
            f2s1 = blocks.float_to_short()
            self.tb.connect(agc, sc1, f2s1, f_out)

        self.tb.start()

        # for mouse position reporting on fft display
        self.fft.win.Bind(wx.EVT_LEFT_UP, self.Mouse)
        # and left click to re-tune
        self.fft.win.Bind(wx.EVT_LEFT_DOWN, self.Click)

        # start a timer to check for web commands
        if WEB_CONTROL:
            self.timer = UpdateTimer(self, 1000)  # every 1000 mSec, 1 Sec

        wx.EVT_BUTTON(self, ID_BUTTON_1, self.set_lsb)
        wx.EVT_BUTTON(self, ID_BUTTON_2, self.set_usb)
        wx.EVT_BUTTON(self, ID_BUTTON_3, self.set_am)
        wx.EVT_BUTTON(self, ID_BUTTON_4, self.set_cw)
        wx.EVT_BUTTON(self, ID_BUTTON_10, self.fwd)
        wx.EVT_BUTTON(self, ID_BUTTON_11, self.rew)
        wx.EVT_BUTTON(self, ID_BUTTON_13, self.AT_calibrate)
        wx.EVT_BUTTON(self, ID_BUTTON_14, self.AT_reset)
        wx.EVT_TOGGLEBUTTON(self, ID_BUTTON_5, self.on_button)
        wx.EVT_TOGGLEBUTTON(self, ID_BUTTON_6, self.on_button)
        wx.EVT_TOGGLEBUTTON(self, ID_BUTTON_7, self.on_button)
        wx.EVT_TOGGLEBUTTON(self, ID_BUTTON_8, self.on_button)
        wx.EVT_TOGGLEBUTTON(self, ID_BUTTON_9, self.on_button)
        wx.EVT_SLIDER(self, ID_SLIDER_1, self.set_filter)
        wx.EVT_SLIDER(self, ID_SLIDER_2, self.set_filter)
        wx.EVT_SLIDER(self, ID_SLIDER_3, self.slide_tune)
        wx.EVT_SLIDER(self, ID_SLIDER_4, self.set_volume)
        wx.EVT_SLIDER(self, ID_SLIDER_5, self.set_pga)
        wx.EVT_SLIDER(self, ID_SLIDER_6, self.am_carrier)
        wx.EVT_SLIDER(self, ID_SLIDER_7, self.antenna_tune)
        wx.EVT_SPINCTRL(self, ID_SPIN_1, self.spin_tune)

        wx.EVT_MENU(self, ID_EXIT, self.TimeToQuit)
示例#39
0
def graph (args):

    nargs = len(args)
    if nargs == 2:
	infile = args[0]
        outfile = args[1]
    else:
        raise ValueError('usage: interp.py input_file output_file\n')

    tb = gr.top_block ()

    # Convert to a from shorts to a stream of complex numbers.
    srcf = blocks.file_source (gr.sizeof_short,infile)
    s2ss = blocks.stream_to_streams(gr.sizeof_short,2)
    s2f1 = blocks.short_to_float()
    s2f2 = blocks.short_to_float()
    src0 = blocks.float_to_complex()
    tb.connect(srcf, s2ss)
    tb.connect((s2ss, 0), s2f1, (src0, 0))
    tb.connect((s2ss, 1), s2f2, (src0, 1))

    # Low pass filter it and increase sample rate by a factor of 3.
    lp_coeffs = filter.firdes.low_pass ( 3, 19.2e6, 3.2e6, .5e6, filter.firdes.WIN_HAMMING )
    lp = filter.interp_fir_filter_ccf ( 3, lp_coeffs )
    tb.connect(src0, lp)

    # Upconvert it.
    duc_coeffs = filter.firdes.low_pass ( 1, 19.2e6, 9e6, 1e6, filter.firdes.WIN_HAMMING )
    duc = filter.freq_xlating_fir_filter_ccf ( 1, duc_coeffs, 5.75e6, 19.2e6 )
    # Discard the imaginary component.
    c2f = blocks.complex_to_float()
    tb.connect(lp, duc, c2f)

    # Frequency Phase Lock Loop
    input_rate = 19.2e6
    IF_freq = 5.75e6
    # 1/2 as wide because we're designing lp filter
    symbol_rate = atsc.ATSC_SYMBOL_RATE/2.
    NTAPS = 279
    tt = filter.firdes.root_raised_cosine (1.0, input_rate, symbol_rate, .115, NTAPS)
    # heterodyne the low pass coefficients up to the specified bandpass
    # center frequency.  Note that when we do this, the filter bandwidth
    # is effectively twice the low pass (2.69 * 2 = 5.38) and hence
    # matches the diagram in the ATSC spec.
    arg = 2. * math.pi * IF_freq / input_rate
    t=[]
    for i in range(len(tt)):
        t += [tt[i] * 2. * math.cos(arg * i)]
    rrc = filter.fir_filter_fff(1, t)

    fpll = atsc.fpll()

    pilot_freq = IF_freq - 3e6 + 0.31e6
    lower_edge = 6e6 - 0.31e6
    upper_edge = IF_freq - 3e6 + pilot_freq
    transition_width = upper_edge - lower_edge
    lp_coeffs = filter.firdes.low_pass(1.0,
                                       input_rate,
                                       (lower_edge + upper_edge) * 0.5,
                                       transition_width,
                                       filter.firdes.WIN_HAMMING);
    
    lp_filter = filter.fir_filter_fff(1,lp_coeffs)
    
    alpha = 1e-5
    iir = filter.single_pole_iir_filter_ff(alpha)
    remove_dc = blocks.sub_ff()

    tb.connect(c2f, fpll, lp_filter)
    tb.connect(lp_filter, iir)
    tb.connect(lp_filter, (remove_dc,0))
    tb.connect(iir, (remove_dc,1))
    
    # Bit Timing Loop, Field Sync Checker and Equalizer

    btl = atsc.bit_timing_loop()
    fsc = atsc.fs_checker()
    eq = atsc.equalizer()
    fsd = atsc.field_sync_demux()

    tb.connect(remove_dc, btl)
    tb.connect((btl, 0),(fsc, 0),(eq, 0),(fsd, 0))
    tb.connect((btl, 1),(fsc, 1),(eq, 1),(fsd, 1))

    # Viterbi

    viterbi = atsc.viterbi_decoder()
    deinter = atsc.deinterleaver()
    rs_dec = atsc.rs_decoder()
    derand = atsc.derandomizer()
    depad = atsc.depad()
    dst = blocks.file_sink(gr.sizeof_char, outfile)
    tb.connect(fsd, viterbi, deinter, rs_dec, derand, depad, dst)

    dst2 = blocks.file_sink(gr.sizeof_gr_complex, "atsc_complex.data")
    tb.connect(src0, dst2)

    tb.run ()
示例#40
0
    def __init__(self, puncpat='11'):
        gr.top_block.__init__(self, "Rx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Rx")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

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

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.samp_rate_array_MCR = samp_rate_array_MCR = [
            7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000,
            1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052,
            400000, 380952
        ]
        self.nfilts = nfilts = 32
        self.eb = eb = 0.22
        self.H_dec = H_dec = fec.ldpc_H_matrix(
            '/usr/local/share/gnuradio/fec/ldpc/n_1100_k_0442_gap_24.alist',
            24)
        self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 28
        self.variable_qtgui_range_0_0_0_0 = variable_qtgui_range_0_0_0_0 = 0
        self.variable_qtgui_range_0_0_0 = variable_qtgui_range_0_0_0 = 0
        self.variable_qtgui_range_0_0 = variable_qtgui_range_0_0 = 53
        self.variable_qtgui_check_box_0 = variable_qtgui_check_box_0 = True
        self.samp_rate = samp_rate = samp_rate_array_MCR[7]

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

        self.pld_dec = pld_dec = map((lambda a: fec.ldpc_bit_flip_decoder.make(
            H_dec.get_base_sptr(), 50)), range(0, 8))
        self.pld_const = pld_const = digital.constellation_rect(([
            0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j
        ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.pld_const.gen_soft_dec_lut(8)
        self.frequencia_usrp = frequencia_usrp = 484e6
        self.MCR = MCR = "master_clock_rate=60e6"

        ##################################################
        # Blocks
        ##################################################
        self._variable_qtgui_range_0_1_range = Range(0, 73, 1, 28, 200)
        self._variable_qtgui_range_0_1_win = RangeWidget(
            self._variable_qtgui_range_0_1_range,
            self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider",
            float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_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._variable_qtgui_range_0_0_range = Range(0, 90, 1, 53, 200)
        self._variable_qtgui_range_0_0_win = RangeWidget(
            self._variable_qtgui_range_0_0_range,
            self.set_variable_qtgui_range_0_0, 'Gain_Jamming',
            "counter_slider", float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_win, 0,
                                       3, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        _variable_qtgui_check_box_0_check_box = Qt.QCheckBox('ENABLE JAM')
        self._variable_qtgui_check_box_0_choices = {True: True, False: False}
        self._variable_qtgui_check_box_0_choices_inv = dict(
            (v, k)
            for k, v in self._variable_qtgui_check_box_0_choices.iteritems())
        self._variable_qtgui_check_box_0_callback = lambda i: Qt.QMetaObject.invokeMethod(
            _variable_qtgui_check_box_0_check_box, "setChecked",
            Qt.Q_ARG("bool", self._variable_qtgui_check_box_0_choices_inv[i]))
        self._variable_qtgui_check_box_0_callback(
            self.variable_qtgui_check_box_0)
        _variable_qtgui_check_box_0_check_box.stateChanged.connect(
            lambda i: self.set_variable_qtgui_check_box_0(
                self._variable_qtgui_check_box_0_choices[bool(i)]))
        self.top_grid_layout.addWidget(_variable_qtgui_check_box_0_check_box,
                                       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._variable_qtgui_range_0_0_0_0_range = Range(0, 1000, 1, 0, 200)
        self._variable_qtgui_range_0_0_0_0_win = RangeWidget(
            self._variable_qtgui_range_0_0_0_0_range,
            self.set_variable_qtgui_range_0_0_0_0, 'Delay2', "counter_slider",
            int)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_0_0_win,
                                       3, 3, 1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._variable_qtgui_range_0_0_0_range = Range(0, 5000, 1, 0, 200)
        self._variable_qtgui_range_0_0_0_win = RangeWidget(
            self._variable_qtgui_range_0_0_0_range,
            self.set_variable_qtgui_range_0_0_0, 'Delay', "counter_slider",
            int)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_0_win, 3,
                                       1, 1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.uhd_usrp_source_0_0 = uhd.usrp_source(
            ",".join(("serial=F5EAC0", MCR)),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_source_0_0.set_center_freq(frequencia_usrp, 0)
        self.uhd_usrp_source_0_0.set_gain(variable_qtgui_range_0_1, 0)
        self.uhd_usrp_source_0_0.set_antenna('TX/RX', 0)
        self.uhd_usrp_source_0_0.set_auto_dc_offset(True, 0)
        self.uhd_usrp_source_0_0.set_auto_iq_balance(True, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("serial=F5EAC0", MCR)),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_subdev_spec('A:B', 0)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_sink_0.set_center_freq(frequencia_usrp, 0)
        self.uhd_usrp_sink_0.set_gain(variable_qtgui_range_0_0, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.qtgui_time_sink_x_2 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "Write Buffer",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_2.set_update_time(0.10)
        self.qtgui_time_sink_x_2.set_y_axis(0, 1.5)

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

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

        if not True:
            self.qtgui_time_sink_x_2.disable_legend()

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

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

        self._qtgui_time_sink_x_2_win = sip.wrapinstance(
            self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_win, 2, 3, 1,
                                       1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_1_0_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "TX JAMMING USRP",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_1_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):
            if len(labels[i]) == 0:
                if (i % 2 == 0):
                    self.qtgui_time_sink_x_1_0_0.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_1_0_0.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            else:
                self.qtgui_time_sink_x_1_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_0_win, 1, 1,
                                       1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_1_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "RX USRP",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_1_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        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:
                if (i % 2 == 0):
                    self.qtgui_time_sink_x_1_0.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_1_0.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            else:
                self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i])

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

        if not True:
            self.qtgui_freq_sink_x_1.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_1.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_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i])

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

        if not True:
            self.qtgui_const_sink_x_0_0_0_1.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_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0_0_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_0_1_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_win, 2,
                                       1, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c(
            1024,  #size
            "RX Treated",  #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 True:
            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.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_win, 2,
                                       2, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.interp_fir_filter_xxx_1 = filter.interp_fir_filter_ccc(
            4, ([1, 0, 0, 0]))
        self.interp_fir_filter_xxx_1.declare_sample_delay(0)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, 6.28 / 100.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 1)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(
            pld_const.arity())
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(
            6.28 / 100.0, pld_const.arity(), False)
        self.digital_correlate_access_code_xx_ts_0_0 = digital.correlate_access_code_bb_ts(
            digital.packet_utils.default_access_code, 4, 'packet_len')
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            pld_const)
        self.custom_corr = correlate_and_delay.corr_and_delay(
            200 * sps, 0, 0.999, sps)
        self.blocks_stream_to_streams_0 = blocks.stream_to_streams(
            gr.sizeof_float * 1, 2)
        self.blocks_stream_mux_1_0 = blocks.stream_mux(gr.sizeof_float * 1,
                                                       (1, 1))
        self.blocks_stream_mux_1 = blocks.stream_mux(gr.sizeof_float * 1,
                                                     (1, 1))
        self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(
            1, 8, '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            pld_const.bits_per_symbol(), 1, '', False, gr.GR_MSB_FIRST)
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vcc((0.5, ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_sink_0_0_0_0_2_0 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/andre/Desktop/Trasmited/buffer.txt',
            False)
        self.blocks_file_sink_0_0_0_0_2_0.set_unbuffered(False)
        self.blocks_copy_0 = blocks.copy(gr.sizeof_gr_complex * 1)
        self.blocks_copy_0.set_enabled(variable_qtgui_check_box_0)
        self.blocks_complex_to_float_0_0 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.analog_noise_source_x_0_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1, -5)
        self.adapt_lms_filter_xx_0 = adapt.lms_filter_ff(
            True, 32, 0.0001, 0, 1, True, False, False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.adapt_lms_filter_xx_0, 0),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.adapt_lms_filter_xx_0, 1),
                     (self.blocks_stream_to_streams_0, 0))
        self.connect((self.analog_noise_source_x_0_0, 0),
                     (self.interp_fir_filter_xxx_1, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.qtgui_time_sink_x_2, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_stream_mux_1, 1))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_stream_mux_1, 0))
        self.connect((self.blocks_complex_to_float_0_0, 1),
                     (self.blocks_stream_mux_1_0, 1))
        self.connect((self.blocks_complex_to_float_0_0, 0),
                     (self.blocks_stream_mux_1_0, 0))
        self.connect((self.blocks_copy_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.blocks_copy_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.custom_corr, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.qtgui_time_sink_x_1_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.digital_correlate_access_code_xx_ts_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0),
                     (self.blocks_file_sink_0_0_0_0_2_0, 0))
        self.connect((self.blocks_stream_mux_1, 0),
                     (self.adapt_lms_filter_xx_0, 1))
        self.connect((self.blocks_stream_mux_1_0, 0),
                     (self.adapt_lms_filter_xx_0, 0))
        self.connect((self.blocks_stream_to_streams_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_stream_to_streams_0, 1),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.custom_corr, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.custom_corr, 1),
                     (self.blocks_complex_to_float_0_0, 0))
        self.connect((self.custom_corr, 2), (self.blocks_null_sink_1, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_correlate_access_code_xx_ts_0_0, 0),
                     (self.blocks_repack_bits_bb_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.qtgui_const_sink_x_0_0_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_costas_loop_cc_0_0, 0))
        self.connect((self.interp_fir_filter_xxx_1, 0),
                     (self.blocks_multiply_const_vxx_1_0, 0))
        self.connect((self.uhd_usrp_source_0_0, 0), (self.custom_corr, 1))
        self.connect((self.uhd_usrp_source_0_0, 0),
                     (self.qtgui_const_sink_x_0_0_0_1, 0))
        self.connect((self.uhd_usrp_source_0_0, 0),
                     (self.qtgui_time_sink_x_1_0, 0))