Beispiel #1
0
        def __init__(self, window_size):
            gr.hier_block2.__init__(self, "FFT_IFFT",
                                    gr.io_signature(1, 1, gr.sizeof_float),
                                    gr.io_signature(1, 1, gr.sizeof_float))
            vector_to_stream = blocks.vector_to_stream(gr.sizeof_gr_complex,
                                                       window_size)
            stream_to_vector = blocks.stream_to_vector(gr.sizeof_float,
                                                       window_size)
            divide = blocks.divide_cc(1)
            complex_to_float = blocks.complex_to_float(1)
            fft_forward = fft.fft_vfc(window_size, True,
                                      (fft.window.blackmanharris(window_size)),
                                      1)
            fft_backward = fft.fft_vcc(
                window_size, False, (fft.window.blackmanharris(window_size)),
                False, 1)
            constant = analog.sig_source_c(0, analog.GR_CONST_WAVE, 0, 0,
                                           window_size)

            #print("1. Connect self to stream_to_vector")
            self.connect((self, 0), (stream_to_vector, 0))
            #print("2. Connect stream_to_vector to fft_forward")
            self.connect((stream_to_vector, 0), (fft_forward, 0))
            #print("3. Connect fft_forward to fft_backward")
            self.connect((fft_forward, 0), (fft_backward, 0))
            #print("4. Connect fft_backward to vector_to_stream")
            self.connect((fft_backward, 0), (vector_to_stream, 0))
            #print("5. Connect vector_to_stream to port 0 of divide")
            self.connect((vector_to_stream, 0), (divide, 0))
            #print("6. Connect constant to port 1 of divide")
            self.connect(constant, (divide, 1))
            #print("7. Connect divide to complex_to_float")
            self.connect((divide, 0), (complex_to_float, 0))
            #print("8. Connect complex_to_float to self")
            self.connect((complex_to_float, 0), (self, 0))
Beispiel #2
0
    def __init__(self, alpha=1e-2, reference=0.5):
        gr.hier_block2.__init__(
            self, "RMS AGC",
                gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
                gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
        )

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

        ##################################################
        # Blocks
        ##################################################
        self.blocks_rms_xx_0 = blocks.rms_cf(alpha)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(1.0/reference)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_divide_xx_0 = blocks.divide_cc(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_ff(1e-20)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_divide_xx_0, 0), (self, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_rms_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self, 0), (self.blocks_divide_xx_0, 0))
        self.connect((self, 0), (self.blocks_rms_xx_0, 0))
Beispiel #3
0
		def __init__(self, window_size):
			gr.hier_block2.__init__(self, "FFT_IFFT", gr.io_signature(1,1,gr.sizeof_float), gr.io_signature(1,1,gr.sizeof_float))
			vector_to_stream = blocks.vector_to_stream(gr.sizeof_gr_complex, window_size)
			stream_to_vector = blocks.stream_to_vector(gr.sizeof_float, window_size)
			divide = blocks.divide_cc(1)
			complex_to_float = blocks.complex_to_float(1)
			fft_forward = fft.fft_vfc(window_size, True, (fft.window.blackmanharris(window_size)), 1)
			fft_backward = fft.fft_vcc(window_size, False, (fft.window.blackmanharris(window_size)), False, 1)
			constant = analog.sig_source_c(0, analog.GR_CONST_WAVE, 0, 0, window_size)

			#print("1. Connect self to stream_to_vector")
			self.connect((self, 0), (stream_to_vector, 0))
			#print("2. Connect stream_to_vector to fft_forward")
			self.connect((stream_to_vector, 0), (fft_forward, 0))
			#print("3. Connect fft_forward to fft_backward")
			self.connect((fft_forward, 0), (fft_backward, 0))
			#print("4. Connect fft_backward to vector_to_stream")
			self.connect((fft_backward, 0), (vector_to_stream, 0))
			#print("5. Connect vector_to_stream to port 0 of divide")
			self.connect((vector_to_stream, 0), (divide, 0))
			#print("6. Connect constant to port 1 of divide")
			self.connect(constant, (divide, 1))
			#print("7. Connect divide to complex_to_float")
			self.connect((divide, 0), (complex_to_float, 0))
			#print("8. Connect complex_to_float to self")
			self.connect((complex_to_float, 0), (self, 0))
Beispiel #4
0
    def test_001_t (self):
        """AGC on random noisy QPSK symbols"""

        # Parameters
        snr_db     = 0.0
        const_mult = 1.5
        agc_rate   = 1e-4
        agc_ref    = 1.0
        agc_gain   = 1.0
        N_last     = 1000 # analyze the last symbols

        # Constants
        n_symbols = int(10*(1/agc_rate))
        noise_v   = 1/sqrt((10**(float(snr_db)/10)))
        rndm      = random.Random()

        # Input data
        in_vec  = tuple([rndm.randint(0,1) for i in range(0, n_symbols)])

        # Flowgraph
        src     = blocks.vector_source_b(in_vec)
        pack    = blocks.repack_bits_bb(1, 2, "", False, gr.GR_MSB_FIRST)
        const   = digital.constellation_qpsk().base()
        cmap    = digital.chunks_to_symbols_bc(const.points())
        mult    = blocks.multiply_const_cc(const_mult)
        nadder  = blocks.add_cc()
        noise   = analog.noise_source_c(analog.GR_GAUSSIAN, noise_v, 0)
        agc     = blocksat.agc_cc(agc_rate, agc_ref, agc_gain)
        snk     = blocks.vector_sink_c()
        snk2    = blocks.vector_sink_c()
        # Reference AGC approach
        rms_cf  = blocks.rms_cf(0.0001)
        f2c     = blocks.float_to_complex()
        div     = blocks.divide_cc()
        snk3    = blocks.vector_sink_c()
        self.tb.connect(src, pack, cmap, mult)
        self.tb.connect(mult, (nadder, 0))
        self.tb.connect(noise, (nadder, 1))
        self.tb.connect(nadder, agc, snk)
        self.tb.connect(nadder, snk2)
        self.tb.connect(nadder, (div, 0))
        self.tb.connect(nadder, rms_cf, (f2c, 0), (div, 1))
        self.tb.connect(div, snk3)
        self.tb.run()

        # Collect results
        agc_syms     = snk.data()
        pre_agc_syms = snk2.data()
        ref_agc_syms = snk3.data()
        rms_agc      = self.rms(agc_syms, N_last)
        rms_pre_agc  = self.rms(pre_agc_syms, N_last)
        rms_agc_ref  = self.rms(ref_agc_syms, N_last)

        print('RMS before AGC: %f' %(rms_pre_agc))
        print('RMS after AGC: %f' %(rms_agc))
        print('RMS after reference AGC: %f' %(rms_agc_ref))

        # Check results
        self.assertAlmostEqual(rms_agc, 1.0, places=1)
    def __init__(self, alpha=0.01):
        gr.hier_block2.__init__(
            self,
            "RMS AGC",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
        )

        self.alpha = alpha

        self.block_rms = blocks.rms_cf(alpha)
        self.block_divide = blocks.divide_cc(1)

        self.connect(
            self,
            self.block_rms,
            blocks.add_const_vff((1e-20, )),  # to avoid div by 0
            blocks.float_to_complex(1),
            (self.block_divide, 1),
        )
        self.connect(self, (self.block_divide, 0))
        self.connect((self.block_divide, 0), self)
Beispiel #6
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="FM Stereo Receiver")

        ##################################################
        # Variables
        ##################################################
        self.smux_filt_samprate = smux_filt_samprate = 256e3
        self.smux_decim = smux_decim = 8
        self.samp_rate = samp_rate = 2.048e6
        self.right_gain = right_gain = 3
        self.left_gain = left_gain = 3
        self.bpf_base = bpf_base = 23e3
        self.RF_Gain = RF_Gain = 45
        self.CF = CF = 99.3e6

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.samp_rate,
        	callback=self.set_samp_rate,
        	label="Sample Rate: 1.024M, 1.4M, 1.8M, 1.92M, 2.048M, 2.4M & 2. 56M",
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._samp_rate_text_box, 1, 0, 1, 1)
        _right_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._right_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_right_gain_sizer,
        	value=self.right_gain,
        	callback=self.set_right_gain,
        	label="R Audio Gain",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._right_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_right_gain_sizer,
        	value=self.right_gain,
        	callback=self.set_right_gain,
        	minimum=0,
        	maximum=5,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_right_gain_sizer, 0, 1, 1, 1)
        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "BB Spectrum")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Demod Spectrum")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Stereo Spectrum")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Stereo Signal")
        self.GridAdd(self.notebook_0, 2, 0, 1, 2)
        _left_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._left_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_left_gain_sizer,
        	value=self.left_gain,
        	callback=self.set_left_gain,
        	label="L Audio Gain",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._left_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_left_gain_sizer,
        	value=self.left_gain,
        	callback=self.set_left_gain,
        	minimum=0,
        	maximum=5,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_left_gain_sizer, 0, 0, 1, 1)
        _RF_Gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._RF_Gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_RF_Gain_sizer,
        	value=self.RF_Gain,
        	callback=self.set_RF_Gain,
        	label="RF Gain",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._RF_Gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_RF_Gain_sizer,
        	value=self.RF_Gain,
        	callback=self.set_RF_Gain,
        	minimum=0,
        	maximum=100,
        	num_steps=45,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_RF_Gain_sizer, 1, 1, 1, 1)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.notebook_0.GetPage(0).GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Baseband Waterfall",
        	size=(800,100),
        )
        self.notebook_0.GetPage(0).GridAdd(self.wxgui_waterfallsink2_0.win, 3, 0, 1, 2)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.notebook_0.GetPage(3).GetWin(),
        	title="Scope Plot",
        	sample_rate=32e3,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=2,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        	size=(800,500),
        )
        self.notebook_0.GetPage(3).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0_1 = fftsink2.fft_sink_f(
        	self.notebook_0.GetPage(2).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=32e3,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Difference FFT ",
        	peak_hold=False,
        )
        self.notebook_0.GetPage(2).Add(self.wxgui_fftsink2_0_1.win)
        self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_f(
        	self.notebook_0.GetPage(1).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate/8,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Demodulated FFT",
        	peak_hold=False,
        	size=(800,800),
        )
        self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_0_0_0.win)
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c(
        	self.notebook_0.GetPage(0).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Baseband FFT",
        	peak_hold=False,
        	size=(800,100),
        )
        self.notebook_0.GetPage(0).GridAdd(self.wxgui_fftsink2_0_0.win, 2, 0, 1, 2)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_f(
        	self.notebook_0.GetPage(2).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=32e3,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Sum FFT",
        	peak_hold=False,
        )
        self.notebook_0.GetPage(2).Add(self.wxgui_fftsink2_0.win)
        self.rfgain = blocks.multiply_const_vcc((RF_Gain, ))
        self.low_pass_filter_1_0 = filter.fir_filter_fff(smux_decim, firdes.low_pass(
        	1, smux_filt_samprate, 15e3, 500, firdes.WIN_HAMMING, 1))
        self.low_pass_filter_0 = filter.fir_filter_ccf(2, firdes.low_pass(
        	2, samp_rate/4, 100e3, 500, firdes.WIN_KAISER, 6.76))
        self.iir_filter_xxx_0 = filter.iir_filter_ccf((-0.00266, 0.00504, -0.00309, -0.00136, 0.00663, -0.01052, 0.01103, -0.00731, 0.00016, 0.00800, -0.01396, 0.01490, -0.00971, -0.00035, 0.01173, -0.01979, 0.02054, -0.01240, -0.00273, 0.01960, -0.03122, 0.03124, -0.01669, -0.01017, 0.04137, -0.06448, 0.06476, -0.02634, -0.07449, 0.33571, -0.00000, -0.33571, 0.07449, 0.02634, -0.06476, 0.06448, -0.04137, 0.01017, 0.01669, -0.03124, 0.03122, -0.01960, 0.00273, 0.01240, -0.02054, 0.01979, -0.01173, 0.00035, 0.00971, -0.01490, 0.01396, -0.00800, -0.00016, 0.00731, -0.01103, 0.01052, -0.00663, 0.00136, 0.00309, -0.00504, 0.00266
        ), (1 , ), False)
        self.fir_filter_xxx_0_0 = filter.fir_filter_ccf(4, (1,1,1,1))
        self.fir_filter_xxx_0_0.declare_sample_delay(0)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_multiply_xx_1_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((right_gain, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((left_gain, ))
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/Users/bretttt/iCloud_drive/16S/engs110/project/radio_dat/IQ_Data_STEREO1", True)
        self.blocks_divide_xx_1 = blocks.divide_cc(1)
        self.blocks_delay_2 = blocks.delay(gr.sizeof_gr_complex*1, 30)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vcc((0.1, ))
        self.baseband_LPF = filter.fir_filter_fff(smux_decim, firdes.low_pass(
        	1, smux_filt_samprate, 15e3, 500, firdes.WIN_KAISER, 6.76))
        self.band_pass_filter_0_0_0 = filter.fir_filter_fcc(1, firdes.complex_band_pass(
        	1, smux_filt_samprate, 18000, 20000, 1000, firdes.WIN_KAISER, 1))
        self.band_pass_filter_0 = filter.fir_filter_fff(1, firdes.band_pass(
        	1, smux_filt_samprate, bpf_base, bpf_base+30e3, 500, firdes.WIN_KAISER, 6.76))
        self.audio_sink_0_0_0_0 = audio.sink(32000, "", True)
        self.analog_pll_refout_cc_0_0 = analog.pll_refout_cc(3.14/100, 0.152*3.14, 0.144*3.14)
        self.analog_fm_deemph_0_0 = analog.fm_deemph(fs=samp_rate/8, tau=75e-6)
        self.analog_fm_deemph_0 = analog.fm_deemph(fs=samp_rate/8, tau=75e-6)
        self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0)
        _CF_sizer = wx.BoxSizer(wx.VERTICAL)
        self._CF_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_CF_sizer,
        	value=self.CF,
        	callback=self.set_CF,
        	label="Center Frequency",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._CF_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_CF_sizer,
        	value=self.CF,
        	callback=self.set_CF,
        	minimum=80e6,
        	maximum=108e6,
        	num_steps=280,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_CF_sizer, 3, 0, 1, 2)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1))    
        self.connect((self.analog_fm_deemph_0, 0), (self.audio_sink_0_0_0_0, 0))    
        self.connect((self.analog_fm_deemph_0_0, 0), (self.audio_sink_0_0_0_0, 1))    
        self.connect((self.analog_pll_refout_cc_0_0, 0), (self.blocks_multiply_xx_1_0, 0))    
        self.connect((self.analog_pll_refout_cc_0_0, 0), (self.blocks_multiply_xx_1_0, 1))    
        self.connect((self.band_pass_filter_0, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.band_pass_filter_0_0_0, 0), (self.analog_pll_refout_cc_0_0, 0))    
        self.connect((self.baseband_LPF, 0), (self.blocks_add_xx_0, 0))    
        self.connect((self.baseband_LPF, 0), (self.blocks_sub_xx_0, 0))    
        self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_divide_xx_1, 1))    
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_complex_to_imag_0, 0), (self.band_pass_filter_0, 0))    
        self.connect((self.blocks_complex_to_imag_0, 0), (self.band_pass_filter_0_0_0, 0))    
        self.connect((self.blocks_complex_to_imag_0, 0), (self.baseband_LPF, 0))    
        self.connect((self.blocks_complex_to_imag_0, 0), (self.wxgui_fftsink2_0_0_0, 0))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_float_to_complex_0, 0))    
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.blocks_delay_2, 0), (self.blocks_multiply_conjugate_cc_0, 1))    
        self.connect((self.blocks_divide_xx_1, 0), (self.blocks_delay_2, 0))    
        self.connect((self.blocks_divide_xx_1, 0), (self.iir_filter_xxx_0, 0))    
        self.connect((self.blocks_file_source_0_0, 0), (self.rfgain, 0))    
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_add_const_vxx_0, 0))    
        self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_imag_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_fm_deemph_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_scopesink2_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.analog_fm_deemph_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.wxgui_fftsink2_0_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.wxgui_scopesink2_0, 1))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_1_0, 0))    
        self.connect((self.blocks_multiply_xx_1_0, 0), (self.blocks_complex_to_real_0, 0))    
        self.connect((self.blocks_sub_xx_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.fir_filter_xxx_0_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_waterfallsink2_0, 0))    
        self.connect((self.fir_filter_xxx_0_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.iir_filter_xxx_0, 0), (self.blocks_multiply_conjugate_cc_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.blocks_divide_xx_1, 0))    
        self.connect((self.low_pass_filter_1_0, 0), (self.blocks_add_xx_0, 1))    
        self.connect((self.low_pass_filter_1_0, 0), (self.blocks_sub_xx_0, 1))    
        self.connect((self.rfgain, 0), (self.blocks_throttle_0, 0))    
Beispiel #7
0
    def __init__(self, rf_params, bb_params):
        gr.hier_block2.__init__(
            self,
            "RX Demod Block",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),  # single in
            gr.io_signature(1, 1, gr.sizeof_char * 1)  # single out
        )

        ##################################################
        # Parameters
        ##################################################
        # ADD VALIDITY CHECKS TO EACH OF THESE
        self.agc_enable = rf_params.agc_enable
        if self.agc_enable:
            self.threshold = 0.5
        else:
            self.threshold = rf_params.threshold
        self.symbol_time = bb_params.symbol_time

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

        ##################################################
        # Blocks
        ##################################################
        if self.agc_enable:
            # the following blocks provide the AGC
            self.blocks_rms_xx_0 = blocks.rms_cf(self.symbol_time / 10)
            self.connect((self, 0), (self.blocks_rms_xx_0, 0))

            self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, ))
            self.connect((self.blocks_rms_xx_0, 0),
                         (self.blocks_multiply_const_vxx_0, 0))

            self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
            self.connect((self.blocks_multiply_const_vxx_0, 0),
                         (self.blocks_float_to_complex_0, 0))

            self.blocks_divide_xx_0 = blocks.divide_cc(1)
            self.connect((self, 0), (self.blocks_divide_xx_0, 0))
            self.connect((self.blocks_float_to_complex_0, 0),
                         (self.blocks_divide_xx_0, 1))

        # demodulation and cleanup
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        if self.agc_enable:
            # get input from agc output
            self.connect((self.blocks_divide_xx_0, 0),
                         (self.blocks_complex_to_mag_0, 0))
        else:
            # connect input directly to input
            self.connect((self, 0), (self.blocks_complex_to_mag_0))

        self.blocks_add_const_vxx_0 = blocks.add_const_vff(
            (-1 * self.threshold, ))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_add_const_vxx_0, 0))

        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))

        # output from block
        self.connect((self.digital_binary_slicer_fb_0, 0), (self, 0))
Beispiel #8
0
    def __init__(self, freq=0, gain=40, loopbw=100, loopbw_0=100, fllbw=0.002):
        gr.top_block.__init__(self, "Rx Gui")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Rx Gui")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Parameters
        ##################################################
        self.freq = freq
        self.gain = gain
        self.loopbw = loopbw
        self.loopbw_0 = loopbw_0
        self.fllbw = fllbw

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 8
        self.excess_bw = excess_bw = 0.25
        self.target_samp_rate = target_samp_rate = sps*(200e3/(1 + excess_bw))
        
        self.qpsk_const = qpsk_const = digital.constellation_qpsk().base()
        
        self.dsp_rate = dsp_rate = 100e6
        self.const_choice = const_choice = "qpsk"
        
        self.bpsk_const = bpsk_const = digital.constellation_bpsk().base()
        
        self.barker_code_two_dim = barker_code_two_dim = [-1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j,  1.0000 + 1.0000j,  1.0000 + 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j,  1.0000 + 1.0000j, -1.0000 - 1.0000j,  1.0000 + 1.0000j, -1.0000 - 1.0000j]
        self.barker_code_one_dim = barker_code_one_dim = sqrt(2)*numpy.real([-1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j,  1.0000 + 1.0000j,  1.0000 + 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j,  1.0000 + 1.0000j, -1.0000 - 1.0000j,  1.0000 + 1.0000j, -1.0000 - 1.0000j])
        self.rrc_delay = rrc_delay = int(round(-44*excess_bw + 33))
        self.nfilts = nfilts = 32
        self.n_barker_rep = n_barker_rep = 10
        self.dec_factor = dec_factor = ceil(dsp_rate/target_samp_rate)
        self.constellation = constellation = qpsk_const if (const_choice=="qpsk") else bpsk_const
        self.barker_code = barker_code = barker_code_two_dim if (const_choice == "qpsk") else barker_code_one_dim
        self.preamble_syms = preamble_syms = numpy.matlib.repmat(barker_code, 1, n_barker_rep)[0]
        self.n_rrc_taps = n_rrc_taps = rrc_delay * int(sps*nfilts)
        self.n_codewords = n_codewords = 1
        self.even_dec_factor = even_dec_factor = dec_factor if (dec_factor % 1 == 1) else (dec_factor+1)
        self.const_order = const_order = pow(2,constellation.bits_per_symbol())
        self.codeword_len = codeword_len = 18444
        self.usrp_rx_addr = usrp_rx_addr = "192.168.10.2"
        self.samp_rate = samp_rate = dsp_rate/even_dec_factor
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts*sps, 1.0, excess_bw, n_rrc_taps)
        self.rf_center_freq = rf_center_freq = 1428.4309e6
        self.preamble_size = preamble_size = len(preamble_syms)
        self.pmf_peak_threshold = pmf_peak_threshold = 0.6
        self.payload_size = payload_size = codeword_len*n_codewords/int(numpy.log2(const_order))
        self.dataword_len = dataword_len = 6144
        self.barker_len = barker_len = 13

        ##################################################
        # Blocks
        ##################################################
        self.tabs = Qt.QTabWidget()
        self.tabs_widget_0 = Qt.QWidget()
        self.tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_0)
        self.tabs_grid_layout_0 = Qt.QGridLayout()
        self.tabs_layout_0.addLayout(self.tabs_grid_layout_0)
        self.tabs.addTab(self.tabs_widget_0, 'PMF Out')
        self.tabs_widget_1 = Qt.QWidget()
        self.tabs_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_1)
        self.tabs_grid_layout_1 = Qt.QGridLayout()
        self.tabs_layout_1.addLayout(self.tabs_grid_layout_1)
        self.tabs.addTab(self.tabs_widget_1, 'Abs PMF Out')
        self.tabs_widget_2 = Qt.QWidget()
        self.tabs_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_2)
        self.tabs_grid_layout_2 = Qt.QGridLayout()
        self.tabs_layout_2.addLayout(self.tabs_grid_layout_2)
        self.tabs.addTab(self.tabs_widget_2, 'FLL In')
        self.tabs_widget_3 = Qt.QWidget()
        self.tabs_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_3)
        self.tabs_grid_layout_3 = Qt.QGridLayout()
        self.tabs_layout_3.addLayout(self.tabs_grid_layout_3)
        self.tabs.addTab(self.tabs_widget_3, 'FLL Out')
        self.tabs_widget_4 = Qt.QWidget()
        self.tabs_layout_4 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_4)
        self.tabs_grid_layout_4 = Qt.QGridLayout()
        self.tabs_layout_4.addLayout(self.tabs_grid_layout_4)
        self.tabs.addTab(self.tabs_widget_4, 'FLL State')
        self.tabs_widget_5 = Qt.QWidget()
        self.tabs_layout_5 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_5)
        self.tabs_grid_layout_5 = Qt.QGridLayout()
        self.tabs_layout_5.addLayout(self.tabs_grid_layout_5)
        self.tabs.addTab(self.tabs_widget_5, 'PFB Sync Out')
        self.tabs_widget_6 = Qt.QWidget()
        self.tabs_layout_6 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_6)
        self.tabs_grid_layout_6 = Qt.QGridLayout()
        self.tabs_layout_6.addLayout(self.tabs_grid_layout_6)
        self.tabs.addTab(self.tabs_widget_6, 'Costas State')
        self.tabs_widget_7 = Qt.QWidget()
        self.tabs_layout_7 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_7)
        self.tabs_grid_layout_7 = Qt.QGridLayout()
        self.tabs_layout_7.addLayout(self.tabs_grid_layout_7)
        self.tabs.addTab(self.tabs_widget_7, 'Demod Bits')
        self.tabs_widget_8 = Qt.QWidget()
        self.tabs_layout_8 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_8)
        self.tabs_grid_layout_8 = Qt.QGridLayout()
        self.tabs_layout_8.addLayout(self.tabs_grid_layout_8)
        self.tabs.addTab(self.tabs_widget_8, 'Costas  Sym Out')
        self.tabs_widget_9 = Qt.QWidget()
        self.tabs_layout_9 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_9)
        self.tabs_grid_layout_9 = Qt.QGridLayout()
        self.tabs_layout_9.addLayout(self.tabs_grid_layout_9)
        self.tabs.addTab(self.tabs_widget_9, 'Payload Symbols')
        self.top_layout.addWidget(self.tabs)
        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(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(0, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(gain, 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(0, 0)
          
        self.qtgui_time_sink_x_2 = qtgui.time_sink_c(
        	preamble_size + payload_size, #size
        	samp_rate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_2.set_update_time(0.10)
        self.qtgui_time_sink_x_2.set_y_axis(-1, 1)
        
        self.qtgui_time_sink_x_2.set_y_label('Amplitude', "")
        
        self.qtgui_time_sink_x_2.enable_tags(-1, True)
        self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_2.enable_autoscale(True)
        self.qtgui_time_sink_x_2.enable_grid(False)
        self.qtgui_time_sink_x_2.enable_axis_labels(True)
        self.qtgui_time_sink_x_2.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_2.disable_legend()
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(2*1):
            if len(labels[i]) == 0:
                if(i % 2 == 0):
                    self.qtgui_time_sink_x_2.set_line_label(i, "Re{{Data {0}}}".format(i/2))
                else:
                    self.qtgui_time_sink_x_2.set_line_label(i, "Im{{Data {0}}}".format(i/2))
            else:
                self.qtgui_time_sink_x_2.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_2.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_2.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_2.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_2.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_2_win = sip.wrapinstance(self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget)
        self.tabs_layout_0.addWidget(self._qtgui_time_sink_x_2_win)
        self.qtgui_time_sink_x_1_0_0 = qtgui.time_sink_f(
        	1024, #size
        	samp_rate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_1_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0_0.set_y_axis(-128, 128)
        
        self.qtgui_time_sink_x_1_0_0.set_y_label('Amplitude', "")
        
        self.qtgui_time_sink_x_1_0_0.enable_tags(-1, False)
        self.qtgui_time_sink_x_1_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_1_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_1_0_0.enable_grid(False)
        self.qtgui_time_sink_x_1_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_1_0_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_1_0_0.disable_legend()
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_0_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_1_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0_0.pyqwidget(), Qt.QWidget)
        self.tabs_layout_7.addWidget(self._qtgui_time_sink_x_1_0_0_win)
        self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f(
        	1024, #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, 1)
        
        self.qtgui_time_sink_x_1_0.set_y_label('Amplitude', "")
        
        self.qtgui_time_sink_x_1_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_1_0.enable_autoscale(False)
        self.qtgui_time_sink_x_1_0.enable_grid(False)
        self.qtgui_time_sink_x_1_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_1_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_1_0.disable_legend()
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.tabs_layout_7.addWidget(self._qtgui_time_sink_x_1_0_win)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
        	8192, #size
        	samp_rate, #samp_rate
        	"", #name
        	3 #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-1, 1)
        
        self.qtgui_time_sink_x_1.set_y_label('Amplitude', "")
        
        self.qtgui_time_sink_x_1.enable_tags(-1, True)
        self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_1.enable_autoscale(False)
        self.qtgui_time_sink_x_1.enable_grid(False)
        self.qtgui_time_sink_x_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_1.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_1.disable_legend()
        
        labels = ['FLL Freq (PI Output)', 'FLL Phase Accum', 'FLL Error', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(3):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.tabs_layout_4.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_time_sink_x_0_3 = qtgui.time_sink_f(
        	1024*4, #size
        	samp_rate, #samp_rate
        	"Error", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0_3.set_update_time(0.10)
        self.qtgui_time_sink_x_0_3.set_y_axis(-1, 1)
        
        self.qtgui_time_sink_x_0_3.set_y_label('Amplitude', "")
        
        self.qtgui_time_sink_x_0_3.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_3.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0_3.enable_autoscale(False)
        self.qtgui_time_sink_x_0_3.enable_grid(False)
        self.qtgui_time_sink_x_0_3.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_3.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_0_3.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_3.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_3.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_3.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_3.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_3.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_3.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_3.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_3_win = sip.wrapinstance(self.qtgui_time_sink_x_0_3.pyqwidget(), Qt.QWidget)
        self.tabs_layout_6.addWidget(self._qtgui_time_sink_x_0_3_win)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
        	preamble_size + payload_size, #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)
        self.qtgui_time_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_0_0.disable_legend()
        
        labels = ['Mag Sq', 'Mag', '', '', '',
                  '', '', '', '', '']
        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.tabs_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win)
        self.qtgui_sink_x_5 = qtgui.sink_c(
        	1024, #fftsize
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"", #name
        	True, #plotfreq
        	False, #plotwaterfall
        	False, #plottime
        	True, #plotconst
        )
        self.qtgui_sink_x_5.set_update_time(1.0/10)
        self._qtgui_sink_x_5_win = sip.wrapinstance(self.qtgui_sink_x_5.pyqwidget(), Qt.QWidget)
        self.tabs_layout_3.addWidget(self._qtgui_sink_x_5_win)
        
        self.qtgui_sink_x_5.enable_rf_freq(False)
        
        
          
        self.qtgui_sink_x_1 = qtgui.sink_c(
        	1024, #fftsize
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"", #name
        	True, #plotfreq
        	False, #plotwaterfall
        	False, #plottime
        	True, #plotconst
        )
        self.qtgui_sink_x_1.set_update_time(1.0/10)
        self._qtgui_sink_x_1_win = sip.wrapinstance(self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget)
        self.tabs_layout_2.addWidget(self._qtgui_sink_x_1_win)
        
        self.qtgui_sink_x_1.enable_rf_freq(False)
        
        
          
        self.qtgui_sink_x_0 = qtgui.sink_c(
        	1024, #fftsize
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"", #name
        	False, #plotfreq
        	False, #plotwaterfall
        	False, #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.tabs_layout_5.addWidget(self._qtgui_sink_x_0_win)
        
        self.qtgui_sink_x_0.enable_rf_freq(False)
        
        
          
        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_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.tabs_layout_2.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(-2, 2)
        self.qtgui_const_sink_x_1.set_x_axis(-2, 2)
        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)
        
        if not True:
          self.qtgui_const_sink_x_1.disable_legend()
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "red", "red", "red",
                  "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
                   0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_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.tabs_layout_9.addWidget(self._qtgui_const_sink_x_1_win)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
        	1024, #size
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)
        
        if not True:
          self.qtgui_const_sink_x_0.disable_legend()
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "red", "red", "red",
                  "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
                   0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tabs_layout_8.addWidget(self._qtgui_const_sink_x_0_win)
        self.mods_turbo_decoder_0 = mods.turbo_decoder(codeword_len, dataword_len)
        self.mods_frame_sync_fast_0 = mods.frame_sync_fast(pmf_peak_threshold, preamble_size, payload_size, 0, 1, 1, int(const_order))
        self.mods_fifo_async_sink_0 = mods.fifo_async_sink('/tmp/async_rx')
        self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_fff(1, ( numpy.ones(n_barker_rep*barker_len)))
        self.interp_fir_filter_xxx_0_0.declare_sample_delay(0)
        self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(1, ( numpy.flipud(numpy.conj(preamble_syms))))
        self.interp_fir_filter_xxx_0.declare_sample_delay(0)
        self.framers_gr_hdlc_deframer_b_0 = framers.gr_hdlc_deframer_b(0)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 2*pi/50, (rrc_taps), nfilts, nfilts/2, pi/8, 1)
        self.digital_map_bb_0_0_0 = digital.map_bb(([1,- 1]))
        self.digital_fll_band_edge_cc_1 = digital.fll_band_edge_cc(sps, excess_bw, rrc_delay * int(sps) + 1, fllbw)
        self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x7F, 16)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(2*pi/loopbw, 2**constellation.bits_per_symbol(), False)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constellation.base())
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(constellation.bits_per_symbol())
        self.blocks_rms_xx_1 = blocks.rms_cf(0.0001)
        self.blocks_pack_k_bits_bb_1 = blocks.pack_k_bits_bb(8)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_1_1 = blocks.multiply_const_vcc((1.0/sqrt(2), ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((1.0/(preamble_size*sqrt(2)), ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_divide_xx_1 = blocks.divide_ff(1)
        self.blocks_divide_xx_0 = blocks.divide_cc(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1)
        self.blocks_char_to_float_0_1 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.framers_gr_hdlc_deframer_b_0, 'pdu'), (self.mods_fifo_async_sink_0, 'async_pdu'))    
        self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_1_0, 0))    
        self.connect((self.blocks_char_to_float_0_1, 0), (self.qtgui_time_sink_x_1_0_0, 0))    
        self.connect((self.blocks_complex_to_mag_1, 0), (self.blocks_divide_xx_1, 0))    
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.interp_fir_filter_xxx_0_0, 0))    
        self.connect((self.blocks_divide_xx_0, 0), (self.digital_fll_band_edge_cc_1, 0))    
        self.connect((self.blocks_divide_xx_0, 0), (self.qtgui_sink_x_1, 0))    
        self.connect((self.blocks_divide_xx_1, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.blocks_divide_xx_1, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_divide_xx_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.mods_frame_sync_fast_0, 2))    
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_time_sink_x_2, 0))    
        self.connect((self.blocks_multiply_const_vxx_1_1, 0), (self.blocks_complex_to_mag_1, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.mods_frame_sync_fast_0, 1))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_time_sink_x_0_0, 0))    
        self.connect((self.blocks_pack_k_bits_bb_1, 0), (self.blocks_char_to_float_0_1, 0))    
        self.connect((self.blocks_rms_xx_1, 0), (self.blocks_float_to_complex_0, 0))    
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.digital_map_bb_0_0_0, 0))    
        self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))    
        self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self.digital_costas_loop_cc_0, 0), (self.interp_fir_filter_xxx_0, 0))    
        self.connect((self.digital_costas_loop_cc_0, 0), (self.mods_frame_sync_fast_0, 0))    
        self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0))    
        self.connect((self.digital_costas_loop_cc_0, 1), (self.qtgui_time_sink_x_0_3, 0))    
        self.connect((self.digital_descrambler_bb_0, 0), (self.blocks_char_to_float_0_0, 0))    
        self.connect((self.digital_descrambler_bb_0, 0), (self.blocks_pack_k_bits_bb_1, 0))    
        self.connect((self.digital_descrambler_bb_0, 0), (self.framers_gr_hdlc_deframer_b_0, 0))    
        self.connect((self.digital_fll_band_edge_cc_1, 0), (self.digital_pfb_clock_sync_xxx_0, 0))    
        self.connect((self.digital_fll_band_edge_cc_1, 0), (self.qtgui_sink_x_5, 0))    
        self.connect((self.digital_fll_band_edge_cc_1, 3), (self.qtgui_time_sink_x_1, 2))    
        self.connect((self.digital_fll_band_edge_cc_1, 1), (self.qtgui_time_sink_x_1, 0))    
        self.connect((self.digital_fll_band_edge_cc_1, 2), (self.qtgui_time_sink_x_1, 1))    
        self.connect((self.digital_map_bb_0_0_0, 0), (self.mods_turbo_decoder_0, 0))    
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0))    
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_sink_x_0, 0))    
        self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_1, 0))    
        self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_1_1, 0))    
        self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_divide_xx_1, 1))    
        self.connect((self.mods_frame_sync_fast_0, 0), (self.digital_constellation_decoder_cb_0, 0))    
        self.connect((self.mods_frame_sync_fast_0, 0), (self.qtgui_const_sink_x_1, 0))    
        self.connect((self.mods_turbo_decoder_0, 0), (self.digital_descrambler_bb_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_divide_xx_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_rms_xx_1, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))    
Beispiel #9
0
    def __init__(self, freq=0, gain=0, loopbw=100, fllbw=0.002):
        gr.top_block.__init__(self, "Rx")

        ##################################################
        # Parameters
        ##################################################
        self.freq = freq
        self.gain = gain
        self.loopbw = loopbw
        self.fllbw = fllbw

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 8
        self.excess_bw = excess_bw = 0.25
        self.target_samp_rate = target_samp_rate = sps*(200e3/(1 + excess_bw))
        
        self.qpsk_const = qpsk_const = digital.constellation_qpsk().base()
        
        self.dsp_rate = dsp_rate = 100e6
        self.const_choice = const_choice = "qpsk"
        
        self.bpsk_const = bpsk_const = digital.constellation_bpsk().base()
        
        self.barker_code_two_dim = barker_code_two_dim = [-1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j,  1.0000 + 1.0000j,  1.0000 + 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j,  1.0000 + 1.0000j, -1.0000 - 1.0000j,  1.0000 + 1.0000j, -1.0000 - 1.0000j]
        self.barker_code_one_dim = barker_code_one_dim = sqrt(2)*numpy.real([-1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j,  1.0000 + 1.0000j,  1.0000 + 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j,  1.0000 + 1.0000j, -1.0000 - 1.0000j,  1.0000 + 1.0000j, -1.0000 - 1.0000j])
        self.rrc_delay = rrc_delay = int(round(-44*excess_bw + 33))
        self.nfilts = nfilts = 32
        self.n_barker_rep = n_barker_rep = 10
        self.dec_factor = dec_factor = ceil(dsp_rate/target_samp_rate)
        self.constellation = constellation = qpsk_const if (const_choice=="qpsk") else bpsk_const
        self.barker_code = barker_code = barker_code_two_dim if (const_choice == "qpsk") else barker_code_one_dim
        self.preamble_syms = preamble_syms = numpy.matlib.repmat(barker_code, 1, n_barker_rep)[0]
        self.n_rrc_taps = n_rrc_taps = rrc_delay * int(sps*nfilts)
        self.n_codewords = n_codewords = 1
        self.even_dec_factor = even_dec_factor = dec_factor if (dec_factor % 1 == 1) else (dec_factor+1)
        self.const_order = const_order = pow(2,constellation.bits_per_symbol())
        self.codeword_len = codeword_len = 18444
        self.usrp_rx_addr = usrp_rx_addr = "192.168.10.2"
        self.samp_rate = samp_rate = dsp_rate/even_dec_factor
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts*sps, 1.0, excess_bw, n_rrc_taps)
        self.rf_center_freq = rf_center_freq = 1428.4309e6
        self.preamble_size = preamble_size = len(preamble_syms)
        self.pmf_peak_threshold = pmf_peak_threshold = 0.6
        self.payload_size = payload_size = codeword_len*n_codewords/int(numpy.log2(const_order))
        self.dataword_len = dataword_len = 6144
        self.barker_len = barker_len = 13

        ##################################################
        # 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(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(0, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(gain, 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(0, 0)
          
        self.mods_turbo_decoder_0 = mods.turbo_decoder(codeword_len, dataword_len)
        self.mods_frame_sync_fast_0 = mods.frame_sync_fast(pmf_peak_threshold, preamble_size, payload_size, 0, 1, 1, int(const_order))
        self.mods_fifo_async_sink_0 = mods.fifo_async_sink('/tmp/async_rx')
        self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_fff(1, ( numpy.ones(n_barker_rep*barker_len)))
        self.interp_fir_filter_xxx_0_0.declare_sample_delay(0)
        self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(1, ( numpy.flipud(numpy.conj(preamble_syms))))
        self.interp_fir_filter_xxx_0.declare_sample_delay(0)
        self.framers_gr_hdlc_deframer_b_0 = framers.gr_hdlc_deframer_b(0)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 2*pi/50, (rrc_taps), nfilts, nfilts/2, pi/8, 1)
        self.digital_map_bb_0_0_0 = digital.map_bb(([1,- 1]))
        self.digital_fll_band_edge_cc_1 = digital.fll_band_edge_cc(sps, excess_bw, rrc_delay * int(sps) + 1, fllbw)
        self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x7F, 16)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(2*pi/loopbw, 2**constellation.bits_per_symbol(), False)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constellation.base())
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(constellation.bits_per_symbol())
        self.blocks_rms_xx_1 = blocks.rms_cf(0.0001)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_1_1 = blocks.multiply_const_vcc((1.0/sqrt(2), ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((1.0/(preamble_size*sqrt(2)), ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_divide_xx_1 = blocks.divide_ff(1)
        self.blocks_divide_xx_0 = blocks.divide_cc(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.framers_gr_hdlc_deframer_b_0, 'pdu'), (self.mods_fifo_async_sink_0, 'async_pdu'))    
        self.connect((self.blocks_complex_to_mag_1, 0), (self.blocks_divide_xx_1, 0))    
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.interp_fir_filter_xxx_0_0, 0))    
        self.connect((self.blocks_divide_xx_0, 0), (self.digital_fll_band_edge_cc_1, 0))    
        self.connect((self.blocks_divide_xx_1, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.blocks_divide_xx_1, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_divide_xx_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.mods_frame_sync_fast_0, 2))    
        self.connect((self.blocks_multiply_const_vxx_1_1, 0), (self.blocks_complex_to_mag_1, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.mods_frame_sync_fast_0, 1))    
        self.connect((self.blocks_rms_xx_1, 0), (self.blocks_float_to_complex_0, 0))    
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.digital_map_bb_0_0_0, 0))    
        self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))    
        self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self.digital_costas_loop_cc_0, 0), (self.interp_fir_filter_xxx_0, 0))    
        self.connect((self.digital_costas_loop_cc_0, 0), (self.mods_frame_sync_fast_0, 0))    
        self.connect((self.digital_descrambler_bb_0, 0), (self.framers_gr_hdlc_deframer_b_0, 0))    
        self.connect((self.digital_fll_band_edge_cc_1, 0), (self.digital_pfb_clock_sync_xxx_0, 0))    
        self.connect((self.digital_map_bb_0_0_0, 0), (self.mods_turbo_decoder_0, 0))    
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0))    
        self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_1, 0))    
        self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_1_1, 0))    
        self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_divide_xx_1, 1))    
        self.connect((self.mods_frame_sync_fast_0, 0), (self.digital_constellation_decoder_cb_0, 0))    
        self.connect((self.mods_turbo_decoder_0, 0), (self.digital_descrambler_bb_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_divide_xx_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_rms_xx_1, 0))    
Beispiel #10
0
    def __init__(self):
        gr.top_block.__init__(self, "FID Sequence")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("FID Sequence")
        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", "fid_grc_1")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.slave_delay = slave_delay = 0
        self.samp_rate = samp_rate = 250000
        self.readout_delay = readout_delay = 0
        self.offset = offset = 0
        self.master_delay = master_delay = 0
        self.ex_delay = ex_delay = 0
        self.TR_clock = TR_clock = 0
        self.TR = TR = 1
        self.RUN = RUN = 1
        self.CF = CF = 21.3e6

        ##################################################
        # Blocks
        ##################################################
        self._TR_tool_bar = Qt.QToolBar(self)
        self._TR_tool_bar.addWidget(Qt.QLabel("TR" + ": "))
        self._TR_line_edit = Qt.QLineEdit(str(self.TR))
        self._TR_tool_bar.addWidget(self._TR_line_edit)
        self._TR_line_edit.returnPressed.connect(
            lambda: self.set_TR(int(str(self._TR_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._TR_tool_bar)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("serial = DR31R6U1", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(2),
            ),
        )
        self.uhd_usrp_source_0.set_subdev_spec("A:B A:A", 0)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(CF + offset, 0)
        self.uhd_usrp_source_0.set_gain(15, 0)
        self.uhd_usrp_source_0.set_antenna("A:B", 0)
        self.uhd_usrp_source_0.set_center_freq(CF + offset, 1)
        self.uhd_usrp_source_0.set_gain(10, 1)
        self.uhd_usrp_source_0.set_antenna("A:A", 1)
        self.signal_out = MRI.gated_vector_sink()
        self.rf_sink = uhd.usrp_sink(
            ",".join(("serial = DR31R6U1", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(2),
            ),
        )
        self.rf_sink.set_subdev_spec("A:AB B:A", 0)
        self.rf_sink.set_samp_rate(samp_rate)
        self.rf_sink.set_center_freq(CF + offset, 0)
        self.rf_sink.set_gain(0, 0)
        self.rf_sink.set_antenna("A:A", 0)
        self.rf_sink.set_center_freq(0, 1)
        self.rf_sink.set_gain(0, 1)
        self.rf_sink.set_antenna("A:B", 1)
        self.readwin = MRI.triggered_vector_source_f([0, 0, 0], 1.0, 0.0, 1, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            int(.00315 * samp_rate),  #size
            samp_rate,  #samp_rate
            "",  #name
            4  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-.25, .25)

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

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_AUTO,
                                                  qtgui.TRIG_SLOPE_POS, .01, 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 = [
            "Read Window", "Real Signal", "Imag Signal", "RMS", "", "", "", "",
            "", ""
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "black", "blue", "red", "green", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [2, 1, 1, 2, 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(4):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.m_delay = blocks.delay(gr.sizeof_gr_complex * 1,
                                    int(master_delay))
        self.ex_pulse = MRI.triggered_vector_source([0, 0, 0], 1.0, 0.0, 1, 1)
        self.delay3 = blocks.delay(gr.sizeof_float * 1, readout_delay)
        self.delay1 = blocks.delay(gr.sizeof_float * 1, ex_delay)
        self.blocks_threshold_ff_0_2 = blocks.threshold_ff(.000001, .000001, 0)
        self.blocks_threshold_ff_0_1 = blocks.threshold_ff(.05, .05, 0)
        self.blocks_rms_xx_1 = blocks.rms_cf(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((RUN, ))
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(10, 1, 4000)
        self.blocks_float_to_complex_0_1_0 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0_1 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_divide_xx_0 = blocks.divide_cc(1)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, 5)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 5)
        self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(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.analog_sig_source_x_0_0 = analog.sig_source_f(
            samp_rate, analog.GR_SQR_WAVE, 1. / TR, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.qtgui_time_sink_x_0, 2))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_complex_to_float_0_0, 0),
                     (self.blocks_float_to_complex_0_1, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_threshold_ff_0_1, 0))
        self.connect((self.blocks_complex_to_mag_1, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_complex_to_float_0_0, 0))
        self.connect((self.blocks_delay_0_0, 0), (self.rf_sink, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.blocks_multiply_conjugate_cc_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_float_to_complex_0_1, 0),
                     (self.blocks_delay_0_0, 0))
        self.connect((self.blocks_float_to_complex_0_1_0, 0),
                     (self.m_delay, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_threshold_ff_0_2, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0),
                     (self.blocks_rms_xx_1, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0),
                     (self.signal_out, 1))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.delay1, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.delay3, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_rms_xx_1, 0), (self.qtgui_time_sink_x_0, 3))
        self.connect((self.blocks_threshold_ff_0_1, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_threshold_ff_0_1, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_threshold_ff_0_1, 0), (self.signal_out, 0))
        self.connect((self.blocks_threshold_ff_0_2, 0),
                     (self.blocks_float_to_complex_0_1_0, 0))
        self.connect((self.delay1, 0), (self.ex_pulse, 0))
        self.connect((self.delay3, 0), (self.readwin, 0))
        self.connect((self.ex_pulse, 0), (self.blocks_complex_to_mag_1, 0))
        self.connect((self.ex_pulse, 0), (self.blocks_delay_0, 0))
        self.connect((self.m_delay, 0), (self.rf_sink, 1))
        self.connect((self.readwin, 0), (self.blocks_float_to_complex_0_1, 1))
        self.connect((self.uhd_usrp_source_0, 1),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.uhd_usrp_source_0, 1), (self.blocks_divide_xx_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.blocks_multiply_conjugate_cc_0, 0))
Beispiel #11
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self.mynotebook = self.mynotebook = wx.Notebook(self.GetWin(),
                                                        style=wx.NB_TOP)
        self.mynotebook.AddPage(grc_wxgui.Panel(self.mynotebook), "FFT")
        self.mynotebook.AddPage(grc_wxgui.Panel(self.mynotebook), "ScopeSink")
        self.Add(self.mynotebook)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.mynotebook.GetPage(0).GetWin(),
            title='Scope Plot',
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.mynotebook.GetPage(0).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_f(
            self.mynotebook.GetPage(1).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='FFT Plot',
            peak_hold=False,
            win=window.hamming,
        )
        self.mynotebook.GetPage(1).Add(self.wxgui_fftsink2_0.win)
        self.hilbert_fc_0 = filter.hilbert_fc(500, firdes.WIN_HAMMING, 6.76)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
                                                 samp_rate, True)
        self.blocks_divide_xx_0 = blocks.divide_cc(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_sig_source_x_0_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_SIN_WAVE, 10000, 1, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(
            samp_rate, analog.GR_TRI_WAVE, 500, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0_0, 0), (self.hilbert_fc_0, 0))
        self.connect((self.analog_sig_source_x_0_0_0, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.hilbert_fc_0, 0), (self.blocks_divide_xx_0, 0))
Beispiel #12
0
    def __init__(self, freq=0, gain=0, loopbw=100, fllbw=0.002):
        gr.top_block.__init__(self, "Rx")

        ##################################################
        # Parameters
        ##################################################
        self.freq = freq
        self.gain = gain
        self.loopbw = loopbw
        self.fllbw = fllbw

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 8
        self.excess_bw = excess_bw = 0.25
        self.target_samp_rate = target_samp_rate = sps * (200e3 /
                                                          (1 + excess_bw))

        self.qpsk_const = qpsk_const = digital.constellation_qpsk().base()

        self.dsp_rate = dsp_rate = 100e6
        self.const_choice = const_choice = "qpsk"

        self.bpsk_const = bpsk_const = digital.constellation_bpsk().base()

        self.barker_code_two_dim = barker_code_two_dim = [
            -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j,
            -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j,
            1.0000 + 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j,
            1.0000 + 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j,
            -1.0000 - 1.0000j
        ]
        self.barker_code_one_dim = barker_code_one_dim = sqrt(2) * numpy.real([
            -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 -
            1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, 1.0000 + 1.0000j,
            -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j,
            -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j
        ])
        self.rrc_delay = rrc_delay = int(round(-44 * excess_bw + 33))
        self.nfilts = nfilts = 32
        self.n_barker_rep = n_barker_rep = 10
        self.dec_factor = dec_factor = ceil(dsp_rate / target_samp_rate)
        self.constellation = constellation = qpsk_const if (
            const_choice == "qpsk") else bpsk_const
        self.barker_code = barker_code = barker_code_two_dim if (
            const_choice == "qpsk") else barker_code_one_dim
        self.preamble_syms = preamble_syms = numpy.matlib.repmat(
            barker_code, 1, n_barker_rep)[0]
        self.n_rrc_taps = n_rrc_taps = rrc_delay * int(sps * nfilts)
        self.n_codewords = n_codewords = 1
        self.even_dec_factor = even_dec_factor = dec_factor if (
            dec_factor % 1 == 1) else (dec_factor + 1)
        self.const_order = const_order = pow(2,
                                             constellation.bits_per_symbol())
        self.codeword_len = codeword_len = 18444
        self.usrp_rx_addr = usrp_rx_addr = "192.168.10.2"
        self.samp_rate = samp_rate = dsp_rate / even_dec_factor
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts * sps, 1.0, excess_bw, n_rrc_taps)
        self.rf_center_freq = rf_center_freq = 1428.4309e6
        self.preamble_size = preamble_size = len(preamble_syms)
        self.pmf_peak_threshold = pmf_peak_threshold = 0.6
        self.payload_size = payload_size = codeword_len * n_codewords / int(
            numpy.log2(const_order))
        self.dataword_len = dataword_len = 6144
        self.barker_len = barker_len = 13

        ##################################################
        # 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(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(0, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(gain, 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(0, 0)

        self.mods_turbo_decoder_0 = mods.turbo_decoder(codeword_len,
                                                       dataword_len)
        self.mods_frame_sync_fast_0 = mods.frame_sync_fast(
            pmf_peak_threshold, preamble_size, payload_size, 0, 1, 1,
            int(const_order))
        self.mods_fifo_async_sink_0 = mods.fifo_async_sink('/tmp/async_rx')
        self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_fff(
            1, (numpy.ones(n_barker_rep * barker_len)))
        self.interp_fir_filter_xxx_0_0.declare_sample_delay(0)
        self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(
            1, (numpy.flipud(numpy.conj(preamble_syms))))
        self.interp_fir_filter_xxx_0.declare_sample_delay(0)
        self.framers_gr_hdlc_deframer_b_0 = framers.gr_hdlc_deframer_b(0)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, 2 * pi / 50, (rrc_taps), nfilts, nfilts / 2, pi / 8, 1)
        self.digital_map_bb_0_0_0 = digital.map_bb(([1, -1]))
        self.digital_fll_band_edge_cc_1 = digital.fll_band_edge_cc(
            sps, excess_bw,
            rrc_delay * int(sps) + 1, fllbw)
        self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x7F, 16)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            2 * pi / loopbw, 2**constellation.bits_per_symbol(), False)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            constellation.base())
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(
            constellation.bits_per_symbol())
        self.blocks_rms_xx_1 = blocks.rms_cf(0.0001)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_1_1 = blocks.multiply_const_vcc(
            (1.0 / sqrt(2), ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc(
            (1.0 / (preamble_size * sqrt(2)), ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_divide_xx_1 = blocks.divide_ff(1)
        self.blocks_divide_xx_0 = blocks.divide_cc(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.framers_gr_hdlc_deframer_b_0, 'pdu'),
                         (self.mods_fifo_async_sink_0, 'async_pdu'))
        self.connect((self.blocks_complex_to_mag_1, 0),
                     (self.blocks_divide_xx_1, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.interp_fir_filter_xxx_0_0, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.digital_fll_band_edge_cc_1, 0))
        self.connect((self.blocks_divide_xx_1, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_divide_xx_1, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.mods_frame_sync_fast_0, 2))
        self.connect((self.blocks_multiply_const_vxx_1_1, 0),
                     (self.blocks_complex_to_mag_1, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.mods_frame_sync_fast_0, 1))
        self.connect((self.blocks_rms_xx_1, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                     (self.digital_map_bb_0_0_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.interp_fir_filter_xxx_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.mods_frame_sync_fast_0, 0))
        self.connect((self.digital_descrambler_bb_0, 0),
                     (self.framers_gr_hdlc_deframer_b_0, 0))
        self.connect((self.digital_fll_band_edge_cc_1, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_map_bb_0_0_0, 0),
                     (self.mods_turbo_decoder_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.interp_fir_filter_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.interp_fir_filter_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_1_1, 0))
        self.connect((self.interp_fir_filter_xxx_0_0, 0),
                     (self.blocks_divide_xx_1, 1))
        self.connect((self.mods_frame_sync_fast_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.mods_turbo_decoder_0, 0),
                     (self.digital_descrambler_bb_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_divide_xx_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_rms_xx_1, 0))
Beispiel #13
0
    def __init__(self):
        gr.top_block.__init__(self, "Rx 5 Antenna Array: The Seer")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Rx 5 Antenna Array: The Seer")
        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", "the_seer_rx_flow")

        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 = 1024000
        self.fft_bins = fft_bins = 1024
        self.skip_bins = skip_bins = int(fft_bins / 2 +
                                         fft_bins / samp_rate) + 1
        self.k = k = -60.103
        self.head = head = 32000
        self.freq = freq = 750000000

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_number_sink_0_1_1_0_1 = qtgui.number_sink(
            gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1)
        self.qtgui_number_sink_0_1_1_0_1.set_update_time(0.10)
        self.qtgui_number_sink_0_1_1_0_1.set_title("Phase 4")

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

        self.qtgui_number_sink_0_1_1_0_1.enable_autoscale(False)
        self._qtgui_number_sink_0_1_1_0_1_win = sip.wrapinstance(
            self.qtgui_number_sink_0_1_1_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_1_1_0_1_win,
                                       4, 1, 1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_number_sink_0_1_1_0_0_0 = qtgui.number_sink(
            gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1)
        self.qtgui_number_sink_0_1_1_0_0_0.set_update_time(0.10)
        self.qtgui_number_sink_0_1_1_0_0_0.set_title("Pr_4")

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

        self.qtgui_number_sink_0_1_1_0_0_0.enable_autoscale(False)
        self._qtgui_number_sink_0_1_1_0_0_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0_1_1_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_1_1_0_0_0_win,
                                       4, 2, 1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_number_sink_0_1_1_0_0 = qtgui.number_sink(
            gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1)
        self.qtgui_number_sink_0_1_1_0_0.set_update_time(0.10)
        self.qtgui_number_sink_0_1_1_0_0.set_title("Pr_3")

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

        self.qtgui_number_sink_0_1_1_0_0.enable_autoscale(False)
        self._qtgui_number_sink_0_1_1_0_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0_1_1_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_1_1_0_0_win,
                                       3, 2, 1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_number_sink_0_1_1_0 = qtgui.number_sink(
            gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1)
        self.qtgui_number_sink_0_1_1_0.set_update_time(0.10)
        self.qtgui_number_sink_0_1_1_0.set_title("Phase 3")

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

        self.qtgui_number_sink_0_1_1_0.enable_autoscale(False)
        self._qtgui_number_sink_0_1_1_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0_1_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_1_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.qtgui_number_sink_0_1_1 = qtgui.number_sink(
            gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1)
        self.qtgui_number_sink_0_1_1.set_update_time(0.10)
        self.qtgui_number_sink_0_1_1.set_title("Pr_2")

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

        self.qtgui_number_sink_0_1_1.enable_autoscale(False)
        self._qtgui_number_sink_0_1_1_win = sip.wrapinstance(
            self.qtgui_number_sink_0_1_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_1_1_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_number_sink_0_1_0_1_0 = qtgui.number_sink(
            gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1)
        self.qtgui_number_sink_0_1_0_1_0.set_update_time(0.10)
        self.qtgui_number_sink_0_1_0_1_0.set_title("Phase_2")

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

        self.qtgui_number_sink_0_1_0_1_0.enable_autoscale(False)
        self._qtgui_number_sink_0_1_0_1_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0_1_0_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_1_0_1_0_win,
                                       2, 1, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_number_sink_0_1_0_1 = qtgui.number_sink(
            gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1)
        self.qtgui_number_sink_0_1_0_1.set_update_time(0.10)
        self.qtgui_number_sink_0_1_0_1.set_title("Phase_1")

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

        self.qtgui_number_sink_0_1_0_1.enable_autoscale(False)
        self._qtgui_number_sink_0_1_0_1_win = sip.wrapinstance(
            self.qtgui_number_sink_0_1_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_1_0_1_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_number_sink_0_1_0 = qtgui.number_sink(
            gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1)
        self.qtgui_number_sink_0_1_0.set_update_time(0.10)
        self.qtgui_number_sink_0_1_0.set_title("Refference")

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

        self.qtgui_number_sink_0_1_0.enable_autoscale(False)
        self._qtgui_number_sink_0_1_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_1_0_win, 0, 1,
                                       1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_number_sink_0_1 = qtgui.number_sink(gr.sizeof_float, 0,
                                                       qtgui.NUM_GRAPH_NONE, 1)
        self.qtgui_number_sink_0_1.set_update_time(0.10)
        self.qtgui_number_sink_0_1.set_title("Pr_1")

        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, 0)
            self.qtgui_number_sink_0_1.set_max(i, 10)
            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, 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.fft_vxx_0_1_0_0_0_0 = fft.fft_vcc(fft_bins, True,
                                               window.blackmanharris(1024),
                                               True, 1)
        self.fft_vxx_0_1_0_0_0 = fft.fft_vcc(fft_bins, True,
                                             window.blackmanharris(1024), True,
                                             1)
        self.fft_vxx_0_1_0_0 = fft.fft_vcc(fft_bins, True,
                                           window.blackmanharris(1024), True,
                                           1)
        self.fft_vxx_0_1_0 = fft.fft_vcc(fft_bins, True,
                                         window.blackmanharris(1024), True, 1)
        self.fft_vxx_0 = fft.fft_vcc(fft_bins, True,
                                     window.blackmanharris(1024), True, 1)
        self.blocks_vector_to_stream_0_1_1_0_0_1_0_0 = blocks.vector_to_stream(
            gr.sizeof_float * 1, fft_bins)
        self.blocks_vector_to_stream_0_1_1_0_0_1_0 = blocks.vector_to_stream(
            gr.sizeof_float * 1, fft_bins)
        self.blocks_vector_to_stream_0_1_1_0_0_1 = blocks.vector_to_stream(
            gr.sizeof_float * 1, fft_bins)
        self.blocks_vector_to_stream_0_1_1_0_0_0_0_0_0 = blocks.vector_to_stream(
            gr.sizeof_float * 1, fft_bins)
        self.blocks_vector_to_stream_0_1_1_0_0_0_0_0 = blocks.vector_to_stream(
            gr.sizeof_float * 1, fft_bins)
        self.blocks_vector_to_stream_0_1_1_0_0_0_0 = blocks.vector_to_stream(
            gr.sizeof_float * 1, fft_bins)
        self.blocks_vector_to_stream_0_1_1_0_0_0 = blocks.vector_to_stream(
            gr.sizeof_float * 1, fft_bins)
        self.blocks_vector_to_stream_0_1_1_0_0 = blocks.vector_to_stream(
            gr.sizeof_float * 1, fft_bins)
        self.blocks_vector_to_stream_0_1_0_0 = blocks.vector_to_stream(
            gr.sizeof_float * 1, fft_bins)
        self.blocks_throttle_0_0_0_0_0_0_0 = blocks.throttle(
            gr.sizeof_gr_complex * 1, samp_rate, True)
        self.blocks_throttle_0_0_0_0_0_0 = blocks.throttle(
            gr.sizeof_gr_complex * 1, samp_rate, True)
        self.blocks_throttle_0_0_0_0_0 = blocks.throttle(
            gr.sizeof_gr_complex * 1, samp_rate, True)
        self.blocks_throttle_0_0_0_0 = blocks.throttle(
            gr.sizeof_gr_complex * 1, samp_rate, True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_stream_to_vector_1_0_0_0_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 1024)
        self.blocks_stream_to_vector_1_0_0_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 1024)
        self.blocks_stream_to_vector_1_0_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 1024)
        self.blocks_stream_to_vector_1_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 1024)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 1024)
        self.blocks_skiphead_0_2 = blocks.skiphead(gr.sizeof_float * 1,
                                                   skip_bins)
        self.blocks_skiphead_0_1_0_0_0_1_0_0 = blocks.skiphead(
            gr.sizeof_float * 1, skip_bins)
        self.blocks_skiphead_0_1_0_0_0_1_0 = blocks.skiphead(
            gr.sizeof_float * 1, skip_bins)
        self.blocks_skiphead_0_1_0_0_0_1 = blocks.skiphead(
            gr.sizeof_float * 1, skip_bins)
        self.blocks_skiphead_0_1_0_0_0_0_0_0_0 = blocks.skiphead(
            gr.sizeof_float * 1, skip_bins)
        self.blocks_skiphead_0_1_0_0_0_0_0_0 = blocks.skiphead(
            gr.sizeof_float * 1, skip_bins)
        self.blocks_skiphead_0_1_0_0_0_0_0 = blocks.skiphead(
            gr.sizeof_float * 1, skip_bins)
        self.blocks_skiphead_0_1_0_0_0_0 = blocks.skiphead(
            gr.sizeof_float * 1, skip_bins)
        self.blocks_skiphead_0_1_0_0_0 = blocks.skiphead(
            gr.sizeof_float * 1, skip_bins)
        self.blocks_nlog10_ff_0_0_0_0 = blocks.nlog10_ff(10, fft_bins, k)
        self.blocks_nlog10_ff_0_0_0 = blocks.nlog10_ff(10, fft_bins, k)
        self.blocks_nlog10_ff_0_0 = blocks.nlog10_ff(10, fft_bins, k)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, fft_bins, k)
        self.blocks_moving_average_xx_3_0 = blocks.moving_average_ff(
            1000, 1 / 1000, 1000, 1)
        self.blocks_moving_average_xx_2_1 = blocks.moving_average_ff(
            1000, 1 / 1000, 1000, 1)
        self.blocks_moving_average_xx_2_0 = blocks.moving_average_ff(
            1000, 1 / 1000, 1000, 1)
        self.blocks_moving_average_xx_1_0_1 = blocks.moving_average_ff(
            1000, 1 / 1000, 1000, 1)
        self.blocks_moving_average_xx_1_0_0_1 = blocks.moving_average_ff(
            1000, 1 / 1000, 1000, 1)
        self.blocks_moving_average_xx_1_0_0_0_0 = blocks.moving_average_ff(
            1000, 1 / 1000, 1000, 1)
        self.blocks_moving_average_xx_1_0_0_0 = blocks.moving_average_ff(
            1000, 1 / 1000, 1000, 1)
        self.blocks_moving_average_xx_1_0_0 = blocks.moving_average_ff(
            1000, 1 / 1000, 1000, 1)
        self.blocks_moving_average_xx_1_0 = blocks.moving_average_ff(
            1000, 1 / 1000, 1000, 1)
        self.blocks_keep_one_in_n_0_2_0_0_0_1_0_0 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, 1024)
        self.blocks_keep_one_in_n_0_2_0_0_0_1_0 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, 1024)
        self.blocks_keep_one_in_n_0_2_0_0_0_1 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, 1024)
        self.blocks_keep_one_in_n_0_2_0_0_0_0_0_0_0 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, 1024)
        self.blocks_keep_one_in_n_0_2_0_0_0_0_0_0 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, 1024)
        self.blocks_keep_one_in_n_0_2_0_0_0_0_0 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, 1024)
        self.blocks_keep_one_in_n_0_2_0_0_0_0 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, 1024)
        self.blocks_keep_one_in_n_0_2_0_0_0 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, 1024)
        self.blocks_keep_one_in_n_0_2 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, 1024)
        self.blocks_head_3_0 = blocks.head(gr.sizeof_float * 1, head)
        self.blocks_head_2_1 = blocks.head(gr.sizeof_float * 1, head)
        self.blocks_head_2_0 = blocks.head(gr.sizeof_float * 1, head)
        self.blocks_head_1_0_2 = blocks.head(gr.sizeof_float * 1, head)
        self.blocks_head_1_0_1 = blocks.head(gr.sizeof_float * 1, head)
        self.blocks_head_1_0_0_1 = blocks.head(gr.sizeof_float * 1, head)
        self.blocks_head_1_0_0_0 = blocks.head(gr.sizeof_float * 1, head)
        self.blocks_head_1_0_0 = blocks.head(gr.sizeof_float * 1, head)
        self.blocks_head_1_0 = blocks.head(gr.sizeof_float * 1, head)
        self.blocks_divide_xx_0_0_0_0 = blocks.divide_cc(fft_bins)
        self.blocks_divide_xx_0_0_0 = blocks.divide_cc(fft_bins)
        self.blocks_divide_xx_0_0 = blocks.divide_cc(fft_bins)
        self.blocks_divide_xx_0 = blocks.divide_cc(fft_bins)
        self.blocks_complex_to_mag_squared_0_0_0_0_0_0_0_0 = blocks.complex_to_mag_squared(
            fft_bins)
        self.blocks_complex_to_mag_squared_0_0_0_0_0_0_0 = blocks.complex_to_mag_squared(
            fft_bins)
        self.blocks_complex_to_mag_squared_0_0_0_0_0_0 = blocks.complex_to_mag_squared(
            fft_bins)
        self.blocks_complex_to_mag_squared_0_0_0_0_0 = blocks.complex_to_mag_squared(
            fft_bins)
        self.blocks_complex_to_arg_0_2_0 = blocks.complex_to_arg(fft_bins)
        self.blocks_complex_to_arg_0_0_0_0_0_0 = blocks.complex_to_arg(
            fft_bins)
        self.blocks_complex_to_arg_0_0_0_0_0 = blocks.complex_to_arg(fft_bins)
        self.blocks_complex_to_arg_0_0_0_0 = blocks.complex_to_arg(fft_bins)
        self.blocks_complex_to_arg_0_0_0 = blocks.complex_to_arg(fft_bins)
        self.analog_const_source_x_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_throttle_0_0_0_0, 0))
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_throttle_0_0_0_0_0, 0))
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_throttle_0_0_0_0_0_0, 0))
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_throttle_0_0_0_0_0_0_0, 0))
        self.connect((self.blocks_complex_to_arg_0_0_0, 0),
                     (self.blocks_vector_to_stream_0_1_1_0_0, 0))
        self.connect((self.blocks_complex_to_arg_0_0_0_0, 0),
                     (self.blocks_vector_to_stream_0_1_1_0_0_1, 0))
        self.connect((self.blocks_complex_to_arg_0_0_0_0_0, 0),
                     (self.blocks_vector_to_stream_0_1_1_0_0_1_0, 0))
        self.connect((self.blocks_complex_to_arg_0_0_0_0_0_0, 0),
                     (self.blocks_vector_to_stream_0_1_1_0_0_1_0_0, 0))
        self.connect((self.blocks_complex_to_arg_0_2_0, 0),
                     (self.blocks_vector_to_stream_0_1_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_0_0_0_0, 0),
                     (self.blocks_nlog10_ff_0_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_0_0_0_0_0, 0),
                     (self.blocks_nlog10_ff_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_0_0_0_0_0_0, 0),
                     (self.blocks_nlog10_ff_0_0_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_0_0_0_0_0_0_0, 0),
                     (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.blocks_complex_to_arg_0_0_0, 0))
        self.connect((self.blocks_divide_xx_0_0, 0),
                     (self.blocks_complex_to_arg_0_0_0_0, 0))
        self.connect((self.blocks_divide_xx_0_0_0, 0),
                     (self.blocks_complex_to_arg_0_0_0_0_0, 0))
        self.connect((self.blocks_divide_xx_0_0_0_0, 0),
                     (self.blocks_complex_to_arg_0_0_0_0_0_0, 0))
        self.connect((self.blocks_head_1_0, 0),
                     (self.blocks_moving_average_xx_1_0, 0))
        self.connect((self.blocks_head_1_0_0, 0),
                     (self.blocks_moving_average_xx_1_0_0, 0))
        self.connect((self.blocks_head_1_0_0_0, 0),
                     (self.blocks_moving_average_xx_1_0_0_0, 0))
        self.connect((self.blocks_head_1_0_0_1, 0),
                     (self.blocks_moving_average_xx_1_0_0_1, 0))
        self.connect((self.blocks_head_1_0_1, 0),
                     (self.blocks_moving_average_xx_1_0_0_0_0, 0))
        self.connect((self.blocks_head_1_0_2, 0),
                     (self.blocks_moving_average_xx_1_0_1, 0))
        self.connect((self.blocks_head_2_0, 0),
                     (self.blocks_moving_average_xx_2_0, 0))
        self.connect((self.blocks_head_2_1, 0),
                     (self.blocks_moving_average_xx_2_1, 0))
        self.connect((self.blocks_head_3_0, 0),
                     (self.blocks_moving_average_xx_3_0, 0))
        self.connect((self.blocks_keep_one_in_n_0_2, 0),
                     (self.blocks_head_2_1, 0))
        self.connect((self.blocks_keep_one_in_n_0_2_0_0_0, 0),
                     (self.blocks_head_1_0_0_0, 0))
        self.connect((self.blocks_keep_one_in_n_0_2_0_0_0_0, 0),
                     (self.blocks_head_1_0_1, 0))
        self.connect((self.blocks_keep_one_in_n_0_2_0_0_0_0_0, 0),
                     (self.blocks_head_1_0_0, 0))
        self.connect((self.blocks_keep_one_in_n_0_2_0_0_0_0_0_0, 0),
                     (self.blocks_head_1_0_0_1, 0))
        self.connect((self.blocks_keep_one_in_n_0_2_0_0_0_0_0_0_0, 0),
                     (self.blocks_head_2_0, 0))
        self.connect((self.blocks_keep_one_in_n_0_2_0_0_0_1, 0),
                     (self.blocks_head_1_0, 0))
        self.connect((self.blocks_keep_one_in_n_0_2_0_0_0_1_0, 0),
                     (self.blocks_head_1_0_2, 0))
        self.connect((self.blocks_keep_one_in_n_0_2_0_0_0_1_0_0, 0),
                     (self.blocks_head_3_0, 0))
        self.connect((self.blocks_moving_average_xx_1_0, 0),
                     (self.qtgui_number_sink_0_1_1_0, 0))
        self.connect((self.blocks_moving_average_xx_1_0_0, 0),
                     (self.qtgui_number_sink_0_1_1_0_0, 0))
        self.connect((self.blocks_moving_average_xx_1_0_0_0, 0),
                     (self.qtgui_number_sink_0_1_1_0_1, 0))
        self.connect((self.blocks_moving_average_xx_1_0_0_0_0, 0),
                     (self.qtgui_number_sink_0_1_1_0_0_0, 0))
        self.connect((self.blocks_moving_average_xx_1_0_0_1, 0),
                     (self.qtgui_number_sink_0_1_1, 0))
        self.connect((self.blocks_moving_average_xx_1_0_1, 0),
                     (self.qtgui_number_sink_0_1_0_1_0, 0))
        self.connect((self.blocks_moving_average_xx_2_0, 0),
                     (self.qtgui_number_sink_0_1, 0))
        self.connect((self.blocks_moving_average_xx_2_1, 0),
                     (self.qtgui_number_sink_0_1_0, 0))
        self.connect((self.blocks_moving_average_xx_3_0, 0),
                     (self.qtgui_number_sink_0_1_0_1, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.blocks_vector_to_stream_0_1_1_0_0_0_0_0_0, 0))
        self.connect((self.blocks_nlog10_ff_0_0, 0),
                     (self.blocks_vector_to_stream_0_1_1_0_0_0_0, 0))
        self.connect((self.blocks_nlog10_ff_0_0_0, 0),
                     (self.blocks_vector_to_stream_0_1_1_0_0_0, 0))
        self.connect((self.blocks_nlog10_ff_0_0_0_0, 0),
                     (self.blocks_vector_to_stream_0_1_1_0_0_0_0_0, 0))
        self.connect((self.blocks_skiphead_0_1_0_0_0, 0),
                     (self.blocks_keep_one_in_n_0_2_0_0_0, 0))
        self.connect((self.blocks_skiphead_0_1_0_0_0_0, 0),
                     (self.blocks_keep_one_in_n_0_2_0_0_0_0, 0))
        self.connect((self.blocks_skiphead_0_1_0_0_0_0_0, 0),
                     (self.blocks_keep_one_in_n_0_2_0_0_0_0_0, 0))
        self.connect((self.blocks_skiphead_0_1_0_0_0_0_0_0, 0),
                     (self.blocks_keep_one_in_n_0_2_0_0_0_0_0_0, 0))
        self.connect((self.blocks_skiphead_0_1_0_0_0_0_0_0_0, 0),
                     (self.blocks_keep_one_in_n_0_2_0_0_0_0_0_0_0, 0))
        self.connect((self.blocks_skiphead_0_1_0_0_0_1, 0),
                     (self.blocks_keep_one_in_n_0_2_0_0_0_1, 0))
        self.connect((self.blocks_skiphead_0_1_0_0_0_1_0, 0),
                     (self.blocks_keep_one_in_n_0_2_0_0_0_1_0, 0))
        self.connect((self.blocks_skiphead_0_1_0_0_0_1_0_0, 0),
                     (self.blocks_keep_one_in_n_0_2_0_0_0_1_0_0, 0))
        self.connect((self.blocks_skiphead_0_2, 0),
                     (self.blocks_keep_one_in_n_0_2, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_stream_to_vector_1_0, 0),
                     (self.fft_vxx_0_1_0, 0))
        self.connect((self.blocks_stream_to_vector_1_0_0, 0),
                     (self.fft_vxx_0_1_0_0, 0))
        self.connect((self.blocks_stream_to_vector_1_0_0_0, 0),
                     (self.fft_vxx_0_1_0_0_0, 0))
        self.connect((self.blocks_stream_to_vector_1_0_0_0_0, 0),
                     (self.fft_vxx_0_1_0_0_0_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_throttle_0_0_0_0, 0),
                     (self.blocks_stream_to_vector_1_0, 0))
        self.connect((self.blocks_throttle_0_0_0_0_0, 0),
                     (self.blocks_stream_to_vector_1_0_0, 0))
        self.connect((self.blocks_throttle_0_0_0_0_0_0, 0),
                     (self.blocks_stream_to_vector_1_0_0_0, 0))
        self.connect((self.blocks_throttle_0_0_0_0_0_0_0, 0),
                     (self.blocks_stream_to_vector_1_0_0_0_0, 0))
        self.connect((self.blocks_vector_to_stream_0_1_0_0, 0),
                     (self.blocks_skiphead_0_2, 0))
        self.connect((self.blocks_vector_to_stream_0_1_1_0_0, 0),
                     (self.blocks_skiphead_0_1_0_0_0, 0))
        self.connect((self.blocks_vector_to_stream_0_1_1_0_0_0, 0),
                     (self.blocks_skiphead_0_1_0_0_0_0, 0))
        self.connect((self.blocks_vector_to_stream_0_1_1_0_0_0_0, 0),
                     (self.blocks_skiphead_0_1_0_0_0_0_0, 0))
        self.connect((self.blocks_vector_to_stream_0_1_1_0_0_0_0_0, 0),
                     (self.blocks_skiphead_0_1_0_0_0_0_0_0, 0))
        self.connect((self.blocks_vector_to_stream_0_1_1_0_0_0_0_0_0, 0),
                     (self.blocks_skiphead_0_1_0_0_0_0_0_0_0, 0))
        self.connect((self.blocks_vector_to_stream_0_1_1_0_0_1, 0),
                     (self.blocks_skiphead_0_1_0_0_0_1, 0))
        self.connect((self.blocks_vector_to_stream_0_1_1_0_0_1_0, 0),
                     (self.blocks_skiphead_0_1_0_0_0_1_0, 0))
        self.connect((self.blocks_vector_to_stream_0_1_1_0_0_1_0_0, 0),
                     (self.blocks_skiphead_0_1_0_0_0_1_0_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.blocks_complex_to_arg_0_2_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_divide_xx_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_divide_xx_0_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_divide_xx_0_0_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_divide_xx_0_0_0_0, 0))
        self.connect((self.fft_vxx_0_1_0, 0),
                     (self.blocks_complex_to_mag_squared_0_0_0_0_0, 0))
        self.connect((self.fft_vxx_0_1_0, 0), (self.blocks_divide_xx_0, 1))
        self.connect((self.fft_vxx_0_1_0_0, 0),
                     (self.blocks_complex_to_mag_squared_0_0_0_0_0_0, 0))
        self.connect((self.fft_vxx_0_1_0_0, 0), (self.blocks_divide_xx_0_0, 1))
        self.connect((self.fft_vxx_0_1_0_0_0, 0),
                     (self.blocks_complex_to_mag_squared_0_0_0_0_0_0_0, 0))
        self.connect((self.fft_vxx_0_1_0_0_0, 0),
                     (self.blocks_divide_xx_0_0_0, 1))
        self.connect((self.fft_vxx_0_1_0_0_0_0, 0),
                     (self.blocks_complex_to_mag_squared_0_0_0_0_0_0_0_0, 0))
        self.connect((self.fft_vxx_0_1_0_0_0_0, 0),
                     (self.blocks_divide_xx_0_0_0_0, 1))
Beispiel #14
0
import gnuradio
from gnuradio import gr
from gnuradio import blocks as grblocks
import sys

if __name__ == '__main__':

    duration = float(sys.argv[1])

    tb = gr.top_block()
    src = gr.null_source(8)
    b0 = gr.copy(8)
    b1 = grblocks.sub_cc()
    b2 = gr.copy(8)
    b3 = grblocks.divide_cc()
    b4 = gr.copy(8)
    sink = gr.null_sink(8)

    tb.connect(src, b0, b1, b2, b3, b4, sink)

    import time
    tb.start()
    time.sleep(duration)
    print '##RESULT##', sink.nitems_read(0) / duration
    import sys
    sys.stdout.flush()
    tb.stop()
    tb.wait()
Beispiel #15
0
    def __init__(self):
        gr.top_block.__init__(self, "Path Length Difference")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Path Length Difference")
        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", "demo_length_host")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.velocity_factor = velocity_factor = 0.69
        self.speed_of_light = speed_of_light = 299792458
        self.rf_freq = rf_freq = 100e6
        self.wavelength = wavelength = velocity_factor * speed_of_light / rf_freq
        self.wave_number = wave_number = 2 * np.pi / wavelength
        self.meters_per_radian = meters_per_radian = 1 / wave_number
        self.variable_qtgui_label_3 = variable_qtgui_label_3 = rf_freq / 1e6
        self.variable_qtgui_label_2 = variable_qtgui_label_2 = meters_per_radian
        self.variable_qtgui_label_1 = variable_qtgui_label_1 = wavelength
        self.variable_qtgui_label_0 = variable_qtgui_label_0 = velocity_factor
        self.tx_gain = tx_gain = 30
        self.samp_rate = samp_rate = 100e3
        self.rx_gain = rx_gain = 30
        self.gui_update_sec = gui_update_sec = 0.2
        self.fft_size = fft_size = 64
        self.client_address = client_address = "192.168.10.184"

        ##################################################
        # Blocks
        ##################################################
        self.tabs = Qt.QTabWidget()
        self.tabs_widget_0 = Qt.QWidget()
        self.tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                           self.tabs_widget_0)
        self.tabs_grid_layout_0 = Qt.QGridLayout()
        self.tabs_layout_0.addLayout(self.tabs_grid_layout_0)
        self.tabs.addTab(self.tabs_widget_0, 'Magnitude')
        self.tabs_widget_1 = Qt.QWidget()
        self.tabs_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                           self.tabs_widget_1)
        self.tabs_grid_layout_1 = Qt.QGridLayout()
        self.tabs_layout_1.addLayout(self.tabs_grid_layout_1)
        self.tabs.addTab(self.tabs_widget_1, 'Phase')
        self.top_grid_layout.addWidget(self.tabs, 0, 0, 1, 2)
        self.zeromq_pull_source_2 = zeromq.pull_source(
            gr.sizeof_gr_complex, 1, 'tcp://192.168.10.184:9997', 100, False,
            -1)
        self.zeromq_pull_source_1 = zeromq.pull_source(
            gr.sizeof_gr_complex, 1, 'tcp://192.168.10.184:9998', 100, False,
            -1)
        self.zeromq_pull_source_0 = zeromq.pull_source(
            gr.sizeof_gr_complex, 1, 'tcp://192.168.10.184:9999', 100, False,
            -1)
        self.xmlrpc_client1 = xmlrpclib.Server('http://192.168.10.184:30000')
        self.xmlrpc_client0 = xmlrpclib.Server('http://192.168.10.184:30000')
        self._variable_qtgui_label_3_tool_bar = Qt.QToolBar(self)

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

        self._variable_qtgui_label_3_tool_bar.addWidget(
            Qt.QLabel('RF Frequency (MHz)' + ": "))
        self._variable_qtgui_label_3_label = Qt.QLabel(
            str(
                self._variable_qtgui_label_3_formatter(
                    self.variable_qtgui_label_3)))
        self._variable_qtgui_label_3_tool_bar.addWidget(
            self._variable_qtgui_label_3_label)
        self.top_grid_layout.addWidget(self._variable_qtgui_label_3_tool_bar,
                                       1, 0, 1, 1)

        self._variable_qtgui_label_2_tool_bar = Qt.QToolBar(self)

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

        self._variable_qtgui_label_2_tool_bar.addWidget(
            Qt.QLabel('Meters Per Radian of Phase in Cable' + ": "))
        self._variable_qtgui_label_2_label = Qt.QLabel(
            str(
                self._variable_qtgui_label_2_formatter(
                    self.variable_qtgui_label_2)))
        self._variable_qtgui_label_2_tool_bar.addWidget(
            self._variable_qtgui_label_2_label)
        self.top_grid_layout.addWidget(self._variable_qtgui_label_2_tool_bar,
                                       4, 0, 1, 1)

        self._variable_qtgui_label_1_tool_bar = Qt.QToolBar(self)

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

        self._variable_qtgui_label_1_tool_bar.addWidget(
            Qt.QLabel('Wavelength in Cable (m)' + ": "))
        self._variable_qtgui_label_1_label = Qt.QLabel(
            str(
                self._variable_qtgui_label_1_formatter(
                    self.variable_qtgui_label_1)))
        self._variable_qtgui_label_1_tool_bar.addWidget(
            self._variable_qtgui_label_1_label)
        self.top_grid_layout.addWidget(self._variable_qtgui_label_1_tool_bar,
                                       3, 0, 1, 1)

        self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self)

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

        self._variable_qtgui_label_0_tool_bar.addWidget(
            Qt.QLabel('Velocity Factor of Cable' + ": "))
        self._variable_qtgui_label_0_label = Qt.QLabel(
            str(
                self._variable_qtgui_label_0_formatter(
                    self.variable_qtgui_label_0)))
        self._variable_qtgui_label_0_tool_bar.addWidget(
            self._variable_qtgui_label_0_label)
        self.top_grid_layout.addWidget(self._variable_qtgui_label_0_tool_bar,
                                       2, 0, 1, 1)

        self._tx_gain_range = Range(0, 40, 1, 30, 50)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        'TX Gain', "counter_slider", float)
        self.tabs_grid_layout_0.addWidget(self._tx_gain_win, 1, 0, 1, 1)
        self.to_mag_db_0_4 = to_mag_db()
        self.to_mag_db_0_3 = to_mag_db()
        self.to_mag_db_0_2 = to_mag_db()
        self.to_mag_db_0_1 = to_mag_db()
        self.to_mag_db_0_0 = to_mag_db()
        self.to_mag_db_0 = to_mag_db()
        self._rx_gain_range = Range(0, 30, 1, 30, 100)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        'RX Gain', "counter_slider", float)
        self.tabs_grid_layout_0.addWidget(self._rx_gain_win, 1, 1, 1, 1)
        self.qtgui_number_sink_1 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_NONE, 3)
        self.qtgui_number_sink_1.set_update_time(gui_update_sec)
        self.qtgui_number_sink_1.set_title("Length (m)")

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

        self.qtgui_number_sink_1.enable_autoscale(False)
        self._qtgui_number_sink_1_win = sip.wrapinstance(
            self.qtgui_number_sink_1.pyqwidget(), Qt.QWidget)
        self.tabs_grid_layout_1.addWidget(self._qtgui_number_sink_1_win, 2, 0,
                                          1, 1)
        self.qtgui_number_sink_0_0_0 = qtgui.number_sink(
            gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 3)
        self.qtgui_number_sink_0_0_0.set_update_time(gui_update_sec)
        self.qtgui_number_sink_0_0_0.set_title("Magnitude Difference (dB)")

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

        self.qtgui_number_sink_0_0_0.enable_autoscale(False)
        self._qtgui_number_sink_0_0_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0_0_0.pyqwidget(), Qt.QWidget)
        self.tabs_grid_layout_0.addWidget(self._qtgui_number_sink_0_0_0_win, 4,
                                          0, 1, 2)
        self.qtgui_number_sink_0_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                       qtgui.NUM_GRAPH_NONE, 3)
        self.qtgui_number_sink_0_0.set_update_time(gui_update_sec)
        self.qtgui_number_sink_0_0.set_title("Magnitude (dB)")

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

        self.qtgui_number_sink_0_0.enable_autoscale(False)
        self._qtgui_number_sink_0_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget)
        self.tabs_grid_layout_0.addWidget(self._qtgui_number_sink_0_0_win, 3,
                                          0, 1, 2)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_NONE, 3)
        self.qtgui_number_sink_0.set_update_time(gui_update_sec)
        self.qtgui_number_sink_0.set_title("Phase Difference (rad)")

        labels = ['REF - A', 'REF - B', 'A - B', '', '', '', '', '', '', '']
        units = ['rad', 'rad', 'rad', '', '', '', '', '', '', '']
        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(3):
            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.tabs_grid_layout_1.addWidget(self._qtgui_number_sink_0_win, 1, 0,
                                          1, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_HANN,  #wintype
            rf_freq,  #fc
            samp_rate,  #bw
            "",  #name
            3  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(gui_update_sec)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, -20)
        self.qtgui_freq_sink_x_0.set_y_label('Amplitude', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not 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 = ['REF', 'RXA', 'RXB', '', '', '', '', '', '', '']
        widths = [1, 2, 2, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(3):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tabs_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0,
                                          1, 2)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024,  #size
            "",  #name
            3  #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(gui_update_sec)
        self.qtgui_const_sink_x_0.set_y_axis(-4, 4)
        self.qtgui_const_sink_x_0.set_x_axis(-4, 4)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(True)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0.disable_legend()

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

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tabs_grid_layout_1.addWidget(self._qtgui_const_sink_x_0_win, 0, 0,
                                          1, 1)
        self.fft_bin_select_ref = fft_bin_select(
            fft_size=64,
            nskip=1,
        )
        self.fft_bin_select_B = fft_bin_select(
            fft_size=64,
            nskip=1,
        )
        self.fft_bin_select_A = fft_bin_select(
            fft_size=64,
            nskip=1,
        )
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_multiply_const_vxx_1_1 = blocks.multiply_const_vff(
            (meters_per_radian, ))
        self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff(
            (meters_per_radian, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff(
            (meters_per_radian, ))
        self.blocks_divide_ref_b = blocks.divide_cc(1)
        self.blocks_divide_ref_a = blocks.divide_cc(1)
        self.blocks_divide_a_b = blocks.divide_cc(1)
        self.blocks_complex_to_arg_0_1 = blocks.complex_to_arg(1)
        self.blocks_complex_to_arg_0_0 = blocks.complex_to_arg(1)
        self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1)
        self.blocks_add_const_vxx_0_1 = blocks.add_const_vff((np.pi, ))
        self.blocks_add_const_vxx_0_0 = blocks.add_const_vff((np.pi, ))
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((np.pi, ))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_multiply_const_vxx_1_1, 0))
        self.connect((self.blocks_add_const_vxx_0_0, 0),
                     (self.blocks_multiply_const_vxx_1_0, 0))
        self.connect((self.blocks_add_const_vxx_0_1, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_complex_to_arg_0, 0),
                     (self.blocks_add_const_vxx_0_1, 0))
        self.connect((self.blocks_complex_to_arg_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_complex_to_arg_0_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_complex_to_arg_0_0, 0),
                     (self.qtgui_number_sink_0, 2))
        self.connect((self.blocks_complex_to_arg_0_1, 0),
                     (self.blocks_add_const_vxx_0_0, 0))
        self.connect((self.blocks_complex_to_arg_0_1, 0),
                     (self.qtgui_number_sink_0, 1))
        self.connect((self.blocks_divide_a_b, 0),
                     (self.blocks_complex_to_arg_0_0, 0))
        self.connect((self.blocks_divide_a_b, 0),
                     (self.qtgui_const_sink_x_0, 2))
        self.connect((self.blocks_divide_a_b, 0), (self.to_mag_db_0_4, 0))
        self.connect((self.blocks_divide_ref_a, 0),
                     (self.blocks_complex_to_arg_0, 0))
        self.connect((self.blocks_divide_ref_a, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.blocks_divide_ref_a, 0), (self.to_mag_db_0_3, 0))
        self.connect((self.blocks_divide_ref_b, 0),
                     (self.blocks_complex_to_arg_0_1, 0))
        self.connect((self.blocks_divide_ref_b, 0),
                     (self.qtgui_const_sink_x_0, 1))
        self.connect((self.blocks_divide_ref_b, 0), (self.to_mag_db_0_2, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.qtgui_number_sink_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.qtgui_number_sink_1, 1))
        self.connect((self.blocks_multiply_const_vxx_1_1, 0),
                     (self.qtgui_number_sink_1, 2))
        self.connect((self.blocks_throttle_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.fft_bin_select_A, 0), (self.blocks_divide_a_b, 0))
        self.connect((self.fft_bin_select_A, 0), (self.blocks_divide_ref_a, 1))
        self.connect((self.fft_bin_select_A, 0), (self.to_mag_db_0_0, 0))
        self.connect((self.fft_bin_select_B, 0), (self.blocks_divide_a_b, 1))
        self.connect((self.fft_bin_select_B, 0), (self.blocks_divide_ref_b, 1))
        self.connect((self.fft_bin_select_B, 0), (self.to_mag_db_0_1, 0))
        self.connect((self.fft_bin_select_ref, 0),
                     (self.blocks_divide_ref_a, 0))
        self.connect((self.fft_bin_select_ref, 0),
                     (self.blocks_divide_ref_b, 0))
        self.connect((self.fft_bin_select_ref, 0), (self.to_mag_db_0, 0))
        self.connect((self.to_mag_db_0, 0), (self.qtgui_number_sink_0_0, 0))
        self.connect((self.to_mag_db_0_0, 0), (self.qtgui_number_sink_0_0, 1))
        self.connect((self.to_mag_db_0_1, 0), (self.qtgui_number_sink_0_0, 2))
        self.connect((self.to_mag_db_0_2, 0),
                     (self.qtgui_number_sink_0_0_0, 1))
        self.connect((self.to_mag_db_0_3, 0),
                     (self.qtgui_number_sink_0_0_0, 0))
        self.connect((self.to_mag_db_0_4, 0),
                     (self.qtgui_number_sink_0_0_0, 2))
        self.connect((self.zeromq_pull_source_0, 0),
                     (self.fft_bin_select_B, 0))
        self.connect((self.zeromq_pull_source_0, 0),
                     (self.qtgui_freq_sink_x_0, 2))
        self.connect((self.zeromq_pull_source_1, 0),
                     (self.fft_bin_select_A, 0))
        self.connect((self.zeromq_pull_source_1, 0),
                     (self.qtgui_freq_sink_x_0, 1))
        self.connect((self.zeromq_pull_source_2, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.zeromq_pull_source_2, 0),
                     (self.fft_bin_select_ref, 0))
Beispiel #16
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="FM Stereo Receiver")

        ##################################################
        # Variables
        ##################################################
        self.smux_filt_samprate = smux_filt_samprate = 256e3
        self.smux_decim = smux_decim = 8
        self.samp_rate = samp_rate = 2.048e6
        self.right_gain = right_gain = 3
        self.left_gain = left_gain = 3
        self.bpf_base = bpf_base = 23e3
        self.RF_Gain = RF_Gain = 45
        self.CF = CF = 99.3e6

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.samp_rate,
            callback=self.set_samp_rate,
            label=
            "Sample Rate: 1.024M, 1.4M, 1.8M, 1.92M, 2.048M, 2.4M & 2. 56M",
            converter=forms.float_converter(),
        )
        self.GridAdd(self._samp_rate_text_box, 1, 0, 1, 1)
        _right_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._right_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_right_gain_sizer,
            value=self.right_gain,
            callback=self.set_right_gain,
            label="R Audio Gain",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._right_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_right_gain_sizer,
            value=self.right_gain,
            callback=self.set_right_gain,
            minimum=0,
            maximum=5,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_right_gain_sizer, 0, 1, 1, 1)
        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(),
                                                        style=wx.NB_TOP)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0),
                                "BB Spectrum")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0),
                                "Demod Spectrum")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0),
                                "Stereo Spectrum")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0),
                                "Stereo Signal")
        self.GridAdd(self.notebook_0, 2, 0, 1, 2)
        _left_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._left_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_left_gain_sizer,
            value=self.left_gain,
            callback=self.set_left_gain,
            label="L Audio Gain",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._left_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_left_gain_sizer,
            value=self.left_gain,
            callback=self.set_left_gain,
            minimum=0,
            maximum=5,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_left_gain_sizer, 0, 0, 1, 1)
        _RF_Gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._RF_Gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_RF_Gain_sizer,
            value=self.RF_Gain,
            callback=self.set_RF_Gain,
            label="RF Gain",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._RF_Gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_RF_Gain_sizer,
            value=self.RF_Gain,
            callback=self.set_RF_Gain,
            minimum=0,
            maximum=100,
            num_steps=45,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_RF_Gain_sizer, 1, 1, 1, 1)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
            self.notebook_0.GetPage(0).GetWin(),
            baseband_freq=0,
            dynamic_range=100,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=512,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="Baseband Waterfall",
            size=(800, 100),
        )
        self.notebook_0.GetPage(0).GridAdd(self.wxgui_waterfallsink2_0.win, 3,
                                           0, 1, 2)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.notebook_0.GetPage(3).GetWin(),
            title="Scope Plot",
            sample_rate=32e3,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=2,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
            size=(800, 500),
        )
        self.notebook_0.GetPage(3).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0_1 = fftsink2.fft_sink_f(
            self.notebook_0.GetPage(2).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=32e3,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="Difference FFT ",
            peak_hold=False,
        )
        self.notebook_0.GetPage(2).Add(self.wxgui_fftsink2_0_1.win)
        self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_f(
            self.notebook_0.GetPage(1).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate / 8,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="Demodulated FFT",
            peak_hold=False,
            size=(800, 800),
        )
        self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_0_0_0.win)
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c(
            self.notebook_0.GetPage(0).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="Baseband FFT",
            peak_hold=False,
            size=(800, 100),
        )
        self.notebook_0.GetPage(0).GridAdd(self.wxgui_fftsink2_0_0.win, 2, 0,
                                           1, 2)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_f(
            self.notebook_0.GetPage(2).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=32e3,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="Sum FFT",
            peak_hold=False,
        )
        self.notebook_0.GetPage(2).Add(self.wxgui_fftsink2_0.win)
        self.rfgain = blocks.multiply_const_vcc((RF_Gain, ))
        self.low_pass_filter_1_0 = filter.fir_filter_fff(
            smux_decim,
            firdes.low_pass(1, smux_filt_samprate, 15e3, 500,
                            firdes.WIN_HAMMING, 1))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            2,
            firdes.low_pass(2, samp_rate / 4, 100e3, 500, firdes.WIN_KAISER,
                            6.76))
        self.iir_filter_xxx_0 = filter.iir_filter_ccf(
            (-0.00266, 0.00504, -0.00309, -0.00136, 0.00663, -0.01052, 0.01103,
             -0.00731, 0.00016, 0.00800, -0.01396, 0.01490, -0.00971, -0.00035,
             0.01173, -0.01979, 0.02054, -0.01240, -0.00273, 0.01960, -0.03122,
             0.03124, -0.01669, -0.01017, 0.04137, -0.06448, 0.06476, -0.02634,
             -0.07449, 0.33571, -0.00000, -0.33571, 0.07449, 0.02634, -0.06476,
             0.06448, -0.04137, 0.01017, 0.01669, -0.03124, 0.03122, -0.01960,
             0.00273, 0.01240, -0.02054, 0.01979, -0.01173, 0.00035, 0.00971,
             -0.01490, 0.01396, -0.00800, -0.00016, 0.00731, -0.01103, 0.01052,
             -0.00663, 0.00136, 0.00309, -0.00504, 0.00266), (1, ), False)
        self.fir_filter_xxx_0_0 = filter.fir_filter_ccf(4, (1, 1, 1, 1))
        self.fir_filter_xxx_0_0.declare_sample_delay(0)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_multiply_xx_1_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff(
            (right_gain, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (left_gain, ))
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            "/Users/bretttt/iCloud_drive/16S/engs110/project/radio_dat/IQ_Data_STEREO1",
            True)
        self.blocks_divide_xx_1 = blocks.divide_cc(1)
        self.blocks_delay_2 = blocks.delay(gr.sizeof_gr_complex * 1, 30)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vcc((0.1, ))
        self.baseband_LPF = filter.fir_filter_fff(
            smux_decim,
            firdes.low_pass(1, smux_filt_samprate, 15e3, 500,
                            firdes.WIN_KAISER, 6.76))
        self.band_pass_filter_0_0_0 = filter.fir_filter_fcc(
            1,
            firdes.complex_band_pass(1, smux_filt_samprate, 18000, 20000, 1000,
                                     firdes.WIN_KAISER, 1))
        self.band_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.band_pass(1, smux_filt_samprate, bpf_base, bpf_base + 30e3,
                             500, firdes.WIN_KAISER, 6.76))
        self.audio_sink_0_0_0_0 = audio.sink(32000, "", True)
        self.analog_pll_refout_cc_0_0 = analog.pll_refout_cc(
            3.14 / 100, 0.152 * 3.14, 0.144 * 3.14)
        self.analog_fm_deemph_0_0 = analog.fm_deemph(fs=samp_rate / 8,
                                                     tau=75e-6)
        self.analog_fm_deemph_0 = analog.fm_deemph(fs=samp_rate / 8, tau=75e-6)
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        _CF_sizer = wx.BoxSizer(wx.VERTICAL)
        self._CF_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_CF_sizer,
            value=self.CF,
            callback=self.set_CF,
            label="Center Frequency",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._CF_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_CF_sizer,
            value=self.CF,
            callback=self.set_CF,
            minimum=80e6,
            maximum=108e6,
            num_steps=280,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_CF_sizer, 3, 0, 1, 2)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.analog_fm_deemph_0, 0),
                     (self.audio_sink_0_0_0_0, 0))
        self.connect((self.analog_fm_deemph_0_0, 0),
                     (self.audio_sink_0_0_0_0, 1))
        self.connect((self.analog_pll_refout_cc_0_0, 0),
                     (self.blocks_multiply_xx_1_0, 0))
        self.connect((self.analog_pll_refout_cc_0_0, 0),
                     (self.blocks_multiply_xx_1_0, 1))
        self.connect((self.band_pass_filter_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.band_pass_filter_0_0_0, 0),
                     (self.analog_pll_refout_cc_0_0, 0))
        self.connect((self.baseband_LPF, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.baseband_LPF, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_divide_xx_1, 1))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.band_pass_filter_0, 0))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.band_pass_filter_0_0_0, 0))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.baseband_LPF, 0))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.wxgui_fftsink2_0_0_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_delay_2, 0),
                     (self.blocks_multiply_conjugate_cc_0, 1))
        self.connect((self.blocks_divide_xx_1, 0), (self.blocks_delay_2, 0))
        self.connect((self.blocks_divide_xx_1, 0), (self.iir_filter_xxx_0, 0))
        self.connect((self.blocks_file_source_0_0, 0), (self.rfgain, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0),
                     (self.blocks_complex_to_imag_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.analog_fm_deemph_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.wxgui_fftsink2_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.wxgui_scopesink2_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.analog_fm_deemph_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.wxgui_fftsink2_0_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.wxgui_scopesink2_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.low_pass_filter_1_0, 0))
        self.connect((self.blocks_multiply_xx_1_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.fir_filter_xxx_0_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.fir_filter_xxx_0_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.iir_filter_xxx_0, 0),
                     (self.blocks_multiply_conjugate_cc_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.blocks_divide_xx_1, 0))
        self.connect((self.low_pass_filter_1_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.low_pass_filter_1_0, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.rfgain, 0), (self.blocks_throttle_0, 0))
Beispiel #17
0
    def __init__(self):
        gr.top_block.__init__(self, "FID Sequence")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("FID Sequence")
        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", "fid_grc_1")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.slave_delay = slave_delay = 0
        self.samp_rate = samp_rate = 250000
        self.readout_delay = readout_delay = 0
        self.offset = offset = 0
        self.master_delay = master_delay = 0
        self.ex_delay = ex_delay = 0
        self.TR_clock = TR_clock = 0
        self.TR = TR = 1
        self.RUN = RUN = 1
        self.CF = CF = 21.3e6

        #### ADDED FROM GR-MRI #####
        f = open('FID_config.txt', 'r')
        foo = {}
        for line in f:
            k, v, bar = [q.strip() for q in line.split(',')]
            if k == 'serial_ID':
                self.serial = str("serial = " + v)
            if k == 'CF':  #added by Chris, to read the CF from FID_config.txt file
                self.CF = float(v)
#            if k == 'num_proj':
#                self.num_proj = float(v)
#            if k == 'angl_inc':
#                self.angl_inc = float(v)
        f.close()

        ############################

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join((self.serial, "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(2),
            ),
        )
        self.uhd_usrp_source_0.set_subdev_spec("A:A A:B", 0)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(CF + offset, 0)
        self.uhd_usrp_source_0.set_gain(15, 0)
        self.uhd_usrp_source_0.set_antenna("A:B", 0)
        self.uhd_usrp_source_0.set_center_freq(CF + offset, 1)
        self.uhd_usrp_source_0.set_gain(10, 1)
        self.uhd_usrp_source_0.set_antenna("A:A", 1)
        self.signal_out = MRI.gated_vector_sink()
        self.rf_sink = uhd.usrp_sink(
            ",".join((self.serial, "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(2),
            ),
        )
        self.rf_sink.set_subdev_spec("A:AB B:A", 0)
        self.rf_sink.set_samp_rate(samp_rate)
        self.rf_sink.set_center_freq(CF + offset, 0)
        self.rf_sink.set_gain(0, 0)
        self.rf_sink.set_antenna("A:AB", 0)
        self.rf_sink.set_center_freq(0, 1)
        self.rf_sink.set_gain(0, 1)
        self.rf_sink.set_antenna("B:A", 1)
        self.readwin = MRI.triggered_vector_source_f([0, 0, 0], 1.0, 0.0, 1, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1000,  #size
            samp_rate,  #samp_rate
            "",  #name
            4  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-.25, .25)

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

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_AUTO,
                                                  qtgui.TRIG_SLOPE_POS, .01, 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 = [
            "Read Window", "Real Signal", "Imag Signal", "RMS", "", "", "", "",
            "", ""
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "black", "blue", "red", "green", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [2, 1, 1, 2, 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(4):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.m_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                      int(master_delay))
        self.m_delay = blocks.delay(gr.sizeof_gr_complex * 1,
                                    int(master_delay))
        self.ex_pulse = MRI.triggered_vector_source([0, 0, 0], 1.0, 0.0, 1, 1)
        self.delay3 = blocks.delay(gr.sizeof_float * 1, readout_delay)
        self.delay1 = blocks.delay(gr.sizeof_float * 1, ex_delay)
        self.blocks_threshold_ff_0_2 = blocks.threshold_ff(.000001, .000001, 0)
        self.blocks_threshold_ff_0_1 = blocks.threshold_ff(.05, .05, 0)
        self.blocks_rms_xx_1 = blocks.rms_cf(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((RUN, ))
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            100, 1.0,
            4000)  #define the length of the unblanking pulse for the RF-PA
        self.blocks_float_to_complex_0_1_0 = blocks.float_to_complex(
            1)  #--> first parameter times Ta (Ta=1/fa) fa=samplingrate
        self.blocks_float_to_complex_0_1 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_divide_xx_0 = blocks.divide_cc(1)
        self.blocks_delay_0 = blocks.delay(
            gr.sizeof_gr_complex * 1, 97
        )  #define delay so that RF-Pulse is centered in the unblanking Window
        self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_xx_1 = blocks.add_vcc(1)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(
            samp_rate, analog.GR_SQR_WAVE, 1. / TR, 1, 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, 0))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.m_delay_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.qtgui_time_sink_x_0, 2))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_threshold_ff_0_1, 0))
        self.connect((self.blocks_complex_to_mag_1, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_add_xx_1, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.blocks_multiply_conjugate_cc_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_float_to_complex_0_1, 0),
                     (self.blocks_add_xx_1, 1))
        self.connect((self.blocks_float_to_complex_0_1_0, 0),
                     (self.m_delay, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_threshold_ff_0_2, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0),
                     (self.blocks_rms_xx_1, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0),
                     (self.signal_out, 1))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.delay1, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.delay3, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_rms_xx_1, 0), (self.qtgui_time_sink_x_0, 3))
        self.connect((self.blocks_threshold_ff_0_1, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_threshold_ff_0_1, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_threshold_ff_0_1, 0), (self.signal_out, 0))
        self.connect((self.blocks_threshold_ff_0_2, 0),
                     (self.blocks_float_to_complex_0_1_0, 0))
        self.connect((self.delay1, 0), (self.ex_pulse, 0))
        self.connect((self.delay3, 0), (self.readwin, 0))
        self.connect((self.ex_pulse, 0), (self.blocks_complex_to_mag_1, 0))
        self.connect((self.ex_pulse, 0), (self.blocks_delay_0, 0))
        self.connect((self.m_delay, 0), (self.rf_sink, 1))
        self.connect((self.m_delay_0, 0), (self.rf_sink, 0))
        self.connect((self.readwin, 0), (self.blocks_float_to_complex_0_1, 1))
        self.connect((self.uhd_usrp_source_0, 1),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.uhd_usrp_source_0, 1), (self.blocks_divide_xx_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.blocks_multiply_conjugate_cc_0, 0))

        #define the GPIO needed to control gradient stepper motor as output
        self.rf_sink.set_gpio_attr(
            "TXA", "DDR", 2, 2, 0
        )  #attributes: which daughterboard, directions, value, mask, which motherboard
Beispiel #18
0
    def __init__(self):
        gr.top_block.__init__(self, "Spin Echo")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Spin Echo")
        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", "spin_echo")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        self._lock = threading.RLock()

        ##################################################
        # Variables
        ##################################################
        self.slave_delay = slave_delay = 0
        self.samp_rate = samp_rate = 250000
        self.ref_delay = ref_delay = 0
        self.readout_delay = readout_delay = 0
        self.power = power = 1
        self.offset = offset = 0
        self.master_delay = master_delay = 0
        self.gz_on = gz_on = 0
        self.gy_on = gy_on = 0
        self.gx_on = gx_on = 0
        self.ex_delay = ex_delay = 0
        self.TR_clock = TR_clock = 0
        self.TR = TR = 1.
        self.RUN = RUN = 1
        self.Gz_delay = Gz_delay = 0
        self.Gy_delay = Gy_delay = 0
        self.Gx_delay = Gx_delay = 0
        self.CF = CF = 21.3e6

        #### ADDED FROM GR-MRI #####
        f = open('spin_config.txt', 'r')
        foo = {}
        for line in f:
            k, v, bar = [q.strip() for q in line.split(',')]
            if k == 'leader_ID':
                self.leader_ID = str("serial = " + v)
            elif k == 'follower_ID':
                self.follower_ID = str("serial = " + v)
            else:
                pass
        f.close()
        ############################

        ##################################################
        # Blocks
        ##################################################
        self.delay = blocks.delay(gr.sizeof_gr_complex * 1, 5)
        self.uhd_usrp_source_0_0 = uhd.usrp_source(
            ",".join((self.follower_ID, "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(2),
            ),
        )
        self.uhd_usrp_source_0_0.set_clock_source("external", 0)
        self.uhd_usrp_source_0_0.set_time_source("external", 0)
        self.uhd_usrp_source_0_0.set_subdev_spec("B:A B:B", 0)
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_center_freq(0, 0)
        self.uhd_usrp_source_0_0.set_gain(0, 0)
        self.uhd_usrp_source_0_0.set_antenna("B:A", 0)
        self.uhd_usrp_source_0_0.set_center_freq(0, 1)
        self.uhd_usrp_source_0_0.set_gain(0, 1)
        self.uhd_usrp_source_0_0.set_antenna("B:B", 1)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join((self.leader_ID, "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(2),
            ),
        )
        self.uhd_usrp_source_0.set_subdev_spec("A:A B:B", 0)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(CF + offset, 0)
        self.uhd_usrp_source_0.set_gain(15, 0)
        self.uhd_usrp_source_0.set_antenna("A:A", 0)
        self.uhd_usrp_source_0.set_bandwidth(25000, 0)
        self.uhd_usrp_source_0.set_center_freq(CF + offset, 1)
        self.uhd_usrp_source_0.set_gain(10, 1)
        self.uhd_usrp_source_0.set_antenna("B:B", 1)
        self.syncwin = MRI.triggered_vector_source_f(
            [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 1.0, 0.0, 1, 1)
        self.sync_data = blocks.vector_sink_c(1)
        self.signal_out = MRI.gated_vector_sink()
        self.s_delay_0_0_0 = blocks.delay(gr.sizeof_float * 1, 5)
        self.s_delay_0_0 = blocks.delay(gr.sizeof_float * 1, 5)
        self.s_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 5)
        self.s_delay = blocks.delay(gr.sizeof_gr_complex * 1, int(slave_delay))
        self.rf_sink = uhd.usrp_sink(
            ",".join((self.leader_ID, "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(2),
            ),
        )
        self.rf_sink.set_subdev_spec("A:AB B:AB", 0)
        self.rf_sink.set_samp_rate(samp_rate)
        self.rf_sink.set_center_freq(CF + offset, 0)
        self.rf_sink.set_gain(0, 0)
        self.rf_sink.set_antenna("A:AB", 0)
        self.rf_sink.set_center_freq(0, 1)
        self.rf_sink.set_gain(0, 1)
        self.rf_sink.set_antenna("B:AB", 1)
        self.ref_pulse = MRI.triggered_vector_source([0, 0, 0], 1.0, 0.0, 1, 1)
        self.readwin = MRI.triggered_vector_source_f([0, 0, 0], 1.0, 0.0, 1, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            3000,  #size
            samp_rate,  #samp_rate
            "",  #name
            4  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(.1)
        self.qtgui_time_sink_x_0.set_y_axis(-.25, .25)

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

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_AUTO,
                                                  qtgui.TRIG_SLOPE_POS, .01, 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 = [
            "Read Window", "Real Signal", "Imag Signal", "RMS", "", "", "", "",
            "", ""
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "black", "blue", "red", "green", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [2, 1, 1, 2, 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(4):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.m_delay = blocks.delay(gr.sizeof_gr_complex * 1,
                                    int(master_delay))
        self.ex_pulse = MRI.triggered_vector_source([0, 0, 0], 1.0, 0.0, 1, 1)
        self.delay6 = blocks.delay(gr.sizeof_float * 1, Gx_delay)
        self.delay3_0_1_0 = blocks.delay(gr.sizeof_float * 1, Gy_delay)
        self.delay3_0_1 = blocks.delay(gr.sizeof_float * 1, Gz_delay)
        self.delay3 = blocks.delay(gr.sizeof_float * 1, readout_delay)
        self.delay1_0 = blocks.delay(gr.sizeof_float * 1, ref_delay)
        self.delay1 = blocks.delay(gr.sizeof_float * 1, ex_delay)
        self.dc_sinc = uhd.usrp_sink(
            ",".join((self.follower_ID, "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(2),
            ),
        )
        self.dc_sinc.set_clock_source("external", 0)
        self.dc_sinc.set_time_source("external", 0)
        self.dc_sinc.set_subdev_spec("B:AB A:AB", 0)
        self.dc_sinc.set_samp_rate(samp_rate)
        self.dc_sinc.set_center_freq(0, 0)
        self.dc_sinc.set_gain(0, 0)
        self.dc_sinc.set_antenna("B:AB", 0)
        self.dc_sinc.set_center_freq(0, 1)
        self.dc_sinc.set_gain(0, 1)
        self.dc_sinc.set_antenna("A:AB", 1)
        self.blocks_threshold_ff_0_2 = blocks.threshold_ff(.000001, .000001, 0)
        self.blocks_threshold_ff_0_1 = blocks.threshold_ff(.05, .05, 0)
        self.blocks_threshold_ff_0_0 = blocks.threshold_ff(.01, .01, 0)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(.01, .01, 0)
        self.blocks_rms_xx_1 = blocks.rms_cf(1)
        self.blocks_rms_xx_0_0 = blocks.rms_cf(1)
        self.blocks_rms_xx_0 = blocks.rms_cf(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_vff((RUN, ))
        self.blocks_multiply_const_vxx_1_0_0 = blocks.multiply_const_vff(
            (gy_on, ))
        self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff(
            (gz_on, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((gx_on, ))
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(10, 1, 4000)
        self.blocks_float_to_complex_2 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_1 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0_1 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0_0_0 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0_0 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_divide_xx_0 = blocks.divide_cc(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_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_xx_1 = blocks.add_vcc(1)
        self.blocks_add_xx_0_0 = blocks.add_vcc(1)
        self.analog_sig_source_x_0_0_0 = analog.sig_source_f(
            samp_rate, analog.GR_SQR_WAVE, 5. / TR, 1, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(
            samp_rate, analog.GR_SQR_WAVE, 1. / TR, 1, 0)
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.Gz = MRI.triggered_vector_source_f([0, 0, 0], 1, 0, 1, 1)
        self.Gy = MRI.triggered_vector_source_f([0, 0, 0], 1, 0, 1, 1)
        self.Gx = MRI.triggered_vector_source_f([0, 0, 0], 1, 0, 1, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.Gx, 0), (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.Gy, 0), (self.blocks_multiply_const_vxx_1_0_0, 0))
        self.connect((self.Gz, 0), (self.blocks_multiply_const_vxx_1_0, 0))
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_const_vxx_2_0, 0))
        self.connect((self.analog_sig_source_x_0_0_0, 0), (self.syncwin, 0))
        self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_add_xx_1, 0))
        self.connect((self.blocks_add_xx_0_0, 0),
                     (self.blocks_complex_to_mag_1, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.delay, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.qtgui_time_sink_x_0, 2))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_threshold_ff_0_1, 0))
        self.connect((self.blocks_complex_to_mag_1, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.blocks_multiply_conjugate_cc_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_add_xx_1, 1))
        self.connect((self.blocks_float_to_complex_0_0, 0), (self.s_delay, 0))
        self.connect((self.blocks_float_to_complex_0_0_0, 0),
                     (self.s_delay, 1))
        self.connect((self.blocks_float_to_complex_0_1, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_float_to_complex_1, 0), (self.sync_data, 0))
        self.connect((self.blocks_float_to_complex_2, 0), (self.m_delay, 1))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_threshold_ff_0_2, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0),
                     (self.blocks_rms_xx_1, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0),
                     (self.signal_out, 1))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.s_delay_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.blocks_float_to_complex_0_0_0, 1))
        self.connect((self.blocks_multiply_const_vxx_1_0_0, 0),
                     (self.blocks_float_to_complex_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.delay1, 0))
        self.connect((self.blocks_multiply_const_vxx_2_0, 0),
                     (self.delay1_0, 0))
        self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.delay3, 0))
        self.connect((self.blocks_multiply_const_vxx_2_0, 0),
                     (self.delay3_0_1, 0))
        self.connect((self.blocks_multiply_const_vxx_2_0, 0),
                     (self.delay3_0_1_0, 0))
        self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.delay6, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_float_to_complex_0_1, 0))
        self.connect((self.blocks_rms_xx_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_rms_xx_0_0, 0),
                     (self.blocks_threshold_ff_0_0, 0))
        self.connect((self.blocks_rms_xx_1, 0), (self.qtgui_time_sink_x_0, 3))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_float_to_complex_1, 0))
        self.connect((self.blocks_threshold_ff_0_0, 0),
                     (self.blocks_float_to_complex_1, 1))
        self.connect((self.blocks_threshold_ff_0_1, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_threshold_ff_0_1, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_threshold_ff_0_1, 0), (self.signal_out, 0))
        self.connect((self.blocks_threshold_ff_0_2, 0),
                     (self.blocks_float_to_complex_2, 0))
        self.connect((self.delay, 0), (self.m_delay, 0))
        self.connect((self.delay1, 0), (self.ex_pulse, 0))
        self.connect((self.delay1_0, 0), (self.ref_pulse, 0))
        self.connect((self.delay3, 0), (self.readwin, 0))
        self.connect((self.delay3_0_1, 0), (self.Gz, 0))
        self.connect((self.delay3_0_1_0, 0), (self.Gy, 0))
        self.connect((self.delay6, 0), (self.Gx, 0))
        self.connect((self.ex_pulse, 0), (self.blocks_add_xx_0_0, 0))
        self.connect((self.m_delay, 0), (self.rf_sink, 0))
        self.connect((self.m_delay, 1), (self.rf_sink, 1))
        self.connect((self.readwin, 0), (self.s_delay_0_0_0, 0))
        self.connect((self.ref_pulse, 0), (self.blocks_add_xx_0_0, 1))
        self.connect((self.s_delay, 0), (self.dc_sinc, 0))
        self.connect((self.s_delay, 1), (self.s_delay_0, 0))
        self.connect((self.s_delay_0, 0), (self.dc_sinc, 1))
        self.connect((self.s_delay_0_0, 0),
                     (self.blocks_float_to_complex_0_0, 1))
        self.connect((self.s_delay_0_0_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.syncwin, 0), (self.blocks_float_to_complex_0_0, 0))
        self.connect((self.syncwin, 0), (self.blocks_float_to_complex_2, 1))
        self.connect((self.uhd_usrp_source_0, 1),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.uhd_usrp_source_0, 1), (self.blocks_divide_xx_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.blocks_multiply_conjugate_cc_0, 0))
        self.connect((self.uhd_usrp_source_0_0, 0), (self.blocks_rms_xx_0, 0))
        self.connect((self.uhd_usrp_source_0_0, 1),
                     (self.blocks_rms_xx_0_0, 0))
Beispiel #19
0
    def __init__(self, fft_size=128):
        gr.top_block.__init__(self, "Holo RX")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Holo RX")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

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

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1000
        self.seconds_record = seconds_record = 7200
        self.label_results_per_second = label_results_per_second = samp_rate / fft_size
        self.label_fftsize = label_fftsize = fft_size
        self.label_binwidth_hz = label_binwidth_hz = samp_rate / fft_size
        self.label_baseband_samp_freq = label_baseband_samp_freq = samp_rate
        self.gui_update_sec = gui_update_sec = 0.2
        self.gain_rxb = gain_rxb = 0
        self.gain_rxa = gain_rxa = 0
        self.freq_rftune = freq_rftune = 70e6
        self.client_address = client_address = "192.168.10.184"

        ##################################################
        # Blocks
        ##################################################
        self.tabs = Qt.QTabWidget()
        self.tabs_widget_0 = Qt.QWidget()
        self.tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                           self.tabs_widget_0)
        self.tabs_grid_layout_0 = Qt.QGridLayout()
        self.tabs_layout_0.addLayout(self.tabs_grid_layout_0)
        self.tabs.addTab(self.tabs_widget_0, 'RX 2 Channels')
        self.top_grid_layout.addWidget(self.tabs, 0, 0, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.zeromq_pull_source_1 = zeromq.pull_source(
            gr.sizeof_gr_complex, 1, 'tcp://192.168.10.184:9998', 100, False,
            -1)
        self.zeromq_pull_source_0 = zeromq.pull_source(
            gr.sizeof_gr_complex, 1, 'tcp://192.168.10.184:9999', 100, False,
            -1)
        self.xmlrpc_client1 = xmlrpclib.Server('http://192.168.10.184:30000')
        self.xmlrpc_client0_0 = xmlrpclib.Server('http://192.168.10.184:30000')
        self.xmlrpc_client0 = xmlrpclib.Server('http://192.168.10.184:30000')
        self.to_mag_db_0_3 = to_mag_db()
        self.to_mag_db_0_1 = to_mag_db()
        self.to_mag_db_0_0 = to_mag_db()
        self.qtgui_number_sink_0_0_0 = qtgui.number_sink(
            gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 2)
        self.qtgui_number_sink_0_0_0.set_update_time(gui_update_sec)
        self.qtgui_number_sink_0_0_0.set_title('Difference A-B')

        labels = [
            'Magnitude (dB)', 'Phase (deg)', 'A - B', '', '', '', '', '', '',
            ''
        ]
        units = ['dB', 'degrees', 'dB', '', '', '', '', '', '', '']
        colors = [("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(2):
            self.qtgui_number_sink_0_0_0.set_min(i, -1)
            self.qtgui_number_sink_0_0_0.set_max(i, 1)
            self.qtgui_number_sink_0_0_0.set_color(i, colors[i][0],
                                                   colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0_0_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0_0_0.set_label(i, labels[i])
            self.qtgui_number_sink_0_0_0.set_unit(i, units[i])
            self.qtgui_number_sink_0_0_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0_0_0.enable_autoscale(False)
        self._qtgui_number_sink_0_0_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0_0_0.pyqwidget(), Qt.QWidget)
        self.tabs_grid_layout_0.addWidget(self._qtgui_number_sink_0_0_0_win, 3,
                                          1, 2, 1)
        for r in range(3, 5):
            self.tabs_grid_layout_0.setRowStretch(r, 1)
        for c in range(1, 2):
            self.tabs_grid_layout_0.setColumnStretch(c, 1)
        self.qtgui_number_sink_0_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                       qtgui.NUM_GRAPH_NONE, 2)
        self.qtgui_number_sink_0_0.set_update_time(gui_update_sec)
        self.qtgui_number_sink_0_0.set_title('Magnitude (dB)')

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

        self.qtgui_number_sink_0_0.enable_autoscale(False)
        self._qtgui_number_sink_0_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget)
        self.tabs_grid_layout_0.addWidget(self._qtgui_number_sink_0_0_win, 1,
                                          1, 2, 1)
        for r in range(1, 3):
            self.tabs_grid_layout_0.setRowStretch(r, 1)
        for c in range(1, 2):
            self.tabs_grid_layout_0.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            fft_size,  #size
            firdes.WIN_HANN,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            2  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(gui_update_sec)
        self.qtgui_freq_sink_x_0.set_y_axis(-160, 0)
        self.qtgui_freq_sink_x_0.set_y_label('FFT Amplitude', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not 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 = ['RXA', 'RXB', 'RXB', '', '', '', '', '', '', '']
        widths = [1, 1, 2, 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.tabs_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0,
                                          1, 2)
        for r in range(0, 1):
            self.tabs_grid_layout_0.setRowStretch(r, 1)
        for c in range(0, 2):
            self.tabs_grid_layout_0.setColumnStretch(c, 1)
        self._label_results_per_second_tool_bar = Qt.QToolBar(self)

        if None:
            self._label_results_per_second_formatter = None
        else:
            self._label_results_per_second_formatter = lambda x: eng_notation.num_to_str(
                x)

        self._label_results_per_second_tool_bar.addWidget(
            Qt.QLabel('FFT Results Per Second ' + ": "))
        self._label_results_per_second_label = Qt.QLabel(
            str(
                self._label_results_per_second_formatter(
                    self.label_results_per_second)))
        self._label_results_per_second_tool_bar.addWidget(
            self._label_results_per_second_label)
        self.top_grid_layout.addWidget(self._label_results_per_second_tool_bar,
                                       4, 0, 1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._label_fftsize_tool_bar = Qt.QToolBar(self)

        if None:
            self._label_fftsize_formatter = None
        else:
            self._label_fftsize_formatter = lambda x: str(x)

        self._label_fftsize_tool_bar.addWidget(Qt.QLabel('FFT Size' + ": "))
        self._label_fftsize_label = Qt.QLabel(
            str(self._label_fftsize_formatter(self.label_fftsize)))
        self._label_fftsize_tool_bar.addWidget(self._label_fftsize_label)
        self.top_grid_layout.addWidget(self._label_fftsize_tool_bar, 2, 0, 1,
                                       1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._label_binwidth_hz_tool_bar = Qt.QToolBar(self)

        if None:
            self._label_binwidth_hz_formatter = None
        else:
            self._label_binwidth_hz_formatter = lambda x: eng_notation.num_to_str(
                x)

        self._label_binwidth_hz_tool_bar.addWidget(
            Qt.QLabel('FFT Bin Width (Hz) ' + ": "))
        self._label_binwidth_hz_label = Qt.QLabel(
            str(self._label_binwidth_hz_formatter(self.label_binwidth_hz)))
        self._label_binwidth_hz_tool_bar.addWidget(
            self._label_binwidth_hz_label)
        self.top_grid_layout.addWidget(self._label_binwidth_hz_tool_bar, 3, 0,
                                       1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._label_baseband_samp_freq_tool_bar = Qt.QToolBar(self)

        if None:
            self._label_baseband_samp_freq_formatter = None
        else:
            self._label_baseband_samp_freq_formatter = lambda x: eng_notation.num_to_str(
                x)

        self._label_baseband_samp_freq_tool_bar.addWidget(
            Qt.QLabel('Baseband Sample Frequency (Hz)' + ": "))
        self._label_baseband_samp_freq_label = Qt.QLabel(
            str(
                self._label_baseband_samp_freq_formatter(
                    self.label_baseband_samp_freq)))
        self._label_baseband_samp_freq_tool_bar.addWidget(
            self._label_baseband_samp_freq_label)
        self.top_grid_layout.addWidget(self._label_baseband_samp_freq_tool_bar,
                                       1, 0, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._gain_rxb_range = Range(0, 80, 1, 0, 1)
        self._gain_rxb_win = RangeWidget(self._gain_rxb_range,
                                         self.set_gain_rxb, 'Gain RXB',
                                         "counter", float)
        self.tabs_grid_layout_0.addWidget(self._gain_rxb_win, 2, 0, 1, 1)
        for r in range(2, 3):
            self.tabs_grid_layout_0.setRowStretch(r, 1)
        for c in range(0, 1):
            self.tabs_grid_layout_0.setColumnStretch(c, 1)
        self._gain_rxa_range = Range(0, 80, 1, 0, 1)
        self._gain_rxa_win = RangeWidget(self._gain_rxa_range,
                                         self.set_gain_rxa, 'Gain RXA',
                                         "counter", float)
        self.tabs_grid_layout_0.addWidget(self._gain_rxa_win, 1, 0, 1, 1)
        for r in range(1, 2):
            self.tabs_grid_layout_0.setRowStretch(r, 1)
        for c in range(0, 1):
            self.tabs_grid_layout_0.setColumnStretch(c, 1)
        self._freq_rftune_range = Range(10e6, 6e9, 1, 70e6, 1)
        self._freq_rftune_win = RangeWidget(self._freq_rftune_range,
                                            self.set_freq_rftune,
                                            'Freq RF Tune', "counter", float)
        self.tabs_grid_layout_0.addWidget(self._freq_rftune_win, 3, 0, 1, 1)
        for r in range(3, 4):
            self.tabs_grid_layout_0.setRowStretch(r, 1)
        for c in range(0, 1):
            self.tabs_grid_layout_0.setColumnStretch(c, 1)
        self.fft_bin_select_B = fft_bin_select(
            fft_size=fft_size,
            nskip=1,
        )
        self.fft_bin_select_A = fft_bin_select(
            fft_size=fft_size,
            nskip=1,
        )
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (180 / np.pi, ))
        self.blocks_head_0 = blocks.head(
            gr.sizeof_gr_complex * 1,
            int(seconds_record * samp_rate / fft_size))
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1,
                                                   'test2hrs.iq', False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_divide_xx_0 = blocks.divide_cc(1)
        self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_arg_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.blocks_complex_to_arg_0, 0))
        self.connect((self.blocks_divide_xx_0, 0), (self.blocks_head_0, 0))
        self.connect((self.blocks_divide_xx_0, 0), (self.to_mag_db_0_3, 0))
        self.connect((self.blocks_head_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_number_sink_0_0_0, 1))
        self.connect((self.blocks_throttle_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.fft_bin_select_A, 0), (self.blocks_divide_xx_0, 0))
        self.connect((self.fft_bin_select_A, 0), (self.to_mag_db_0_0, 0))
        self.connect((self.fft_bin_select_B, 0), (self.blocks_divide_xx_0, 1))
        self.connect((self.fft_bin_select_B, 0), (self.to_mag_db_0_1, 0))
        self.connect((self.to_mag_db_0_0, 0), (self.qtgui_number_sink_0_0, 0))
        self.connect((self.to_mag_db_0_1, 0), (self.qtgui_number_sink_0_0, 1))
        self.connect((self.to_mag_db_0_3, 0),
                     (self.qtgui_number_sink_0_0_0, 0))
        self.connect((self.zeromq_pull_source_0, 0),
                     (self.fft_bin_select_B, 0))
        self.connect((self.zeromq_pull_source_0, 0),
                     (self.qtgui_freq_sink_x_0, 1))
        self.connect((self.zeromq_pull_source_1, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.zeromq_pull_source_1, 0),
                     (self.fft_bin_select_A, 0))
Beispiel #20
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.occupied_carriers = occupied_carriers = (
            range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) +
            range(8, 21) + range(22, 27), )
        self.sync_word_zeros = sync_word_zeros = [
            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, 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, 0, 0, 0, 0
        ]
        self.sync_word = sync_word = [
            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.pilot_symbols = pilot_symbols = ((
            1,
            1,
            1,
            -1,
        ), )
        self.pilot_carriers = pilot_carriers = ((
            -21,
            -7,
            7,
            21,
        ), )
        self.packet_len = packet_len = 80 - 48
        self.occupied_carriers_len = occupied_carriers_len = len(
            occupied_carriers[0])
        self.variable_function_probe_0_2 = variable_function_probe_0_2 = 0
        self.variable_function_probe_0_1_0 = variable_function_probe_0_1_0 = 0
        self.variable_function_probe_0_0_1 = variable_function_probe_0_0_1 = 0
        self.variable_function_probe_0_0_0_0 = variable_function_probe_0_0_0_0 = 0
        self.usrp_source_addr = usrp_source_addr = "addr0=192.168.30.4"
        self.usrp_sink_addr = usrp_sink_addr = "addr0=192.168.30.4"
        self.sync_word_zero_len = sync_word_zero_len = len(sync_word_zeros)
        self.sync_word_len = sync_word_len = len(sync_word)
        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.symbols_num = symbols_num = (
            packet_len + 4) * 8 / 2 / occupied_carriers_len + 3
        self.samp_rate = samp_rate = 1e6
        self.qf_1 = qf_1 = 0
        self.qf_0 = qf_0 = 0
        self.pilot_symbols_len = pilot_symbols_len = len(pilot_symbols[0])
        self.pilot_carriers_len = pilot_carriers_len = len(pilot_carriers[0])
        self.pad_tail_len = pad_tail_len = 1000
        self.pad_front_len = pad_front_len = 20000 * 2
        self.out_buf_size = out_buf_size = 96000
        self.len_tag_key = len_tag_key = "packet_len"
        self.freq = freq = 950e6
        self.frame_len = frame_len = (
            (packet_len + 4) / 12 + 3 + 2 + 2 + 2 * 2) * 80
        self.fft_len = fft_len = 64
        self.delay_tx2rx = delay_tx2rx = 50
        self.dac_2 = dac_2 = 0
        self.dac_1 = dac_1 = 0
        self.dac_0 = dac_0 = 0
        self.cf_1 = cf_1 = 0
        self.cf_0 = cf_0 = 0
        self.cap_2 = cap_2 = 0
        self.cap_1 = cap_1 = 0
        self.cap_0 = cap_0 = 0
        self.canc_path = canc_path = 0
        self.att_2 = att_2 = 0
        self.att_1 = att_1 = 0
        self.att_0 = att_0 = 0

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source = uhd.usrp_source(
            ",".join((usrp_source_addr, "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source.set_samp_rate(samp_rate)
        self.uhd_usrp_source.set_center_freq(freq, 0)
        self.uhd_usrp_source.set_gain(15, 0)
        self.uhd_usrp_source.set_antenna('RX2', 0)
        self.uhd_usrp_source.set_auto_dc_offset(True, 0)
        self.uhd_usrp_source.set_auto_iq_balance(True, 0)
        self.uhd_usrp_sink = uhd.usrp_sink(
            ",".join((usrp_sink_addr, "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink.set_samp_rate(samp_rate)
        self.uhd_usrp_sink.set_center_freq(freq, 0)
        self.uhd_usrp_sink.set_gain(0, 0)
        self.uhd_usrp_sink.set_antenna('TX/RX', 0)
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, 'Rx Packets')
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, 'Rx Signal Spectr')
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, 'Estimated Digital Taps')
        self.tab_widget_3 = Qt.QWidget()
        self.tab_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_3)
        self.tab_grid_layout_3 = Qt.QGridLayout()
        self.tab_layout_3.addLayout(self.tab_grid_layout_3)
        self.tab.addTab(self.tab_widget_3, 'Sync b/w Two Radios')
        self.tab_widget_4 = Qt.QWidget()
        self.tab_layout_4 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_4)
        self.tab_grid_layout_4 = Qt.QGridLayout()
        self.tab_layout_4.addLayout(self.tab_grid_layout_4)
        self.tab.addTab(self.tab_widget_4, 'SI Channel')
        self.top_grid_layout.addWidget(self.tab, 0, 0, 1, 3)
        self._delay_tx2rx_range = Range(0, 100, 1, 50, 200)
        self._delay_tx2rx_win = RangeWidget(self._delay_tx2rx_range,
                                            self.set_delay_tx2rx,
                                            "delay_tx2rx", "counter_slider",
                                            int)
        self.top_grid_layout.addWidget(self._delay_tx2rx_win, 7, 0, 1, 3)

        def _variable_function_probe_0_2_probe():
            while True:
                val = self.uhd_usrp_sink.set_time_now(uhd.time_spec_t(0.0))
                try:
                    self.set_variable_function_probe_0_2(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (1e-9))

        _variable_function_probe_0_2_thread = threading.Thread(
            target=_variable_function_probe_0_2_probe)
        _variable_function_probe_0_2_thread.daemon = True
        _variable_function_probe_0_2_thread.start()

        def _variable_function_probe_0_1_0_probe():
            while True:
                val = self.uhd_usrp_source.set_time_now(uhd.time_spec_t(0.0))
                try:
                    self.set_variable_function_probe_0_1_0(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (1e-9))

        _variable_function_probe_0_1_0_thread = threading.Thread(
            target=_variable_function_probe_0_1_0_probe)
        _variable_function_probe_0_1_0_thread.daemon = True
        _variable_function_probe_0_1_0_thread.start()

        def _variable_function_probe_0_0_1_probe():
            while True:
                val = self.uhd_usrp_sink.set_start_time(uhd.time_spec_t(1.0))
                try:
                    self.set_variable_function_probe_0_0_1(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (1e-9))

        _variable_function_probe_0_0_1_thread = threading.Thread(
            target=_variable_function_probe_0_0_1_probe)
        _variable_function_probe_0_0_1_thread.daemon = True
        _variable_function_probe_0_0_1_thread.start()

        def _variable_function_probe_0_0_0_0_probe():
            while True:
                val = self.uhd_usrp_source.set_start_time(uhd.time_spec_t(1.0))
                try:
                    self.set_variable_function_probe_0_0_0_0(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (1e-9))

        _variable_function_probe_0_0_0_0_thread = threading.Thread(
            target=_variable_function_probe_0_0_0_0_probe)
        _variable_function_probe_0_0_0_0_thread.daemon = True
        _variable_function_probe_0_0_0_0_thread.start()

        self.sub20fde_fde_config_0 = sub20fde.fde_config(0, 0, '5647')
        self.qtgui_time_sink_x_1 = qtgui.time_sink_c(
            21 * 1,  #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(-1, True)
        self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_TAG,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "packet_len")
        self.qtgui_time_sink_x_1.enable_autoscale(False)
        self.qtgui_time_sink_x_1.enable_grid(False)
        self.qtgui_time_sink_x_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_1.enable_control_panel(True)

        if not True:
            self.qtgui_time_sink_x_1.disable_legend()

        labels = [
            "Digital Canc. Tap - I", "Digital Canc. Tap - Q", '', '', '', '',
            '', '', '', ''
        ]
        widths = [2, 2, 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 = [0, 0, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2):
            if len(labels[i]) == 0:
                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.tab_layout_2.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_time_sink_x_0_0_0_1 = qtgui.time_sink_c(
            80,  #size
            samp_rate,  #samp_rate
            'Scope Plot',  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_0_0_0_1.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0_0_1.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0_0_0_1.disable_legend()

        labels = [
            "SI after Circ. + RF Canc. - I", "SI after Circ. + RF Canc. - Q",
            "SI after Circ. + RF Canc. + Digital Canc. - I",
            "SI after Circ. + RF Canc. + Digital Canc. - Q", '', '', '', '',
            '', ''
        ]
        widths = [2, 2, 2, 2, 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(4):
            if len(labels[i]) == 0:
                if (i % 2 == 0):
                    self.qtgui_time_sink_x_0_0_0_1.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_0_0_0_1.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            else:
                self.qtgui_time_sink_x_0_0_0_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0_0_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0_0_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0_0_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0_0_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_0_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget)
        self.tab_layout_3.addWidget(self._qtgui_time_sink_x_0_0_0_1_win)
        self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_c(
            frame_len,  #size
            samp_rate,  #samp_rate
            'Scope Plot',  #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(-1, 1)

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

        self.qtgui_time_sink_x_0_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_TAG,
                                                      qtgui.TRIG_SLOPE_POS,
                                                      0.0, 0, 0, "packet_len")
        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 = [
            "SI after Circ. + RF Canc. - I", "SI after Circ. + RF Canc. - Q",
            "SI after Circ. + RF Canc. + Digital Canc. - I",
            "SI after Circ. + RF Canc. + Digital Canc. - Q", '', '', '', '',
            '', ''
        ]
        widths = [2, 2, 2, 2, 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(4):
            if len(labels[i]) == 0:
                if (i % 2 == 0):
                    self.qtgui_time_sink_x_0_0_0.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_0_0_0.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            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.tab_layout_0.addWidget(self._qtgui_time_sink_x_0_0_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            64,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_4.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c(
            1024 * 3,  #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(-120, 0)
        self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_1.enable_autoscale(False)
        self.qtgui_freq_sink_x_1.enable_grid(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(True)

        if not True:
            self.qtgui_freq_sink_x_1.disable_legend()

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

        labels = [
            "SI after Circ. + RF Canc.", "SI after Circ. + RF + Digital Canc.",
            '', '', '', '', '', '', '', ''
        ]
        widths = [2, 2, 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_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_1_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget)
        self.tab_layout_1.addWidget(self._qtgui_freq_sink_x_1_win)
        self._qf_1_range = Range(0, 31, 1, 0, 200)
        self._qf_1_win = RangeWidget(self._qf_1_range, self.set_qf_1, "qf_1",
                                     "counter_slider", int)
        self.top_grid_layout.addWidget(self._qf_1_win, 3, 1, 1, 1)
        self._qf_0_range = Range(0, 31, 1, 0, 200)
        self._qf_0_win = RangeWidget(self._qf_0_range, self.set_qf_0, "qf_0",
                                     "counter_slider", int)
        self.top_grid_layout.addWidget(self._qf_0_win, 3, 0, 1, 1)
        self.fullduplex_parse_stream_sync_1 = fullduplex.parse_stream_sync(
            False, delay_tx2rx, pad_front_len, 320)
        (self.fullduplex_parse_stream_sync_1).set_min_output_buffer(96000)
        self.fullduplex_packet_encap2_0 = fullduplex.packet_encap2(
            False, False, 0.001, pad_front_len, pad_tail_len, 0)
        (self.fullduplex_packet_encap2_0).set_min_output_buffer(96000)
        self.fullduplex_digital_sic_0 = fullduplex.digital_sic(
            False, delay_tx2rx, pad_front_len, 0, frame_len, 10, 1)
        (self.fullduplex_digital_sic_0).set_min_output_buffer(96000)
        self.fft_vxx_0_0 = fft.fft_vcc(64, True, (window.blackmanharris(64)),
                                       True, 1)
        self.fft_vxx_0 = fft.fft_vcc(64, True, (window.blackmanharris(64)),
                                     True, 1)
        self.digital_ofdm_tx_0_0 = digital.ofdm_tx(
            fft_len=fft_len,
            cp_len=fft_len / 4,
            packet_length_tag_key=len_tag_key,
            occupied_carriers=occupied_carriers,
            pilot_carriers=pilot_carriers,
            pilot_symbols=pilot_symbols,
            sync_word1=sync_word1,
            sync_word2=sync_word2,
            bps_header=1,
            bps_payload=2,
            rolloff=0,
            debug_log=False,
            scramble_bits=False)
        self._dac_2_range = Range(0, 255, 1, 0, 200)
        self._dac_2_win = RangeWidget(self._dac_2_range, self.set_dac_2,
                                      "dac_2", "counter_slider", int)
        self.top_grid_layout.addWidget(self._dac_2_win, 5, 2, 1, 1)
        self._dac_1_range = Range(0, 255, 1, 0, 200)
        self._dac_1_win = RangeWidget(self._dac_1_range, self.set_dac_1,
                                      "dac_1", "counter_slider", int)
        self.top_grid_layout.addWidget(self._dac_1_win, 5, 1, 1, 1)
        self._dac_0_range = Range(0, 255, 1, 0, 200)
        self._dac_0_win = RangeWidget(self._dac_0_range, self.set_dac_0,
                                      "dac_0", "counter_slider", int)
        self.top_grid_layout.addWidget(self._dac_0_win, 5, 0, 1, 1)
        self._cf_1_range = Range(0, 15, 1, 0, 200)
        self._cf_1_win = RangeWidget(self._cf_1_range, self.set_cf_1, "cf_1",
                                     "counter_slider", int)
        self.top_grid_layout.addWidget(self._cf_1_win, 2, 1, 1, 1)
        self._cf_0_range = Range(0, 15, 1, 0, 200)
        self._cf_0_win = RangeWidget(self._cf_0_range, self.set_cf_0, "cf_0",
                                     "counter_slider", int)
        self.top_grid_layout.addWidget(self._cf_0_win, 2, 0, 1, 1)
        self._cap_2_range = Range(0, 15, 1, 0, 200)
        self._cap_2_win = RangeWidget(self._cap_2_range, self.set_cap_2,
                                      "cap_2", "counter_slider", int)
        self.top_grid_layout.addWidget(self._cap_2_win, 1, 2, 1, 1)
        self._cap_1_range = Range(0, 15, 1, 0, 200)
        self._cap_1_win = RangeWidget(self._cap_1_range, self.set_cap_1,
                                      "cap_1", "counter_slider", int)
        self.top_grid_layout.addWidget(self._cap_1_win, 1, 1, 1, 1)
        self._cap_0_range = Range(0, 15, 1, 0, 200)
        self._cap_0_win = RangeWidget(self._cap_0_range, self.set_cap_0,
                                      "cap_0", "counter_slider", int)
        self.top_grid_layout.addWidget(self._cap_0_win, 1, 0, 1, 1)
        self._canc_path_range = Range(0, 1, 1, 0, 200)
        self._canc_path_win = RangeWidget(self._canc_path_range,
                                          self.set_canc_path, "canc_path",
                                          "counter_slider", int)
        self.top_grid_layout.addWidget(self._canc_path_win, 6, 0, 1, 3)
        self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, 64)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, 64)
        self.blocks_vector_source_x_0 = blocks.vector_source_b(
            range(50), True, 1, ())
        self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 64)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 64)
        self.blocks_stream_to_tagged_stream_1 = blocks.stream_to_tagged_stream(
            gr.sizeof_gr_complex, 1, frame_len + pad_front_len + pad_tail_len,
            "packet_len")
        (self.blocks_stream_to_tagged_stream_1).set_min_output_buffer(96000)
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, packet_len, "packet_len")
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(20, 1, 0)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(
            (0.01 * 2.23 * 0.56 * 1.4 * 1.4, ))
        self.blocks_divide_xx_0 = blocks.divide_cc(1)
        self.blocks_complex_to_magphase_0 = blocks.complex_to_magphase(1)
        self._att_2_range = Range(0, 127, 1, 0, 200)
        self._att_2_win = RangeWidget(self._att_2_range, self.set_att_2,
                                      "att_2", "counter_slider", int)
        self.top_grid_layout.addWidget(self._att_2_win, 4, 2, 1, 1)
        self._att_1_range = Range(0, 127, 1, 0, 200)
        self._att_1_win = RangeWidget(self._att_1_range, self.set_att_1,
                                      "att_1", "counter_slider", int)
        self.top_grid_layout.addWidget(self._att_1_win, 4, 1, 1, 1)
        self._att_0_range = Range(0, 127, 1, 0, 200)
        self._att_0_win = RangeWidget(self._att_0_range, self.set_att_0,
                                      "att_0", "counter_slider", int)
        self.top_grid_layout.addWidget(self._att_0_win, 4, 0, 1, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_magphase_0, 0),
                     (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_complex_to_magphase_0, 1),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.blocks_complex_to_magphase_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.fullduplex_packet_encap2_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0),
                     (self.digital_ofdm_tx_0_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_1, 0),
                     (self.fullduplex_digital_sic_0, 1))
        self.connect((self.blocks_stream_to_tagged_stream_1, 0),
                     (self.fullduplex_parse_stream_sync_1, 1))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_stream_to_vector_0_0, 0),
                     (self.fft_vxx_0_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_vector_to_stream_0_0, 0),
                     (self.blocks_divide_xx_0, 0))
        self.connect((self.digital_ofdm_tx_0_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.fft_vxx_0_0, 0),
                     (self.blocks_vector_to_stream_0_0, 0))
        self.connect((self.fullduplex_digital_sic_0, 0),
                     (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.fullduplex_digital_sic_0, 1),
                     (self.qtgui_freq_sink_x_1, 1))
        self.connect((self.fullduplex_digital_sic_0, 0),
                     (self.qtgui_time_sink_x_0_0_0, 0))
        self.connect((self.fullduplex_digital_sic_0, 1),
                     (self.qtgui_time_sink_x_0_0_0, 1))
        self.connect((self.fullduplex_digital_sic_0, 2),
                     (self.qtgui_time_sink_x_1, 0))
        self.connect((self.fullduplex_packet_encap2_0, 0),
                     (self.fullduplex_digital_sic_0, 0))
        self.connect((self.fullduplex_packet_encap2_0, 0),
                     (self.fullduplex_parse_stream_sync_1, 0))
        self.connect((self.fullduplex_packet_encap2_0, 0),
                     (self.uhd_usrp_sink, 0))
        self.connect((self.fullduplex_parse_stream_sync_1, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.fullduplex_parse_stream_sync_1, 1),
                     (self.blocks_stream_to_vector_0_0, 0))
        self.connect((self.fullduplex_parse_stream_sync_1, 0),
                     (self.qtgui_time_sink_x_0_0_0_1, 0))
        self.connect((self.fullduplex_parse_stream_sync_1, 1),
                     (self.qtgui_time_sink_x_0_0_0_1, 1))
        self.connect((self.uhd_usrp_source, 0),
                     (self.blocks_stream_to_tagged_stream_1, 0))
import gnuradio
from gnuradio import gr
from gnuradio import blocks as grblocks
import sys

if __name__ == '__main__':

    duration = float(sys.argv[1])

    tb = gr.top_block()
    src = gr.null_source(8)
    b0 = gr.copy(8)
    b1 = grblocks.sub_cc()
    b2 = gr.copy(8)
    b3 = grblocks.divide_cc()
    b4 = gr.copy(8)
    sink = gr.null_sink(8)

    tb.connect(src, b0, b1, b2, b3, b4, sink)

    import time
    tb.start()
    time.sleep(duration)
    print '##RESULT##', sink.nitems_read(0)/duration
    import sys; sys.stdout.flush()
    tb.stop()
    tb.wait()