def __init__(self, cf):
        gr.top_block.__init__(self, "FM radio FFT example")

        ##################################################
        # Blocks
        ##################################################
        self.fft_vxx_0 = fft.fft_vcc(2048, True, (window.rectangular(2048)), True, 1)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 2048)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*2048, "/home/pradeep/tutorial_btp/fm/out", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(2048)
        self.RTL820T = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.RTL820T.set_sample_rate(2.0E6)
        self.RTL820T.set_center_freq(cf, 0)
        self.RTL820T.set_freq_corr(00, 0)
        self.RTL820T.set_dc_offset_mode(0, 0)
        self.RTL820T.set_iq_balance_mode(0, 0)
        self.RTL820T.set_gain_mode(False, 0)
        self.RTL820T.set_gain(0, 0)
        self.RTL820T.set_if_gain(00000000000, 0)
        self.RTL820T.set_bb_gain(000000000000, 0)
        self.RTL820T.set_antenna("", 0)
        self.RTL820T.set_bandwidth(0, 0)
          

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.RTL820T, 0), (self.blocks_stream_to_vector_0, 0))
        #self.connect((self.fft_vxx_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_file_sink_0, 0))
示例#2
0
    def __init__(self, sps=2.0, rolloff=0.35, preamble=[0,0,0,0,0,0,1,1,0,1,1,0,1,1,0,0,1,1,1,1,0,0,0,0],
                    modtype=mapper.QPSK, greymap=[0,1,3,2] ):
        gr.hier_block2.__init__(self, "preamble_correlator",
                                    gr.io_signature(1,1,gr.sizeof_gr_complex),
                                    gr.io_signature(1,1,gr.sizeof_float))
                                    #gr.io_signature(0,0,0))

        # vet preamble bits
        for b in preamble:
            assert(b >= 0 and b<=1);

        tb = gr.top_block();
        vs = blocks.vector_source_b( preamble );
        mp = mapper.mapper(modtype, greymap);  
        it = filter.interp_fir_filter_ccf(2, firdes.root_raised_cosine(1, 1.0, 1.0/sps, rolloff, 21))
        vk = blocks.vector_sink_c();
        tb.connect(vs,mp,it,vk);
        tb.run();
        self.taps = list(vk.data());
        self.taps.reverse();
        self.taps = map(lambda x: x.conjugate(), self.taps);

        self.flt = filter.fft_filter_ccc(1, self.taps);
        self.mag = blocks.complex_to_mag_squared();
        self.connect(self, self.flt, self.mag);

        # connect output
        self.connect(self.mag, self);
示例#3
0
	def __init__(self, fft_len, sample_rate, tune_freq, average, rate, length, height):
		gr.hier_block2.__init__(self,
			"ascii plot",
			gr.io_signature(1, 1, gr.sizeof_gr_complex),
			gr.io_signature(0,0,0))
		self.fft_len = fft_len
		self.sample_rate = sample_rate
		self.average = average
		self.tune_freq = tune_freq
		self.rate = rate
		self.length = length
		self.height = height

		self.msgq = gr.msg_queue(2)

		#######BLOCKS#####
		self.s2p = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fft_len)
		self.one_in_n = blocks.keep_one_in_n(gr.sizeof_gr_complex * self.fft_len,
		 max(1, int(self.sample_rate/self.fft_len/self.rate)))

		mywindow = window.blackmanharris(self.fft_len)
		self.fft = fft.fft_vcc(self.fft_len, True, (), True)

		self.c2mag2 = blocks.complex_to_mag_squared(self.fft_len)
		self.avg = grfilter.single_pole_iir_filter_ff(1.0, self.fft_len)
		self.log = blocks.nlog10_ff(10, self.fft_len,
								-10*math.log10(self.fft_len)                # Adjust for number of bins
								-10*math.log10(self.sample_rate))                # Adjust for sample rate

		self.sink = blocks.message_sink(gr.sizeof_float * self.fft_len, self.msgq, True)
		#####CONNECTIONS####
		self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag2, self.avg, self.log, self.sink)

		self._main = main_thread(self.msgq, self.fft_len, self.sample_rate, self.tune_freq, self.length, self.height)
示例#4
0
    def __init__(self, beta=0):
        gr.hier_block2.__init__(
            self, "Third Order Distortion",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.beta = beta

        ##################################################
        # Blocks
        ##################################################
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_float*1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((beta, ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_null_source_0, 0), (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self, 0), (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self, 0))
示例#5
0
    def __init__(self, samp_rate=2e6, dst=None, freq=13.57e6, rx_gain=6.5):
        
        gr.hier_block2.__init__(self, "usrp_src",
                gr.io_signature(0, 0, 0), # Input signature
                gr.io_signature(1, 1, gr.sizeof_float))       # Output signature

        self._src = uhd.usrp_source(
            device_addr="",
            stream_args=uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )  

        self._src.set_samp_rate(samp_rate)
        self._src.set_center_freq(freq, 0)
        self._src.set_gain(rx_gain, 0)
        self._src.set_antenna("RX", 0)
        self._c2m2 = blocks.complex_to_mag_squared(1)

        self.connect(self._src, self._c2m2, self)

        if dst:
            self._wav = blocks.wavfile_sink(dst, 1, int(samp_rate), 16)
            self.connect(self._c2m2, self._wav)
示例#6
0
    def __init__(self, fft_size, mavg_size, ed_threshold):
        """
        CTOR
        @param fft_size FFT Size
        @param mavg_size Energy Detector mavg size.
        """

        gr.hier_block2.__init__(
            self,
            name="simple_ranking_detector",
            input_signature=gr.io_signature(1, 1, gr.sizeof_gr_complex),
            output_signature=gr.io_signature(2, 2, gr.sizeof_float),
        )

        # Blocks
        # Convert the output of a FFT
        self.s2v_0 = blocks.stream_to_vector(gr.sizeof_gr_complex, fft_size)
        self.fft_0 = fft.fft_vcc(fft_size, True, [])
        self.c2mag_0 = blocks.complex_to_mag_squared(fft_size)

        # Instantiate the energy calculator
        from sensing import EnergyDecision

        self.ql = QLearningWorker(fft_size, algorithm=EnergyDecision(ed_threshold))

        #::TODO:: parece que nao tem mais o metodo connect
        # Flow graph
        self.connect(self, self.s2v_0, self.fft_0, self.c2mag_0, self.ql)

        self.connect((self.ql, 0), (self, 0))
        self.connect((self.ql, 1), (self, 1))
示例#7
0
	def __init__(self, fft_size=2048, decim=100):
		gr.hier_block2.__init__(
			self, "RA:FFT",
			gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
			gr.io_signature(1, 1, gr.sizeof_float*fft_size),
		)

		##################################################
		# Parameters
		##################################################
		self.fft_size = fft_size
		self.decim = decim

		##################################################
		# Blocks
		##################################################
		self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(1.0/decim, fft_size)
		self.fft_vxx_0 = fft.fft_vcc(fft_size, True, (window.blackmanharris(1024)), True, 1)
		self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_size)
		self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(([1.0/fft_size]*fft_size))
		self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_float*fft_size, decim)
		self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(fft_size)

		##################################################
		# Connections
		##################################################
		self.connect((self.blocks_multiply_const_vxx_0, 0), (self.single_pole_iir_filter_xx_0, 0))
		self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_multiply_const_vxx_0, 0))
		self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_keep_one_in_n_0, 0))
		self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
		self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
		self.connect((self, 0), (self.blocks_stream_to_vector_0, 0))
		self.connect((self.blocks_keep_one_in_n_0, 0), (self, 0))
    def __init__(self, ts=(0+0j,), factor=0, alpha=0.01):
        gr.hier_block2.__init__(
            self, "timing_estimator_hier",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signature(1, 1, gr.sizeof_char*1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.ts = ts
        self.factor = factor
        self.alpha = alpha

        ##################################################
        # Blocks
        ##################################################
        self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(1, (numpy.conjugate(ts[::-1])))
        self.blocks_peak_detector_xb_0_0 = blocks.peak_detector_fb(factor, factor, 0, alpha)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_peak_detector_xb_0_0, 0))
        self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_peak_detector_xb_0_0, 0), (self, 0))
        self.connect((self, 0), (self.interp_fir_filter_xxx_0, 0))
示例#9
0
	def __init__(self, length, debug=False):
		"""
		Hierarchical block to detect Null symbols

		@param length length of the Null symbol (in samples)
		@param debug whether to write signals out to files
		"""
		gr.hier_block2.__init__(self,"detect_null",
		                        gr.io_signature(1, 1, gr.sizeof_gr_complex),    # input signature
					gr.io_signature(1, 1, gr.sizeof_char))          # output signature


		# get the magnitude squared
		self.ns_c2magsquared = blocks.complex_to_mag_squared()
		
		# this wastes cpu cycles:
		# ns_detect_taps = [1]*length
		# self.ns_moving_sum = gr.fir_filter_fff(1,ns_detect_taps)
		# this isn't better:
		#self.ns_filter = gr.iir_filter_ffd([1]+[0]*(length-1)+[-1],[0,1])
		# this does the same again, but is actually faster (outsourced to an independent block ..):
		self.ns_moving_sum = dab_swig.moving_sum_ff(length)
		self.ns_invert = blocks.multiply_const_ff(-1)

		# peak detector on the inverted, summed up signal -> we get the nulls (i.e. the position of the start of a frame)
		self.ns_peak_detect = blocks.peak_detector_fb(0.6,0.7,10,0.0001) # mostly found by try and error -> remember that the values are negative!

		# connect it all
		self.connect(self, self.ns_c2magsquared, self.ns_moving_sum, self.ns_invert, self.ns_peak_detect, self)

		if debug:
			self.connect(self.ns_invert, blocks.file_sink(gr.sizeof_float, "debug/ofdm_sync_dab_ns_filter_inv_f.dat"))
			self.connect(self.ns_peak_detect,blocks.file_sink(gr.sizeof_char, "debug/ofdm_sync_dab_peak_detect_b.dat"))
示例#10
0
 def __init__(self, dpss, fftshift=False):
     gr.hier_block2.__init__(self, "eigenspectrum",
             gr.io_signature(1, 1, gr.sizeof_gr_complex*len(dpss)),
             gr.io_signature(1, 1, gr.sizeof_float*len(dpss)))
     self.window = dpss
     self.fft = fft.fft_vcc(len(dpss), True, self.window, fftshift)
     self.c2mag = blocks.complex_to_mag_squared(len(dpss))
     self.connect(self, self.fft, self.c2mag, self)
    def __init__(self, uhd_address, options):

        gr.top_block.__init__(self)

        self.uhd_addr = uhd_address
        self.freq = options.freq
        self.samp_rate = options.samp_rate
        self.gain = options.gain
        self.threshold = options.threshold
        self.trigger = options.trigger

        self.uhd_src = uhd.single_usrp_source(
            device_addr=self.uhd_addr,
            stream_args=uhd.stream_args('fc32'))

        self.uhd_src.set_samp_rate(self.samp_rate)
        self.uhd_src.set_center_freq(self.freq, 0)
        self.uhd_src.set_gain(self.gain, 0)

        taps = firdes.low_pass_2(1, 1, 0.4, 0.1, 60)
        self.chanfilt = filter.fir_filter_ccc(10, taps)
        self.tagger = blocks.burst_tagger(gr.sizeof_gr_complex)

        # Dummy signaler to collect a burst on known periods
        data = 1000*[0,] + 1000*[1,]
        self.signal = blocks.vector_source_s(data, True)

        # Energy detector to get signal burst
        ## use squelch to detect energy
        self.det  = analog.simple_squelch_cc(self.threshold, 0.01)
        ## convert to mag squared (float)
        self.c2m = blocks.complex_to_mag_squared()
        ## average to debounce
        self.avg = filter.single_pole_iir_filter_ff(0.01)
        ## rescale signal for conversion to short
        self.scale = blocks.multiply_const_ff(2**16)
        ## signal input uses shorts
        self.f2s = blocks.float_to_short()

        # Use file sink burst tagger to capture bursts
        self.fsnk = blocks.tagged_file_sink(gr.sizeof_gr_complex, self.samp_rate)


        ##################################################
        # Connections
        ##################################################
        self.connect((self.uhd_src, 0), (self.tagger, 0))
        self.connect((self.tagger, 0), (self.fsnk, 0))

        if self.trigger:
            # Connect a dummy signaler to the burst tagger
            self.connect((self.signal, 0), (self.tagger, 1))

        else:
            # Connect an energy detector signaler to the burst tagger
            self.connect(self.uhd_src, self.det)
            self.connect(self.det, self.c2m, self.avg, self.scale, self.f2s)
            self.connect(self.f2s, (self.tagger, 1))
    def __init__(self):
        gr.top_block.__init__(self)

        self.sample_rate = 5000000
        self.ampl = 0.1
        self.freq = 144000000

        self.uhd = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd.set_samp_rate(self.sample_rate)
        self.uhd.set_center_freq(self.freq, 0)
        self.uhd.set_gain(0, 0)
        self.uhd.set_antenna("RX2", 0)
        self.fft_vxx_0 = fft.fft_vcc(1024, True, (window.blackmanharris(1024)), True, 1)
        
        self.throttle = blocks.throttle(gr.sizeof_gr_complex*1, self.sample_rate,True)
        
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, self.sample_rate,True)

        self.stream = blocks.stream_to_vector_decimator(
            item_size=gr.sizeof_gr_complex,
            sample_rate=self.sample_rate,
            vec_rate=30,
            vec_len=1024,
        )

        self.probe = blocks.probe_signal_vf(1024)
        self.fft = fft.fft_vcc(1024, True, (window.blackmanharris(1024)), True, 1)

        src0 = analog.sig_source_c(self.sample_rate, analog.GR_SIN_WAVE, self.freq, self.ampl)
        dst = audio.sink(self.sample_rate, "")

        self.sqrt = blocks.complex_to_mag_squared(1024)

        def fft_out():
            while 1:
                val = self.probe.level()
                print max(val)
                freq = (val.index(max(val)) * (self.sample_rate/1024.0)) + (self.freq - (self.sample_rate/2.0))
                print freq
                time.sleep(1)

        fft_thread = threading.Thread(target=fft_out)

        fft_thread.daemon = True
        fft_thread.start()

        self.connect((self.uhd,0),(self.throttle, 0))
        self.connect((self.throttle,0),(self.stream,0))
        self.connect((self.stream, 0),(self.fft, 0))
        self.connect((self.fft, 0),(self.sqrt, 0))
        self.connect((self.sqrt, 0),(self.probe, 0))
示例#13
0
 def test_complex_to_mag_squared(self):
     src_data = (1+2j, 3-4j, 5+6j, 7-8j, -9+10j)
     expected_data = (5.0, 25.0, 61.0, 113.0, 181.0)
     src = blocks.vector_source_c(src_data)
     op = blocks.complex_to_mag_squared()
     dst = blocks.vector_sink_f()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertFloatTuplesAlmostEqual(expected_data, dst.data())
    def __init__(self, ts, factor, alpha, samp_rate, freqs):
        gr.hier_block2.__init__(
            self, "freq_timing_estimator_hier",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signaturev(3, 3, [gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1]),
        )

        ##################################################
        # Parameters
        ##################################################
        self.ts = ts
        self.factor = factor
        self.alpha = alpha
        self.samp_rate = samp_rate
        self.freqs = freqs
        self.n = n = len(freqs)

        ##################################################
        # Blocks
        ##################################################
        self._filter=[0]*self.n
        self._c2mag2=[0]*self.n
        for i in range(self.n):
          self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, (numpy.conjugate(self.ts[::-1])), self.freqs[i], self.samp_rate)
          self._c2mag2[i] = blocks.complex_to_mag_squared(1)

        self.blocks_max = blocks.max_ff(1)
        self.blocks_peak_detector = blocks.peak_detector_fb(self.factor, self.factor, 0, self.alpha)

        self.blocks_argmax = blocks.argmax_fs(1)
        self.blocks_null_sink = blocks.null_sink(gr.sizeof_short*1)
        self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs), 1)
        self.blocks_sample_and_hold = blocks.sample_and_hold_ff()

        ##################################################
        # Connections
        ##################################################
        for i in range(self.n):
          self.connect((self, 0), (self._filter[i], 0))
          self.connect((self._filter[i], 0), (self._c2mag2[i], 0))
          self.connect((self._c2mag2[i], 0), (self.blocks_max, i))
          self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i))
        self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0))
        self.connect((self.blocks_peak_detector, 0), (self, 0))
        self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0))
        self.connect((self.blocks_argmax, 1), (self.digital_chunks_to_symbols, 0))
        self.connect((self.digital_chunks_to_symbols, 0), (self.blocks_sample_and_hold, 0))
        self.connect((self.blocks_peak_detector, 0), (self.blocks_sample_and_hold, 1))
        self.connect((self.blocks_sample_and_hold, 0), (self, 1))
        self.connect((self.blocks_max, 0), (self, 2))
示例#15
0
    def __init__(self, alpha=0):
        gr.hier_block2.__init__(
            self, "IQ Phase Balancer",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
        )

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

        ##################################################
        # Blocks
        ##################################################
        self.filter_single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(alpha, 1)
        self.blocks_sub_xx_1 = blocks.sub_ff(1)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_multiply_xx_2 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_divide_xx_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.filter_single_pole_iir_filter_xx_0, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_sub_xx_1, 1))
        self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_sub_xx_1, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_sub_xx_1, 0))
        self.connect((self.blocks_divide_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.filter_single_pole_iir_filter_xx_0, 0))
        self.connect((self, 0), (self.blocks_complex_to_float_0, 0))
        self.connect((self, 0), (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self, 0))
        self.connect((self.filter_single_pole_iir_filter_xx_0, 0), (self.blocks_multiply_xx_2, 0))
        self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_2, 1))
示例#16
0
文件: top.py 项目: shadown/shinysdr
	def set_window_and_reconnect(self, window):
		'''
		Must be called while the flowgraph is locked already.
		'''
		window = int(window)
		self.disconnect_all()
		self.__sink = blocks.probe_signal_f()
		self.connect(
			self,
			blocks.complex_to_mag_squared(),
			blocks.stream_to_vector(itemsize=gr.sizeof_float, nitems_per_block=window),
			blocks.max_ff(window),
			self.__sink)
		
		# shortcut method implementation
		self.level = self.__sink.level
示例#17
0
	def __init__(self, fft_len, sens_per_sec, sample_rate, channel_space = 1,
	 search_bw = 1, thr_leveler = 10, tune_freq = 0, alpha_avg = 1, test_duration = 1,
	  period = 3600, trunc_band = 1, verbose = False, peak_alpha = 0, subject_channels = []):
		gr.hier_block2.__init__(self,
			"flank detector",
			gr.io_signature(1, 1, gr.sizeof_gr_complex),
			gr.io_signature(0,0,0))
		self.fft_len = fft_len #lenght of the fft for spectral analysis
		self.sens_per_sec = sens_per_sec #number of measurements per second (decimates)
		self.sample_rate = sample_rate 
		self.channel_space = channel_space #channel space for analysis
		self.search_bw = search_bw #search bandwidth within each channel
		self.thr_leveler = thr_leveler #leveler factor for noise floor / threshold comparison
		self.tune_freq = tune_freq #center frequency
		self.threshold = 0 #actual value of the threshold
		self.alpha_avg = alpha_avg #averaging factor for noise level between consecutive measurements
		self.peak_alpha = peak_alpha  #averaging factor for peak level between consecutive measurements
		self.subject_channels = subject_channels #channels whose flancks will be analysed
		

		self.msgq0 = gr.msg_queue(2)

		#######BLOCKS#####
		self.s2p = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fft_len)
		self.one_in_n = blocks.keep_one_in_n(gr.sizeof_gr_complex * self.fft_len,
		 max(1, int(self.sample_rate/self.fft_len/self.sens_per_sec)))

		mywindow = window.blackmanharris(self.fft_len)
		self.fft = fft.fft_vcc(self.fft_len, True, (), True)

		self.c2mag2 = blocks.complex_to_mag_squared(self.fft_len)
		self.multiply = blocks.multiply_const_vff(np.array([1.0/float(self.fft_len**2)]*fft_len))

		self.sink0 = blocks.message_sink(gr.sizeof_float * self.fft_len, self.msgq0, True)
		#####CONNECTIONS####
		self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag2, self.multiply, self.sink0)

		#start periodic logging
		self._logger = logger(period, test_duration)
		#self._logger = None

		#Watchers
		#statistics and power
		self._watcher0 = _queue0_watcher(self.msgq0, sens_per_sec, self.tune_freq, self.channel_space,
		 self.search_bw, self.fft_len, self.sample_rate, self.thr_leveler, self.alpha_avg, test_duration,
		  trunc_band, verbose, peak_alpha, subject_channels, self._logger)
示例#18
0
文件: top.py 项目: nunb/shinysdr
 def set_window_and_reconnect(self, window):
     '''
     Must be called while the flowgraph is locked already.
     '''
     # Use a power-of-2 window size to satisfy gnuradio allocation alignment without going overboard.
     window = int(2 ** math.floor(math.log(window, 2)))
     self.disconnect_all()
     self.__sink = blocks.probe_signal_f()
     self.connect(
         self,
         blocks.complex_to_mag_squared(),
         blocks.stream_to_vector(itemsize=gr.sizeof_float, nitems_per_block=window),
         blocks.max_ff(window),
         self.__sink)
     
     # shortcut method implementation
     self.level = self.__sink.level
示例#19
0
    def __init__(self, parent, baseband_freq=0, ref_scale=2.0,
                 y_per_div=10, y_divs=8, ref_level=50, sample_rate=1, fft_size=512,
                 fft_rate=default_fft_rate, average=False, avg_alpha=None,
                 title='', size=default_fftsink_size, peak_hold=False,
                 use_persistence=False, persist_alpha=0.2, **kwargs):

        gr.hier_block2.__init__(self, "fft_sink_c",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(0,0,0))

        fft_sink_base.__init__(self, input_is_real=False, baseband_freq=baseband_freq,
                               y_per_div=y_per_div, y_divs=y_divs, ref_level=ref_level,
                               sample_rate=sample_rate, fft_size=fft_size,
                               fft_rate=fft_rate,
                               average=average, avg_alpha=avg_alpha, title=title,
                               peak_hold=peak_hold, use_persistence=use_persistence,
                               persist_alpha=persist_alpha)

        self.s2p = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fft_size)
        self.one_in_n = blocks.keep_one_in_n(gr.sizeof_gr_complex * self.fft_size,
                                             max(1, int(self.sample_rate/self.fft_size/self.fft_rate)))

        mywindow = window.blackmanharris(self.fft_size)
        self.fft = fft.fft_vcc(self.fft_size, True, mywindow)
        power = 0
        for tap in mywindow:
            power += tap*tap

        self.c2magsq = blocks.complex_to_mag_squared(self.fft_size)
        self.avg = grfilter.single_pole_iir_filter_ff(1.0, self.fft_size)

        # FIXME  We need to add 3dB to all bins but the DC bin
        self.log = blocks.nlog10_ff(10, self.fft_size,
                                -20*math.log10(self.fft_size)                # Adjust for number of bins
                                -10*math.log10(power/self.fft_size)        # Adjust for windowing loss
                                -20*math.log10(ref_scale/2))                # Adjust for reference scale

        self.sink = blocks.message_sink(gr.sizeof_float * self.fft_size, self.msgq, True)
        self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2magsq, self.avg, self.log, self.sink)

        self.win = fft_window(self, parent, size=size)
        self.set_average(self.average)
        self.set_use_persistence(self.use_persistence)
        self.set_persist_alpha(self.persist_alpha)
        self.set_peak_hold(self.peak_hold)
示例#20
0
    def __init__(self, fft_size):
        """
        CTOR
        @param fft_size FFT size (output of FFT is passed to the algorithm object).
        @param algorithm Waveform Algorithm. An AbstractAlgorithm implementation.
        """

        gr.hier_block2.__init__(self,
                                name="waveform detector",
                                input_signature=gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                output_signature=gr.io_signature(1, 1, gr.sizeof_float * fft_size)
                                )

        s2v_0 = blocks.stream_to_vector(gr.sizeof_gr_complex, fft_size)
        fft_0 = fft.fft_vcc(fft_size, True, [])
        c2mag_0 = blocks.complex_to_mag_squared(fft_size)

        self.connect(self, s2v_0, fft_0, c2mag_0,  self)  #pylint: disable=E1101
示例#21
0
    def __init__(self, item_size_in, item_size_out, onoff,ts,factor,alpha):
        gr.hier_block2.__init__(self,
            "myselector",
            gr.io_signature(1,1, item_size_in),  # Input signature
            gr.io_signature(1,1, item_size_out), # Output signature
        )

        self.item_size_in = item_size_in
        self.item_size_out = item_size_out
        self.onoff=onoff

        #print self.item_size_in, self.item_size_out, self.onoff
     
        # Define blocks and connect them

        # This is the BIG block
        self.A=cdma.timing_estimator_hier(ts,factor,alpha)
        #self.Ab=blocks.multiply_const_cc(2.0+0j)
        #self.Ab=filter.interp_fir_filter_ccc(1,ts)
        #self.A1=blocks.complex_to_mag_squared()
        #self.Ae=blocks.float_to_char()
        #self.Ae=blocks.complex_to_mag_squared()
        #self.connect(self.Ab, self.A1, self.Ae)
        #self.connect(self.Ab, self.Ae)

        # This is the SMALL block
        self.Ob=blocks.multiply_const_cc(0.0)
        self.O1=blocks.complex_to_mag_squared()
        self.Oe=blocks.float_to_char()
        #self.Oe=blocks.complex_to_mag_squared()
        self.connect(self.Ob, self.O1, self.Oe)
        #self.connect(self.Ob, self.Oe)

        # null sources/sinks for connecting inactive block
        self.nso=blocks.null_source(item_size_in)
        self.h=blocks.head(item_size_in, 0)
        self.connect(self.nso, self.h)

        self.nsi=blocks.null_sink(item_size_out)

        if self.onoff==0:
          self._connect_off()
        else:
          self._connect_on()
示例#22
0
    def __init__(self):
        gr.top_block.__init__(self, "Salsa Eceiver")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 5000000.0
        self.outfile = outfile = "/tmp/vale.dat"
        self.int_time = int_time = 10
        self.gain = gain = 60
        self.fftsize = fftsize = 4096
        self.c_freq = c_freq = 1420.4e6

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	device_addr="addr=192.168.10.2",
        	stream_args=uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(c_freq, 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.fft_vxx_0 = fft.fft_vcc(fftsize, True, (window.blackmanharris(fftsize)), True, 1)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, fftsize)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fftsize)
        self.blocks_head_0 = blocks.head(gr.sizeof_float*1, int(int_time*samp_rate))
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, outfile, False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_head_0, 0))
        self.connect((self.blocks_head_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
示例#23
0
	def change(self, fftsize, fftlen):
		fftlen = 1024 * 5
		# TODO: change without clearing the buffer
		self.bmpbuf = bytearray('\x00\x00\x00\x00' * (fftsize * fftlen))

		self.img = qtgui4.QImage(self.bmpbuf, fftsize, fftlen, fftsize * 4, qtgui4.QImage.Format_RGB32)

		self.fftsize = fftsize
		self.fftlen = fftlen

		if self.src_blk is None:
			return

		self.tb.lock()
		if self.fft is not None:
			try:
				self.tb.disconnect(self.src_blk, self.fft)
			except:
				pass
			try:
				self.tb.disconnect(self.fft, slf.stv0)
			except:
				pass
			try:
				self.tb.disconnect(self.stv0, self.ctm)
			except:
				pass

		fft_filter = []
		for x in xrange(0, fftsize):
			fft_filter.append(math.sin(float(x) / float(fftsize) * math.pi))

		self.fft = fft.fft_vcc(fftsize, True, fft_filter, True, 4)
		self.stv0 = blocks.stream_to_vector(8, fftsize)
		self.ctm = blocks.complex_to_mag_squared(fftsize)
		self.reader = PyBlockHandler(fftsize=fftsize, blockcnt=1)
		self.reader.setVecHandler(self.__vec_handler)
		self.keep = blocks.keep_m_in_n(8, self.fftsize, self.fftsize * 1, 0)

		self.tb.connect(self.src_blk, self.keep, self.stv0, self.fft, self.ctm, self.reader)

		self.tb.unlock()
示例#24
0
    def __init__(self, fft_size=4096):
        gr.hier_block2.__init__(
            self, "Fast Autocor",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signature(1, 1, gr.sizeof_float*1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.fft_size = fft_size

        ##################################################
        # Blocks
        ##################################################
        self.fft_vxx_0_0 = fft.fft_vcc(fft_size, False, (window.hamming(fft_size)), False, 1)
        self.fft_vxx_0 = fft.fft_vcc(fft_size, True, (window.hamming(fft_size)), False, 1)
        self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, fft_size)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, fft_size)
        self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_size)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_size)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((1.0/fft_size, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2048.0/fft_size, ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_mag_squared_1 = blocks.complex_to_mag_squared(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_complex_to_mag_squared_1, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_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.fft_vxx_0_0, 0), (self.blocks_vector_to_stream_0_0, 0))
        self.connect((self.blocks_vector_to_stream_0_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_stream_to_vector_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self, 0))
        self.connect((self.blocks_complex_to_mag_squared_1, 0), (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_float_to_complex_0, 0))
示例#25
0
    def __init__(self, fft_size, mavg_size, name="EnergyDetectorC"):
        """
        CTOR
        @param fft_size FFT Size.
        """

        gr.hier_block2.__init__(self,
                name=name,
                input_signature=gr.io_signature(1, 1, gr.sizeof_gr_complex),
                output_signature=gr.io_signature(1, 1, gr.sizeof_float*fft_size),
         )

        # Blocks
        # Convert the output of a FFT
        s2v_0 = blocks.stream_to_vector(gr.sizeof_gr_complex, fft_size)
        fft_0 = fft.fft_vcc(fft_size, True, [])
        c2mag_0 = blocks.complex_to_mag_squared(fft_size)

        ## Flow graph
        self.connect(self, s2v_0, fft_0, c2mag_0, self)  #pylint: disable=E1101
示例#26
0
    def __init__(self, sample_rate, fft_size, ref_scale, frame_rate, avg_alpha, average, win=None):
        """
        Create an log10(abs(fft)) stream chain.
        Provide access to the setting the filter and sample rate.
        
        Args:
            sample_rate: Incoming stream sample rate
            fft_size: Number of FFT bins
            ref_scale: Sets 0 dB value input amplitude
            frame_rate: Output frame rate
            avg_alpha: FFT averaging (over time) constant [0.0-1.0]
            average: Whether to average [True, False]
            win: the window taps generation function
        """
        gr.hier_block2.__init__(self, self._name,
                                gr.io_signature(1, 1, self._item_size),          # Input signature
                                gr.io_signature(1, 1, gr.sizeof_float*fft_size)) # Output signature

        self._sd = blocks.stream_to_vector_decimator(item_size=self._item_size,
                                                     sample_rate=sample_rate,
                                                     vec_rate=frame_rate,
                                                     vec_len=fft_size)

        if win is None: win = window.blackmanharris
        fft_window = win(fft_size)
        fft = self._fft_block[0](fft_size, True, fft_window)
        window_power = sum(map(lambda x: x*x, fft_window))

        c2magsq = blocks.complex_to_mag_squared(fft_size)
        self._avg = filter.single_pole_iir_filter_ff(1.0, fft_size)
        self._log = blocks.nlog10_ff(10, fft_size,
                                     -20*math.log10(fft_size)              # Adjust for number of bins
                                     -10*math.log10(window_power/fft_size) # Adjust for windowing loss
                                     -20*math.log10(ref_scale/2))      # Adjust for reference scale
        self.connect(self, self._sd, fft, c2magsq, self._avg, self._log, self)

        self._average = average
        self._avg_alpha = avg_alpha
        self.set_avg_alpha(avg_alpha)
        self.set_average(average)
示例#27
0
	def __init__(self, samp_rate=1600000, samp_per_sym=16, verbose=0, msgq=0, freq_error=-0.0025000):
		gr.hier_block2.__init__(
			self, "Wmbus Phy1",
			gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
			gr.io_signature(0, 0, 0),
		)

		##################################################
		# Parameters
		##################################################
		self.samp_rate = samp_rate
		self.samp_per_sym = samp_per_sym
		self.verbose = verbose
		self.msgq = msgq
		self.freq_error = freq_error

		##################################################
		# Blocks
		##################################################
		self.wmbus_demod_0 = wmbus_demod(
			samp_rate=1600000,
			samp_per_sym=16,
			freq_error=-0.0025000,
		)
		self.gr_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0)
		self.gr_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
		self.fir_filter_xxx_0 = gnuradio.filter.fir_filter_fff(samp_per_sym, (16*[1./16]))
		self.any_sink_0_1 = mbus.framer(msgq, verbose) 
		self.any_0 = mbus.correlate_preamble()

		##################################################
		# Connections
		##################################################
		self.connect((self.any_0, 0), (self.any_sink_0_1, 0))
		self.connect((self.gr_complex_to_mag_squared_0, 0), (self.gr_nlog10_ff_0, 0))
		self.connect((self.gr_nlog10_ff_0, 0), (self.fir_filter_xxx_0, 0))
		self.connect((self.fir_filter_xxx_0, 0), (self.any_sink_0_1, 1))
		self.connect((self, 0), (self.gr_complex_to_mag_squared_0, 0))
		self.connect((self, 0), (self.wmbus_demod_0, 0))
		self.connect((self.wmbus_demod_0, 0), (self.any_0, 0))
示例#28
0
 def test_symbol_src ( self, arity ):
   vlen = 1
   N = int( 1e7 )
   
   demapper = ofdm.generic_demapper_vcb( vlen )
   const = demapper.get_constellation( arity )
   assert( len( const ) == 2**arity )
   
   symsrc = ofdm.symbol_random_src( const, vlen )
   # tx = transmitter_hier_bc(M=M,K=K,qam_size=qam_size,syms_per_frame=syms_per_frame,theta_sel=theta_sel,exclude_preamble=exclude_preamble,sel_preamble=None)
   acc = ofdm.accumulator_cc()
   skiphead = blocks.skiphead( gr.sizeof_gr_complex, N-1 )
   limit = blocks.head( gr.sizeof_gr_complex, 1 )
   dst = blocks.vector_sink_c()
   
   c2mag = blocks.complex_to_mag_squared()
   acc_c2m = ofdm.accumulator_ff()
   skiphead_c2m = blocks.skiphead( gr.sizeof_float, N-1 )
   limit_c2m = blocks.head( gr.sizeof_float, 1 )
   dst_c2m = blocks.vector_sink_f()
   
   tb = gr.top_block ( "test__block" )
   tb.connect( symsrc, acc, skiphead, limit, dst )
   tb.connect( symsrc, c2mag, acc_c2m, skiphead_c2m, limit_c2m, dst_c2m )
   tb.run()
   
   data = numpy.array( dst.data() )
   data_c2m = numpy.array( dst_c2m.data() )
   
   m = data / N
   av_pow = data_c2m / N
   
   assert( abs( m ) < 0.01 )
   assert( abs( 1.0 - av_pow ) < 0.5  )
   
   print "Uniform distributed random symbol source has"
   print "\tno offset for N=%d, relative error: %f" % (arity, abs( m ) )
   print "\tAverage signal power equal 1.0, relative error: %f\t\tOK" \
          % ( abs( 1.0 - av_pow ) )
示例#29
0
    def __init__(self, rate, threshold, queue, use_pmf=False, use_dcblock=False):
        gr.hier_block2.__init__(self, "modes_rx_path",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(0,0,0))

        self._rate = int(rate)
        self._threshold = threshold
        self._queue = queue
        self._spc = int(rate/2e6)

        # Convert incoming I/Q baseband to amplitude
        self._demod = blocks.complex_to_mag_squared()
        if use_dcblock:
            self._dcblock = filter.dc_blocker_cc(100*self._spc,False)
            self.connect(self, self._dcblock, self._demod)
        else:
            self.connect(self, self._demod)
            self._dcblock = None

        self._bb = self._demod
        # Pulse matched filter for 0.5us pulses
        if use_pmf:
            self._pmf = blocks.moving_average_ff(self._spc, 1.0/self._spc)#, self._rate)
            self.connect(self._demod, self._pmf)
            self._bb = self._pmf

        # Establish baseline amplitude (noise, interference)
        self._avg = blocks.moving_average_ff(48*self._spc, 1.0/(48*self._spc))#, self._rate) # 3 preambles

        # Synchronize to Mode-S preamble
        self._sync = air_modes_swig.preamble(self._rate, self._threshold)

        # Slice Mode-S bits and send to message queue
        self._slicer = air_modes_swig.slicer(self._queue)

        # Wire up the flowgraph
        self.connect(self._bb, (self._sync, 0))
        self.connect(self._bb, self._avg, (self._sync, 1))
        self.connect(self._sync, self._slicer)
示例#30
0
    def __init__(self, src="uhd", dst=None, repeat=False, reader=True, tag=True, samp_rate=2e6, emulator=None):
        gr.hier_block2.__init__(self, "decoder",
                gr.io_signature(0, 0, 0), # Input signature
                gr.io_signature(0, 0, 0)) # Output signature

        if src == "uhd":
            self._src = usrp_src.usrp_src(samp_rate=samp_rate, dst=dst)
            hi_val = 1.1
        else:
            self._wav = blocks.wavfile_source(src, repeat)
            self._r2c = blocks.float_to_complex(1)
            self._src = blocks.complex_to_mag_squared(1)
            self.connect(self._wav, self._r2c, self._src)
            hi_val = 1.09 # may need to be set to 1.05 depending on antenna setup

        self._back = background.background(reader, tag, emulator)    
        self._trans = transition_sink.transition_sink(samp_rate, self._back.append, hi_val=hi_val)
        self._connect(self._src, self._trans)

        if dst and dst != "uhd" and src == "uhd":
            self._rec = record.record(dst, samp_rate)
            self._connect(self._src, self._rec)
示例#31
0
    def __do_connect(self):
        itemsize = self.__itemsize

        if self.__signal_type.is_analytic():
            input_length = self.__freq_resolution
            output_length = self.__freq_resolution
            self.__after_fft = None
        else:
            # use vector_to_streams to cut the output in half and discard the redundant part
            input_length = self.__freq_resolution * 2
            output_length = self.__freq_resolution
            self.__after_fft = blocks.vector_to_streams(
                itemsize=output_length * gr.sizeof_float, nstreams=2)

        sample_rate = self.__signal_type.get_sample_rate()
        overlap_factor = int(
            math.ceil(_maximum_fft_rate * input_length / sample_rate))
        # sanity limit -- OverlapGimmick is not free
        overlap_factor = min(16, overlap_factor)

        self.__frame_rate_to_decimation_conversion = sample_rate * overlap_factor / input_length

        self.__gate = blocks.copy(itemsize)
        self.__gate.set_enabled(not self.__paused)

        overlapper = _OverlappedStreamToVector(size=input_length,
                                               factor=overlap_factor,
                                               itemsize=itemsize)

        self.__frame_dec = blocks.keep_one_in_n(
            itemsize=itemsize * input_length,
            n=max(
                1,
                int(
                    round(self.__frame_rate_to_decimation_conversion /
                          self.__frame_rate))))

        # the actual FFT logic, which is similar to GR's logpwrfft_c
        window = windows.build(self.__window_type, input_length, 6.76)
        window_power = sum(x * x for x in window)
        # TODO: use fft_vfc when applicable
        fft_block = (fft_vcc if itemsize == gr.sizeof_gr_complex else fft_vfc)(
            fft_size=input_length, forward=True, window=window)
        mag_squared = blocks.complex_to_mag_squared(input_length)
        logarithmizer = blocks.nlog10_ff(
            n=10,  # the "deci" in "decibel"
            vlen=input_length,
            k=(
                -to_dB(window_power) +  # compensate for window
                -to_dB(sample_rate)
                +  # convert from power-per-sample to power-per-Hz
                self.__power_offset  # offset for packing into bytes
            ))

        # It would make slightly more sense to use unsigned chars, but blocks.float_to_uchar does not support vlen.
        self.__fft_converter = blocks.float_to_char(
            vlen=self.__freq_resolution, scale=1.0)

        self.__fft_sink = blocks.message_sink(output_length * gr.sizeof_char,
                                              self.__fft_queue, True)
        self.__scope_sink = blocks.message_sink(
            self.__time_length * gr.sizeof_gr_complex, self.__scope_queue,
            True)
        scope_chunker = blocks.stream_to_vector_decimator(
            item_size=gr.sizeof_gr_complex,
            sample_rate=sample_rate,
            vec_rate=self.__frame_rate,  # TODO doesn't need to be coupled
            vec_len=self.__time_length)

        # connect everything
        self.__context.lock()
        try:
            self.disconnect_all()
            self.connect(self, self.__gate, overlapper, self.__frame_dec,
                         fft_block, mag_squared, logarithmizer)
            if self.__after_fft is not None:
                self.connect(logarithmizer, self.__after_fft)
                self.connect(self.__after_fft, self.__fft_converter,
                             self.__fft_sink)
                self.connect(
                    (self.__after_fft, 1),
                    blocks.null_sink(gr.sizeof_float * self.__freq_resolution))
            else:
                self.connect(logarithmizer, self.__fft_converter,
                             self.__fft_sink)
            if self.__enable_scope:
                self.connect(self.__gate, scope_chunker, self.__scope_sink)
        finally:
            self.__context.unlock()
示例#32
0
    def __init__(self):
        gr.top_block.__init__(self, "TX OFDM")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("TX OFDM")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

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

        ##################################################
        # Variables
        ##################################################
        self.fft_len = fft_len = 256
        self.fft2 = fft2 = int(fft_len / 2)
        self.pilot_symbols = pilot_symbols = ((
            1,
            1,
            1,
            -1,
        ), )
        self.pilot_carriers = pilot_carriers = ((
            -21,
            -7,
            7,
            21,
        ), )
        self.payload_mod = payload_mod = digital.constellation_qpsk()
        self.packet_length_tag_key = packet_length_tag_key = "packet_len"
        self.occupied_carriers = occupied_carriers = (
            list(range(-fft2, 0)) + list(range(1, fft2 + 1)), )
        self.num_syms = num_syms = 16
        self.length_tag_key = length_tag_key = "frame_len"
        self.header_mod = header_mod = digital.constellation_bpsk()
        self.tx_amp = tx_amp = 1
        self.sync_word2 = sync_word2 = [
            0j, 0j, 0j, 0j, 0j, 0j, (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j),
            (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j),
            (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j),
            (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j),
            (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), 0j, (1 + 0j), (-1 + 0j),
            (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j),
            (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j),
            (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j),
            (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j),
            0j, 0j, 0j, 0j, 0j
        ]
        self.sync_word1 = sync_word1 = [
            0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0.,
            -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            0., 0., 0., 0., 0.
        ]
        self.samp_rate = samp_rate = 1e6
        self.rx_gain = rx_gain = 30
        self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_static(
            fft_len, occupied_carriers, pilot_carriers, pilot_symbols, 0, True)
        self.packet_len = packet_len = int(96 / 8 * num_syms)
        self.offset = offset = 8
        self.header_formatter = header_formatter = digital.packet_header_ofdm(
            occupied_carriers,
            n_syms=1,
            len_tag_key=packet_length_tag_key,
            frame_len_tag_key=length_tag_key,
            bits_per_header_sym=header_mod.bits_per_symbol(),
            bits_per_payload_sym=payload_mod.bits_per_symbol(),
            scramble_header=False)
        self.header_equalizer = header_equalizer = digital.ofdm_equalizer_static(
            fft_len, occupied_carriers, pilot_carriers, pilot_symbols, 0, True)
        self.freqc = freqc = 900e6
        self.frame_len = frame_len = 4096

        ##################################################
        # Blocks
        ##################################################
        self._tx_amp_range = Range(0, 2, .001, 1, 200)
        self._tx_amp_win = RangeWidget(self._tx_amp_range, self.set_tx_amp,
                                       'TX Amplitude', "counter_slider", float)
        self.top_grid_layout.addWidget(self._tx_amp_win, 1, 0, 1, 8)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_gain_range = Range(0, 64, 1, 30, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        'RX Gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._rx_gain_win, 0, 0, 1, 8)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.wes_max_ff_0 = wes.max_ff(frame_len)
        self.qtgui_number_sink_0_1 = qtgui.number_sink(gr.sizeof_float, 0,
                                                       qtgui.NUM_GRAPH_HORIZ,
                                                       1)
        self.qtgui_number_sink_0_1.set_update_time(0.10)
        self.qtgui_number_sink_0_1.set_title('PAPR (dB)')

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

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

        self.qtgui_number_sink_0_1.enable_autoscale(False)
        self._qtgui_number_sink_0_1_win = sip.wrapinstance(
            self.qtgui_number_sink_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_1_win, 11, 4,
                                       1, 4)
        for r in range(11, 12):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_HORIZ, 1)
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title('PAPR')

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

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

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 11, 0, 1,
                                       4)
        for r in range(11, 12):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate * 2,  #bw
            "",  #name
            1)
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-120, -40)
        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.1)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(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 range(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 2, 0, 8,
                                       8)
        for r in range(2, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.iio_pluto_source_0 = iio.pluto_source('usb:1.4.5', int(freqc),
                                                   int(samp_rate * 2),
                                                   20000000, 32768, True, True,
                                                   True, 'manual', rx_gain, '',
                                                   True)
        self.iio_pluto_sink_0 = iio.pluto_sink('usb:1.3.5', int(freqc),
                                               int(samp_rate), 20000000, 32768,
                                               False, 10.0, '', True)
        self.digital_ofdm_tx_0 = digital.ofdm_tx(
            fft_len=fft_len,
            cp_len=fft_len // 4,
            packet_length_tag_key=packet_length_tag_key,
            occupied_carriers=occupied_carriers,
            bps_header=2,
            bps_payload=2,
            rolloff=0,
            debug_log=False,
            scramble_bits=False)
        self.blocks_vector_source_x_0 = blocks.vector_source_b((1, 1, 1, 1),
                                                               True, 1, [])
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, packet_len, packet_length_tag_key)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(tx_amp /
                                                                    30)
        self.blocks_moving_average_xx_0_0 = blocks.moving_average_ff(
            frame_len, 1 / frame_len, frame_len * 4, 1)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            frame_len, 1 / frame_len, frame_len * 4, 1)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.wes_max_ff_0, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.blocks_moving_average_xx_0_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_moving_average_xx_0_0, 0),
                     (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_moving_average_xx_0_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.iio_pluto_sink_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.qtgui_number_sink_0_1, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0),
                     (self.digital_ofdm_tx_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.digital_ofdm_tx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.iio_pluto_source_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.wes_max_ff_0, 0), (self.blocks_divide_xx_0, 0))
    def __init__(self,
                 fft_len,
                 sens_per_sec,
                 sample_rate,
                 channel_space=1,
                 search_bw=1,
                 tune_freq=0,
                 trunc_band=1,
                 verbose=False,
                 output=False,
                 subject_channels=[]):
        gr.hier_block2.__init__(self, "multichannel_scanner",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(0, 0, 0))
        self.fft_len = fft_len  #lenght of the fft for spectral analysis
        self.sens_per_sec = sens_per_sec  #number of measurements per second (decimates)
        self.sample_rate = sample_rate
        self.channel_space = channel_space  #channel space for analysis
        self.search_bw = search_bw  #search bandwidth within each channel
        self.tune_freq = tune_freq  #center frequency
        self.verbose = verbose
        self.trunc_band = trunc_band
        self.output = output
        self.subject_channels = subject_channels
        self.subject_channels_pwr = np.array([1.0] *
                                             len(self.subject_channels))

        #gnuradio msg queues
        self.msgq0 = gr.msg_queue(2)

        #output top 4 freqs
        self.top4 = [
            self.subject_channels[0], self.subject_channels[0],
            self.subject_channels[0], self.subject_channels[0]
        ]

        #register message out to other blocks
        self.message_port_register_hier_out("freq_out_0")
        self.message_port_register_hier_out("freq_out_1")
        self.message_port_register_hier_out("freq_out_2")
        self.message_port_register_hier_out("freq_out_3")
        self.message_port_register_hier_out("freq_msg_PDU")

        #######BLOCKS#####
        self.s2p = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fft_len)
        self.one_in_n = blocks.keep_one_in_n(
            gr.sizeof_gr_complex * self.fft_len,
            max(1, int(self.sample_rate / self.fft_len / self.sens_per_sec)))

        mywindow = window.blackmanharris(self.fft_len)
        self.fft = fft.fft_vcc(self.fft_len, True, (), True)

        self.c2mag2 = blocks.complex_to_mag_squared(self.fft_len)
        self.multiply = blocks.multiply_const_vff(
            np.array([1.0 / float(self.fft_len**2)] * fft_len))

        #MSG sinks PSD data
        self.sink0 = blocks.message_sink(gr.sizeof_float * self.fft_len,
                                         self.msgq0, True)

        #MSG output blocks to other blocks
        self.message_out0 = blocks.message_strobe(
            pmt.cons(pmt.intern("freq"), pmt.to_pmt(self.top4[0])), 1000)
        self.message_out1 = blocks.message_strobe(
            pmt.cons(pmt.intern("freq"), pmt.to_pmt(self.top4[1])), 1000)
        self.message_out2 = blocks.message_strobe(
            pmt.cons(pmt.intern("freq"), pmt.to_pmt(self.top4[2])), 1000)
        self.message_out3 = blocks.message_strobe(
            pmt.cons(pmt.intern("freq"), pmt.to_pmt(self.top4[3])), 1000)
        self.PDU_messages = message_pdu(None)

        #####CONNECTIONS####
        print 'connecting elements'
        self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag2,
                     self.multiply, self.sink0)
        print 'elements connected'

        #MSG output
        self.msg_connect(self.message_out0, "strobe", self, "freq_out_0")
        self.msg_connect(self.message_out1, "strobe", self, "freq_out_1")
        self.msg_connect(self.message_out2, "strobe", self, "freq_out_2")
        self.msg_connect(self.message_out3, "strobe", self, "freq_out_3")
        self.msg_connect(self.PDU_messages, 'out', self, 'freq_msg_PDU')

        self._output_data = output_data(self.output, self.subject_channels,
                                        self.subject_channels_pwr,
                                        self.PDU_messages)

        self._basic_spectrum_watcher = basic_spectrum_watcher(
            self.msgq0, sens_per_sec, self.tune_freq, self.channel_space,
            self.search_bw, self.fft_len, self.sample_rate, trunc_band,
            verbose, self.subject_channels, self.set_freqs, self._output_data)
示例#34
0
    def __init__(self):
        gr.top_block.__init__(self,
                              "IEEE 802.15.4 Transceiver using OQPSK PHY")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("IEEE 802.15.4 Transceiver using OQPSK PHY")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(
                self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = float(d_txdb)
        self.samp = samp = 4
        self.rx_gain = rx_gain = float(d_rxdb)
        self.freq = freq = float(d_freq)
        self.buf = buf = 0x8000
        self.bits = bits = 16
        self.samp_rate = samp_rate = 4e6

        ##################################################
        # Blocks
        ##################################################
        self._tx_gain_range = Range(-20, 64, 0.01, tx_gain, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        "tx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._tx_gain_win)
        self._rx_gain_range = Range(0, 72, 0.01, rx_gain, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        "rx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._rx_gain_win)
        self._freq_options = [2450000000, 915000000, 430000000]
        self._freq_labels = ['2.45GHz', '915MHz', '430MHz']
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel('Channel' + ": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels:
            self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._freq_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
            lambda i: self.set_freq(self._freq_options[i]))
        self.top_layout.addWidget(self._freq_tool_bar)
        self._bits_range = Range(1, 127, 1, 16, 200)
        self._bits_win = RangeWidget(self._bits_range, self.set_bits, "bits",
                                     "counter_slider", int)
        self.top_layout.addWidget(self._bits_win)
        self.qtgui_time_sink_x_0_1_0 = qtgui.time_sink_f(
            buf * 16,  #size
            samp_rate,  #samp_rate
            "HSS OQPSK",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_1_0.set_y_axis(0, 2e-4)

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

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

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

        self._qtgui_time_sink_x_0_1_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_1_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_1_0_win)
        self.pluto_source_0 = iio.pluto_source(d_rxid, int(freq), int(4e6),
                                               int(20000000), buf * 16, True,
                                               True, True, "manual", rx_gain,
                                               '', True)
        self.pluto_sink_0 = iio.pluto_sink(d_txid, int(freq), int(4e6),
                                           int(20000000), buf, True, tx_gain,
                                           '', True)
        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(
            ([129]), ([131]), ([132]), ([23, 42]))

        self.ieee802_15_4_phy_0 = ieee802_15_4_oqpsk_phy()
        if argv[7] == 'ook':
            self.ieee802_15_4_phy_0 = ieee802_15_4_ook_phy(
                threshold=float(argv[8]))
        if argv[7] == 'fsk':
            self.ieee802_15_4_phy_0 = ieee802_15_4_cpfsk_phy()

        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(False, 0x8841, 0, 0x1aaa,
                                                   0xffff, 0x3344)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", '',
                                                       '52001', 10000, False)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1)
        self.blocks_message_strobe_0_0 = blocks.message_strobe(
            pmt.intern('a' * bits), 10)
        self.blocks_file_sink_1_0_0 = blocks.file_sink(
            gr.sizeof_float * 1, '/home/hrbenitez/Desktop/just_sig.bin', False)
        self.blocks_file_sink_1_0_0.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/hrbenitez/Desktop/2_pluto.pcap', False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'),
                         (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'),
                         (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'),
                         (self.ieee802_15_4_phy_0, 'txin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'),
                         (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_phy_0, 'rxout'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.ieee802_15_4_phy_0, 'rxout'),
                         (self.ieee802_15_4_mac_0, 'pdu in'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'),
                         (self.blocks_socket_pdu_0_0, 'pdus'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'),
                         (self.ieee802_15_4_mac_0, 'app in'))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_file_sink_1_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.qtgui_time_sink_x_0_1_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.ieee802_15_4_phy_0, 2),
                     (self.blocks_null_sink_0, 1))
        self.connect((self.ieee802_15_4_phy_0, 3),
                     (self.blocks_null_sink_0, 2))
        self.connect((self.ieee802_15_4_phy_0, 1),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.ieee802_15_4_phy_0, 0), (self.pluto_sink_0, 0))
        self.connect((self.pluto_source_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.pluto_source_0, 0), (self.ieee802_15_4_phy_0, 0))
示例#35
0
    def __init__(self, end_f=500e6, parameter_0=0, start_f=50e6):
        gr.top_block.__init__(self, "Electosense")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Electosense")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

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

        ##################################################
        # Parameters
        ##################################################
        self.end_f = end_f
        self.parameter_0 = parameter_0
        self.start_f = start_f

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2e6
        self.prober = prober = 1
        self.hop_mode = hop_mode = 1
        self.variable_0 = variable_0 = 0
        self.tune_delay = tune_delay = 50e-3
        self.sensorid = sensorid = 123456
        self.rfgain = rfgain = 40
        self.ppm = ppm = 0
        self.navg_vectors = navg_vectors = 100
        self.fft_size = fft_size = 512
        self.cfreq = cfreq = scanning.step(start_f, end_f, samp_rate / 1.5,
                                           prober, hop_mode, 0.8, 0.8)
        self.alpha = alpha = 0.75

        ##################################################
        # Blocks
        ##################################################
        self.vecprobe = blocks.probe_signal_vf(fft_size)
        self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(
            alpha, fft_size)
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              '')
        self.rtlsdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(cfreq, 0)
        self.rtlsdr_source_0.set_freq_corr(ppm, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(2, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(2, 0)
        self.rtlsdr_source_0.set_gain_mode(True, 0)
        self.rtlsdr_source_0.set_gain(rfgain, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna('', 0)
        self.rtlsdr_source_0.set_bandwidth(250e3, 0)
        self.qtgui_vector_sink_f_0 = qtgui.vector_sink_f(
            fft_size,
            0,
            1.0,
            "x-Axis",
            "y-Axis",
            "",
            1  # Number of inputs
        )
        self.qtgui_vector_sink_f_0.set_update_time(0.10)
        self.qtgui_vector_sink_f_0.set_y_axis(-140, 10)
        self.qtgui_vector_sink_f_0.enable_autoscale(False)
        self.qtgui_vector_sink_f_0.enable_grid(False)
        self.qtgui_vector_sink_f_0.set_x_axis_units("")
        self.qtgui_vector_sink_f_0.set_y_axis_units("")
        self.qtgui_vector_sink_f_0.set_ref_level(0)

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

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

        self._qtgui_vector_sink_f_0_win = sip.wrapinstance(
            self.qtgui_vector_sink_f_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_vector_sink_f_0_win)

        def _prober_probe():
            while True:

                val = self.vecprobe.level()
                try:
                    self.set_prober(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (1 /
                                  (tune_delay +
                                   (1 / samp_rate * fft_size * navg_vectors))))

        _prober_thread = threading.Thread(target=_prober_probe)
        _prober_thread.daemon = True
        _prober_thread.start()

        self.fft_vxx_0 = fft.fft_vcc(fft_size, True,
                                     window.blackmanharris(fft_size), True, 1)
        self.electrosense_discard_samples_0 = electrosense.discard_samples(
            int(tune_delay * samp_rate), int(cfreq), pmt.intern("burst_len"),
            False)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, fft_size)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(1, fft_size, 0)
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(
            gr.sizeof_float * fft_size, navg_vectors)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(
            fft_size)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.single_pole_iir_filter_xx_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0),
                     (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0), (self.vecprobe, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.qtgui_vector_sink_f_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.electrosense_discard_samples_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.electrosense_discard_samples_0, 0))
        self.connect((self.single_pole_iir_filter_xx_0, 0),
                     (self.blocks_keep_one_in_n_0, 0))
示例#36
0
    def __init__(self):
        gr.top_block.__init__(self)

        usage = "usage: %prog [options] min_freq max_freq"
        parser = OptionParser(option_class=eng_option, usage=usage)
        parser.add_option(
            "-a",
            "--args",
            type="string",
            default="",
            help="UHD device device address args [default=%default]")
        parser.add_option("",
                          "--spec",
                          type="string",
                          default=None,
                          help="Subdevice of UHD device where appropriate")
        parser.add_option("-A",
                          "--antenna",
                          type="string",
                          default=None,
                          help="select Rx Antenna where appropriate")
        parser.add_option("-s",
                          "--samp-rate",
                          type="eng_float",
                          default=1e6,
                          help="set sample rate [default=%default]")
        parser.add_option("-g",
                          "--gain",
                          type="eng_float",
                          default=None,
                          help="set gain in dB (default is midpoint)")
        parser.add_option(
            "",
            "--tune-delay",
            type="eng_float",
            default=0.25,
            metavar="SECS",
            help=
            "time to delay (in seconds) after changing frequency [default=%default]"
        )
        parser.add_option(
            "",
            "--dwell-delay",
            type="eng_float",
            default=0.25,
            metavar="SECS",
            help=
            "time to dwell (in seconds) at a given frequency [default=%default]"
        )
        parser.add_option(
            "-b",
            "--channel-bandwidth",
            type="eng_float",
            default=6.25e3,
            metavar="Hz",
            help="channel bandwidth of fft bins in Hz [default=%default]")
        parser.add_option("-l",
                          "--lo-offset",
                          type="eng_float",
                          default=0,
                          metavar="Hz",
                          help="lo_offset in Hz [default=%default]")
        parser.add_option("-q",
                          "--squelch-threshold",
                          type="eng_float",
                          default=None,
                          metavar="dB",
                          help="squelch threshold in dB [default=%default]")
        parser.add_option(
            "-F",
            "--fft-size",
            type="int",
            default=None,
            help="specify number of FFT bins [default=samp_rate/channel_bw]")
        parser.add_option("",
                          "--real-time",
                          action="store_true",
                          default=False,
                          help="Attempt to enable real-time scheduling")

        (options, args) = parser.parse_args()
        if len(args) != 2:
            parser.print_help()
            sys.exit(1)

        self.channel_bandwidth = options.channel_bandwidth

        self.min_freq = eng_notation.str_to_num(args[0])
        self.max_freq = eng_notation.str_to_num(args[1])

        if self.min_freq > self.max_freq:
            # swap them
            self.min_freq, self.max_freq = self.max_freq, self.min_freq

        if not options.real_time:
            realtime = False
        else:
            # Attempt to enable realtime scheduling
            r = gr.enable_realtime_scheduling()
            if r == gr.RT_OK:
                realtime = True
            else:
                realtime = False
                print "Note: failed to enable realtime scheduling"

        # build graph
        self.u = uhd.usrp_source(device_addr=options.args,
                                 stream_args=uhd.stream_args('fc32'))

        # Set the subdevice spec
        if (options.spec):
            self.u.set_subdev_spec(options.spec, 0)

        # Set the antenna
        if (options.antenna):
            self.u.set_antenna(options.antenna, 0)

        self.u.set_samp_rate(options.samp_rate)
        self.usrp_rate = usrp_rate = self.u.get_samp_rate()

        self.lo_offset = options.lo_offset

        if options.fft_size is None:
            self.fft_size = int(self.usrp_rate / self.channel_bandwidth)
        else:
            self.fft_size = options.fft_size

        self.squelch_threshold = options.squelch_threshold

        s2v = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fft_size)

        mywindow = filter.window.blackmanharris(self.fft_size)
        ffter = fft.fft_vcc(self.fft_size, True, mywindow, True)
        power = 0
        for tap in mywindow:
            power += tap * tap

        c2mag = blocks.complex_to_mag_squared(self.fft_size)

        # FIXME the log10 primitive is dog slow
        #log = blocks.nlog10_ff(10, self.fft_size,
        #                       -20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size))

        # Set the freq_step to 75% of the actual data throughput.
        # This allows us to discard the bins on both ends of the spectrum.

        self.freq_step = self.nearest_freq((0.75 * self.usrp_rate),
                                           self.channel_bandwidth)
        self.min_center_freq = self.min_freq + (self.freq_step / 2)
        nsteps = math.ceil((self.max_freq - self.min_freq) / self.freq_step)
        self.nstep = nsteps
        #mydata = open('flag_nstep', mode = 'a+')#将nsteps传给tx_control.py,因为tx_control.py需要使用这个参数以实现循环读文本
        self.max_center_freq = self.min_center_freq + (nsteps * self.freq_step)

        self.next_freq = self.min_center_freq

        tune_delay = max(
            0,
            int(round(options.tune_delay * usrp_rate /
                      self.fft_size)))  #调频延时转化为 FFT 计算时忽略的向量个数。 in fft_frames
        dwell_delay = max(
            1, int(round(options.dwell_delay * usrp_rate / self.fft_size)
                   ))  # in fft_frames,一个扫频范围内停留的时间.(原输入参数是一个频点的扫的时间,)

        self.msgq = gr.msg_queue(1)
        self._tune_callback = tune(
            self)  # hang on to this to keep it from being GC'd
        stats = blocks.bin_statistics_f(self.fft_size, self.msgq,
                                        self._tune_callback, tune_delay,
                                        dwell_delay)
        #mydata = open('mydata.log', mode = 'a+')
        print "usrp_rate=",self.usrp_rate,"channel_bandwidth(频谱分辨率)=",self.channel_bandwidth,\
          "fft_size= ",self.fft_size ,"freq_step(扫频长度)=", self.freq_step,"nsteps=",nsteps  #,"tune_delay=",tune_delay,"dwell_delay=",dwell_delay
        #mydata.close()

        # FIXME leave out the log10 until we speed it up
        #self.connect(self.u, s2v, ffter, c2mag, log, stats)
        self.connect(self.u, s2v, ffter, c2mag, stats)

        if options.gain is None:
            # if no gain was specified, use the mid-point in dB
            g = self.u.get_gain_range()
            options.gain = float(g.start() + g.stop()) / 2.0

        self.set_gain(options.gain)
        print "gain =", options.gain
示例#37
0
    def __init__(self):
        gr.top_block.__init__(self, "HFS first channel")

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

        ##################################################
        # Blocks
        ##################################################
        self.snr_out = blocks.probe_signal_f()
        self.out_rms = blocks.probe_signal_f()

        def _snr_out_func_probe():
            while True:

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

        _snr_out_func_thread = threading.Thread(target=_snr_out_func_probe)
        _snr_out_func_thread.daemon = True
        _snr_out_func_thread.start()

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

        def _out_rms_func_probe():
            while True:

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

        _out_rms_func_thread = threading.Thread(target=_out_rms_func_probe)
        _out_rms_func_thread.daemon = True
        _out_rms_func_thread.start()

        self.low_pass_filter_2 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 1550, 100, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_1_0 = filter.interp_fir_filter_ccf(
            int(samp_rate / 100),
            firdes.low_pass(ampl[0][1] * (samp_rate / 100.0), samp_rate, 50,
                            25, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_1 = filter.interp_fir_filter_ccf(
            int(samp_rate / 100),
            firdes.low_pass(ampl[0][0] * (samp_rate / 100.0), samp_rate, 50,
                            25, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 1750 + 100, 600, firdes.WIN_HAMMING,
                            6.76))
        self.epy_block_0_0 = epy_block_0_0.blk(fd=fd)
        self.epy_block_0 = epy_block_0.blk(fd=fd)
        self.blocks_selector_0_0 = blocks.selector(gr.sizeof_gr_complex * 1,
                                                   noSpread, 0)
        self.blocks_selector_0_0.set_enabled(True)
        self.blocks_selector_0 = blocks.selector(gr.sizeof_gr_complex * 1,
                                                 noSpread, 0)
        self.blocks_selector_0.set_enabled(True)
        self.blocks_rms_xx_0_0 = blocks.rms_ff(2 * pi * tau_a * 10 / samp_rate)
        self.blocks_rms_xx_0 = blocks.rms_cf(2 * pi * tau_a * 100 / samp_rate)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0_0_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_3 = blocks.multiply_const_ff(en_noise)
        self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_cc(vol)
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_cc(vol)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_ff(
            2 * sqrt(ampl[0][0]**2 + ampl[0][1]**2) * 2)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_ff(0.5)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(0.5)
        self.blocks_float_to_complex_1 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_divide_xx_1 = blocks.divide_ff(1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                           int(tau * samp_rate))
        self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_mag_squared_2_0 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_mag_squared_2 = blocks.complex_to_mag_squared(1)
        self.blocks_add_xx_1 = blocks.add_vff(1)
        self.blocks_add_xx_0_0 = blocks.add_vcc(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.audio_source_0 = audio.source(samp_rate, 'in1', True)
        self.audio_sink_0_0_0 = audio.sink(samp_rate, 'out3', False)
        self.audio_sink_0_0 = audio.sink(samp_rate, 'out2', False)
        self.analog_sig_source_x_2 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 1850, 1, 0, 0)
        self.analog_sig_source_x_1 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, freqShift, 1, 0, 0)
        self.analog_sig_source_x_0_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 1850, 1, 0, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -1850, 1, 0, 0)
        self.analog_noise_source_x_1 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1e-0 * kN, 3)
        self.analog_fastnoise_source_x_2 = analog.fastnoise_source_c(
            analog.GR_GAUSSIAN, 1, 1, 8192)
        self.analog_fastnoise_source_x_1 = analog.fastnoise_source_c(
            analog.GR_GAUSSIAN, 1, 0, 8192)
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_f(
            analog.GR_GAUSSIAN, 0.3, 0, 8192)
        self.analog_const_source_x_2 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_1_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, ampl[0][1])
        self.analog_const_source_x_1 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, ampl[0][0])
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.analog_const_source_x_1, 0),
                     (self.blocks_selector_0, 1))
        self.connect((self.analog_const_source_x_1_0, 0),
                     (self.blocks_selector_0_0, 1))
        self.connect((self.analog_const_source_x_2, 0),
                     (self.blocks_float_to_complex_1, 1))
        self.connect((self.analog_fastnoise_source_x_0, 0),
                     (self.blocks_multiply_const_vxx_3, 0))
        self.connect((self.analog_fastnoise_source_x_1, 0),
                     (self.epy_block_0, 0))
        self.connect((self.analog_fastnoise_source_x_2, 0),
                     (self.epy_block_0_0, 0))
        self.connect((self.analog_noise_source_x_1, 0),
                     (self.low_pass_filter_2, 0))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_0_0_0, 0),
                     (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.analog_sig_source_x_2, 0),
                     (self.blocks_multiply_xx_0_0_0_0_0, 1))
        self.connect((self.audio_source_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_add_xx_0_0, 0),
                     (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.audio_sink_0_0, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.blocks_rms_xx_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_2, 0),
                     (self.single_pole_iir_filter_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_2_0, 0),
                     (self.single_pole_iir_filter_xx_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_complex_to_real_0_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_multiply_xx_0_0_0_0, 0))
        self.connect((self.blocks_divide_xx_1, 0),
                     (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_float_to_complex_1, 0),
                     (self.blocks_multiply_xx_0_0_0_0_0, 2))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_add_xx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.audio_sink_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_float_to_complex_1, 0))
        self.connect((self.blocks_multiply_const_vxx_2, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_multiply_const_vxx_2_0, 0),
                     (self.blocks_complex_to_real_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_3, 0),
                     (self.blocks_add_xx_1, 1))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.blocks_multiply_xx_0_0_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.blocks_rms_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0_0_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0_0_0_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_xx_0_0_0_0_0, 0),
                     (self.blocks_add_xx_0_0, 1))
        self.connect((self.blocks_multiply_xx_0_0_0_0_0, 0),
                     (self.blocks_complex_to_mag_squared_2_0, 0))
        self.connect((self.blocks_multiply_xx_0_0_0_0_0, 0),
                     (self.blocks_multiply_const_vxx_2_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0),
                     (self.blocks_add_xx_0_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0),
                     (self.blocks_complex_to_mag_squared_2, 0))
        self.connect((self.blocks_nlog10_ff_0, 0), (self.snr_out, 0))
        self.connect((self.blocks_rms_xx_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_rms_xx_0_0, 0), (self.out_rms, 0))
        self.connect((self.blocks_selector_0, 0),
                     (self.blocks_multiply_xx_0_0_0, 1))
        self.connect((self.blocks_selector_0_0, 0),
                     (self.blocks_multiply_xx_0_0_0_0, 1))
        self.connect((self.epy_block_0, 0), (self.low_pass_filter_1, 0))
        self.connect((self.epy_block_0_0, 0), (self.low_pass_filter_1_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.low_pass_filter_1, 0), (self.blocks_selector_0, 0))
        self.connect((self.low_pass_filter_1_0, 0),
                     (self.blocks_selector_0_0, 0))
        self.connect((self.low_pass_filter_2, 0),
                     (self.blocks_multiply_xx_0_0_0_0_0, 0))
        self.connect((self.single_pole_iir_filter_xx_0, 0),
                     (self.blocks_divide_xx_1, 0))
        self.connect((self.single_pole_iir_filter_xx_0_0, 0),
                     (self.blocks_divide_xx_1, 1))
示例#38
0
    def __init__(self):
        gr.top_block.__init__(self, "Wifi Rx Rftap Nox")

        ##################################################
        # Variables
        ##################################################
        self.window_size = window_size = 48
        self.sync_length = sync_length = 320
        self.samp_rate = samp_rate = 20e6
        self.freq = freq = 2.4e9
        self.chan_est = chan_est = ieee802_11.LMS

        ##################################################
        # Blocks
        ##################################################
        self.rftap_rftap_encap_0 = rftap.rftap_encap(0, -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(freq, 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(10, 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.ieee802_11_sync_short_0 = ieee802_11.sync_short(
            0.56, 2, False, False)
        self.ieee802_11_sync_long_0 = ieee802_11.sync_long(
            sync_length, False, False)
        self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(
            self.freq, True, False)
        self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff(
            window_size + 16)
        self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc(
            window_size)
        self.ieee802_11_frame_equalizer_0 = ieee802_11.frame_equalizer(
            chan_est, freq, samp_rate, False, False)
        self.ieee802_11_decode_mac_0 = ieee802_11.decode_mac(False, False)
        self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True,
                                     1)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 64)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1",
                                                     "52001", 10000, False)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, 16)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                           sync_length)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ieee802_11_decode_mac_0, 'out'),
                         (self.ieee802_11_parse_mac_0, 'in'))
        self.msg_connect((self.ieee802_11_decode_mac_0, 'out'),
                         (self.rftap_rftap_encap_0, 'in'))
        self.msg_connect((self.rftap_rftap_encap_0, 'out'),
                         (self.blocks_socket_pdu_0, 'pdus'))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_divide_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.ieee802_11_moving_average_xx_1, 0))
        self.connect((self.blocks_conjugate_cc_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_delay_0, 0),
                     (self.ieee802_11_sync_long_0, 1))
        self.connect((self.blocks_delay_0_0, 0),
                     (self.blocks_conjugate_cc_0, 0))
        self.connect((self.blocks_delay_0_0, 0),
                     (self.ieee802_11_sync_short_0, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.ieee802_11_sync_short_0, 2))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.ieee802_11_moving_average_xx_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.ieee802_11_frame_equalizer_0, 0))
        self.connect((self.ieee802_11_frame_equalizer_0, 0),
                     (self.ieee802_11_decode_mac_0, 0))
        self.connect((self.ieee802_11_moving_average_xx_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.ieee802_11_moving_average_xx_0, 0),
                     (self.ieee802_11_sync_short_0, 1))
        self.connect((self.ieee802_11_moving_average_xx_1, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.ieee802_11_sync_long_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.ieee802_11_sync_short_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.ieee802_11_sync_short_0, 0),
                     (self.ieee802_11_sync_long_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.blocks_delay_0_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.blocks_multiply_xx_0, 0))
示例#39
0
    def __init__(self, fftsize, samp_rate, gain, c_freq):
        gr.top_block.__init__(self, "Receiver")

        #Class variables
        self.samp_rate = samp_rate
        self.gain = gain
        self.fftsize = fftsize
        self.c_freq = c_freq
        self.dump1 = "/tmp/ramdisk/dump1"  #View as null sinks
        self.dump2 = "/tmp/ramdisk/dump2"
        self.dump3 = "/tmp/ramdisk/dump3"
        self.dump4 = "/tmp/ramdisk/dump4"
        self.alpha = 0.01  #Integrate 100 FFTS 0.01
        self.N = 100  #100
        self.probe_var = probe_var = 0
        self.probe_var_1 = probe_var_1 = 0

        ########## GNURADIO BLOCKS #########
        ####################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(
                ("", "")
            ),  #Set the master_clock_rate, default = 200 MHz, alt 184.32 MHz and 120 MHz (Set)
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(2),
            ),
        )
        #Configure USRP channel 0
        self.uhd_usrp_source_0.set_antenna("RX2", 0)
        self.uhd_usrp_source_0.set_samp_rate(self.samp_rate)
        self.uhd_usrp_source_0.set_center_freq(self.c_freq, 0)
        self.uhd_usrp_source_0.set_gain(self.gain, 0)
        self.uhd_usrp_source_0.set_bandwidth(self.samp_rate, 0)
        self.uhd_usrp_source_0.set_clock_source('external')

        #Configure USRP channel 1
        self.uhd_usrp_source_0.set_antenna("RX2", 1)
        self.uhd_usrp_source_0.set_center_freq(self.c_freq, 1)
        self.uhd_usrp_source_0.set_gain(self.gain, 1)
        self.uhd_usrp_source_0.set_bandwidth(self.samp_rate, 1)
        #self.uhd_usrp_source_0.set_clock_source('external', 1)

        #Signal and reference file sinks channel 0
        self.signal_file_sink_1 = blocks.file_sink(gr.sizeof_float * 1,
                                                   self.dump1, False)
        self.signal_file_sink_1.set_unbuffered(False)
        self.signal_file_sink_2 = blocks.file_sink(gr.sizeof_float * 1,
                                                   self.dump2, False)
        self.signal_file_sink_2.set_unbuffered(False)

        #Signal and reference file sinks channel 1
        self.signal_file_sink_3 = blocks.file_sink(gr.sizeof_float * 1,
                                                   self.dump3, False)
        self.signal_file_sink_3.set_unbuffered(False)
        self.signal_file_sink_4 = blocks.file_sink(gr.sizeof_float * 1,
                                                   self.dump4, False)
        self.signal_file_sink_4.set_unbuffered(False)

        #Selector for GPIO switch channel 0
        self.blks2_selector_0 = grc_blks2.selector(
            item_size=gr.sizeof_float * 1,
            num_inputs=1,
            num_outputs=3,  #+1 for the null sink
            input_index=0,
            output_index=0,
        )
        #Selector for GPIO switch channel 1
        self.blks2_selector_1 = grc_blks2.selector(
            item_size=gr.sizeof_float * 1,
            num_inputs=1,
            num_outputs=3,  #+1 for the null sink
            input_index=0,
            output_index=0,
        )

        #Div blocks channel 0
        self.blocks_null_sink = blocks.null_sink(gr.sizeof_float * 1)
        self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(
            self.alpha, self.fftsize)
        self.fft_vxx_0 = fft.fft_vcc(self.fftsize, True,
                                     (window.blackmanharris(self.fftsize)),
                                     True,
                                     1)  #Last argument threads, 1 default
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_float * 1, self.fftsize)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, self.fftsize)
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(
            gr.sizeof_float * self.fftsize, self.N)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(
            self.fftsize)
        #Div blocks channel 1
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_float * 1)
        self.single_pole_iir_filter_xx_1 = filter.single_pole_iir_filter_ff(
            self.alpha, self.fftsize)
        self.fft_vxx_1 = fft.fft_vcc(self.fftsize, True,
                                     (window.blackmanharris(self.fftsize)),
                                     True, 1)
        self.blocks_vector_to_stream_1 = blocks.vector_to_stream(
            gr.sizeof_float * 1, self.fftsize)
        self.blocks_stream_to_vector_1 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, self.fftsize)
        self.blocks_keep_one_in_n_1 = blocks.keep_one_in_n(
            gr.sizeof_float * self.fftsize, self.N)
        self.blocks_complex_to_mag_squared_1 = blocks.complex_to_mag_squared(
            self.fftsize)

        #Block connections channel 0
        self.connect((self.uhd_usrp_source_0, 0),
                     self.blocks_stream_to_vector_0)
        self.connect(self.blocks_stream_to_vector_0, self.fft_vxx_0)
        self.connect(self.fft_vxx_0, self.blocks_complex_to_mag_squared_0)
        self.connect(self.blocks_complex_to_mag_squared_0,
                     self.single_pole_iir_filter_xx_0)
        self.connect(self.single_pole_iir_filter_xx_0,
                     self.blocks_keep_one_in_n_0)
        self.connect(self.blocks_keep_one_in_n_0,
                     self.blocks_vector_to_stream_0)
        self.connect(self.blocks_vector_to_stream_0, self.blks2_selector_0)

        #Block connections channel 1
        self.connect((self.uhd_usrp_source_0, 1),
                     self.blocks_stream_to_vector_1)
        self.connect(self.blocks_stream_to_vector_1, self.fft_vxx_1)
        self.connect(self.fft_vxx_1, self.blocks_complex_to_mag_squared_1)
        self.connect(self.blocks_complex_to_mag_squared_1,
                     self.single_pole_iir_filter_xx_1)
        self.connect(self.single_pole_iir_filter_xx_1,
                     self.blocks_keep_one_in_n_1)
        self.connect(self.blocks_keep_one_in_n_1,
                     self.blocks_vector_to_stream_1)
        self.connect(self.blocks_vector_to_stream_1, self.blks2_selector_1)

        #Selector connections channel 0
        self.connect((self.blks2_selector_0, 1), self.signal_file_sink_1)
        self.connect((self.blks2_selector_0, 2), self.signal_file_sink_2)

        #Selector connections channel 1
        self.connect((self.blks2_selector_1, 1), self.signal_file_sink_3)
        self.connect((self.blks2_selector_1, 2), self.signal_file_sink_4)

        #Null sink connection channel 0
        self.connect((self.blks2_selector_0, 0), self.blocks_null_sink)

        #Null sink connection channel 1
        self.connect((self.blks2_selector_1, 0), self.blocks_null_sink_1)

        #########PROBE SAMPLES channel 0##########
        self.probe_signal = blocks.probe_signal_f()
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        self.connect((self.uhd_usrp_source_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.probe_signal, 0))

        #########PROBE SAMPLES channel 1##########
        self.probe_signal_1 = blocks.probe_signal_f()
        self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1)

        self.connect((self.uhd_usrp_source_0, 1),
                     (self.blocks_complex_to_mag_1, 0))
        self.connect((self.blocks_complex_to_mag_1, 0),
                     (self.probe_signal_1, 0))

        #Probe update rate
        def _probe_var_probe():
            while True:
                val = self.probe_signal.level()
                try:
                    self.set_probe_var(val)
                except AttributeError:
                    pass
                time.sleep(10 / (self.samp_rate)
                           )  #Update probe variabel every 10/samp_rate seconds

        _probe_var_thread = threading.Thread(target=_probe_var_probe)
        _probe_var_thread.daemon = True
        _probe_var_thread.start()

        #Probe update rate
        def _probe_var_probe_1():
            while True:
                val = self.probe_signal_1.level()
                try:
                    self.set_probe_var_1(val)
                except AttributeError:
                    pass
                time.sleep(10 / (self.samp_rate)
                           )  #Update probe variabel every 10/samp_rate seconds

        _probe_var_thread_1 = threading.Thread(target=_probe_var_probe_1)
        _probe_var_thread_1.daemon = True
        _probe_var_thread_1.start()
示例#40
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 9142857.14286

        ##################################################
        # Blocks
        ##################################################
        self.blocks_moving_average = blocks.moving_average_cc(1, 1, 4000)
        self.blocks_delay = blocks.delay(gr.sizeof_gr_complex * 1, 0)
        self.t2_p1_detector_0 = t2_p1_detector()
        self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f(
            1024000,  #size
            1,  #samp_rate
            "",  #name
            2  #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(0, 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_AUTO,
                                                      qtgui.TRIG_SLOPE_POS,
                                                      0.0, 50000, 0,
                                                      "p1_start")
        self.qtgui_time_sink_x_0_0_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0_0_0.enable_grid(False)
        self.qtgui_time_sink_x_0_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0_0.enable_control_panel(True)

        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", "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_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.dvbt2rx_gi_est_decider_0 = dvbt2rx.gi_est_decider(3, 16)
        self.dvbt2rx_gi_est_control_cc_0 = dvbt2rx.gi_est_control_cc(
            self.blocks_delay, self.blocks_moving_average)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_tag_gate_0_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1,
                                                   False)
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1,
                                                 False)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_conjugate_0 = blocks.multiply_conjugate_cc(1)
        self.blocks_moving_average_1 = blocks.moving_average_ff(
            2**12, 1. / 2**24, 4000)
        (self.blocks_moving_average_1).set_min_output_buffer(500000)
        self.blocks_file_source_0_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            '/home/kmaier/workspace/gr-dvbt2rx/binary_testfiles/ard_multiplex_karlsruhe_rx_sr9142857.14286.iq',
            True)
        self.blocks_complex_to_mag_squared_1_0 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_mag_squared_1 = blocks.complex_to_mag_squared(1)
        (self.blocks_complex_to_mag_squared_1).set_min_output_buffer(500000)
        self.analog_sig_source_x_1 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, samp_rate / 1024 * 0, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_complex_to_mag_squared_1, 0),
                     (self.dvbt2rx_gi_est_decider_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_1, 0),
                     (self.qtgui_time_sink_x_0_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_1_0, 0),
                     (self.blocks_moving_average_1, 0))
        self.connect((self.blocks_delay, 0), (self.blocks_tag_gate_0, 0))
        self.connect((self.blocks_file_source_0_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_moving_average, 0),
                     (self.blocks_complex_to_mag_squared_1, 0))
        self.connect((self.blocks_moving_average_1, 0),
                     (self.dvbt2rx_gi_est_decider_0, 1))
        self.connect((self.blocks_moving_average_1, 0),
                     (self.qtgui_time_sink_x_0_0_0, 1))
        self.connect((self.blocks_multiply_conjugate_0, 0),
                     (self.blocks_moving_average, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_tag_gate_0, 0),
                     (self.blocks_multiply_conjugate_0, 1))
        self.connect((self.blocks_tag_gate_0_0, 0),
                     (self.blocks_complex_to_mag_squared_1_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.t2_p1_detector_0, 0))
        self.connect((self.dvbt2rx_gi_est_control_cc_0, 0),
                     (self.blocks_delay, 0))
        self.connect((self.dvbt2rx_gi_est_control_cc_0, 0),
                     (self.blocks_multiply_conjugate_0, 0))
        self.connect((self.dvbt2rx_gi_est_control_cc_0, 0),
                     (self.blocks_tag_gate_0_0, 0))
        self.connect((self.t2_p1_detector_0, 0),
                     (self.dvbt2rx_gi_est_control_cc_0, 0))
示例#41
0
    def __init__(self):
        gr.top_block.__init__(self, "Ham2Mon Receiver Flow Example")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Ham2Mon Receiver Flow Example")
        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", "flow_example")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1E6
        self.initial_decim = initial_decim = 5
        self.samp_ratio = samp_ratio = samp_rate / 1E6
        self.final_rate = final_rate = samp_rate / initial_decim**2 / int(
            samp_rate / 1E6)

        self.variable_low_pass_filter_taps_2 = variable_low_pass_filter_taps_2 = firdes.low_pass(
            1.0, final_rate, 3500, 500, firdes.WIN_HAMMING, 6.76)

        self.variable_low_pass_filter_taps_1 = variable_low_pass_filter_taps_1 = firdes.low_pass(
            1.0, samp_rate / 25, 12.5E3, 1E3, firdes.WIN_HAMMING, 6.76)

        self.variable_low_pass_filter_taps_0 = variable_low_pass_filter_taps_0 = firdes.low_pass(
            1.0, 1, 0.090, 0.010, firdes.WIN_HAMMING, 6.76)

        self.squelch_dB = squelch_dB = -70
        self.gain_db = gain_db = 30
        self.final_decim = final_decim = int(samp_rate / 1E6)
        self.file_name = file_name = "test.wav"
        self.fft_length = fft_length = 256 * int(
            pow(2, np.ceil(np.log(samp_ratio) / np.log(2))))
        self.demod_bb_freq = demod_bb_freq = 390E3
        self.center_freq = center_freq = 144E6

        ##################################################
        # Blocks
        ##################################################
        self._squelch_dB_range = Range(-100, 0, 5, -70, 200)
        self._squelch_dB_win = RangeWidget(self._squelch_dB_range,
                                           self.set_squelch_dB, "Squelch (dB)",
                                           "counter_slider", float)
        self.top_grid_layout.addWidget(self._squelch_dB_win, 5, 1, 1, 3)
        self._gain_db_range = Range(0, 70, 1, 30, 200)
        self._gain_db_win = RangeWidget(self._gain_db_range, self.set_gain_db,
                                        "HW Gain (dB)", "counter_slider",
                                        float)
        self.top_grid_layout.addWidget(self._gain_db_win, 4, 1, 1, 3)
        self._demod_bb_freq_range = Range(-samp_rate / 2, samp_rate / 2, 5E3,
                                          390E3, 200)
        self._demod_bb_freq_win = RangeWidget(self._demod_bb_freq_range,
                                              self.set_demod_bb_freq,
                                              "Demod BB Freq (Hz)",
                                              "counter_slider", float)
        self.top_grid_layout.addWidget(self._demod_bb_freq_win, 3, 1, 1, 3)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            fft_length,  #size
            samp_rate,  #samp_rate
            "Averaged Spectrum",  #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(-60, 40)

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

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 0, 1, 3,
                                       1)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            final_rate,  #bw
            "Decimated Channel",  #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(-200, -60)
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0.enable_grid(False)
        self.qtgui_freq_sink_x_0_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0_0.disable_legend()

        if complex == type(float()):
            self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True)

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

        self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 3, 0,
                                       3, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            fft_length,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            144E6,  #fc
            samp_rate,  #bw
            "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_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if complex == type(float()):
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 3,
                                       1)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff(
            16E3 / float(final_rate / 5), taps=None, flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "uhd")
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(center_freq, 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(gain_db, 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(samp_rate * 0.8, 0)

        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            initial_decim, (variable_low_pass_filter_taps_0), demod_bb_freq,
            samp_rate)
        self.fir_filter_xxx_0_1 = filter.fir_filter_fff(
            initial_decim, (variable_low_pass_filter_taps_0))
        self.fir_filter_xxx_0_1.declare_sample_delay(0)
        self.fir_filter_xxx_0_0 = filter.fir_filter_ccc(
            int(samp_rate / 1E6), (variable_low_pass_filter_taps_0))
        self.fir_filter_xxx_0_0.declare_sample_delay(0)
        self.fir_filter_xxx_0 = filter.fir_filter_ccc(
            initial_decim, (variable_low_pass_filter_taps_0))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.fft_vxx_0 = fft.fft_vcc(fft_length, True,
                                     (window.blackmanharris(fft_length)), True,
                                     1)
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink(
            file_name, 1, 16000, 8)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_float * 1, fft_length)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, fft_length)
        self.blocks_probe_signal_vx_0 = blocks.probe_signal_vf(fft_length)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, fft_length, 0)
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(
            gr.sizeof_gr_complex * fft_length,
            int(round(samp_rate / fft_length / 1000)))
        self.blocks_integrate_xx_0 = blocks.integrate_ff(100, fft_length)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(
            fft_length)
        self.audio_sink_0 = audio.sink(16000, "", True)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(0.050)
        self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_ff(
            -200, 0.1, 0, True)
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(
            squelch_dB, 0.1, 0, False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_pwr_squelch_xx_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0_0, 0),
                     (self.blocks_wavfile_sink_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.fir_filter_xxx_0_1, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_integrate_xx_0, 0))
        self.connect((self.blocks_integrate_xx_0, 0),
                     (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.blocks_probe_signal_vx_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0),
                     (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.fir_filter_xxx_0, 0), (self.fir_filter_xxx_0_0, 0))
        self.connect((self.fir_filter_xxx_0_0, 0),
                     (self.analog_pwr_squelch_xx_0, 0))
        self.connect((self.fir_filter_xxx_0_0, 0),
                     (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.fir_filter_xxx_0_1, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.fir_filter_xxx_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.analog_pwr_squelch_xx_0_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.audio_sink_0, 0))
示例#42
0
    def __init__(self):
        gr.top_block.__init__(self, "bladeRF_transceiver")

        ##################################################
        # Variables
        ##################################################
        self.symbole_rate = symbole_rate = 10e3
        self.samp_rate = samp_rate = 1e6
        self.rat_interop = rat_interop = 8
        self.rat_decim = rat_decim = 5
        self.firdes_transition_width = firdes_transition_width = 15000
        self.firdes_decim = firdes_decim = 4
        self.firdes_cuttoff = firdes_cuttoff = 21e3
        self.tx_valve_value = tx_valve_value = False
        self.tx_rf_gain = tx_rf_gain = 10
        self.tx_bb_gain = tx_bb_gain = -20
        self.samp_per_sym_source = samp_per_sym_source = (
            (samp_rate / 2 / firdes_decim) * rat_interop /
            rat_decim) / symbole_rate
        self.samp_per_sym = samp_per_sym = int(samp_rate / symbole_rate)
        self.rx_valve_value = rx_valve_value = False
        self.rx_rf_gain = rx_rf_gain = 3
        self.rx_bb_gain = rx_bb_gain = 20
        self.preamble = preamble = '0101010101010101'
        self.msg_source_msgq_in = msg_source_msgq_in = gr.msg_queue(2)
        self.msg_sink_msgq_out = msg_sink_msgq_out = gr.msg_queue(2)
        self.frequency_tx = frequency_tx = 450e6
        self.frequency_shift = frequency_shift = 520000
        self.frequency_rx = frequency_rx = 450.0e6
        self.firdes_filter = firdes_filter = firdes.low_pass(
            1, samp_rate / 2, firdes_cuttoff, firdes_transition_width)
        self.bit_per_sym = bit_per_sym = 1
        self.bandwith = bandwith = 6e6
        self.access_code = access_code = '11010011100100011101001110010001'

        ##################################################
        # Blocks
        ##################################################
        self.xlating_fir_filter_1 = filter.freq_xlating_fir_filter_ccc(
            2, (1, ), frequency_shift, samp_rate)
        self.xlating_fir_filter_0 = filter.freq_xlating_fir_filter_ccc(
            firdes_decim, (firdes_filter), 0, samp_rate / 2)
        self.tx_valve = grc_blks2.valve(item_size=gr.sizeof_gr_complex * 1,
                                        open=bool(tx_valve_value))
        self.throttle = blocks.throttle(gr.sizeof_gr_complex * 1,
                                        samp_rate / 2, True)
        self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(
            0.05, 1)
        self.rx_valve = grc_blks2.valve(item_size=gr.sizeof_gr_complex * 1,
                                        open=bool(rx_valve_value))
        self.rational_resampler = filter.rational_resampler_ccc(
            interpolation=rat_interop,
            decimation=rat_decim,
            taps=None,
            fractional_bw=None,
        )
        self.quadrature_demod = analog.quadrature_demod_cf(2)
        self.probe_signal_2 = blocks.probe_signal_f()
        self.probe_signal_1 = blocks.probe_signal_f()
        self.osmosdr_source = osmosdr.source(args="numchan=" + str(1) + " " +
                                             "bladerf=0")
        self.osmosdr_source.set_sample_rate(samp_rate)
        self.osmosdr_source.set_center_freq(frequency_rx - frequency_shift, 0)
        self.osmosdr_source.set_freq_corr(0, 0)
        self.osmosdr_source.set_dc_offset_mode(0, 0)
        self.osmosdr_source.set_iq_balance_mode(2, 0)
        self.osmosdr_source.set_gain_mode(False, 0)
        self.osmosdr_source.set_gain(rx_rf_gain, 0)
        self.osmosdr_source.set_if_gain(0, 0)
        self.osmosdr_source.set_bb_gain(rx_bb_gain, 0)
        self.osmosdr_source.set_antenna("", 0)
        self.osmosdr_source.set_bandwidth(bandwith, 0)

        self.osmosdr_sink = osmosdr.sink(args="numchan=" + str(1) + " " +
                                         "bladerf=0")
        self.osmosdr_sink.set_sample_rate(samp_rate)
        self.osmosdr_sink.set_center_freq(frequency_tx, 0)
        self.osmosdr_sink.set_freq_corr(0, 0)
        self.osmosdr_sink.set_gain(tx_rf_gain, 0)
        self.osmosdr_sink.set_if_gain(0, 0)
        self.osmosdr_sink.set_bb_gain(tx_bb_gain, 0)
        self.osmosdr_sink.set_antenna("", 0)
        self.osmosdr_sink.set_bandwidth(bandwith, 0)

        self.nlog10_ff = blocks.nlog10_ff(10, 1, 0)
        self.gmsk_mod = digital.gmsk_mod(
            samples_per_symbol=int(samp_per_sym),
            bt=0.5,
            verbose=False,
            log=False,
        )
        self.correlate_access_code = digital.correlate_access_code_bb(
            access_code, 4)
        self.clock_recovery = digital.clock_recovery_mm_ff(
            samp_per_sym_source * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.5, 0.175,
            0.005)
        self.cc1111_packet_encoder = cc1111.cc1111_packet_mod_base(
            cc1111.cc1111_packet_encoder(samples_per_symbol=samp_per_sym,
                                         bits_per_symbol=bit_per_sym,
                                         preamble=preamble,
                                         access_code=access_code,
                                         pad_for_usrp=True,
                                         do_whitening=True,
                                         add_crc=True),
            source_queue=msg_source_msgq_in)
        self.cc1111_packet_decoder = cc1111.cc1111_packet_decoder(
            msg_sink_msgq_out, True, True, False, True)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1)
        self.blocks_keep_one_in_n = blocks.keep_one_in_n(
            gr.sizeof_float * 1, int(samp_rate / 30))
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1000)
        self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.binary_slicer = digital.binary_slicer_fb()
        self.avg_mag_sqrd = analog.probe_avg_mag_sqrd_c(0, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.binary_slicer, 0), (self.correlate_access_code, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.probe_signal_2, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_0, 0),
                     (self.single_pole_iir_filter_xx_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.osmosdr_sink, 0))
        self.connect((self.blocks_keep_one_in_n, 0), (self.nlog10_ff, 0))
        self.connect((self.cc1111_packet_decoder, 0),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.cc1111_packet_encoder, 0), (self.gmsk_mod, 0))
        self.connect((self.clock_recovery, 0), (self.binary_slicer, 0))
        self.connect((self.correlate_access_code, 0),
                     (self.cc1111_packet_decoder, 0))
        self.connect((self.gmsk_mod, 0), (self.tx_valve, 0))
        self.connect((self.nlog10_ff, 0), (self.probe_signal_1, 0))
        self.connect((self.osmosdr_source, 0), (self.rx_valve, 0))
        self.connect((self.quadrature_demod, 0), (self.clock_recovery, 0))
        self.connect((self.rational_resampler, 0), (self.quadrature_demod, 0))
        self.connect((self.rx_valve, 0), (self.avg_mag_sqrd, 0))
        self.connect((self.rx_valve, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.rx_valve, 0),
                     (self.blocks_complex_to_mag_squared_0_0, 0))
        self.connect((self.rx_valve, 0), (self.xlating_fir_filter_1, 0))
        self.connect((self.single_pole_iir_filter_xx_0, 0),
                     (self.blocks_keep_one_in_n, 0))
        self.connect((self.throttle, 0), (self.xlating_fir_filter_0, 0))
        self.connect((self.tx_valve, 0), (self.blocks_delay_0, 0))
        self.connect((self.xlating_fir_filter_0, 0),
                     (self.rational_resampler, 0))
        self.connect((self.xlating_fir_filter_1, 0), (self.throttle, 0))
    def __init__(self):
        gr.top_block.__init__(self, "DAB channel  decoder")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("DAB channel  decoder")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

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

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2048000
        self.freq_offset = freq_offset = 0

        ##################################################
        # Blocks
        ##################################################
        self.rtlsdr_source_0_0 = osmosdr.source(
            args="numchan=" + str(1) + " " + ''
        )
        self.rtlsdr_source_0_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.rtlsdr_source_0_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0_0.set_center_freq(218640000, 0)
        self.rtlsdr_source_0_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0_0.set_gain(30, 0)
        self.rtlsdr_source_0_0.set_if_gain(20, 0)
        self.rtlsdr_source_0_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0_0.set_antenna('', 0)
        self.rtlsdr_source_0_0.set_bandwidth(0, 0)
        self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f(
            2048*96*2, #size
            samp_rate, #samp_rate
            "", #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  * 3.1415 / 2048, 1 * 3.1415 / 2048)

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

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


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


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

        self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
            2048*5, #size
            samp_rate, #samp_rate
            "", #name
            1 #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-1, 1)

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

        self.qtgui_time_sink_x_1.enable_tags(True)
        self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_1.enable_autoscale(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)
        self.qtgui_time_sink_x_1.enable_stem_plot(False)


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


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

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



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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.qtgui_const_sink_x_1 = qtgui.const_sink_c(
            1024, #size
            "", #name
            1 #number of inputs
        )
        self.qtgui_const_sink_x_1.set_update_time(0.10)
        self.qtgui_const_sink_x_1.set_y_axis(-200, 200)
        self.qtgui_const_sink_x_1.set_x_axis(-200, 200)
        self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_1.enable_autoscale(False)
        self.qtgui_const_sink_x_1.enable_grid(False)
        self.qtgui_const_sink_x_1.enable_axis_labels(True)


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

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

        self._qtgui_const_sink_x_1_win = sip.wrapinstance(self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_1_win)
        self._freq_offset_range = Range(-1000, +1000, 10, 0, 200)
        self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'freq_offset', "counter_slider", float)
        self.top_grid_layout.addWidget(self._freq_offset_win)
        self.fft_vxx_0 = fft.fft_vcc(2048, True, [], True, 1)
        self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 2048)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 1536)
        self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_char*1, 'msc.dat', False)
        self.blocks_file_sink_0_0_0.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, 'fic.dat', False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.bad_qpsk_symbol_demapper_0 = bad.qpsk_symbol_demapper()
        self.bad_ofdm_symbols_selector_0_0 = bad.ofdm_symbols_selector()
        self.bad_ofdm_symbols_selector_0_0.select_msc_symbols()
        self.bad_ofdm_symbols_selector_0 = bad.ofdm_symbols_selector()
        self.bad_ofdm_symbols_selector_0.select_fic_symbols()
        self.bad_ofdm_sampler_0 = bad.ofdm_sampler()
        self.bad_ofdm_fine_frequency_correction_0 = bad.ofdm_fine_frequency_correction(0.1)
        self.bad_ofdm_differential_demodulator_0 = bad.ofdm_differential_demodulator()
        self.bad_ofdm_coarse_frequency_correction_0 = bad.ofdm_coarse_frequency_correction()
        self.bad_ns_detector_1 = bad.ns_detector()
        self.bad_msc_decoder_0 = bad.msc_decoder()
        self.bad_msc_decoder_0.set_eep_a_params(618, 72, 2)
        self.bad_frequency_deinterleaver_0 = bad.frequency_deinterleaver()
        self.bad_fic_decoder_0 = bad.fic_decoder()



        ##################################################
        # Connections
        ##################################################
        self.connect((self.bad_fic_decoder_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.bad_frequency_deinterleaver_0, 0), (self.bad_qpsk_symbol_demapper_0, 0))
        self.connect((self.bad_msc_decoder_0, 0), (self.blocks_file_sink_0_0_0, 0))
        self.connect((self.bad_ns_detector_1, 0), (self.bad_ofdm_fine_frequency_correction_0, 0))
        self.connect((self.bad_ofdm_coarse_frequency_correction_0, 0), (self.bad_ofdm_differential_demodulator_0, 0))
        self.connect((self.bad_ofdm_differential_demodulator_0, 0), (self.bad_frequency_deinterleaver_0, 0))
        self.connect((self.bad_ofdm_differential_demodulator_0, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.bad_ofdm_fine_frequency_correction_0, 0), (self.bad_ofdm_sampler_0, 0))
        self.connect((self.bad_ofdm_fine_frequency_correction_0, 1), (self.qtgui_time_sink_x_1_0, 0))
        self.connect((self.bad_ofdm_sampler_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.bad_ofdm_symbols_selector_0, 0), (self.bad_fic_decoder_0, 0))
        self.connect((self.bad_ofdm_symbols_selector_0_0, 0), (self.bad_msc_decoder_0, 0))
        self.connect((self.bad_qpsk_symbol_demapper_0, 0), (self.bad_ofdm_symbols_selector_0, 0))
        self.connect((self.bad_qpsk_symbol_demapper_0, 0), (self.bad_ofdm_symbols_selector_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.qtgui_time_sink_x_1, 0))
        self.connect((self.blocks_vector_to_stream_0, 0), (self.qtgui_const_sink_x_1, 0))
        self.connect((self.blocks_vector_to_stream_0_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.bad_ofdm_coarse_frequency_correction_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0_0, 0))
        self.connect((self.rtlsdr_source_0_0, 0), (self.bad_ns_detector_1, 0))
        self.connect((self.rtlsdr_source_0_0, 0), (self.qtgui_freq_sink_x_0, 0))
示例#44
0
    def __init__(self):
        gr.top_block.__init__(self, "codar_playback_sigmf")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("codar_playback_sigmf")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.trig_lvl = trig_lvl = 0
        self.throttle_rate = throttle_rate = 1
        self.samp_rate = samp_rate = 500e3
        self.decim = decim = 5
        self.cutoff = cutoff = 5e3
        self.coarse_freq = coarse_freq = 0

        ##################################################
        # Blocks
        ##################################################
        self._trig_lvl_tool_bar = Qt.QToolBar(self)
        self._trig_lvl_tool_bar.addWidget(Qt.QLabel("trig_lvl" + ": "))
        self._trig_lvl_line_edit = Qt.QLineEdit(str(self.trig_lvl))
        self._trig_lvl_tool_bar.addWidget(self._trig_lvl_line_edit)
        self._trig_lvl_line_edit.returnPressed.connect(
            lambda: self.set_trig_lvl(
                eng_notation.str_to_num(
                    str(self._trig_lvl_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._trig_lvl_tool_bar, 7, 6, 1, 2)
        for r in range(7, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(6, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._throttle_rate_tool_bar = Qt.QToolBar(self)
        self._throttle_rate_tool_bar.addWidget(
            Qt.QLabel("throttle_rate" + ": "))
        self._throttle_rate_line_edit = Qt.QLineEdit(str(self.throttle_rate))
        self._throttle_rate_tool_bar.addWidget(self._throttle_rate_line_edit)
        self._throttle_rate_line_edit.returnPressed.connect(
            lambda: self.set_throttle_rate(
                eng_notation.str_to_num(
                    str(self._throttle_rate_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._throttle_rate_tool_bar, 4, 6, 1,
                                       2)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(6, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._samp_rate_tool_bar = Qt.QToolBar(self)
        self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate" + ": "))
        self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate))
        self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit)
        self._samp_rate_line_edit.returnPressed.connect(
            lambda: self.set_samp_rate(
                eng_notation.str_to_num(
                    str(self._samp_rate_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._samp_rate_tool_bar, 4, 4, 1, 2)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._cutoff_tool_bar = Qt.QToolBar(self)
        self._cutoff_tool_bar.addWidget(Qt.QLabel("cutoff" + ": "))
        self._cutoff_line_edit = Qt.QLineEdit(str(self.cutoff))
        self._cutoff_tool_bar.addWidget(self._cutoff_line_edit)
        self._cutoff_line_edit.returnPressed.connect(lambda: self.set_cutoff(
            eng_notation.str_to_num(
                str(self._cutoff_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._cutoff_tool_bar, 6, 4, 1, 2)
        for r in range(6, 7):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._coarse_freq_range = Range(-125e3, 125e3, 1, 0, 200)
        self._coarse_freq_win = RangeWidget(self._coarse_freq_range,
                                            self.set_coarse_freq,
                                            "coarse_freq", "counter_slider",
                                            float)
        self.top_grid_layout.addWidget(self._coarse_freq_win, 5, 4, 1, 4)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.sigmf_source_0 = gr_sigmf.source(
            '/captures/20210404/CODAR_2021-05-05T04:51:43Z.sigmf-data',
            "cf32" + ("_le" if sys.byteorder == "little" else "_be"), True)
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=decim,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=decim,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.010)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
            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 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_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(-140, 10)

        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, 4,
                                       0, 4, 4)
        for r in range(4, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate / decim / decim,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.010)
        self.qtgui_time_sink_x_0.set_y_axis(-30, 20)

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

        if not 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.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 2, 4, 2,
                                       4)
        for r in range(2, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim,  #bw
            "",  #name
            2  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(0.010)
        self.qtgui_freq_sink_x_0_0.set_y_axis(-80, 10)
        self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0.enable_grid(False)
        self.qtgui_freq_sink_x_0_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 4,
                                       2, 4)
        for r in range(0, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            2048,  #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.010)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 4,
                                       4)
        for r in range(0, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate / decim, cutoff, 1e3,
                            firdes.WIN_HAMMING, 6.76))
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate * throttle_rate,
                                                 True)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -1 * coarse_freq, 1, 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)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_throttle_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.qtgui_freq_sink_x_0_0, 1))
        self.connect((self.low_pass_filter_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_agc2_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.sigmf_source_0, 0), (self.blocks_throttle_0, 0))
示例#45
0
    def __init__(self, port=65400, address="addr=192.168.10.2", seed1=1088):
        gr.top_block.__init__(self, "Ue")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Ue")
        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", "UE")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.port = port
        self.address = address
        self.seed1 = seed1

        ##################################################
        # Variables
        ##################################################
        self.seed2 = seed2 = seed1 + 384
        self.pilot_symbols = pilot_symbols = ((
            1,
            1,
            1,
            -1,
        ), )
        self.pilot_carriers = pilot_carriers = ((
            -21,
            -7,
            7,
            21,
        ), )
        self.payload_mod = payload_mod = digital.constellation_qpsk()
        self.occupied_carriers = occupied_carriers = (
            range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) +
            range(8, 21) + range(22, 27), )
        self.header_mod = header_mod = digital.constellation_bpsk()
        self.fft_len = fft_len = 64
        self.sync_word2 = sync_word2 = [
            0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1,
            1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1,
            1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1,
            -1, 0, 0, 0, 0, 0
        ]
        self.sync_word1 = sync_word1 = [
            0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0.,
            -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            0., 0., 0., 0., 0.
        ]
        self.seed6 = seed6 = seed1 + 4590
        self.seed5 = seed5 = seed2 + 851
        self.seed4 = seed4 = seed1 + 9027
        self.seed3 = seed3 = seed1 + 2791
        self.samp_rate = samp_rate = 500000
        self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe(
            fft_len, payload_mod.base(), occupied_carriers, pilot_carriers,
            pilot_symbols, 0, 1)
        self.packet_length_tag_key = packet_length_tag_key = "packet_len"
        self.packet_len = packet_len = 12
        self.noise_power = noise_power = 0
        self.length_tag_key = length_tag_key = "frame_len"
        self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(
            fft_len, header_mod.base(), occupied_carriers, pilot_carriers,
            pilot_symbols, 0, 1)
        self.h_2 = h_2 = 0
        self.h_1 = h_1 = 0
        self.h_0 = h_0 = 1

        ##################################################
        # Blocks
        ##################################################
        self.s_2 = blocks.probe_signal_c()
        self.s_1 = blocks.probe_signal_c()
        self.s_0 = blocks.probe_signal_c()
        self.noise_variance = blocks.probe_signal_f()

        def _noise_power_probe():
            while True:
                val = self.noise_variance.level()
                try:
                    self.set_noise_power(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))

        _noise_power_thread = threading.Thread(target=_noise_power_probe)
        _noise_power_thread.daemon = True
        _noise_power_thread.start()

        def _h_2_probe():
            while True:
                val = self.s_2.level()
                try:
                    self.set_h_2(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))

        _h_2_thread = threading.Thread(target=_h_2_probe)
        _h_2_thread.daemon = True
        _h_2_thread.start()

        def _h_1_probe():
            while True:
                val = self.s_1.level()
                try:
                    self.set_h_1(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))

        _h_1_thread = threading.Thread(target=_h_1_probe)
        _h_1_thread.daemon = True
        _h_1_thread.start()

        def _h_0_probe():
            while True:
                val = self.s_0.level()
                try:
                    self.set_h_0(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))

        _h_0_thread = threading.Thread(target=_h_0_probe)
        _h_0_thread.daemon = True
        _h_0_thread.start()
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join((address, "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(450e6, 0)
        self.uhd_usrp_source_0.set_gain(0, 0)
        self.uhd_usrp_source_0.set_antenna("RX2", 0)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)

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

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

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

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

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win)
        self.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(True)
        self.qtgui_time_sink_x_0.enable_grid(False)

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

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.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(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)

        if complex == type(float()):
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.projectGT_variance_cc_0 = projectGT.variance_cc(5000)
        self.projectGT_IA_vectors_vcvc_0 = projectGT.IA_vectors_vcvc(
            fft_len, noise_power, 1, 2, (15, 25, 40, 45), length_tag_key)
        self.ofdm_rx_phase_1_0 = ofdm_rx_phase_1(
            pilot_symbols=pilot_symbols,
            header_mod=header_mod,
            payload_mod=payload_mod,
            sync_word2=sync_word2,
            sync_word1=sync_word1,
            fft_len=fft_len,
            packet_len=packet_len,
            occupied_carriers=occupied_carriers,
            pilot_carriers=pilot_carriers,
            samp_rate=samp_rate,
        )
        self.channels_channel_model_4_0 = channels.channel_model(
            noise_voltage=0.1,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=(1.0, ),
            noise_seed=seed6,
            block_tags=False)
        self.channels_channel_model_4 = channels.channel_model(
            noise_voltage=0.1,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=(1.0, ),
            noise_seed=seed4,
            block_tags=False)
        self.channels_channel_model_3_0 = channels.channel_model(
            noise_voltage=0.05,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=(1.0, ),
            noise_seed=seed5,
            block_tags=False)
        self.channels_channel_model_3 = channels.channel_model(
            noise_voltage=0.1,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=(1.0, ),
            noise_seed=seed3,
            block_tags=False)
        self.channels_channel_model_2 = channels.channel_model(
            noise_voltage=0.11,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=(1.0, ),
            noise_seed=seed2,
            block_tags=False)
        self.channels_channel_model_1 = channels.channel_model(
            noise_voltage=0.12,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=(1.0, ),
            noise_seed=seed1,
            block_tags=False)
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=0.000,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=((h_0, h_1, h_2)),
            noise_seed=0,
            block_tags=False)
        self.blocks_vector_to_stream_1 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, fft_len)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, fft_len)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex * 1,
                                                 "134.214.146.135", port, 1472,
                                                 True)
        self.blocks_tag_debug_3 = blocks.tag_debug(gr.sizeof_gr_complex * 1,
                                                   "IA", "")
        self.blocks_tag_debug_3.set_display(True)
        self.blocks_tag_debug_1 = blocks.tag_debug(
            gr.sizeof_gr_complex * fft_len, "chnl_intrf", "")
        self.blocks_tag_debug_1.set_display(False)
        self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char * 1,
                                                   "Payload_intrf", "")
        self.blocks_tag_debug_0.set_display(False)
        self.blocks_null_source_3_0 = blocks.null_source(gr.sizeof_gr_complex *
                                                         1)
        self.blocks_null_source_3 = blocks.null_source(gr.sizeof_gr_complex *
                                                       1)
        self.blocks_null_source_2_0 = blocks.null_source(gr.sizeof_gr_complex *
                                                         1)
        self.blocks_null_source_2 = blocks.null_source(gr.sizeof_gr_complex *
                                                       1)
        self.blocks_null_source_1 = blocks.null_source(gr.sizeof_gr_complex *
                                                       1)
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_gr_complex *
                                                       1)
        self.blocks_float_to_complex_1_0 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_1 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_mag_3_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_3 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_2_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_2 = blocks.complex_to_mag(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_add_const_vxx_1_0 = blocks.add_const_vcc((0.0, ))
        self.blocks_add_const_vxx_1 = blocks.add_const_vcc((0.1, ))
        self.blocks_add_const_vxx_0 = blocks.add_const_vcc((0.8, ))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_add_const_vxx_0, 0), (self.s_0, 0))
        self.connect((self.blocks_add_const_vxx_1, 0), (self.s_1, 0))
        self.connect((self.blocks_add_const_vxx_1_0, 0), (self.s_2, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_complex_to_mag_1, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_complex_to_mag_2, 0),
                     (self.blocks_float_to_complex_1, 0))
        self.connect((self.blocks_complex_to_mag_2_0, 0),
                     (self.blocks_float_to_complex_1_0, 0))
        self.connect((self.blocks_complex_to_mag_3, 0),
                     (self.blocks_float_to_complex_1, 1))
        self.connect((self.blocks_complex_to_mag_3_0, 0),
                     (self.blocks_float_to_complex_1_0, 1))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_float_to_complex_1, 0),
                     (self.blocks_add_const_vxx_1, 0))
        self.connect((self.blocks_float_to_complex_1_0, 0),
                     (self.blocks_add_const_vxx_1_0, 0))
        self.connect((self.blocks_null_source_0, 0),
                     (self.channels_channel_model_1, 0))
        self.connect((self.blocks_null_source_1, 0),
                     (self.channels_channel_model_2, 0))
        self.connect((self.blocks_null_source_2, 0),
                     (self.channels_channel_model_3, 0))
        self.connect((self.blocks_null_source_2_0, 0),
                     (self.channels_channel_model_3_0, 0))
        self.connect((self.blocks_null_source_3, 0),
                     (self.channels_channel_model_4, 0))
        self.connect((self.blocks_null_source_3_0, 0),
                     (self.channels_channel_model_4_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_vector_to_stream_1, 0),
                     (self.blocks_complex_to_mag_squared_0_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.ofdm_rx_phase_1_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.projectGT_variance_cc_0, 0))
        self.connect((self.channels_channel_model_1, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.channels_channel_model_2, 0),
                     (self.blocks_complex_to_mag_1, 0))
        self.connect((self.channels_channel_model_3, 0),
                     (self.blocks_complex_to_mag_2, 0))
        self.connect((self.channels_channel_model_3_0, 0),
                     (self.blocks_complex_to_mag_2_0, 0))
        self.connect((self.channels_channel_model_4, 0),
                     (self.blocks_complex_to_mag_3, 0))
        self.connect((self.channels_channel_model_4_0, 0),
                     (self.blocks_complex_to_mag_3_0, 0))
        self.connect((self.ofdm_rx_phase_1_0, 2), (self.blocks_tag_debug_0, 0))
        self.connect((self.ofdm_rx_phase_1_0, 0), (self.blocks_tag_debug_1, 0))
        self.connect((self.ofdm_rx_phase_1_0, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.connect((self.ofdm_rx_phase_1_0, 1),
                     (self.blocks_vector_to_stream_1, 0))
        self.connect((self.projectGT_IA_vectors_vcvc_0, 0),
                     (self.blocks_tag_debug_3, 0))
        self.connect((self.projectGT_IA_vectors_vcvc_0, 0),
                     (self.blocks_udp_sink_0, 0))
        self.connect((self.projectGT_variance_cc_0, 0),
                     (self.noise_variance, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.ofdm_rx_phase_1_0, 1),
                     (self.projectGT_IA_vectors_vcvc_0, 0))
        self.connect((self.ofdm_rx_phase_1_0, 0),
                     (self.projectGT_IA_vectors_vcvc_0, 1))
示例#46
0
    def __init__(self):
        gr.top_block.__init__(self, "Adsb Uhd")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Adsb Uhd")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.thresh_mult = thresh_mult = 2
        self.samp_rate = samp_rate = 2e6
        self.low_thresh = low_thresh = 0
        self.rx_gain = rx_gain = 40
        self.low_thresh_lbl = low_thresh_lbl = low_thresh
        self.high = high = .4
        self.hi_thresh_lbl = hi_thresh_lbl = low_thresh * thresh_mult
        self.freq = freq = 1090e6
        self.filter_taps = filter_taps = firdes.low_pass(
            1, samp_rate, samp_rate / 2, 50000, firdes.WIN_FLATTOP, 6.76)
        self.decim = decim = 1
        self.center = center = 0
        self.bb_gain = bb_gain = .1e6

        ##################################################
        # Message Queues
        ##################################################
        adsb_decoder_0_msgq_out = baz_message_server_0_msgq_in = gr.msg_queue(
            2)
        adsb_decoder_0_msgq_out = blocks_message_source_0_msgq_in = gr.msg_queue(
            2)
        adsb_framer_0_msgq_out = adsb_decoder_0_msgq_in = gr.msg_queue(2)

        ##################################################
        # Blocks
        ##################################################
        self.probe_power = blocks.probe_signal_f()
        self._thresh_mult_tool_bar = Qt.QToolBar(self)
        self._thresh_mult_tool_bar.addWidget(Qt.QLabel("thresh_mult" + ": "))
        self._thresh_mult_line_edit = Qt.QLineEdit(str(self.thresh_mult))
        self._thresh_mult_tool_bar.addWidget(self._thresh_mult_line_edit)
        self._thresh_mult_line_edit.returnPressed.connect(
            lambda: self.set_thresh_mult(
                eng_notation.str_to_num(
                    str(self._thresh_mult_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._thresh_mult_tool_bar)
        self._rx_gain_tool_bar = Qt.QToolBar(self)
        self._rx_gain_tool_bar.addWidget(Qt.QLabel("rx_gain" + ": "))
        self._rx_gain_line_edit = Qt.QLineEdit(str(self.rx_gain))
        self._rx_gain_tool_bar.addWidget(self._rx_gain_line_edit)
        self._rx_gain_line_edit.returnPressed.connect(lambda: self.set_rx_gain(
            eng_notation.str_to_num(
                str(self._rx_gain_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._rx_gain_tool_bar)

        def _low_thresh_probe():
            while True:
                val = self.probe_power.level()
                try:
                    self.set_low_thresh(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))

        _low_thresh_thread = threading.Thread(target=_low_thresh_probe)
        _low_thresh_thread.daemon = True
        _low_thresh_thread.start()

        self._center_tool_bar = Qt.QToolBar(self)
        self._center_tool_bar.addWidget(Qt.QLabel("center" + ": "))
        self._center_line_edit = Qt.QLineEdit(str(self.center))
        self._center_tool_bar.addWidget(self._center_line_edit)
        self._center_line_edit.returnPressed.connect(lambda: self.set_center(
            eng_notation.str_to_num(
                str(self._center_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._center_tool_bar)
        self._bb_gain_tool_bar = Qt.QToolBar(self)
        self._bb_gain_tool_bar.addWidget(Qt.QLabel("bb_gain" + ": "))
        self._bb_gain_line_edit = Qt.QLineEdit(str(self.bb_gain))
        self._bb_gain_tool_bar.addWidget(self._bb_gain_line_edit)
        self._bb_gain_line_edit.returnPressed.connect(lambda: self.set_bb_gain(
            eng_notation.str_to_num(
                str(self._bb_gain_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._bb_gain_tool_bar)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(
            uhd.tune_request(freq, samp_rate / 2), 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            4096,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim,  #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 True:
            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 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_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(-130, -70)

        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_time_sink_x_0 = qtgui.time_sink_f(
            4096,  #size
            samp_rate,  #samp_rate
            "",  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.010)
        self.qtgui_time_sink_x_0.set_y_axis(0, 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_NORM,
                                                  qtgui.TRIG_SLOPE_POS, .3,
                                                  .0001, 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 = ['pre', 'post', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_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 / decim,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.01)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, -80)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

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

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(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._low_thresh_lbl_tool_bar = Qt.QToolBar(self)

        if None:
            self._low_thresh_lbl_formatter = None
        else:
            self._low_thresh_lbl_formatter = lambda x: x

        self._low_thresh_lbl_tool_bar.addWidget(
            Qt.QLabel("low_thresh_lbl" + ": "))
        self._low_thresh_lbl_label = Qt.QLabel(
            str(self._low_thresh_lbl_formatter(self.low_thresh_lbl)))
        self._low_thresh_lbl_tool_bar.addWidget(self._low_thresh_lbl_label)
        self.top_layout.addWidget(self._low_thresh_lbl_tool_bar)

        self._high_tool_bar = Qt.QToolBar(self)
        self._high_tool_bar.addWidget(Qt.QLabel("high" + ": "))
        self._high_line_edit = Qt.QLineEdit(str(self.high))
        self._high_tool_bar.addWidget(self._high_line_edit)
        self._high_line_edit.returnPressed.connect(lambda: self.set_high(
            eng_notation.str_to_num(str(self._high_line_edit.text().toAscii()))
        ))
        self.top_layout.addWidget(self._high_tool_bar)
        self._hi_thresh_lbl_tool_bar = Qt.QToolBar(self)

        if None:
            self._hi_thresh_lbl_formatter = None
        else:
            self._hi_thresh_lbl_formatter = lambda x: x

        self._hi_thresh_lbl_tool_bar.addWidget(
            Qt.QLabel("hi_thresh_lbl" + ": "))
        self._hi_thresh_lbl_label = Qt.QLabel(
            str(self._hi_thresh_lbl_formatter(self.hi_thresh_lbl)))
        self._hi_thresh_lbl_tool_bar.addWidget(self._hi_thresh_lbl_label)
        self.top_layout.addWidget(self._hi_thresh_lbl_tool_bar)

        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (filter_taps), center, samp_rate)
        self.digital_correlate_access_code_tag_bb_0 = digital.correlate_access_code_tag_bb(
            '1010000101000000', 0, 'adsb_preamble')
        self.blocks_threshold_ff_0 = blocks.threshold_ff(
            low_thresh, low_thresh * thresh_mult, 0)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (bb_gain, ))
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            1000, .0001, 4000)
        self.blocks_message_source_0 = blocks.message_source(
            gr.sizeof_char * 1, blocks_message_source_0_msgq_in)
        self.blocks_float_to_uchar_0 = blocks.float_to_uchar()
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   '/dev/stdout', True)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.baz_message_server_0 = message_server.message_server(
            msgq=baz_message_server_0_msgq_in, port=12345)
        self.adsb_framer_0 = adsb.framer(tx_msgq=adsb_framer_0_msgq_out)
        self.adsb_decoder_0 = adsb.decoder(rx_msgq=adsb_decoder_0_msgq_in,
                                           tx_msgq=adsb_decoder_0_msgq_out,
                                           output_type="csv",
                                           check_parity=True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_float_to_uchar_0, 0),
                     (self.digital_correlate_access_code_tag_bb_0, 0))
        self.connect((self.blocks_message_source_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.probe_power, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_float_to_uchar_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.digital_correlate_access_code_tag_bb_0, 0),
                     (self.adsb_framer_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
示例#47
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.freq_0 = freq_0 = 525.2e6
        self.threshold = threshold = -60
        self.samp_rate = samp_rate = 2.048e6
        self.freq = freq = freq_0

        ##################################################
        # Blocks
        ##################################################
        _threshold_sizer = wx.BoxSizer(wx.VERTICAL)
        self._threshold_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_threshold_sizer,
            value=self.threshold,
            callback=self.set_threshold,
            label="threshold",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._threshold_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_threshold_sizer,
            value=self.threshold,
            callback=self.set_threshold,
            minimum=-100,
            maximum=0,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_threshold_sizer)
        self.wxgui_numbersink2_0_0 = numbersink2.number_sink_f(
            self.GetWin(),
            unit="signal present",
            minval=0,
            maxval=1,
            factor=1.0,
            decimal_places=10,
            ref_level=0,
            sample_rate=2.048e6,
            number_rate=15,
            average=False,
            avg_alpha=None,
            label="Signal detection",
            peak_hold=False,
            show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0_0.win)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
            self.GetWin(),
            unit="Units",
            minval=-120,
            maxval=0,
            factor=1.0,
            decimal_places=10,
            ref_level=0,
            sample_rate=2048000,
            number_rate=15,
            average=True,
            avg_alpha=0.03,
            label="Level",
            peak_hold=False,
            show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=2048000,
            fft_size=1024,
            fft_rate=15,
            average=True,
            avg_alpha=0.030,
            title="FFT Plot",
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              "")
        self.rtlsdr_source_0.set_sample_rate(2.048e6)
        self.rtlsdr_source_0.set_center_freq(freq, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(2, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(15, 0)
        self.rtlsdr_source_0.set_if_gain(15, 0)
        self.rtlsdr_source_0.set_bb_gain(5, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)

        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(),
                                                        style=wx.NB_TOP)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab1")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab2")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab3")
        self.Add(self.notebook_0)
        _freq_0_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_0_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_freq_0_sizer,
            value=self.freq_0,
            callback=self.set_freq_0,
            label='freq_0',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._freq_0_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_freq_0_sizer,
            value=self.freq_0,
            callback=self.set_freq_0,
            minimum=478e6,
            maximum=862e6,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_freq_0_sizer)
        self.fft_vxx_0 = fft.fft_vcc(1024, True, (window.rectangular(1024)),
                                     True, 1)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_float * 1, 1024)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 2048000, True)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(-100, threshold, -60)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 1024)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_int * 1,
            "/media/ubuntu/01D165566F075780/Q3/wireless networking/GNU/out1.txt",
            False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(
            1024)
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 1.04858e6)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.wxgui_numbersink2_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.wxgui_numbersink2_0_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_divide_xx_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
示例#48
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.zoom = zoom = 32768
        self.samp_rate = samp_rate = 2048000
        self.centre_freq2 = centre_freq2 = 433895e3
        self.centre_freq1 = centre_freq1 = 434140e3
        self.baud_rate = baud_rate = 4800

        ##################################################
        # Blocks
        ##################################################
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              '')
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(centre_freq2, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(10, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna('', 0)
        self.rtlsdr_source_0.set_bandwidth(baud_rate, 0)

        self.qtgui_time_sink_x_1 = qtgui.time_sink_c(
            zoom,  #size
            baud_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.1)
        self.qtgui_time_sink_x_1.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_1.disable_legend()

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

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

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            zoom,  #size
            samp_rate,  #samp_rate
            'MAG',  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.1)
        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, False)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        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_grid_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_sink_x_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #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_grid_layout.addWidget(self._qtgui_sink_x_0_win)

        self.qtgui_sink_x_0.enable_rf_freq(False)

        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.qtgui_sink_x_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.qtgui_time_sink_x_1, 0))
示例#49
0
    def __init__(self, meta_rate=10, radio_id='USRP', sat_name='FOX-1D'):
        gr.top_block.__init__(self, "FOX1D Receiver, Pipe to FoxTelem")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("FOX1D Receiver, Pipe to FoxTelem")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Parameters
        ##################################################
        self.meta_rate = meta_rate
        self.radio_id = radio_id
        self.sat_name = sat_name

        ##################################################
        # Variables
        ##################################################
        self.ts_str = ts_str = dt.strftime(dt.utcnow(),
                                           "%Y%m%d_%H%M%S.%f") + '_UTC'
        self.samp_rate = samp_rate = 250e3
        self.fn_wav = fn_wav = "{:s}_{:s}_{:s}_{:s}k.wav".format(
            sat_name, radio_id, ts_str, str(int(48000) / 1000))
        self.fn = fn = "{:s}_{:s}_{:s}_{:s}k.fc32".format(
            sat_name, radio_id, ts_str, str(int(samp_rate) / 1000))
        self.decim = decim = 5
        self.baud = baud = 9600

        self.xlate_taps = xlate_taps = firdes.low_pass(1.0, samp_rate, 15e3,
                                                       1000,
                                                       firdes.WIN_HAMMING,
                                                       6.76)

        self.volume = volume = 0.01
        self.throttle_factor = throttle_factor = 1
        self.samps_per_symb = samps_per_symb = samp_rate / decim / baud
        self.rx_gain = rx_gain = 20
        self.rx_freq = rx_freq = 145.88e6
        self.rf_lpf_cutoff = rf_lpf_cutoff = 8e3
        self.fsk_deviation_hz = fsk_deviation_hz = 4000
        self.fp_wav = fp_wav = "/home/zleffke/captures/fox1d/{:s}".format(
            fn_wav)
        self.fp = fp = "/home/zleffke/captures/fox1d/{:s}".format(fn)
        self.fll_loop_bw_fine = fll_loop_bw_fine = 0.0001
        self.fll_loop_bw = fll_loop_bw = math.pi / 200
        self.audio_lpf_cutoff = audio_lpf_cutoff = 6e3

        ##################################################
        # Blocks
        ##################################################
        self._volume_tool_bar = Qt.QToolBar(self)
        self._volume_tool_bar.addWidget(Qt.QLabel("volume" + ": "))
        self._volume_line_edit = Qt.QLineEdit(str(self.volume))
        self._volume_tool_bar.addWidget(self._volume_line_edit)
        self._volume_line_edit.returnPressed.connect(lambda: self.set_volume(
            eng_notation.str_to_num(
                str(self._volume_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._volume_tool_bar, 7, 4, 1, 2)
        for r in range(7, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_gain_tool_bar = Qt.QToolBar(self)
        self._rx_gain_tool_bar.addWidget(Qt.QLabel('GAIN' + ": "))
        self._rx_gain_line_edit = Qt.QLineEdit(str(self.rx_gain))
        self._rx_gain_tool_bar.addWidget(self._rx_gain_line_edit)
        self._rx_gain_line_edit.returnPressed.connect(lambda: self.set_rx_gain(
            eng_notation.str_to_num(
                str(self._rx_gain_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._rx_gain_tool_bar, 8, 0, 1, 2)
        for r in range(8, 9):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_freq_tool_bar = Qt.QToolBar(self)
        self._rx_freq_tool_bar.addWidget(Qt.QLabel('FREQ' + ": "))
        self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq))
        self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit)
        self._rx_freq_line_edit.returnPressed.connect(lambda: self.set_rx_freq(
            eng_notation.str_to_num(
                str(self._rx_freq_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._rx_freq_tool_bar, 7, 6, 1, 2)
        for r in range(7, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(6, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rf_lpf_cutoff_tool_bar = Qt.QToolBar(self)
        self._rf_lpf_cutoff_tool_bar.addWidget(
            Qt.QLabel("rf_lpf_cutoff" + ": "))
        self._rf_lpf_cutoff_line_edit = Qt.QLineEdit(str(self.rf_lpf_cutoff))
        self._rf_lpf_cutoff_tool_bar.addWidget(self._rf_lpf_cutoff_line_edit)
        self._rf_lpf_cutoff_line_edit.returnPressed.connect(
            lambda: self.set_rf_lpf_cutoff(
                eng_notation.str_to_num(
                    str(self._rf_lpf_cutoff_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._rf_lpf_cutoff_tool_bar, 6, 0, 1,
                                       2)
        for r in range(6, 7):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._fll_loop_bw_fine_tool_bar = Qt.QToolBar(self)
        self._fll_loop_bw_fine_tool_bar.addWidget(
            Qt.QLabel("fll_loop_bw_fine" + ": "))
        self._fll_loop_bw_fine_line_edit = Qt.QLineEdit(
            str(self.fll_loop_bw_fine))
        self._fll_loop_bw_fine_tool_bar.addWidget(
            self._fll_loop_bw_fine_line_edit)
        self._fll_loop_bw_fine_line_edit.returnPressed.connect(
            lambda: self.set_fll_loop_bw_fine(
                eng_notation.str_to_num(
                    str(self._fll_loop_bw_fine_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._fll_loop_bw_fine_tool_bar, 7, 2,
                                       1, 2)
        for r in range(7, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._fll_loop_bw_tool_bar = Qt.QToolBar(self)
        self._fll_loop_bw_tool_bar.addWidget(Qt.QLabel("fll_loop_bw" + ": "))
        self._fll_loop_bw_line_edit = Qt.QLineEdit(str(self.fll_loop_bw))
        self._fll_loop_bw_tool_bar.addWidget(self._fll_loop_bw_line_edit)
        self._fll_loop_bw_line_edit.returnPressed.connect(
            lambda: self.set_fll_loop_bw(
                eng_notation.str_to_num(
                    str(self._fll_loop_bw_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._fll_loop_bw_tool_bar, 6, 2, 1, 2)
        for r in range(6, 7):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._audio_lpf_cutoff_tool_bar = Qt.QToolBar(self)
        self._audio_lpf_cutoff_tool_bar.addWidget(
            Qt.QLabel("audio_lpf_cutoff" + ": "))
        self._audio_lpf_cutoff_line_edit = Qt.QLineEdit(
            str(self.audio_lpf_cutoff))
        self._audio_lpf_cutoff_tool_bar.addWidget(
            self._audio_lpf_cutoff_line_edit)
        self._audio_lpf_cutoff_line_edit.returnPressed.connect(
            lambda: self.set_audio_lpf_cutoff(
                eng_notation.str_to_num(
                    str(self._audio_lpf_cutoff_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._audio_lpf_cutoff_tool_bar, 7, 0,
                                       1, 2)
        for r in range(7, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_clock_source('external', 0)
        self.uhd_usrp_source_0.set_time_source('external', 0)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_center_freq(
            uhd.tune_request(rx_freq, samp_rate / 2), 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self._throttle_factor_tool_bar = Qt.QToolBar(self)
        self._throttle_factor_tool_bar.addWidget(
            Qt.QLabel("throttle_factor" + ": "))
        self._throttle_factor_line_edit = Qt.QLineEdit(
            str(self.throttle_factor))
        self._throttle_factor_tool_bar.addWidget(
            self._throttle_factor_line_edit)
        self._throttle_factor_line_edit.returnPressed.connect(
            lambda: self.set_throttle_factor(
                eng_notation.str_to_num(
                    str(self._throttle_factor_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._throttle_factor_tool_bar, 6, 4, 1,
                                       2)
        for r in range(6, 7):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=4,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=4,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=48,
            decimation=50,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim,  #bw
            "corrected",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0_0.set_update_time(0.010)
        self.qtgui_waterfall_sink_x_0_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_waterfall_sink_x_0_0.disable_legend()

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

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

        self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-80, 0)

        self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_0_win, 2,
                                       4, 2, 4)
        for r in range(2, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim,  #bw
            "Pre-D",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.010)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
            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 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_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(-80, 0)

        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,
                                       4, 2, 4)
        for r in range(0, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate / decim / 50 * 48,  #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)
        self.qtgui_time_sink_x_0.enable_stem_plot(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_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 8, 2, 1,
                                       6)
        for r in range(8, 9):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_number_sink_0_0_0_0_0 = qtgui.number_sink(
            gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1)
        self.qtgui_number_sink_0_0_0_0_0.set_update_time(0.10)
        self.qtgui_number_sink_0_0_0_0_0.set_title("")

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

        self.qtgui_number_sink_0_0_0_0_0.enable_autoscale(False)
        self._qtgui_number_sink_0_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_0_win,
                                       6, 6, 1, 1)
        for r in range(6, 7):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(6, 7):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_number_sink_0_0_0_0 = qtgui.number_sink(
            gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1)
        self.qtgui_number_sink_0_0_0_0.set_update_time(0.010)
        self.qtgui_number_sink_0_0_0_0.set_title("")

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

        self.qtgui_number_sink_0_0_0_0.enable_autoscale(False)
        self._qtgui_number_sink_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_win, 6,
                                       7, 1, 1)
        for r in range(6, 7):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(7, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim,  #bw
            "Pre-D",  #name
            2  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.010)
        self.qtgui_freq_sink_x_0.set_y_axis(-60, 0)
        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 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 = ['pre-d', 'corr', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.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, 4,
                                       4)
        for r in range(0, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.low_pass_filter_0_0_0 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate / decim / 50 * 48, audio_lpf_cutoff,
                            2e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate / decim, rf_lpf_cutoff, 2e3,
                            firdes.WIN_HAMMING, 6.76))
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            decim, (xlate_taps), 0, samp_rate)
        self.digital_fll_band_edge_cc_0_0 = digital.fll_band_edge_cc(
            samps_per_symb, .5, 1024, fll_loop_bw_fine)
        self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(
            samps_per_symb, .5, 1024, fll_loop_bw)
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink(fp_wav, 1, 48000, 16)
        self.blocks_tagged_stream_to_pdu_0_0 = blocks.tagged_stream_to_pdu(
            blocks.float_t, 'snr')
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(
            blocks.float_t, 'rfo')
        self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_float, 1, 1, "snr")
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_float, 1, 1, "rfo")
        self.blocks_socket_pdu_0_0 = blocks.socket_pdu("TCP_SERVER", '0.0.0.0',
                                                       '52002', 10000, False)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", '0.0.0.0',
                                                     '52001', 10000, False)
        self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_nlog10_ff_0_1 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff(
            (-1 * samp_rate / decim / (2 * math.pi), ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (volume, ))
        self.blocks_moving_average_xx_0_0_1 = blocks.moving_average_ff(
            10000, 0.0001, 4000, 1)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            100000, 0.00001, 4000, 1)
        self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, int(samp_rate * meta_rate))
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, int(samp_rate / 4 * meta_rate))
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_gr_complex * 1,
                                                     fp, False)
        self.blocks_file_sink_0_0.set_unbuffered(False)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, samp_rate / 2, 1, 0)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            samp_rate / (2 * math.pi * fsk_deviation_hz / 8.0))
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 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.blocks_socket_pdu_0, 'pdus'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'),
                         (self.blocks_socket_pdu_0_0, 'pdus'))
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.low_pass_filter_0_0_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_divide_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_0, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.blocks_nlog10_ff_0_1, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0),
                     (self.blocks_stream_to_tagged_stream_0_0, 0))
        self.connect((self.blocks_keep_one_in_n_0_0, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_keep_one_in_n_0_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.qtgui_number_sink_0_0_0_0, 0))
        self.connect((self.blocks_moving_average_xx_0_0_1, 0),
                     (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.blocks_moving_average_xx_0_0_1, 0),
                     (self.qtgui_number_sink_0_0_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_wavfile_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.blocks_nlog10_ff_0_1, 0),
                     (self.blocks_moving_average_xx_0_0_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.digital_fll_band_edge_cc_0, 1),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.digital_fll_band_edge_cc_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.digital_fll_band_edge_cc_0, 2),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.digital_fll_band_edge_cc_0, 3),
                     (self.blocks_null_sink_0_0, 0))
        self.connect((self.digital_fll_band_edge_cc_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.digital_fll_band_edge_cc_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.digital_fll_band_edge_cc_0_0, 0),
                     (self.qtgui_freq_sink_x_0, 1))
        self.connect((self.digital_fll_band_edge_cc_0_0, 0),
                     (self.qtgui_waterfall_sink_x_0_0, 0))
        self.connect((self.digital_fll_band_edge_cc_0_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.digital_fll_band_edge_cc_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.digital_fll_band_edge_cc_0_0, 0))
        self.connect((self.low_pass_filter_0_0_0, 0),
                     (self.blocks_multiply_const_vxx_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, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.blocks_complex_to_mag_squared_0_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.blocks_file_sink_0_0, 0))
示例#50
0
    def __init__(self,
                 c_freq=1420000000,
                 nbin=1000,
                 nchan=1024,
                 obs_time=60,
                 samp_rate=2400000):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Parameters
        ##################################################
        self.c_freq = c_freq
        self.nbin = nbin
        self.nchan = nchan
        self.obs_time = obs_time
        self.samp_rate = samp_rate

        ##################################################
        # Variables
        ##################################################
        self.sinc_sample_locations = sinc_sample_locations = np.arange(
            -np.pi * 4 / 2.0, np.pi * 4 / 2.0, np.pi / nchan)
        self.sinc = sinc = np.sinc(sinc_sample_locations / np.pi)
        self.custom_window = custom_window = sinc * np.hamming(4 * nchan)

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               'rtl=0')
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(c_freq, 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(rtlgain, 0)
        self.osmosdr_source_0.set_if_gain(rtlgain, 0)
        self.osmosdr_source_0.set_bb_gain(rtlgain, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.fft_vxx_0 = fft.fft_vcc(nchan, True,
                                     (window.blackmanharris(nchan)), True, 1)
        self.blocks_stream_to_vector_0_2 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, nchan)
        self.blocks_stream_to_vector_0_1 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, nchan)
        self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, nchan)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, nchan)
        self.blocks_multiply_const_vxx_0_0_0_0 = blocks.multiply_const_vcc(
            (custom_window[0:nchan]))
        self.blocks_multiply_const_vxx_0_0_0 = blocks.multiply_const_vcc(
            (custom_window[nchan:2 * nchan]))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc(
            (custom_window[2 * nchan:3 * nchan]))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(
            (custom_window[-nchan:]))
        self.blocks_integrate_xx_0 = blocks.integrate_ff(nbin, nchan)
        self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex * 1,
                                         int(obs_time * samp_rate))
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float * nchan,
                                                   'observation.dat', True)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_delay_0_1 = blocks.delay(gr.sizeof_gr_complex * 1, nchan)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                             nchan * 2)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, nchan * 3)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(
            nchan)
        self.blocks_add_xx_0 = blocks.add_vcc(nchan)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_add_xx_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_integrate_xx_0, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_stream_to_vector_0_2, 0))
        self.connect((self.blocks_delay_0_0, 0),
                     (self.blocks_stream_to_vector_0_0, 0))
        self.connect((self.blocks_delay_0_1, 0),
                     (self.blocks_stream_to_vector_0_1, 0))
        self.connect((self.blocks_head_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_head_0, 0), (self.blocks_delay_0_0, 0))
        self.connect((self.blocks_head_0, 0), (self.blocks_delay_0_1, 0))
        self.connect((self.blocks_head_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_integrate_xx_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0_0_0, 0),
                     (self.blocks_add_xx_0, 2))
        self.connect((self.blocks_multiply_const_vxx_0_0_0_0, 0),
                     (self.blocks_add_xx_0, 3))
        self.connect((self.blocks_stream_to_vector_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_stream_to_vector_0_0, 0),
                     (self.blocks_multiply_const_vxx_0_0_0, 0))
        self.connect((self.blocks_stream_to_vector_0_1, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_stream_to_vector_0_2, 0),
                     (self.blocks_multiply_const_vxx_0_0_0_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.blocks_head_0, 0))
示例#51
0
    def __init__(self):
        gr.top_block.__init__(self, "udp-recive")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("udp-recive")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

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

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 850e3
        self.dec = dec = 25
        self.freq_0 = freq_0 = 137.50625e6
        self.bandwidth = bandwidth = 34e3
        self.RF_gain = RF_gain = 40
        self.Out_samprate = Out_samprate = samp_rate / dec
        self.NOAA19 = NOAA19 = -0.40625e6
        self.NOAA18 = NOAA18 = 0.40625e6
        self.NOAA15 = NOAA15 = 0.11375e6
        self.IF_gain = IF_gain = 40

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=11025,
            decimation=34000,
            taps=None,
            fractional_bw=None)
        self.qtgui_sink_x_0 = qtgui.sink_c(
            2048,  #fftsize
            firdes.WIN_HAMMING,  #wintype
            0,  #fc
            34e3,  #bw
            "output sink",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            False,  #plottime
            False  #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.qtgui_sink_x_0.enable_rf_freq(False)

        self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win)
        self.qtgui_sink_x_0.set_block_alias("output sink")
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_short, 0,
                                                     qtgui.NUM_GRAPH_NONE, 1)
        self.qtgui_number_sink_0.set_update_time(0.1)
        self.qtgui_number_sink_0.set_title("Selected channel")

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

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

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win)
        self.blocks_udp_source_0_2 = blocks.udp_source(
            gr.sizeof_gr_complex * 1, '0.0.0.0', 1232, 4000, True)
        self.blocks_udp_source_0_1 = blocks.udp_source(
            gr.sizeof_gr_complex * 1, '0.0.0.0', 1230, 4000, True)
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_gr_complex * 1,
                                                     '0.0.0.0', 1231, 4000,
                                                     True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_float * 1,
                                                 'localhost', 7355, 1225, True)
        self.blocks_threshold_ff_0_1 = blocks.threshold_ff(1.5, 2.5, 0)
        self.blocks_threshold_ff_0_0 = blocks.threshold_ff(0.5, 1.5, 0)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(-0.5, 0.5, 0)
        self.blocks_streams_to_vector_0 = blocks.streams_to_vector(
            gr.sizeof_float * 1, 3)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_short * 1)
        self.blocks_multiply_xx_2 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_moving_average_2_0 = blocks.moving_average_ff(
            4000, 1, 4000, 1)
        self.blocks_moving_average_2 = blocks.moving_average_ff(
            4000, 1, 4000, 1)
        self.blocks_moving_average_1 = blocks.moving_average_ff(
            4000, 1, 4000, 1)
        self.blocks_float_to_complex_1_1 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_1_0 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_1 = blocks.float_to_complex(1)
        self.blocks_complex_to_mag_squared_0_1 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_argmax_xx_0 = blocks.argmax_fs(3)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.blocks_add_const_vxx_0_0_0 = blocks.add_const_ff(-1)
        self.blocks_add_const_vxx_0_0 = blocks.add_const_ff(-1)
        self.blocks_add_const_vxx_0 = blocks.add_const_ff(-1)
        self.blocks_abs_xx_0_0_0 = blocks.abs_ff(1)
        self.blocks_abs_xx_0_0 = blocks.abs_ff(1)
        self.blocks_abs_xx_0 = blocks.abs_ff(1)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=bandwidth,
            audio_decimation=1,
        )
        self.NOAA19_fall = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            freq_0 + NOAA19,  #fc
            Out_samprate,  #bw
            "NOAA19 (stream 0)",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            False,  #plottime
            False  #plotconst
        )
        self.NOAA19_fall.set_update_time(1.0 / 1)
        self._NOAA19_fall_win = sip.wrapinstance(self.NOAA19_fall.pyqwidget(),
                                                 Qt.QWidget)

        self.NOAA19_fall.enable_rf_freq(True)

        self.top_grid_layout.addWidget(self._NOAA19_fall_win)
        self.NOAA18_fall = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            freq_0 + NOAA18,  #fc
            Out_samprate,  #bw
            "NOAA18 (stream 1)",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            False,  #plottime
            False  #plotconst
        )
        self.NOAA18_fall.set_update_time(1.0 / 1)
        self._NOAA18_fall_win = sip.wrapinstance(self.NOAA18_fall.pyqwidget(),
                                                 Qt.QWidget)

        self.NOAA18_fall.enable_rf_freq(True)

        self.top_grid_layout.addWidget(self._NOAA18_fall_win)
        self.NOAA15_fall = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            freq_0 + NOAA15,  #fc
            Out_samprate,  #bw
            "NOAA15 (stream 2)",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            False,  #plottime
            False  #plotconst
        )
        self.NOAA15_fall.set_update_time(1.0 / 1)
        self._NOAA15_fall_win = sip.wrapinstance(self.NOAA15_fall.pyqwidget(),
                                                 Qt.QWidget)

        self.NOAA15_fall.enable_rf_freq(True)

        self.top_grid_layout.addWidget(self._NOAA15_fall_win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_abs_xx_0, 0),
                     (self.blocks_float_to_complex_1, 0))
        self.connect((self.blocks_abs_xx_0_0, 0),
                     (self.blocks_float_to_complex_1_0, 0))
        self.connect((self.blocks_abs_xx_0_0_0, 0),
                     (self.blocks_float_to_complex_1_1, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_abs_xx_0, 0))
        self.connect((self.blocks_add_const_vxx_0_0, 0),
                     (self.blocks_abs_xx_0_0, 0))
        self.connect((self.blocks_add_const_vxx_0_0_0, 0),
                     (self.blocks_abs_xx_0_0_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.analog_wfm_rcv_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.qtgui_sink_x_0, 0))
        self.connect((self.blocks_argmax_xx_0, 1),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.blocks_argmax_xx_0, 0),
                     (self.blocks_short_to_float_0, 0))
        self.connect((self.blocks_argmax_xx_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_moving_average_1, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_0, 0),
                     (self.blocks_moving_average_2, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_1, 0),
                     (self.blocks_moving_average_2_0, 0))
        self.connect((self.blocks_float_to_complex_1, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_float_to_complex_1_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_float_to_complex_1_1, 0),
                     (self.blocks_multiply_xx_2, 1))
        self.connect((self.blocks_moving_average_1, 0),
                     (self.blocks_streams_to_vector_0, 0))
        self.connect((self.blocks_moving_average_2, 0),
                     (self.blocks_streams_to_vector_0, 1))
        self.connect((self.blocks_moving_average_2_0, 0),
                     (self.blocks_streams_to_vector_0, 2))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_add_xx_0, 2))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.blocks_threshold_ff_0_0, 0))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.blocks_threshold_ff_0_1, 0))
        self.connect((self.blocks_streams_to_vector_0, 0),
                     (self.blocks_argmax_xx_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_threshold_ff_0_0, 0),
                     (self.blocks_add_const_vxx_0_0, 0))
        self.connect((self.blocks_threshold_ff_0_1, 0),
                     (self.blocks_add_const_vxx_0_0_0, 0))
        self.connect((self.blocks_udp_source_0, 0), (self.NOAA19_fall, 0))
        self.connect((self.blocks_udp_source_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_udp_source_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_udp_source_0_1, 0), (self.NOAA18_fall, 0))
        self.connect((self.blocks_udp_source_0_1, 0),
                     (self.blocks_complex_to_mag_squared_0_0, 0))
        self.connect((self.blocks_udp_source_0_1, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_udp_source_0_2, 0), (self.NOAA15_fall, 0))
        self.connect((self.blocks_udp_source_0_2, 0),
                     (self.blocks_complex_to_mag_squared_0_1, 0))
        self.connect((self.blocks_udp_source_0_2, 0),
                     (self.blocks_multiply_xx_2, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_udp_sink_0, 0))
示例#52
0
	def __init__(self, fft_len, sens_per_sec, sample_rate, channel_space = 1,
	 search_bw = 1, thr_leveler = 10, tune_freq = 0, alpha_avg = 1, test_duration = 1,
	  period = 3600, trunc_band = 1, verbose = False, psd = False, waterfall = False, subject_channels = []):
		gr.hier_block2.__init__(self,
			"spectrum_sensor_v1",
			gr.io_signature(1, 1, gr.sizeof_gr_complex),
			gr.io_signature(0, 0, 0))
		self.fft_len = fft_len #lenght of the fft for spectral analysis
		self.sens_per_sec = sens_per_sec #number of measurements per second (decimates)
		self.sample_rate = sample_rate 
		self.channel_space = channel_space #channel space for analysis
		self.search_bw = search_bw #search bandwidth within each channel
		self.thr_leveler = thr_leveler #leveler factor for noise floor / threshold comparison
		self.tune_freq = tune_freq #center frequency
		self.threshold = 0 #actual value of the threshold
		self.alpha_avg = alpha_avg #averaging factor for noise level between consecutive measurements
		self.verbose = verbose
		self.trunc_band = trunc_band
		self.psd = psd
		self.waterfall = waterfall
		self.subject_channels = subject_channels

		#gnuradio msg queues
		self.msgq0 = gr.msg_queue(2)
		self.msgq1 = gr.msg_queue(2)

		#######BLOCKS#####
		self.s2p = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fft_len)
		self.one_in_n = blocks.keep_one_in_n(gr.sizeof_gr_complex * self.fft_len,
		 max(1, int(self.sample_rate/self.fft_len/self.sens_per_sec)))

		mywindow = window.blackmanharris(self.fft_len)
		self.fft = fft.fft_vcc(self.fft_len, True, (), True)

		self.c2mag2 = blocks.complex_to_mag_squared(self.fft_len)
		self.multiply = blocks.multiply_const_vff(np.array([1.0/float(self.fft_len**2)]*fft_len))

		#MSG sinks PSD data 
		self.sink0 = blocks.message_sink(gr.sizeof_float * self.fft_len, self.msgq0, True)
		self.sink1 = blocks.message_sink(gr.sizeof_float * self.fft_len, self.msgq1, True)

		#####CONNECTIONS####
		self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag2, self.multiply, self.sink0)
		self.connect(self.multiply, self.sink1)
		
		#-----waterfall-----> different decimation because operates in a slower rate
		self.msgq2 = gr.msg_queue(2)
		self.sink2 = blocks.message_sink(gr.sizeof_float * self.fft_len, self.msgq2, True)
		self.one_in_n_waterfall = blocks.keep_one_in_n(gr.sizeof_float * self.fft_len, self.sens_per_sec) #keep 1 per second...
		self.connect(self.multiply, self.one_in_n_waterfall, self.sink2)

		#start periodic logging
		self._logger = logger(self.fft_len, period, test_duration)

		#Watchers
		#statistics and power
		self._stats_watcher = _stats_watcher(self.msgq0, sens_per_sec, self.tune_freq, self.channel_space,
		 self.search_bw, self.fft_len, self.sample_rate, self.thr_leveler, self.alpha_avg, test_duration,
		  trunc_band, verbose, self._logger)
		#psd
		if self.psd:
			self._psd_watcher = _psd_watcher(self.msgq1, verbose, self._logger)
		#waterfall
		if self.waterfall:
			self._waterfall_watcher = _waterfall_watcher(self.msgq2, verbose, self._logger)
示例#53
0
    def __init__(self):
        gr.top_block.__init__(
            self, "NsfIntegrate: Average+Record Astronomical Obs.")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("NsfIntegrate: Average+Record Astronomical Obs.")
        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", "NsfIntegrate60")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.ConfigFile = ConfigFile = "Watch60.conf"
        self._Frequencys_config = ConfigParser.ConfigParser()
        self._Frequencys_config.read(ConfigFile)
        try:
            Frequencys = self._Frequencys_config.getfloat("main", "Frequency")
        except:
            Frequencys = 1419.5e6
        self.Frequencys = Frequencys
        self._Bandwidths_config = ConfigParser.ConfigParser()
        self._Bandwidths_config.read(ConfigFile)
        try:
            Bandwidths = self._Bandwidths_config.getfloat("main", "Bandwidth")
        except:
            Bandwidths = 4.5e6
        self.Bandwidths = Bandwidths
        self._fftsize_save_config = ConfigParser.ConfigParser()
        self._fftsize_save_config.read(ConfigFile)
        try:
            fftsize_save = self._fftsize_save_config.getint("main", "fftsize")
        except:
            fftsize_save = 1024
        self.fftsize_save = fftsize_save
        self.Frequency = Frequency = Frequencys
        self.Bandwidth = Bandwidth = Bandwidths
        self._xaxis_save_config = ConfigParser.ConfigParser()
        self._xaxis_save_config.read(ConfigFile)
        try:
            xaxis_save = self._xaxis_save_config.getint("main", "Xaxis")
        except:
            xaxis_save = 0
        self.xaxis_save = xaxis_save
        self._telescope_save_config = ConfigParser.ConfigParser()
        self._telescope_save_config.read(ConfigFile)
        try:
            telescope_save = self._telescope_save_config.get(
                "main", "telescope")
        except:
            telescope_save = "Bubble Wrap Horn"
        self.telescope_save = telescope_save
        self._observers_save_config = ConfigParser.ConfigParser()
        self._observers_save_config.read(ConfigFile)
        try:
            observers_save = self._observers_save_config.get(
                "main", "observers")
        except:
            observers_save = "Katherine, Nathaniel, Glen"
        self.observers_save = observers_save
        self.numin = numin = (Frequency - (Bandwidth / 2.))
        self._nAves_config = ConfigParser.ConfigParser()
        self._nAves_config.read(ConfigFile)
        try:
            nAves = self._nAves_config.getint("main", "nave")
        except:
            nAves = 20
        self.nAves = nAves
        self._frame_save_config = ConfigParser.ConfigParser()
        self._frame_save_config.read(ConfigFile)
        try:
            frame_save = self._frame_save_config.getint("main", "Frame")
        except:
            frame_save = 0
        self.frame_save = frame_save
        self.fftsize = fftsize = fftsize_save
        self._device_save_config = ConfigParser.ConfigParser()
        self._device_save_config.read(ConfigFile)
        try:
            device_save = self._device_save_config.get("main", "device")
        except:
            device_save = "pluto=0"
        self.device_save = device_save
        self.H1 = H1 = 1420.406E6
        self._Gain1s_config = ConfigParser.ConfigParser()
        self._Gain1s_config.read(ConfigFile)
        try:
            Gain1s = self._Gain1s_config.getfloat("main", "gain1")
        except:
            Gain1s = 63.
        self.Gain1s = Gain1s
        self._Elevation_save_config = ConfigParser.ConfigParser()
        self._Elevation_save_config.read(ConfigFile)
        try:
            Elevation_save = self._Elevation_save_config.getfloat(
                "main", "elevation")
        except:
            Elevation_save = 90.
        self.Elevation_save = Elevation_save
        self._Azimuth_save_config = ConfigParser.ConfigParser()
        self._Azimuth_save_config.read(ConfigFile)
        try:
            Azimuth_save = self._Azimuth_save_config.getfloat(
                "main", "azimuth")
        except:
            Azimuth_save = 90.
        self.Azimuth_save = Azimuth_save
        self.yunits = yunits = ["Counts", "Power (dB)", "Intensity (Kelvins)"]
        self.ymins = ymins = [0.01, -20, 50.]
        self.ymaxs = ymaxs = [7., 10., 200.]
        self.xsteps = xsteps = [
            Bandwidth * 1.E-6 / fftsize, -Bandwidth * 3.E5 / (H1 * fftsize), 1
        ]
        self.xmins = xmins = [numin * 1E-6, (H1 - numin) * (3E5 / H1), 0]
        self._xaxis_save_0_config = ConfigParser.ConfigParser()
        self._xaxis_save_0_config.read(ConfigFile)
        try:
            xaxis_save_0 = self._xaxis_save_0_config.getint("main", "Xaxis")
        except:
            xaxis_save_0 = 0
        self.xaxis_save_0 = xaxis_save_0
        self.units = units = 0
        self.obstype = obstype = 0
        self.observer = observer = observers_save
        self.nAve = nAve = nAves
        self.Xaxis = Xaxis = xaxis_save
        self.VelFrame = VelFrame = frame_save
        self.Telescope = Telescope = telescope_save
        self.Record = Record = 0
        self.Gain1 = Gain1 = Gain1s
        self.Elevation = Elevation = Elevation_save
        self.Device = Device = device_save
        self.Azimuth = Azimuth = Azimuth_save

        ##################################################
        # Blocks
        ##################################################
        self._units_options = (
            0,
            1,
            2,
        )
        self._units_labels = (
            "Counts",
            "dB",
            "Kelvins",
        )
        self._units_tool_bar = Qt.QToolBar(self)
        self._units_tool_bar.addWidget(Qt.QLabel("Units" + ": "))
        self._units_combo_box = Qt.QComboBox()
        self._units_tool_bar.addWidget(self._units_combo_box)
        for label in self._units_labels:
            self._units_combo_box.addItem(label)
        self._units_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._units_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._units_options.index(i)))
        self._units_callback(self.units)
        self._units_combo_box.currentIndexChanged.connect(
            lambda i: self.set_units(self._units_options[i]))
        self.top_grid_layout.addWidget(self._units_tool_bar, 9, 0, 1, 1)
        self._obstype_options = (
            0,
            1,
            2,
            3,
        )
        self._obstype_labels = (
            "Survey",
            "Hot",
            "Cold",
            "Ref",
        )
        self._obstype_tool_bar = Qt.QToolBar(self)
        self._obstype_tool_bar.addWidget(Qt.QLabel("Obs" + ": "))
        self._obstype_combo_box = Qt.QComboBox()
        self._obstype_tool_bar.addWidget(self._obstype_combo_box)
        for label in self._obstype_labels:
            self._obstype_combo_box.addItem(label)
        self._obstype_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._obstype_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._obstype_options.index(i)))
        self._obstype_callback(self.obstype)
        self._obstype_combo_box.currentIndexChanged.connect(
            lambda i: self.set_obstype(self._obstype_options[i]))
        self.top_grid_layout.addWidget(self._obstype_tool_bar, 8, 0, 1, 1)
        self._observer_tool_bar = Qt.QToolBar(self)
        self._observer_tool_bar.addWidget(Qt.QLabel("Who" + ": "))
        self._observer_line_edit = Qt.QLineEdit(str(self.observer))
        self._observer_tool_bar.addWidget(self._observer_line_edit)
        self._observer_line_edit.returnPressed.connect(
            lambda: self.set_observer(
                str(str(self._observer_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._observer_tool_bar, 0, 0, 1, 2)
        self._nAve_tool_bar = Qt.QToolBar(self)
        self._nAve_tool_bar.addWidget(Qt.QLabel("N_Ave." + ": "))
        self._nAve_line_edit = Qt.QLineEdit(str(self.nAve))
        self._nAve_tool_bar.addWidget(self._nAve_line_edit)
        self._nAve_line_edit.returnPressed.connect(lambda: self.set_nAve(
            int(str(self._nAve_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._nAve_tool_bar, 0, 3, 1, 1)
        self._fftsize_tool_bar = Qt.QToolBar(self)
        self._fftsize_tool_bar.addWidget(Qt.QLabel("FFT_size" + ": "))
        self._fftsize_line_edit = Qt.QLineEdit(str(self.fftsize))
        self._fftsize_tool_bar.addWidget(self._fftsize_line_edit)
        self._fftsize_line_edit.returnPressed.connect(lambda: self.set_fftsize(
            int(str(self._fftsize_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._fftsize_tool_bar, 1, 3, 1, 1)
        self._Xaxis_options = (
            0,
            1,
            2,
        )
        self._Xaxis_labels = (
            "Frequency (MHz)",
            "Velocity (km/sec)",
            "Channels",
        )
        self._Xaxis_tool_bar = Qt.QToolBar(self)
        self._Xaxis_tool_bar.addWidget(Qt.QLabel("Xaxis" + ": "))
        self._Xaxis_combo_box = Qt.QComboBox()
        self._Xaxis_tool_bar.addWidget(self._Xaxis_combo_box)
        for label in self._Xaxis_labels:
            self._Xaxis_combo_box.addItem(label)
        self._Xaxis_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._Xaxis_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._Xaxis_options.index(i)))
        self._Xaxis_callback(self.Xaxis)
        self._Xaxis_combo_box.currentIndexChanged.connect(
            lambda i: self.set_Xaxis(self._Xaxis_options[i]))
        self.top_grid_layout.addWidget(self._Xaxis_tool_bar, 11, 4, 1, 2)
        self._Telescope_tool_bar = Qt.QToolBar(self)
        self._Telescope_tool_bar.addWidget(Qt.QLabel("Tel" + ": "))
        self._Telescope_line_edit = Qt.QLineEdit(str(self.Telescope))
        self._Telescope_tool_bar.addWidget(self._Telescope_line_edit)
        self._Telescope_line_edit.returnPressed.connect(
            lambda: self.set_Telescope(
                str(str(self._Telescope_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._Telescope_tool_bar, 1, 0, 1, 2)
        self._Record_options = (
            0,
            1,
            2,
        )
        self._Record_labels = (
            "! Wait !",
            "AVERAGE",
            "Save",
        )
        self._Record_tool_bar = Qt.QToolBar(self)
        self._Record_tool_bar.addWidget(Qt.QLabel("Rec" + ": "))
        self._Record_combo_box = Qt.QComboBox()
        self._Record_tool_bar.addWidget(self._Record_combo_box)
        for label in self._Record_labels:
            self._Record_combo_box.addItem(label)
        self._Record_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._Record_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._Record_options.index(i)))
        self._Record_callback(self.Record)
        self._Record_combo_box.currentIndexChanged.connect(
            lambda i: self.set_Record(self._Record_options[i]))
        self.top_grid_layout.addWidget(self._Record_tool_bar, 7, 0, 1, 1)
        self._Gain1_tool_bar = Qt.QToolBar(self)
        self._Gain1_tool_bar.addWidget(Qt.QLabel("Gain1" + ": "))
        self._Gain1_line_edit = Qt.QLineEdit(str(self.Gain1))
        self._Gain1_tool_bar.addWidget(self._Gain1_line_edit)
        self._Gain1_line_edit.returnPressed.connect(lambda: self.set_Gain1(
            eng_notation.str_to_num(str(self._Gain1_line_edit.text().toAscii())
                                    )))
        self.top_grid_layout.addWidget(self._Gain1_tool_bar, 3, 0, 1, 1)
        self._Frequency_tool_bar = Qt.QToolBar(self)
        self._Frequency_tool_bar.addWidget(Qt.QLabel("Freq. Hz" + ": "))
        self._Frequency_line_edit = Qt.QLineEdit(str(self.Frequency))
        self._Frequency_tool_bar.addWidget(self._Frequency_line_edit)
        self._Frequency_line_edit.returnPressed.connect(
            lambda: self.set_Frequency(
                eng_notation.str_to_num(
                    str(self._Frequency_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._Frequency_tool_bar, 1, 5, 1, 1)
        self._Elevation_tool_bar = Qt.QToolBar(self)
        self._Elevation_tool_bar.addWidget(Qt.QLabel("Elevation" + ": "))
        self._Elevation_line_edit = Qt.QLineEdit(str(self.Elevation))
        self._Elevation_tool_bar.addWidget(self._Elevation_line_edit)
        self._Elevation_line_edit.returnPressed.connect(
            lambda: self.set_Elevation(
                eng_notation.str_to_num(
                    str(self._Elevation_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._Elevation_tool_bar, 0, 6, 1, 1)
        self._Device_tool_bar = Qt.QToolBar(self)
        self._Device_tool_bar.addWidget(Qt.QLabel("Dev" + ": "))
        self._Device_line_edit = Qt.QLineEdit(str(self.Device))
        self._Device_tool_bar.addWidget(self._Device_line_edit)
        self._Device_line_edit.returnPressed.connect(lambda: self.set_Device(
            str(str(self._Device_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._Device_tool_bar, 2, 0, 1, 2)
        self._Bandwidth_tool_bar = Qt.QToolBar(self)
        self._Bandwidth_tool_bar.addWidget(Qt.QLabel("Bandwidth" + ": "))
        self._Bandwidth_line_edit = Qt.QLineEdit(str(self.Bandwidth))
        self._Bandwidth_tool_bar.addWidget(self._Bandwidth_line_edit)
        self._Bandwidth_line_edit.returnPressed.connect(
            lambda: self.set_Bandwidth(
                eng_notation.str_to_num(
                    str(self._Bandwidth_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._Bandwidth_tool_bar, 1, 6, 1, 1)
        self._Azimuth_tool_bar = Qt.QToolBar(self)
        self._Azimuth_tool_bar.addWidget(Qt.QLabel("Azimuth" + ": "))
        self._Azimuth_line_edit = Qt.QLineEdit(str(self.Azimuth))
        self._Azimuth_tool_bar.addWidget(self._Azimuth_line_edit)
        self._Azimuth_line_edit.returnPressed.connect(lambda: self.set_Azimuth(
            eng_notation.str_to_num(
                str(self._Azimuth_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._Azimuth_tool_bar, 0, 5, 1, 1)
        self.ra_vmedian_5 = ra_vmedian.ra_vmedian(fftsize, 4)
        self.ra_vmedian_4 = ra_vmedian.ra_vmedian(fftsize, 4)
        self.ra_vmedian_3 = ra_vmedian.ra_vmedian(fftsize, 4)
        self.ra_vmedian_2 = ra_vmedian.ra_vmedian(fftsize, 4)
        self.ra_vmedian_1 = ra_vmedian.ra_vmedian(fftsize, 4)
        self.qtgui_vector_sink_f_0_0 = qtgui.vector_sink_f(
            fftsize,
            xmins[Xaxis],
            xsteps[Xaxis],
            "",
            "Power",
            "",
            5  # Number of inputs
        )
        self.qtgui_vector_sink_f_0_0.set_update_time(1)
        self.qtgui_vector_sink_f_0_0.set_y_axis(ymins[units], ymaxs[units])
        self.qtgui_vector_sink_f_0_0.enable_autoscale(False)
        self.qtgui_vector_sink_f_0_0.enable_grid(False)
        self.qtgui_vector_sink_f_0_0.set_x_axis_units("")
        self.qtgui_vector_sink_f_0_0.set_y_axis_units("")
        self.qtgui_vector_sink_f_0_0.set_ref_level(
            0.25 * (ymins[units] + (3. * ymaxs[units])))

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

        self._qtgui_vector_sink_f_0_0_win = sip.wrapinstance(
            self.qtgui_vector_sink_f_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_vector_sink_f_0_0_win, 2, 1,
                                       8, 6)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_NONE, 1)
        self.qtgui_number_sink_0.set_update_time(1)
        self.qtgui_number_sink_0.set_title("")

        labels = ["T Remains:", "", "", "", "", "", "", "", "", ""]
        units = ["(s)", "", "", "", "", "", "", "", "", ""]
        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, 0)
            self.qtgui_number_sink_0.set_max(
                i, nAve * fftsize * 1024. / Bandwidth)
            self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0.set_label(i, labels[i])
            self.qtgui_number_sink_0.set_unit(i, units[i])
            self.qtgui_number_sink_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 11, 6, 1,
                                       2)
        self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f(
            1024, 100, -.8, .8, "", 2)

        self.qtgui_histogram_sink_x_0.set_update_time(1)
        self.qtgui_histogram_sink_x_0.enable_autoscale(True)
        self.qtgui_histogram_sink_x_0.enable_accumulate(False)
        self.qtgui_histogram_sink_x_0.enable_grid(False)

        if not True:
            self.qtgui_histogram_sink_x_0.disable_legend()

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

        self._qtgui_histogram_sink_x_0_win = sip.wrapinstance(
            self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_histogram_sink_x_0_win, 4,
                                       0, 3, 1)

        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               Device)
        self.osmosdr_source_0.set_sample_rate(Bandwidth)
        self.osmosdr_source_0.set_center_freq(Frequency, 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(float(Gain1), 0)
        self.osmosdr_source_0.set_if_gain(12, 0)
        self.osmosdr_source_0.set_bb_gain(12, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(Bandwidth, 0)

        self.fft_vxx_0 = fft.fft_vcc(fftsize, True, (window.hamming(fftsize)),
                                     True, 1)
        self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, fftsize)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(
            fftsize)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self._VelFrame_options = (
            0,
            1,
            2,
        )
        self._VelFrame_labels = (
            "Topocentric",
            "LSRK",
            "Barycentric",
        )
        self._VelFrame_tool_bar = Qt.QToolBar(self)
        self._VelFrame_tool_bar.addWidget(Qt.QLabel("Frame" + ": "))
        self._VelFrame_combo_box = Qt.QComboBox()
        self._VelFrame_tool_bar.addWidget(self._VelFrame_combo_box)
        for label in self._VelFrame_labels:
            self._VelFrame_combo_box.addItem(label)
        self._VelFrame_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._VelFrame_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._VelFrame_options.index(i)))
        self._VelFrame_callback(self.VelFrame)
        self._VelFrame_combo_box.currentIndexChanged.connect(
            lambda i: self.set_VelFrame(self._VelFrame_options[i]))
        self.top_grid_layout.addWidget(self._VelFrame_tool_bar, 11, 0, 1, 1)
        self.Ra_Integrate_1 = ra_integrate.ra_integrate(
            str(ConfigFile), observer, fftsize, Frequency, Bandwidth, Azimuth,
            Elevation, Record, obstype, (4**5), units, 295., 10.)
        self.Ra_Ascii_Sink_0 = ra_ascii_sink.ra_ascii_sink(
            ConfigFile, observer, fftsize, Frequency, Bandwidth, Azimuth,
            Elevation, Record, obstype, 4**5, nAve, Telescope, Device, Gain1,
            12, 12)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.Ra_Ascii_Sink_0, 0), (self.qtgui_number_sink_0, 0))
        self.connect((self.Ra_Integrate_1, 1),
                     (self.qtgui_vector_sink_f_0_0, 1))
        self.connect((self.Ra_Integrate_1, 3),
                     (self.qtgui_vector_sink_f_0_0, 3))
        self.connect((self.Ra_Integrate_1, 2),
                     (self.qtgui_vector_sink_f_0_0, 2))
        self.connect((self.Ra_Integrate_1, 0),
                     (self.qtgui_vector_sink_f_0_0, 0))
        self.connect((self.Ra_Integrate_1, 4),
                     (self.qtgui_vector_sink_f_0_0, 4))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.qtgui_histogram_sink_x_0, 1))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.qtgui_histogram_sink_x_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.ra_vmedian_1, 0))
        self.connect((self.blocks_stream_to_vector_0_0, 0),
                     (self.fft_vxx_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.blocks_stream_to_vector_0_0, 0))
        self.connect((self.ra_vmedian_1, 0), (self.ra_vmedian_2, 0))
        self.connect((self.ra_vmedian_2, 0), (self.ra_vmedian_3, 0))
        self.connect((self.ra_vmedian_3, 0), (self.ra_vmedian_4, 0))
        self.connect((self.ra_vmedian_4, 0), (self.ra_vmedian_5, 0))
        self.connect((self.ra_vmedian_5, 0), (self.Ra_Ascii_Sink_0, 0))
        self.connect((self.ra_vmedian_5, 0), (self.Ra_Integrate_1, 0))
示例#54
0
    def __init__(self):
        gr.top_block.__init__(self)

        # usage = "usage: %prog [options] min_freq max_freq"
        usage = "usage: %prog [options] mycenter_freq show_band"

        parser = OptionParser(option_class=eng_option, usage=usage)
        parser.add_option("-a", "--args", type="string", default="",
                          help="UHD device device address args [default=%default]")
        parser.add_option("", "--spec", type="string", default=None,
	                  help="Subdevice of UHD device where appropriate")
        parser.add_option("-A", "--antenna", type="string", default=None,
                          help="select Rx Antenna where appropriate")
        parser.add_option("-s", "--samp-rate", type="eng_float", default=1e6,
                          help="set sample rate [default=%default]")
        parser.add_option("-g", "--gain", type="eng_float", default=None,
                          help="set gain in dB (default is midpoint)")
        parser.add_option("", "--tune-delay", type="eng_float",
                          default=0.25, metavar="SECS",
                          help="time to delay (in seconds) after changing frequency [default=%default]")
        parser.add_option("", "--dwell-delay", type="eng_float",
                          default=0.25, metavar="SECS",
                          help="time to dwell (in seconds) at a given frequency [default=%default]")
        # parser.add_option("-b", "--channel-bandwidth", type="eng_float",
        #                   default=6.25e3, metavar="Hz",
        #                   help="channel bandwidth of fft bins in Hz [default=%default]")#这个应该是频率分辨度(的而他f)
        parser.add_option("-l", "--lo-offset", type="eng_float",
                          default=0, metavar="Hz",
                          help="lo_offset in Hz [default=%default]")
        parser.add_option("-q", "--squelch-threshold", type="eng_float",
                          default=None, metavar="dB",
                          help="squelch threshold in dB [default=%default]")
        parser.add_option("-F", "--fft-size", type="int", default=None,
                          help="specify number of FFT bins [default=1024]")
        parser.add_option("", "--real-time", action="store_true", default=False,
                          help="Attempt to enable real-time scheduling")

        (options, args) = parser.parse_args()
        if len(args) != 2:
            parser.print_help()
            sys.exit(1)

        # self.channel_bandwidth = options.channel_bandwidth

        myusrprate=options.samp_rate
        self.fft_size = options.fft_size
        self.channel_bandwidth = myusrprate/self.fft_size 

        self.mycenter_freq = eng_notation.str_to_num(args[0])
        self.show_band     = eng_notation.str_to_num(args[1])
        if self.show_band >myusrprate:
            sys.stderr.write("error:show_band must be smaller than samplerate\n")
            sys.exit(1)
        show_band=self.show_band 
        #add
        temp_varible=show_band/2
        self.min_freq = self.mycenter_freq - temp_varible
        self.max_freq = self.mycenter_freq + temp_varible

        args[0]=eng_notation.num_to_str(self.min_freq)
        args[1]=eng_notation.num_to_str(self.max_freq)

        # if self.min_freq > self.max_freq:
        #     # swap them
        #     self.min_freq, self.max_freq = self.max_freq, self.min_freq

        if not options.real_time:#尝试使用实时调度
            realtime = False
        else:
            # Attempt to enable realtime scheduling
            r = gr.enable_realtime_scheduling()
            if r == gr.RT_OK:
                realtime = True
            else:
                realtime = False
                print "Note: failed to enable realtime scheduling"

        # build graph应该是调用真实的usrp的信号self.u有地址和数据
        self.u = uhd.usrp_source(device_addr=options.args,
                                 stream_args=uhd.stream_args('fc32'))

        # Set the subdevice spec
        if(options.spec):
            self.u.set_subdev_spec(options.spec, 0)

        # Set the antenna
        if(options.antenna):
            self.u.set_antenna(options.antenna, 0)

        self.u.set_samp_rate(options.samp_rate)
        self.usrp_rate = usrp_rate = self.u.get_samp_rate()

        self.lo_offset = options.lo_offset

        self.squelch_threshold = options.squelch_threshold

        s2v = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fft_size)#stream_to_vector

        mywindow = filter.window.blackmanharris(self.fft_size)
        ffter = fft.fft_vcc(self.fft_size, True, mywindow, True)#滤波参数
        power = 0
        for tap in mywindow:
            power += tap*tap

        c2mag = blocks.complex_to_mag_squared(self.fft_size)#平方运算

        # FIXME the log10 primitive is dog slow
        #log = blocks.nlog10_ff(10, self.fft_size,
        #                       -20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size))

        # Set the freq_step to 75% of the actual data throughput.
        # This allows us to discard the bins on both ends of the spectrum.

        self.freq_step = self.nearest_freq(show_band, self.channel_bandwidth)#频率分辨率的整数倍(并不等于自己设置的那个),也是扫频长度
        self.center_freq = self.min_freq + (self.freq_step/2)#算最小中心频率
        # nsteps = math.ceil((self.max_freq - self.min_freq) / self.freq_step)
        # self.center_freq = self.min_center_freq + self.freq_step

        self.next_freq = self.center_freq

        tune_delay  = max(0, int(round(options.tune_delay * usrp_rate / self.fft_size)))  # in fft_frames
        dwell_delay = max(1, int(round(options.dwell_delay * usrp_rate / self.fft_size))) # in fft_frames

        self.msgq = gr.msg_queue(1)
        self._tune_callback = tune(self)        # 是USRP调谐频率过程的一个程序句柄,有了它,stats就可以调用调谐子程序了hang on to this to keep it from being GC'd
        stats = blocks.bin_statistics_f(self.fft_size, self.msgq,
                                        self._tune_callback, tune_delay,#等待时间,扫频时间等可能都在这个函数中实现
                                        dwell_delay)      #构建一个bin统计数据块(可能是计算出下一个的中心频率)
        print "usrp_rate=",self.usrp_rate,"channel_bandwidth(频谱分辨率)=",self.channel_bandwidth,\
             "fft_size= ",self.fft_size ,"freq_step(扫频长度)=", self.freq_step
        # FIXME leave out the log10 until we speed it up

	#self.connect(self.u, s2v, ffter, c2mag, log, stats)
	self.connect(self.u, s2v, ffter, c2mag, stats)
        if options.gain is None:
            # if no gain was specified, use the mid-point in dB
            g = self.u.get_gain_range()
            options.gain = float(g.start()+g.stop())/2.0
        self.set_gain(options.gain)
        print "gain =", options.gain
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.initpathprefix = initpathprefix = "/home/user/alarm-fingerprint/AlarmGnuRadioFiles/"
        self.pathprefix = pathprefix = "/home/user/alarm-fingerprint/AlarmGnuRadioFiles/Captured/"
        self.finput = finput = initpathprefix+"Capture_init.cap"
        self.foutput = foutput = pathprefix+finput.rsplit("/", 1)[1] 
        self.symb_rate = symb_rate = 4000
        self.samp_rate = samp_rate = 10e6
        self.decimation = decimation = 100
        self.channel_spacing = channel_spacing = (2000000+1000000)
        self.addconst = addconst = 0
        self.symb_rate_slider = symb_rate_slider = 4000
        self.samp_per_sym = samp_per_sym = int((samp_rate/decimation) / symb_rate)
        self.recfile4 = recfile4 = initpathprefix+"/init/_AddConst"+str(addconst)+ "_DSC.dat"
        self.freq_offset = freq_offset = (channel_spacing/2)+(channel_spacing * .1)
        self.freq = freq = 433.92e6
        self.channel_trans = channel_trans = 1.2e6

        ##################################################
        # Blocks
        ##################################################
        _channel_trans_sizer = wx.BoxSizer(wx.VERTICAL)
        self._channel_trans_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_channel_trans_sizer,
        	value=self.channel_trans,
        	callback=self.set_channel_trans,
        	label='channel_trans',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._channel_trans_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_channel_trans_sizer,
        	value=self.channel_trans,
        	callback=self.set_channel_trans,
        	minimum=0,
        	maximum=1.8e6,
        	num_steps=10,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_channel_trans_sizer)
        _symb_rate_slider_sizer = wx.BoxSizer(wx.VERTICAL)
        self._symb_rate_slider_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_symb_rate_slider_sizer,
        	value=self.symb_rate_slider,
        	callback=self.set_symb_rate_slider,
        	label='symb_rate_slider',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._symb_rate_slider_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_symb_rate_slider_sizer,
        	value=self.symb_rate_slider,
        	callback=self.set_symb_rate_slider,
        	minimum=0,
        	maximum=10e3,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_symb_rate_slider_sizer)
        self.low_pass_filter_0 = filter.fir_filter_fff(decimation, firdes.low_pass(
        	1, samp_rate, 8e3, 1.8e6, firdes.WIN_BLACKMAN, 6.76))
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (firdes.low_pass(1, samp_rate, channel_spacing, channel_trans, firdes.WIN_BLACKMAN,6.76)), -freq_offset, samp_rate)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(samp_per_sym*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005)
        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_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, finput, False)
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_char*1, recfile4, False)
        self.blocks_file_sink_1.set_unbuffered(False)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((addconst, ))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.low_pass_filter_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_file_sink_1, 0))
示例#56
0
    def __init__(self, alpha=0):
        gr.hier_block2.__init__(
            self,
            "IQ Phase Balancer",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
        )

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

        ##################################################
        # Blocks
        ##################################################
        self.filter_single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(
            alpha, 1)
        self.blocks_sub_xx_1 = blocks.sub_ff(1)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_multiply_xx_2 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_divide_xx_0, 0))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.filter_single_pole_iir_filter_xx_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_sub_xx_1, 1))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_sub_xx_1, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_sub_xx_1, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.filter_single_pole_iir_filter_xx_0, 0))
        self.connect((self, 0), (self.blocks_complex_to_float_0, 0))
        self.connect((self, 0), (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self, 0))
        self.connect((self.filter_single_pole_iir_filter_xx_0, 0),
                     (self.blocks_multiply_xx_2, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_multiply_xx_2, 1))
    def __init__(self, bandwidth=10e6, chan_est=ieee802_11.LS, encoding=ieee802_11.BPSK_1_2, frequency=5.89e9, sensitivity=0.56):
        gr.hier_block2.__init__(
            self, "WiFi PHY Hier",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
        )
        self.message_port_register_hier_in("mac_in")
        self.message_port_register_hier_out("carrier")
        self.message_port_register_hier_out("mac_out")

        ##################################################
        # Parameters
        ##################################################
        self.bandwidth = bandwidth
        self.chan_est = chan_est
        self.encoding = encoding
        self.frequency = frequency
        self.sensitivity = sensitivity

        ##################################################
        # Variables
        ##################################################
        self.window_size = window_size = 48
        self.sync_length = sync_length = 320
        self.max_symbols = max_symbols = 5 + 1 + ((16 + 1540 * 8 + 6) * 2) / 24
        self.header_formatter = header_formatter = ieee802_11.signal_field()

        ##################################################
        # Blocks
        ##################################################
        self.sync_short = ieee802_11.sync_short(sensitivity, 2, False, False)
        self.sync_long = ieee802_11.sync_long(sync_length, False, False)
        self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_cc(window_size)
        self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_ff(window_size + 16)
        self.ieee802_11_mapper_0 = ieee802_11.mapper(encoding, False)
        self.ieee802_11_frame_equalizer_0 = ieee802_11.frame_equalizer(chan_est, frequency, bandwidth, False, False)
        self.ieee802_11_decode_mac_0 = ieee802_11.decode_mac(False, False)
        self.ieee802_11_chunks_to_symbols_xx_0 = ieee802_11.chunks_to_symbols()
        (self.ieee802_11_chunks_to_symbols_xx_0).set_min_output_buffer(397056)
        self.fft_vxx_0_1 = fft.fft_vcc(64, True, (window.rectangular(64)), True, 1)
        self.fft_vxx_0_0 = fft.fft_vcc(64, False, (tuple([1/52**.5] * 64)), True, 1)
        (self.fft_vxx_0_0).set_min_output_buffer(397056)
        self.digital_packet_headergenerator_bb_0 = digital.packet_headergenerator_bb(header_formatter.formatter(), "packet_len")
        self.digital_ofdm_cyclic_prefixer_0_0 = digital.ofdm_cyclic_prefixer(64, 64+16, 2, "packet_len")
        (self.digital_ofdm_cyclic_prefixer_0_0).set_min_output_buffer(397056)
        self.digital_ofdm_carrier_allocator_cvc_0_0_0 = digital.ofdm_carrier_allocator_cvc(64, (range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27),), ((-21, -7, 7, 21), ), ((1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1)), ((0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), (0, 0j, 0, 0j, 0, 0j, -1, 1j, -1, 1j, -1, 1j, -1, -1j, 1, 1j, 1, -1j, -1, 1j, 1, 1j, 1, 1j, 1, 1j, -1, (-0-1j), 1, -1j, -1, 1j, 0, -1j, 1, (-0-1j), 1, -1j, 1, 1j, -1, -1j, 1, (-0-1j), -1, 1j, 1, 1j, 1, 1j, 1, 1j, -1, -1j, 1, 1j, 1, -1j, -1, 0j, 0, 0j, 0, 0j), (0, 0, 0, 0, 0, 0, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 0, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 0, 0, 0, 0, 0)), "packet_len")
        (self.digital_ofdm_carrier_allocator_cvc_0_0_0).set_min_output_buffer(397056)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(([-1, 1]), 1)
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, "packet_len", 1)
        (self.blocks_tagged_stream_mux_0).set_min_output_buffer(397056)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 64)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex*1, 16)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, sync_length)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ieee802_11_decode_mac_0, 'out'), (self, 'mac_out'))    
        self.msg_connect((self.ieee802_11_frame_equalizer_0, 'symbols'), (self, 'carrier'))    
        self.msg_connect((self, 'mac_in'), (self.ieee802_11_mapper_0, 'in'))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_divide_xx_0, 0))    
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.ieee802_11_moving_average_xx_0, 0))    
        self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.blocks_delay_0, 0), (self.sync_long, 1))    
        self.connect((self.blocks_delay_0_0, 0), (self.blocks_conjugate_cc_0, 0))    
        self.connect((self.blocks_delay_0_0, 0), (self.sync_short, 0))    
        self.connect((self.blocks_divide_xx_0, 0), (self.sync_short, 2))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.ieee802_11_moving_average_xx_1, 0))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0_1, 0))    
        self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0_0_0, 0))    
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0))    
        self.connect((self.digital_ofdm_carrier_allocator_cvc_0_0_0, 0), (self.fft_vxx_0_0, 0))    
        self.connect((self.digital_ofdm_cyclic_prefixer_0_0, 0), (self, 0))    
        self.connect((self.digital_packet_headergenerator_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))    
        self.connect((self.fft_vxx_0_0, 0), (self.digital_ofdm_cyclic_prefixer_0_0, 0))    
        self.connect((self.fft_vxx_0_1, 0), (self.ieee802_11_frame_equalizer_0, 0))    
        self.connect((self.ieee802_11_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 1))    
        self.connect((self.ieee802_11_frame_equalizer_0, 0), (self.ieee802_11_decode_mac_0, 0))    
        self.connect((self.ieee802_11_mapper_0, 0), (self.digital_packet_headergenerator_bb_0, 0))    
        self.connect((self.ieee802_11_mapper_0, 0), (self.ieee802_11_chunks_to_symbols_xx_0, 0))    
        self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.blocks_divide_xx_0, 1))    
        self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.sync_short, 1))    
        self.connect((self, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self, 0), (self.blocks_delay_0_0, 0))    
        self.connect((self, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.sync_long, 0), (self.blocks_stream_to_vector_0, 0))    
        self.connect((self.sync_short, 0), (self.blocks_delay_0, 0))    
        self.connect((self.sync_short, 0), (self.sync_long, 0))    
示例#58
0
    def __init__(self, fc=629e6, gaindB=23, samp_rate=12.5e6):
        gr.top_block.__init__(self, "Usrp 2Chrx Save")

        ##################################################
        # Parameters
        ##################################################
        self.fc = fc
        self.gaindB = gaindB
        self.samp_rate = samp_rate

        ##################################################
        # Variables
        ##################################################
        self.chans = chans = 4096

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_pub_sink_0 = zeromq.pub_sink(gr.sizeof_float, chans, 'tcp://*:50001', 100, False, -1)
        self.uhd_usrp_source = uhd.usrp_source(
            ",".join(("addr=10.11.2.61", "master_clock_rate=250e6")),
            uhd.stream_args(
                cpu_format="fc32",
                otw_format="sc16",
                args='',
                channels=list(range(0,2)),
            ),
        )
        self.uhd_usrp_source.set_subdev_spec('A:0 B:0', 0)
        self.uhd_usrp_source.set_time_source('external', 0)
        self.uhd_usrp_source.set_clock_source('external', 0)
        self.uhd_usrp_source.set_center_freq(fc, 0)
        self.uhd_usrp_source.set_gain(gaindB, 0)
        self.uhd_usrp_source.set_antenna('TX/RX', 0)
        self.uhd_usrp_source.set_center_freq(fc, 1)
        self.uhd_usrp_source.set_gain(gaindB, 1)
        self.uhd_usrp_source.set_antenna('TX/RX', 1)
        self.uhd_usrp_source.set_samp_rate(samp_rate)
        self.uhd_usrp_source.set_time_unknown_pps(uhd.time_spec())
        self.fft_vxx_0_0 = fft.fft_vcc(chans, True, window.blackmanharris(chans), True, 1)
        self.fft_vxx_0 = fft.fft_vcc(chans, True, window.blackmanharris(chans), True, 1)
        self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, chans)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, chans)
        self.blocks_interleave_0 = blocks.interleave(gr.sizeof_float*chans, 1)
        self.blocks_integrate_xx_0_0 = blocks.integrate_ff(1000, chans)
        self.blocks_integrate_xx_0 = blocks.integrate_ff(1000, chans)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, 'test.cfile', False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared(chans)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(chans)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_integrate_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_0, 0), (self.blocks_integrate_xx_0_0, 0))
        self.connect((self.blocks_integrate_xx_0, 0), (self.blocks_interleave_0, 0))
        self.connect((self.blocks_integrate_xx_0_0, 0), (self.blocks_interleave_0, 1))
        self.connect((self.blocks_interleave_0, 0), (self.zeromq_pub_sink_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0_0, 0))
        self.connect((self.blocks_stream_to_vector_0_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.fft_vxx_0_0, 0), (self.blocks_complex_to_mag_squared_0_0, 0))
        self.connect((self.uhd_usrp_source, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.uhd_usrp_source, 1), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.uhd_usrp_source, 0), (self.blocks_stream_to_vector_0_0, 0))
示例#59
0
    def __init__(self):
        gr.top_block.__init__(self, "Uhd Adsb 2")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Uhd Adsb 2")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2e6
        self.rx_gain = rx_gain = 40
        self.low = low = .3
        self.high = high = .31
        self.freq = freq = 1090e6
        self.bb_gain = bb_gain = .1e6

        ##################################################
        # Blocks
        ##################################################
        self._rx_gain_tool_bar = Qt.QToolBar(self)
        self._rx_gain_tool_bar.addWidget(Qt.QLabel("rx_gain"+": "))
        self._rx_gain_line_edit = Qt.QLineEdit(str(self.rx_gain))
        self._rx_gain_tool_bar.addWidget(self._rx_gain_line_edit)
        self._rx_gain_line_edit.returnPressed.connect(
        	lambda: self.set_rx_gain(eng_notation.str_to_num(str(self._rx_gain_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._rx_gain_tool_bar)
        self._low_tool_bar = Qt.QToolBar(self)
        self._low_tool_bar.addWidget(Qt.QLabel("low"+": "))
        self._low_line_edit = Qt.QLineEdit(str(self.low))
        self._low_tool_bar.addWidget(self._low_line_edit)
        self._low_line_edit.returnPressed.connect(
        	lambda: self.set_low(eng_notation.str_to_num(str(self._low_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._low_tool_bar)
        self._high_tool_bar = Qt.QToolBar(self)
        self._high_tool_bar.addWidget(Qt.QLabel("high"+": "))
        self._high_line_edit = Qt.QLineEdit(str(self.high))
        self._high_tool_bar.addWidget(self._high_line_edit)
        self._high_line_edit.returnPressed.connect(
        	lambda: self.set_high(eng_notation.str_to_num(str(self._high_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._high_tool_bar)
        self._bb_gain_tool_bar = Qt.QToolBar(self)
        self._bb_gain_tool_bar.addWidget(Qt.QLabel("bb_gain"+": "))
        self._bb_gain_line_edit = Qt.QLineEdit(str(self.bb_gain))
        self._bb_gain_tool_bar.addWidget(self._bb_gain_line_edit)
        self._bb_gain_line_edit.returnPressed.connect(
        	lambda: self.set_bb_gain(eng_notation.str_to_num(str(self._bb_gain_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._bb_gain_tool_bar)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(freq, samp_rate/2), 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
        	4096, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #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 True:
          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 = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_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(-130, -70)
        
        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,0,4,4)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	512, #size
        	samp_rate, #samp_rate
        	"", #name
        	2 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.010)
        self.qtgui_time_sink_x_0.set_y_axis(0, 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_NORM, qtgui.TRIG_SLOPE_POS, .3, .00005, 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 = ['pre', 'post', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_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.01)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, -80)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_freq_sink_x_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(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, 4,0,4,4)
        self.fosphor_glfw_sink_c_0 = fosphor.glfw_sink_c()
        self.fosphor_glfw_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS)
        self.fosphor_glfw_sink_c_0.set_frequency_range(0, samp_rate)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(low, high, 0)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((bb_gain, ))
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_threshold_ff_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0))    
        self.connect((self.blocks_threshold_ff_0, 0), (self.qtgui_time_sink_x_0, 1))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.fosphor_glfw_sink_c_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))    
    def __init__(self, puncpat='11'):
        gr.top_block.__init__(self, "Tutorial")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Tutorial")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

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

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

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

        self.samp_rate = samp_rate = samp_rate_array_MCR[7]

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

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

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

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

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

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

        if not True:
            self.qtgui_time_sink_x_2_0_1.disable_legend()

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

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

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

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

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

        if not True:
            self.qtgui_time_sink_x_2_0_0_1.disable_legend()

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

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

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

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

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

        if not True:
            self.qtgui_time_sink_x_1.disable_legend()

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

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

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

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

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

        if not True:
            self.qtgui_time_sink_x_0_1.disable_legend()

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

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

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

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

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

        if not True:
            self.qtgui_time_sink_x_0_0.disable_legend()

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

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

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

        if not True:
            self.qtgui_freq_sink_x_1.disable_legend()

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

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

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

        if not True:
            self.qtgui_freq_sink_x_0_0_1_0.disable_legend()

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

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

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

        if not True:
            self.qtgui_const_sink_x_0_0_0_1_0.disable_legend()

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

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

        if not True:
            self.qtgui_const_sink_x_0_0_0_0.disable_legend()

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

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

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

        ##################################################
        # Connections
        ##################################################
        self.connect((self.acode_1104, 0), (self.blocks_stream_mux_0_1_0, 0))
        self.connect((self.adapt_lms_filter_xx_0, 1),
                     (self.blocks_stream_to_streams_0, 0))
        self.connect((self.adapt_lms_filter_xx_0, 1),
                     (self.qtgui_freq_sink_x_1, 1))
        self.connect((self.adapt_lms_filter_xx_0, 0),
                     (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.interp_fir_filter_xxx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_delay_0_0, 0))
        self.connect((self.blocks_char_to_float_1_0_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_char_to_float_1_0_1, 0),
                     (self.qtgui_time_sink_x_0_1, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_stream_mux_1, 1))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_stream_mux_1, 0))
        self.connect((self.blocks_complex_to_float_0_0, 1),
                     (self.blocks_stream_mux_1_0, 1))
        self.connect((self.blocks_complex_to_float_0_0, 0),
                     (self.blocks_stream_mux_1_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_1_0, 0),
                     (self.qtgui_time_sink_x_2_0_1, 0))
        self.connect((self.blocks_delay_0_0, 0), (self.custom_corr, 1))
        self.connect((self.blocks_delay_0_0_0, 0), (self.custom_corr, 0))
        self.connect((self.blocks_file_source_0_0_1_0, 0),
                     (self.blocks_char_to_float_1_0_0, 0))
        self.connect((self.blocks_file_source_0_0_1_0, 0),
                     (self.blocks_repack_bits_bb_1_0_0_1, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.qtgui_const_sink_x_0_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.qtgui_time_sink_x_1, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.digital_correlate_access_code_xx_ts_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0),
                     (self.blocks_char_to_float_1_0_1, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0),
                     (self.blocks_file_sink_0_0_0_2, 0))
        self.connect((self.blocks_repack_bits_bb_0_1, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_repack_bits_bb_1_0_0_1, 0),
                     (self.blocks_stream_mux_0_1_0, 1))
        self.connect((self.blocks_stream_mux_0_1_0, 0),
                     (self.blocks_repack_bits_bb_0_1, 0))
        self.connect((self.blocks_stream_mux_1, 0),
                     (self.adapt_lms_filter_xx_0, 1))
        self.connect((self.blocks_stream_mux_1_0, 0),
                     (self.adapt_lms_filter_xx_0, 0))
        self.connect((self.blocks_stream_to_streams_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_stream_to_streams_0, 1),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_throttle_0, 0),
                     (self.insert_vec_cpp_new_vec_0, 0))
        self.connect((self.custom_corr, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.custom_corr, 1),
                     (self.blocks_complex_to_float_0_0, 0))
        self.connect((self.custom_corr, 2),
                     (self.blocks_complex_to_mag_squared_0_1_0, 0))
        self.connect((self.custom_corr, 2),
                     (self.qtgui_time_sink_x_2_0_0_1, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0),
                     (self.qtgui_freq_sink_x_0_0_1_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_correlate_access_code_xx_ts_0_0, 0),
                     (self.blocks_repack_bits_bb_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.digital_constellation_decoder_cb_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.qtgui_const_sink_x_0_0_0_1_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.qtgui_freq_sink_x_0_0_1_0, 1))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0_0_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.insert_vec_cpp_new_vec_0, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.interp_fir_filter_xxx_0, 0),
                     (self.blocks_delay_0_0_0, 0))
        self.connect((self.interp_fir_filter_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))