def xtest_fff_004(self):
        random.seed(0)
        for i in xrange(25):
            sys.stderr.write("\n>>> Loop = %d\n" % (i,))
            src_len = 4096
            src_data = make_random_float_tuple(src_len)
            ntaps = int(random.uniform(2, 1000))
            taps = make_random_float_tuple(ntaps)
            expected_result = reference_filter_fff(1, taps, src_data)

            src = blocks.vector_source_f(src_data)
            op = filter.fft_filter_fff(1, taps)
            dst = blocks.vector_sink_f()
    	    tb = gr.top_block()
            tb.connect(src, op, dst)
            tb.run()
            result_data = dst.data()

            #print "src_len =", src_len, " ntaps =", ntaps
            try:
                self.assert_fft_float_ok2(expected_result, result_data, abs_eps=1.0)
            except:
                expected = open('expected', 'w')
                for x in expected_result:
                    expected.write(`x` + '\n')
                actual = open('actual', 'w')
                for x in result_data:
                    actual.write(`x` + '\n')
                raise
Beispiel #2
0
    def xtest_fff_004(self):
        random.seed(0)
        for i in range(25):
            sys.stderr.write("\n>>> Loop = %d\n" % (i,))
            src_len = 4096
            src_data = make_random_float_tuple(src_len)
            ntaps = int(random.uniform(2, 1000))
            taps = make_random_float_tuple(ntaps)
            expected_result = reference_filter_fff(1, taps, src_data)

            src = blocks.vector_source_f(src_data)
            op = filter.fft_filter_fff(1, taps)
            dst = blocks.vector_sink_f()
            tb = gr.top_block()
            tb.connect(src, op, dst)
            tb.run()
            result_data = dst.data()

            #print "src_len =", src_len, " ntaps =", ntaps
            try:
                self.assert_fft_float_ok2(expected_result, result_data, abs_eps=1.0)
            except AssertionError:
                expected = open('expected', 'w')
                for x in expected_result:
                    expected.write(repr(x) + '\n')
                actual = open('actual', 'w')
                for x in result_data:
                    actual.write(repr(x) + '\n')
                raise
def test_fft_filter_fff():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_float)
    firfilter = filter.fft_filter_fff(1, [random.random() for _ in range(128)])
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, firfilter, probe)

    return top, probe
Beispiel #4
0
def test_fft_filter_fff():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_float)
    firfilter = filter.fft_filter_fff(1, [random.random() for _ in range(128)])
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, firfilter, probe)

    return top, probe
Beispiel #5
0
    def test_fff_get0(self):
        random.seed(0)
        for i in range(25):
            ntaps = int(random.uniform(2, 100))
            taps = make_random_float_tuple(ntaps)

            op = filter.fft_filter_fff(1, taps)
            result_data = op.taps()
            #print result_data

            self.assertEqual(taps, result_data)
    def test_fff_get0(self):
        random.seed(0)
        for i in xrange(25):
            ntaps = int(random.uniform(2, 100))
            taps = make_random_float_tuple(ntaps)

            op = filter.fft_filter_fff(1, taps)
            result_data = op.taps()
            #print result_data

            self.assertEqual(taps, result_data)
 def test_fff_002(self):
     tb = gr.top_block()
     src_data = (0,1,2,3,4,5,6,7)
     taps = (2,)
     expected_result = tuple([2 * float(x) for x in (0,1,2,3,4,5,6,7)])
     src = blocks.vector_source_f(src_data)
     op = filter.fft_filter_fff(1, taps)
     dst = blocks.vector_sink_f()
     tb.connect(src, op, dst)
     tb.run()
     result_data = dst.data()
     #print 'expected:', expected_result
     #print 'results: ', result_data
     self.assertFloatTuplesAlmostEqual (expected_result, result_data, 5)
 def test_fff_003(self):
     # Test 02 with nthreads
     tb = gr.top_block()
     src_data = (0,1,2,3,4,5,6,7)
     taps = (2,)
     nthreads = 2
     expected_result = tuple([2 * float(x) for x in (0,1,2,3,4,5,6,7)])
     src = blocks.vector_source_f(src_data)
     op = filter.fft_filter_fff(1, taps, nthreads)
     dst = blocks.vector_sink_f()
     tb.connect(src, op, dst)
     tb.run()
     result_data = dst.data()
     self.assertFloatTuplesAlmostEqual (expected_result, result_data, 5)
Beispiel #9
0
 def test_fff_002(self):
     tb = gr.top_block()
     src_data = (0,1,2,3,4,5,6,7)
     taps = (2,)
     expected_result = tuple([2 * float(x) for x in (0,1,2,3,4,5,6,7)])
     src = blocks.vector_source_f(src_data)
     op = filter.fft_filter_fff(1, taps)
     dst = blocks.vector_sink_f()
     tb.connect(src, op, dst)
     tb.run()
     result_data = dst.data()
     #print 'expected:', expected_result
     #print 'results: ', result_data
     self.assertFloatTuplesAlmostEqual (expected_result, result_data, 5)
Beispiel #10
0
 def test_fff_003(self):
     # Test 02 with nthreads
     tb = gr.top_block()
     src_data = (0,1,2,3,4,5,6,7)
     taps = (2,)
     nthreads = 2
     expected_result = tuple([2 * float(x) for x in (0,1,2,3,4,5,6,7)])
     src = blocks.vector_source_f(src_data)
     op = filter.fft_filter_fff(1, taps, nthreads)
     dst = blocks.vector_sink_f()
     tb.connect(src, op, dst)
     tb.run()
     result_data = dst.data()
     self.assertFloatTuplesAlmostEqual (expected_result, result_data, 5)
Beispiel #11
0
    def __init__(self, nstages, ntaps=256):
        """
        Create a pipeline of nstages of filter.fir_filter_fff's connected in serial
        terminating in a blocks.null_sink.
        """
        gr.hier_block2.__init__(self, "pipeline",
                                gr.io_signature(1, 1, gr.sizeof_float),
                                gr.io_signature(0, 0, 0))
        taps = ntaps*[1.0/ntaps]
        upstream = self
        for i in range(nstages):
            op = filter.fft_filter_fff(1, taps)
            self.connect(upstream, op)
            upstream = op

        self.connect(upstream, blocks.null_sink(gr.sizeof_float))
Beispiel #12
0
    def __init__(self, rfgain=30.0):
        gr.top_block.__init__(self, "APRS I-Gate")

        ##################################################
        # Parameters
        ##################################################
        self.rfgain = rfgain

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1.2e6

        ##################################################
        # Blocks
        ##################################################
        self.igate_aprs_pkt_gen_0_0_1_0_0 = igate.aprs_pkt_gen(3600, 'YD1SDL-10', 'APGRC', 'WIDE2-2', 240, 3, ':BLNA     :New Digi YB2YOU-1 at Mt. Merapi is now in full operational')
        self.igate_aprs_pkt_gen_0_0 = igate.aprs_pkt_gen(180, 'YD1SDL-10', 'APGRC', 'WIDE2-2', 240, 3, '>Automated message generator : OFF')
        self.igate_aprs_pkt_gen_0 = igate.aprs_pkt_gen(180, 'YD1SDL-10', 'APGRC', 'WIDE2-2', 240, 3, '!0745.80S/11022.51E`PHG5130/GNU Radio APRS I-gate - ver 0')
        self.igate_aprs_is_sink_0 = igate.aprs_is_sink('rotate.aprs2.net', 14580, 'YD1SDL-10', 24505)
        self.igate_aprs_demod_0 = igate.aprs_demod(48000)
        self.fft_filter_xxx_3 = filter.fft_filter_fff(1, (firdes.band_pass(1,48e3,1e3,2400,1e2,firdes.WIN_HAMMING)), 1)
        self.fft_filter_xxx_3.declare_sample_delay(0)
        self.blocks_null_sink_2 = blocks.null_sink(gr.sizeof_float*1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.RTL_APRS_RX_0 = RTL_APRS_RX(
            device_ppm=58,
            freq=144.39e6,
            rf_gain=rfgain,
            samp_rate=samp_rate,
            squelch=-60,
        )

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.igate_aprs_demod_0, 'out'), (self.igate_aprs_is_sink_0, 'in'))    
        self.msg_connect((self.igate_aprs_pkt_gen_0, 'out'), (self.igate_aprs_is_sink_0, 'in'))    
        self.msg_connect((self.igate_aprs_pkt_gen_0_0, 'out'), (self.igate_aprs_is_sink_0, 'in'))    
        self.msg_connect((self.igate_aprs_pkt_gen_0_0_1_0_0, 'out'), (self.igate_aprs_is_sink_0, 'in'))    
        self.connect((self.RTL_APRS_RX_0, 0), (self.blocks_null_sink_0, 0))    
        self.connect((self.RTL_APRS_RX_0, 1), (self.fft_filter_xxx_3, 0))    
        self.connect((self.fft_filter_xxx_3, 0), (self.blocks_null_sink_2, 0))    
        self.connect((self.fft_filter_xxx_3, 0), (self.igate_aprs_demod_0, 0))    
Beispiel #13
0
    def xtest_fff_005(self):
        random.seed(0)
        for i in range(25):
            sys.stderr.write("\n>>> Loop = %d\n" % (i,))
            src_len = 4*1024
            src_data = make_random_float_tuple(src_len)
            ntaps = int(random.uniform(2, 1000))
            taps = make_random_float_tuple(ntaps)
            expected_result = reference_filter_fff(1, taps, src_data)

            src = blocks.vector_source_f(src_data)
            op = filter.fft_filter_fff(1, taps)
            dst = blocks.vector_sink_f()
            tb = gr.top_block()
            tb.connect(src, op, dst)
            tb.run()
            result_data = dst.data()

            self.assert_fft_float_ok2(expected_result, result_data, abs_eps=2.0)
Beispiel #14
0
    def xtest_fff_005(self):
        random.seed(0)
        for i in xrange(25):
            sys.stderr.write("\n>>> Loop = %d\n" % (i,))
            src_len = 4*1024
            src_data = make_random_float_tuple(src_len)
            ntaps = int(random.uniform(2, 1000))
            taps = make_random_float_tuple(ntaps)
            expected_result = reference_filter_fff(1, taps, src_data)

            src = blocks.vector_source_f(src_data)
            op = filter.fft_filter_fff(1, taps)
            dst = blocks.vector_sink_f()
    	    tb = gr.top_block()
            tb.connect(src, op, dst)
            tb.run()
            result_data = dst.data()

            self.assert_fft_float_ok2(expected_result, result_data, abs_eps=2.0)
Beispiel #15
0
    def __init__(self, options, log=False):

        ## Read configuration
        config = station_configuration()

        fft_length = config.fft_length
        cp_length = config.cp_length
        block_header = config.training_data
        data_subc = config.data_subcarriers
        virtual_subc = config.virtual_subcarriers
        total_subc = config.subcarriers
        block_length = config.block_length
        frame_length = config.frame_length
        dc_null = config.dc_null

        L = block_header.mm_periodic_parts

        ## Set Input/Output signature
        gr.hier_block2.__init__(
            self,
            "ofdm_inner_receiver",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
            gr.io_signaturev(
                4,
                4,
                [
                    gr.sizeof_gr_complex * total_subc,  # OFDM blocks
                    gr.sizeof_char,  # Frame start
                    gr.sizeof_float * total_subc,
                    gr.sizeof_float
                ]))  # Normalized |CTF|^2

        ## Input and output ports
        self.input = rx_input = self

        out_ofdm_blocks = (self, 0)
        out_frame_start = (self, 1)
        out_disp_ctf = (self, 2)
        out_disp_cfo = (self, 3)

        ## pre-FFT processing
        if options.ideal is False and options.ideal2 is False:
            if options.old_receiver is False:
                ## Compute autocorrelations for S&C preamble
                ## and cyclic prefix

                self._sc_metric = sc_metric = autocorrelator(
                    fft_length / 2, fft_length / 2)
                self._gi_metric = gi_metric = autocorrelator(
                    fft_length, cp_length)

                self.connect(rx_input, sc_metric)
                self.connect(rx_input, gi_metric)

                ## Sync. Output contains OFDM blocks
                sync = ofdm.time_sync(fft_length, cp_length)
                self.connect(rx_input, (sync, 0))
                self.connect(sc_metric, (sync, 1))
                self.connect(gi_metric, (sync, 2))
                ofdm_blocks = (sync, 0)
                frame_start = (sync, 1)
                #log_to_file( self, ( sync, 1 ), "data/peak_detector.char" )
            else:

                #Testing old/new metric
                self.tm = schmidl.recursive_timing_metric(fft_length)
                self.connect(self.input, self.tm)
                #log_to_file( self, self.tm, "data/rec_sc_metric_ofdm.float" )

                timingmetric_shift = -2  #int(-cp_length/4)# 0#-2 #int(-cp_length * 0.8)
                tmfilter = filter.fft_filter_fff(1,
                                                 [1. / cp_length] * cp_length)
                self.connect(self.tm, tmfilter)
                self.tm = tmfilter

                self._pd_thres = 0.3
                self._pd_lookahead = fft_length / 2  # empirically chosen
                peak_detector = ofdm.peak_detector_02_fb(
                    self._pd_lookahead, self._pd_thres)
                self.connect(self.tm, peak_detector)
                #log_to_file( self, peak_detector, "data/rec_peak_detector.char" )

                frame_start = [0] * frame_length
                frame_start[0] = 1
                frame_start = self.frame_trigger_old = blocks.vector_source_b(
                    frame_start, True)

                delayed_timesync = blocks.delay(
                    gr.sizeof_char,
                    (frame_length - 1) * block_length + timingmetric_shift)
                self.connect(peak_detector, delayed_timesync)

                self.block_sampler = ofdm.vector_sampler(
                    gr.sizeof_gr_complex, block_length * frame_length)
                self.discard_cp = ofdm.vector_mask(block_length, cp_length,
                                                   fft_length, [])

                self.connect(self.input, self.block_sampler)
                self.connect(delayed_timesync, (self.block_sampler, 1))

                # TODO: dynamic solution
                vt2s = blocks.vector_to_stream(
                    gr.sizeof_gr_complex * block_length, frame_length)
                self.connect(self.block_sampler, vt2s, self.discard_cp)
                #terminate_stream(self,ofdm_blocks)
                ofdm_blocks = self.discard_cp
#     else:
#       serial_to_parallel = blocks.stream_to_vector(gr.sizeof_gr_complex,block_length)
#       discard_cp = ofdm.vector_mask(block_length,cp_length,fft_length,[])
#       ofdm_blocks = discard_cp
#       self.connect( rx_input, serial_to_parallel, discard_cp )
#       frame_start = [0]*frame_length
#       frame_start[0] = 1
#       frame_start = blocks.vector_source_b(frame_start,True)
#
#       print "Disabled time synchronization stage"

## Compute autocorrelations for S&C preamble
## and cyclic prefix

#log_to_file( self, sc_metric, "data/sc_metric_ofdm.float" )
#log_to_file(self, frame_start, "data/frame_start.compl")

#    log_to_file(self,ofdm_blocks,"data/ofdm_blocks_original.compl")

        if options.disable_time_sync or options.ideal or options.ideal2:
            if options.ideal is False and options.ideal2 is False:
                terminate_stream(self, ofdm_blocks)
                terminate_stream(self, frame_start)

            serial_to_parallel = blocks.stream_to_vector(
                gr.sizeof_gr_complex, block_length)
            discard_cp = ofdm.vector_mask_dc_null(block_length, cp_length,
                                                  fft_length, dc_null, [])
            ofdm_blocks = discard_cp
            self.connect(rx_input, serial_to_parallel, discard_cp)

            frame_start = [0] * frame_length
            frame_start[0] = 1
            frame_start = blocks.vector_source_b(frame_start, True)

            print "Disabled time synchronization stage"

        print "\t\t\t\t\tframe_length = ", frame_length

        if options.ideal is False and options.ideal2 is False:
            ## Extract preamble, feed to Morelli & Mengali frequency offset estimator
            assert (block_header.mm_preamble_pos == 0)
            morelli_foe = ofdm.mm_frequency_estimator(fft_length, L, 1, 0)
            sampler_preamble = ofdm.vector_sampler(
                gr.sizeof_gr_complex * fft_length, 1)
            self.connect(ofdm_blocks, (sampler_preamble, 0))
            self.connect(frame_start, (sampler_preamble, 1))
            self.connect(sampler_preamble, morelli_foe)
            freq_offset = morelli_foe

            ## Adaptive LMS FIR filtering of frequency offset
            lms_fir = ofdm.lms_fir_ff(20,
                                      1e-3)  # TODO: verify parameter choice
            self.connect(freq_offset, lms_fir)
            freq_offset = lms_fir

            #self.zmq_probe_freqoff = zeromq.pub_sink(gr.sizeof_float, 1, "tcp://*:5557")
            self.connect(lms_fir, blocks.keep_one_in_n(gr.sizeof_float, 20),
                         out_disp_cfo)
        else:
            self.connect(blocks.vector_source_f([1]), out_disp_cfo)

            #log_to_file(self, lms_fir, "data/lms_fir.float")

        if options.disable_freq_sync or options.ideal or options.ideal2:
            if options.ideal is False and options.ideal2 is False:
                terminate_stream(self, freq_offset)
                freq_offset = blocks.vector_source_f([0.0], True)
            print "Disabled frequency synchronization stage"

        if options.ideal is False and options.ideal2 is False:
            ## Correct frequency shift, feed-forward structure
            frequency_shift = ofdm.frequency_shift_vcc(fft_length,
                                                       -1.0 / fft_length,
                                                       cp_length)
            self.connect(ofdm_blocks, (frequency_shift, 0))
            self.connect(freq_offset, (frequency_shift, 1))
            self.connect(frame_start, (frequency_shift, 2))
            ofdm_blocks = frequency_shift

        ## FFT
        fft = fft_blocks.fft_vcc(fft_length, True, [], True)
        self.connect(ofdm_blocks, fft)
        ofdm_blocks = fft
        #log_to_file( self, fft, "data/compen.float" )

        ## Remove virtual subcarriers
        if fft_length > data_subc:
            subcarrier_mask = ofdm.vector_mask_dc_null(fft_length,
                                                       virtual_subc / 2,
                                                       total_subc, dc_null, [])
            self.connect(ofdm_blocks, subcarrier_mask)
            ofdm_blocks = subcarrier_mask
            #log_to_file(self, ofdm_blocks, "data/vec_mask.compl")
            ## Least Squares estimator for channel transfer function (CTF)

            if options.logcir:
                log_to_file(self, ofdm_blocks, "data/OFDM_Blocks.compl")

                inv_preamble_fd = numpy.array(block_header.pilotsym_fd[
                    block_header.channel_estimation_pilot[0]])
                inv_preamble_fd = numpy.concatenate([
                    inv_preamble_fd[:total_subc / 2],
                    inv_preamble_fd[total_subc / 2 + dc_null:]
                ])
                #print "Channel estimation pilot: ", inv_preamble_fd
                inv_preamble_fd = 1. / inv_preamble_fd
                LS_channel_estimator0 = ofdm.multiply_const_vcc(
                    list(inv_preamble_fd))
                self.connect(ofdm_blocks, LS_channel_estimator0,
                             gr.null_sink(gr.sizeof_gr_complex * total_subc))
                log_to_file(self, LS_channel_estimator0,
                            "data/OFDM_Blocks_eq.compl")

        ## post-FFT processing

        ## extract channel estimation preamble from frame
        if options.ideal is False and options.ideal2 is False:
            chest_pre_trigger = blocks.delay(gr.sizeof_char, 1)
            sampled_chest_preamble = ofdm.vector_sampler(
                gr.sizeof_gr_complex * total_subc, 1)
            self.connect(frame_start, chest_pre_trigger)
            self.connect(chest_pre_trigger, (sampled_chest_preamble, 1))
            self.connect(ofdm_blocks, (sampled_chest_preamble, 0))

            ## Least Squares estimator for channel transfer function (CTF)
            inv_preamble_fd = numpy.array(block_header.pilotsym_fd[
                block_header.channel_estimation_pilot[0]])
            inv_preamble_fd = numpy.concatenate([
                inv_preamble_fd[:total_subc / 2],
                inv_preamble_fd[total_subc / 2 + dc_null:]
            ])
            #print "Channel estimation pilot: ", inv_preamble_fd
            inv_preamble_fd = 1. / inv_preamble_fd

            LS_channel_estimator = ofdm.multiply_const_vcc(
                list(inv_preamble_fd))
            self.connect(sampled_chest_preamble, LS_channel_estimator)
            estimated_CTF = LS_channel_estimator

            if options.logcir:
                log_to_file(self, sampled_chest_preamble, "data/PREAM.compl")

            if not options.disable_ctf_enhancer:

                if options.logcir:
                    ifft1 = fft_blocks.fft_vcc(total_subc, False, [], True)
                    self.connect(
                        estimated_CTF, ifft1,
                        gr.null_sink(gr.sizeof_gr_complex * total_subc))
                    summ1 = ofdm.vector_sum_vcc(total_subc)
                    c2m = gr.complex_to_mag(total_subc)
                    self.connect(estimated_CTF, summ1,
                                 gr.null_sink(gr.sizeof_gr_complex))
                    self.connect(estimated_CTF, c2m,
                                 gr.null_sink(gr.sizeof_float * total_subc))
                    log_to_file(self, ifft1, "data/CIR1.compl")
                    log_to_file(self, summ1, "data/CTFsumm1.compl")
                    log_to_file(self, estimated_CTF, "data/CTF1.compl")
                    log_to_file(self, c2m, "data/CTFmag1.float")

                ## MSE enhancer
                ctf_mse_enhancer = ofdm.CTF_MSE_enhancer(
                    total_subc, cp_length + cp_length)
                self.connect(estimated_CTF, ctf_mse_enhancer)
                #      log_to_file( self, ctf_mse_enhancer, "data/ctf_mse_enhancer_original.compl")
                #ifft3 = fft_blocks.fft_vcc(total_subc,False,[],True)
                #null_noise = ofdm.noise_nulling(total_subc, cp_length + cp_length)
                #ctf_mse_enhancer = fft_blocks.fft_vcc(total_subc,True,[],True)
                #ctf_mse_enhancer = ofdm.vector_mask( fft_length, virtual_subc/2,
                # total_subc, [] )
                #self.connect( estimated_CTF, ifft3,null_noise,ctf_mse_enhancer )

                estimated_CTF = ctf_mse_enhancer
                print "Disabled CTF MSE enhancer"

            if options.logcir:
                ifft2 = fft_blocks.fft_vcc(total_subc, False, [], True)
                self.connect(estimated_CTF, ifft2,
                             gr.null_sink(gr.sizeof_gr_complex * total_subc))
                summ2 = ofdm.vector_sum_vcc(total_subc)
                c2m2 = gr.complex_to_mag(total_subc)
                self.connect(estimated_CTF, summ2,
                             gr.null_sink(gr.sizeof_gr_complex))
                self.connect(estimated_CTF, c2m2,
                             gr.null_sink(gr.sizeof_float * total_subc))
                log_to_file(self, ifft2, "data/CIR2.compl")
                log_to_file(self, summ2, "data/CTFsumm2.compl")
                log_to_file(self, estimated_CTF, "data/CTF2.compl")
                log_to_file(self, c2m2, "data/CTFmag2.float")

        ## Postprocess the CTF estimate
        ## CTF -> inverse CTF (for equalizer)
        ## CTF -> norm |.|^2 (for CTF display)
            ctf_postprocess = ofdm.postprocess_CTF_estimate(total_subc)
            self.connect(estimated_CTF, ctf_postprocess)
            inv_estimated_CTF = (ctf_postprocess, 0)
            disp_CTF = (ctf_postprocess, 1)


#     if options.disable_equalization or options.ideal:
#       terminate_stream(self, inv_estimated_CTF)
#       inv_estimated_CTF_vec = blocks.vector_source_c([1.0/fft_length*math.sqrt(total_subc)]*total_subc,True,total_subc)
#       inv_estimated_CTF_str = blocks.vector_to_stream(gr.sizeof_gr_complex, total_subc)
#       self.inv_estimated_CTF_mul = ofdm.multiply_const_ccf( 1.0/config.rms_amplitude )
#       #inv_estimated_CTF_mul.set_k(1.0/config.rms_amplitude)
#       inv_estimated_CTF = blocks.stream_to_vector(gr.sizeof_gr_complex, total_subc)
#       self.connect( inv_estimated_CTF_vec, inv_estimated_CTF_str, self.inv_estimated_CTF_mul, inv_estimated_CTF)
#       print "Disabled equalization stage"
        '''
    ## LMS Phase tracking
    ## Track residual frequency offset and sampling clock frequency offset

    nondata_blocks = []
    for i in range(config.frame_length):
      if i in config.training_data.pilotsym_pos:
        nondata_blocks.append(i)
        
    print"\t\t\t\t\tnondata_blocks=",nondata_blocks
    pilot_subc = block_header.pilot_tones
    pilot_subcarriers = block_header.pilot_subc_sym
    print "PILOT SUBCARRIERS: ", pilot_subcarriers
        
    phase_tracking = ofdm.lms_phase_tracking_03( total_subc, pilot_subc,
                                               nondata_blocks, pilot_subcarriers,0 )
    self.connect( ofdm_blocks, ( phase_tracking, 0 ) )
    self.connect( inv_estimated_CTF, ( phase_tracking, 1 ) )
    self.connect( frame_start, ( phase_tracking, 2 ) ) ##
    
    if options.scatter_plot_before_phase_tracking:
      self.before_phase_tracking = equalizer
      
    
    if options.disable_phase_tracking or options.ideal:
      terminate_stream(self, phase_tracking)
      print "Disabled phase tracking stage"
    else:
      ofdm_blocks = phase_tracking
    '''
        ## Channel Equalizer
        if options.disable_equalization or options.ideal or options.ideal2:
            print "Disabled equalization stage"
            if options.ideal is False and options.ideal2 is False:
                terminate_stream(self, inv_estimated_CTF)
        else:
            equalizer = ofdm.channel_equalizer(total_subc)
            self.connect(ofdm_blocks, (equalizer, 0))
            self.connect(inv_estimated_CTF, (equalizer, 1))
            self.connect(frame_start, (equalizer, 2))
            ofdm_blocks = equalizer
        #log_to_file(self, equalizer,"data/equalizer_siso.compl")

        #log_to_file(self, ofdm_blocks, "data/equalizer.compl")

        ## LMS Phase tracking
        ## Track residual frequency offset and sampling clock frequency offset
        if options.ideal is False and options.ideal2 is False:
            nondata_blocks = []
            for i in range(config.frame_length):
                if i in config.training_data.pilotsym_pos:
                    nondata_blocks.append(i)

            print "\t\t\t\t\tnondata_blocks=", nondata_blocks
            pilot_subc = block_header.pilot_tones
            pilot_subcarriers = block_header.pilot_subc_sym
            print "PILOT SUBCARRIERS: ", pilot_subcarriers

            phase_tracking2 = ofdm.lms_phase_tracking_dc_null(
                total_subc, pilot_subc, nondata_blocks, pilot_subcarriers,
                dc_null)
            self.connect(ofdm_blocks, (phase_tracking2, 0))
            self.connect(frame_start, (phase_tracking2, 1))  ##

        if options.disable_phase_tracking or options.ideal or options.ideal2:
            if options.ideal is False and options.ideal2 is False:
                terminate_stream(self, phase_tracking2)
            print "Disabled phase tracking stage"
        else:
            ofdm_blocks = phase_tracking2

        if options.scatter_plot_before_phase_tracking:
            self.before_phase_tracking = equalizer

        ## Output connections

        self.connect(ofdm_blocks, out_ofdm_blocks)
        self.connect(frame_start, out_frame_start)
        if options.ideal is False and options.ideal2 is False:
            self.connect(disp_CTF, out_disp_ctf)
        else:
            self.connect(blocks.vector_source_f([1.0] * total_subc),
                         blocks.stream_to_vector(gr.sizeof_float, total_subc),
                         out_disp_ctf)

        if log:
            log_to_file(self, sc_metric, "data/sc_metric.float")
            log_to_file(self, gi_metric, "data/gi_metric.float")
            log_to_file(self, morelli_foe, "data/morelli_foe.float")
            log_to_file(self, lms_fir, "data/lms_fir.float")
            log_to_file(self, sampler_preamble, "data/preamble.compl")
            log_to_file(self, sync, "data/sync.compl")
            log_to_file(self, frequency_shift, "data/frequency_shift.compl")
            log_to_file(self, fft, "data/fft.compl")
            log_to_file(self, fft, "data/fft.float", mag=True)

            if vars().has_key('subcarrier_mask'):
                log_to_file(self, subcarrier_mask,
                            "data/subcarrier_mask.compl")

            log_to_file(self, ofdm_blocks, "data/ofdm_blocks_out.compl")
            log_to_file(self,
                        frame_start,
                        "data/frame_start.float",
                        char_to_float=True)

            log_to_file(self, sampled_chest_preamble,
                        "data/sampled_chest_preamble.compl")
            log_to_file(self, LS_channel_estimator,
                        "data/ls_channel_estimator.compl")
            log_to_file(self,
                        LS_channel_estimator,
                        "data/ls_channel_estimator.float",
                        mag=True)

            if "ctf_mse_enhancer" in locals():
                log_to_file(self, ctf_mse_enhancer,
                            "data/ctf_mse_enhancer.compl")
                log_to_file(self,
                            ctf_mse_enhancer,
                            "data/ctf_mse_enhancer.float",
                            mag=True)

            log_to_file(self, (ctf_postprocess, 0),
                        "data/inc_estimated_ctf.compl")
            log_to_file(self, (ctf_postprocess, 1), "data/disp_ctf.float")

            log_to_file(self, equalizer, "data/equalizer.compl")
            log_to_file(self, equalizer, "data/equalizer.float", mag=True)

            log_to_file(self, phase_tracking, "data/phase_tracking.compl")
Beispiel #16
0
    def __init__(self, fft_length, cp_length, logging=False):
        """
        OFDM synchronization using PN Correlation:
        T. M. Schmidl and D. C. Cox, "Robust Frequency and Timing
        Synchonization for OFDM," IEEE Trans. Communications, vol. 45,
        no. 12, 1997.
        """

        gr.hier_block2.__init__(
            self,
            "ofdm_sync_pn",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),  # Input signature
            gr.io_signature2(2, 2, gr.sizeof_float,
                             gr.sizeof_char))  # Output signature

        self.input = blocks.add_const_cc(0)

        # PN Sync

        # Create a delay line
        self.delay = blocks.delay(gr.sizeof_gr_complex, fft_length / 2)

        # Correlation from ML Sync
        self.conjg = blocks.conjugate_cc()
        self.corr = blocks.multiply_cc()

        # Create a moving sum filter for the corr output
        if 1:
            moving_sum_taps = [1.0 for i in range(fft_length // 2)]
            self.moving_sum_filter = filter.fir_filter_ccf(1, moving_sum_taps)
        else:
            moving_sum_taps = [
                complex(1.0, 0.0) for i in range(fft_length // 2)
            ]
            self.moving_sum_filter = filter.fft_filter_ccc(1, moving_sum_taps)

        # Create a moving sum filter for the input
        self.inputmag2 = blocks.complex_to_mag_squared()
        movingsum2_taps = [1.0 for i in range(fft_length // 2)]

        if 1:
            self.inputmovingsum = filter.fir_filter_fff(1, movingsum2_taps)
        else:
            self.inputmovingsum = filter.fft_filter_fff(1, movingsum2_taps)

        self.square = blocks.multiply_ff()
        self.normalize = blocks.divide_ff()

        # Get magnitude (peaks) and angle (phase/freq error)
        self.c2mag = blocks.complex_to_mag_squared()
        self.angle = blocks.complex_to_arg()

        self.sample_and_hold = blocks.sample_and_hold_ff()

        #ML measurements input to sampler block and detect
        self.sub1 = blocks.add_const_ff(-1)
        self.pk_detect = blocks.peak_detector_fb(0.20, 0.20, 30, 0.001)
        #self.pk_detect = blocks.peak_detector2_fb(9)

        self.connect(self, self.input)

        # Calculate the frequency offset from the correlation of the preamble
        self.connect(self.input, self.delay)
        self.connect(self.input, (self.corr, 0))
        self.connect(self.delay, self.conjg)
        self.connect(self.conjg, (self.corr, 1))
        self.connect(self.corr, self.moving_sum_filter)
        self.connect(self.moving_sum_filter, self.c2mag)
        self.connect(self.moving_sum_filter, self.angle)
        self.connect(self.angle, (self.sample_and_hold, 0))

        # Get the power of the input signal to normalize the output of the correlation
        self.connect(self.input, self.inputmag2, self.inputmovingsum)
        self.connect(self.inputmovingsum, (self.square, 0))
        self.connect(self.inputmovingsum, (self.square, 1))
        self.connect(self.square, (self.normalize, 1))
        self.connect(self.c2mag, (self.normalize, 0))

        # Create a moving sum filter for the corr output
        matched_filter_taps = [1.0 / cp_length for i in range(cp_length)]
        self.matched_filter = filter.fir_filter_fff(1, matched_filter_taps)
        self.connect(self.normalize, self.matched_filter)

        self.connect(self.matched_filter, self.sub1, self.pk_detect)
        #self.connect(self.matched_filter, self.pk_detect)
        self.connect(self.pk_detect, (self.sample_and_hold, 1))

        # Set output signals
        #    Output 0: fine frequency correction value
        #    Output 1: timing signal
        self.connect(self.sample_and_hold, (self, 0))
        self.connect(self.pk_detect, (self, 1))

        if logging:
            self.connect(
                self.matched_filter,
                blocks.file_sink(gr.sizeof_float, "ofdm_sync_pn-mf_f.dat"))
            self.connect(
                self.normalize,
                blocks.file_sink(gr.sizeof_float, "ofdm_sync_pn-theta_f.dat"))
            self.connect(
                self.angle,
                blocks.file_sink(gr.sizeof_float,
                                 "ofdm_sync_pn-epsilon_f.dat"))
            self.connect(
                self.pk_detect,
                blocks.file_sink(gr.sizeof_char, "ofdm_sync_pn-peaks_b.dat"))
            self.connect(
                self.sample_and_hold,
                blocks.file_sink(gr.sizeof_float,
                                 "ofdm_sync_pn-sample_and_hold_f.dat"))
            self.connect(
                self.input,
                blocks.file_sink(gr.sizeof_gr_complex,
                                 "ofdm_sync_pn-input_c.dat"))
Beispiel #17
0
    def __init__(self):
        gr.top_block.__init__(self, "Tlm Rec")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Tlm Rec")
        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", "tlm_rec")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.audio_rate = audio_rate = 48e3
        self.sps = sps = int(audio_rate / 1200)
        self.samp_rate = samp_rate = 300e3
        self.mm_sps = mm_sps = 2
        self.gain_mu = gain_mu = 0.9

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=int(audio_rate),
            decimation=int(samp_rate),
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f(
            8192,  #size
            24000,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0_0_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "magenta", "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_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_0_win)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            1024,  #size
            1200,  #samp_rate
            "",  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)

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

        self.qtgui_time_sink_x_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                    qtgui.TRIG_SLOPE_POS, 0.0,
                                                    0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0_0.enable_grid(True)
        self.qtgui_time_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0.enable_control_panel(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", "magenta", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [2, 2, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [0, 0, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

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

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win)
        self.fsk_demod_0 = fsk_demod(
            baud=1200,
            fsk_hi_tone=2300,
            fsk_lo_tone=1200,
            in_sps=sps,
            out_sps=mm_sps,
        )
        self.fft_filter_xxx_1 = filter.fft_filter_fff(1, (firdes.band_pass(
            0.2, audio_rate, 900, 2500, 500, firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_1.declare_sample_delay(0)
        self.fft_filter_xxx_0 = filter.fft_filter_ccc(
            1, (firdes.low_pass(1, samp_rate, audio_rate / 2, audio_rate / 4,
                                firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            mm_sps * (1 + 0.0), 0.25 * gain_mu * gain_mu, 0.5, gain_mu, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=4e-6,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=(1.0 + 1.0j, ),
            noise_seed=0,
            block_tags=False)
        self.blocks_rotator_cc_0 = blocks.rotator_cc(-(-16.2e3 / samp_rate) *
                                                     2 * math.pi)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            '/home/handiko/gqrx_20180319_072938_433268400_300000_fc.raw',
            False)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            audio_rate / (2 * math.pi * 24e3 / 8.0))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.fft_filter_xxx_1, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.qtgui_time_sink_x_0_0, 1))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_rotator_cc_0, 0))
        self.connect((self.blocks_rotator_cc_0, 0), (self.fft_filter_xxx_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.fft_filter_xxx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.fft_filter_xxx_1, 0), (self.audio_sink_0, 0))
        self.connect((self.fft_filter_xxx_1, 0), (self.fsk_demod_0, 0))
        self.connect((self.fsk_demod_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.fsk_demod_0, 0), (self.qtgui_time_sink_x_0_0_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.channels_channel_model_0, 0))
Beispiel #18
0
    def __init__(self):
        gr.top_block.__init__(self, "APRS I-Gate")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("APRS I-Gate")
        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", "aprs_minigate")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1.2e6
        self.rfgain = rfgain = 8.0

        ##################################################
        # Blocks
        ##################################################
        self._rfgain_range = Range(0.0, 49.0, 1.0, 8.0, 200)
        self._rfgain_win = RangeWidget(self._rfgain_range, self.set_rfgain,
                                       'RF Gain (dB)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._rfgain_win, 1, 0, 1, 2)
        self.show_text_0 = display.show_text()
        self._show_text_0_win = sip.wrapinstance(self.show_text_0.pyqwidget(),
                                                 Qt.QWidget)
        self.top_grid_layout.addWidget(self._show_text_0_win, 2, 0, 1, 2)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            144.39e6,  #fc
            192e3,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-120, -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(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0.enable_axis_labels(False)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 1,
                                       1)
        self.igate_debug_print_msg_0 = igate.debug_print_msg()
        self.igate_aprs_pkt_gen_0_0 = igate.aprs_pkt_gen(
            300, 'YD1SDL-10', 'APGRC', 'WIDE2-2', 240, 3,
            '>Non Permanent - Experimental')
        self.igate_aprs_pkt_gen_0 = igate.aprs_pkt_gen(
            120, 'YD1SDL-10', 'APGRC', 'WIDE2-2', 240, 3,
            '!0615.32S/10643.36E`PHG5130/GNU Radio APRS I-gate - ver 0')
        self.igate_aprs_is_sink_0 = igate.aprs_is_sink('rotate.aprs.net',
                                                       14580, 'YD1SDL-10',
                                                       24505)
        self.igate_aprs_demod_0 = igate.aprs_demod(48000)
        self.fft_filter_xxx_3 = filter.fft_filter_fff(1, (firdes.band_pass(
            10, 48e3, 1e3, 2600, 1e2, firdes.WIN_HAMMING)), 1)
        self.fft_filter_xxx_3.declare_sample_delay(0)
        self.afsk_aprs2inet_1 = afsk.aprs2inet(48000, 4)
        self.RTL_APRS_RX_0 = RTL_APRS_RX(
            device_ppm=58,
            freq=144.39e6,
            rf_gain=rfgain,
            samp_rate=samp_rate,
            squelch=-60,
        )
        self.DL1KSV_AFSK_1200baud_demod_0 = DL1KSV_AFSK_1200baud_demod(
            samp_rate=48000, )

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.igate_aprs_demod_0, 'out'),
                         (self.igate_aprs_is_sink_0, 'in'))
        self.msg_connect((self.igate_aprs_demod_0, 'out'),
                         (self.igate_debug_print_msg_0, 'in'))
        self.msg_connect((self.igate_aprs_pkt_gen_0, 'out'),
                         (self.igate_aprs_is_sink_0, 'in'))
        self.msg_connect((self.igate_aprs_pkt_gen_0, 'out'),
                         (self.igate_debug_print_msg_0, 'in'))
        self.msg_connect((self.igate_aprs_pkt_gen_0_0, 'out'),
                         (self.igate_aprs_is_sink_0, 'in'))
        self.msg_connect((self.igate_aprs_pkt_gen_0_0, 'out'),
                         (self.igate_debug_print_msg_0, 'in'))
        self.connect((self.DL1KSV_AFSK_1200baud_demod_0, 0),
                     (self.afsk_aprs2inet_1, 0))
        self.connect((self.RTL_APRS_RX_0, 1), (self.fft_filter_xxx_3, 0))
        self.connect((self.RTL_APRS_RX_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.afsk_aprs2inet_1, 0), (self.show_text_0, 0))
        self.connect((self.fft_filter_xxx_3, 0),
                     (self.DL1KSV_AFSK_1200baud_demod_0, 0))
        self.connect((self.fft_filter_xxx_3, 0), (self.igate_aprs_demod_0, 0))
Beispiel #19
0
    def __init__(self):
        gr.top_block.__init__(self, "APRS - With RTL-SDR dongle")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("APRS - With RTL-SDR dongle")
        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", "APRS_RX_RTL")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2.4e6
        self.space = space = 2400
        self.rfgain = rfgain = 25
        self.mu = mu = 0.5
        self.mark = mark = 1200
        self.gmu = gmu = 0.175
        self.freq = freq = 144.39e6 - samp_rate / 4
        self.dev_ppm = dev_ppm = 58
        self.ch_rate = ch_rate = 48e3
        self.bb_rate = bb_rate = 192e3
        self.baud = baud = 1200
        self.afgain = afgain = -7

        ##################################################
        # Blocks
        ##################################################
        self._rfgain_range = Range(0, 49, 1, 25, 100)
        self._rfgain_win = RangeWidget(self._rfgain_range, self.set_rfgain,
                                       'RF Gain (dB)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._rfgain_win, 2, 0, 1, 1)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=8000,
            decimation=int(ch_rate),
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            4096 / 2,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            192e3,  #bw
            'RF Spectrum',  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not False:
            self.qtgui_waterfall_sink_x_0.disable_legend()

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

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

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-105, -20)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 0,
                                       2, 1, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            256,  #size
            1200,  #samp_rate
            'Clock Recovery',  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-2.1, 2.1)

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

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

        if not False:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 1, 0, 1,
                                       2)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_f(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            8e3,  #bw
            'AF Spectrum',  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_0.set_y_axis(-80, 20)
        self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0.enable_grid(True)
        self.qtgui_freq_sink_x_0_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 1, 2,
                                       2, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            144.39e6,  #fc
            192e3,  #bw
            'RF Spectrum',  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-120, -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(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 1,
                                       2)
        self.pfb_decimator_ccf_0_0 = pfb.decimator_ccf(
            int(samp_rate / ch_rate), (), 0, 100, True, True)
        self.pfb_decimator_ccf_0_0.declare_sample_delay(0)

        self.pfb_decimator_ccf_0 = pfb.decimator_ccf(int(samp_rate / bb_rate),
                                                     (), 0, 100, True, True)
        self.pfb_decimator_ccf_0.declare_sample_delay(0)

        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               '')
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(dev_ppm, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(rfgain, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.fft_filter_xxx_1 = filter.fft_filter_fff(1, (firdes.band_pass(
            1, ch_rate, 400, 5e3, 400, firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_1.declare_sample_delay(0)
        self.epy_block_0 = epy_block_0.blk()
        self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", '', '52001',
                                                     10000, False)
        self.blocks_rotator_cc_0 = blocks.rotator_cc(-math.pi / 2)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            ch_rate / (2 * math.pi * 12e3 / 8.0))
        self._afgain_range = Range(-20, -1, 0.1, -7, 100)
        self._afgain_win = RangeWidget(self._afgain_range, self.set_afgain,
                                       'AF Gain (dB)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._afgain_win, 2, 1, 1, 1)
        self.APRS_Rx_0 = APRS_Rx(
            samp_rate=ch_rate,
            baud=baud,
            mark=mark,
            space=space,
            mu=mu,
            gmu=gmu,
        )

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.APRS_Rx_0, 'HDLC'),
                         (self.epy_block_0, 'hdlc in'))
        self.msg_connect((self.epy_block_0, 'ax25 out'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.epy_block_0, 'ax25 out'),
                         (self.blocks_socket_pdu_0, 'pdus'))
        self.connect((self.APRS_Rx_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.fft_filter_xxx_1, 0))
        self.connect((self.blocks_rotator_cc_0, 0),
                     (self.pfb_decimator_ccf_0, 0))
        self.connect((self.blocks_rotator_cc_0, 0),
                     (self.pfb_decimator_ccf_0_0, 0))
        self.connect((self.fft_filter_xxx_1, 0), (self.APRS_Rx_0, 0))
        self.connect((self.fft_filter_xxx_1, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.blocks_rotator_cc_0, 0))
        self.connect((self.pfb_decimator_ccf_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.pfb_decimator_ccf_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.pfb_decimator_ccf_0_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0_0, 0))
Beispiel #20
0
    def __init__(self):
        gr.top_block.__init__(self, "Aprs Rx Test")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Aprs Rx Test")
        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", "aprs_rx_test")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 48e3
        self.sps = sps = int(samp_rate / 1200)
        self.gain_mu = gain_mu = 0.175

        ##################################################
        # Blocks
        ##################################################
        self.show_text_0 = display.show_text()
        self._show_text_0_win = sip.wrapinstance(self.show_text_0.pyqwidget(),
                                                 Qt.QWidget)
        self.top_grid_layout.addWidget(self._show_text_0_win, 2, 0, 1, 2)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            2048,  #size
            1024,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(True)
        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(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.fsk_demod_0 = fsk_demod(
            baud=1200,
            fsk_hi_tone=2200,
            fsk_lo_tone=1200,
            in_sps=sps,
            out_sps=2,
        )
        self.fft_filter_xxx_0 = filter.fft_filter_fff(1, (firdes.band_pass(
            1, samp_rate, 1000, 2400, 300, firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.epy_block_0 = epy_block_0.blk()
        self.digital_hdlc_deframer_bp_0_0 = digital.hdlc_deframer_bp(32, 500)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            2 * (1 + 0.0), 0.25 * gain_mu * gain_mu, 0.5, gain_mu, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            '/home/handiko/aprs_test.wav', True)
        self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')
        self.blocks_not_xx_0 = blocks.not_bb()
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.1, ))
        self.blocks_and_const_xx_0 = blocks.and_const_bb(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.audio_sink_0 = audio.sink(int(samp_rate), '', True)
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_f(
            analog.GR_UNIFORM, 0.1, 0, 8192)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.digital_hdlc_deframer_bp_0_0, 'out'),
                         (self.epy_block_0, 'hdlc in'))
        self.msg_connect((self.epy_block_0, 'ax25 out'),
                         (self.blocks_pdu_to_tagged_stream_1, 'pdus'))
        self.connect((self.analog_fastnoise_source_x_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.fft_filter_xxx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.fsk_demod_0, 0))
        self.connect((self.blocks_and_const_xx_0, 0),
                     (self.digital_hdlc_deframer_bp_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_not_xx_0, 0),
                     (self.blocks_and_const_xx_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_1, 0),
                     (self.show_text_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_not_xx_0, 0))
        self.connect((self.fft_filter_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.fsk_demod_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
Beispiel #21
0
  def __init__( self, options, log = False ):
    
    ## Read configuration
    config = station_configuration()
    
    fft_length    = config.fft_length
    #cp_length     = config.cp_length
    block_header  = config.training_data
    data_subc     = config.data_subcarriers
    virtual_subc  = config.virtual_subcarriers
    total_subc    = config.subcarriers
    block_length  = config.block_length
    frame_length  = config.frame_length
    
    L             = block_header.mm_periodic_parts
    
        
    cp_length     = config.cp_length


    
    print "data_subc: ", config.data_subcarriers
    print "total_subc: ", config.subcarriers
    print "frame_lengthframe_length: ", frame_length
    
    
    ## Set Input/Output signature
    gr.hier_block2.__init__( self, 
        "fbmc_inner_receiver",
        gr.io_signature(
            1, 1,
            gr.sizeof_gr_complex ),
        gr.io_signaturev(
            4, 4,
            [gr.sizeof_float * total_subc,    # Normalized |CTF|^2 
            gr.sizeof_char,                       # Frame start
            gr.sizeof_gr_complex * total_subc, # OFDM blocks, SNR est
            gr.sizeof_float] ) )      # CFO
    
    
    ## Input and output ports
    self.input = rx_input = self
    
    out_ofdm_blocks = ( self, 2 )
    out_frame_start = ( self, 1 )
    out_disp_ctf    = ( self, 0 )
    out_disp_cfo    = ( self, 3 )
    #out_snr_pream    = ( self, 3 )
    
    
    
    
    ## pre-FFT processing
    
    '''
    ## Compute autocorrelations for S&C preamble
    ## and cyclic prefix
    
    self._sc_metric = sc_metric = autocorrelator( fft_length/2, fft_length/2 )
    self._gi_metric = gi_metric = autocorrelator( fft_length, cp_length )
    
    self.connect( rx_input, sc_metric )
    self.connect( rx_input, gi_metric )
    terminate_stream(self, gi_metric)
    
    ## Sync. Output contains OFDM blocks
    sync = ofdm.time_sync( fft_length/2, 1)
    self.connect( rx_input, ( sync, 0 ) )
    self.connect( sc_metric, ( sync, 1 ) )
    self.connect( sc_metric, ( sync, 2 ) )
    
    ofdm_blocks = ( sync, 0 )
    frame_start = ( sync, 1 )
    log_to_file( self, ( sync, 1 ), "data/fbmc_peak_detector.char" )
    '''
    if options.ideal is False and options.ideal2 is False:
        #Testing old/new metric
        self.tm = schmidl.recursive_timing_metric(2*fft_length)
        self.connect( self.input, self.tm)
        #log_to_file( self, self.tm, "data/fbmc_rec_sc_metric_ofdm.float" )
        
        timingmetric_shift = 0 #-2 #int(-cp_length * 0.8)
        tmfilter = filter.fft_filter_fff(1, [2./fft_length]*(fft_length/2))# ofdm.lms_fir_ff( fft_length, 1e-3 ) #; filter.fir_filter_fff(1, [1./fft_length]*fft_length)
        self.connect( self.tm, tmfilter )
        self.tm = tmfilter
        #log_to_file( self, self.tm, "data/fbmc_rec_sc_metric_ofdm2.float" )
        
        self._pd_thres = 0.6
        self._pd_lookahead = fft_length # empirically chosen
        peak_detector = ofdm.peak_detector_02_fb(self._pd_lookahead, self._pd_thres)
        self.connect(self.tm, peak_detector)
        #log_to_file( self, peak_detector, "data/fbmc_rec_peak_detector.char" )
        
        
        #frame_start = [0]*frame_length
        #frame_start[0] = 1
        #frame_start = blocks.vector_source_b(frame_start,True)
        
        #OLD
        #delayed_timesync = blocks.delay(gr.sizeof_char,
         #                           (frame_length-10)*fft_length/2 - fft_length/4 -1 + timingmetric_shift)
        delayed_timesync = blocks.delay(gr.sizeof_char,
                                    (frame_length-10)*fft_length/2 - fft_length/4  + int(2.5*fft_length)  + timingmetric_shift-1)
        #delayed_timesync = blocks.delay(gr.sizeof_char,
                                    #(frame_length-10)*fft_length/2 - fft_length/4 + int(3.5*fft_length)  + timingmetric_shift-1)
        self.connect( peak_detector, delayed_timesync )
        
        self.block_sampler = ofdm.vector_sampler(gr.sizeof_gr_complex,fft_length/2*frame_length)
        
        self.connect(self.input,self.block_sampler)
        self.connect(delayed_timesync,(self.block_sampler,1))
        #log_to_file( self, self.block_sampler, "data/fbmc_block_sampler.compl" )
        
        vt2s = blocks.vector_to_stream(gr.sizeof_gr_complex*fft_length,
                                                frame_length/2)
        self.connect(self.block_sampler,vt2s)
        #terminate_stream(self,ofdm_blocks)
        
        ofdm_blocks = vt2s
        
        '''
        # TODO: dynamic solution
        vt2s = blocks.vector_to_stream(gr.sizeof_gr_complex*block_length/2,
                                                frame_length)
        self.connect(self.block_sampler,vt2s)
        terminate_stream(self,( sync, 0 ))
        ofdm_blocks = vt2s
        '''
        
        
        
        
        
        ##stv_help = blocks.stream_to_vector(gr.sizeof_gr_complex*config.fft_length/2, 1)
        #stv_help = blocks.vector_to_stream(gr.sizeof_gr_complex*config.fft_length/2, 2)
       ##self.connect(ofdm_blocks, stv_help)
        ##ofdm_blocks = stv_help
        #ofdm_blocks = ( sync, 0 )
        #frame_start = ( sync, 1 )
        #log_to_file(self, frame_start, "data/frame_start.compl")
        
        #log_to_file( self, sc_metric, "data/sc_metric.float" )
        #log_to_file( self, gi_metric, "data/gi_metric.float" )
        #log_to_file( self, (sync,1), "data/sync.float" )
        
    #    log_to_file(self,ofdm_blocks,"data/ofdm_blocks_original.compl")
        frame_start = [0]*int(frame_length/2)
        frame_start[0] = 1
        frame_start = blocks.vector_source_b(frame_start,True)          
        
        #frame_start2 = [0]*int(frame_length/2)
        #frame_start2[0] = 1
        #frame_start2 = blocks.vector_source_b(frame_start2,True)
    
    if options.disable_time_sync or options.ideal or options.ideal2:
      if options.ideal is False and options.ideal2 is False:
        terminate_stream(self, ofdm_blocks)
        terminate_stream(self, frame_start)
      
      serial_to_parallel = blocks.stream_to_vector(gr.sizeof_gr_complex,fft_length)
      #discard_cp = ofdm.vector_mask(block_length,cp_length,fft_length,[])
      #serial_to_parallel = blocks.stream_to_vector(gr.sizeof_gr_complex,block_length)
      #discard_cp = ofdm.vector_mask(block_length,cp_length,fft_length,[])
      #self.connect( rx_input,serial_to_parallel)
      
      #self.connect( rx_input, blocks.delay(gr.sizeof_gr_complex,0),serial_to_parallel)
      initial_skip = blocks.skiphead(gr.sizeof_gr_complex,2*fft_length)
      self.connect( rx_input, initial_skip)
      if options.ideal is False and options.ideal2 is False:          
          self.connect(  initial_skip, serial_to_parallel)
          ofdm_blocks = serial_to_parallel
      else:
          ofdm_blocks = initial_skip
      #self.connect( rx_input, serial_to_parallel, discard_cp )
      
      frame_start = [0]*int(frame_length/2)
      frame_start[0] = 1
      frame_start = blocks.vector_source_b(frame_start,True)
      
      #frame_start2 = [0]*int(frame_length/2)
      #frame_start2[0] = 1
      #frame_start2 = blocks.vector_source_b(frame_start2,True)
      
      print "Disabled time synchronization stage"
    
    print"\t\t\t\t\tframe_length = ",frame_length
    
    if options.ideal is False and options.ideal2 is False:
        ## Extract preamble, feed to Morelli & Mengali frequency offset estimator
        assert( block_header.mm_preamble_pos == 0 )
        morelli_foe = ofdm.mm_frequency_estimator( fft_length, 2, 1, config.fbmc )
        sampler_preamble = ofdm.vector_sampler( gr.sizeof_gr_complex * fft_length,
                                                1 )
        self.connect( ofdm_blocks, ( sampler_preamble, 0 ) )
        self.connect( frame_start, blocks.delay( gr.sizeof_char, 1 ), ( sampler_preamble, 1 ) )
        self.connect( sampler_preamble, morelli_foe )
        freq_offset = morelli_foe
        print "FRAME_LENGTH: ", frame_length
        #log_to_file( self, sampler_preamble, "data/sampler_preamble.compl" )
        #log_to_file( self, rx_input, "data/rx_input.compl" )
        #log_to_file( self, ofdm_blocks, "data/rx_input.compl" )

        
        #Extracting preamble for SNR estimation
        #fft_snr_est = fft_blocks.fft_vcc( fft_length, True, [], True )
        #self.connect( sampler_preamble, blocks.stream_to_vector(gr.sizeof_gr_complex*fft_length/2, 2),  fft_snr_est )
        
        
        ## Remove virtual subcarriers
        #if fft_length > data_subc:
          #subcarrier_mask_snr_est = ofdm.vector_mask( fft_length, virtual_subc/2,
                        #                       total_subc, [] )
          #self.connect( fft_snr_est, subcarrier_mask_snr_est )
          #fft_snr_est = subcarrier_mask_snr_est
          #log_to_file(self, ofdm_blocks, "data/vec_mask.compl")
           ## Least Squares estimator for channel transfer function (CTF)
        
        #self.connect( fft_snr_est, out_snr_pream ) # Connecting to output
        
        ## Adaptive LMS FIR filtering of frequency offset
        lms_fir = ofdm.lms_fir_ff( 20, 1e-3 ) # TODO: verify parameter choice
        self.connect( freq_offset, lms_fir )
        freq_offset = lms_fir
        
        self.connect(freq_offset, blocks.keep_one_in_n(gr.sizeof_float,20) ,out_disp_cfo)
    else:
        self.connect(blocks.vector_source_f ([1]) ,out_disp_cfo)

    
    #log_to_file(self, lms_fir, "data/lms_fir.float")
    
    if options.disable_freq_sync or options.ideal or options.ideal2:
      if options.ideal is False and options.ideal2 is False:  
          terminate_stream(self, freq_offset)
          freq_offset = blocks.vector_source_f([0.0],True)
      print "Disabled frequency synchronization stage"
    
    if options.ideal is False and options.ideal2 is False:
        ## Correct frequency shift, feed-forward structure
        frequency_shift = ofdm.frequency_shift_vcc( fft_length, -1.0/fft_length,
                                                    0)
        
        #freq_shift = blocks.multiply_cc()
        #norm_freq = -0.1 / config.fft_length
        #freq_off = self.freq_off_src = analog.sig_source_c(1.0, analog.GR_SIN_WAVE, norm_freq, 1.0, 0.0 )
        
        self.connect( ofdm_blocks, ( frequency_shift, 0 ) )
        self.connect( freq_offset, ( frequency_shift, 1 ) )
        self.connect( frame_start,blocks.delay( gr.sizeof_char, 0), ( frequency_shift, 2 ) )
        
        

        
        #self.connect(frequency_shift,s2help)
        #ofdm_blocks = s2help
        ofdm_blocks = frequency_shift
    #terminate_stream(self, frequency_shift)
    
    
    
    #inner_pb_filt = self._inner_pilot_block_filter = fbmc_inner_pilot_block_filter()
    #self.connect(ofdm_blocks,inner_pb_filt)
    #self.connect(frame_start,(inner_pb_filt,1))
    #self.connect((inner_pb_filt,1),blocks.null_sink(gr.sizeof_char))
    
    #ofdm_blocks = (inner_pb_filt,0)
    
    
    overlap_ser_to_par = ofdm.fbmc_overlapping_serial_to_parallel_cvc(fft_length)
    self.separate_vcvc = ofdm.fbmc_separate_vcvc(fft_length, 2)
    self.polyphase_network_vcvc_1 = ofdm.fbmc_polyphase_network_vcvc(fft_length, 4, 4*fft_length-1, True)
    self.polyphase_network_vcvc_2 = ofdm.fbmc_polyphase_network_vcvc(fft_length, 4, 4*fft_length-1, True)
    self.junction_vcvc = ofdm.fbmc_junction_vcvc(fft_length, 2)
    self.fft_fbmc = fft_blocks.fft_vcc(fft_length, True, [], True)
    
    print "config.training_data.fbmc_no_preambles: ", config.training_data.fbmc_no_preambles
    #center_preamble = [1, -1j, -1, 1j]
    
    #self.preamble = preamble = [0]*total_subc + center_preamble*((int)(total_subc/len(center_preamble)))+[0]*total_subc
    
    self.preamble = preamble = config.training_data.fbmc_pilotsym_fd_list
    #inv_preamble = 1. / numpy.array(self.preamble)
    #print "self.preamble: ", len(self.preamble
    #print "inv_preamble: ", list(inv_preamble)
    
    #print "self.preamble", self.preamble
    #print "self.preamble2", self.preamble2
    
    
    self.multiply_const= ofdm.multiply_const_vcc(([1.0/(math.sqrt(fft_length*0.6863))]*total_subc))    
    self.beta_multiplier_vcvc = ofdm.fbmc_beta_multiplier_vcvc(total_subc, 4, 4*fft_length-1, 0)
    #self.skiphead = blocks.skiphead(gr.sizeof_gr_complex*total_subc, 2*4-1-1)
    self.skiphead = blocks.skiphead(gr.sizeof_gr_complex*total_subc,2)
    self.skiphead_1 = blocks.skiphead(gr.sizeof_gr_complex*total_subc, 0)
    #self.remove_preamble_vcvc = ofdm.fbmc_remove_preamble_vcvc(total_subc, config.frame_data_part/2, config.training_data.fbmc_no_preambles*total_subc/2)
    #self.subchannel_processing_vcvc = ofdm.fbmc_subchannel_processing_vcvc(total_subc, config.frame_data_part, 1, 2, 1, 0)
    self.oqam_postprocessing_vcvc = ofdm.fbmc_oqam_postprocessing_vcvc(total_subc, 0, 0)
    
    #log_to_file( self, ofdm_blocks, "data/PRE_FBMC.compl" )
    #log_to_file( self, self.fft_fbmc, "data/FFT_FBMC.compl" )

    if options.ideal is False and options.ideal2 is False:
        self.subchannel_processing_vcvc = ofdm.fbmc_subchannel_processing_vcvc(total_subc, config.frame_data_part, 3, 2, 1, 0)
        help2 = blocks.keep_one_in_n(gr.sizeof_gr_complex*total_subc,frame_length)
        self.connect ((self.subchannel_processing_vcvc,1),help2)
        #log_to_file( self, self.subchannel_processing_vcvc, "data/fbmc_subc.compl" )

    
    #terminate_stream(self, help2)
    
    if options.ideal is False and options.ideal2 is False:
        self.connect(ofdm_blocks, blocks.vector_to_stream(gr.sizeof_gr_complex, fft_length),overlap_ser_to_par)
    else:
        self.connect(ofdm_blocks,overlap_ser_to_par)
        
    self.connect(overlap_ser_to_par, self.separate_vcvc)
    self.connect((self.separate_vcvc, 1), (self.polyphase_network_vcvc_2, 0))
    self.connect((self.separate_vcvc, 0), (self.polyphase_network_vcvc_1, 0))
    self.connect((self.polyphase_network_vcvc_1, 0), (self.junction_vcvc, 0))
    self.connect((self.polyphase_network_vcvc_2, 0), (self.junction_vcvc, 1))
    self.connect(self.junction_vcvc, self.fft_fbmc)
    
    ofdm_blocks = self.fft_fbmc
    print "config.dc_null: ", config.dc_null
    if fft_length > data_subc:
      subcarrier_mask_fbmc = ofdm.vector_mask_dc_null( fft_length, virtual_subc/2,
                                           total_subc, config.dc_null, [] )
      self.connect( ofdm_blocks, subcarrier_mask_fbmc )
      ofdm_blocks = subcarrier_mask_fbmc
      #log_to_file(self, ofdm_blocks, "data/vec_mask.compl")
       ## Least Squares estimator for channel transfer function (CTF)
      #log_to_file( self, subcarrier_mask, "data/OFDM_Blocks.compl" )
      
    
    self.connect(ofdm_blocks, self.beta_multiplier_vcvc)
    
    ofdm_blocks = self.beta_multiplier_vcvc
    #self.connect(ofdm_blocks,self.multiply_const)
    #self.connect(self.multiply_const, (self.skiphead, 0))
    
    self.connect(ofdm_blocks, (self.skiphead, 0))
    #log_to_file( self, self.skiphead, "data/fbmc_skiphead_4.compl" )
    
    
    #self.connect(ofdm_blocks, self.multiply_const)
    #self.connect(self.multiply_const, self.beta_multiplier_vcvc)
    #self.connect((self.beta_multiplier_vcvc, 0), (self.skiphead, 0))
    if options.ideal or options.ideal2:
        self.connect((self.skiphead, 0),(self.skiphead_1, 0))
    else:
        self.connect((self.skiphead, 0), (self.subchannel_processing_vcvc, 0))
        self.connect((self.subchannel_processing_vcvc, 0), (self.skiphead_1, 0))
        
    #log_to_file( self, self.skiphead, "data/fbmc_subc.compl" )    
    #self.connect((self.skiphead_1, 0),(self.remove_preamble_vcvc, 0))
    #self.connect((self.remove_preamble_vcvc, 0),  (self.oqam_postprocessing_vcvc, 0))
    
    #ofdm_blocks = self.oqam_postprocessing_vcvc
    #log_to_file( self, self.subchannel_processing_vcvc, "data/subc_0.compl" )
    #log_to_file( self, (self.subchannel_processing_vcvc,1), "data/subc_1.compl" )
    
    
    
    self.connect((self.skiphead_1, 0),(self.oqam_postprocessing_vcvc, 0))
    #self.connect((self.oqam_postprocessing_vcvc, 0), (self.remove_preamble_vcvc, 0) )
    
    ofdm_blocks = (self.oqam_postprocessing_vcvc, 0)#(self.remove_preamble_vcvc, 0)
    #log_to_file( self, (self.oqam_postprocessing_vcvc, 0), "data/fbmc_before_remove.compl" )
    
    #log_to_file( self, self.skiphead, "data/SKIP_HEAD_FBMC.compl" )
    #log_to_file( self, self.beta_multiplier_vcvc, "data/BETA_REC_FBMC.compl" )
    #log_to_file( self, self.oqam_postprocessing_vcvc, "data/REC_OUT_FBMC.compl" )
        
    

    
    
    
    
    
    """ DISABLED OFDM CHANNEL ESTIMATION PREMBLE -> CORRECT LATER to compare FBMC and OFDM channel estimation
    #TAKING THE CHANNEL ESTIMATION PREAMBLE
    chest_pre_trigger = blocks.delay( gr.sizeof_char, 3 )
    sampled_chest_preamble = ofdm.vector_sampler( gr.sizeof_gr_complex * fft_length/2, 2 )
      
    self.connect( frame_start,       chest_pre_trigger )
    self.connect( chest_pre_trigger, ( sampled_chest_preamble, 1 ) )
    self.connect( frequency_shift,       ( sampled_chest_preamble, 0 ) )
    #ofdm_blocks = sampled_chest_preamble
    
        
    ## FFT
    fft = fft_blocks.fft_vcc( fft_length, True, [], True )
    self.connect( sampled_chest_preamble, fft )
    ofdm_blocks_est = fft
    log_to_file( self, sampled_chest_preamble, "data/SAMPLED_EST_PREAMBLE.compl" )
    log_to_file( self, ofdm_blocks_est, "data/FFT.compl" )
    
    
    ## Remove virtual subcarriers
    if fft_length > data_subc:
      subcarrier_mask = ofdm.vector_mask( fft_length, virtual_subc/2,
                                           total_subc, [] )
      self.connect( ofdm_blocks_est, subcarrier_mask )
      ofdm_blocks_est = subcarrier_mask
      #log_to_file(self, ofdm_blocks, "data/vec_mask.compl")
       ## Least Squares estimator for channel transfer function (CTF)
      log_to_file( self, subcarrier_mask, "data/OFDM_Blocks.compl" )
    
          
    ## post-FFT processing
      
    
    
    ## extract channel estimation preamble from frame
    ##chest_pre_trigger = blocks.delay( gr.sizeof_char, 
                                  ##1 )
    ##sampled_chest_preamble = \
     ## ofdm.vector_sampler( gr.sizeof_gr_complex * total_subc, 1 )
    ##self.connect( frame_start,       chest_pre_trigger )
    ##self.connect( chest_pre_trigger, ( sampled_chest_preamble, 1 ) )
    ##self.connect( ofdm_blocks,       ( sampled_chest_preamble, 0 ) )
    

    
    ## Least Squares estimator for channel transfer function (CTF)
    inv_preamble_fd = numpy.array( block_header.pilotsym_fd[ 
        block_header.channel_estimation_pilot[0] ] )
    #print "Channel estimation pilot: ", inv_preamble_fd
    inv_preamble_fd = 1. / inv_preamble_fd
    
    LS_channel_estimator = ofdm.multiply_const_vcc( list( inv_preamble_fd ) )
    self.connect( ofdm_blocks_est, LS_channel_estimator )
    estimated_CTF = LS_channel_estimator
    terminate_stream(self,estimated_CTF)
    """
    if options.ideal is False and options.ideal2 is False:
        if options.logcir:
         log_to_file( self, sampled_chest_preamble, "data/PREAM.compl" )
     
    
        if not options.disable_ctf_enhancer:
      
      
            if options.logcir:
                ifft1 = fft_blocks.fft_vcc(total_subc,False,[],True)
                self.connect( estimated_CTF, ifft1,gr.null_sink(gr.sizeof_gr_complex*total_subc))
                summ1 = ofdm.vector_sum_vcc(total_subc)
                c2m =gr.complex_to_mag(total_subc)
                self.connect( estimated_CTF,summ1 ,gr.null_sink(gr.sizeof_gr_complex))
                self.connect( estimated_CTF, c2m,gr.null_sink(gr.sizeof_float*total_subc))
                log_to_file( self, ifft1, "data/CIR1.compl" )
                log_to_file( self, summ1, "data/CTFsumm1.compl" )
                log_to_file( self, estimated_CTF, "data/CTF1.compl" )
                log_to_file( self, c2m, "data/CTFmag1.float" )
        
            ## MSE enhancer
            ctf_mse_enhancer = ofdm.CTF_MSE_enhancer( total_subc, cp_length + cp_length)
            self.connect( estimated_CTF, ctf_mse_enhancer )
#      log_to_file( self, ctf_mse_enhancer, "data/ctf_mse_enhancer_original.compl")
      #ifft3 = fft_blocks.fft_vcc(total_subc,False,[],True)
      #null_noise = ofdm.noise_nulling(total_subc, cp_length + cp_length)
      #ctf_mse_enhancer = fft_blocks.fft_vcc(total_subc,True,[],True)
      #ctf_mse_enhancer = ofdm.vector_mask( fft_length, virtual_subc/2,
                                          # total_subc, [] )
      #self.connect( estimated_CTF, ifft3,null_noise,ctf_mse_enhancer )
        
            estimated_CTF = ctf_mse_enhancer 
            print "Disabled CTF MSE enhancer"

        if options.logcir:
         ifft2 = fft_blocks.fft_vcc(total_subc,False,[],True)
         self.connect( estimated_CTF, ifft2,gr.null_sink(gr.sizeof_gr_complex*total_subc))
         summ2 = ofdm.vector_sum_vcc(total_subc)
         c2m2 =gr.complex_to_mag(total_subc)
         self.connect( estimated_CTF,summ2 ,gr.null_sink(gr.sizeof_gr_complex))
         self.connect( estimated_CTF, c2m2,gr.null_sink(gr.sizeof_float*total_subc))
         log_to_file( self, ifft2, "data/CIR2.compl" )
         log_to_file( self, summ2, "data/CTFsumm2.compl" )
         log_to_file( self, estimated_CTF, "data/CTF2.compl" )
         log_to_file( self, c2m2, "data/CTFmag2.float" )
         
        ## Postprocess the CTF estimate
        ## CTF -> inverse CTF (for equalizer)
        ## CTF -> norm |.|^2 (for CTF display)
        ctf_postprocess = ofdm.fbmc_postprocess_CTF_estimate( total_subc )
        
        self.connect( help2, ctf_postprocess )
        #estimated_SNR = ( ctf_postprocess, 0 )
        disp_CTF = ( ctf_postprocess, 0 )
        #self.connect(estimated_SNR,out_snr_pream)
        #log_to_file( self, estimated_SNR, "data/fbmc_SNR.float" )
        
        #Disable measured SNR output
        #terminate_stream(self, estimated_SNR)
        #self.connect(blocks.vector_source_f([10.0],True) ,out_snr_pream)
    
#     if options.disable_equalization or options.ideal:
#       terminate_stream(self, inv_estimated_CTF)
#       inv_estimated_CTF_vec = blocks.vector_source_c([1.0/fft_length*math.sqrt(total_subc)]*total_subc,True,total_subc)
#       inv_estimated_CTF_str = blocks.vector_to_stream(gr.sizeof_gr_complex, total_subc)
#       self.inv_estimated_CTF_mul = ofdm.multiply_const_ccf( 1.0/config.rms_amplitude )
#       #inv_estimated_CTF_mul.set_k(1.0/config.rms_amplitude)
#       inv_estimated_CTF = blocks.stream_to_vector(gr.sizeof_gr_complex, total_subc)
#       self.connect( inv_estimated_CTF_vec, inv_estimated_CTF_str, self.inv_estimated_CTF_mul, inv_estimated_CTF)
#       print "Disabled equalization stage"
    '''
    ## LMS Phase tracking
    ## Track residual frequency offset and sampling clock frequency offset

    nondata_blocks = []
    for i in range(config.frame_length):
      if i in config.training_data.pilotsym_pos:
        nondata_blocks.append(i)
        
    print"\t\t\t\t\tnondata_blocks=",nondata_blocks
    pilot_subc = block_header.pilot_tones
    pilot_subcarriers = block_header.pilot_subc_sym
    print "PILOT SUBCARRIERS: ", pilot_subcarriers
        
    phase_tracking = ofdm.lms_phase_tracking_03( total_subc, pilot_subc,
                                               nondata_blocks, pilot_subcarriers,0 )
    self.connect( ofdm_blocks, ( phase_tracking, 0 ) )
    self.connect( inv_estimated_CTF, ( phase_tracking, 1 ) )
    self.connect( frame_start, ( phase_tracking, 2 ) ) ##
    
    if options.scatter_plot_before_phase_tracking:
      self.before_phase_tracking = equalizer
      
    
    if options.disable_phase_tracking or options.ideal:
      terminate_stream(self, phase_tracking)
      print "Disabled phase tracking stage"
    else:
      ofdm_blocks = phase_tracking
    '''
    ## Channel Equalizer
    ##equalizer = ofdm.channel_equalizer( total_subc )
    ##self.connect( ofdm_blocks,       ( equalizer, 0 ) )
    ##self.connect( inv_estimated_CTF, ( equalizer, 1 ) )
    ##self.connect( frame_start,       ( equalizer, 2 ) )
    ##ofdm_blocks = equalizer
    #log_to_file(self, equalizer,"data/equalizer_siso.compl")
    
    
    #log_to_file(self, ofdm_blocks, "data/equalizer.compl")

    ## LMS Phase tracking
    ## Track residual frequency offset and sampling clock frequency offset

    nondata_blocks = []
    for i in range(config.frame_length):
      if i in config.training_data.pilotsym_pos:
        nondata_blocks.append(i)
        
    print"\t\t\t\t\tnondata_blocks=",nondata_blocks
    pilot_subc = block_header.pilot_tones
    pilot_subcarriers = block_header.pilot_subc_sym
    print "PILOT SUBCARRIERS: ", pilot_subcarriers
    
    if options.scatter_plot_before_phase_tracking:
      self.before_phase_tracking = equalizer
        

    ## Output connections

    self.connect( ofdm_blocks, out_ofdm_blocks )
    self.connect( frame_start, out_frame_start )
    if options.ideal is False and options.ideal2 is False:
        self.connect( disp_CTF, out_disp_ctf )
    else:
        self.connect( blocks.vector_source_f([1.0]*total_subc),blocks.stream_to_vector(gr.sizeof_float,total_subc), out_disp_ctf )
    
    

    if log:
      log_to_file( self, sc_metric, "data/sc_metric.float" )
      log_to_file( self, gi_metric, "data/gi_metric.float" )
      log_to_file( self, morelli_foe, "data/morelli_foe.float" )
      log_to_file( self, lms_fir, "data/lms_fir.float" )
      log_to_file( self, sampler_preamble, "data/preamble.compl" )
      log_to_file( self, sync, "data/sync.compl" )
      log_to_file( self, frequency_shift, "data/frequency_shift.compl" )
      log_to_file( self, fft, "data/fft.compl")
      log_to_file( self, fft, "data/fft.float", mag=True )
      
      if vars().has_key( 'subcarrier_mask' ):
        log_to_file( self, subcarrier_mask, "data/subcarrier_mask.compl" )
      
      log_to_file( self, ofdm_blocks, "data/ofdm_blocks_out.compl" )
      log_to_file( self, frame_start, "data/frame_start.float", 
                   char_to_float=True )
      
      log_to_file( self, sampled_chest_preamble, 
                   "data/sampled_chest_preamble.compl" )
      log_to_file( self, LS_channel_estimator, 
                   "data/ls_channel_estimator.compl" )
      log_to_file( self, LS_channel_estimator, 
                   "data/ls_channel_estimator.float", mag=True )
      
      if "ctf_mse_enhancer" in locals(): 
        log_to_file( self, ctf_mse_enhancer, "data/ctf_mse_enhancer.compl" )
        log_to_file( self, ctf_mse_enhancer, "data/ctf_mse_enhancer.float", 
                     mag=True )
      
      log_to_file( self, (ctf_postprocess,0), "data/inc_estimated_ctf.compl" )
      log_to_file( self, (ctf_postprocess,1), "data/disp_ctf.float" )
      
      log_to_file( self, equalizer, "data/equalizer.compl" )
      log_to_file( self, equalizer, "data/equalizer.float", mag=True )
      
      log_to_file( self, phase_tracking, "data/phase_tracking.compl" )
    def __init__(self, fft_length, cp_length, logging=False):
        """
        OFDM synchronization using PN Correlation:
        T. M. Schmidl and D. C. Cox, "Robust Frequency and Timing
        Synchonization for OFDM," IEEE Trans. Communications, vol. 45,
        no. 12, 1997.
        """
        
	gr.hier_block2.__init__(self, "ofdm_sync_pn",
				gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
                                gr.io_signature2(2, 2, gr.sizeof_float, gr.sizeof_char)) # Output signature

        self.input = gr.add_const_cc(0)

        # PN Sync

        # Create a delay line
        self.delay = gr.delay(gr.sizeof_gr_complex, fft_length/2)

        # Correlation from ML Sync
        self.conjg = gr.conjugate_cc();
        self.corr = gr.multiply_cc();

        # Create a moving sum filter for the corr output
        if 1:
            moving_sum_taps = [1.0 for i in range(fft_length//2)]
            self.moving_sum_filter = filter.fir_filter_ccf(1,moving_sum_taps)
        else:
            moving_sum_taps = [complex(1.0,0.0) for i in range(fft_length//2)]
            self.moving_sum_filter = filter.fft_filter_ccc(1,moving_sum_taps)

        # Create a moving sum filter for the input
        self.inputmag2 = gr.complex_to_mag_squared()
        movingsum2_taps = [1.0 for i in range(fft_length//2)]

        if 1:
            self.inputmovingsum = filter.fir_filter_fff(1,movingsum2_taps)
        else:
            self.inputmovingsum = filter.fft_filter_fff(1,movingsum2_taps)

        self.square = gr.multiply_ff()
        self.normalize = gr.divide_ff()
     
        # Get magnitude (peaks) and angle (phase/freq error)
        self.c2mag = gr.complex_to_mag_squared()
        self.angle = gr.complex_to_arg()

        self.sample_and_hold = gr.sample_and_hold_ff()

        #ML measurements input to sampler block and detect
        self.sub1 = gr.add_const_ff(-1)
        self.pk_detect = gr.peak_detector_fb(0.20, 0.20, 30, 0.001)
        #self.pk_detect = gr.peak_detector2_fb(9)

        self.connect(self, self.input)
        
        # Calculate the frequency offset from the correlation of the preamble
        self.connect(self.input, self.delay)
        self.connect(self.input, (self.corr,0))
        self.connect(self.delay, self.conjg)
        self.connect(self.conjg, (self.corr,1))
        self.connect(self.corr, self.moving_sum_filter)
        self.connect(self.moving_sum_filter, self.c2mag)
        self.connect(self.moving_sum_filter, self.angle)
        self.connect(self.angle, (self.sample_and_hold,0))

        # Get the power of the input signal to normalize the output of the correlation
        self.connect(self.input, self.inputmag2, self.inputmovingsum)
        self.connect(self.inputmovingsum, (self.square,0))
        self.connect(self.inputmovingsum, (self.square,1))
        self.connect(self.square, (self.normalize,1))
        self.connect(self.c2mag, (self.normalize,0))

        # Create a moving sum filter for the corr output
        matched_filter_taps = [1.0/cp_length for i in range(cp_length)]
        self.matched_filter = filter.fir_filter_fff(1,matched_filter_taps)
        self.connect(self.normalize, self.matched_filter)
        
        self.connect(self.matched_filter, self.sub1, self.pk_detect)
        #self.connect(self.matched_filter, self.pk_detect)
        self.connect(self.pk_detect, (self.sample_and_hold,1))

        # Set output signals
        #    Output 0: fine frequency correction value
        #    Output 1: timing signal
        self.connect(self.sample_and_hold, (self,0))
        self.connect(self.pk_detect, (self,1))

        if logging:
            self.connect(self.matched_filter, gr.file_sink(gr.sizeof_float, "ofdm_sync_pn-mf_f.dat"))
            self.connect(self.normalize, gr.file_sink(gr.sizeof_float, "ofdm_sync_pn-theta_f.dat"))
            self.connect(self.angle, gr.file_sink(gr.sizeof_float, "ofdm_sync_pn-epsilon_f.dat"))
            self.connect(self.pk_detect, gr.file_sink(gr.sizeof_char, "ofdm_sync_pn-peaks_b.dat"))
            self.connect(self.sample_and_hold, gr.file_sink(gr.sizeof_float, "ofdm_sync_pn-sample_and_hold_f.dat"))
            self.connect(self.input, gr.file_sink(gr.sizeof_gr_complex, "ofdm_sync_pn-input_c.dat"))
Beispiel #23
0
    def __init__(self):
        gr.top_block.__init__(self, "Merapi Vco")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Merapi Vco")
        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", "merapi_vco")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2.4e6
        self.filt_len = filt_len = 1e6
        self.ch_bw = ch_bw = 30e3
        self.bb_rate = bb_rate = 192e3
        self.audio_rate = audio_rate = 48e3

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=int(bb_rate),
            decimation=int(samp_rate),
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_time_sink_x_2 = qtgui.time_sink_f(
            8192 * 8,  #size
            audio_rate,  #samp_rate
            "",  #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(-10, 10)

        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_NORM,
                                                  qtgui.TRIG_SLOPE_POS, 8, 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)

        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_layout.addWidget(self._qtgui_time_sink_x_2_win)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
            8192 * 8,  #size
            audio_rate,  #samp_rate
            "",  #name
            2  #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)

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

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
            1024,  #size
            audio_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(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 * 1):
            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_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c(
            8192,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            bb_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(-100, -20)
        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(0.2)
        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_layout.addWidget(self._qtgui_freq_sink_x_1_win)
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               '')
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(166.3e6, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(49, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.fft_filter_xxx_3 = filter.fft_filter_fff(
            1, (firdes.low_pass(1, audio_rate, 100, 100, firdes.WIN_BLACKMAN)),
            1)
        self.fft_filter_xxx_3.declare_sample_delay(0)
        self.fft_filter_xxx_2 = filter.fft_filter_ccc(
            1, (firdes.complex_band_pass(1, audio_rate, 360, 2360, 1e3,
                                         firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_2.declare_sample_delay(0)
        self.fft_filter_xxx_1 = filter.fft_filter_ccc(1, (firdes.low_pass(
            1, bb_rate, ch_bw / 2, ch_bw / 10, firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_1.declare_sample_delay(0)
        self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (firdes.low_pass(
            1, samp_rate, bb_rate / 2, bb_rate / 10, firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_rotator_cc_0 = blocks.rotator_cc(502e3 / samp_rate * 2 *
                                                     math.pi)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            int(filt_len), 1 / filt_len, 4000)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            audio_rate / (2 * math.pi * 1e3 / 8.0))
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=int(audio_rate),
            quad_rate=int(bb_rate),
            tau=75e-6,
            max_dev=5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.fft_filter_xxx_2, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_rotator_cc_0, 0), (self.fft_filter_xxx_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.fft_filter_xxx_3, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_time_sink_x_1, 0))
        self.connect((self.fft_filter_xxx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.fft_filter_xxx_1, 0), (self.analog_nbfm_rx_0, 0))
        self.connect((self.fft_filter_xxx_2, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.fft_filter_xxx_3, 0), (self.qtgui_time_sink_x_1, 1))
        self.connect((self.fft_filter_xxx_3, 0), (self.qtgui_time_sink_x_2, 0))
        self.connect((self.osmosdr_source_0, 0), (self.blocks_rotator_cc_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.fft_filter_xxx_1, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.qtgui_freq_sink_x_1, 0))
Beispiel #24
0
    def __init__(self):
        gr.top_block.__init__(self, "APRS - AFSK Demod (Test)")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("APRS - AFSK Demod (Test)")
        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", "APRS_AFSK_Demod")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.space = space = 2400
        self.samp_rate = samp_rate = 24e3
        self.out_sps = out_sps = 2
        self.mark = mark = 1200
        self.baud = baud = 1200

        ##################################################
        # Blocks
        ##################################################
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, 'Spectrum')
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, 'Demodulator')
        self.top_grid_layout.addWidget(self.tab, 1, 0, 1, 1)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            512,  #size
            baud * out_sps,  #samp_rate
            'Demodulator Output',  #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(-5, 5)

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

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

        if not False:
            self.qtgui_time_sink_x_0_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [2, 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.tab_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            'Input Waveform',  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        if not False:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 0, 0, 1,
                                       1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f(
            4096,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            'Input Spectrum',  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-120, -20)
        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(True)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_0.addWidget(self._qtgui_freq_sink_x_0_win)
        self.fft_filter_xxx_0 = filter.fft_filter_fff(1, (firdes.band_pass(
            10, samp_rate, 1e3, 2.6e3, 100, firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.audio_source_0 = audio.source(int(samp_rate), '', True)
        self.AFSK_Demod_0 = AFSK_Demod(
            baud=baud,
            fsk_hi_tone=space,
            fsk_lo_tone=mark,
            in_sps=int(samp_rate / baud),
            out_sps=out_sps,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.AFSK_Demod_0, 0), (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.audio_source_0, 0), (self.fft_filter_xxx_0, 0))
        self.connect((self.fft_filter_xxx_0, 0), (self.AFSK_Demod_0, 0))
        self.connect((self.fft_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.fft_filter_xxx_0, 0), (self.qtgui_time_sink_x_0, 0))
Beispiel #25
0
    def __init__(self):
        gr.top_block.__init__(self, "Rtl Airband")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Rtl Airband")
        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", "rtl_airband")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2.048e6
        self.freq_corr = freq_corr = 0
        self.freq = freq = 131.55e6

        ##################################################
        # Blocks
        ##################################################
        self._freq_corr_range = Range(-10e3, 10e3, 1, 0, 200)
        self._freq_corr_win = RangeWidget(self._freq_corr_range, self.set_freq_corr, "freq_corr", "counter_slider", float)
        self.top_layout.addWidget(self._freq_corr_win)
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
                interpolation=24000,
                decimation=192000,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=192000,
                decimation=int(samp_rate),
                taps=None,
                fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
        	8192, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	freq+freq_corr, #fc
        	192e3, #bw
        	"", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)
        
        if not False:
          self.qtgui_waterfall_sink_x_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        colors = [6, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])
        
        self.qtgui_waterfall_sink_x_0.set_intensity_range(-100, -40)
        
        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	4096, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	192e3, #bw
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-120, -20)
        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(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)
        
        if not False:
          self.qtgui_freq_sink_x_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq+freq_corr, 0)
        self.osmosdr_source_0.set_freq_corr(70, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(45, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
          
        self.fft_filter_xxx_0 = filter.fft_filter_fff(1, (firdes.low_pass(7,24e3,3e3,1e2,firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(32, True)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.audio_sink_0 = audio.sink(24000, '', True)
        self.analog_agc_xx_0 = analog.agc_ff(4e-1, 0.01, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0), (self.fft_filter_xxx_0, 0))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.dc_blocker_xx_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.analog_agc_xx_0, 0))    
        self.connect((self.fft_filter_xxx_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_waterfall_sink_x_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.rational_resampler_xxx_1, 0))    
        self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_complex_to_mag_0, 0))    
Beispiel #26
0
    def __init__(self):
        gr.top_block.__init__(self, "Merapi Vco Demo")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Merapi Vco Demo")
        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", "merapi_vco_demo")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2.4e6
        self.rfgain = rfgain = 30
        self.ch_rate = ch_rate = 48e3
        self.cfreq = cfreq = 165807500
        self.bb_rate = bb_rate = 192e3
        self.audio_mute = audio_mute = False
        self.afgain = afgain = -20

        ##################################################
        # Blocks
        ##################################################
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, 'Input Spectrum')
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, 'Baseband')
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, 'Demodulated Audio')
        self.tab_widget_3 = Qt.QWidget()
        self.tab_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_3)
        self.tab_grid_layout_3 = Qt.QGridLayout()
        self.tab_layout_3.addLayout(self.tab_grid_layout_3)
        self.tab.addTab(self.tab_widget_3, 'Sensor - Voltage')
        self.tab_widget_4 = Qt.QWidget()
        self.tab_layout_4 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_4)
        self.tab_grid_layout_4 = Qt.QGridLayout()
        self.tab_layout_4.addLayout(self.tab_grid_layout_4)
        self.tab.addTab(self.tab_widget_4, 'Sensor - Freq')
        self.tab_widget_5 = Qt.QWidget()
        self.tab_layout_5 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_5)
        self.tab_grid_layout_5 = Qt.QGridLayout()
        self.tab_layout_5.addLayout(self.tab_grid_layout_5)
        self.tab.addTab(self.tab_widget_5, 'Tab 5')
        self.tab_widget_6 = Qt.QWidget()
        self.tab_layout_6 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_6)
        self.tab_grid_layout_6 = Qt.QGridLayout()
        self.tab_layout_6.addLayout(self.tab_grid_layout_6)
        self.tab.addTab(self.tab_widget_6, 'Tab 6')
        self.tab_widget_7 = Qt.QWidget()
        self.tab_layout_7 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_7)
        self.tab_grid_layout_7 = Qt.QGridLayout()
        self.tab_layout_7.addLayout(self.tab_grid_layout_7)
        self.tab.addTab(self.tab_widget_7, 'Tab 7')
        self.tab_widget_8 = Qt.QWidget()
        self.tab_layout_8 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_8)
        self.tab_grid_layout_8 = Qt.QGridLayout()
        self.tab_layout_8.addLayout(self.tab_grid_layout_8)
        self.tab.addTab(self.tab_widget_8, 'Tab 8')
        self.tab_widget_9 = Qt.QWidget()
        self.tab_layout_9 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_9)
        self.tab_grid_layout_9 = Qt.QGridLayout()
        self.tab_layout_9.addLayout(self.tab_grid_layout_9)
        self.tab.addTab(self.tab_widget_9, 'Tab 9')
        self.top_layout.addWidget(self.tab)
        self._rfgain_range = Range(0, 50, 1, 30, 200)
        self._rfgain_win = RangeWidget(self._rfgain_range, self.set_rfgain,
                                       'RF Gain (dB)', "counter_slider", float)
        self.tab_grid_layout_0.addWidget(self._rfgain_win, 1, 1, 1, 1)
        self._cfreq_tool_bar = Qt.QToolBar(self)
        self._cfreq_tool_bar.addWidget(Qt.QLabel('Freq. (Hz)' + ": "))
        self._cfreq_line_edit = Qt.QLineEdit(str(self.cfreq))
        self._cfreq_tool_bar.addWidget(self._cfreq_line_edit)
        self._cfreq_line_edit.returnPressed.connect(lambda: self.set_cfreq(
            int(str(self._cfreq_line_edit.text().toAscii()))))
        self.tab_grid_layout_0.addWidget(self._cfreq_tool_bar, 1, 0, 1, 1)
        _audio_mute_check_box = Qt.QCheckBox('Audio Mute')
        self._audio_mute_choices = {True: True, False: False}
        self._audio_mute_choices_inv = dict(
            (v, k) for k, v in self._audio_mute_choices.iteritems())
        self._audio_mute_callback = lambda i: Qt.QMetaObject.invokeMethod(
            _audio_mute_check_box, "setChecked",
            Qt.Q_ARG("bool", self._audio_mute_choices_inv[i]))
        self._audio_mute_callback(self.audio_mute)
        _audio_mute_check_box.stateChanged.connect(
            lambda i: self.set_audio_mute(self._audio_mute_choices[bool(i)]))
        self.tab_grid_layout_2.addWidget(_audio_mute_check_box, 2, 0, 1, 1)
        self._afgain_range = Range(-30, -1, 1, -20, 200)
        self._afgain_win = RangeWidget(self._afgain_range, self.set_afgain,
                                       'AF Gain (dB)', "counter_slider", float)
        self.tab_grid_layout_2.addWidget(self._afgain_win, 2, 1, 1, 1)
        self.rational_resampler_xxx_2 = filter.rational_resampler_fff(
            interpolation=5,
            decimation=48,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_1 = filter.rational_resampler_fff(
            interpolation=10,
            decimation=48,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=int(bb_rate),
            decimation=int(samp_rate),
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_f(
            4096,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            5e3,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.01)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not False:
            self.qtgui_waterfall_sink_x_0.disable_legend()

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

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

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-50, 0)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_4.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.qtgui_time_sink_x_2 = qtgui.time_sink_f(
            8192 * 8,  #size
            ch_rate / 10,  #samp_rate
            "",  #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(-8, 8)

        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(True)
        self.qtgui_time_sink_x_2.enable_axis_labels(True)
        self.qtgui_time_sink_x_2.enable_control_panel(False)

        if not False:
            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.tab_grid_layout_3.addWidget(self._qtgui_time_sink_x_2_win, 1, 0,
                                         1, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            2048,  #size
            ch_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-15, 15)

        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(True)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_grid_layout_2.addWidget(self._qtgui_time_sink_x_0_win, 0, 0,
                                         1, 1)
        self.qtgui_freq_sink_x_2 = qtgui.freq_sink_f(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            10e3,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_2.set_update_time(0.10)
        self.qtgui_freq_sink_x_2.set_y_axis(-50, 0)
        self.qtgui_freq_sink_x_2.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_2.enable_autoscale(False)
        self.qtgui_freq_sink_x_2.enable_grid(True)
        self.qtgui_freq_sink_x_2.set_fft_average(0.1)
        self.qtgui_freq_sink_x_2.enable_axis_labels(True)
        self.qtgui_freq_sink_x_2.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_2.disable_legend()

        if "float" == "float" or "float" == "msg_float":
            self.qtgui_freq_sink_x_2.set_plot_pos_half(not False)

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

        self._qtgui_freq_sink_x_2_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_2.pyqwidget(), Qt.QWidget)
        self.tab_grid_layout_2.addWidget(self._qtgui_freq_sink_x_2_win, 0, 1,
                                         1, 1)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            bb_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(-100, -20)
        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(True)
        self.qtgui_freq_sink_x_1.set_fft_average(0.2)
        self.qtgui_freq_sink_x_1.enable_axis_labels(True)
        self.qtgui_freq_sink_x_1.enable_control_panel(False)

        if not False:
            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.tab_grid_layout_1.addWidget(self._qtgui_freq_sink_x_1_win, 0, 0,
                                         1, 1)
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               '')
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(cfreq + samp_rate / 4, 0)
        self.osmosdr_source_0.set_freq_corr(55, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(rfgain, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.fft_filter_xxx_4 = filter.fft_filter_fff(
            1, (firdes.low_pass(1, ch_rate, 5000, 1000, firdes.WIN_BLACKMAN)),
            1)
        self.fft_filter_xxx_4.declare_sample_delay(0)
        self.fft_filter_xxx_2 = filter.fft_filter_fff(1, (firdes.band_pass(
            1, ch_rate, 600, 2000, 600, firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_2.declare_sample_delay(0)
        self.fft_filter_xxx_1_0 = filter.fft_filter_fff(
            10, (firdes.low_pass(1, 48000, 40, 40, firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_1_0.declare_sample_delay(0)
        self.fft_filter_xxx_1 = filter.fft_filter_ccc(int(
            bb_rate / ch_rate), (firdes.low_pass(
                1, bb_rate, ch_rate / 2, ch_rate / 10, firdes.WIN_BLACKMAN)),
                                                      1)
        self.fft_filter_xxx_1.declare_sample_delay(0)
        self.fft_filter_xxx_0_0 = filter.fft_filter_ccc(
            1, (firdes.low_pass(1, 48000, 700, 200, firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_0_0.declare_sample_delay(0)
        self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (firdes.low_pass(
            1, samp_rate, bb_rate / 2, bb_rate / 10, firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.blocks_rotator_cc_0_0 = blocks.rotator_cc(
            (-1360 / 48000.0) * 2 * math.pi)
        self.blocks_rotator_cc_0 = blocks.rotator_cc(math.pi / 2)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (pow(10, afgain / 10), ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blks2_valve_0 = grc_blks2.valve(item_size=gr.sizeof_float * 1,
                                             open=bool(audio_mute))
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_quadrature_demod_cf_1 = analog.quadrature_demod_cf(
            ch_rate / (2 * math.pi * 1000 / 8.0))
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            ch_rate / (2 * math.pi * 12500 / 8.0))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.fft_filter_xxx_2, 0))
        self.connect((self.analog_quadrature_demod_cf_1, 0),
                     (self.fft_filter_xxx_1_0, 0))
        self.connect((self.blks2_valve_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_rotator_cc_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_rotator_cc_0, 0), (self.fft_filter_xxx_0, 0))
        self.connect((self.blocks_rotator_cc_0_0, 0),
                     (self.fft_filter_xxx_0_0, 0))
        self.connect((self.fft_filter_xxx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.fft_filter_xxx_0_0, 0),
                     (self.analog_quadrature_demod_cf_1, 0))
        self.connect((self.fft_filter_xxx_1, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.fft_filter_xxx_1_0, 0),
                     (self.qtgui_time_sink_x_2, 0))
        self.connect((self.fft_filter_xxx_2, 0), (self.blks2_valve_0, 0))
        self.connect((self.fft_filter_xxx_2, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.fft_filter_xxx_2, 0), (self.fft_filter_xxx_4, 0))
        self.connect((self.fft_filter_xxx_2, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.fft_filter_xxx_2, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.fft_filter_xxx_4, 0),
                     (self.rational_resampler_xxx_2, 0))
        self.connect((self.osmosdr_source_0, 0), (self.blocks_rotator_cc_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.fft_filter_xxx_1, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.qtgui_freq_sink_x_2, 0))
        self.connect((self.rational_resampler_xxx_2, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
Beispiel #27
0
    def __init__(self):
        gr.top_block.__init__(self, "Vor Sim")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Vor Sim")
        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", "vor_sim")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.angle = angle = 0
        self.samp_rate = samp_rate = 48e3
        self.angle_degree = angle_degree = angle * 1.0

        ##################################################
        # Blocks
        ##################################################
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, 'RF Spectrum')
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, 'VOR Baseband')
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, 'REF/VAR Signal')
        self.tab_widget_3 = Qt.QWidget()
        self.tab_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_3)
        self.tab_grid_layout_3 = Qt.QGridLayout()
        self.tab_layout_3.addLayout(self.tab_grid_layout_3)
        self.tab.addTab(self.tab_widget_3, 'Bearing Estimation')
        self.top_layout.addWidget(self.tab)
        self.vor_generator_0 = vor_generator(
            am_carrier=5e3,
            angle_degree=angle_degree,
            samp_rate=samp_rate,
        )
        self.rational_resampler_xxx_2 = filter.rational_resampler_fff(
            interpolation=512,
            decimation=3000,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_1 = filter.rational_resampler_fff(
            interpolation=512,
            decimation=3000,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff(
            interpolation=3000,
            decimation=int(samp_rate),
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=3000,
            decimation=int(samp_rate),
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
            2048,  #size
            3e3,  #samp_rate
            "",  #name
            2  #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(True)
        self.qtgui_time_sink_x_1.enable_grid(True)
        self.qtgui_time_sink_x_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_1.enable_control_panel(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:
                self.qtgui_time_sink_x_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.tab_layout_2.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
            2048,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(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 * 1):
            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.tab_grid_layout_0.addWidget(self._qtgui_time_sink_x_0_win, 1, 0,
                                         1, 1)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_HORIZ, 1)
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("")

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

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_3.addWidget(self._qtgui_number_sink_0_win)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c(
            8192,  #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(0.1)
        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.tab_grid_layout_1.addWidget(self._qtgui_freq_sink_x_1_win, 0, 0,
                                         1, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            8192,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_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(0.1)
        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(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0,
                                         1, 1)
        self.fft_vxx_0_0 = fft.fft_vfc(512, True, (window.blackmanharris(512)),
                                       1)
        self.fft_vxx_0 = fft.fft_vfc(512, True, (window.blackmanharris(512)),
                                     1)
        self.fft_filter_xxx_3 = filter.fft_filter_ccc(
            1, (firdes.low_pass(1, samp_rate, 2e3, 1e3, firdes.WIN_BLACKMAN)),
            1)
        self.fft_filter_xxx_3.declare_sample_delay(0)
        self.fft_filter_xxx_2 = filter.fft_filter_ccc(
            1, (firdes.low_pass(-1, samp_rate, 2e3, 1e3, firdes.WIN_BLACKMAN)),
            1)
        self.fft_filter_xxx_2.declare_sample_delay(0)
        self.fft_filter_xxx_0_0 = filter.fft_filter_fff(
            1, (firdes.low_pass(1, 3e3, 60, 10, firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_0_0.declare_sample_delay(0)
        self.fft_filter_xxx_0 = filter.fft_filter_fff(
            1, (firdes.low_pass(1, 3e3, 60, 10, firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.dc_blocker_xx_0_0 = filter.dc_blocker_ff(32, True)
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(32, True)
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=0.01,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=(1.0 + 1.0j, ),
            noise_seed=0,
            block_tags=False)
        self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, 512)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, 512)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(
            gr.sizeof_float * 1, 512)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_float * 1, 512)
        self.blocks_skiphead_0_0 = blocks.skiphead(gr.sizeof_gr_complex * 1,
                                                   30)
        self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_gr_complex * 1, 30)
        self.blocks_rotator_cc_1 = blocks.rotator_cc(-(9960.0 / samp_rate) *
                                                     2 * math.pi)
        self.blocks_rotator_cc_0 = blocks.rotator_cc(
            (-5e3 / samp_rate) * 2 * math.pi)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float * 1, 1000)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (180.0 / math.pi, ))
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            10000, 1e-4, 4000)
        self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n(
            gr.sizeof_gr_complex * 1, 512)
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(
            gr.sizeof_gr_complex * 1, 512)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_arg_0_0 = blocks.complex_to_arg(1)
        self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((0.0, ))
        self._angle_range = Range(-180, 180, 1, 0, 200)
        self._angle_win = RangeWidget(self._angle_range, self.set_angle,
                                      "angle", "counter_slider", float)
        self.top_layout.addWidget(self._angle_win)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            samp_rate / (2 * math.pi * 500 / 8.0))
        self.analog_agc_xx_0_0 = analog.agc_ff(1e-3, 1.0, 1.0)
        self.analog_agc_xx_0_0.set_max_gain(65536)
        self.analog_agc_xx_0 = analog.agc_ff(1e-3, 1.0, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0), (self.qtgui_time_sink_x_1, 0))
        self.connect((self.analog_agc_xx_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.analog_agc_xx_0_0, 0),
                     (self.qtgui_time_sink_x_1, 1))
        self.connect((self.analog_agc_xx_0_0, 0),
                     (self.rational_resampler_xxx_2, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_complex_to_arg_0, 0),
                     (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_complex_to_arg_0_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.fft_filter_xxx_2, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0),
                     (self.blocks_complex_to_arg_0, 0))
        self.connect((self.blocks_keep_one_in_n_0_0, 0),
                     (self.blocks_complex_to_arg_0_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_repeat_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_rotator_cc_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_rotator_cc_0, 0),
                     (self.blocks_rotator_cc_1, 0))
        self.connect((self.blocks_rotator_cc_0, 0),
                     (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.blocks_rotator_cc_1, 0), (self.fft_filter_xxx_3, 0))
        self.connect((self.blocks_skiphead_0, 0),
                     (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.blocks_skiphead_0_0, 0),
                     (self.blocks_keep_one_in_n_0_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_stream_to_vector_0_0, 0),
                     (self.fft_vxx_0_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.blocks_repeat_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_skiphead_0, 0))
        self.connect((self.blocks_vector_to_stream_0_0, 0),
                     (self.blocks_skiphead_0_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.blocks_rotator_cc_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.fft_filter_xxx_0, 0))
        self.connect((self.dc_blocker_xx_0_0, 0), (self.fft_filter_xxx_0_0, 0))
        self.connect((self.fft_filter_xxx_0, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.fft_filter_xxx_0_0, 0), (self.analog_agc_xx_0_0, 0))
        self.connect((self.fft_filter_xxx_2, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.fft_filter_xxx_3, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.fft_vxx_0_0, 0),
                     (self.blocks_vector_to_stream_0_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.dc_blocker_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.dc_blocker_xx_0_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.rational_resampler_xxx_2, 0),
                     (self.blocks_stream_to_vector_0_0, 0))
        self.connect((self.vor_generator_0, 0), (self.blocks_throttle_0, 0))
Beispiel #28
0
    def __init__(self):
        gr.top_block.__init__(self, "RTL SDR FM RX")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("RTL SDR FM RX")
        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", "RTL_FM_RX")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2.88e6
        self.rfgain = rfgain = 10
        self.freq = freq = 103.8
        self.ch_rate = ch_rate = 240e3
        self.audio_mute = audio_mute = False
        self.audio_cut = audio_cut = 12e3
        self.afgain = afgain = -10

        ##################################################
        # Blocks
        ##################################################
        self._rfgain_range = Range(0, 49, 0.1, 10, 200)
        self._rfgain_win = RangeWidget(self._rfgain_range, self.set_rfgain,
                                       'RF Gain (dB)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._rfgain_win, 2, 0, 1, 1)
        self._freq_range = Range(88.0, 108.0, 0.1, 103.8, 200)
        self._freq_win = RangeWidget(self._freq_range, self.set_freq,
                                     'Freq (MHz)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._freq_win, 1, 0, 1, 3)
        _audio_mute_check_box = Qt.QCheckBox('Audio Mute')
        self._audio_mute_choices = {True: True, False: False}
        self._audio_mute_choices_inv = dict(
            (v, k) for k, v in self._audio_mute_choices.iteritems())
        self._audio_mute_callback = lambda i: Qt.QMetaObject.invokeMethod(
            _audio_mute_check_box, "setChecked",
            Qt.Q_ARG("bool", self._audio_mute_choices_inv[i]))
        self._audio_mute_callback(self.audio_mute)
        _audio_mute_check_box.stateChanged.connect(
            lambda i: self.set_audio_mute(self._audio_mute_choices[bool(i)]))
        self.top_layout.addWidget(_audio_mute_check_box)
        self._afgain_range = Range(-20, 3, 0.1, -10, 200)
        self._afgain_win = RangeWidget(self._afgain_range, self.set_afgain,
                                       'AF Gain (dB)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._afgain_win, 2, 1, 1, 1)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=int(ch_rate),
            decimation=int(samp_rate),
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            freq * 1e6,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-120, -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(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 1,
                                       2)
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               '')
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq * 1e6, 0)
        self.osmosdr_source_0.set_freq_corr(55, 0)
        self.osmosdr_source_0.set_dc_offset_mode(2, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(rfgain, 0)
        self.osmosdr_source_0.set_if_gain(0, 0)
        self.osmosdr_source_0.set_bb_gain(0, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.fft_filter_xxx_0 = filter.fft_filter_fff(
            1, (firdes.low_pass(pow(10.0, afgain / 10.0), ch_rate, 12e3, 6e3,
                                firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, 10)
        self.blks2_valve_0 = grc_blks2.valve(item_size=gr.sizeof_float * 1,
                                             open=bool(audio_mute))
        self.audio_sink_0 = audio.sink(int(ch_rate / 10), '', True)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            ch_rate / (2 * math.pi * 250e3 / 8.0))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.fft_filter_xxx_0, 0))
        self.connect((self.blks2_valve_0, 0), (self.audio_sink_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0), (self.blks2_valve_0, 0))
        self.connect((self.fft_filter_xxx_0, 0),
                     (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
Beispiel #29
0
    def __init__(self, baud, bpf_trans, filter_len, fsk_hi_tone, fsk_lo_tone,
                 gain, gmu, hi, input_rate, low, mu):
        gr.hier_block2.__init__(
            self,
            "merapi_rx",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signaturev(3, 3, [
                gr.sizeof_gr_complex * 1, gr.sizeof_float * 1,
                gr.sizeof_short * 1
            ]),
        )
        self.message_port_register_hier_out("frame_out")
        self.message_port_register_hier_out("afsk")
        self.message_port_register_hier_out("hi_symb")
        self.message_port_register_hier_out("lo_symb")
        self.message_port_register_hier_out("softbits")

        ##################################################
        # Parameters
        ##################################################
        self.baud = baud
        self.bpf_trans = bpf_trans
        self.filter_len = filter_len
        self.fsk_hi_tone = fsk_hi_tone
        self.fsk_lo_tone = fsk_lo_tone
        self.gain = gain
        self.gmu = gmu
        self.hi = hi
        self.input_rate = input_rate
        self.low = low
        self.mu = mu

        ##################################################
        # Variables
        ##################################################
        self.ch_rate = ch_rate = 48e3
        self.sps = sps = int(ch_rate / baud)

        ##################################################
        # Blocks
        ##################################################
        self.root_raised_cosine_filter_1 = filter.fir_filter_ccf(
            1, firdes.root_raised_cosine(1, sps * 1.0, 1.0, 0.7, 4 * sps))
        self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(
            1, firdes.root_raised_cosine(1, sps * 1.0, 1.0, 0.7, 4 * sps))
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=2,
            decimation=sps,
            taps=None,
            fractional_bw=None,
        )
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(ch_rate /
                                                             input_rate,
                                                             taps=None,
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.Merapi_frame_detect_0 = Merapi.frame_detect()
        self.fft_filter_xxx_0 = filter.fft_filter_fff(1, (firdes.band_pass(
            0.1, ch_rate, fsk_lo_tone - (bpf_trans / 2), fsk_hi_tone +
            (bpf_trans / 2), 1e3, firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            2 * (1 + 0.0), 0.25 * gmu * gmu, mu, gmu, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_threshold_ff_0 = blocks.threshold_ff(low, hi, 0)
        self.blocks_tagged_stream_to_pdu_1 = blocks.tagged_stream_to_pdu(
            blocks.float_t, 'packet_len')
        self.blocks_tagged_stream_to_pdu_0_0_0 = blocks.tagged_stream_to_pdu(
            blocks.float_t, 'packet_len')
        self.blocks_tagged_stream_to_pdu_0_0 = blocks.tagged_stream_to_pdu(
            blocks.float_t, 'packet_len')
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(
            blocks.float_t, 'packet_len')
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_stream_to_tagged_stream_1 = blocks.stream_to_tagged_stream(
            gr.sizeof_float, 1, 512, "packet_len")
        self.blocks_stream_to_tagged_stream_0_0_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_float, 1, 512, "packet_len")
        self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_float, 1, 512, "packet_len")
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_float, 1, 512, "packet_len")
        self.blocks_rotator_cc_1 = blocks.rotator_cc(
            (-1.0 * fsk_hi_tone / ch_rate) * 2 * math.pi)
        self.blocks_rotator_cc_0_0 = blocks.rotator_cc(
            (-1.0 * fsk_lo_tone / ch_rate) * 2 * math.pi)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((gain, ))
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            filter_len, 1.0 / filter_len, 4000)
        self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_short, 2, sps,
                                                       0)
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 0)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_burst_tagger_1 = blocks.burst_tagger(gr.sizeof_float)
        self.blocks_burst_tagger_1.set_true_tag('burst_start', True)
        self.blocks_burst_tagger_1.set_false_tag('burst_stop', False)

        self.blocks_burst_tagger_0 = blocks.burst_tagger(gr.sizeof_float)
        self.blocks_burst_tagger_0.set_true_tag('burst_start', True)
        self.blocks_burst_tagger_0.set_false_tag('burst_stop', False)

        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            ch_rate / (2 * math.pi * (10e3) / 8.0))
        self.analog_agc_xx_0 = analog.agc_ff(1e-4, 1.0, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)
        self.analog_agc2_xx_1 = analog.agc2_ff(0.5, 0.00001, 1.0, 1.0)
        self.analog_agc2_xx_1.set_max_gain(65536)
        self.analog_agc2_xx_0 = analog.agc2_ff(0.5, 0.00001, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'),
                         (self, 'softbits'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'),
                         (self, 'hi_symb'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0_0, 'pdus'),
                         (self, 'lo_symb'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_1, 'pdus'),
                         (self, 'afsk'))
        self.msg_connect((self.Merapi_frame_detect_0, 'frame out'),
                         (self, 'frame_out'))
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.blocks_stream_to_tagged_stream_0_0, 0))
        self.connect((self.analog_agc2_xx_0, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.analog_agc2_xx_1, 0),
                     (self.blocks_stream_to_tagged_stream_0_0_0, 0))
        self.connect((self.analog_agc2_xx_1, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.analog_agc_xx_0, 0),
                     (self.blocks_burst_tagger_1, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.fft_filter_xxx_0, 0))
        self.connect((self.blocks_burst_tagger_0, 0),
                     (self.blocks_stream_to_tagged_stream_1, 0))
        self.connect((self.blocks_burst_tagger_0, 0), (self, 1))
        self.connect((self.blocks_burst_tagger_1, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.analog_agc2_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_1, 0),
                     (self.analog_agc2_xx_1, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_null_sink_0, 0))
        self.connect((self.blocks_delay_0, 0), (self, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_rotator_cc_0_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_rotator_cc_1, 0))
        self.connect((self.blocks_float_to_short_0, 0),
                     (self.blocks_burst_tagger_0, 1))
        self.connect((self.blocks_float_to_short_0, 0),
                     (self.blocks_keep_m_in_n_0, 0))
        self.connect((self.blocks_float_to_short_0, 0), (self, 2))
        self.connect((self.blocks_keep_m_in_n_0, 0),
                     (self.blocks_burst_tagger_1, 1))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_rotator_cc_0_0, 0),
                     (self.root_raised_cosine_filter_0, 0))
        self.connect((self.blocks_rotator_cc_1, 0),
                     (self.root_raised_cosine_filter_1, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0_0_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0_0_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_1, 0),
                     (self.blocks_tagged_stream_to_pdu_1, 0))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_float_to_short_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.Merapi_frame_detect_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.fft_filter_xxx_0, 0),
                     (self.blocks_burst_tagger_0, 0))
        self.connect((self.fft_filter_xxx_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self, 0), (self.blocks_delay_0, 0))
        self.connect((self, 0), (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_agc_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.root_raised_cosine_filter_1, 0),
                     (self.blocks_complex_to_mag_1, 0))
Beispiel #30
0
    def __init__(self):
        gr.top_block.__init__(self, "Tlm Ana")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Tlm Ana")
        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", "tlm_ana")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 40
        self.nfilt = nfilt = 40
        self.audio_rate = audio_rate = 48e3
        self.samp_rate = samp_rate = 300e3

        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilt * 1.0, audio_rate, 1200.0, 0.35, 16 * sps)

        self.ch_rate = ch_rate = 96e3

        ##################################################
        # Blocks
        ##################################################
        self.root_raised_cosine_filter_0 = filter.fir_filter_fff(
            1, firdes.root_raised_cosine(1.0, audio_rate, 1200.0, 0.35,
                                         16 * 40))
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=int(ch_rate),
            decimation=int(samp_rate),
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            8192 * 8,  #size
            audio_rate,  #samp_rate
            "",  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-15, 15)

        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_TAG,
                                                  qtgui.TRIG_SLOPE_POS, 0.0,
                                                  50e-3, 0, 'start')
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(True)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            4096,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-100, -20)
        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(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.fft_filter_xxx_2 = filter.fft_filter_ccc(
            1, (firdes.low_pass(1, audio_rate, 1e3, 1e3, firdes.WIN_BLACKMAN)),
            1)
        self.fft_filter_xxx_2.declare_sample_delay(0)
        self.fft_filter_xxx_1 = filter.fft_filter_fff(1, (firdes.band_pass(
            1, audio_rate, 700, 2700, 500, firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_1.declare_sample_delay(0)
        self.fft_filter_xxx_0 = filter.fft_filter_ccc(
            1, (firdes.low_pass(1, samp_rate, 5e3, 1e3, firdes.WIN_BLACKMAN)),
            1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(0.5, 0.7, 0)
        self.blocks_tagged_file_sink_0 = blocks.tagged_file_sink(
            gr.sizeof_char * 1, int(audio_rate))
        self.blocks_rotator_cc_1 = blocks.rotator_cc(
            (-1700 / audio_rate) * 2 * math.pi)
        self.blocks_rotator_cc_0 = blocks.rotator_cc(-(-16.2e3 / samp_rate) *
                                                     2 * math.pi)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_multiply_const_vxx_5 = blocks.multiply_const_vcc((2, ))
        self.blocks_multiply_const_vxx_4 = blocks.multiply_const_vff((1.0, ))
        self.blocks_multiply_const_vxx_3 = blocks.multiply_const_vff((1, ))
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((7, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((1e4, ))
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            400, 1.0 / 400, 4000)
        self.blocks_keep_one_in_n_2 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, 5)
        self.blocks_keep_one_in_n_1 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, 2)
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 1)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            '/home/handiko/gqrx_20180319_072938_433268400_300000_fc.raw', True)
        self.blocks_delay_3 = blocks.delay(gr.sizeof_float * 1, 0)
        self.blocks_delay_2 = blocks.delay(gr.sizeof_short * 1, 2400)
        self.blocks_delay_1 = blocks.delay(gr.sizeof_short * 1, 400)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 400)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.blocks_burst_tagger_1 = blocks.burst_tagger(gr.sizeof_float)
        self.blocks_burst_tagger_1.set_true_tag('burst', True)
        self.blocks_burst_tagger_1.set_false_tag('burst', False)

        self.blocks_burst_tagger_0 = blocks.burst_tagger(gr.sizeof_float)
        self.blocks_burst_tagger_0.set_true_tag('start', True)
        self.blocks_burst_tagger_0.set_false_tag('stop', False)

        self.blocks_add_const_vxx_3 = blocks.add_const_vff((-5, ))
        self.blocks_add_const_vxx_2 = blocks.add_const_vff((5, ))
        self.blocks_add_const_vxx_1 = blocks.add_const_vff((48, ))
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((0, ))
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            audio_rate / (2 * math.pi * 1e3 / 8.0))
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=int(audio_rate),
            quad_rate=int(ch_rate),
            tau=75e-6,
            max_dev=5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.fft_filter_xxx_1, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.root_raised_cosine_filter_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_burst_tagger_1, 0))
        self.connect((self.blocks_add_const_vxx_1, 0),
                     (self.blocks_keep_one_in_n_2, 0))
        self.connect((self.blocks_add_const_vxx_2, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_add_const_vxx_3, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_burst_tagger_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_burst_tagger_1, 0),
                     (self.blocks_add_const_vxx_1, 0))
        self.connect((self.blocks_burst_tagger_1, 0),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.blocks_delay_1, 0), (self.blocks_burst_tagger_0, 1))
        self.connect((self.blocks_delay_2, 0), (self.blocks_burst_tagger_1, 1))
        self.connect((self.blocks_delay_3, 0),
                     (self.blocks_multiply_const_vxx_3, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_rotator_cc_0, 0))
        self.connect((self.blocks_float_to_char_0, 0),
                     (self.blocks_tagged_file_sink_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_rotator_cc_1, 0))
        self.connect((self.blocks_float_to_short_0, 0),
                     (self.blocks_delay_1, 0))
        self.connect((self.blocks_float_to_short_0, 0),
                     (self.blocks_delay_2, 0))
        self.connect((self.blocks_keep_one_in_n_1, 0),
                     (self.blocks_float_to_short_0, 0))
        self.connect((self.blocks_keep_one_in_n_2, 0),
                     (self.blocks_float_to_char_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_2, 0),
                     (self.blocks_add_const_vxx_2, 0))
        self.connect((self.blocks_multiply_const_vxx_3, 0),
                     (self.blocks_add_const_vxx_3, 0))
        self.connect((self.blocks_multiply_const_vxx_4, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.blocks_multiply_const_vxx_5, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_rotator_cc_0, 0),
                     (self.blocks_multiply_const_vxx_5, 0))
        self.connect((self.blocks_rotator_cc_1, 0), (self.fft_filter_xxx_2, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_keep_one_in_n_1, 0))
        self.connect((self.blocks_throttle_0, 0), (self.fft_filter_xxx_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.fft_filter_xxx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.fft_filter_xxx_1, 0),
                     (self.blocks_burst_tagger_0, 0))
        self.connect((self.fft_filter_xxx_1, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.fft_filter_xxx_2, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_nbfm_rx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.blocks_delay_3, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.blocks_multiply_const_vxx_4, 0))
Beispiel #31
0
    def __init__(self, demod_rate, audio_decimation):
        """
        Hierarchical block for demodulating a broadcast FM signal.

        The input is the downconverted complex baseband signal (gr_complex).
        The output is two streams of the demodulated audio (float) 0=Left, 1=Right.

        Args:
            demod_rate: input sample rate of complex baseband input. (float)
            audio_decimation: how much to decimate demod_rate to get to audio. (integer) FIXME: Not actually implemented!
        """
        gr.hier_block2.__init__(
            self,
            "wfm_rcv_pll",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),  # Input signature
            gr.io_signature(2, 2, gr.sizeof_float))  # Output signature

        if audio_decimation != int(audio_decimation):
            raise ValueError("audio_decimation needs to be an integer")
        audio_decimation = int(audio_decimation)

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 3840000
        self.rf_decim = rf_decim = 10
        self.demod_rate = demod_rate = (int)(samp_rate / rf_decim)
        self.stereo_carrier_filter_coeffs_0 = stereo_carrier_filter_coeffs_0 = firdes.band_pass(
            1.0, demod_rate, 37600, 38400, 400, fft.window.WIN_HAMMING, 6.76)
        self.stereo_carrier_filter_coeffs = stereo_carrier_filter_coeffs = firdes.complex_band_pass(
            1.0, demod_rate, 18980, 19020, 1500, fft.window.WIN_HAMMING, 6.76)
        self.deviation = deviation = 75000
        self.audio_filter = audio_filter = firdes.low_pass(
            1, demod_rate, 15000, 1500, fft.window.WIN_HAMMING, 6.76)
        self.audio_decim = audio_decim = (int)(demod_rate / 48000)

        ##################################################
        # Blocks
        ##################################################
        self.fir_filter_xxx_1 = filter.fir_filter_fcc(
            1, stereo_carrier_filter_coeffs)
        self.fir_filter_xxx_1.declare_sample_delay(0)
        self.fft_filter_xxx_3 = filter.fft_filter_fff(
            1, stereo_carrier_filter_coeffs_0, 1)
        self.fft_filter_xxx_3.declare_sample_delay(0)
        self.fft_filter_xxx_2 = filter.fft_filter_fff(audio_decim,
                                                      audio_filter, 1)
        self.fft_filter_xxx_2.declare_sample_delay(0)
        self.fft_filter_xxx_1 = filter.fft_filter_fff(audio_decim,
                                                      audio_filter, 1)
        self.fft_filter_xxx_1.declare_sample_delay(0)
        self.blocks_multiply_xx_2 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_ff(5.5)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(-5.5)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_add_xx_0_0 = blocks.add_vff(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            demod_rate / (2 * math.pi * deviation))
        self.analog_pll_refout_cc_0 = analog.pll_refout_cc(
            0.001, 2 * math.pi * 19200 / demod_rate,
            2 * math.pi * 18800 / demod_rate)
        self.analog_fm_deemph_0_0 = analog.fm_deemph(fs=48000, tau=75e-6)
        self.analog_fm_deemph_0 = analog.fm_deemph(fs=48000, tau=75e-6)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_fm_deemph_0, 0), (self, 0))
        self.connect((self.analog_fm_deemph_0_0, 0), (self, 1))
        self.connect((self.analog_pll_refout_cc_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_pll_refout_cc_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.blocks_multiply_xx_2, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.fft_filter_xxx_1, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.fir_filter_xxx_1, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.analog_fm_deemph_0, 0))
        self.connect((self.blocks_add_xx_0_0, 0),
                     (self.analog_fm_deemph_0_0, 0))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.fft_filter_xxx_3, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_1, 0),
                     (self.blocks_add_xx_0_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_complex_to_imag_0, 0))
        self.connect((self.blocks_multiply_xx_2, 0),
                     (self.fft_filter_xxx_2, 0))
        self.connect((self.fft_filter_xxx_1, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.fft_filter_xxx_1, 0), (self.blocks_add_xx_0_0, 1))
        self.connect((self.fft_filter_xxx_2, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.fft_filter_xxx_2, 0),
                     (self.blocks_multiply_const_vxx_0_1, 0))
        self.connect((self.fft_filter_xxx_3, 0),
                     (self.blocks_multiply_xx_2, 1))
        self.connect((self.fir_filter_xxx_1, 0),
                     (self.analog_pll_refout_cc_0, 0))
        self.connect((self, 0), (self.analog_quadrature_demod_cf_0, 0))
Beispiel #32
0
    def __init__(self, options, log=False):

        ## Read configuration
        config = station_configuration()

        fft_length = config.fft_length
        #cp_length     = config.cp_length
        block_header = config.training_data
        data_subc = config.data_subcarriers
        virtual_subc = config.virtual_subcarriers
        total_subc = config.subcarriers
        block_length = config.block_length
        frame_length = config.frame_length

        L = block_header.mm_periodic_parts

        cp_length = config.cp_length

        print "data_subc: ", config.data_subcarriers
        print "total_subc: ", config.subcarriers
        print "frame_lengthframe_length: ", frame_length

        ## Set Input/Output signature
        gr.hier_block2.__init__(
            self,
            "fbmc_inner_receiver",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
            gr.io_signaturev(
                4,
                4,
                [
                    gr.sizeof_float * total_subc,  # Normalized |CTF|^2 
                    gr.sizeof_char,  # Frame start
                    gr.sizeof_gr_complex * total_subc,  # OFDM blocks, SNR est
                    gr.sizeof_float
                ]))  # CFO

        ## Input and output ports
        self.input = rx_input = self

        out_ofdm_blocks = (self, 2)
        out_frame_start = (self, 1)
        out_disp_ctf = (self, 0)
        out_disp_cfo = (self, 3)
        #out_snr_pream    = ( self, 3 )

        ## pre-FFT processing
        '''
    ## Compute autocorrelations for S&C preamble
    ## and cyclic prefix
    
    self._sc_metric = sc_metric = autocorrelator( fft_length/2, fft_length/2 )
    self._gi_metric = gi_metric = autocorrelator( fft_length, cp_length )
    
    self.connect( rx_input, sc_metric )
    self.connect( rx_input, gi_metric )
    terminate_stream(self, gi_metric)
    
    ## Sync. Output contains OFDM blocks
    sync = ofdm.time_sync( fft_length/2, 1)
    self.connect( rx_input, ( sync, 0 ) )
    self.connect( sc_metric, ( sync, 1 ) )
    self.connect( sc_metric, ( sync, 2 ) )
    
    ofdm_blocks = ( sync, 0 )
    frame_start = ( sync, 1 )
    log_to_file( self, ( sync, 1 ), "data/fbmc_peak_detector.char" )
    '''
        if options.ideal is False and options.ideal2 is False:
            #Testing old/new metric
            self.tm = schmidl.recursive_timing_metric(2 * fft_length)
            self.connect(self.input, self.tm)
            #log_to_file( self, self.tm, "data/fbmc_rec_sc_metric_ofdm.float" )

            timingmetric_shift = 0  #-2 #int(-cp_length * 0.8)
            tmfilter = filter.fft_filter_fff(
                1, [2. / fft_length] * (fft_length / 2)
            )  # ofdm.lms_fir_ff( fft_length, 1e-3 ) #; filter.fir_filter_fff(1, [1./fft_length]*fft_length)
            self.connect(self.tm, tmfilter)
            self.tm = tmfilter
            #log_to_file( self, self.tm, "data/fbmc_rec_sc_metric_ofdm2.float" )

            self._pd_thres = 0.6
            self._pd_lookahead = fft_length  # empirically chosen
            peak_detector = ofdm.peak_detector_02_fb(self._pd_lookahead,
                                                     self._pd_thres)
            self.connect(self.tm, peak_detector)
            #log_to_file( self, peak_detector, "data/fbmc_rec_peak_detector.char" )

            #frame_start = [0]*frame_length
            #frame_start[0] = 1
            #frame_start = blocks.vector_source_b(frame_start,True)

            #OLD
            #delayed_timesync = blocks.delay(gr.sizeof_char,
            #                           (frame_length-10)*fft_length/2 - fft_length/4 -1 + timingmetric_shift)
            delayed_timesync = blocks.delay(
                gr.sizeof_char,
                (frame_length - 10) * fft_length / 2 - fft_length / 4 +
                int(2.5 * fft_length) + timingmetric_shift - 1)
            #delayed_timesync = blocks.delay(gr.sizeof_char,
            #(frame_length-10)*fft_length/2 - fft_length/4 + int(3.5*fft_length)  + timingmetric_shift-1)
            self.connect(peak_detector, delayed_timesync)

            self.block_sampler = ofdm.vector_sampler(
                gr.sizeof_gr_complex, fft_length / 2 * frame_length)

            self.connect(self.input, self.block_sampler)
            self.connect(delayed_timesync, (self.block_sampler, 1))
            #log_to_file( self, self.block_sampler, "data/fbmc_block_sampler.compl" )

            vt2s = blocks.vector_to_stream(gr.sizeof_gr_complex * fft_length,
                                           frame_length / 2)
            self.connect(self.block_sampler, vt2s)
            #terminate_stream(self,ofdm_blocks)

            ofdm_blocks = vt2s
            '''
        # TODO: dynamic solution
        vt2s = blocks.vector_to_stream(gr.sizeof_gr_complex*block_length/2,
                                                frame_length)
        self.connect(self.block_sampler,vt2s)
        terminate_stream(self,( sync, 0 ))
        ofdm_blocks = vt2s
        '''

            ##stv_help = blocks.stream_to_vector(gr.sizeof_gr_complex*config.fft_length/2, 1)
            #stv_help = blocks.vector_to_stream(gr.sizeof_gr_complex*config.fft_length/2, 2)
            ##self.connect(ofdm_blocks, stv_help)
            ##ofdm_blocks = stv_help
            #ofdm_blocks = ( sync, 0 )
            #frame_start = ( sync, 1 )
            #log_to_file(self, frame_start, "data/frame_start.compl")

            #log_to_file( self, sc_metric, "data/sc_metric.float" )
            #log_to_file( self, gi_metric, "data/gi_metric.float" )
            #log_to_file( self, (sync,1), "data/sync.float" )

            #    log_to_file(self,ofdm_blocks,"data/ofdm_blocks_original.compl")
            frame_start = [0] * int(frame_length / 2)
            frame_start[0] = 1
            frame_start = blocks.vector_source_b(frame_start, True)

            #frame_start2 = [0]*int(frame_length/2)
            #frame_start2[0] = 1
            #frame_start2 = blocks.vector_source_b(frame_start2,True)

        if options.disable_time_sync or options.ideal or options.ideal2:
            if options.ideal is False and options.ideal2 is False:
                terminate_stream(self, ofdm_blocks)
                terminate_stream(self, frame_start)

            serial_to_parallel = blocks.stream_to_vector(
                gr.sizeof_gr_complex, fft_length)
            #discard_cp = ofdm.vector_mask(block_length,cp_length,fft_length,[])
            #serial_to_parallel = blocks.stream_to_vector(gr.sizeof_gr_complex,block_length)
            #discard_cp = ofdm.vector_mask(block_length,cp_length,fft_length,[])
            #self.connect( rx_input,serial_to_parallel)

            #self.connect( rx_input, blocks.delay(gr.sizeof_gr_complex,0),serial_to_parallel)
            initial_skip = blocks.skiphead(gr.sizeof_gr_complex,
                                           2 * fft_length)
            self.connect(rx_input, initial_skip)
            if options.ideal is False and options.ideal2 is False:
                self.connect(initial_skip, serial_to_parallel)
                ofdm_blocks = serial_to_parallel
            else:
                ofdm_blocks = initial_skip
            #self.connect( rx_input, serial_to_parallel, discard_cp )

            frame_start = [0] * int(frame_length / 2)
            frame_start[0] = 1
            frame_start = blocks.vector_source_b(frame_start, True)

            #frame_start2 = [0]*int(frame_length/2)
            #frame_start2[0] = 1
            #frame_start2 = blocks.vector_source_b(frame_start2,True)

            print "Disabled time synchronization stage"

        print "\t\t\t\t\tframe_length = ", frame_length

        if options.ideal is False and options.ideal2 is False:
            ## Extract preamble, feed to Morelli & Mengali frequency offset estimator
            assert (block_header.mm_preamble_pos == 0)
            morelli_foe = ofdm.mm_frequency_estimator(fft_length, 2, 1,
                                                      config.fbmc)
            sampler_preamble = ofdm.vector_sampler(
                gr.sizeof_gr_complex * fft_length, 1)
            self.connect(ofdm_blocks, (sampler_preamble, 0))
            self.connect(frame_start, blocks.delay(gr.sizeof_char, 1),
                         (sampler_preamble, 1))
            self.connect(sampler_preamble, morelli_foe)
            freq_offset = morelli_foe
            print "FRAME_LENGTH: ", frame_length
            #log_to_file( self, sampler_preamble, "data/sampler_preamble.compl" )
            #log_to_file( self, rx_input, "data/rx_input.compl" )
            #log_to_file( self, ofdm_blocks, "data/rx_input.compl" )

            #Extracting preamble for SNR estimation
            #fft_snr_est = fft_blocks.fft_vcc( fft_length, True, [], True )
            #self.connect( sampler_preamble, blocks.stream_to_vector(gr.sizeof_gr_complex*fft_length/2, 2),  fft_snr_est )

            ## Remove virtual subcarriers
            #if fft_length > data_subc:
            #subcarrier_mask_snr_est = ofdm.vector_mask( fft_length, virtual_subc/2,
            #                       total_subc, [] )
            #self.connect( fft_snr_est, subcarrier_mask_snr_est )
            #fft_snr_est = subcarrier_mask_snr_est
            #log_to_file(self, ofdm_blocks, "data/vec_mask.compl")
            ## Least Squares estimator for channel transfer function (CTF)

            #self.connect( fft_snr_est, out_snr_pream ) # Connecting to output

            ## Adaptive LMS FIR filtering of frequency offset
            lms_fir = ofdm.lms_fir_ff(20,
                                      1e-3)  # TODO: verify parameter choice
            self.connect(freq_offset, lms_fir)
            freq_offset = lms_fir

            self.connect(freq_offset,
                         blocks.keep_one_in_n(gr.sizeof_float,
                                              20), out_disp_cfo)
        else:
            self.connect(blocks.vector_source_f([1]), out_disp_cfo)

        #log_to_file(self, lms_fir, "data/lms_fir.float")

        if options.disable_freq_sync or options.ideal or options.ideal2:
            if options.ideal is False and options.ideal2 is False:
                terminate_stream(self, freq_offset)
                freq_offset = blocks.vector_source_f([0.0], True)
            print "Disabled frequency synchronization stage"

        if options.ideal is False and options.ideal2 is False:
            ## Correct frequency shift, feed-forward structure
            frequency_shift = ofdm.frequency_shift_vcc(fft_length,
                                                       -1.0 / fft_length, 0)

            #freq_shift = blocks.multiply_cc()
            #norm_freq = -0.1 / config.fft_length
            #freq_off = self.freq_off_src = analog.sig_source_c(1.0, analog.GR_SIN_WAVE, norm_freq, 1.0, 0.0 )

            self.connect(ofdm_blocks, (frequency_shift, 0))
            self.connect(freq_offset, (frequency_shift, 1))
            self.connect(frame_start, blocks.delay(gr.sizeof_char, 0),
                         (frequency_shift, 2))

            #self.connect(frequency_shift,s2help)
            #ofdm_blocks = s2help
            ofdm_blocks = frequency_shift
        #terminate_stream(self, frequency_shift)

        #inner_pb_filt = self._inner_pilot_block_filter = fbmc_inner_pilot_block_filter()
        #self.connect(ofdm_blocks,inner_pb_filt)
        #self.connect(frame_start,(inner_pb_filt,1))
        #self.connect((inner_pb_filt,1),blocks.null_sink(gr.sizeof_char))

        #ofdm_blocks = (inner_pb_filt,0)

        overlap_ser_to_par = ofdm.fbmc_overlapping_serial_to_parallel_cvc(
            fft_length)
        self.separate_vcvc = ofdm.fbmc_separate_vcvc(fft_length, 2)
        self.polyphase_network_vcvc_1 = ofdm.fbmc_polyphase_network_vcvc(
            fft_length, 4, 4 * fft_length - 1, True)
        self.polyphase_network_vcvc_2 = ofdm.fbmc_polyphase_network_vcvc(
            fft_length, 4, 4 * fft_length - 1, True)
        self.junction_vcvc = ofdm.fbmc_junction_vcvc(fft_length, 2)
        self.fft_fbmc = fft_blocks.fft_vcc(fft_length, True, [], True)

        print "config.training_data.fbmc_no_preambles: ", config.training_data.fbmc_no_preambles
        #center_preamble = [1, -1j, -1, 1j]

        #self.preamble = preamble = [0]*total_subc + center_preamble*((int)(total_subc/len(center_preamble)))+[0]*total_subc

        self.preamble = preamble = config.training_data.fbmc_pilotsym_fd_list
        #inv_preamble = 1. / numpy.array(self.preamble)
        #print "self.preamble: ", len(self.preamble
        #print "inv_preamble: ", list(inv_preamble)

        #print "self.preamble", self.preamble
        #print "self.preamble2", self.preamble2

        self.multiply_const = ofdm.multiply_const_vcc(
            ([1.0 / (math.sqrt(fft_length * 0.6863))] * total_subc))
        self.beta_multiplier_vcvc = ofdm.fbmc_beta_multiplier_vcvc(
            total_subc, 4, 4 * fft_length - 1, 0)
        #self.skiphead = blocks.skiphead(gr.sizeof_gr_complex*total_subc, 2*4-1-1)
        self.skiphead = blocks.skiphead(gr.sizeof_gr_complex * total_subc, 2)
        self.skiphead_1 = blocks.skiphead(gr.sizeof_gr_complex * total_subc, 0)
        #self.remove_preamble_vcvc = ofdm.fbmc_remove_preamble_vcvc(total_subc, config.frame_data_part/2, config.training_data.fbmc_no_preambles*total_subc/2)
        #self.subchannel_processing_vcvc = ofdm.fbmc_subchannel_processing_vcvc(total_subc, config.frame_data_part, 1, 2, 1, 0)
        self.oqam_postprocessing_vcvc = ofdm.fbmc_oqam_postprocessing_vcvc(
            total_subc, 0, 0)

        #log_to_file( self, ofdm_blocks, "data/PRE_FBMC.compl" )
        #log_to_file( self, self.fft_fbmc, "data/FFT_FBMC.compl" )

        if options.ideal is False and options.ideal2 is False:
            self.subchannel_processing_vcvc = ofdm.fbmc_subchannel_processing_vcvc(
                total_subc, config.frame_data_part, 3, 2, 1, 0)
            help2 = blocks.keep_one_in_n(gr.sizeof_gr_complex * total_subc,
                                         frame_length)
            self.connect((self.subchannel_processing_vcvc, 1), help2)
            #log_to_file( self, self.subchannel_processing_vcvc, "data/fbmc_subc.compl" )

        #terminate_stream(self, help2)

        if options.ideal is False and options.ideal2 is False:
            self.connect(
                ofdm_blocks,
                blocks.vector_to_stream(gr.sizeof_gr_complex, fft_length),
                overlap_ser_to_par)
        else:
            self.connect(ofdm_blocks, overlap_ser_to_par)

        self.connect(overlap_ser_to_par, self.separate_vcvc)
        self.connect((self.separate_vcvc, 1),
                     (self.polyphase_network_vcvc_2, 0))
        self.connect((self.separate_vcvc, 0),
                     (self.polyphase_network_vcvc_1, 0))
        self.connect((self.polyphase_network_vcvc_1, 0),
                     (self.junction_vcvc, 0))
        self.connect((self.polyphase_network_vcvc_2, 0),
                     (self.junction_vcvc, 1))
        self.connect(self.junction_vcvc, self.fft_fbmc)

        ofdm_blocks = self.fft_fbmc
        print "config.dc_null: ", config.dc_null
        if fft_length > data_subc:
            subcarrier_mask_fbmc = ofdm.vector_mask_dc_null(
                fft_length, virtual_subc / 2, total_subc, config.dc_null, [])
            self.connect(ofdm_blocks, subcarrier_mask_fbmc)
            ofdm_blocks = subcarrier_mask_fbmc
            #log_to_file(self, ofdm_blocks, "data/vec_mask.compl")
            ## Least Squares estimator for channel transfer function (CTF)
            #log_to_file( self, subcarrier_mask, "data/OFDM_Blocks.compl" )

        self.connect(ofdm_blocks, self.beta_multiplier_vcvc)

        ofdm_blocks = self.beta_multiplier_vcvc
        #self.connect(ofdm_blocks,self.multiply_const)
        #self.connect(self.multiply_const, (self.skiphead, 0))

        self.connect(ofdm_blocks, (self.skiphead, 0))
        #log_to_file( self, self.skiphead, "data/fbmc_skiphead_4.compl" )

        #self.connect(ofdm_blocks, self.multiply_const)
        #self.connect(self.multiply_const, self.beta_multiplier_vcvc)
        #self.connect((self.beta_multiplier_vcvc, 0), (self.skiphead, 0))
        if options.ideal or options.ideal2:
            self.connect((self.skiphead, 0), (self.skiphead_1, 0))
        else:
            self.connect((self.skiphead, 0),
                         (self.subchannel_processing_vcvc, 0))
            self.connect((self.subchannel_processing_vcvc, 0),
                         (self.skiphead_1, 0))

        #log_to_file( self, self.skiphead, "data/fbmc_subc.compl" )
        #self.connect((self.skiphead_1, 0),(self.remove_preamble_vcvc, 0))
        #self.connect((self.remove_preamble_vcvc, 0),  (self.oqam_postprocessing_vcvc, 0))

        #ofdm_blocks = self.oqam_postprocessing_vcvc
        #log_to_file( self, self.subchannel_processing_vcvc, "data/subc_0.compl" )
        #log_to_file( self, (self.subchannel_processing_vcvc,1), "data/subc_1.compl" )

        self.connect((self.skiphead_1, 0), (self.oqam_postprocessing_vcvc, 0))
        #self.connect((self.oqam_postprocessing_vcvc, 0), (self.remove_preamble_vcvc, 0) )

        ofdm_blocks = (self.oqam_postprocessing_vcvc, 0
                       )  #(self.remove_preamble_vcvc, 0)
        #log_to_file( self, (self.oqam_postprocessing_vcvc, 0), "data/fbmc_before_remove.compl" )

        #log_to_file( self, self.skiphead, "data/SKIP_HEAD_FBMC.compl" )
        #log_to_file( self, self.beta_multiplier_vcvc, "data/BETA_REC_FBMC.compl" )
        #log_to_file( self, self.oqam_postprocessing_vcvc, "data/REC_OUT_FBMC.compl" )
        """ DISABLED OFDM CHANNEL ESTIMATION PREMBLE -> CORRECT LATER to compare FBMC and OFDM channel estimation
    #TAKING THE CHANNEL ESTIMATION PREAMBLE
    chest_pre_trigger = blocks.delay( gr.sizeof_char, 3 )
    sampled_chest_preamble = ofdm.vector_sampler( gr.sizeof_gr_complex * fft_length/2, 2 )
      
    self.connect( frame_start,       chest_pre_trigger )
    self.connect( chest_pre_trigger, ( sampled_chest_preamble, 1 ) )
    self.connect( frequency_shift,       ( sampled_chest_preamble, 0 ) )
    #ofdm_blocks = sampled_chest_preamble
    
        
    ## FFT
    fft = fft_blocks.fft_vcc( fft_length, True, [], True )
    self.connect( sampled_chest_preamble, fft )
    ofdm_blocks_est = fft
    log_to_file( self, sampled_chest_preamble, "data/SAMPLED_EST_PREAMBLE.compl" )
    log_to_file( self, ofdm_blocks_est, "data/FFT.compl" )
    
    
    ## Remove virtual subcarriers
    if fft_length > data_subc:
      subcarrier_mask = ofdm.vector_mask( fft_length, virtual_subc/2,
                                           total_subc, [] )
      self.connect( ofdm_blocks_est, subcarrier_mask )
      ofdm_blocks_est = subcarrier_mask
      #log_to_file(self, ofdm_blocks, "data/vec_mask.compl")
       ## Least Squares estimator for channel transfer function (CTF)
      log_to_file( self, subcarrier_mask, "data/OFDM_Blocks.compl" )
    
          
    ## post-FFT processing
      
    
    
    ## extract channel estimation preamble from frame
    ##chest_pre_trigger = blocks.delay( gr.sizeof_char, 
                                  ##1 )
    ##sampled_chest_preamble = \
     ## ofdm.vector_sampler( gr.sizeof_gr_complex * total_subc, 1 )
    ##self.connect( frame_start,       chest_pre_trigger )
    ##self.connect( chest_pre_trigger, ( sampled_chest_preamble, 1 ) )
    ##self.connect( ofdm_blocks,       ( sampled_chest_preamble, 0 ) )
    

    
    ## Least Squares estimator for channel transfer function (CTF)
    inv_preamble_fd = numpy.array( block_header.pilotsym_fd[ 
        block_header.channel_estimation_pilot[0] ] )
    #print "Channel estimation pilot: ", inv_preamble_fd
    inv_preamble_fd = 1. / inv_preamble_fd
    
    LS_channel_estimator = ofdm.multiply_const_vcc( list( inv_preamble_fd ) )
    self.connect( ofdm_blocks_est, LS_channel_estimator )
    estimated_CTF = LS_channel_estimator
    terminate_stream(self,estimated_CTF)
    """
        if options.ideal is False and options.ideal2 is False:
            if options.logcir:
                log_to_file(self, sampled_chest_preamble, "data/PREAM.compl")

            if not options.disable_ctf_enhancer:

                if options.logcir:
                    ifft1 = fft_blocks.fft_vcc(total_subc, False, [], True)
                    self.connect(
                        estimated_CTF, ifft1,
                        gr.null_sink(gr.sizeof_gr_complex * total_subc))
                    summ1 = ofdm.vector_sum_vcc(total_subc)
                    c2m = gr.complex_to_mag(total_subc)
                    self.connect(estimated_CTF, summ1,
                                 gr.null_sink(gr.sizeof_gr_complex))
                    self.connect(estimated_CTF, c2m,
                                 gr.null_sink(gr.sizeof_float * total_subc))
                    log_to_file(self, ifft1, "data/CIR1.compl")
                    log_to_file(self, summ1, "data/CTFsumm1.compl")
                    log_to_file(self, estimated_CTF, "data/CTF1.compl")
                    log_to_file(self, c2m, "data/CTFmag1.float")

                ## MSE enhancer
                ctf_mse_enhancer = ofdm.CTF_MSE_enhancer(
                    total_subc, cp_length + cp_length)
                self.connect(estimated_CTF, ctf_mse_enhancer)
                #      log_to_file( self, ctf_mse_enhancer, "data/ctf_mse_enhancer_original.compl")
                #ifft3 = fft_blocks.fft_vcc(total_subc,False,[],True)
                #null_noise = ofdm.noise_nulling(total_subc, cp_length + cp_length)
                #ctf_mse_enhancer = fft_blocks.fft_vcc(total_subc,True,[],True)
                #ctf_mse_enhancer = ofdm.vector_mask( fft_length, virtual_subc/2,
                # total_subc, [] )
                #self.connect( estimated_CTF, ifft3,null_noise,ctf_mse_enhancer )

                estimated_CTF = ctf_mse_enhancer
                print "Disabled CTF MSE enhancer"

            if options.logcir:
                ifft2 = fft_blocks.fft_vcc(total_subc, False, [], True)
                self.connect(estimated_CTF, ifft2,
                             gr.null_sink(gr.sizeof_gr_complex * total_subc))
                summ2 = ofdm.vector_sum_vcc(total_subc)
                c2m2 = gr.complex_to_mag(total_subc)
                self.connect(estimated_CTF, summ2,
                             gr.null_sink(gr.sizeof_gr_complex))
                self.connect(estimated_CTF, c2m2,
                             gr.null_sink(gr.sizeof_float * total_subc))
                log_to_file(self, ifft2, "data/CIR2.compl")
                log_to_file(self, summ2, "data/CTFsumm2.compl")
                log_to_file(self, estimated_CTF, "data/CTF2.compl")
                log_to_file(self, c2m2, "data/CTFmag2.float")

            ## Postprocess the CTF estimate
            ## CTF -> inverse CTF (for equalizer)
            ## CTF -> norm |.|^2 (for CTF display)
            ctf_postprocess = ofdm.fbmc_postprocess_CTF_estimate(total_subc)

            self.connect(help2, ctf_postprocess)
            #estimated_SNR = ( ctf_postprocess, 0 )
            disp_CTF = (ctf_postprocess, 0)
            #self.connect(estimated_SNR,out_snr_pream)
            #log_to_file( self, estimated_SNR, "data/fbmc_SNR.float" )

            #Disable measured SNR output
            #terminate_stream(self, estimated_SNR)
            #self.connect(blocks.vector_source_f([10.0],True) ,out_snr_pream)


#     if options.disable_equalization or options.ideal:
#       terminate_stream(self, inv_estimated_CTF)
#       inv_estimated_CTF_vec = blocks.vector_source_c([1.0/fft_length*math.sqrt(total_subc)]*total_subc,True,total_subc)
#       inv_estimated_CTF_str = blocks.vector_to_stream(gr.sizeof_gr_complex, total_subc)
#       self.inv_estimated_CTF_mul = ofdm.multiply_const_ccf( 1.0/config.rms_amplitude )
#       #inv_estimated_CTF_mul.set_k(1.0/config.rms_amplitude)
#       inv_estimated_CTF = blocks.stream_to_vector(gr.sizeof_gr_complex, total_subc)
#       self.connect( inv_estimated_CTF_vec, inv_estimated_CTF_str, self.inv_estimated_CTF_mul, inv_estimated_CTF)
#       print "Disabled equalization stage"
        '''
    ## LMS Phase tracking
    ## Track residual frequency offset and sampling clock frequency offset

    nondata_blocks = []
    for i in range(config.frame_length):
      if i in config.training_data.pilotsym_pos:
        nondata_blocks.append(i)
        
    print"\t\t\t\t\tnondata_blocks=",nondata_blocks
    pilot_subc = block_header.pilot_tones
    pilot_subcarriers = block_header.pilot_subc_sym
    print "PILOT SUBCARRIERS: ", pilot_subcarriers
        
    phase_tracking = ofdm.lms_phase_tracking_03( total_subc, pilot_subc,
                                               nondata_blocks, pilot_subcarriers,0 )
    self.connect( ofdm_blocks, ( phase_tracking, 0 ) )
    self.connect( inv_estimated_CTF, ( phase_tracking, 1 ) )
    self.connect( frame_start, ( phase_tracking, 2 ) ) ##
    
    if options.scatter_plot_before_phase_tracking:
      self.before_phase_tracking = equalizer
      
    
    if options.disable_phase_tracking or options.ideal:
      terminate_stream(self, phase_tracking)
      print "Disabled phase tracking stage"
    else:
      ofdm_blocks = phase_tracking
    '''
        ## Channel Equalizer
        ##equalizer = ofdm.channel_equalizer( total_subc )
        ##self.connect( ofdm_blocks,       ( equalizer, 0 ) )
        ##self.connect( inv_estimated_CTF, ( equalizer, 1 ) )
        ##self.connect( frame_start,       ( equalizer, 2 ) )
        ##ofdm_blocks = equalizer
        #log_to_file(self, equalizer,"data/equalizer_siso.compl")

        #log_to_file(self, ofdm_blocks, "data/equalizer.compl")

        ## LMS Phase tracking
        ## Track residual frequency offset and sampling clock frequency offset

        nondata_blocks = []
        for i in range(config.frame_length):
            if i in config.training_data.pilotsym_pos:
                nondata_blocks.append(i)

        print "\t\t\t\t\tnondata_blocks=", nondata_blocks
        pilot_subc = block_header.pilot_tones
        pilot_subcarriers = block_header.pilot_subc_sym
        print "PILOT SUBCARRIERS: ", pilot_subcarriers

        if options.scatter_plot_before_phase_tracking:
            self.before_phase_tracking = equalizer

        ## Output connections

        self.connect(ofdm_blocks, out_ofdm_blocks)
        self.connect(frame_start, out_frame_start)
        if options.ideal is False and options.ideal2 is False:
            self.connect(disp_CTF, out_disp_ctf)
        else:
            self.connect(blocks.vector_source_f([1.0] * total_subc),
                         blocks.stream_to_vector(gr.sizeof_float, total_subc),
                         out_disp_ctf)

        if log:
            log_to_file(self, sc_metric, "data/sc_metric.float")
            log_to_file(self, gi_metric, "data/gi_metric.float")
            log_to_file(self, morelli_foe, "data/morelli_foe.float")
            log_to_file(self, lms_fir, "data/lms_fir.float")
            log_to_file(self, sampler_preamble, "data/preamble.compl")
            log_to_file(self, sync, "data/sync.compl")
            log_to_file(self, frequency_shift, "data/frequency_shift.compl")
            log_to_file(self, fft, "data/fft.compl")
            log_to_file(self, fft, "data/fft.float", mag=True)

            if vars().has_key('subcarrier_mask'):
                log_to_file(self, subcarrier_mask,
                            "data/subcarrier_mask.compl")

            log_to_file(self, ofdm_blocks, "data/ofdm_blocks_out.compl")
            log_to_file(self,
                        frame_start,
                        "data/frame_start.float",
                        char_to_float=True)

            log_to_file(self, sampled_chest_preamble,
                        "data/sampled_chest_preamble.compl")
            log_to_file(self, LS_channel_estimator,
                        "data/ls_channel_estimator.compl")
            log_to_file(self,
                        LS_channel_estimator,
                        "data/ls_channel_estimator.float",
                        mag=True)

            if "ctf_mse_enhancer" in locals():
                log_to_file(self, ctf_mse_enhancer,
                            "data/ctf_mse_enhancer.compl")
                log_to_file(self,
                            ctf_mse_enhancer,
                            "data/ctf_mse_enhancer.float",
                            mag=True)

            log_to_file(self, (ctf_postprocess, 0),
                        "data/inc_estimated_ctf.compl")
            log_to_file(self, (ctf_postprocess, 1), "data/disp_ctf.float")

            log_to_file(self, equalizer, "data/equalizer.compl")
            log_to_file(self, equalizer, "data/equalizer.float", mag=True)

            log_to_file(self, phase_tracking, "data/phase_tracking.compl")
Beispiel #33
0
    def __init__(self):
        gr.top_block.__init__(self, "Noaa Apt")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Noaa Apt")
        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", "noaa_apt")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 300e3
        self.fcarrier_i = fcarrier_i = 47.4e3
        self.fcarrier_d = fcarrier_d = 41.3e3
        self.fcarrier = fcarrier = -73.18e3
        self.ch_rate = ch_rate = 96e3

        ##################################################
        # Blocks
        ##################################################
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, 'RF Input')
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, 'Subcarrier')
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, 'Image Scan Line')
        self.top_layout.addWidget(self.tab)
        self.rational_resampler_xxx_3 = filter.rational_resampler_fff(
            interpolation=11025,
            decimation=int(ch_rate),
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_2 = filter.rational_resampler_fff(
            interpolation=4160,
            decimation=4800,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_1 = filter.rational_resampler_fff(
            interpolation=1,
            decimation=10,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=int(ch_rate),
            decimation=int(samp_rate),
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            8192,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            ch_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(False)

        if not False:
            self.qtgui_waterfall_sink_x_0.disable_legend()

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

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

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-110, -30)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win, 1,
                                         0, 1, 1)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
            2048,  #size
            4160,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-200, 400)

        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(True)
        self.qtgui_time_sink_x_1.enable_axis_labels(False)
        self.qtgui_time_sink_x_1.enable_control_panel(False)

        if not False:
            self.qtgui_time_sink_x_1.disable_legend()

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

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

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.tab_layout_2.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            4096,  #size
            ch_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-8, 8)

        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(True)
        self.qtgui_time_sink_x_0.enable_axis_labels(False)
        self.qtgui_time_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0, 0,
                                         1, 1)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_f(
            4096,  #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(-80, 0)
        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(True)
        self.qtgui_freq_sink_x_1.set_fft_average(0.1)
        self.qtgui_freq_sink_x_1.enable_axis_labels(False)
        self.qtgui_freq_sink_x_1.enable_control_panel(False)

        if not False:
            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 False)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in 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.tab_grid_layout_1.addWidget(self._qtgui_freq_sink_x_1_win, 1, 0,
                                         1, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            4096,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            ch_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-120, -20)
        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(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.05)
        self.qtgui_freq_sink_x_0.enable_axis_labels(False)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0,
                                         1, 1)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (1, ), fcarrier, samp_rate)
        self.fft_filter_xxx_0 = filter.fft_filter_fff(
            1, (firdes.low_pass(1, ch_rate, 4800, 1200, firdes.WIN_BLACKMAN)),
            1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink(
            'aptfull2.wav', 1, 11025, 16)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_float * 1, 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff(
            (1.0 / 20, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((50, ))
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            100000, 1e-5, 4000)
        self.blocks_keep_one_in_n_1 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, 2)
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, 2)
        self.blocks_float_to_uchar_0 = blocks.float_to_uchar()
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            '/home/handiko/gqrx_20180412_230748_137696953_300000_fc.raw',
            False)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.analog_rail_ff_0 = analog.rail_ff(0, 255)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            ch_rate / (2 * math.pi * (40e3) / 8.0))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.blocks_sub_xx_0, 0))
        self.connect((self.analog_rail_ff_0, 0),
                     (self.blocks_float_to_uchar_0, 0))
        self.connect((self.analog_rail_ff_0, 0), (self.qtgui_time_sink_x_1, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.rational_resampler_xxx_2, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_float_to_uchar_0, 0),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_keep_one_in_n_1, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.analog_rail_ff_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_wavfile_sink_0, 0))
        self.connect((self.blocks_skiphead_0, 0),
                     (self.blocks_keep_one_in_n_1, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.fft_filter_xxx_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.fft_filter_xxx_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.fft_filter_xxx_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.fft_filter_xxx_0, 0),
                     (self.rational_resampler_xxx_3, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.blocks_skiphead_0, 0))
        self.connect((self.rational_resampler_xxx_2, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.rational_resampler_xxx_3, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
Beispiel #34
0
    def __init__(self, demod_rate, audio_decimation, deemph_tau):
        """
        Hierarchical block for demodulating a broadcast FM signal.

        The input is the downconverted complex baseband signal (gr_complex).
        The output is two streams of the demodulated audio (float) 0=Left, 1=Right.

        Args:
            demod_rate: input sample rate of complex baseband input. (float)
            audio_decimation: how much to decimate demod_rate to get to audio. (integer)
            deemph_tau: deemphasis ime constant in seconds (75us in US, 50us in EUR). (float)
        """
        gr.hier_block2.__init__(self, "wfm_rcv_pll",
                                # Input signature
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(2, 2, gr.sizeof_float))      # Output signature

        if audio_decimation != int(audio_decimation):
            raise ValueError("audio_decimation needs to be an integer")
        audio_decimation = int(audio_decimation)

        ##################################################
        # Variables
        ##################################################
        self.demod_rate = demod_rate
        self.deemph_tau = deemph_tau
        self.stereo_carrier_filter_coeffs = stereo_carrier_filter_coeffs = firdes.band_pass(
            -2.0, demod_rate, 37600, 38400, 400, fft.window.WIN_HAMMING, 6.76)
        self.pilot_carrier_filter_coeffs = pilot_carrier_filter_coeffs = firdes.complex_band_pass(
            1.0, demod_rate, 18980, 19020, 1500, fft.window.WIN_HAMMING, 6.76)
        self.deviation = deviation = 75000
        self.audio_filter_coeffs = audio_filter_coeffs = firdes.low_pass(
            1, demod_rate, 15000, 1500, fft.window.WIN_HAMMING, 6.76)
        self.audio_decim = audio_decim = audio_decimation
        self.audio_rate = audio_rate = demod_rate / audio_decim
        self.samp_delay = samp_delay = (len(
            pilot_carrier_filter_coeffs) - 1) // 2 + (len(stereo_carrier_filter_coeffs) - 1) // 2

        ##################################################
        # Blocks
        ##################################################
        self.pilot_carrier_bpf = filter.fir_filter_fcc(
            1, pilot_carrier_filter_coeffs)
        self.pilot_carrier_bpf.declare_sample_delay(0)
        self.stereo_carrier_bpf = filter.fft_filter_fff(
            1, stereo_carrier_filter_coeffs, 1)
        self.stereo_carrier_bpf.declare_sample_delay(0)
        self.stereo_audio_lpf = filter.fft_filter_fff(
            audio_decim, audio_filter_coeffs, 1)
        self.stereo_audio_lpf.declare_sample_delay(0)
        self.mono_audio_lpf = filter.fft_filter_fff(
            audio_decim, audio_filter_coeffs, 1)
        self.mono_audio_lpf.declare_sample_delay(0)
        self.blocks_stereo_multiply = blocks.multiply_ff(1)
        self.blocks_pilot_multiply = blocks.multiply_cc(1)
        self.blocks_complex_to_imag = blocks.complex_to_imag(1)
        self.blocks_right_sub = blocks.sub_ff(1)
        self.blocks_left_add = blocks.add_ff(1)
        self.analog_quadrature_demod_cf = analog.quadrature_demod_cf(
            demod_rate / (2 * math.pi * deviation))
        self.analog_pll_refout_cc = analog.pll_refout_cc(
            0.001, 2 * math.pi * 19200 / demod_rate, 2 * math.pi * 18800 / demod_rate)
        self.analog_right_fm_deemph = analog.fm_deemph(
            fs=audio_rate, tau=deemph_tau)
        self.analog_left_fm_deemph = analog.fm_deemph(
            fs=audio_rate, tau=deemph_tau)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, samp_delay)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_left_fm_deemph, 0), (self, 0))
        self.connect((self.analog_right_fm_deemph, 0), (self, 1))
        self.connect((self.analog_pll_refout_cc, 0),
                     (self.blocks_pilot_multiply, 1))
        self.connect((self.analog_pll_refout_cc, 0),
                     (self.blocks_pilot_multiply, 0))
        self.connect((self.analog_quadrature_demod_cf, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_stereo_multiply, 0))
        self.connect((self.blocks_delay_0, 0), (self.mono_audio_lpf, 0))
        self.connect((self.analog_quadrature_demod_cf, 0),
                     (self.pilot_carrier_bpf, 0))
        self.connect((self.blocks_left_add, 0),
                     (self.analog_left_fm_deemph, 0))
        self.connect((self.blocks_right_sub, 0),
                     (self.analog_right_fm_deemph, 0))
        self.connect((self.blocks_complex_to_imag, 0),
                     (self.stereo_carrier_bpf, 0))
        self.connect((self.blocks_pilot_multiply, 0),
                     (self.blocks_complex_to_imag, 0))
        self.connect((self.blocks_stereo_multiply, 0),
                     (self.stereo_audio_lpf, 0))  # L - R path
        self.connect((self.mono_audio_lpf, 0), (self.blocks_left_add, 1))
        self.connect((self.mono_audio_lpf, 0), (self.blocks_right_sub, 0))
        self.connect((self.stereo_audio_lpf, 0), (self.blocks_left_add, 0))
        self.connect((self.stereo_audio_lpf, 0), (self.blocks_right_sub, 1))
        self.connect((self.stereo_carrier_bpf, 0),
                     (self.blocks_stereo_multiply, 1))
        self.connect((self.pilot_carrier_bpf, 0),
                     (self.analog_pll_refout_cc, 0))
        self.connect((self, 0), (self.analog_quadrature_demod_cf, 0))
Beispiel #35
0
    def __init__(self):
        gr.top_block.__init__(self, "APRS Symbol Recovery")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("APRS Symbol Recovery")
        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", "aprs_symbol_recov")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.ch_rate = ch_rate = 48e3
        self.bb_rate = bb_rate = 192e3
        self.afsk_spec = afsk_spec = [1200, 1200, 2200]
        self.thresh = thresh = -50*2
        self.samp_rate = samp_rate = 2.88e6
        self.rfgain = rfgain = 10
        self.out_sps = out_sps = 2
        self.in_sps = in_sps = int(ch_rate) / afsk_spec[0]
        self.gain_mu = gain_mu = 0.175
        self.freq = freq = 144.39e6
        self.dev_ppm = dev_ppm = 52
        self.bb_decim = bb_decim = int(bb_rate)/int(ch_rate)
        self.afgain = afgain = -7

        ##################################################
        # Blocks
        ##################################################
        self._rfgain_range = Range(0, 49, 1, 10, 100)
        self._rfgain_win = RangeWidget(self._rfgain_range, self.set_rfgain, 'RF Gain (dB)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._rfgain_win, 3,0,1,1)
        self.show_text_2 = display.show_text()
        self._show_text_2_win = sip.wrapinstance(self.show_text_2.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._show_text_2_win, 2,2,2,1)
        self.show_text_0 = display.show_text()
        self._show_text_0_win = sip.wrapinstance(self.show_text_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._show_text_0_win, 2,0,1,2)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
        	4096, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	192e3, #bw
        	"", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(False)
        
        if not False:
          self.qtgui_waterfall_sink_x_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        colors = [6, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])
        
        self.qtgui_waterfall_sink_x_0.set_intensity_range(-105, -20)
        
        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 0,2,1,1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	1024, #size
        	1200, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-4.2, 4.2)
        
        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")
        
        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(True)
        self.qtgui_time_sink_x_0.enable_axis_labels(False)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        
        if not False:
          self.qtgui_time_sink_x_0.disable_legend()
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [2, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 1,0,1,3)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	2048, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	144.39e6, #fc
        	192e3, #bw
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-120, -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(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0.enable_axis_labels(False)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)
        
        if not False:
          self.qtgui_freq_sink_x_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [2, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [0.8, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0,0,1,2)
        self.pfb_decimator_ccf_0_0 = pfb.decimator_ccf(
        	  int(samp_rate / ch_rate),
        	  (),
        	  0,
        	  100,
                  True,
                  True)
        self.pfb_decimator_ccf_0_0.declare_sample_delay(0)
        	
        self.pfb_decimator_ccf_0 = pfb.decimator_ccf(
        	  int(samp_rate / bb_rate),
        	  (),
        	  0,
        	  100,
                  True,
                  True)
        self.pfb_decimator_ccf_0.declare_sample_delay(0)
        	
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(dev_ppm, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(rfgain, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
          
        self.hdlc_to_ax25 = hdlc_to_ax25.blk()
        self.fsk_demod_0 = fsk_demod(
            baud=afsk_spec[0],
            fsk_hi_tone=afsk_spec[2],
            fsk_lo_tone=afsk_spec[1],
            in_sps=in_sps,
            out_sps=out_sps,
        )
        self.fft_filter_xxx_1 = filter.fft_filter_fff(1, (firdes.band_pass(1,ch_rate,400,5e3,400,firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_1.declare_sample_delay(0)
        self.digital_hdlc_deframer_bp_0 = digital.hdlc_deframer_bp(32, 500)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(out_sps*(1+0.0), 0.25*gain_mu*gain_mu, 0.5, gain_mu, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", '', '52001', 10000, False)
        self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
        self.blocks_not_xx_0 = blocks.not_bb()
        self.blocks_and_const_xx_0 = blocks.and_const_bb(1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(ch_rate/(2*math.pi*12e3/8.0))
        self.afsk_afsk1200_0 = afsk.afsk1200(int(ch_rate),4)
        self._afgain_range = Range(-20, -1, 0.1, -7, 100)
        self._afgain_win = RangeWidget(self._afgain_range, self.set_afgain, 'AF Gain (dB)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._afgain_win, 3,1,1,1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.digital_hdlc_deframer_bp_0, 'out'), (self.hdlc_to_ax25, 'hdlc in'))    
        self.msg_connect((self.hdlc_to_ax25, 'ax25 out'), (self.blocks_pdu_to_tagged_stream_1, 'pdus'))    
        self.msg_connect((self.hdlc_to_ax25, 'ax25 out'), (self.blocks_socket_pdu_0, 'pdus'))    
        self.connect((self.afsk_afsk1200_0, 0), (self.show_text_2, 0))    
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.fft_filter_xxx_1, 0))    
        self.connect((self.blocks_and_const_xx_0, 0), (self.digital_hdlc_deframer_bp_0, 0))    
        self.connect((self.blocks_not_xx_0, 0), (self.blocks_and_const_xx_0, 0))    
        self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.show_text_0, 0))    
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_diff_decoder_bb_0, 0))    
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))    
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.qtgui_time_sink_x_0, 0))    
        self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_not_xx_0, 0))    
        self.connect((self.fft_filter_xxx_1, 0), (self.afsk_afsk1200_0, 0))    
        self.connect((self.fft_filter_xxx_1, 0), (self.fsk_demod_0, 0))    
        self.connect((self.fsk_demod_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.pfb_decimator_ccf_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.pfb_decimator_ccf_0_0, 0))    
        self.connect((self.pfb_decimator_ccf_0, 0), (self.qtgui_freq_sink_x_0, 0))    
        self.connect((self.pfb_decimator_ccf_0, 0), (self.qtgui_waterfall_sink_x_0, 0))    
        self.connect((self.pfb_decimator_ccf_0_0, 0), (self.analog_quadrature_demod_cf_0, 0))    
Beispiel #36
0
    def __init__(self):
        gr.top_block.__init__(self, "APRS S-Gate")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("APRS S-Gate")
        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", "aprs_satgate")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.freq = freq = 145.825e6
        self.variable_qtgui_label_0 = variable_qtgui_label_0 = int(freq)
        self.samp_rate = samp_rate = 2.4e6
        
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(4, 48000, 1200, 0.35, 16*48000/1200)
          
        self.rfgain = rfgain = 35
        self.audio_mute = audio_mute = True
        self.afgain = afgain = -7

        ##################################################
        # Blocks
        ##################################################
        self._rfgain_range = Range(0, 49, 1, 35, 200)
        self._rfgain_win = RangeWidget(self._rfgain_range, self.set_rfgain, 'RF Gain (dB)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._rfgain_win, 3,0,1,1)
        self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self)
        
        if None:
          self._variable_qtgui_label_0_formatter = None
        else:
          self._variable_qtgui_label_0_formatter = lambda x: x
        
        self._variable_qtgui_label_0_tool_bar.addWidget(Qt.QLabel('Freq (Hz)'+": "))
        self._variable_qtgui_label_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_formatter(self.variable_qtgui_label_0)))
        self._variable_qtgui_label_0_tool_bar.addWidget(self._variable_qtgui_label_0_label)
        self.top_grid_layout.addWidget(self._variable_qtgui_label_0_tool_bar, 4,0,1,1)
          
        self.show_text_2 = display.show_text()
        self._show_text_2_win = sip.wrapinstance(self.show_text_2.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._show_text_2_win, 2,2,2,1)
        self.show_text_0 = display.show_text()
        self._show_text_0_win = sip.wrapinstance(self.show_text_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._show_text_0_win, 2,0,1,2)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
        	4096, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	192e3, #bw
        	"", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(False)
        
        if not False:
          self.qtgui_waterfall_sink_x_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        colors = [6, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])
        
        self.qtgui_waterfall_sink_x_0.set_intensity_range(-105, -20)
        
        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 0,2,1,1)
        self.qtgui_time_sink_x_2 = qtgui.time_sink_f(
        	2048, #size
        	1200, #samp_rate
        	"", #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(-4, 4)
        
        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(True)
        self.qtgui_time_sink_x_2.enable_axis_labels(False)
        self.qtgui_time_sink_x_2.enable_control_panel(False)
        
        if not False:
          self.qtgui_time_sink_x_2.disable_legend()
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [2, 2, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "blue", "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 = [0.7, 0.7, 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, 1,0,1,3)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	2048, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	144.39e6, #fc
        	192e3, #bw
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-120, -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(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0.enable_axis_labels(False)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)
        
        if not False:
          self.qtgui_freq_sink_x_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [2, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["red", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [0.8, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0,0,1,2)
        self.igate_aprs_pkt_gen_0 = igate.aprs_pkt_gen(120, 'YD1SDL-10', 'APGRC', 'WIDE2-2', 240, 3, '!0745.80S/11022.51E` Temporary / Experimental APRS I/S-Gate')
        self.igate_aprs_is_sink_0 = igate.aprs_is_sink('rotate.aprs.net', 14580, 'YD1SDL-10', 24505)
        self.igate_aprs_demod_0 = igate.aprs_demod(48000)
        self.gpredict_doppler_0 = gpredict.doppler(self.set_freq, "localhost", 4532, True)
        self.fft_filter_xxx_3 = filter.fft_filter_fff(1, (firdes.band_pass(0.5,48e3,1e3,2400,1e2,firdes.WIN_HAMMING)), 1)
        self.fft_filter_xxx_3.declare_sample_delay(0)
        self.fft_filter_xxx_2 = filter.fft_filter_fff(2, (firdes.band_pass(0.25,48e3,400,2500,500,firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_2.declare_sample_delay(0)
        self.fft_filter_xxx_1 = filter.fft_filter_fff(1, (rrc_taps), 1)
        self.fft_filter_xxx_1.declare_sample_delay(0)
        self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (firdes.low_pass(1,48e3,1e3,1e2,firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_fff(48000 / 1200, 6.28 / 1000, (rrc_taps), 39, 20, 1.5, 1)
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink('IO86-wav-dump.wav', 1, 24000, 16)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_rotator_cc_0 = blocks.rotator_cc(-1700 / 48e3 * 2 * math.pi)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, 10)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(int(10e3*math.pi), 1.0/(10e3*math.pi), 4000)
        self.blocks_float_to_complex_0_0 = blocks.float_to_complex(1)
        _audio_mute_check_box = Qt.QCheckBox('Audio Mute')
        self._audio_mute_choices = {True: True, False: False}
        self._audio_mute_choices_inv = dict((v,k) for k,v in self._audio_mute_choices.iteritems())
        self._audio_mute_callback = lambda i: Qt.QMetaObject.invokeMethod(_audio_mute_check_box, "setChecked", Qt.Q_ARG("bool", self._audio_mute_choices_inv[i]))
        self._audio_mute_callback(self.audio_mute)
        _audio_mute_check_box.stateChanged.connect(lambda i: self.set_audio_mute(self._audio_mute_choices[bool(i)]))
        self.top_grid_layout.addWidget(_audio_mute_check_box, 4,1,1,1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(48e3 / (2*math.pi*1200/8.0))
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-1, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)
        self.afsk_aprs2inet_1 = afsk.aprs2inet(12000, 4)
        self.afsk_afsk1200_0 = afsk.afsk1200(48000,4)
        self._afgain_range = Range(-20, -1, 0.1, -7, 200)
        self._afgain_win = RangeWidget(self._afgain_range, self.set_afgain, 'AF Gain (dB)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._afgain_win, 3,1,1,1)
        self.RTL_APRS_RX_0 = RTL_APRS_RX(
            device_ppm=58,
            freq=freq,
            rf_gain=rfgain,
            samp_rate=samp_rate,
        )

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.igate_aprs_demod_0, 'out'), (self.igate_aprs_is_sink_0, 'in'))    
        self.msg_connect((self.igate_aprs_pkt_gen_0, 'out'), (self.igate_aprs_is_sink_0, 'in'))    
        self.connect((self.RTL_APRS_RX_0, 1), (self.fft_filter_xxx_2, 0))    
        self.connect((self.RTL_APRS_RX_0, 1), (self.fft_filter_xxx_3, 0))    
        self.connect((self.RTL_APRS_RX_0, 0), (self.qtgui_freq_sink_x_0, 0))    
        self.connect((self.RTL_APRS_RX_0, 0), (self.qtgui_waterfall_sink_x_0, 0))    
        self.connect((self.afsk_afsk1200_0, 0), (self.show_text_2, 0))    
        self.connect((self.afsk_aprs2inet_1, 0), (self.show_text_0, 0))    
        self.connect((self.analog_agc2_xx_0, 0), (self.fft_filter_xxx_0, 0))    
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_moving_average_xx_0, 0))    
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_sub_xx_0, 0))    
        self.connect((self.blocks_float_to_complex_0_0, 0), (self.blocks_rotator_cc_0, 0))    
        self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_sub_xx_0, 1))    
        self.connect((self.blocks_repeat_0, 0), (self.afsk_aprs2inet_1, 0))    
        self.connect((self.blocks_rotator_cc_0, 0), (self.analog_agc2_xx_0, 0))    
        self.connect((self.blocks_sub_xx_0, 0), (self.fft_filter_xxx_1, 0))    
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_repeat_0, 0))    
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_time_sink_x_2, 0))    
        self.connect((self.fft_filter_xxx_0, 0), (self.analog_quadrature_demod_cf_0, 0))    
        self.connect((self.fft_filter_xxx_1, 0), (self.digital_pfb_clock_sync_xxx_0, 0))    
        self.connect((self.fft_filter_xxx_2, 0), (self.blocks_wavfile_sink_0, 0))    
        self.connect((self.fft_filter_xxx_3, 0), (self.afsk_afsk1200_0, 0))    
        self.connect((self.fft_filter_xxx_3, 0), (self.blocks_float_to_complex_0_0, 0))    
        self.connect((self.fft_filter_xxx_3, 0), (self.igate_aprs_demod_0, 0))    
Beispiel #37
0
    def __init__(self):
        gr.top_block.__init__(self, "Rx Top")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Rx Top")
        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_top")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sound_card_sample_rate = sound_card_sample_rate = 44000
        self.samples_per_symbol = samples_per_symbol = 19
        self.symbol_rate = symbol_rate = sound_card_sample_rate / samples_per_symbol
        self.bits_per_symbol = bits_per_symbol = 1

        self.variable_rrc_filter_taps = variable_rrc_filter_taps = firdes.root_raised_cosine(
            1, sound_card_sample_rate, symbol_rate, 0.5, 70)

        self.bit_rate = bit_rate = symbol_rate / bits_per_symbol

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_1_2_0 = qtgui.time_sink_f(
            500,  #size
            sound_card_sample_rate,  #samp_rate
            "Filtered signal",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_2_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_2_0.set_y_axis(-1, 1)

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

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

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

        self._qtgui_time_sink_x_1_2_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_2_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_2_0_win)
        self.qtgui_time_sink_x_1_2 = qtgui.time_sink_f(
            500,  #size
            symbol_rate,  #samp_rate
            "Synchronization phase",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_2.set_update_time(0.10)
        self.qtgui_time_sink_x_1_2.set_y_axis(-1, 1)

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

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

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

        self._qtgui_time_sink_x_1_2_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_2.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_2_win)
        self.qtgui_time_sink_x_1_1 = qtgui.time_sink_f(
            500,  #size
            symbol_rate,  #samp_rate
            "Synchronization rate",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1_1.set_y_axis(-1, 1)

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

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

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

        self._qtgui_time_sink_x_1_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_1_win)
        self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f(
            500,  #size
            symbol_rate,  #samp_rate
            "Synchronization error",  #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(True)
        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)

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

        self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_0_win)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
            50,  #size
            symbol_rate,  #samp_rate
            "Received symbols",  #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(True)
        self.qtgui_time_sink_x_1.enable_grid(False)
        self.qtgui_time_sink_x_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_1.enable_control_panel(False)

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

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_sink_x_0_1 = qtgui.sink_f(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            sound_card_sample_rate,  #bw
            "sync symbols",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0_1.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_1_win)

        self.qtgui_sink_x_0_1.enable_rf_freq(False)

        self.qtgui_sink_x_0 = qtgui.sink_f(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            sound_card_sample_rate,  #bw
            "received-symbol",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_win)

        self.qtgui_sink_x_0.enable_rf_freq(False)

        self.fft_filter_xxx_0 = filter.fft_filter_fff(
            1, (variable_rrc_filter_taps), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_fff(
            samples_per_symbol, 0.5, (variable_rrc_filter_taps), 32, 0, 1.5, 1)
        self.digital_hdlc_deframer_bp_0 = digital.hdlc_deframer_bp(32, 500)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
                                                 sound_card_sample_rate, True)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(-0.01, 0.01, 0)
        self.blocks_tagged_file_sink_0 = blocks.tagged_file_sink(
            gr.sizeof_char * 1, bit_rate)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'burst')
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 1)
        self.audio_source_0 = audio.source(sound_card_sample_rate, '', True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.digital_hdlc_deframer_bp_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.connect((self.audio_source_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.audio_source_0, 0), (self.qtgui_sink_x_0, 0))
        self.connect((self.blocks_float_to_char_0, 0),
                     (self.digital_hdlc_deframer_bp_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0),
                     (self.blocks_tagged_file_sink_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_float_to_char_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.fft_filter_xxx_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.qtgui_sink_x_0_1, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.qtgui_time_sink_x_1, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 1),
                     (self.qtgui_time_sink_x_1_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 2),
                     (self.qtgui_time_sink_x_1_1, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 3),
                     (self.qtgui_time_sink_x_1_2, 0))
        self.connect((self.fft_filter_xxx_0, 0),
                     (self.qtgui_time_sink_x_1_2_0, 0))
Beispiel #38
0
    def __init__(self):
        gr.top_block.__init__(self, "RTL FM UDP - Handiko Gesang")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("RTL FM UDP - Handiko Gesang")
        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", "rtl_fm_udp")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.volume = volume = 0.0
        self.samp_rate = samp_rate = 2.88e6
        self.rfgain = rfgain = 10.0
        self.freq = freq = 104.6

        ##################################################
        # Blocks
        ##################################################
        self._volume_range = Range(-30.0, 20.0, 1.0, 0.0, 200)
        self._volume_win = RangeWidget(self._volume_range, self.set_volume,
                                       'Volume (dB)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._volume_win, 2, 1, 1, 1)
        self._rfgain_range = Range(0.0, 49.0, 0.1, 10.0, 200)
        self._rfgain_win = RangeWidget(self._rfgain_range, self.set_rfgain,
                                       'RF Gain (dB)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._rfgain_win, 2, 0, 1, 1)
        self._freq_range = Range(88.0, 108.8, 0.1, 104.6, 200)
        self._freq_win = RangeWidget(self._freq_range, self.set_freq, 'Freq',
                                     "counter_slider", float)
        self.top_grid_layout.addWidget(self._freq_win, 1, 0, 1, 2)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=int(192e3),
            decimation=int(samp_rate),
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            freq * 1e6,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-120, -20)
        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(True)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 1,
                                       2)
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               '')
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq * 1e6, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(rfgain, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.fft_filter_xxx_0 = filter.fft_filter_fff(1, (firdes.low_pass(
            0.1 *
            (pow(10.0, volume / 10.0)), 48e3, 10e3, 5e3, firdes.WIN_BLACKMAN)),
                                                      1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short * 1,
                                                 'localhost', 7355, 1472, True)
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 500)
        self.blocks_endian_swap_0 = blocks.endian_swap(2)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=192e3,
            audio_decimation=4,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_rcv_0, 0), (self.fft_filter_xxx_0, 0))
        self.connect((self.blocks_endian_swap_0, 0),
                     (self.blocks_udp_sink_0, 0))
        self.connect((self.blocks_float_to_short_0, 0),
                     (self.blocks_endian_swap_0, 0))
        self.connect((self.fft_filter_xxx_0, 0),
                     (self.blocks_float_to_short_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_wfm_rcv_0, 0))
Beispiel #39
0
    def __init__(self):
        gr.top_block.__init__(self, "Merapi Test")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Merapi Test")
        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", "merapi_test")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

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

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=10,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
            1024,  #size
            samp_rate / 100,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.01)
        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)

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

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

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

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.fft_filter_xxx_2 = filter.fft_filter_fff(1, (firdes.band_pass(
            1, samp_rate, 1360 - 300, 1360 + 300, 500, firdes.WIN_HAMMING)), 1)
        self.fft_filter_xxx_2.declare_sample_delay(0)
        self.fft_filter_xxx_0 = filter.fft_filter_fff(10, (firdes.low_pass(
            1, samp_rate / 10, 20, 20, firdes.WIN_HAMMING)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            '/home/handiko/cv.wav', True)
        self.blocks_rotator_cc_0 = blocks.rotator_cc(
            (-1360.0 / samp_rate) * 2 * math.pi)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.audio_sink_0 = audio.sink(samp_rate, '', True)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            0.1 * samp_rate / (2 * math.pi * 500 / 8.0))
        self.analog_agc_xx_0 = analog.agc_ff(1e-2, 0.1, 0.1)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.analog_agc_xx_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.analog_agc_xx_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.fft_filter_xxx_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_rotator_cc_0, 0))
        self.connect((self.blocks_rotator_cc_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.fft_filter_xxx_2, 0))
        self.connect((self.fft_filter_xxx_0, 0), (self.qtgui_time_sink_x_1, 0))
        self.connect((self.fft_filter_xxx_2, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
Beispiel #40
0
  def __init__( self, options, log = False ):
    
    ## Read configuration
    config = station_configuration()
    
    fft_length    = config.fft_length
    cp_length     = config.cp_length
    block_header  = config.training_data
    data_subc     = config.data_subcarriers
    virtual_subc  = config.virtual_subcarriers
    total_subc    = config.subcarriers
    block_length  = config.block_length
    frame_length  = config.frame_length
    dc_null       = config.dc_null
    
    L             = block_header.mm_periodic_parts
    
    
    ## Set Input/Output signature
    gr.hier_block2.__init__( self, 
        "ofdm_inner_receiver",
        gr.io_signature(
            1, 1,
            gr.sizeof_gr_complex ),
        gr.io_signaturev(
            4, 4,
            [gr.sizeof_gr_complex * total_subc,    # OFDM blocks
            gr.sizeof_char,                       # Frame start
            gr.sizeof_float * total_subc,
            gr.sizeof_float] ) )      # Normalized |CTF|^2 
    
    
    ## Input and output ports
    self.input = rx_input = self
    
    out_ofdm_blocks = ( self, 0 )
    out_frame_start = ( self, 1 )
    out_disp_ctf    = ( self, 2 )
    out_disp_cfo    = ( self, 3 )
    
    
    ## pre-FFT processing
    if options.ideal is False and options.ideal2 is False:
        if options.old_receiver is False:
            ## Compute autocorrelations for S&C preamble
            ## and cyclic prefix
            
            self._sc_metric = sc_metric = autocorrelator( fft_length/2, fft_length/2 )
            self._gi_metric = gi_metric = autocorrelator( fft_length, cp_length )
            
            self.connect( rx_input, sc_metric )
            self.connect( rx_input, gi_metric )    
            
            ## Sync. Output contains OFDM blocks
            sync = ofdm.time_sync( fft_length, cp_length )
            self.connect( rx_input, ( sync, 0 ) )
            self.connect( sc_metric, ( sync, 1 ) )
            self.connect( gi_metric, ( sync, 2 ) )
            ofdm_blocks = ( sync, 0 )
            frame_start = ( sync, 1 )
            #log_to_file( self, ( sync, 1 ), "data/peak_detector.char" )
        else:
    
            #Testing old/new metric
            self.tm = schmidl.recursive_timing_metric(fft_length)
            self.connect( self.input, self.tm)
            #log_to_file( self, self.tm, "data/rec_sc_metric_ofdm.float" )
            
            timingmetric_shift = -2#int(-cp_length/4)# 0#-2 #int(-cp_length * 0.8)
            tmfilter = filter.fft_filter_fff(1, [1./cp_length]*cp_length)
            self.connect( self.tm, tmfilter )
            self.tm = tmfilter
        
            
            
            self._pd_thres = 0.3
            self._pd_lookahead = fft_length / 2 # empirically chosen
            peak_detector = ofdm.peak_detector_02_fb(self._pd_lookahead, self._pd_thres)
            self.connect(self.tm, peak_detector)
            #log_to_file( self, peak_detector, "data/rec_peak_detector.char" )
            
            
            frame_start = [0]*frame_length
            frame_start[0] = 1
            frame_start = self.frame_trigger_old = blocks.vector_source_b(frame_start,True)
            
            
            delayed_timesync = blocks.delay(gr.sizeof_char,
                                        (frame_length-1)*block_length + timingmetric_shift)
            self.connect( peak_detector, delayed_timesync )
            
            self.block_sampler = ofdm.vector_sampler(gr.sizeof_gr_complex,block_length*frame_length)
            self.discard_cp = ofdm.vector_mask(block_length,cp_length,fft_length,[])
            
            self.connect(self.input,self.block_sampler)
            self.connect(delayed_timesync,(self.block_sampler,1))
        
            # TODO: dynamic solution
            vt2s = blocks.vector_to_stream(gr.sizeof_gr_complex*block_length,
                                                    frame_length)
            self.connect(self.block_sampler,vt2s,self.discard_cp)
            #terminate_stream(self,ofdm_blocks)
            ofdm_blocks = self.discard_cp
#     else:
#       serial_to_parallel = blocks.stream_to_vector(gr.sizeof_gr_complex,block_length)
#       discard_cp = ofdm.vector_mask(block_length,cp_length,fft_length,[])
#       ofdm_blocks = discard_cp
#       self.connect( rx_input, serial_to_parallel, discard_cp )
#       frame_start = [0]*frame_length
#       frame_start[0] = 1
#       frame_start = blocks.vector_source_b(frame_start,True)
#       
#       print "Disabled time synchronization stage"
    
    ## Compute autocorrelations for S&C preamble
    ## and cyclic prefix
    
    #log_to_file( self, sc_metric, "data/sc_metric_ofdm.float" )
    #log_to_file(self, frame_start, "data/frame_start.compl")
    
#    log_to_file(self,ofdm_blocks,"data/ofdm_blocks_original.compl")
    
    if options.disable_time_sync or options.ideal or options.ideal2:
      if options.ideal is False and options.ideal2 is False:
          terminate_stream(self, ofdm_blocks)
          terminate_stream(self, frame_start)
      
      serial_to_parallel = blocks.stream_to_vector(gr.sizeof_gr_complex,block_length)
      discard_cp = ofdm.vector_mask_dc_null(block_length,cp_length,fft_length,dc_null, [])
      ofdm_blocks = discard_cp
      self.connect( rx_input, serial_to_parallel, discard_cp )
      
      frame_start = [0]*frame_length
      frame_start[0] = 1
      frame_start = blocks.vector_source_b(frame_start,True)
      
      print "Disabled time synchronization stage"
    
    print"\t\t\t\t\tframe_length = ",frame_length
    
    
    
    
    if options.ideal is False and options.ideal2 is False:
        ## Extract preamble, feed to Morelli & Mengali frequency offset estimator
        assert( block_header.mm_preamble_pos == 0 )
        morelli_foe = ofdm.mm_frequency_estimator( fft_length, L,1,0 )
        sampler_preamble = ofdm.vector_sampler( gr.sizeof_gr_complex * fft_length,
                                            1 )
        self.connect( ofdm_blocks, ( sampler_preamble, 0 ) )
        self.connect( frame_start, ( sampler_preamble, 1 ) )
        self.connect( sampler_preamble, morelli_foe )
        freq_offset = morelli_foe
    
    
        ## Adaptive LMS FIR filtering of frequency offset
        lms_fir = ofdm.lms_fir_ff( 20, 1e-3 ) # TODO: verify parameter choice
        self.connect( freq_offset, lms_fir )
        freq_offset = lms_fir
    
        #self.zmq_probe_freqoff = zeromq.pub_sink(gr.sizeof_float, 1, "tcp://*:5557")
        self.connect(lms_fir, blocks.keep_one_in_n(gr.sizeof_float,20) ,out_disp_cfo)
    else:
        self.connect(blocks.vector_source_f ([1]) ,out_disp_cfo)
    
        #log_to_file(self, lms_fir, "data/lms_fir.float")
    
    if options.disable_freq_sync or options.ideal or options.ideal2:
      if options.ideal is False and options.ideal2 is False:
          terminate_stream(self, freq_offset)
          freq_offset = blocks.vector_source_f([0.0],True)
      print "Disabled frequency synchronization stage"
    
    if options.ideal is False and options.ideal2 is False:
        ## Correct frequency shift, feed-forward structure
        frequency_shift = ofdm.frequency_shift_vcc( fft_length, -1.0/fft_length,
                                                    cp_length )
        self.connect( ofdm_blocks, ( frequency_shift, 0 ) )
        self.connect( freq_offset, ( frequency_shift, 1 ) )
        self.connect( frame_start, ( frequency_shift, 2 ) )
        ofdm_blocks = frequency_shift
    
    
    
    
    ## FFT
    fft = fft_blocks.fft_vcc( fft_length, True, [], True )
    self.connect( ofdm_blocks, fft )
    ofdm_blocks = fft
    #log_to_file( self, fft, "data/compen.float" )
    
    
    
    ## Remove virtual subcarriers
    if fft_length > data_subc:
      subcarrier_mask = ofdm.vector_mask_dc_null( fft_length, virtual_subc/2,
                                           total_subc, dc_null, [] )
      self.connect( ofdm_blocks, subcarrier_mask )
      ofdm_blocks = subcarrier_mask
      #log_to_file(self, ofdm_blocks, "data/vec_mask.compl")
       ## Least Squares estimator for channel transfer function (CTF)
    
    
      if options.logcir:
          log_to_file( self, ofdm_blocks, "data/OFDM_Blocks.compl" )
          
          inv_preamble_fd = numpy.array( block_header.pilotsym_fd[ 
            block_header.channel_estimation_pilot[0] ] )
          inv_preamble_fd = numpy.concatenate([inv_preamble_fd[:total_subc/2],inv_preamble_fd[total_subc/2+dc_null:]])
          #print "Channel estimation pilot: ", inv_preamble_fd
          inv_preamble_fd = 1. / inv_preamble_fd
          LS_channel_estimator0 = ofdm.multiply_const_vcc( list( inv_preamble_fd ) )
          self.connect( ofdm_blocks, LS_channel_estimator0, gr.null_sink(gr.sizeof_gr_complex*total_subc))
          log_to_file( self, LS_channel_estimator0, "data/OFDM_Blocks_eq.compl" )
          
    ## post-FFT processing
      
    
    
    ## extract channel estimation preamble from frame
    if options.ideal is False and options.ideal2 is False:
        chest_pre_trigger = blocks.delay( gr.sizeof_char, 1)
        sampled_chest_preamble = ofdm.vector_sampler( gr.sizeof_gr_complex * total_subc, 1)
        self.connect( frame_start,       chest_pre_trigger )
        self.connect( chest_pre_trigger, ( sampled_chest_preamble, 1 ) )
        self.connect( ofdm_blocks,       ( sampled_chest_preamble, 0 ) )
    

    
        ## Least Squares estimator for channel transfer function (CTF)
        inv_preamble_fd = numpy.array( block_header.pilotsym_fd[ 
                                                            block_header.channel_estimation_pilot[0] ] )
        inv_preamble_fd = numpy.concatenate([inv_preamble_fd[:total_subc/2],inv_preamble_fd[total_subc/2+dc_null:]])    
        #print "Channel estimation pilot: ", inv_preamble_fd
        inv_preamble_fd = 1. / inv_preamble_fd
    
        LS_channel_estimator = ofdm.multiply_const_vcc( list( inv_preamble_fd ) )
        self.connect( sampled_chest_preamble, LS_channel_estimator )
        estimated_CTF = LS_channel_estimator
    
        if options.logcir:
             log_to_file( self, sampled_chest_preamble, "data/PREAM.compl" )
     
    
        if not options.disable_ctf_enhancer:
      
      
            if options.logcir:
                ifft1 = fft_blocks.fft_vcc(total_subc,False,[],True)
                self.connect( estimated_CTF, ifft1,gr.null_sink(gr.sizeof_gr_complex*total_subc))
                summ1 = ofdm.vector_sum_vcc(total_subc)
                c2m =gr.complex_to_mag(total_subc)
                self.connect( estimated_CTF,summ1 ,gr.null_sink(gr.sizeof_gr_complex))
                self.connect( estimated_CTF, c2m,gr.null_sink(gr.sizeof_float*total_subc))
                log_to_file( self, ifft1, "data/CIR1.compl" )
                log_to_file( self, summ1, "data/CTFsumm1.compl" )
                log_to_file( self, estimated_CTF, "data/CTF1.compl" )
                log_to_file( self, c2m, "data/CTFmag1.float" )
        
            ## MSE enhancer
            ctf_mse_enhancer = ofdm.CTF_MSE_enhancer( total_subc, cp_length + cp_length)
            self.connect( estimated_CTF, ctf_mse_enhancer )
#      log_to_file( self, ctf_mse_enhancer, "data/ctf_mse_enhancer_original.compl")
      #ifft3 = fft_blocks.fft_vcc(total_subc,False,[],True)
      #null_noise = ofdm.noise_nulling(total_subc, cp_length + cp_length)
      #ctf_mse_enhancer = fft_blocks.fft_vcc(total_subc,True,[],True)
      #ctf_mse_enhancer = ofdm.vector_mask( fft_length, virtual_subc/2,
                                          # total_subc, [] )
      #self.connect( estimated_CTF, ifft3,null_noise,ctf_mse_enhancer )
        
            estimated_CTF = ctf_mse_enhancer 
            print "Disabled CTF MSE enhancer"

        if options.logcir:
             ifft2 = fft_blocks.fft_vcc(total_subc,False,[],True)
             self.connect( estimated_CTF, ifft2,gr.null_sink(gr.sizeof_gr_complex*total_subc))
             summ2 = ofdm.vector_sum_vcc(total_subc)
             c2m2 =gr.complex_to_mag(total_subc)
             self.connect( estimated_CTF,summ2 ,gr.null_sink(gr.sizeof_gr_complex))
             self.connect( estimated_CTF, c2m2,gr.null_sink(gr.sizeof_float*total_subc))
             log_to_file( self, ifft2, "data/CIR2.compl" )
             log_to_file( self, summ2, "data/CTFsumm2.compl" )
             log_to_file( self, estimated_CTF, "data/CTF2.compl" )
             log_to_file( self, c2m2, "data/CTFmag2.float" )
         
    ## Postprocess the CTF estimate
    ## CTF -> inverse CTF (for equalizer)
    ## CTF -> norm |.|^2 (for CTF display)
        ctf_postprocess = ofdm.postprocess_CTF_estimate( total_subc )
        self.connect( estimated_CTF, ctf_postprocess )
        inv_estimated_CTF = ( ctf_postprocess, 0 )
        disp_CTF = ( ctf_postprocess, 1 )
    
#     if options.disable_equalization or options.ideal:
#       terminate_stream(self, inv_estimated_CTF)
#       inv_estimated_CTF_vec = blocks.vector_source_c([1.0/fft_length*math.sqrt(total_subc)]*total_subc,True,total_subc)
#       inv_estimated_CTF_str = blocks.vector_to_stream(gr.sizeof_gr_complex, total_subc)
#       self.inv_estimated_CTF_mul = ofdm.multiply_const_ccf( 1.0/config.rms_amplitude )
#       #inv_estimated_CTF_mul.set_k(1.0/config.rms_amplitude)
#       inv_estimated_CTF = blocks.stream_to_vector(gr.sizeof_gr_complex, total_subc)
#       self.connect( inv_estimated_CTF_vec, inv_estimated_CTF_str, self.inv_estimated_CTF_mul, inv_estimated_CTF)
#       print "Disabled equalization stage"
    '''
    ## LMS Phase tracking
    ## Track residual frequency offset and sampling clock frequency offset

    nondata_blocks = []
    for i in range(config.frame_length):
      if i in config.training_data.pilotsym_pos:
        nondata_blocks.append(i)
        
    print"\t\t\t\t\tnondata_blocks=",nondata_blocks
    pilot_subc = block_header.pilot_tones
    pilot_subcarriers = block_header.pilot_subc_sym
    print "PILOT SUBCARRIERS: ", pilot_subcarriers
        
    phase_tracking = ofdm.lms_phase_tracking_03( total_subc, pilot_subc,
                                               nondata_blocks, pilot_subcarriers,0 )
    self.connect( ofdm_blocks, ( phase_tracking, 0 ) )
    self.connect( inv_estimated_CTF, ( phase_tracking, 1 ) )
    self.connect( frame_start, ( phase_tracking, 2 ) ) ##
    
    if options.scatter_plot_before_phase_tracking:
      self.before_phase_tracking = equalizer
      
    
    if options.disable_phase_tracking or options.ideal:
      terminate_stream(self, phase_tracking)
      print "Disabled phase tracking stage"
    else:
      ofdm_blocks = phase_tracking
    '''
    ## Channel Equalizer
    if options.disable_equalization or options.ideal or options.ideal2:
        print "Disabled equalization stage"
        if options.ideal is False and options.ideal2 is False:
            terminate_stream(self, inv_estimated_CTF)
    else:
        equalizer = ofdm.channel_equalizer( total_subc )
        self.connect( ofdm_blocks,       ( equalizer, 0 ) )
        self.connect( inv_estimated_CTF, ( equalizer, 1 ) )
        self.connect( frame_start,       ( equalizer, 2 ) )
        ofdm_blocks = equalizer
    #log_to_file(self, equalizer,"data/equalizer_siso.compl")
    
    
    #log_to_file(self, ofdm_blocks, "data/equalizer.compl")

    ## LMS Phase tracking
    ## Track residual frequency offset and sampling clock frequency offset
    if options.ideal is False and options.ideal2 is False:
        nondata_blocks = []
        for i in range(config.frame_length):
          if i in config.training_data.pilotsym_pos:
            nondata_blocks.append(i)
            
        print"\t\t\t\t\tnondata_blocks=",nondata_blocks
        pilot_subc = block_header.pilot_tones
        pilot_subcarriers = block_header.pilot_subc_sym
        print "PILOT SUBCARRIERS: ", pilot_subcarriers
         
        phase_tracking2 = ofdm.lms_phase_tracking_dc_null( total_subc, pilot_subc,
                                                   nondata_blocks, pilot_subcarriers, dc_null  )
        self.connect( ofdm_blocks, ( phase_tracking2, 0 ) )
        self.connect( frame_start, ( phase_tracking2, 1 ) ) ##
        
    if options.disable_phase_tracking or options.ideal or options.ideal2:
        if options.ideal is False and options.ideal2 is False:
            terminate_stream(self, phase_tracking2)
        print "Disabled phase tracking stage"
    else:
        ofdm_blocks = phase_tracking2
    
    if options.scatter_plot_before_phase_tracking:
      self.before_phase_tracking = equalizer


    ## Output connections

    self.connect( ofdm_blocks, out_ofdm_blocks )
    self.connect( frame_start, out_frame_start )
    if options.ideal is False and options.ideal2 is False:
        self.connect( disp_CTF, out_disp_ctf )
    else:
        self.connect( blocks.vector_source_f([1.0]*total_subc),blocks.stream_to_vector(gr.sizeof_float,total_subc), out_disp_ctf )

    if log:
      log_to_file( self, sc_metric, "data/sc_metric.float" )
      log_to_file( self, gi_metric, "data/gi_metric.float" )
      log_to_file( self, morelli_foe, "data/morelli_foe.float" )
      log_to_file( self, lms_fir, "data/lms_fir.float" )
      log_to_file( self, sampler_preamble, "data/preamble.compl" )
      log_to_file( self, sync, "data/sync.compl" )
      log_to_file( self, frequency_shift, "data/frequency_shift.compl" )
      log_to_file( self, fft, "data/fft.compl")
      log_to_file( self, fft, "data/fft.float", mag=True )
      
      if vars().has_key( 'subcarrier_mask' ):
        log_to_file( self, subcarrier_mask, "data/subcarrier_mask.compl" )
      
      log_to_file( self, ofdm_blocks, "data/ofdm_blocks_out.compl" )
      log_to_file( self, frame_start, "data/frame_start.float", 
                   char_to_float=True )
      
      log_to_file( self, sampled_chest_preamble, 
                   "data/sampled_chest_preamble.compl" )
      log_to_file( self, LS_channel_estimator, 
                   "data/ls_channel_estimator.compl" )
      log_to_file( self, LS_channel_estimator, 
                   "data/ls_channel_estimator.float", mag=True )
      
      if "ctf_mse_enhancer" in locals(): 
        log_to_file( self, ctf_mse_enhancer, "data/ctf_mse_enhancer.compl" )
        log_to_file( self, ctf_mse_enhancer, "data/ctf_mse_enhancer.float", 
                     mag=True )
      
      log_to_file( self, (ctf_postprocess,0), "data/inc_estimated_ctf.compl" )
      log_to_file( self, (ctf_postprocess,1), "data/disp_ctf.float" )
      
      log_to_file( self, equalizer, "data/equalizer.compl" )
      log_to_file( self, equalizer, "data/equalizer.float", mag=True )
      
      log_to_file( self, phase_tracking, "data/phase_tracking.compl" )
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="V/HF mult-imode transmitter")

        ##################################################
        # Variables
        ##################################################
        self.var_1 = var_1 = 145100000
        self.var_text = var_text = var_1
        self.tx_mode = tx_mode = 0, 0, 1
        self.tx_freq = tx_freq = 1500, -1500, -1500
        self.tune = tune = 0
        self.side_band = side_band = 2
        self.samp_rate = samp_rate = 1.515152e6
        self.pwr = pwr = 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.0, 0, 0.11
        self.lo_freq_Hz = lo_freq_Hz = (145.1e6, 145.11e6, 14.070e6, 14.236e6, 28.720e6, 10.0e6, 15.0e6, var_1)
        self.hi_lo = hi_lo = 1
        self.freq_chooser = freq_chooser = 0
        self.fine_tune = fine_tune = 0
        self.chooser = chooser = 1

        ##################################################
        # Blocks
        ##################################################
        _tune_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tune_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_tune_sizer,
            value=self.tune,
            callback=self.set_tune,
            label="Coarse Tune",
            converter=forms.int_converter(),
            proportion=0,
        )
        self._tune_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_tune_sizer,
            value=self.tune,
            callback=self.set_tune,
            minimum=-61000,
            maximum=61000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.GridAdd(_tune_sizer, 3, 1, 1, 1)
        self._side_band_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.side_band,
            callback=self.set_side_band,
            label="  Sideband",
            choices=[0, 1, 2],
            labels=["LSB", "USB", "CW"],
            style=wx.RA_HORIZONTAL,
        )
        self.GridAdd(self._side_band_chooser, 3, 2, 1, 1)
        self._hi_lo_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.hi_lo,
            callback=self.set_hi_lo,
            label="Power Level",
            choices=[1, 2],
            labels=["Low", "High"],
            style=wx.RA_HORIZONTAL,
        )
        self.GridAdd(self._hi_lo_chooser, 4, 2, 1, 1)
        self._freq_chooser_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.freq_chooser,
            callback=self.set_freq_chooser,
            label="FREQUENCY SELECT",
            choices=[0, 1, 2, 3, 4, 5, 6, 7],
            labels=["145.100", "145.110", "14.070", "14.236", "28.720", "10", "15", "PRESET"],
            style=wx.RA_HORIZONTAL,
        )
        self.GridAdd(self._freq_chooser_chooser, 1, 1, 1, 1)
        _fine_tune_sizer = wx.BoxSizer(wx.VERTICAL)
        self._fine_tune_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_fine_tune_sizer,
            value=self.fine_tune,
            callback=self.set_fine_tune,
            label="Fine Tune",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._fine_tune_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_fine_tune_sizer,
            value=self.fine_tune,
            callback=self.set_fine_tune,
            minimum=-5000 / 2,
            maximum=5000 / 2,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_fine_tune_sizer, 4, 1, 1, 1)
        self._chooser_chooser = forms.button(
            parent=self.GetWin(),
            value=self.chooser,
            callback=self.set_chooser,
            label="TX-RX Selector",
            choices=[1, 0],
            labels=["Receive", "Transmit"],
        )
        self.GridAdd(self._chooser_chooser, 6, 1, 2, 1)
        self._var_text_static_text = forms.static_text(
            parent=self.GetWin(),
            value=self.var_text,
            callback=self.set_var_text,
            label="PRESET FREQUENCY",
            converter=forms.float_converter(),
        )
        self.GridAdd(self._var_text_static_text, 1, 2, 1, 1)
        self.pfb_interpolator_ccf_0 = pfb.interpolator_ccf(8, (), 100)
        self.pfb_interpolator_ccf_0.declare_sample_delay(0)

        self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + "")
        self.osmosdr_sink_0.set_sample_rate(samp_rate / 4)
        self.osmosdr_sink_0.set_center_freq(lo_freq_Hz[freq_chooser] + tune + fine_tune - (tx_freq[side_band]), 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(10, 0)
        self.osmosdr_sink_0.set_if_gain(20, 0)
        self.osmosdr_sink_0.set_bb_gain(20, 0)
        self.osmosdr_sink_0.set_antenna("", 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)

        self.fft_filter_xxx_0_0_0_0_0 = filter.fft_filter_fff(
            1, (firdes.band_pass(1, samp_rate / 32, 250, 3500, 400)), 1
        )
        self.fft_filter_xxx_0_0_0_0_0.declare_sample_delay(0)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate / 32, True)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_1_0_0_0 = blocks.multiply_const_vcc(((pwr[freq_chooser] * hi_lo),))
        self.blocks_multiply_const_vxx_1_0_0 = blocks.multiply_const_vff((40 * 10,))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blks2_valve_1 = grc_blks2.valve(item_size=gr.sizeof_gr_complex * 1, open=bool(chooser))
        self.blks2_selector_0 = grc_blks2.selector(
            item_size=gr.sizeof_gr_complex * 1,
            num_inputs=2,
            num_outputs=1,
            input_index=tx_mode[side_band],
            output_index=0,
        )
        self.band_pass_filter_0 = filter.interp_fir_filter_ccf(
            1, firdes.band_pass(1, 47348, 150, 1500, 300, firdes.WIN_HAMMING, 6.76)
        )
        self.audio_source_0_0 = audio.source(47348, "", True)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate / 32, analog.GR_COS_WAVE, tx_freq[side_band], 1, 0)
        self.analog_const_source_x_0 = analog.sig_source_c(0, analog.GR_CONST_WAVE, 0, 0, (0.070) * 9)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.audio_source_0_0, 0), (self.blocks_multiply_const_vxx_1_0_0, 0))
        self.connect((self.band_pass_filter_0, 0), (self.blks2_selector_0, 0))
        self.connect((self.blks2_selector_0, 0), (self.blocks_multiply_const_vxx_1_0_0_0, 0))
        self.connect((self.blks2_valve_1, 0), (self.pfb_interpolator_ccf_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.blocks_multiply_const_vxx_1_0_0, 0), (self.fft_filter_xxx_0_0_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0_0_0, 0), (self.blks2_valve_1, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0), (self.band_pass_filter_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blks2_selector_0, 1))
        self.connect((self.fft_filter_xxx_0_0_0_0_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.pfb_interpolator_ccf_0, 0), (self.osmosdr_sink_0, 0))