Ejemplo n.º 1
0
    def __init__(self):
        gr.top_block.__init__(self, "Scanner Grc")

        ##################################################
        # Variables
        ##################################################
        self.f_symb = f_symb = 1625000.0/6.0
        self.f_900_b = f_900_b = 921.2e6
        self.samp_rate = samp_rate = f_symb*4
        self.fs = fs = f_900_b
        self.f_900_e = f_900_e = 959.8e6
        self.f_1800_e = f_1800_e = 1879.8e6
        self.f_1800_b = f_1800_b = 1805.2e6
        self.OSR = OSR = 4

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "bladerf=0" )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(fs, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(2, 0)
        self.osmosdr_source_0.set_gain_mode(True, 0)
        self.osmosdr_source_0.set_gain(30, 0)
        self.osmosdr_source_0.set_if_gain(30, 0)
        self.osmosdr_source_0.set_bb_gain(30, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(200000, 0)
          
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate, 200e3, 10e3, firdes.WIN_HAMMING, 6.76))
        self.threshold_result = blocks.threshold_ff(0, 0.2, 0)
        self.blocks_threshold_ff_0_0 = blocks.threshold_ff(0, 0, 0)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(int((138)*samp_rate/f_symb), int((138)*samp_rate/f_symb), 0)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1)
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(int((142)*samp_rate/f_symb), 1, int(1e6))
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, int(OSR))
        self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_threshold_ff_0_0, 0))    
        self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 1))    
        self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_threshold_ff_0, 0))    
        self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_arg_0, 0))    
        self.connect((self.blocks_threshold_ff_0, 0), (self.threshold_result, 0))    
        self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_moving_average_xx_0, 0))    
        self.connect((self.threshold_result, 0), (self.blocks_null_sink_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.blocks_delay_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.blocks_multiply_conjugate_cc_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.low_pass_filter_0, 0))    
Ejemplo n.º 2
0
    def __init__(self, OSR=4):
        grgsm.hier_block.__init__(
            self,
            "FCCH bursts detector",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.OSR = OSR

        ##################################################
        # Variables
        ##################################################
        self.f_symb = f_symb = 1625000.0 / 6.0
        self.samp_rate = samp_rate = f_symb * OSR

        ##################################################
        # Blocks
        ##################################################
        self.gsm_fcch_burst_tagger_0 = grgsm.fcch_burst_tagger(OSR)
        self.blocks_threshold_ff_0_0 = blocks.threshold_ff(0, 0, 0)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(
            int((138) * samp_rate / f_symb), int((138) * samp_rate / f_symb),
            0)
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            int((142) * samp_rate / f_symb), 1, int(1e6))
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, int(OSR))
        self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self, 0), (self.blocks_multiply_conjugate_cc_0, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_multiply_conjugate_cc_0, 1))
        self.connect((self.blocks_complex_to_arg_0, 0),
                     (self.blocks_threshold_ff_0_0, 0))
        self.connect((self, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0),
                     (self.blocks_complex_to_arg_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_threshold_ff_0_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.gsm_fcch_burst_tagger_0, 0), (self, 0))
        self.connect((self, 0), (self.gsm_fcch_burst_tagger_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.gsm_fcch_burst_tagger_0, 1))
Ejemplo n.º 3
0
    def __init__(self, alpha=0.0001, threshold_db=-10, gate=False):
        gr.hier_block2.__init__(
            self,
            "standard_squelch",
            gr.io_signature(1, 1, gr.sizeof_float),  # Input signature
            gr.io_signature(1, 1, gr.sizeof_float))  # Output signature

        #fixed coeffs, Chebyshev type 2 LPF=[0, 0.4, 0.7], HPF=[0.4, 0.7, 1]
        self.low_iir = iir_filter_ffd([
            0.12260106307699403, -0.22058023529806434, 0.22058023529806436,
            -0.12260106307699434
        ], [
            1.00000000000000000, 0.7589332900264623, 0.5162740252200005,
            0.07097813844342238
        ], False)
        self.low_square = blocks.multiply_ff()
        self.low_smooth = single_pole_iir_filter_ff(alpha)

        self.hi_iir = iir_filter_ffd([
            0.1913118666668073, 0.4406071020350289, 0.4406071020350288,
            0.19131186666680736
        ], [
            1.000000000000000000, -0.11503633296078866, 0.3769676347066441,
            0.0019066356578167866
        ], False)
        self.hi_square = blocks.multiply_ff()
        self.hi_smooth = single_pole_iir_filter_ff(alpha)

        #inverted thresholds because we reversed the division block inputs
        #to make the threshold output 1 when open and 0 when closed
        self.gate = blocks.threshold_ff(0, 0, 0)
        self.set_threshold(threshold_db)
        self.squelch_lpf = single_pole_iir_filter_ff(alpha)
        self.squelch_mult = blocks.multiply_ff()
        self.div = blocks.divide_ff()

        #This is horrible, but there's no better way to gate samples.
        #the block is fast, so realistically there's little overhead
        #TODO: implement a valve block that gates based on an input value
        self.valve = analog.pwr_squelch_ff(-100, 1, 0, gate)

        #sample path
        self.connect(self, (self.squelch_mult, 0))

        #filter path (LPF)
        self.connect(self, self.low_iir)
        self.connect(self.low_iir, (self.low_square, 0))
        self.connect(self.low_iir, (self.low_square, 1))
        self.connect(self.low_square, self.low_smooth, (self.div, 0))

        #filter path (HPF)
        self.connect(self, self.hi_iir)
        self.connect(self.hi_iir, (self.hi_square, 0))
        self.connect(self.hi_iir, (self.hi_square, 1))
        self.connect(self.hi_square, self.hi_smooth, (self.div, 1))

        #control path
        self.connect(self.div, self.gate, self.squelch_lpf,
                     (self.squelch_mult, 1))
        self.connect(self.squelch_mult, self)
Ejemplo n.º 4
0
    def __init__(self, freq_sample_delay_samps, freq_samps_to_avg,
                 mag_samps_to_avg, thresh):
        gr.hier_block2.__init__(
            self, "Sample and Hold Detector",
            gr.io_signaturev(2, 2, [gr.sizeof_float * 1, gr.sizeof_float * 1]),
            gr.io_signaturev(4, 4, [
                gr.sizeof_float * 1, gr.sizeof_float * 1, gr.sizeof_float * 1,
                gr.sizeof_float * 1
            ]))
        '''
        Constructor
        
        @param freq_sample_delay_samps - 
        @param freq_samps_to_avg - 
        @param mag_samps_to_avg - 
        @param thresh - 
        
        '''

        ##################################################
        # Parameters
        ##################################################
        self.freq_sample_delay_samps = freq_sample_delay_samps
        self.freq_samps_to_avg = freq_samps_to_avg
        self.mag_samps_to_avg = mag_samps_to_avg
        self.thresh = thresh

        ##################################################
        # Blocks
        ##################################################
        self.edge_detector = timing_utils.edge_detector_bb(
            timing_utils.RISING_EDGE)
        self.threshold = blocks.threshold_ff(thresh / 4.0, thresh, 0)
        self.samp_hold = blocks.sample_and_hold_ff()
        self.mag_avg = blocks.moving_average_ff(int(mag_samps_to_avg),
                                                1.0 / (mag_samps_to_avg), 4000)
        self.freq_avg = blocks.moving_average_ff(int(freq_samps_to_avg),
                                                 1.0 / (freq_samps_to_avg),
                                                 4000)
        self.f2c = blocks.float_to_char(1, 1)
        self.delay = blocks.delay(
            gr.sizeof_float * 1,
            int(freq_samps_to_avg - mag_samps_to_avg +
                freq_sample_delay_samps))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.delay, 0), (self.mag_avg, 0))
        self.connect((self.f2c, 0), (self.edge_detector, 0))
        self.connect((self.freq_avg, 0), (self.samp_hold, 0))
        self.connect((self.freq_avg, 0), (self, 1))
        self.connect((self.mag_avg, 0), (self.threshold, 0))
        self.connect((self.mag_avg, 0), (self, 3))
        self.connect((self.samp_hold, 0), (self, 0))
        self.connect((self.threshold, 0), (self.f2c, 0))
        self.connect((self.threshold, 0), (self, 2))
        self.connect((self, 0), (self.delay, 0))
        self.connect((self, 1), (self.freq_avg, 0))
        self.connect((self.edge_detector, 0), (self.samp_hold, 1))
Ejemplo n.º 5
0
    def __init__(self, src="uhd", dst="uhd", in_rate=2e6, out_rate=2e6, extra=None):
        super(tag_emulate, self).__init__()

        uhd = dst == "uhd"

        if uhd:
            dst = None

        self._bin_src = binary_src.binary_src(out_rate, encode="manchester", idle_bit=0)

        parser = Parser(extra)
        self._tag = parser.get_tag(self._bin_src.set_bits)

        # Do not record here
        self._dec = decoder.decoder(src=src, dst=None, reader=True, tag=False, samp_rate=in_rate, emulator=self._tag)
        self.connect(self._dec)

        
        self._mult = multiplier.multiplier(samp_rate=out_rate)
        self.connect(self._bin_src, self._mult)
        if uhd:
            # active load modulation
            self._real = blocks.complex_to_real(1)     
            self._thres = blocks.threshold_ff(0.02, 0.1, 0)
            self._r2c = blocks.float_to_complex(1)
            
            self._sink = usrp_sink.usrp_sink(out_rate)
            self.connect(self._mult, self._real, self._thres, self._r2c, self._sink)
        elif dst:   
            self._sink = record.record(dst, out_rate)
            self.connect(self._mult, self._sink)
        else:
            self._sink = blocks.null_sink(gr.sizeof_gr_complex)
            self.connect(self._mult, self._sink)
Ejemplo n.º 6
0
    def __init__(self, OSR=4):
        gr.hier_block2.__init__(
            self,
            "FCCH bursts detector",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.OSR = OSR

        ##################################################
        # Variables
        ##################################################
        self.f_symb = f_symb = 1625000.0 / 6.0
        self.samp_rate = samp_rate = f_symb * OSR

        ##################################################
        # Blocks
        ##################################################
        self.gsm_fcch_burst_tagger_0 = grgsm.fcch_burst_tagger(OSR)
        self.blocks_threshold_ff_0_0 = blocks.threshold_ff(0, 0, 0)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(
            int((138) * samp_rate / f_symb), int((138) * samp_rate / f_symb), 0
        )
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(int((142) * samp_rate / f_symb), 1, int(1e6))
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, int(OSR))
        self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self, 0), (self.blocks_multiply_conjugate_cc_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 1))
        self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_threshold_ff_0_0, 0))
        self.connect((self, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_arg_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_moving_average_xx_0, 0))
        self.connect((self.gsm_fcch_burst_tagger_0, 0), (self, 0))
        self.connect((self, 0), (self.gsm_fcch_burst_tagger_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0), (self.gsm_fcch_burst_tagger_0, 1))
class top_block(gr.top_block):

    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1e6
		self.center_freq = center_freq = 433.92e6
		self.jamming_freq = jamming_freq = 433.85e6
		self.cutoff_freq = cutoff_freq = 50e3
		self.output_file = output_file = 'signal.raw'

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

        self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + '' )
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(center_freq, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(40, 0)
        self.osmosdr_sink_0.set_if_gain(20, 0)
        self.osmosdr_sink_0.set_bb_gain(20, 0)
        self.osmosdr_sink_0.set_antenna('', 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)

        self.custom_file_sink = custom_file_sink.blk(sink=output_file)
        self.blocks_threshold_ff_0_0 = blocks.threshold_ff(4e-3, 4e-3, 0)
        self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared(1)
        self.band_pass_filter_0 = filter.fir_filter_ccf(1, firdes.band_pass(
        	1, samp_rate, 1, cutoff_freq, 5e3, firdes.WIN_HAMMING, 6.76))
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, jamming_freq - center_freq, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.custom_file_sink, 0))
        self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_mag_squared_0_0, 0))
        self.connect((self.band_pass_filter_0, 0), (self.custom_file_sink, 1))
        self.connect((self.blocks_complex_to_mag_squared_0_0, 0), (self.blocks_threshold_ff_0_0, 0))
        self.connect((self.blocks_threshold_ff_0_0, 0), (self.custom_file_sink, 2))
        self.connect((self.custom_file_sink, 0), (self.osmosdr_sink_0, 0))
        self.connect((self.osmosdr_source_0_0, 0), (self.band_pass_filter_0, 0))
Ejemplo n.º 8
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "C:\Program Files\GNURadio-3.7\share\icons\hicolor\scalable/apps\gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1e6
        self.center_freq = center_freq = 315e6

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.GetWin(),
        	title='Scope Plot',
        	sample_rate=samp_rate,
        	v_scale=1,
        	v_offset=0,
        	t_scale=0.002,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label='Counts',
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(center_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(10, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.blocks_wavfile_sink_0 = blocks.wavfile_sink('S:\\SDROutput\\Screen\\stop.bin', 1, int(samp_rate), 8)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(0.1, 0.11, 0)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, ))
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-0.5, ))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_wavfile_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
Ejemplo n.º 9
0
    def __init__(self):
        gr.top_block.__init__(self, "Ook Demod")

        ##################################################
        # Command Line Arguments
        ##################################################
	parser = argparse.ArgumentParser()
		
	# Python ook_demod.py -s 1e6 -r 4e3 -f 433.92e6 -m true
	parser.add_argument("-s", "--samp_rate", default=1e6, help="Sample rate of software-defined radio")
	parser.add_argument("-r", "--symbol_rate", default=4e3, help="Symbol rate of key fob")
	parser.add_argument("-f", "--frequency", default=433.92e6, help="Listening frequency")
	parser.add_argument("-m", "--manchester", default=True, help="Manchester decoder", type=str2bool)
	parser.add_argument("-o", "--output", default=None, help="Output file")

	args = parser.parse_args()
        ##################################################
        # Variables
        ##################################################
	self.frequency = frequency = float(args.frequency)
        self.symbol_rate = symbol_rate = float(args.symbol_rate)
        self.samp_rate = samp_rate = float(args.sample_rate)
	self.manchester = manchester = args.manchester
	self.output = output = args.output

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

        self.ook_demod_block = ook_demod_block.blk(symbol_rate=symbol_rate, sample_rate=samp_rate, manchester_decoding=manchester, sink_file=output)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(1e-3, 1e-3, 0)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.band_pass_filter_0 = filter.fir_filter_ccc(1, firdes.complex_band_pass(
        	1, samp_rate, 1, 50e3, 20e3, firdes.WIN_HAMMING, 6.76))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0), (self.ook_demod_block, 0))
        self.connect((self.osmosdr_source_0, 0), (self.band_pass_filter_0, 0))
Ejemplo n.º 10
0
    def __init__(self, audio_rate):
        gr.hier_block2.__init__(
            self,
            "standard_squelch",
            # Input signature
            gr.io_signature(1, 1, gr.sizeof_float),
            gr.io_signature(1, 1, gr.sizeof_float))  # Output signature

        self.input_node = blocks.add_const_ff(0)  # FIXME kludge

        self.low_iir = filter.iir_filter_ffd((0.0193, 0, -0.0193),
                                             (1, 1.9524, -0.9615))
        self.low_square = blocks.multiply_ff()
        self.low_smooth = filter.single_pole_iir_filter_ff(
            1 / (0.01 * audio_rate))  # 100ms time constant

        self.hi_iir = filter.iir_filter_ffd((0.0193, 0, -0.0193),
                                            (1, 1.3597, -0.9615))
        self.hi_square = blocks.multiply_ff()
        self.hi_smooth = filter.single_pole_iir_filter_ff(1 /
                                                          (0.01 * audio_rate))

        self.sub = blocks.sub_ff()
        self.add = blocks.add_ff()
        self.gate = blocks.threshold_ff(0.3, 0.43, 0)
        self.squelch_lpf = filter.single_pole_iir_filter_ff(
            1 / (0.01 * audio_rate))

        self.div = blocks.divide_ff()
        self.squelch_mult = blocks.multiply_ff()

        self.connect(self, self.input_node)
        self.connect(self.input_node, (self.squelch_mult, 0))

        self.connect(self.input_node, self.low_iir)
        self.connect(self.low_iir, (self.low_square, 0))
        self.connect(self.low_iir, (self.low_square, 1))
        self.connect(self.low_square, self.low_smooth, (self.sub, 0))
        self.connect(self.low_smooth, (self.add, 0))

        self.connect(self.input_node, self.hi_iir)
        self.connect(self.hi_iir, (self.hi_square, 0))
        self.connect(self.hi_iir, (self.hi_square, 1))
        self.connect(self.hi_square, self.hi_smooth, (self.sub, 1))
        self.connect(self.hi_smooth, (self.add, 1))

        self.connect(self.sub, (self.div, 0))
        self.connect(self.add, (self.div, 1))
        self.connect(self.div, self.gate, self.squelch_lpf,
                     (self.squelch_mult, 1))
        self.connect(self.squelch_mult, self)
Ejemplo n.º 11
0
    def __init__(self):
        gr.top_block.__init__(self, "Gr Adsb Example")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2e6
        self.freq = freq = 1090e6

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

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(2, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(50, 0)
        self.osmosdr_source_0.set_if_gain(50, 0)
        self.osmosdr_source_0.set_bb_gain(50, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(samp_rate, 0)
          
        self.digital_correlate_access_code_tag_bb_0 = digital.correlate_access_code_tag_bb('1010000101000000', 0, 'adsb_preamble')
        self.blocks_threshold_ff_0 = blocks.threshold_ff(0.3, 0.31, 0)
        self.blocks_message_source_0 = blocks.message_source(gr.sizeof_char*1, blocks_message_source_0_msgq_in)
        self.blocks_float_to_uchar_0 = blocks.float_to_uchar()
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, '/dev/stdout', True)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.adsb_framer_0 = adsb.framer(tx_msgq=adsb_framer_0_msgq_out)
        self.adsb_decoder_0 = adsb.decoder(rx_msgq=adsb_decoder_0_msgq_in,tx_msgq=adsb_decoder_0_msgq_out,output_type="csv",check_parity=True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_threshold_ff_0, 0))    
        self.connect((self.blocks_float_to_uchar_0, 0), (self.digital_correlate_access_code_tag_bb_0, 0))    
        self.connect((self.blocks_message_source_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_float_to_uchar_0, 0))    
        self.connect((self.digital_correlate_access_code_tag_bb_0, 0), (self.adsb_framer_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
Ejemplo n.º 12
0
    def __init__(self, alpha=0.0001, threshold_db=-10, gate=False):
        gr.hier_block2.__init__(self, "standard_squelch",
                                gr.io_signature(1, 1, gr.sizeof_float), # Input signature
                                gr.io_signature(1, 1, gr.sizeof_float)) # Output signature


        #fixed coeffs, Chebyshev type 2 LPF=[0, 0.4, 0.7], HPF=[0.4, 0.7, 1]
        self.low_iir = iir_filter_ffd([0.12260106307699403, -0.22058023529806434, 0.22058023529806436, -0.12260106307699434],
                                             [1.00000000000000000, 0.7589332900264623, 0.5162740252200005, 0.07097813844342238],
                                             False)
        self.low_square = blocks.multiply_ff()
        self.low_smooth = single_pole_iir_filter_ff(alpha)

        self.hi_iir = iir_filter_ffd([0.1913118666668073, 0.4406071020350289, 0.4406071020350288, 0.19131186666680736],
                                            [1.000000000000000000, -0.11503633296078866, 0.3769676347066441, 0.0019066356578167866], 
                                             False)
        self.hi_square = blocks.multiply_ff()
        self.hi_smooth = single_pole_iir_filter_ff(alpha)

        #inverted thresholds because we reversed the division block inputs
        #to make the threshold output 1 when open and 0 when closed
        self.gate = blocks.threshold_ff(0,0,0)
        self.set_threshold(threshold_db)
        self.squelch_lpf = single_pole_iir_filter_ff(alpha)
        self.squelch_mult = blocks.multiply_ff()
        self.div = blocks.divide_ff()

        #This is horrible, but there's no better way to gate samples.
        #the block is fast, so realistically there's little overhead
        #TODO: implement a valve block that gates based on an input value
        self.valve = analog.pwr_squelch_ff(-100, 1, 0, gate)

        #sample path
        self.connect(self, (self.squelch_mult, 0))

        #filter path (LPF)
        self.connect(self,self.low_iir)
        self.connect(self.low_iir,(self.low_square,0))
        self.connect(self.low_iir,(self.low_square,1))
        self.connect(self.low_square,self.low_smooth,(self.div,0))

        #filter path (HPF)
        self.connect(self,self.hi_iir)
        self.connect(self.hi_iir,(self.hi_square,0))
        self.connect(self.hi_iir,(self.hi_square,1))
        self.connect(self.hi_square,self.hi_smooth,(self.div,1))

        #control path
        self.connect(self.div, self.gate, self.squelch_lpf, (self.squelch_mult,1))
        self.connect(self.squelch_mult, self)
Ejemplo n.º 13
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.vec_length = vec_length = int(100e3)
        self.samp_rate = samp_rate = 2e6
        self.folder = folder = "/home/erik/Dev/mini-hackathon/HackaCurtain/data/test/"
        self.center_freq = center_freq = 433.5e6

        ##################################################
        # Blocks
        ##################################################
        self.trigger_trigger_ff_0 = trigger.trigger_ff(0.5, int(200))
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(center_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(20, 0)
        self.osmosdr_source_0.set_if_gain(30, 0)
        self.osmosdr_source_0.set_bb_gain(30, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
          
        self.blocks_threshold_ff_0 = blocks.threshold_ff(0.08, 0.14, 0)
        self.blocks_tagged_file_sink_0 = blocks.tagged_file_sink(gr.sizeof_float*1, int(samp_rate))
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_burst_tagger_0 = blocks.burst_tagger(gr.sizeof_float)
        self.blocks_burst_tagger_0.set_true_tag("burst",True)
        self.blocks_burst_tagger_0.set_false_tag("burst",False)
        	

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_burst_tagger_0, 0), (self.blocks_tagged_file_sink_0, 0))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_threshold_ff_0, 0))    
        self.connect((self.blocks_float_to_short_0, 0), (self.blocks_burst_tagger_0, 1))    
        self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_burst_tagger_0, 0))    
        self.connect((self.blocks_threshold_ff_0, 0), (self.trigger_trigger_ff_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.trigger_trigger_ff_0, 0), (self.blocks_float_to_short_0, 0))    
Ejemplo n.º 14
0
    def __init__(self, rx_callback, tx_status, rx_status):
        gr.hier_block2.__init__(self, "receive_path",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
            gr.io_signature(0, 0, 0))

        ##################################################
        # Variables
        ##################################################
        self.callback = rx_callback

        ##################################################
        # Blocks
        ##################################################
        self.demod = digital.gfsk_demod(
        	samples_per_symbol=4,
        	sensitivity=1.0,
        	gain_mu=0.175,
        	mu=0.5,
        	omega_relative_limit=0.005,
        	freq_error=0.0,
        	verbose=False,
        	log=False,
        )
        self.frame_sync = frame_sync(tx_status, rx_status) # Your custom block!!!

        self.output_unpacked_to_packed = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)

        self.rcvd_pktq = gr.msg_queue()
        self.message_sink = blocks.message_sink(gr.sizeof_char, self.rcvd_pktq, True)

        self.queue_watcher_thread = _queue_watcher_thread(self.rcvd_pktq, self.callback)

        self.blocks_max = blocks.max_ff(1,1)

        #Don't Search if nothing is transmitting
        self.blocks_threshold_ff_0 = blocks.threshold_ff(0.00002, 0.00002, 0)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(-80, 0.55)
        ##################################################
        # Connections
        ##################################################
        #main path
        self.connect(self, self.demod, (self.frame_sync, 0))
        self.connect(self.frame_sync, self.output_unpacked_to_packed, self.message_sink)

        #squelch path
        self.connect(self, (self.analog_simple_squelch_cc_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_max, 0), (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0), (self.frame_sync, 1))
Ejemplo n.º 15
0
    def __init__(self):
        gr.top_block.__init__(self, "Ask Rx Top Raspi")

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

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

        self.bit_rate = bit_rate = symbol_rate / bits_per_symbol

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

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.digital_hdlc_deframer_bp_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.connect((self.audio_source_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_float_to_char_0, 0),
                     (self.digital_hdlc_deframer_bp_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0),
                     (self.blocks_tagged_file_sink_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_float_to_char_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_threshold_ff_0, 0))
Ejemplo n.º 16
0
    def __init__(self,
                 src="uhd",
                 dst="uhd",
                 in_rate=2e6,
                 out_rate=2e6,
                 extra=None):
        super(tag_emulate, self).__init__()

        uhd = dst == "uhd"

        if uhd:
            dst = None

        self._bin_src = binary_src.binary_src(out_rate,
                                              encode="manchester",
                                              idle_bit=0)

        parser = Parser(extra)
        self._tag = parser.get_tag(self._bin_src.set_bits)

        # Do not record here
        self._dec = decoder.decoder(src=src,
                                    dst=None,
                                    reader=True,
                                    tag=False,
                                    samp_rate=in_rate,
                                    emulator=self._tag)
        self.connect(self._dec)

        self._mult = multiplier.multiplier(samp_rate=out_rate)
        self.connect(self._bin_src, self._mult)
        if uhd:
            # active load modulation
            self._real = blocks.complex_to_real(1)
            self._thres = blocks.threshold_ff(0.02, 0.1, 0)
            self._r2c = blocks.float_to_complex(1)

            self._sink = usrp_sink.usrp_sink(out_rate)
            self.connect(self._mult, self._real, self._thres, self._r2c,
                         self._sink)
        elif dst:
            self._sink = record.record(dst, out_rate)
            self.connect(self._mult, self._sink)
        else:
            self._sink = blocks.null_sink(gr.sizeof_gr_complex)
            self.connect(self._mult, self._sink)
Ejemplo n.º 17
0
    def test_01(self):
        tb = self.tb

        data = [0, 0, 0, 2, 2, 2, 2, 0, 0, 0, 2, 2, 2]

        expected_result = (0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1)

        src = blocks.vector_source_f(data, False)
        op = blocks.threshold_ff(1, 1)
        dst = blocks.vector_sink_f()

        tb.connect(src, op)
        tb.connect(op, dst)
        tb.run()

        dst_data = dst.data()

        self.assertEqual(expected_result, dst_data)
Ejemplo n.º 18
0
    def test_01(self):
        tb = self.tb

        data = [0, 0, 0, 2, 2, 2, 2, 0, 0, 0, 2, 2, 2]

        expected_result = (0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1)

        src = blocks.vector_source_f(data, False)
        op = blocks.threshold_ff(1, 1)
        dst = blocks.vector_sink_f()

        tb.connect(src, op)
        tb.connect(op, dst)
        tb.run()

        dst_data = dst.data()

        self.assertEqual(expected_result, dst_data)
Ejemplo n.º 19
0
    def __init__(self, audio_rate):
	gr.hier_block2.__init__(self, "standard_squelch",
				gr.io_signature(1, 1, gr.sizeof_float), # Input signature
				gr.io_signature(1, 1, gr.sizeof_float)) # Output signature

        self.input_node = blocks.add_const_ff(0)          # FIXME kludge

        self.low_iir = filter.iir_filter_ffd((0.0193,0,-0.0193),(1,1.9524,-0.9615))
        self.low_square = blocks.multiply_ff()
        self.low_smooth = filter.single_pole_iir_filter_ff(1/(0.01*audio_rate))   # 100ms time constant

        self.hi_iir = filter.iir_filter_ffd((0.0193,0,-0.0193),(1,1.3597,-0.9615))
        self.hi_square = blocks.multiply_ff()
        self.hi_smooth = filter.single_pole_iir_filter_ff(1/(0.01*audio_rate))

        self.sub = blocks.sub_ff();
        self.add = blocks.add_ff();
        self.gate = blocks.threshold_ff(0.3,0.43,0)
        self.squelch_lpf = filter.single_pole_iir_filter_ff(1/(0.01*audio_rate))

        self.div = blocks.divide_ff()
        self.squelch_mult = blocks.multiply_ff()

	self.connect(self, self.input_node)
        self.connect(self.input_node, (self.squelch_mult, 0))

        self.connect(self.input_node,self.low_iir)
        self.connect(self.low_iir,(self.low_square,0))
        self.connect(self.low_iir,(self.low_square,1))
        self.connect(self.low_square,self.low_smooth,(self.sub,0))
        self.connect(self.low_smooth, (self.add,0))

        self.connect(self.input_node,self.hi_iir)
        self.connect(self.hi_iir,(self.hi_square,0))
        self.connect(self.hi_iir,(self.hi_square,1))
        self.connect(self.hi_square,self.hi_smooth,(self.sub,1))
        self.connect(self.hi_smooth, (self.add,1))

        self.connect(self.sub, (self.div, 0))
        self.connect(self.add, (self.div, 1))
        self.connect(self.div, self.gate, self.squelch_lpf, (self.squelch_mult,1))
	self.connect(self.squelch_mult, self)
Ejemplo n.º 20
0
    def __init__(self, filter_len, gain, hi, low):
        gr.hier_block2.__init__(
            self,
            "carrier_detect",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signature(1, 1, gr.sizeof_short * 1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.filter_len = filter_len
        self.gain = gain
        self.hi = hi
        self.low = low

        ##################################################
        # Blocks
        ##################################################
        self.blocks_threshold_ff_0 = blocks.threshold_ff(low, hi, 0)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((gain, ))
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            filter_len, 1.0 / filter_len, 4000)
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_float_to_short_0, 0), (self, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_float_to_short_0, 0))
        self.connect((self, 0), (self.blocks_complex_to_mag_squared_0, 0))
Ejemplo n.º 21
0
  def __init__(self):
    gr.top_block.__init__(self, name="Doorbell Top Block")

    # RF Config
    self.threshold_min = -60
    self.threshold_max = -50
    self.samp_rate = samp_rate = 100e3
    self.gain = gain = 30
    self.freq = freq = 315e6
    self.decimation = 10

    # USRP
    self.usrp = uhd.usrp_source("", uhd.stream_args("fc32"))
    self.usrp.set_samp_rate(samp_rate)
    self.usrp.set_center_freq(freq, 0)
    self.usrp.set_gain(gain, 0)
    self.usrp.set_antenna("TX/RX", 0)

    # Low Pass Filter
    self.lpf = filter.fir_filter_ccf(self.decimation,
      firdes.low_pass(1, samp_rate, 50e3, 10e3, firdes.WIN_HAMMING, 6.76))

    # Complex to Power (dB)
    self._10log10 = blocks.nlog10_ff(10, 1, 0)
    self.complex_to_mag_squared = blocks.complex_to_mag_squared(1)

    # Threshold
    self.threshold = blocks.threshold_ff(self.threshold_min, self.threshold_max, 0)

    # Framer
    self.framer = doorbell_framer()

    # Connect the blocks
    self.connect((self.usrp, 0), (self.lpf, 0))
    self.connect((self.lpf, 0), (self.complex_to_mag_squared, 0))
    self.connect((self.complex_to_mag_squared, 0), (self._10log10, 0))
    self.connect((self._10log10, 0), (self.threshold, 0))
    self.connect((self.threshold, 0), (self.framer, 0))
Ejemplo n.º 22
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Variables
        ##################################################
        self.threshold = threshold = -70
        self.samp_rate = samp_rate = 2048000
        self.freq = freq = 525200000
        self.fft_size = fft_size = 1024

        ##################################################
        # Blocks
        ##################################################
        _threshold_sizer = wx.BoxSizer(wx.VERTICAL)
        self._threshold_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_threshold_sizer,
            value=self.threshold,
            callback=self.set_threshold,
            label="Threshold",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._threshold_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_threshold_sizer,
            value=self.threshold,
            callback=self.set_threshold,
            minimum=-100,
            maximum=0,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_threshold_sizer)
        _freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_freq_sizer,
            value=self.freq,
            callback=self.set_freq,
            label="freq",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._freq_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_freq_sizer,
            value=self.freq,
            callback=self.set_freq,
            minimum=478000000,
            maximum=862000000,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_freq_sizer)
        self.wxgui_numbersink2_1 = numbersink2.number_sink_f(
            self.GetWin(),
            unit="signal present",
            minval=0,
            maxval=1,
            factor=1.0,
            decimal_places=0,
            ref_level=0,
            sample_rate=samp_rate,
            number_rate=15,
            average=False,
            avg_alpha=None,
            label="Signal Detection",
            peak_hold=False,
            show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_1.win)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
            self.GetWin(),
            unit="dB",
            minval=-120,
            maxval=0,
            factor=1.0,
            decimal_places=0,
            ref_level=0,
            sample_rate=samp_rate,
            number_rate=15,
            average=True,
            avg_alpha=0.030,
            label="Level",
            peak_hold=False,
            show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=freq,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=fft_size,
            fft_rate=15,
            average=True,
            avg_alpha=0.03,
            title="Spectrum",
            peak_hold=False,
            win=window.rectangular,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rtlsdr_source_1 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              "")
        self.rtlsdr_source_1.set_sample_rate(samp_rate)
        self.rtlsdr_source_1.set_center_freq(freq, 0)
        self.rtlsdr_source_1.set_freq_corr(0, 0)
        self.rtlsdr_source_1.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_1.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_1.set_gain_mode(False, 0)
        self.rtlsdr_source_1.set_gain(20, 0)
        self.rtlsdr_source_1.set_if_gain(10, 0)
        self.rtlsdr_source_1.set_bb_gain(5, 0)
        self.rtlsdr_source_1.set_antenna("", 0)
        self.rtlsdr_source_1.set_bandwidth(1, 0)

        self.notebook = self.notebook = wx.Notebook(self.GetWin(),
                                                    style=wx.NB_TOP)
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "spectrum")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "output")
        self.Add(self.notebook)
        self.fft_vxx_0 = fft.fft_vcc(fft_size, True,
                                     (window.blackmanharris(1024)), True, 1)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_float * 1, fft_size)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(
            -100, threshold, threshold)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, fft_size)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(
            fft_size)
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, fft_size * fft_size)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.wxgui_numbersink2_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.wxgui_numbersink2_1, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_divide_xx_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.rtlsdr_source_1, 0), (self.blocks_throttle_0, 0))
        self.connect((self.rtlsdr_source_1, 0), (self.wxgui_fftsink2_0, 0))
Ejemplo n.º 23
0
    def __init__(self, large_sig_len=0.0015, signal_mult=2, freq=433866000):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        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())

        ##################################################
        # Parameters
        ##################################################
        self.large_sig_len = large_sig_len
        self.signal_mult = signal_mult
        self.freq = freq

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 240000

        ##################################################
        # Blocks
        ##################################################
        self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(0.2, 1)
        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(-24, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(1, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(50, 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.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate, 10000, 10000, firdes.WIN_HAMMING, 6.76))
        self.blocks_threshold_ff_2 = blocks.threshold_ff(0, 0, 0)
        self.blocks_threshold_ff_1 = blocks.threshold_ff(0, 0, 0)
        self.blocks_sub_xx_2 = blocks.sub_ff(1)
        self.blocks_sub_xx_1 = blocks.sub_ff(1)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "localhost", "52001", 10000, False)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((signal_mult, ))
        self.blocks_moving_average_xx_1 = blocks.moving_average_ff(int(samp_rate*large_sig_len), 0.8/samp_rate/large_sig_len, 4000)
        self.blocks_float_to_char_1 = blocks.float_to_char(1, 1)
        self.blocks_float_to_char_0_0 = blocks.float_to_char(1, 1)
        self.blocks_delay_1 = blocks.delay(gr.sizeof_float*1, int(samp_rate*0.00005))
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, 1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.bitgate_triggered_bits_0 = bitgate.triggered_bits(int(samp_rate*large_sig_len*5), False)
        self.analog_rail_ff_1 = analog.rail_ff(0.001, 1)
        self.analog_rail_ff_0 = analog.rail_ff(0, 1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.bitgate_triggered_bits_0, 'pdus'), (self.blocks_socket_pdu_0, 'pdus'))    
        self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_char_0_0, 0))    
        self.connect((self.analog_rail_ff_1, 0), (self.blocks_multiply_const_vxx_1, 0))    
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.analog_rail_ff_1, 0))    
        self.connect((self.blocks_delay_0, 0), (self.blocks_sub_xx_0, 0))    
        self.connect((self.blocks_delay_1, 0), (self.blocks_float_to_char_1, 0))    
        self.connect((self.blocks_float_to_char_0_0, 0), (self.bitgate_triggered_bits_0, 1))    
        self.connect((self.blocks_float_to_char_1, 0), (self.bitgate_triggered_bits_0, 0))    
        self.connect((self.blocks_moving_average_xx_1, 0), (self.blocks_sub_xx_1, 1))    
        self.connect((self.blocks_moving_average_xx_1, 0), (self.blocks_sub_xx_2, 1))    
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_moving_average_xx_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.single_pole_iir_filter_xx_0, 0))    
        self.connect((self.blocks_sub_xx_0, 0), (self.analog_rail_ff_0, 0))    
        self.connect((self.blocks_sub_xx_1, 0), (self.blocks_sub_xx_2, 0))    
        self.connect((self.blocks_sub_xx_1, 0), (self.blocks_threshold_ff_1, 0))    
        self.connect((self.blocks_sub_xx_2, 0), (self.blocks_threshold_ff_2, 0))    
        self.connect((self.blocks_threshold_ff_1, 0), (self.blocks_delay_0, 0))    
        self.connect((self.blocks_threshold_ff_1, 0), (self.blocks_sub_xx_0, 1))    
        self.connect((self.blocks_threshold_ff_2, 0), (self.blocks_delay_1, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_sub_xx_1, 0))    
Ejemplo n.º 24
0
    def __init__(self):
        gr.top_block.__init__(self, "Experiment4 Rx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Experiment4 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", "experiment4_rx")

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

        ##################################################
        # Variables
        ##################################################
        self.time_preamble = time_preamble = [
            0.125000 + 0.000000j, 0.522104 - 0.148216j, -0.495528 + 0.114832j,
            -0.267916 + 0.091700j, 0.236544 - 0.138456j, -0.098500 + 0.473800j,
            0.476480 - 0.225344j, -0.187516 + 0.035372j, 0.051776 - 0.353552j,
            -0.104936 + 0.059916j, 0.228684 + 0.117504j, -0.530912 + 0.560756j,
            0.359128 + 0.015872j, -0.132852 + 0.632840j, -0.105164 - 0.368872j,
            0.368272 - 0.032412j, 0.125000 + 0.750000j, 0.463968 + 0.457792j,
            0.151476 - 0.430948j, 0.685052 + 0.238524j, 0.494428 + 0.119428j,
            -0.557540 - 0.050056j, 0.416348 + 0.017368j, 0.104256 - 0.568836j,
            -0.301776 - 0.353552j, 0.079812 + 0.451516j, 0.439152 + 0.528072j,
            0.642060 + 0.178484j, -0.090096 + 0.465096j, -0.446492 + 0.305776j,
            -0.111440 - 0.093688j, -0.538848 - 0.320228j, 0.125000 + 0.000000j,
            -0.538848 + 0.320228j, -0.111440 + 0.093688j,
            -0.446492 - 0.305776j, -0.090096 - 0.465096j, 0.642060 - 0.178484j,
            0.439152 - 0.528072j, 0.079812 - 0.451516j, -0.301776 + 0.353552j,
            0.104256 + 0.568836j, 0.416348 - 0.017368j, -0.557540 + 0.050056j,
            0.494428 - 0.119428j, 0.685052 - 0.238524j, 0.151476 + 0.430948j,
            0.463968 - 0.457792j, 0.125000 - 0.750000j, 0.368272 + 0.032412j,
            -0.105164 + 0.368872j, -0.132852 - 0.632840j, 0.359128 - 0.015872j,
            -0.530912 - 0.560756j, 0.228684 - 0.117504j, -0.104936 - 0.059916j,
            0.051776 + 0.353552j, -0.187516 - 0.035372j, 0.476480 + 0.225344j,
            -0.098500 - 0.473800j, 0.236544 + 0.138456j, -0.267916 - 0.091700j,
            -0.495528 - 0.114832j, 0.522104 + 0.148216j
        ]
        self.threshold = threshold = 1
        self.samp_rate = samp_rate = 1e6
        self.preamble_len = preamble_len = 64
        self.packet_len = packet_len = 1024
        self.length = length = 96

        ##################################################
        # Blocks
        ##################################################
        self._threshold_range = Range(0, 2, 0.01, 1, 200)
        self._threshold_win = RangeWidget(self._threshold_range,
                                          self.set_threshold, 'Threshold',
                                          "counter_slider", float)
        self.top_grid_layout.addWidget(self._threshold_win, 0, 0, 1, 2)
        [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)]
        [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 2)]
        self.timesvl_TimeSVL_0 = timesvl.TimeSVL(
            gr.sizeof_gr_complex * 1, 1,
            '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Time_maps/output_time_map1.txt',
            '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Input_Output parameters/output_1.txt'
        )
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=2,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
            preamble_len + packet_len,  #size
            samp_rate,  #samp_rate
            "Synchronization",  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-0.2, 2)

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

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

        if not True:
            self.qtgui_time_sink_x_1.disable_legend()

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

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

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win, 1, 0, 1,
                                       2)
        [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)]
        [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 2)]
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            512,  #size
            samp_rate,  #samp_rate
            "Demodulated OFDM  Data",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)

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

        self.qtgui_time_sink_x_0_0.enable_tags(-1, False)
        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)
        self.qtgui_time_sink_x_0_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 2, 1,
                                       1, 1)
        [self.top_grid_layout.setRowStretch(r, 1) for r in range(2, 3)]
        [self.top_grid_layout.setColumnStretch(c, 1) for c in range(1, 2)]
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            512,  #size
            samp_rate,  #samp_rate
            "Demodulated GMSK  Data",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 2, 0, 1,
                                       1)
        [self.top_grid_layout.setRowStretch(r, 1) for r in range(2, 3)]
        [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 1)]
        self.mysvl_triggered_demux_0 = mysvl.triggered_demux(
            gr.sizeof_gr_complex * 1, gr.sizeof_float,
            (preamble_len, packet_len), 1, True)
        self.digital_ofdm_rx_0 = digital.ofdm_rx(
            fft_len=64,
            cp_len=16,
            frame_length_tag_key='frame_' + "length",
            packet_length_tag_key="length",
            bps_header=1,
            bps_payload=2,
            debug_log=False,
            scramble_bits=False)
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
            samples_per_symbol=2,
            gain_mu=0.175,
            mu=0.5,
            omega_relative_limit=0.005,
            freq_error=0.0,
            verbose=False,
            log=False,
        )
        self.digital_corr_est_cc_0 = digital.corr_est_cc((time_preamble), 1, 0,
                                                         0.99)
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_gr_complex * 1,
                                                     '127.0.0.1', 4000,
                                                     1472 * 32, True)
        (self.blocks_udp_source_0).set_min_output_buffer(1000000)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(
            threshold, threshold, 0)
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_file_sink_0_0 = blocks.file_sink(
            gr.sizeof_char * 1, './outputs/output_audio1.mp3', False)
        self.blocks_file_sink_0_0.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1, './outputs/output_audio2.mp3', False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.blocks_abs_xx_1 = blocks.abs_ff(1)
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(
            grc_blks2.packet_decoder(
                access_code='',
                threshold=-1,
                callback=lambda ok, payload: self.blks2_packet_decoder_0.
                recv_pkt(ok, payload),
            ), )
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, threshold)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.qtgui_time_sink_x_1, 1))
        self.connect((self.blks2_packet_decoder_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.blks2_packet_decoder_0, 0),
                     (self.blocks_file_sink_0_0, 0))
        self.connect((self.blocks_abs_xx_1, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_abs_xx_1, 0), (self.qtgui_time_sink_x_1, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_char_to_float_0_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_abs_xx_1, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.mysvl_triggered_demux_0, 1))
        self.connect((self.blocks_udp_source_0, 0),
                     (self.digital_corr_est_cc_0, 0))
        self.connect((self.digital_corr_est_cc_0, 1),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.digital_corr_est_cc_0, 0),
                     (self.mysvl_triggered_demux_0, 0))
        self.connect((self.digital_gmsk_demod_0, 0),
                     (self.blks2_packet_decoder_0, 0))
        self.connect((self.digital_ofdm_rx_0, 0),
                     (self.blocks_char_to_float_0_0, 0))
        self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.mysvl_triggered_demux_0, 0),
                     (self.blocks_null_sink_1, 0))
        self.connect((self.mysvl_triggered_demux_0, 1),
                     (self.timesvl_TimeSVL_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.digital_gmsk_demod_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.digital_ofdm_rx_0, 0))
        self.connect((self.timesvl_TimeSVL_0, 1),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.timesvl_TimeSVL_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
Ejemplo n.º 25
0
    def __init__(self, fft_length, cp_length, kstime, logging=False):
        """
        OFDM synchronization using PN Correlation and initial cross-correlation:
        F. Tufvesson, O. Edfors, and M. Faulkner, "Time and Frequency Synchronization for OFDM using
        PN-Sequency Preambles," IEEE Proc. VTC, 1999, pp. 2203-2207.

        This implementation is meant to be a more robust version of the Schmidl and Cox receiver design.
        By correlating against the preamble and using that as the input to the time-delayed correlation,
        this circuit produces a very clean timing signal at the end of the preamble. The timing is
        more accurate and does not have the problem associated with determining the timing from the
        plateau structure in the Schmidl and Cox.

        This implementation appears to require that the signal is received with a normalized power or signal
        scaling factor to reduce ambiguities introduced from partial correlation of the cyclic prefix and
        the peak detection. A better peak detection block might fix this.

        Also, the cross-correlation falls apart as the frequency offset gets larger and completely fails
        when an integer offset is introduced. Another thing to look at.
        """

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

        self.input = blocks.add_const_cc(0)

        symbol_length = fft_length + cp_length

        # PN Sync with cross-correlation input

        # cross-correlate with the known symbol
        kstime = [k.conjugate() for k in kstime[0:fft_length//2]]
        kstime.reverse()
        self.crosscorr_filter = filter.fir_filter_ccc(1, kstime)
        
        # Create a delay line
        self.delay = blocks.delay(gr.sizeof_gr_complex, fft_length/2)

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

        # Create a moving sum filter for the input
        self.mag = blocks.complex_to_mag_squared()
        self.power = filter.fir_filter_fff(1, [1.0] * int(fft_length))

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

        self.sample_and_hold = blocks.sample_and_hold_ff()

        #ML measurements input to sampler block and detect
        self.threshold = blocks.threshold_ff(0,0,0)      # threshold detection might need to be tweaked
        self.peaks = blocks.float_to_char()

        self.connect(self, self.input)

        # Cross-correlate input signal with known preamble
        self.connect(self.input, self.crosscorr_filter)

        # use the output of the cross-correlation as input time-shifted correlation
        self.connect(self.crosscorr_filter, self.delay)
        self.connect(self.crosscorr_filter, (self.corr,0))
        self.connect(self.delay, self.conjg)
        self.connect(self.conjg, (self.corr,1))
        self.connect(self.corr, self.c2mag)
        self.connect(self.corr, self.angle)
        self.connect(self.angle, (self.sample_and_hold,0))
        
        # Get the power of the input signal to compare against the correlation
        self.connect(self.crosscorr_filter, self.mag, self.power)

        # Compare the power to the correlator output to determine timing peak
        # When the peak occurs, it peaks above zero, so the thresholder detects this
        self.connect(self.c2mag, (self.compare,0))
        self.connect(self.power, (self.compare,1))
        self.connect(self.compare, self.threshold)
        self.connect(self.threshold, self.peaks, (self.sample_and_hold,1))

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

        if logging:
            self.connect(self.compare, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pnac-compare_f.dat"))
            self.connect(self.c2mag, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pnac-theta_f.dat"))
            self.connect(self.power, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pnac-inputpower_f.dat"))
            self.connect(self.angle, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pnac-epsilon_f.dat"))
            self.connect(self.threshold, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pnac-threshold_f.dat"))
            self.connect(self.peaks, blocks.file_sink(gr.sizeof_char, "ofdm_sync_pnac-peaks_b.dat"))
            self.connect(self.sample_and_hold, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pnac-sample_and_hold_f.dat"))
            self.connect(self.input, blocks.file_sink(gr.sizeof_gr_complex, "ofdm_sync_pnac-input_c.dat"))
Ejemplo n.º 26
0
    def __init__(self):
        gr.top_block.__init__(self, "OOK Receiver")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("OOK Receiver")
        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", "ook_receiver")

        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 = 10e6
        self.baseband_freq = baseband_freq = 500
        self.threshold = threshold = 0.03
        self.samples_per_symbol = samples_per_symbol = int(samp_rate /
                                                           baseband_freq)
        self.carrier_freq = carrier_freq = 432.867e6
        self.alpha = alpha = 0.00328

        ##################################################
        # Blocks
        ##################################################
        self._threshold_range = Range(0, 1, 0.01, 0.03, 200)
        self._threshold_win = RangeWidget(self._threshold_range,
                                          self.set_threshold, 'Threshold',
                                          "counter_slider", float)
        self.top_grid_layout.addWidget(self._threshold_win)
        self._alpha_range = Range(0.00001, 0.01, 0.00001, 0.00328, 200)
        self._alpha_win = RangeWidget(self._alpha_range, self.set_alpha,
                                      'alpha', "counter_slider", float)
        self.top_grid_layout.addWidget(self._alpha_win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=1,
            decimation=int(samples_per_symbol / 4),
            taps=[1],
            fractional_bw=None)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-1, 1)

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

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

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

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

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            600000,  #size
            samp_rate,  #samp_rate
            "",  #name
            3  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(0, 0.15)

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

        self.qtgui_time_sink_x_0.enable_tags(True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_NORM,
                                                  qtgui.TRIG_SLOPE_POS, 0.07,
                                                  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)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

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

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

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

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "soapy=0,driver=lime")
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(carrier_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_gain(0, 0)
        self.osmosdr_source_0.set_if_gain(0, 0)
        self.osmosdr_source_0.set_bb_gain(0, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
        self.blocks_threshold_ff_0_0 = blocks.threshold_ff(
            threshold, threshold, 0)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(0.04, 0.06, 0)
        self.blocks_rms_xx_0 = blocks.rms_ff(alpha)
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(4)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(0.1)
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 1)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/run/media/gpellaeon/ubuntu20_04/home/pellaeon/Development/SDR/GRFlowgraphs/ook/digital_output.txt',
            False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_rms_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_float_to_char_0, 0),
                     (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_pack_k_bits_bb_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_rms_xx_0, 0),
                     (self.blocks_threshold_ff_0_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_threshold_ff_0_0, 0),
                     (self.qtgui_time_sink_x_0, 2))
        self.connect((self.blocks_threshold_ff_0_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_float_to_char_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.qtgui_time_sink_x_1, 0))
Ejemplo n.º 27
0
    def __init__(self):
        gr.top_block.__init__(self, "udp-recive")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("udp-recive")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

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

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

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=11025,
            decimation=34000,
            taps=None,
            fractional_bw=None)
        self.qtgui_sink_x_0 = qtgui.sink_c(
            2048,  #fftsize
            firdes.WIN_HAMMING,  #wintype
            0,  #fc
            34e3,  #bw
            "output sink",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            False,  #plottime
            False  #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)

        self.qtgui_sink_x_0.enable_rf_freq(False)

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

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

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

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

        self.NOAA19_fall.enable_rf_freq(True)

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

        self.NOAA18_fall.enable_rf_freq(True)

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

        self.NOAA15_fall.enable_rf_freq(True)

        self.top_grid_layout.addWidget(self._NOAA15_fall_win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_abs_xx_0, 0),
                     (self.blocks_float_to_complex_1, 0))
        self.connect((self.blocks_abs_xx_0_0, 0),
                     (self.blocks_float_to_complex_1_0, 0))
        self.connect((self.blocks_abs_xx_0_0_0, 0),
                     (self.blocks_float_to_complex_1_1, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_abs_xx_0, 0))
        self.connect((self.blocks_add_const_vxx_0_0, 0),
                     (self.blocks_abs_xx_0_0, 0))
        self.connect((self.blocks_add_const_vxx_0_0_0, 0),
                     (self.blocks_abs_xx_0_0_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.analog_wfm_rcv_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.qtgui_sink_x_0, 0))
        self.connect((self.blocks_argmax_xx_0, 1),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.blocks_argmax_xx_0, 0),
                     (self.blocks_short_to_float_0, 0))
        self.connect((self.blocks_argmax_xx_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_moving_average_1, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_0, 0),
                     (self.blocks_moving_average_2, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_1, 0),
                     (self.blocks_moving_average_2_0, 0))
        self.connect((self.blocks_float_to_complex_1, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_float_to_complex_1_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_float_to_complex_1_1, 0),
                     (self.blocks_multiply_xx_2, 1))
        self.connect((self.blocks_moving_average_1, 0),
                     (self.blocks_streams_to_vector_0, 0))
        self.connect((self.blocks_moving_average_2, 0),
                     (self.blocks_streams_to_vector_0, 1))
        self.connect((self.blocks_moving_average_2_0, 0),
                     (self.blocks_streams_to_vector_0, 2))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_add_xx_0, 2))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.blocks_threshold_ff_0_0, 0))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.blocks_threshold_ff_0_1, 0))
        self.connect((self.blocks_streams_to_vector_0, 0),
                     (self.blocks_argmax_xx_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_threshold_ff_0_0, 0),
                     (self.blocks_add_const_vxx_0_0, 0))
        self.connect((self.blocks_threshold_ff_0_1, 0),
                     (self.blocks_add_const_vxx_0_0_0, 0))
        self.connect((self.blocks_udp_source_0, 0), (self.NOAA19_fall, 0))
        self.connect((self.blocks_udp_source_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_udp_source_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_udp_source_0_1, 0), (self.NOAA18_fall, 0))
        self.connect((self.blocks_udp_source_0_1, 0),
                     (self.blocks_complex_to_mag_squared_0_0, 0))
        self.connect((self.blocks_udp_source_0_1, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_udp_source_0_2, 0), (self.NOAA15_fall, 0))
        self.connect((self.blocks_udp_source_0_2, 0),
                     (self.blocks_complex_to_mag_squared_0_1, 0))
        self.connect((self.blocks_udp_source_0_2, 0),
                     (self.blocks_multiply_xx_2, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_udp_sink_0, 0))
Ejemplo n.º 28
0
    def __init__(self, options, filename):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Blocks
        ##################################################
        self.dc_blocker_xx_0_0 = filter.dc_blocker_cc(32, True)
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(32, True)

        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 20000000, True)
        self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_gr_complex * 1,
                                                 options.skip)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_magphase_to_complex_0 = blocks.magphase_to_complex(1)
        self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex * 1,
                                         options.maxsamp)
        self.blocks_file_source_0_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1, filename[0], True)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1, filename[1], True)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1,
                                                   filename[2], False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_magphase_0 = blocks.complex_to_magphase(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        #self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 1)

        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(0.01, 0.04, 0)

        ##################################################
        # Connections
        ##################################################

        self.connect((self.blocks_file_source_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.blocks_file_source_0_0, 0),
                     (self.dc_blocker_xx_0_0, 0))

        self.connect((self.dc_blocker_xx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.dc_blocker_xx_0_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0))

        self.connect((self.blocks_throttle_0, 0), (self.blocks_skiphead_0, 0))
        self.connect((self.blocks_skiphead_0, 0), (self.blocks_head_0, 0))

        self.connect((self.blocks_head_0, 0),
                     (self.blocks_complex_to_magphase_0, 0))

        # tap for power analysis
        self.connect((self.blocks_head_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_threshold_ff_0, 0))

        self.connect((self.blocks_complex_to_magphase_0, 1),
                     (self.blocks_magphase_to_complex_0, 1))
        self.connect((self.blocks_complex_to_magphase_0, 0),
                     (self.blocks_null_sink_0, 0))

        #self.connect((self.analog_const_source_x_0, 0), (self.blocks_magphase_to_complex_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_magphase_to_complex_0, 0))

        # in case you want to just add
        #self.connect((self.blocks_complex_to_magphase_0, 0), (self.blocks_magphase_to_complex_0, 0))

        self.connect((self.blocks_magphase_to_complex_0, 0),
                     (self.blocks_file_sink_0, 0))
Ejemplo n.º 29
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Funtenna Demod")

        ##################################################
        # Variables
        ##################################################
        self.symbol_threshold = symbol_threshold = .4
        self.sample_threshold = sample_threshold = 115
        self.samp_rate = samp_rate = 250000
        self.initial_dec = initial_dec = 20
        self.complex_dec = complex_dec = 10
        self.center_freq = center_freq = 29494830
        self.bandwidth = bandwidth = 550
        self.amplitude_filter = amplitude_filter = 10
        self.amplitude_dec = amplitude_dec = 1

        ##################################################
        # Blocks
        ##################################################
        self._symbol_threshold_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.symbol_threshold,
        	callback=self.set_symbol_threshold,
        	label="Amplitude Threshold (n)",
        	converter=forms.float_converter(),
        )
        self.Add(self._symbol_threshold_text_box)
        self._sample_threshold_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.sample_threshold,
        	callback=self.set_sample_threshold,
        	label="Sample Threshold",
        	converter=forms.float_converter(),
        )
        self.Add(self._sample_threshold_text_box)
        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab1")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab2")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab3")
        self.Add(self.notebook_0)
        self._initial_dec_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.initial_dec,
        	callback=self.set_initial_dec,
        	label="Initial Decimation",
        	converter=forms.float_converter(),
        )
        self.Add(self._initial_dec_text_box)
        _complex_dec_sizer = wx.BoxSizer(wx.VERTICAL)
        self._complex_dec_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_complex_dec_sizer,
        	value=self.complex_dec,
        	callback=self.set_complex_dec,
        	label="Complex Filter Decimation",
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._complex_dec_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_complex_dec_sizer,
        	value=self.complex_dec,
        	callback=self.set_complex_dec,
        	minimum=1,
        	maximum=400,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_complex_dec_sizer)
        self._center_freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.center_freq,
        	callback=self.set_center_freq,
        	label="Center Frequency",
        	converter=forms.float_converter(),
        )
        self.Add(self._center_freq_text_box)
        self._bandwidth_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.bandwidth,
        	callback=self.set_bandwidth,
        	label="Bandwidth",
        	converter=forms.float_converter(),
        )
        self.Add(self._bandwidth_text_box)
        self._amplitude_filter_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.amplitude_filter,
        	callback=self.set_amplitude_filter,
        	label="Amplitude Filter (Hz)",
        	converter=forms.float_converter(),
        )
        self.Add(self._amplitude_filter_text_box)
        _amplitude_dec_sizer = wx.BoxSizer(wx.VERTICAL)
        self._amplitude_dec_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_amplitude_dec_sizer,
        	value=self.amplitude_dec,
        	callback=self.set_amplitude_dec,
        	label="Amplitude Decimation",
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._amplitude_dec_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_amplitude_dec_sizer,
        	value=self.amplitude_dec,
        	callback=self.set_amplitude_dec,
        	minimum=0,
        	maximum=1000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_amplitude_dec_sizer)
        self.wxgui_waterfallsink2_0_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/initial_dec,
        	fft_size=256,
        	fft_rate=65,
        	average=False,
        	avg_alpha=None,
        	title="Decimated IQ",
        )
        self.notebook_0.GetPage(0).Add(self.wxgui_waterfallsink2_0_0.win)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_f(
        	self.notebook_0.GetPage(0).GetWin(),
        	title="Filtered Magnitude",
        	sample_rate=samp_rate/initial_dec/complex_dec/amplitude_dec,
        	v_scale=.000000005,
        	v_offset=0,
        	t_scale=.5,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.notebook_0.GetPage(0).Add(self.wxgui_scopesink2_1.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.notebook_0.GetPage(1).GetWin(),
        	title="Pre-demod",
        	sample_rate=samp_rate/initial_dec/complex_dec/amplitude_dec,
        	v_scale=1,
        	v_offset=.00000,
        	t_scale=0.5,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.notebook_0.GetPage(1).Add(self.wxgui_scopesink2_0.win)
        self.low_pass_filter_0_0 = filter.fir_filter_fff(amplitude_dec, firdes.low_pass(
        	1, (samp_rate/initial_dec)/complex_dec, amplitude_filter, 50, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(complex_dec, firdes.low_pass(
        	1, samp_rate/initial_dec, bandwidth, 20, firdes.WIN_HAMMING, 6.76))
        self.funtenna_ook_demod_funtenna_demod_1 = funtenna_ook_demod.funtenna_demod(sample_threshold)
        self.funtenna_ook_demod_funtenna_decode_1 = funtenna_ook_demod.funtenna_decode(([1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0]))
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(initial_dec, (1, ), center_freq, samp_rate)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(.000000001 * symbol_threshold, .000000001 * symbol_threshold, 0)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "./funtenna_iq.bin", True)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "./funtenna_out.txt", False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.low_pass_filter_0_0, 0))    
        self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_threshold_ff_0, 0), (self.funtenna_ook_demod_funtenna_demod_1, 0))    
        self.connect((self.blocks_threshold_ff_0, 0), (self.wxgui_scopesink2_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_waterfallsink2_0_0, 0))    
        self.connect((self.funtenna_ook_demod_funtenna_decode_1, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.funtenna_ook_demod_funtenna_demod_1, 0), (self.funtenna_ook_demod_funtenna_decode_1, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self.low_pass_filter_0_0, 0), (self.blocks_threshold_ff_0, 0))    
        self.connect((self.low_pass_filter_0_0, 0), (self.wxgui_scopesink2_1, 0))    
Ejemplo n.º 30
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="DVBT Scanner")

        ##################################################
        # Variables
        ##################################################
        self.threshold = threshold = -60
        self.signal_level = signal_level = 0
        self.samp_rate = samp_rate = 2048000
        self.freq = freq = 525200000
        self.fft_size = fft_size = 1024
        self.detected = detected = 0

        ##################################################
        # Blocks
        ##################################################
        _threshold_sizer = wx.BoxSizer(wx.VERTICAL)
        self._threshold_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_threshold_sizer,
            value=self.threshold,
            callback=self.set_threshold,
            label="Threshold",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._threshold_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_threshold_sizer,
            value=self.threshold,
            callback=self.set_threshold,
            minimum=-100,
            maximum=0,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_threshold_sizer, 2, 0, 1, 1)
        self.probe_signal_lvl = blocks.probe_signal_f()
        self.notebook = self.notebook = wx.Notebook(self.GetWin(),
                                                    style=wx.NB_TOP)
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "Spektrum")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "Output")
        self.GridAdd(self.notebook, 0, 0, 1, 1)
        _freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_freq_sizer,
            value=self.freq,
            callback=self.set_freq,
            label="Frequency",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._freq_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_freq_sizer,
            value=self.freq,
            callback=self.set_freq,
            minimum=478000000,
            maximum=862000000,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_freq_sizer, 1, 0, 1, 1)
        self.wxgui_numbersink2_1 = numbersink2.number_sink_f(
            self.notebook.GetPage(1).GetWin(),
            unit="Signal present",
            minval=0,
            maxval=1,
            factor=1.0,
            decimal_places=0,
            ref_level=0,
            sample_rate=samp_rate,
            number_rate=15,
            average=False,
            avg_alpha=None,
            label="Signal Detection",
            peak_hold=False,
            show_gauge=True,
        )
        self.notebook.GetPage(1).Add(self.wxgui_numbersink2_1.win)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
            self.notebook.GetPage(1).GetWin(),
            unit="dB",
            minval=-120,
            maxval=0,
            factor=1.0,
            decimal_places=1,
            ref_level=0,
            sample_rate=samp_rate,
            number_rate=15,
            average=False,
            avg_alpha=0.03,
            label="Level",
            peak_hold=False,
            show_gauge=True,
        )
        self.notebook.GetPage(1).Add(self.wxgui_numbersink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.notebook.GetPage(0).GetWin(),
            baseband_freq=freq,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=fft_size,
            fft_rate=15,
            average=True,
            avg_alpha=0.03,
            title="FFT Plot",
            peak_hold=False,
            win=window.flattop,
        )
        self.notebook.GetPage(0).Add(self.wxgui_fftsink2_0.win)

        def _signal_level_probe():
            while True:
                val = self.probe_signal_lvl.level()
                try:
                    self.set_signal_level(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (5))

        _signal_level_thread = threading.Thread(target=_signal_level_probe)
        _signal_level_thread.daemon = True
        _signal_level_thread.start()
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              "hackrf=0")
        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(14, 0)
        self.rtlsdr_source_0.set_if_gain(24, 0)
        self.rtlsdr_source_0.set_bb_gain(12, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)

        self.probe_detected = blocks.probe_signal_f()
        self.fft_vxx_0 = fft.fft_vcc(fft_size, True,
                                     (window.rectangular(fft_size)), True, 1)

        def _detected_probe():
            while True:
                val = self.probe_detected.level()
                try:
                    self.set_detected(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (5))

        _detected_thread = threading.Thread(target=_detected_probe)
        _detected_thread.daemon = True
        _detected_thread.start()
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_float * 1, fft_size)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(
            threshold, threshold, threshold)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, fft_size)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            1000, 0.001, 4000)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(
            fft_size)
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 1048580)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.probe_signal_lvl, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.wxgui_numbersink2_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0), (self.probe_detected, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.wxgui_numbersink2_1, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_divide_xx_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Output Window")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.threshold = threshold = -55
        self.samp_rate = samp_rate = 2.048e6
        self.freq = freq = 658e6
        self.fft_size = fft_size = 1.024e3

        ##################################################
        # Blocks
        ##################################################
        self.notebook = self.notebook = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "Spectrum")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "Output")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "Stream")
        self.Add(self.notebook)
        _threshold_sizer = wx.BoxSizer(wx.VERTICAL)
        self._threshold_text_box = forms.text_box(
        	parent=self.notebook.GetPage(1).GetWin(),
        	sizer=_threshold_sizer,
        	value=self.threshold,
        	callback=self.set_threshold,
        	label="Threshold",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._threshold_slider = forms.slider(
        	parent=self.notebook.GetPage(1).GetWin(),
        	sizer=_threshold_sizer,
        	value=self.threshold,
        	callback=self.set_threshold,
        	minimum=-100,
        	maximum=0,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.notebook.GetPage(1).Add(_threshold_sizer)
        _freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_text_box = forms.text_box(
        	parent=self.notebook.GetPage(0).GetWin(),
        	sizer=_freq_sizer,
        	value=self.freq,
        	callback=self.set_freq,
        	label="freq",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._freq_slider = forms.slider(
        	parent=self.notebook.GetPage(0).GetWin(),
        	sizer=_freq_sizer,
        	value=self.freq,
        	callback=self.set_freq,
        	minimum=10e6,
        	maximum=10e9,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.notebook.GetPage(0).Add(_freq_sizer)
        self.wxgui_numbersink2_1 = numbersink2.number_sink_f(
        	self.notebook.GetPage(1).GetWin(),
        	unit="signal present",
        	minval=0,
        	maxval=1,
        	factor=1,
        	decimal_places=0,
        	ref_level=0,
        	sample_rate=samp_rate,
        	number_rate=15,
        	average=False,
        	avg_alpha=None,
        	label="Signal Detection",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.notebook.GetPage(1).Add(self.wxgui_numbersink2_1.win)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
        	self.notebook.GetPage(1).GetWin(),
        	unit="dB",
        	minval=-120,
        	maxval=0,
        	factor=1.0,
        	decimal_places=10,
        	ref_level=0,
        	sample_rate=samp_rate,
        	number_rate=15,
        	average=False,
        	avg_alpha=30e-3,
        	label="level",
        	peak_hold=False,
        	show_gauge=False,
        )
        self.notebook.GetPage(1).Add(self.wxgui_numbersink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.notebook.GetPage(0).GetWin(),
        	baseband_freq=freq,
        	y_per_div=5,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=True,
        	avg_alpha=30e-3,
        	title="Spectrum",
        	peak_hold=False,
        	win=window.rectangular,
        )
        self.notebook.GetPage(0).Add(self.wxgui_fftsink2_0.win)
        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(20, 0)
        self.rtlsdr_source_0.set_if_gain(10, 0)
        self.rtlsdr_source_0.set_bb_gain(5, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        self.fft_1 = fft.fft_vcc(1024, True, (window.rectangular(1024)), True, 1)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float*1, 1024)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(-100, threshold, 0)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 1024)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, "/media/shashwat/DATA/Q3/Wireless Networking/gnu codes/Outputs/db_498", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1024)
        self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 1.04858e6)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_divide_xx_0, 1))    
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_vector_to_stream_0, 0))    
        self.connect((self.blocks_divide_xx_0, 0), (self.blocks_nlog10_ff_0, 0))    
        self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_threshold_ff_0, 0))    
        self.connect((self.blocks_nlog10_ff_0, 0), (self.wxgui_numbersink2_0, 0))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_1, 0))    
        self.connect((self.blocks_threshold_ff_0, 0), (self.wxgui_numbersink2_1, 0))    
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_divide_xx_0, 0))    
        self.connect((self.fft_1, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_stream_to_vector_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0))    
Ejemplo n.º 32
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.ntaps = ntaps = 1408
        self.nfilts = nfilts = 32
        self.excess_bw = excess_bw = 0.45
        self.timing_bw = timing_bw = 2 * pi / 100
        self.sr2 = sr2 = 300000
        self.samp_rate_0 = samp_rate_0 = 32000
        self.samp_rate = samp_rate = 100000
        self.s = s = 0.01
        self.rx_taps = rx_taps = filter.firdes.root_raised_cosine(nfilts, nfilts * sps, 1.0, excess_bw, ntaps)
        self.freq_bw = freq_bw = 2 * pi / 100
        self.fll_ntaps = fll_ntaps = 55

        ##################################################
        # Blocks
        ##################################################
        self.n = self.n = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.n.AddPage(grc_wxgui.Panel(self.n), "tab1")
        self.n.AddPage(grc_wxgui.Panel(self.n), "tab2")
        self.n.AddPage(grc_wxgui.Panel(self.n), "tab3")
        self.Add(self.n)
        self.wxgui_scopesink2_2 = scopesink2.scope_sink_c(
            self.n.GetPage(1).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.n.GetPage(1).Add(self.wxgui_scopesink2_2.win)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_f(
            self.n.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.n.GetPage(0).Add(self.wxgui_scopesink2_1.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
            self.n.GetPage(2).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.n.GetPage(2).Add(self.wxgui_scopesink2_0.win)
        _s_sizer = wx.BoxSizer(wx.VERTICAL)
        self._s_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_s_sizer,
            value=self.s,
            callback=self.set_s,
            label="s",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._s_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_s_sizer,
            value=self.s,
            callback=self.set_s,
            minimum=-5,
            maximum=5,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_s_sizer)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
            4, taps=(firdes.root_raised_cosine(32, 32, 1.0, 0.45, 1408)), flt_size=32
        )
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.iir_filter_xxx_0_0 = filter.iir_filter_ffd(([1.0001, -1]), ([-1, 1]), True)
        self.iir_filter_xxx_0 = filter.iir_filter_ffd((0.01,), ([-1, 0.99]), True)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(4, 2 * pi / 100, (rx_taps), 32, 16, 1.5, 1)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            (((1 + 1j), (1 - 1j), (-1 + 1j), (-1 - 1j))), 1
        )
        self.blocks_vco_c_0 = blocks.vco_c(samp_rate, -5, 1)
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_float * 1, "127.0.0.1", 12345, 1472, True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_float * 1, "127.0.0.1", 12345, 1472, True)
        self.blocks_threshold_ff_0_0 = blocks.threshold_ff(-0.001, 0.001, 0)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(-0.001, 0.001, 0)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_multiply_xx_2 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((1,))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((1.413,))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1.413,))
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 1000)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_add_const_vxx_0_0 = blocks.add_const_vff((-0.5,))
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-0.5,))
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_SIN_WAVE, 10, 1, 0)
        self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 4, 1000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_add_const_vxx_0_0, 0), (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_complex_to_imag_0, 0), (self.blocks_multiply_xx_2, 1))
        self.connect((self.blocks_complex_to_imag_0, 0), (self.blocks_threshold_ff_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.iir_filter_xxx_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_xx_2, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.iir_filter_xxx_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_add_const_vxx_0_0, 0))
        self.connect((self.blocks_udp_source_0, 0), (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.blocks_vco_c_0, 0), (self.blocks_multiply_xx_0, 2))
        self.connect((self.blocks_vco_c_0, 0), (self.wxgui_scopesink2_2, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_complex_to_imag_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.iir_filter_xxx_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.iir_filter_xxx_0, 0), (self.wxgui_scopesink2_1, 0))
        self.connect((self.iir_filter_xxx_0_0, 0), (self.blocks_vco_c_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0))
Ejemplo n.º 33
0
    def __init__(self, storageval):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 192000
        self.pulse_width = pulse_width = 0.07
        self.pseudo_frequency = pseudo_frequency = 1
        self.fft_size = fft_size = 1024
        self.blocksize = blocksize = int(samp_rate / fft_size * pseudo_frequency *1.0 / (1.0 / pulse_width))  / 2
        self.timeout_blocks = timeout_blocks = int(samp_rate/fft_size * 1.0/blocksize)
        self.target_freq = target_freq = 457000
        self.measure = measure = 0
        self.firdes_tap = firdes_tap = firdes.low_pass(1, samp_rate, 500, 1000, firdes.WIN_HAMMING, 6.76)
        self.base_freq = base_freq = 450000
        self.burst_trigger = burst_trigger = 0.75
        self.storageval = storageval

        ##################################################
        # Blocks
        ##################################################
        self.probe = blocks.probe_signal_f()
        self.stbpilot_signal_level_0 = stbpilot.signal_level(6, timeout_blocks)
        def _measure_probe():
            while True:
                val = self.probe.level()
                try:
                    self.set_measure(val)
                    self.storageval.value = val
                except AttributeError:
                    pass
                time.sleep(1.0 / (1))
        _measure_thread = threading.Thread(target=_measure_probe)
        _measure_thread.daemon = True
        _measure_thread.start()
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (firdes_tap), -(base_freq - target_freq), samp_rate)
        self.fft_vxx_0 = fft.fft_vcc(fft_size, True, (), True, 1)
        self.fcdproplus_fcdproplus_0 = fcdproplus.fcdproplus("",1)
        self.fcdproplus_fcdproplus_0.set_lna(1)
        self.fcdproplus_fcdproplus_0.set_mixer_gain(1)
        self.fcdproplus_fcdproplus_0.set_if_gain(0)
        self.fcdproplus_fcdproplus_0.set_freq_corr(0)
        self.fcdproplus_fcdproplus_0.set_freq(base_freq)
          
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, fft_size)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(burst_trigger, burst_trigger, 0)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_size)
        self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_float*1, (int(target_freq*1.0*fft_size/samp_rate)+1)*0+513)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_keep_one_in_n_1 = blocks.keep_one_in_n(gr.sizeof_float*1, fft_size)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_complex_to_mag_0, 0))
        self.connect((self.fcdproplus_fcdproplus_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_keep_one_in_n_1, 0), (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_keep_one_in_n_1, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_skiphead_0, 0))
        self.connect((self.blocks_skiphead_0, 0), (self.blocks_keep_one_in_n_1, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.stbpilot_signal_level_0, 0))
        self.connect((self.stbpilot_signal_level_0, 0), (self.probe, 0))
Ejemplo n.º 34
0
    def __init__(self):
        gr.top_block.__init__(self, "Receiver NC-OFDM")

        ##################################################
        # Variables
        ##################################################
        self.shseq_len = shseq_len = 40
        self.pn_symbols = pn_symbols = (1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1)
        self.lgseq_len = lgseq_len = 320
        self.fft_len = fft_len = 64
        self.dataseq_len = dataseq_len = 64
        self.shseq_rep = shseq_rep = 8
        self.shseq = shseq = pn_symbols[0:shseq_len]
        self.samp_rate = samp_rate = 1000000
        self.pilot_symbols = pilot_symbols = ((1, 1, 1, -1,),)
        self.pilot_carriers = pilot_carriers = ((-21, -7, 7, 21,),)
        self.packet_len = packet_len = 3*len(range(-26, -21)+ range(-20,-7) + range(8, 21) + range(22, 27),)
        self.occupied_carriers = occupied_carriers = (range(-26, -21)+ range(-20,-7) + range(8, 21) + range(22, 27),)
        self.lgseq = lgseq = pn_symbols[shseq_len:shseq_len+lgseq_len]
        self.length_tag_name = length_tag_name = "packet_len"
        self.fileprefix = fileprefix = "/root/"
        self.data_len = data_len = dataseq_len*20
        self.cp_len = cp_len = fft_len/4
        self.cen_freq = cen_freq = 1500000000
        self.ShThreshold = ShThreshold = 10
        self.ShRepThreshold = ShRepThreshold = 3.5
        self.LgThreshold = LgThreshold = 60

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source = uhd.usrp_source(
        	",".join(("", "")),
        	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(cen_freq, 0)
        self.uhd_usrp_source.set_gain(10, 0)
        self.null_sink_shortpncorr_out = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.null_sink_longpncorrv2_out = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.null_sink_longpncorrv2_flag = blocks.null_sink(gr.sizeof_int*1)
        self.null_sink_longpncorrv2_corr = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.ncofdm_ShortPNdetector = ncofdm.ShortPNdetector(fft_len, cp_len, shseq_rep, shseq_len, 1)
        self.ncofdm_ShortPNcorr = ncofdm.ShortPNcorr(fft_len, cp_len, shseq_rep, shseq_len, (shseq))
        self.ncofdm_LongPNcorrV2 = ncofdm.LongPNcorrV2(fft_len, cp_len, lgseq_len, (lgseq), 60, shseq_len*shseq_rep+lgseq_len+data_len+10)
        self.ncofdm_FreqOffCalc = ncofdm.FreqOffCalc(fft_len, fft_len/4, shseq_len, shseq_rep)
        self.file_sink_short = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"short.dat", False)
        self.file_sink_short.set_unbuffered(False)
        self.file_sink_rxshth = blocks.file_sink(gr.sizeof_float*1, fileprefix+"rxshth.dat", False)
        self.file_sink_rxshth.set_unbuffered(False)
        self.file_sink_org = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"org.dat", False)
        self.file_sink_org.set_unbuffered(False)
        self.file_sink_long = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"long.dat", False)
        self.file_sink_long.set_unbuffered(False)
        self.file_sink_lgth = blocks.file_sink(gr.sizeof_float*1, fileprefix+"lgth.dat", False)
        self.file_sink_lgth.set_unbuffered(False)
        self.file_sink_gain = blocks.file_sink(gr.sizeof_float*1, fileprefix+"gain.dat", False)
        self.file_sink_gain.set_unbuffered(False)
        self.file_sink_freqoff = blocks.file_sink(gr.sizeof_float*1, fileprefix+"freqoff.dat", False)
        self.file_sink_freqoff.set_unbuffered(False)
        self.file_sink_corr = blocks.file_sink(gr.sizeof_int*1, fileprefix+"corr.dat", False)
        self.file_sink_corr.set_unbuffered(False)
        self.blocks_threshold_ff = blocks.threshold_ff(ShRepThreshold, ShRepThreshold, 0)
        self.blocks_moving_average = blocks.moving_average_ff(100, 0.01, 4000)
        self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex*1, 10000)
        self.blocks_float_to_int = blocks.float_to_int(1, 1)
        self.blocks_float_to_complex_lgpn_input = blocks.float_to_complex(1)
        self.blocks_delay_shpn_lgpn = blocks.delay(gr.sizeof_float*1, 2)
        self.blocks_delay_shpn_freqoff = blocks.delay(gr.sizeof_int*1, 1)
        self.blocks_delay_freqoff_lgpn = blocks.delay(gr.sizeof_float*1, 2)
        self.blocks_complex_to_real_lgth = blocks.complex_to_real(1)
        self.blocks_complex_to_mag_org = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag = blocks.complex_to_mag(1)
        self.analog_agc = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc.set_max_gain(50000.0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc, 0), (self.blocks_complex_to_mag_org, 0))    
        self.connect((self.analog_agc, 1), (self.file_sink_gain, 0))    
        self.connect((self.analog_agc, 0), (self.file_sink_org, 0))    
        self.connect((self.analog_agc, 0), (self.ncofdm_LongPNcorrV2, 0))    
        self.connect((self.analog_agc, 0), (self.ncofdm_ShortPNcorr, 0))    
        self.connect((self.blocks_complex_to_mag, 0), (self.ncofdm_ShortPNdetector, 0))    
        self.connect((self.blocks_complex_to_mag_org, 0), (self.blocks_moving_average, 0))    
        self.connect((self.blocks_complex_to_real_lgth, 0), (self.file_sink_lgth, 0))    
        self.connect((self.blocks_delay_freqoff_lgpn, 0), (self.blocks_float_to_complex_lgpn_input, 0))    
        self.connect((self.blocks_delay_freqoff_lgpn, 0), (self.file_sink_freqoff, 0))    
        self.connect((self.blocks_delay_shpn_freqoff, 0), (self.ncofdm_FreqOffCalc, 1))    
        self.connect((self.blocks_delay_shpn_lgpn, 0), (self.blocks_float_to_complex_lgpn_input, 1))    
        self.connect((self.blocks_float_to_complex_lgpn_input, 0), (self.ncofdm_LongPNcorrV2, 1))    
        self.connect((self.blocks_float_to_int, 0), (self.blocks_delay_shpn_freqoff, 0))    
        self.connect((self.blocks_head_0, 0), (self.analog_agc, 0))    
        self.connect((self.blocks_moving_average, 0), (self.ncofdm_LongPNcorrV2, 2))    
        self.connect((self.blocks_threshold_ff, 0), (self.blocks_delay_shpn_lgpn, 0))    
        self.connect((self.blocks_threshold_ff, 0), (self.blocks_float_to_int, 0))    
        self.connect((self.ncofdm_FreqOffCalc, 0), (self.blocks_delay_freqoff_lgpn, 0))    
        self.connect((self.ncofdm_LongPNcorrV2, 0), (self.blocks_complex_to_real_lgth, 0))    
        self.connect((self.ncofdm_LongPNcorrV2, 2), (self.file_sink_corr, 0))    
        self.connect((self.ncofdm_LongPNcorrV2, 1), (self.file_sink_long, 0))    
        self.connect((self.ncofdm_LongPNcorrV2, 1), (self.null_sink_longpncorrv2_corr, 0))    
        self.connect((self.ncofdm_LongPNcorrV2, 2), (self.null_sink_longpncorrv2_flag, 0))    
        self.connect((self.ncofdm_LongPNcorrV2, 0), (self.null_sink_longpncorrv2_out, 0))    
        self.connect((self.ncofdm_ShortPNcorr, 1), (self.blocks_complex_to_mag, 0))    
        self.connect((self.ncofdm_ShortPNcorr, 1), (self.file_sink_short, 0))    
        self.connect((self.ncofdm_ShortPNcorr, 1), (self.ncofdm_FreqOffCalc, 0))    
        self.connect((self.ncofdm_ShortPNcorr, 0), (self.null_sink_shortpncorr_out, 0))    
        self.connect((self.ncofdm_ShortPNdetector, 0), (self.blocks_threshold_ff, 0))    
        self.connect((self.ncofdm_ShortPNdetector, 1), (self.file_sink_rxshth, 0))    
        self.connect((self.uhd_usrp_source, 0), (self.blocks_head_0, 0))    
Ejemplo n.º 35
0
    def __init__(self, fft_length, cp_length, snr, kstime, logging):
        ''' Maximum Likelihood OFDM synchronizer:
        J. van de Beek, M. Sandell, and P. O. Borjesson, "ML Estimation
        of Time and Frequency Offset in OFDM Systems," IEEE Trans.
        Signal Processing, vol. 45, no. 7, pp. 1800-1805, 1997.
        '''

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

        self.input = blocks.add_const_cc(0)

        SNR = 10.0**(snr / 10.0)
        rho = SNR / (SNR + 1.0)
        symbol_length = fft_length + cp_length

        # ML Sync

        # Energy Detection from ML Sync

        self.connect(self, self.input)

        # Create a delay line
        self.delay = blocks.delay(gr.sizeof_gr_complex, fft_length)
        self.connect(self.input, self.delay)

        # magnitude squared blocks
        self.magsqrd1 = blocks.complex_to_mag_squared()
        self.magsqrd2 = blocks.complex_to_mag_squared()
        self.adder = blocks.add_ff()

        moving_sum_taps = [rho / 2 for i in range(cp_length)]
        self.moving_sum_filter = filter.fir_filter_fff(1,moving_sum_taps)

        self.connect(self.input,self.magsqrd1)
        self.connect(self.delay,self.magsqrd2)
        self.connect(self.magsqrd1,(self.adder,0))
        self.connect(self.magsqrd2,(self.adder,1))
        self.connect(self.adder,self.moving_sum_filter)


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

        movingsum2_taps = [1.0 for i in range(cp_length)]
        self.movingsum2 = filter.fir_filter_ccf(1,movingsum2_taps)

        # Correlator data handler
        self.c2mag = blocks.complex_to_mag()
        self.angle = blocks.complex_to_arg()
        self.connect(self.input,(self.mixer,1))
        self.connect(self.delay,self.conjg,(self.mixer,0))
        self.connect(self.mixer,self.movingsum2,self.c2mag)
        self.connect(self.movingsum2,self.angle)

        # ML Sync output arg, need to find maximum point of this
        self.diff = blocks.sub_ff()
        self.connect(self.c2mag,(self.diff,0))
        self.connect(self.moving_sum_filter,(self.diff,1))

        #ML measurements input to sampler block and detect
        self.f2c = blocks.float_to_complex()
        self.pk_detect = blocks.peak_detector_fb(0.2, 0.25, 30, 0.0005)
        self.sample_and_hold = blocks.sample_and_hold_ff()

        # use the sync loop values to set the sampler and the NCO
        #     self.diff = theta
        #     self.angle = epsilon

        self.connect(self.diff, self.pk_detect)

        # The DPLL corrects for timing differences between CP correlations
        use_dpll = 0
        if use_dpll:
            self.dpll = gr.dpll_bb(float(symbol_length),0.01)
            self.connect(self.pk_detect, self.dpll)
            self.connect(self.dpll, (self.sample_and_hold,1))
        else:
            self.connect(self.pk_detect, (self.sample_and_hold,1))

        self.connect(self.angle, (self.sample_and_hold,0))

        ################################
        # correlate against known symbol
        # This gives us the same timing signal as the PN sync block only on the preamble
        # we don't use the signal generated from the CP correlation because we don't want
        # to readjust the timing in the middle of the packet or we ruin the equalizer settings.
        kstime = [k.conjugate() for k in kstime]
        kstime.reverse()
        self.kscorr = filter.fir_filter_ccc(1, kstime)
        self.corrmag = blocks.complex_to_mag_squared()
        self.div = blocks.divide_ff()

        # The output signature of the correlation has a few spikes because the rest of the
        # system uses the repeated preamble symbol. It needs to work that generically if
        # anyone wants to use this against a WiMAX-like signal since it, too, repeats.
        # The output theta of the correlator above is multiplied with this correlation to
        # identify the proper peak and remove other products in this cross-correlation
        self.threshold_factor = 0.1
        self.slice = blocks.threshold_ff(self.threshold_factor, self.threshold_factor, 0)
        self.f2b = blocks.float_to_char()
        self.b2f = blocks.char_to_float()
        self.mul = blocks.multiply_ff()

        # Normalize the power of the corr output by the energy. This is not really needed
        # and could be removed for performance, but it makes for a cleaner signal.
        # if this is removed, the threshold value needs adjustment.
        self.connect(self.input, self.kscorr, self.corrmag, (self.div,0))
        self.connect(self.moving_sum_filter, (self.div,1))

        self.connect(self.div, (self.mul,0))
        self.connect(self.pk_detect, self.b2f, (self.mul,1))
        self.connect(self.mul, self.slice)

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


        if logging:
            self.connect(self.moving_sum_filter, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-energy_f.dat"))
            self.connect(self.diff, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-theta_f.dat"))
            self.connect(self.angle, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-epsilon_f.dat"))
            self.connect(self.corrmag, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-corrmag_f.dat"))
            self.connect(self.kscorr, blocks.file_sink(gr.sizeof_gr_complex, "ofdm_sync_ml-kscorr_c.dat"))
            self.connect(self.div, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-div_f.dat"))
            self.connect(self.mul, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-mul_f.dat"))
            self.connect(self.slice, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-slice_f.dat"))
            self.connect(self.pk_detect, blocks.file_sink(gr.sizeof_char, "ofdm_sync_ml-peaks_b.dat"))
            if use_dpll:
                self.connect(self.dpll, blocks.file_sink(gr.sizeof_char, "ofdm_sync_ml-dpll_b.dat"))

            self.connect(self.sample_and_hold, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-sample_and_hold_f.dat"))
            self.connect(self.input, blocks.file_sink(gr.sizeof_gr_complex, "ofdm_sync_ml-input_c.dat"))
Ejemplo n.º 36
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="DVBT Scanner")

        ##################################################
        # Variables
        ##################################################
        self.threshold = threshold = -60
        self.signal_level = signal_level = 0
        self.samp_rate = samp_rate = 2048000
        self.freq = freq = 525200000
        self.fft_size = fft_size = 1024
        self.detected = detected = 0

        ##################################################
        # Blocks
        ##################################################
        _threshold_sizer = wx.BoxSizer(wx.VERTICAL)
        self._threshold_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_threshold_sizer,
        	value=self.threshold,
        	callback=self.set_threshold,
        	label="Threshold",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._threshold_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_threshold_sizer,
        	value=self.threshold,
        	callback=self.set_threshold,
        	minimum=-100,
        	maximum=0,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_threshold_sizer, 2, 0, 1, 1)
        self.probe_signal_lvl = blocks.probe_signal_f()
        self.notebook = self.notebook = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "Spektrum")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "Output")
        self.GridAdd(self.notebook, 0, 0, 1, 1)
        _freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_freq_sizer,
        	value=self.freq,
        	callback=self.set_freq,
        	label="Frequency",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._freq_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_freq_sizer,
        	value=self.freq,
        	callback=self.set_freq,
        	minimum=478000000,
        	maximum=862000000,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_freq_sizer, 1, 0, 1, 1)
        self.wxgui_numbersink2_1 = numbersink2.number_sink_f(
        	self.notebook.GetPage(1).GetWin(),
        	unit="Signal present",
        	minval=0,
        	maxval=1,
        	factor=1.0,
        	decimal_places=0,
        	ref_level=0,
        	sample_rate=samp_rate,
        	number_rate=15,
        	average=False,
        	avg_alpha=None,
        	label="Signal Detection",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.notebook.GetPage(1).Add(self.wxgui_numbersink2_1.win)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
        	self.notebook.GetPage(1).GetWin(),
        	unit="dB",
        	minval=-120,
        	maxval=0,
        	factor=1.0,
        	decimal_places=1,
        	ref_level=0,
        	sample_rate=samp_rate,
        	number_rate=15,
        	average=False,
        	avg_alpha=0.03,
        	label="Level",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.notebook.GetPage(1).Add(self.wxgui_numbersink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.notebook.GetPage(0).GetWin(),
        	baseband_freq=freq,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=fft_size,
        	fft_rate=15,
        	average=True,
        	avg_alpha=0.03,
        	title="FFT Plot",
        	peak_hold=False,
        	win=window.flattop,
        )
        self.notebook.GetPage(0).Add(self.wxgui_fftsink2_0.win)
        def _signal_level_probe():
            while True:
                val = self.probe_signal_lvl.level()
                try:
                    self.set_signal_level(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (5))
        _signal_level_thread = threading.Thread(target=_signal_level_probe)
        _signal_level_thread.daemon = True
        _signal_level_thread.start()
        self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "hackrf=0" )
        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(14, 0)
        self.rtlsdr_source_0.set_if_gain(24, 0)
        self.rtlsdr_source_0.set_bb_gain(12, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        self.probe_detected = blocks.probe_signal_f()
        self.fft_vxx_0 = fft.fft_vcc(fft_size, True, (window.rectangular(fft_size)), True, 1)
        def _detected_probe():
            while True:
                val = self.probe_detected.level()
                try:
                    self.set_detected(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (5))
        _detected_thread = threading.Thread(target=_detected_probe)
        _detected_thread.daemon = True
        _detected_thread.start()
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float*1, fft_size)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(threshold, threshold, threshold)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_size)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(1000, 0.001, 4000)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(fft_size)
        self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 1048580)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_divide_xx_0, 1))    
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_vector_to_stream_0, 0))    
        self.connect((self.blocks_divide_xx_0, 0), (self.blocks_nlog10_ff_0, 0))    
        self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_threshold_ff_0, 0))    
        self.connect((self.blocks_moving_average_xx_0, 0), (self.probe_signal_lvl, 0))    
        self.connect((self.blocks_moving_average_xx_0, 0), (self.wxgui_numbersink2_0, 0))    
        self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_moving_average_xx_0, 0))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))    
        self.connect((self.blocks_threshold_ff_0, 0), (self.probe_detected, 0))    
        self.connect((self.blocks_threshold_ff_0, 0), (self.wxgui_numbersink2_1, 0))    
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_divide_xx_0, 0))    
        self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_stream_to_vector_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0))    
Ejemplo n.º 37
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

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

        ##################################################
        # Blocks
        ##################################################
        _threshold_sizer = wx.BoxSizer(wx.VERTICAL)
        self._threshold_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_threshold_sizer,
        	value=self.threshold,
        	callback=self.set_threshold,
        	label="threshold",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._threshold_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_threshold_sizer,
        	value=self.threshold,
        	callback=self.set_threshold,
        	minimum=-100,
        	maximum=0,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_threshold_sizer)
        self.wxgui_numbersink2_0_0 = numbersink2.number_sink_f(
        	self.GetWin(),
        	unit="signal present",
        	minval=0,
        	maxval=1,
        	factor=1.0,
        	decimal_places=10,
        	ref_level=0,
        	sample_rate=2.048e6,
        	number_rate=15,
        	average=False,
        	avg_alpha=None,
        	label="Signal detection",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0_0.win)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
        	self.GetWin(),
        	unit="Units",
        	minval=-120,
        	maxval=0,
        	factor=1.0,
        	decimal_places=10,
        	ref_level=0,
        	sample_rate=2048000,
        	number_rate=15,
        	average=True,
        	avg_alpha=0.03,
        	label="Level",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=2048000,
        	fft_size=1024,
        	fft_rate=15,
        	average=True,
        	avg_alpha=0.030,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.rtlsdr_source_0.set_sample_rate(2.048e6)
        self.rtlsdr_source_0.set_center_freq(freq, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(2, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(75, 0)
        self.rtlsdr_source_0.set_if_gain(75, 0)
        self.rtlsdr_source_0.set_bb_gain(5, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab1")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab2")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab3")
        self.Add(self.notebook_0)
        _freq_0_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_0_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_freq_0_sizer,
        	value=self.freq_0,
        	callback=self.set_freq_0,
        	label='freq_0',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._freq_0_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_freq_0_sizer,
        	value=self.freq_0,
        	callback=self.set_freq_0,
        	minimum=478e6,
        	maximum=862e6,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_freq_0_sizer)
        self.fft_vxx_0 = fft.fft_vcc(1024, True, (window.rectangular(1024)), True, 1)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float*1, 1024)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, 2048000,True)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(-100, threshold, -60)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 1024)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_int*1, "/media/ubuntu/01D165566F075780/Q3/wireless networking/GNU/out1.txt", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1024)
        self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 1.04858e6)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_divide_xx_0, 1))    
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_vector_to_stream_0, 0))    
        self.connect((self.blocks_divide_xx_0, 0), (self.blocks_nlog10_ff_0, 0))    
        self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_threshold_ff_0, 0))    
        self.connect((self.blocks_nlog10_ff_0, 0), (self.wxgui_numbersink2_0, 0))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))    
        self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.blocks_threshold_ff_0, 0), (self.wxgui_numbersink2_0_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.blocks_stream_to_vector_0, 0))    
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_divide_xx_0, 0))    
        self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0))    
Ejemplo n.º 38
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

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

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

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

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.wxgui_numbersink2_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.wxgui_numbersink2_0_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_divide_xx_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
Ejemplo n.º 39
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Hysteresis")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 128000
        self.noise = noise = 0.05
        self.level = level = 0

        ##################################################
        # Blocks
        ##################################################
        _noise_sizer = wx.BoxSizer(wx.VERTICAL)
        self._noise_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_noise_sizer,
        	value=self.noise,
        	callback=self.set_noise,
        	label="Noise",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._noise_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_noise_sizer,
        	value=self.noise,
        	callback=self.set_noise,
        	minimum=0,
        	maximum=1,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_noise_sizer)
        _level_sizer = wx.BoxSizer(wx.VERTICAL)
        self._level_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_level_sizer,
        	value=self.level,
        	callback=self.set_level,
        	label="Level",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._level_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_level_sizer,
        	value=self.level,
        	callback=self.set_level,
        	minimum=-1,
        	maximum=2,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_level_sizer)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=samp_rate,
        	v_scale=0.25,
        	v_offset=0.5,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=5,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        	size=(510,320),
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.wxgui_histosink2_0 = histosink_gl.histo_sink_f(
        	self.GetWin(),
        	title="Histogram Plot",
        	num_bins=241,
        	frame_size=10000,
        )
        self.Add(self.wxgui_histosink2_0.win)
        self.blocks_throttle_0_0_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(0.25, 0.75, 0)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.analog_noise_source_x_0 = analog.noise_source_f(analog.GR_GAUSSIAN, noise, 42)
        self.analog_const_source_x_2 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, level)
        self.analog_const_source_x_1 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0.25)
        self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0.75)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_throttle_0_0_0, 0))    
        self.connect((self.analog_const_source_x_1, 0), (self.blocks_throttle_0_0, 0))    
        self.connect((self.analog_const_source_x_2, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1))    
        self.connect((self.analog_noise_source_x_0, 0), (self.wxgui_histosink2_0, 0))    
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_threshold_ff_0, 0))    
        self.connect((self.blocks_add_xx_0, 0), (self.wxgui_scopesink2_0, 3))    
        self.connect((self.blocks_threshold_ff_0, 0), (self.wxgui_scopesink2_0, 2))    
        self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_scopesink2_0, 4))    
        self.connect((self.blocks_throttle_0_0, 0), (self.wxgui_scopesink2_0, 0))    
        self.connect((self.blocks_throttle_0_0_0, 0), (self.wxgui_scopesink2_0, 1))    
Ejemplo n.º 40
0
    def __init__(self):
        gr.top_block.__init__(self, "Bicm Atsc 2")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Bicm Atsc 2")
        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", "BICM_ATSC_2")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000
        self.r = r = 10
        self.n = n = 64800
        self.EsN0_dB = EsN0_dB = [4, 5, 6, 7, 8, 9, 10, 11, 12]

        ##################################################
        # Blocks
        ##################################################
        for EsNo in self.EsN0_dB:
            self._EsN0_dB_range = Range(-50, 50, 1, EsNo, 200)
            self._EsN0_dB_win = RangeWidget(self._EsN0_dB_range,
                                            self.set_EsN0_dB, "EsN0_dB",
                                            "counter_slider", float)
            self.top_layout.addWidget(self._EsN0_dB_win)
            self.qtgui_number_sink_0 = qtgui.number_sink(
                gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1)
            self.qtgui_number_sink_0.set_update_time(0.10)
            self.qtgui_number_sink_0.set_title("")

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

            self.qtgui_number_sink_0.enable_autoscale(False)
            self._qtgui_number_sink_0_win = sip.wrapinstance(
                self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
            self.top_layout.addWidget(self._qtgui_number_sink_0_win)
            self.mapper_atsc_0 = mapper_atsc(
                m=4,
                n=2,
                r=r,
            )
            self.mack_sdr_rossi_Bit_interleaver_ATSC_0 = mack_sdr_rossi.Bit_interleaver_ATSC(
                n, r, 4)
            self.mack_sdr_rossi_Bit_deinterleaver_ATSC_0 = mack_sdr_rossi.Bit_deinterleaver_ATSC(
                n, r, 4)
            self.ldpc_enc_0 = ldpc_enc(
                n=n,
                r=r,
            )
            self.ldpc_dec_0 = ldpc_dec(
                n=n,
                r=r,
            )
            self.demapper_atsc_0 = demapper_atsc(
                m=4,
                r=r,
                size_in=1,
            )
            self.blocks_vector_to_stream_0_0_0 = blocks.vector_to_stream(
                gr.sizeof_float * 1, n)
            self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
                gr.sizeof_char * 1, n)
            self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8)
            self.blocks_threshold_ff_0_0 = blocks.threshold_ff(0, 0, 0)
            self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(
                gr.sizeof_float * 1, n)
            self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
                gr.sizeof_char * 1, n)
            self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)
            self.blocks_file_source_0 = blocks.file_source(
                gr.sizeof_char * 1, '/home/rossi/PN.ts', False)
            self.blocks_file_sink_0 = blocks.file_sink(
                gr.sizeof_char * 1,
                '/media/rossi/02C46D54C46D4ACD/Users/grgan/Desktop/RESULTADOS_COMPLETO/PN_bicm_completo_'
                + str(EsNo) + '.bin', False)
            self.blocks_file_sink_0.set_unbuffered(False)
            self.blocks_add_xx_0 = blocks.add_vcc(1)
            self.blks2_error_rate_0 = grc_blks2.error_rate(
                type='BER',
                win_size=1000000000,
                bits_per_symbol=8,
            )
            self.bch_enc_0 = bch_enc(
                fec=r,
                size=n,
            )
            self.bch_dec_0 = bch_dec(
                fec=r,
                size=n,
            )
            self.analog_noise_source_x_0_0 = analog.noise_source_c(
                analog.GR_GAUSSIAN,
                math.sqrt(1 / math.pow(10.0, (EsNo / 10.0))), 0)

            ##################################################
            # Connections
            ##################################################
            self.connect((self.analog_noise_source_x_0_0, 0),
                         (self.blocks_add_xx_0, 0))
            self.connect((self.bch_dec_0, 0),
                         (self.blocks_pack_k_bits_bb_0, 0))
            self.connect((self.bch_enc_0, 0), (self.ldpc_enc_0, 0))
            self.connect((self.blks2_error_rate_0, 0),
                         (self.qtgui_number_sink_0, 0))
            self.connect((self.blocks_add_xx_0, 0), (self.demapper_atsc_0, 0))
            self.connect((self.blocks_file_source_0, 0),
                         (self.blks2_error_rate_0, 0))
            self.connect((self.blocks_file_source_0, 0),
                         (self.blocks_unpack_k_bits_bb_0, 0))
            self.connect((self.blocks_pack_k_bits_bb_0, 0),
                         (self.blks2_error_rate_0, 1))
            self.connect((self.blocks_pack_k_bits_bb_0, 0),
                         (self.blocks_file_sink_0, 0))
            self.connect((self.blocks_stream_to_vector_0, 0),
                         (self.mack_sdr_rossi_Bit_interleaver_ATSC_0, 0))
            self.connect((self.blocks_stream_to_vector_0_0, 0),
                         (self.mack_sdr_rossi_Bit_deinterleaver_ATSC_0, 0))
            self.connect((self.blocks_threshold_ff_0_0, 0),
                         (self.ldpc_dec_0, 0))
            self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                         (self.bch_enc_0, 0))
            self.connect((self.blocks_vector_to_stream_0, 0),
                         (self.mapper_atsc_0, 0))
            self.connect((self.blocks_vector_to_stream_0_0_0, 0),
                         (self.blocks_threshold_ff_0_0, 0))
            self.connect((self.demapper_atsc_0, 0),
                         (self.blocks_stream_to_vector_0_0, 0))
            self.connect((self.ldpc_dec_0, 0), (self.bch_dec_0, 0))
            self.connect((self.ldpc_enc_0, 0),
                         (self.blocks_stream_to_vector_0, 0))
            self.connect((self.mack_sdr_rossi_Bit_deinterleaver_ATSC_0, 0),
                         (self.blocks_vector_to_stream_0_0_0, 0))
            self.connect((self.mack_sdr_rossi_Bit_interleaver_ATSC_0, 0),
                         (self.blocks_vector_to_stream_0, 0))
            self.connect((self.mapper_atsc_0, 0), (self.blocks_add_xx_0, 1))
        def _probe_detection_probe():
            while True:
                val = self.probe_signal_detection.level()
                try:
                    self.set_probe_detection(val)
                except AttributeError, e:
                    pass
                time.sleep(1.0 / (10))

        _probe_detection_thread = threading.Thread(target=_probe_detection_probe)
        _probe_detection_thread.daemon = True
        _probe_detection_thread.start()
        self.fft_vxx_0 = fft.fft_vcc(fft_size, True, (window.rectangular(fft_size)), True, 1)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float * 1, fft_size)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(threshold, threshold, threshold)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex * 1, fft_size)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(fft_size, 1.0 / fft_size, 4000)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(fft_size)
        self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, fft_size * fft_size)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_divide_xx_0, 0))
        self.connect((self.blocks_divide_xx_0, 0), (self.blocks_nlog10_ff_0, 0))
Ejemplo n.º 42
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.threshold = threshold = -40
        self.samp_rate = samp_rate = 2000000
        self.freq = freq = 446093750

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_numbersink2_0_0 = numbersink2.number_sink_f(
        	self.GetWin(),
        	unit="Units",
        	minval=-100,
        	maxval=100,
        	factor=1.0,
        	decimal_places=10,
        	ref_level=0,
        	sample_rate=samp_rate,
        	number_rate=15,
        	average=False,
        	avg_alpha=None,
        	label="Number Plot",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0_0.win)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
        	self.GetWin(),
        	unit="Units",
        	minval=-100,
        	maxval=100,
        	factor=1.0,
        	decimal_places=10,
        	ref_level=0,
        	sample_rate=samp_rate,
        	number_rate=15,
        	average=False,
        	avg_alpha=None,
        	label="Number Plot",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0.win)
        self.wxgui_fftsink2_2 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=30,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_2.win)
        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(2, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_0.set_gain_mode(0, 0)
        self.rtlsdr_source_0.set_gain(42, 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.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=48,
                decimation=200,
                taps=None,
                fractional_bw=None,
        )
        self.blocks_threshold_ff_0 = blocks.threshold_ff(threshold-1, threshold, 0)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((100, ))
        self.blocks_float_to_int_0 = blocks.float_to_int(1, 1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vii((40, ))
        self.blks2_tcp_sink_0 = grc_blks2.tcp_sink(
        	itemsize=gr.sizeof_int*1,
        	addr="127.0.0.1",
        	port=50000,
        	server=False,
        )
        self.analog_am_demod_cf_0 = analog.am_demod_cf(
        	channel_rate=200e3,
        	audio_decim=1,
        	audio_pass=5000,
        	audio_stop=5500,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_add_const_vxx_0, 0), (self.blks2_tcp_sink_0, 0))
        self.connect((self.blocks_float_to_int_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_float_to_int_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0), (self.wxgui_numbersink2_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_threshold_ff_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.analog_am_demod_cf_0, 0))
        self.connect((self.analog_am_demod_cf_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_numbersink2_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_2, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
Ejemplo n.º 43
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Variables
        ##################################################
        self.thresh = thresh = 900*10**-3
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        _thresh_sizer = wx.BoxSizer(wx.VERTICAL)
        self._thresh_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_thresh_sizer,
        	value=self.thresh,
        	callback=self.set_thresh,
        	label='thresh',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._thresh_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_thresh_sizer,
        	value=self.thresh,
        	callback=self.set_thresh,
        	minimum=0,
        	maximum=1,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_thresh_sizer)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=samp_rate,
        	v_scale=200*10**-3,
        	v_offset=0,
        	t_scale=100*10**-3,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=2,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
        	self.GetWin(),
        	unit="Units",
        	minval=0,
        	maxval=1,
        	factor=1.0,
        	decimal_places=6,
        	ref_level=0,
        	sample_rate=samp_rate,
        	number_rate=15,
        	average=False,
        	avg_alpha=None,
        	label="Number Plot",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0.win)
        self.digital_glfsr_source_x_0 = digital.glfsr_source_b(6, True, 0, 1)
        self.blocks_xor_xx_0 = blocks.xor_bb()
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(thresh, thresh, 0)
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((0.5, ))
        self.blks2_error_rate_0 = grc_blks2.error_rate(
        	type='BER',
        	win_size=1280,
        	bits_per_symbol=1,
        )
        self.analog_noise_source_x_0 = analog.noise_source_f(analog.GR_UNIFORM, 0.5, 32)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_const_vxx_0, 0))    
        self.connect((self.blks2_error_rate_0, 0), (self.wxgui_numbersink2_0, 0))    
        self.connect((self.blks2_error_rate_0, 0), (self.wxgui_scopesink2_0, 0))    
        self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_threshold_ff_0, 0))    
        self.connect((self.blocks_float_to_char_0, 0), (self.blocks_xor_xx_0, 1))    
        self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_float_to_char_0, 0))    
        self.connect((self.blocks_threshold_ff_0, 0), (self.wxgui_scopesink2_0, 1))    
        self.connect((self.blocks_throttle_0, 0), (self.blks2_error_rate_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.blocks_xor_xx_0, 0))    
        self.connect((self.blocks_xor_xx_0, 0), (self.blks2_error_rate_0, 1))    
        self.connect((self.digital_glfsr_source_x_0, 0), (self.blocks_throttle_0, 0))    
Ejemplo n.º 44
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))
Ejemplo n.º 45
0
    def __init__(self):
        gr.top_block.__init__(self, "Adsb Uhd")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Adsb Uhd")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

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

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

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

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

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

        self._center_tool_bar = Qt.QToolBar(self)
        self._center_tool_bar.addWidget(Qt.QLabel("center" + ": "))
        self._center_line_edit = Qt.QLineEdit(str(self.center))
        self._center_tool_bar.addWidget(self._center_line_edit)
        self._center_line_edit.returnPressed.connect(lambda: self.set_center(
            eng_notation.str_to_num(
                str(self._center_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._center_tool_bar)
        self._bb_gain_tool_bar = Qt.QToolBar(self)
        self._bb_gain_tool_bar.addWidget(Qt.QLabel("bb_gain" + ": "))
        self._bb_gain_line_edit = Qt.QLineEdit(str(self.bb_gain))
        self._bb_gain_tool_bar.addWidget(self._bb_gain_line_edit)
        self._bb_gain_line_edit.returnPressed.connect(lambda: self.set_bb_gain(
            eng_notation.str_to_num(
                str(self._bb_gain_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._bb_gain_tool_bar)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(
            uhd.tune_request(freq, samp_rate / 2), 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            4096,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.01)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_waterfall_sink_x_0.disable_legend()

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

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

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-130, -70)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            4096,  #size
            samp_rate,  #samp_rate
            "",  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.010)
        self.qtgui_time_sink_x_0.set_y_axis(0, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            4096,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.01)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, -80)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self._low_thresh_lbl_tool_bar = Qt.QToolBar(self)

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

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

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

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

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

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

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_float_to_uchar_0, 0),
                     (self.digital_correlate_access_code_tag_bb_0, 0))
        self.connect((self.blocks_message_source_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.probe_power, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_float_to_uchar_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.digital_correlate_access_code_tag_bb_0, 0),
                     (self.adsb_framer_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Nexrad Playback Sigmf")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Nexrad Playback Sigmf")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        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.tune = tune = 1e6
        self.trig_lvl = trig_lvl = 30
        self.throttle_rate = throttle_rate = 0.5
        self.thresh_lo = thresh_lo = 10000
        self.thresh_hi = thresh_hi = 10000
        self.samp_rate = samp_rate = 15e6
        self.lpf_trans = lpf_trans = 500e3
        self.lpf_cutoff = lpf_cutoff = .45e6
        self.look_ahead = look_ahead = 10
        self.decim = decim = 1
        self.alpha_0 = alpha_0 = 1
        self.alpha = alpha = 0.01

        ##################################################
        # Blocks
        ##################################################
        self._tune_tool_bar = Qt.QToolBar(self)
        self._tune_tool_bar.addWidget(Qt.QLabel('tune' + ": "))
        self._tune_line_edit = Qt.QLineEdit(str(self.tune))
        self._tune_tool_bar.addWidget(self._tune_line_edit)
        self._tune_line_edit.returnPressed.connect(lambda: self.set_tune(
            eng_notation.str_to_num(str(self._tune_line_edit.text()))))
        self.top_grid_layout.addWidget(self._tune_tool_bar, 1, 4, 1, 2)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._trig_lvl_tool_bar = Qt.QToolBar(self)
        self._trig_lvl_tool_bar.addWidget(Qt.QLabel('trig_lvl' + ": "))
        self._trig_lvl_line_edit = Qt.QLineEdit(str(self.trig_lvl))
        self._trig_lvl_tool_bar.addWidget(self._trig_lvl_line_edit)
        self._trig_lvl_line_edit.returnPressed.connect(
            lambda: self.set_trig_lvl(
                eng_notation.str_to_num(str(self._trig_lvl_line_edit.text()))))
        self.top_grid_layout.addWidget(self._trig_lvl_tool_bar, 3, 4, 1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._throttle_rate_tool_bar = Qt.QToolBar(self)
        self._throttle_rate_tool_bar.addWidget(
            Qt.QLabel('throttle_rate' + ": "))
        self._throttle_rate_line_edit = Qt.QLineEdit(str(self.throttle_rate))
        self._throttle_rate_tool_bar.addWidget(self._throttle_rate_line_edit)
        self._throttle_rate_line_edit.returnPressed.connect(
            lambda: self.set_throttle_rate(
                eng_notation.str_to_num(
                    str(self._throttle_rate_line_edit.text()))))
        self.top_grid_layout.addWidget(self._throttle_rate_tool_bar, 3, 5, 1,
                                       1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(5, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._thresh_lo_tool_bar = Qt.QToolBar(self)
        self._thresh_lo_tool_bar.addWidget(Qt.QLabel('thresh_lo' + ": "))
        self._thresh_lo_line_edit = Qt.QLineEdit(str(self.thresh_lo))
        self._thresh_lo_tool_bar.addWidget(self._thresh_lo_line_edit)
        self._thresh_lo_line_edit.returnPressed.connect(
            lambda: self.set_thresh_lo(
                eng_notation.str_to_num(str(self._thresh_lo_line_edit.text()))
            ))
        self.top_grid_layout.addWidget(self._thresh_lo_tool_bar, 0, 7, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(7, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._thresh_hi_tool_bar = Qt.QToolBar(self)
        self._thresh_hi_tool_bar.addWidget(Qt.QLabel('thresh_hi' + ": "))
        self._thresh_hi_line_edit = Qt.QLineEdit(str(self.thresh_hi))
        self._thresh_hi_tool_bar.addWidget(self._thresh_hi_line_edit)
        self._thresh_hi_line_edit.returnPressed.connect(
            lambda: self.set_thresh_hi(
                eng_notation.str_to_num(str(self._thresh_hi_line_edit.text()))
            ))
        self.top_grid_layout.addWidget(self._thresh_hi_tool_bar, 0, 6, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(6, 7):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._samp_rate_tool_bar = Qt.QToolBar(self)
        self._samp_rate_tool_bar.addWidget(Qt.QLabel('samp_rate' + ": "))
        self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate))
        self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit)
        self._samp_rate_line_edit.returnPressed.connect(
            lambda: self.set_samp_rate(
                eng_notation.str_to_num(str(self._samp_rate_line_edit.text()))
            ))
        self.top_grid_layout.addWidget(self._samp_rate_tool_bar, 0, 4, 1, 2)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._lpf_trans_tool_bar = Qt.QToolBar(self)
        self._lpf_trans_tool_bar.addWidget(Qt.QLabel('lpf_trans' + ": "))
        self._lpf_trans_line_edit = Qt.QLineEdit(str(self.lpf_trans))
        self._lpf_trans_tool_bar.addWidget(self._lpf_trans_line_edit)
        self._lpf_trans_line_edit.returnPressed.connect(
            lambda: self.set_lpf_trans(
                eng_notation.str_to_num(str(self._lpf_trans_line_edit.text()))
            ))
        self.top_grid_layout.addWidget(self._lpf_trans_tool_bar, 2, 5, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(5, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._lpf_cutoff_tool_bar = Qt.QToolBar(self)
        self._lpf_cutoff_tool_bar.addWidget(Qt.QLabel('lpf_cutoff' + ": "))
        self._lpf_cutoff_line_edit = Qt.QLineEdit(str(self.lpf_cutoff))
        self._lpf_cutoff_tool_bar.addWidget(self._lpf_cutoff_line_edit)
        self._lpf_cutoff_line_edit.returnPressed.connect(
            lambda: self.set_lpf_cutoff(
                eng_notation.str_to_num(str(self._lpf_cutoff_line_edit.text()))
            ))
        self.top_grid_layout.addWidget(self._lpf_cutoff_tool_bar, 2, 4, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._alpha_0_tool_bar = Qt.QToolBar(self)
        self._alpha_0_tool_bar.addWidget(Qt.QLabel('alpha_0' + ": "))
        self._alpha_0_line_edit = Qt.QLineEdit(str(self.alpha_0))
        self._alpha_0_tool_bar.addWidget(self._alpha_0_line_edit)
        self._alpha_0_line_edit.returnPressed.connect(lambda: self.set_alpha_0(
            eng_notation.str_to_num(str(self._alpha_0_line_edit.text()))))
        self.top_grid_layout.addWidget(self._alpha_0_tool_bar, 2, 6, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(6, 7):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(
            alpha_0, 1)
        self.sigmf_source_0 = gr_sigmf.source(
            '/captures/20191214/NEXRAD_2019-12-14T23:24:46Z.sigmf-data',
            "ci16" + ("_le" if sys.byteorder == "little" else "_be"), True)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            1024 * 16 * 100,  #size
            samp_rate / decim,  #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(0, 2)

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

        self.qtgui_time_sink_x_0_0.enable_tags(True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_NORM,
                                                    qtgui.TRIG_SLOPE_POS, .5,
                                                    0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(False)
        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)
        self.qtgui_time_sink_x_0_0.enable_stem_plot(False)

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

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

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 7, 4,
                                       1, 4)
        for r in range(7, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024 * 16 * 100,  #size
            samp_rate / decim,  #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(0, 50)

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

        self.qtgui_time_sink_x_0.enable_tags(True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_NORM,
                                                  qtgui.TRIG_SLOPE_POS,
                                                  trig_lvl, 0, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        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]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 4, 4, 3,
                                       4)
        for r in range(4, 7):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            decim,
            firdes.low_pass(1, samp_rate, lpf_cutoff, lpf_trans,
                            firdes.WIN_HAMMING, 6.76))
        self._look_ahead_tool_bar = Qt.QToolBar(self)
        self._look_ahead_tool_bar.addWidget(Qt.QLabel('look_ahead' + ": "))
        self._look_ahead_line_edit = Qt.QLineEdit(str(self.look_ahead))
        self._look_ahead_tool_bar.addWidget(self._look_ahead_line_edit)
        self._look_ahead_line_edit.returnPressed.connect(
            lambda: self.set_look_ahead(
                int(str(self._look_ahead_line_edit.text()))))
        self.top_grid_layout.addWidget(self._look_ahead_tool_bar, 1, 6, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(6, 7):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.fosphor_qt_sink_c_0 = fosphor.qt_sink_c()
        self.fosphor_qt_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS)
        self.fosphor_qt_sink_c_0.set_frequency_range(0, samp_rate / decim)
        self._fosphor_qt_sink_c_0_win = sip.wrapinstance(
            self.fosphor_qt_sink_c_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._fosphor_qt_sink_c_0_win, 0, 0, 8,
                                       4)
        for r in range(0, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_short * 2,
                                                 samp_rate * throttle_rate,
                                                 True)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(
            thresh_hi, thresh_lo, 0)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_xx_0 = blocks.multiply_const_cc(
            1.0 / 65536.0, 1)
        self.blocks_interleaved_short_to_complex_0 = blocks.interleaved_short_to_complex(
            True, False)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, tune, 1, 0, 0)
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)
        self._alpha_tool_bar = Qt.QToolBar(self)
        self._alpha_tool_bar.addWidget(Qt.QLabel('alpha' + ": "))
        self._alpha_line_edit = Qt.QLineEdit(str(self.alpha))
        self._alpha_tool_bar.addWidget(self._alpha_line_edit)
        self._alpha_line_edit.returnPressed.connect(lambda: self.set_alpha(
            eng_notation.str_to_num(str(self._alpha_line_edit.text()))))
        self.top_grid_layout.addWidget(self._alpha_tool_bar, 1, 7, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(7, 8):
            self.top_grid_layout.setColumnStretch(c, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.single_pole_iir_filter_xx_0, 0))
        self.connect((self.blocks_interleaved_short_to_complex_0, 0),
                     (self.blocks_multiply_const_xx_0, 0))
        self.connect((self.blocks_multiply_const_xx_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.analog_agc2_xx_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_interleaved_short_to_complex_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.fosphor_qt_sink_c_0, 0))
        self.connect((self.sigmf_source_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.single_pole_iir_filter_xx_0, 0),
                     (self.blocks_nlog10_ff_0, 0))
        self.connect((self.single_pole_iir_filter_xx_0, 0),
                     (self.blocks_threshold_ff_0, 0))
Ejemplo n.º 47
0
    def __init__(self):
        gr.top_block.__init__(self, "Uhd Adsb 2")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Uhd Adsb 2")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

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

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

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_threshold_ff_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0))    
        self.connect((self.blocks_threshold_ff_0, 0), (self.qtgui_time_sink_x_0, 1))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.fosphor_glfw_sink_c_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))    
Ejemplo n.º 48
0
    def __init__(self):
        gr.top_block.__init__(self, "Receiver NC-OFDM")

        global expduration
        ##################################################
        # Read parameter for configuration
        ##################################################
        file_handle = open('/root/gr-ncofdm/examples/config_ncofdm_rx', 'r')
        for line in file_handle: # read rest of lines
            linefromfile = ([x for x in line.split()])
            linesize = len(linefromfile)-1
            if linesize > 1:
                linedata = map(float, linefromfile[1:linesize+1])
            else:
                linedata = float(linefromfile[1])
            if linefromfile[0] == "fft_len":
                fft_len = int(linedata)
            elif linefromfile[0] == "cp_len":
                cp_len = int(linedata)
            elif linefromfile[0] == "shseq_len":
                shseq_len = int(linedata)
            elif linefromfile[0] == "lgseq_len":
                lgseq_len = int(linedata)
            elif linefromfile[0] == "dataseq_len":
                dataseq_len = int(linedata)
            elif linefromfile[0] == "shseq_rep":
                shseq_rep = int(linedata)
            elif linefromfile[0] == "samp_rate":
                samp_rate = int(linedata)
            elif linefromfile[0] == "pnseq_offset":
                pnseq_offset = int(linedata)
            elif linefromfile[0] == "shseq":
                shseq = [int(z) for z in linedata]
            elif linefromfile[0] == "lgseq":
                lgseq = [int(z) for z in linedata]
            elif linefromfile[0] == "dataseq":
                dataseq = [int(z) for z in linedata]
            elif linefromfile[0] == "occupied_carriers":
                occupied_carriers = [int(z) for z in linedata]
            elif linefromfile[0] == "pilot_carriers":
                pilot_carriers = [int(z) for z in linedata]
            elif linefromfile[0] == "pilot_symbols":
                pilot_symbols = [int(z) for z in linedata]
            elif linefromfile[0] == "cen_freq":
                cen_freq = linedata
            elif linefromfile[0] == "noofsamples":
                noofsamples = int(linedata)
            elif linefromfile[0] == "expduration":
                expduration = linedata
        ##################################################
        # Variables
        ##################################################
        self.pn_symbols = pn_symbols = (1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1)
        self.lgseq_len = lgseq_len
        self.shseq_len = shseq_len
        self.fft_len = fft_len
        self.shseq_rep = shseq_rep
        self.shseq = shseq = pn_symbols[pnseq_offset+0:pnseq_offset+shseq_len]
        self.lgseq = lgseq = pn_symbols[pnseq_offset+shseq_len:pnseq_offset+shseq_len+lgseq_len]
        self.samp_rate = samp_rate
        self.pilot_symbols = pilot_symbols
        self.pilot_carriers = pilot_carriers
        self.packet_len = packet_len = 3*len(occupied_carriers)
        self.occupied_carriers = occupied_carriers
        self.length_tag_name = length_tag_name = "packet_len"
        self.fileprefix = fileprefix = "/root/"
        self.cp_len = cp_len
        self.cen_freq = cen_freq
        self.data_len = data_len = dataseq_len*20
        self.ShThreshold = ShThreshold = 10
        self.ShRepThreshold = ShRepThreshold = 3.5
        self.LgThreshold = LgThreshold = 60

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        # UHD
        self.uhd_usrp_source.set_samp_rate(samp_rate)
        self.uhd_usrp_source.set_center_freq(cen_freq, 0)
        self.uhd_usrp_source.set_gain(0, 0)
        self.uhd_usrp_source.set_antenna("RX2", 0)
        # Null sinks
        self.null_sink_shortpncorr_out = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.null_sink_longpncorrv2_out = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.null_sink_longpncorrv2_flag = blocks.null_sink(gr.sizeof_int*1)
        self.null_sink_longpncorrv2_corr = blocks.null_sink(gr.sizeof_gr_complex*1)
        # NCOFDM blocks
        self.ncofdm_ShortPNdetector = ncofdm.ShortPNdetector(fft_len, cp_len, shseq_rep, shseq_len, 1)
        self.ncofdm_ShortPNcorr = ncofdm.ShortPNcorr(fft_len, cp_len, shseq_rep, shseq_len, (shseq))
        self.ncofdm_LongPNcorrV2 = ncofdm.LongPNcorrV2(fft_len, cp_len, lgseq_len, (lgseq), 60, shseq_len*shseq_rep+lgseq_len+data_len+10)
        self.ncofdm_FreqOffCalc = ncofdm.FreqOffCalc(fft_len, fft_len/4, shseq_len, shseq_rep)
        # File sinks
        self.file_sink_short = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"short.dat", False)
        self.file_sink_short.set_unbuffered(False)
        self.file_sink_rxshth = blocks.file_sink(gr.sizeof_float*1, fileprefix+"rxshth.dat", False)
        self.file_sink_rxshth.set_unbuffered(False)
        self.file_sink_org = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"org.dat", False)
        self.file_sink_org.set_unbuffered(False)
        self.file_sink_long = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"long.dat", False)
        self.file_sink_long.set_unbuffered(False)
        self.file_sink_lgth = blocks.file_sink(gr.sizeof_float*1, fileprefix+"lgth.dat", False)
        self.file_sink_lgth.set_unbuffered(False)
        self.file_sink_gain = blocks.file_sink(gr.sizeof_float*1, fileprefix+"gain.dat", False)
        self.file_sink_gain.set_unbuffered(False)
        #self.file_sink_freqoff = blocks.file_sink(gr.sizeof_float*1, fileprefix+"freqoff.dat", False)
        #self.file_sink_freqoff.set_unbuffered(False)
        self.file_sink_corr = blocks.file_sink(gr.sizeof_int*1, fileprefix+"corr.dat", False)
        self.file_sink_corr.set_unbuffered(False)
        # Blocks
        self.blocks_head = blocks.head(gr.sizeof_gr_complex*1, noofsamples)
        self.blocks_threshold_ff = blocks.threshold_ff(ShRepThreshold, ShRepThreshold, 0)
        self.blocks_moving_average = blocks.moving_average_ff(100, 0.01, 4000)
        self.blocks_float_to_int = blocks.float_to_int(1, 1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_delay_shpn_lgpn = blocks.delay(gr.sizeof_float*1, 2)
        self.blocks_delay_shpn_freqoff = blocks.delay(gr.sizeof_int*1, 1)
        self.blocks_delay_freqoff_lgpn = blocks.delay(gr.sizeof_float*1, 2)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_mag_org = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag = blocks.complex_to_mag(1)
        self.analog_agc = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc.set_max_gain(50000.0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.uhd_usrp_source, 0), (self.blocks_head, 0))
        self.connect((self.blocks_head, 0), (self.analog_agc, 0))
        self.connect((self.analog_agc, 0), (self.blocks_complex_to_mag_org, 0))
        self.connect((self.analog_agc, 1), (self.file_sink_gain, 0))
        self.connect((self.analog_agc, 0), (self.file_sink_org, 0))
        self.connect((self.analog_agc, 0), (self.ncofdm_LongPNcorrV2, 0))
        self.connect((self.analog_agc, 0), (self.ncofdm_ShortPNcorr, 0))
        self.connect((self.blocks_complex_to_mag, 0), (self.ncofdm_ShortPNdetector, 0))
        self.connect((self.blocks_complex_to_mag_org, 0), (self.blocks_moving_average, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.file_sink_lgth, 0))
        self.connect((self.blocks_delay_freqoff_lgpn, 0), (self.blocks_float_to_complex_0, 0))
        #self.connect((self.blocks_delay_freqoff_lgpn, 0), (self.file_sink_freqoff, 0))
        self.connect((self.blocks_delay_shpn_freqoff, 0), (self.ncofdm_FreqOffCalc, 1))
        self.connect((self.blocks_delay_shpn_lgpn, 0), (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0), (self.ncofdm_LongPNcorrV2, 1))
        self.connect((self.blocks_float_to_int, 0), (self.blocks_delay_shpn_freqoff, 0))
        self.connect((self.blocks_moving_average, 0), (self.ncofdm_LongPNcorrV2, 2))
        self.connect((self.blocks_threshold_ff, 0), (self.blocks_delay_shpn_lgpn, 0))
        self.connect((self.blocks_threshold_ff, 0), (self.blocks_float_to_int, 0))
        self.connect((self.ncofdm_FreqOffCalc, 0), (self.blocks_delay_freqoff_lgpn, 0))
        self.connect((self.ncofdm_LongPNcorrV2, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.ncofdm_LongPNcorrV2, 2), (self.file_sink_corr, 0))
        self.connect((self.ncofdm_LongPNcorrV2, 1), (self.file_sink_long, 0))
        self.connect((self.ncofdm_LongPNcorrV2, 1), (self.null_sink_longpncorrv2_corr, 0))
        self.connect((self.ncofdm_LongPNcorrV2, 2), (self.null_sink_longpncorrv2_flag, 0))
        self.connect((self.ncofdm_LongPNcorrV2, 0), (self.null_sink_longpncorrv2_out, 0))
        self.connect((self.ncofdm_ShortPNcorr, 1), (self.blocks_complex_to_mag, 0))
        self.connect((self.ncofdm_ShortPNcorr, 1), (self.file_sink_short, 0))
        self.connect((self.ncofdm_ShortPNcorr, 1), (self.ncofdm_FreqOffCalc, 0))
        self.connect((self.ncofdm_ShortPNcorr, 0), (self.null_sink_shortpncorr_out, 0))
        self.connect((self.ncofdm_ShortPNdetector, 0), (self.blocks_threshold_ff, 0))
        self.connect((self.ncofdm_ShortPNdetector, 1), (self.file_sink_rxshth, 0))
Ejemplo n.º 49
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 4e6
        self.fsk_deviation_hz = fsk_deviation_hz = 186000
        self.channel_freq = channel_freq = 433930000
        self.centre_freq = centre_freq = 432000000

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=samp_rate/12,
        	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.Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate/12,
        	fft_size=1024,
        	fft_rate=15,
        	average=True,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=1,
                decimation=2,
                taps=None,
                fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(14, firdes.low_pass(
        	1, samp_rate, 1000e3, 100e3, firdes.WIN_HAMMING, 6.76))
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(1, 2, 0)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, ))
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/home/x/navtrak/navtrak4339.sink", True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(-60, 1)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -930000, 1, 0)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(samp_rate/(2*math.pi*fsk_deviation_hz/8.0))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_threshold_ff_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.analog_simple_squelch_cc_0, 0))    
        self.connect((self.blocks_threshold_ff_0, 0), (self.wxgui_scopesink2_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
Ejemplo n.º 50
0
    def __init__(self, rxPort=52002, txPort=52001):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Parameters
        ##################################################
        self.rxPort = rxPort
        self.txPort = txPort

        ##################################################
        # Variables
        ##################################################
        self.localOscillator = localOscillator = 14070000
        self.threshold = threshold = -200
        self.samp_rate = samp_rate = 48000
        self.rxPhase = rxPhase = .84
        self.rxMagnitude = rxMagnitude = 0.854
        self.freqFine = freqFine = 0
        self.freq = freq = localOscillator
        self.bandwidth = bandwidth = 50

        ##################################################
        # Blocks
        ##################################################
        _threshold_sizer = wx.BoxSizer(wx.VERTICAL)
        self._threshold_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_threshold_sizer,
        	value=self.threshold,
        	callback=self.set_threshold,
        	label="threshold",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._threshold_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_threshold_sizer,
        	value=self.threshold,
        	callback=self.set_threshold,
        	minimum=-500,
        	maximum=500,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_threshold_sizer)
        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tuning")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "scope")
        self.Add(self.notebook_0)
        _freqFine_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freqFine_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_freqFine_sizer,
        	value=self.freqFine,
        	callback=self.set_freqFine,
        	label="Tuning",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._freqFine_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_freqFine_sizer,
        	value=self.freqFine,
        	callback=self.set_freqFine,
        	minimum=-500,
        	maximum=500,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_freqFine_sizer)
        _freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_freq_sizer,
        	value=self.freq,
        	callback=self.set_freq,
        	label="Frequency",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._freq_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_freq_sizer,
        	value=self.freq,
        	callback=self.set_freq,
        	minimum=localOscillator-samp_rate,
        	maximum=localOscillator+samp_rate,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_freq_sizer)
        _bandwidth_sizer = wx.BoxSizer(wx.VERTICAL)
        self._bandwidth_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_bandwidth_sizer,
        	value=self.bandwidth,
        	callback=self.set_bandwidth,
        	label="Signal Bandwidth",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._bandwidth_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_bandwidth_sizer,
        	value=self.bandwidth,
        	callback=self.set_bandwidth,
        	minimum=30,
        	maximum=5000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_bandwidth_sizer)
        self.wxgui_waterfallsink2_0_0_0 = waterfallsink2.waterfall_sink_c(
        	self.notebook_0.GetPage(1).GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=125*8,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        )
        self.notebook_0.GetPage(1).Add(self.wxgui_waterfallsink2_0_0_0.win)
        self.wxgui_waterfallsink2_0_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=125*8,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        )
        self.notebook_0.GetPage(0).Add(self.wxgui_waterfallsink2_0_0.win)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.notebook_0.GetPage(0).GetWin(),
        	baseband_freq=localOscillator,
        	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="Waterfall Plot",
        )
        self.notebook_0.GetPage(0).Add(self.wxgui_waterfallsink2_0.win)
        self.low_pass_filter_0_1 = filter.fir_filter_ccf(samp_rate/125/8, firdes.low_pass(
        	1, samp_rate, 500, 500, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0_0 = filter.interp_fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate, 30, 30, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(samp_rate/125/8, firdes.low_pass(
        	1, samp_rate, bandwidth, bandwidth, firdes.WIN_HAMMING, 6.76))
        self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc(2, 0, cmath.pi/100.0, -0.5, 0.5, 0.25, 0.01, 125*8/31.25, 0.001, 0.001)
        self.blocks_transcendental_1 = blocks.transcendental("sin", "float")
        self.blocks_transcendental_0 = blocks.transcendental("cos", "float")
        self.blocks_throttle_0_1 = blocks.throttle(gr.sizeof_float*1, samp_rate)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, 31.25)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(1e-12, 1e-12, 0)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, int(samp_rate/31.25))
        self.blocks_null_source_1 = blocks.null_source(gr.sizeof_float*1)
        self.blocks_null_source_0_0 = blocks.null_source(gr.sizeof_float*1)
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_float*1)
        self.blocks_multiply_xx_0_2 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((rxMagnitude, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, ))
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        self.blocks_float_to_complex_1_0 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_1 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0_1 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, ))
        self.blks2_tcp_source_0 = grc_blks2.tcp_source(
        	itemsize=gr.sizeof_char*1,
        	addr="127.0.0.1",
        	port=txPort,
        	server=False,
        )
        self.blks2_tcp_sink_0 = grc_blks2.tcp_sink(
        	itemsize=gr.sizeof_char*1,
        	addr="127.0.0.1",
        	port=rxPort,
        	server=False,
        )
        self.audio_source_0 = audio.source(samp_rate, "", True)
        self.audio_sink_0 = audio.sink(samp_rate, "", True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(threshold, 1)
        self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -freqFine, 1, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, freq+freqFine-localOscillator, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_SIN_WAVE, -(freq-localOscillator), 1, 0)
        self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, rxPhase*3.14159/180.0)
        self.analog_agc_xx_0 = analog.agc_cc(1e-4, 1.0, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_tcp_source_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_char_to_float_0, 0))
        self.connect((self.blocks_char_to_float_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.low_pass_filter_0_0, 0))
        self.connect((self.blocks_throttle_0_1, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.low_pass_filter_0_0, 0), (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.blocks_float_to_complex_0_1, 0), (self.blocks_multiply_xx_0_1, 1))
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_transcendental_1, 0))
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_transcendental_0, 0))
        self.connect((self.blocks_transcendental_0, 0), (self.blocks_float_to_complex_0_1, 0))
        self.connect((self.blocks_transcendental_1, 0), (self.blocks_float_to_complex_0_1, 1))
        self.connect((self.blocks_null_source_0, 0), (self.blocks_float_to_complex_1, 0))
        self.connect((self.audio_source_0, 0), (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_float_to_complex_1, 1))
        self.connect((self.blocks_float_to_complex_1, 0), (self.blocks_multiply_xx_0_1, 0))
        self.connect((self.blocks_null_source_0_0, 0), (self.blocks_float_to_complex_1_0, 1))
        self.connect((self.audio_source_0, 1), (self.blocks_float_to_complex_1_0, 0))
        self.connect((self.blocks_float_to_complex_1_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0_1, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0_0, 0))
        self.connect((self.blocks_null_source_1, 0), (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_throttle_0_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_float_to_char_0, 0), (self.blks2_tcp_sink_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_float_to_char_0, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.blocks_multiply_conjugate_cc_0, 1))
        self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.blocks_throttle_0_1, 0))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_repeat_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_complex_to_float_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_multiply_xx_0_2, 0))
        self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0_2, 1))
        self.connect((self.blocks_multiply_xx_0_2, 0), (self.low_pass_filter_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0_1, 0))
        self.connect((self.low_pass_filter_0_1, 0), (self.wxgui_waterfallsink2_0_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.analog_agc_xx_0, 0), (self.digital_mpsk_receiver_cc_0, 0))
        self.connect((self.analog_agc_xx_0, 0), (self.wxgui_waterfallsink2_0_0_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0), (self.audio_sink_0, 1))
        self.connect((self.blocks_complex_to_float_0, 1), (self.audio_sink_0, 0))
        self.connect((self.blocks_throttle_0_0, 0), (self.wxgui_waterfallsink2_0, 0))
Ejemplo n.º 51
0
    def __init__(self):
        gr.top_block.__init__(self, "Recepteur ADSB -Mode-S")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Recepteur ADSB -Mode-S")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        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.seuil = seuil = 0.003
        self.samp_rate = samp_rate = 2000000
        self.freq = freq = 1090000000

        ##################################################
        # Blocks
        ##################################################
        self._seuil_range = Range(0.0001, 0.3, 0.0001, 0.003, 200)
        self._seuil_win = RangeWidget(self._seuil_range, self.set_seuil, 'Seuil', "counter_slider", float)
        self.top_grid_layout.addWidget(self._seuil_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._freq_range = Range(950000000, 1093000000, 10000, 1090000000, 200)
        self._freq_win = RangeWidget(self._freq_range, self.set_freq, 'Frequency', "counter_slider", float)
        self.top_grid_layout.addWidget(self._freq_win, 0, 0, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.figures = Qt.QTabWidget()
        self.figures_widget_0 = Qt.QWidget()
        self.figures_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.figures_widget_0)
        self.figures_grid_layout_0 = Qt.QGridLayout()
        self.figures_layout_0.addLayout(self.figures_grid_layout_0)
        self.figures.addTab(self.figures_widget_0, 'Waterfall (recu)')
        self.figures_widget_1 = Qt.QWidget()
        self.figures_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.figures_widget_1)
        self.figures_grid_layout_1 = Qt.QGridLayout()
        self.figures_layout_1.addLayout(self.figures_grid_layout_1)
        self.figures.addTab(self.figures_widget_1, 'Spectre (recu)')
        self.figures_widget_2 = Qt.QWidget()
        self.figures_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.figures_widget_2)
        self.figures_grid_layout_2 = Qt.QGridLayout()
        self.figures_layout_2.addLayout(self.figures_grid_layout_2)
        self.figures.addTab(self.figures_widget_2, 'Rx: temporel / bits')
        self.top_grid_layout.addWidget(self.figures, 1, 0, 3, 2)
        for r in range(1, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.rtlsdr_source_0_0 = osmosdr.source(
            args="numchan=" + str(1) + " " + ''
        )
        self.rtlsdr_source_0_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.rtlsdr_source_0_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0_0.set_center_freq(freq, 0)
        self.rtlsdr_source_0_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0_0.set_gain(14, 0)
        self.rtlsdr_source_0_0.set_if_gain(24, 0)
        self.rtlsdr_source_0_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0_0.set_antenna('', 0)
        self.rtlsdr_source_0_0.set_bandwidth(samp_rate, 0)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            1024, #size
            firdes.WIN_BLACKMAN_hARRIS, #wintype
            0, #fc
            samp_rate, #bw
            "Spectre", #name
            1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)



        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        colors = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

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

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.figures_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.qtgui_time_sink_x_0_2 = qtgui.time_sink_f(
            250, #size
            samp_rate, #samp_rate
            "", #name
            1 #number of inputs
        )
        self.qtgui_time_sink_x_0_2.set_update_time(0.10)
        self.qtgui_time_sink_x_0_2.set_y_axis(-0.1, 1.1)

        self.qtgui_time_sink_x_0_2.set_y_label('Manchester bits', "")

        self.qtgui_time_sink_x_0_2.enable_tags(True)
        self.qtgui_time_sink_x_0_2.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0.000008, 0, "burst")
        self.qtgui_time_sink_x_0_2.enable_autoscale(False)
        self.qtgui_time_sink_x_0_2.enable_grid(False)
        self.qtgui_time_sink_x_0_2.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_2.enable_control_panel(True)
        self.qtgui_time_sink_x_0_2.enable_stem_plot(False)


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


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

        self._qtgui_time_sink_x_0_2_win = sip.wrapinstance(self.qtgui_time_sink_x_0_2.pyqwidget(), Qt.QWidget)
        self.figures_grid_layout_2.addWidget(self._qtgui_time_sink_x_0_2_win, 0, 1, 1, 1)
        for r in range(0, 1):
            self.figures_grid_layout_2.setRowStretch(r, 1)
        for c in range(1, 2):
            self.figures_grid_layout_2.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            1024, #size
            samp_rate, #samp_rate
            "", #name
            1 #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0_0.set_y_label('Rx mag2', "")

        self.qtgui_time_sink_x_0_0.enable_tags(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(True)
        self.qtgui_time_sink_x_0_0.enable_stem_plot(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]
        styles = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
            -1, -1, -1, -1, -1]


        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_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.figures_grid_layout_2.addWidget(self._qtgui_time_sink_x_0_0_win, 0, 0, 1, 1)
        for r in range(0, 1):
            self.figures_grid_layout_2.setRowStretch(r, 1)
        for c in range(0, 1):
            self.figures_grid_layout_2.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024, #size
            firdes.WIN_BLACKMAN_hARRIS, #wintype
            freq, #fc
            samp_rate, #bw
            "", #name
            1
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)



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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.figures_layout_1.addWidget(self._qtgui_freq_sink_x_0_win)
        self.digital_correlate_access_code_tag_xx_0 = digital.correlate_access_code_tag_bb('010100001010000001001010110', 0, 'burst')
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.blocks_threshold_ff_0 = blocks.threshold_ff(seuil, seuil, 0)
        self.blocks_tagged_file_sink_0 = blocks.tagged_file_sink(gr.sizeof_char*1, samp_rate)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char*1)
        self.blocks_float_to_uchar_0 = blocks.float_to_uchar()
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_burst_tagger_0 = blocks.burst_tagger(gr.sizeof_char)
        self.blocks_burst_tagger_0.set_true_tag('',True)
        self.blocks_burst_tagger_0.set_false_tag('burst',False)
        self.analog_sig_source_x_1 = analog.sig_source_s(samp_rate, analog.GR_COS_WAVE, 80, 1, 0, 0)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_1, 0), (self.blocks_burst_tagger_0, 1))
        self.connect((self.blocks_burst_tagger_0, 0), (self.blocks_null_sink_0, 0))
        self.connect((self.blocks_burst_tagger_0, 0), (self.blocks_tagged_file_sink_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_float_to_uchar_0, 0), (self.digital_correlate_access_code_tag_xx_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_float_to_uchar_0, 0))
        self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_0_2, 0))
        self.connect((self.digital_correlate_access_code_tag_xx_0, 0), (self.blocks_burst_tagger_0, 0))
        self.connect((self.digital_correlate_access_code_tag_xx_0, 0), (self.blocks_uchar_to_float_0, 0))
        self.connect((self.rtlsdr_source_0_0, 0), (self.blocks_complex_to_mag_0, 0))
        self.connect((self.rtlsdr_source_0_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.rtlsdr_source_0_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
Ejemplo n.º 52
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.samp_rate = samp_rate = 256000
        self.rx_taps = rx_taps = firdes.root_raised_cosine(
            32, 32 * sps, 1.0, 0.35, 1408)
        self.loop_bw = loop_bw = 2 * pi / 100
        self.excess_bw = excess_bw = 0.35
        self.a = a = 0.65

        ##################################################
        # Blocks
        ##################################################
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "rrc_out")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "difference")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "output")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "parity")
        self.Add(self.nb)
        self.wxgui_scopesink2_4 = scopesink2.scope_sink_f(
            self.nb.GetPage(3).GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate / sps,
            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.nb.GetPage(3).Add(self.wxgui_scopesink2_4.win)
        self.wxgui_scopesink2_2 = scopesink2.scope_sink_c(
            self.nb.GetPage(0).GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate / sps,
            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.nb.GetPage(0).Add(self.wxgui_scopesink2_2.win)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_f(
            self.nb.GetPage(2).GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate / sps,
            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.nb.GetPage(2).Add(self.wxgui_scopesink2_1.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
            self.nb.GetPage(1).GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate / sps,
            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.nb.GetPage(1).Add(self.wxgui_scopesink2_0.win)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, loop_bw, (rx_taps), 32, 16, 1.5, 1)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(0.2, 1.8, 0)
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vcc((-1, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff(
            (1 / 0.85, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (1 / 0.5, ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            "/home/ritesh/Dropbox/Sem5/EE340_communications_Lab/File1.dat",
            True)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1)
        self.blocks_complex_to_float_1 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_xx_1 = blocks.add_vff(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.blocks_abs_xx_0 = blocks.abs_ff(1)
        _a_sizer = wx.BoxSizer(wx.VERTICAL)
        self._a_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_a_sizer,
            value=self.a,
            callback=self.set_a,
            label='a',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._a_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_a_sizer,
            value=self.a,
            callback=self.set_a,
            minimum=0,
            maximum=1,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_a_sizer)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_abs_xx_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_complex_to_float_1, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.wxgui_scopesink2_4, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_complex_to_float_1, 0),
                     (self.blocks_abs_xx_0, 0))
        self.connect((self.blocks_complex_to_float_1, 1),
                     (self.blocks_add_xx_1, 1))
        self.connect((self.blocks_complex_to_float_1, 0),
                     (self.blocks_add_xx_1, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_multiply_const_vxx_2, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.wxgui_scopesink2_1, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.wxgui_scopesink2_2, 0))
Ejemplo n.º 53
0
    def __init__(self):
        gr.top_block.__init__(self, "NC-OFDM loopback")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("NC-OFDM loopback")
        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", "ncofdm_loopback")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.pn_symbols = pn_symbols = (1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1)
        self.occupied_carriers = occupied_carriers = (range(-31,32),)
        self.length_tag_name = length_tag_name = "packet_len"
        self.fft_len = fft_len = 64
        self.ShSeqLen = ShSeqLen = 40
        self.LgSeqLen = LgSeqLen = 320
        self.DataSeqLen = DataSeqLen = 64
        self.sync_len = sync_len = 20
        self.samp_rate = samp_rate = 100000
        self.pilot_symbols = pilot_symbols = ((1, 1, 1, -1,),)
        self.pilot_carriers = pilot_carriers = ((-21, -7, 7, 21,),)
        self.payload_mod = payload_mod = digital.constellation_qpsk()
        self.packet_len = packet_len = 100
        self.ncofdm_amp = ncofdm_amp = 1
        self.header_formatter = header_formatter = digital.packet_header_ofdm(occupied_carriers, 1, length_tag_name)
        self.fileprefix = fileprefix = "/root/"
        self.cp_len = cp_len = fft_len/4
        self.cen_freq = cen_freq = 1500000000
        self.ShThreshold = ShThreshold = 10
        self.ShSymbols = ShSymbols = pn_symbols[0:ShSeqLen]
        self.ShSeqRep = ShSeqRep = 8
        self.ShRepThreshold = ShRepThreshold = 3.5
        self.LgThreshold = LgThreshold = 100
        self.LgSymbols = LgSymbols = pn_symbols[ShSeqLen:ShSeqLen+LgSeqLen]
        self.DataSymbols = DataSymbols = pn_symbols[ShSeqLen+LgSeqLen:DataSeqLen+ShSeqLen+LgSeqLen]
        self.DataLen = DataLen = DataSeqLen*20

        ##################################################
        # Blocks
        ##################################################
        self.ncofdm_stream2fftvector_0 = ncofdm.stream2fftvector(fft_len, cp_len)
        self.ncofdm_ncofdm_carrier_allocator_0 = ncofdm.ncofdm_carrier_allocator(fft_len, occupied_carriers, (), (), "packet_len")
        self._ncofdm_amp_layout = Qt.QVBoxLayout()
        self._ncofdm_amp_tool_bar = Qt.QToolBar(self)
        self._ncofdm_amp_layout.addWidget(self._ncofdm_amp_tool_bar)
        self._ncofdm_amp_tool_bar.addWidget(Qt.QLabel("ncofdm_amp"+": "))
        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)
            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)
        self._ncofdm_amp_counter = qwt_counter_pyslot()
        self._ncofdm_amp_counter.setRange(0, 2, 0.001)
        self._ncofdm_amp_counter.setNumButtons(2)
        self._ncofdm_amp_counter.setValue(self.ncofdm_amp)
        self._ncofdm_amp_tool_bar.addWidget(self._ncofdm_amp_counter)
        self._ncofdm_amp_counter.valueChanged.connect(self.set_ncofdm_amp)
        self._ncofdm_amp_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._ncofdm_amp_slider.setRange(0, 2, 0.001)
        self._ncofdm_amp_slider.setValue(self.ncofdm_amp)
        self._ncofdm_amp_slider.setMinimumWidth(200)
        self._ncofdm_amp_slider.valueChanged.connect(self.set_ncofdm_amp)
        self._ncofdm_amp_layout.addWidget(self._ncofdm_amp_slider)
        self.top_layout.addLayout(self._ncofdm_amp_layout)
        self.ncofdm_add_cp_underlay_0 = ncofdm.add_cp_underlay(fft_len, cp_len, 20, 1280, ShSeqLen, ShSeqRep, ShSymbols, DataSeqLen, DataSymbols, LgSeqLen, LgSymbols, "packet_len")
        self.ncofdm_ShortPNdetector_0 = ncofdm.ShortPNdetector(fft_len, cp_len, ShSeqRep, ShSeqLen, 1)
        self.ncofdm_ShortPNcorr_0 = ncofdm.ShortPNcorr(fft_len, cp_len, ShSeqRep, ShSeqLen, (ShSymbols))
        self.ncofdm_LongPNcorrV2_0 = ncofdm.LongPNcorrV2(fft_len, cp_len, LgSeqLen, (LgSymbols), 60, ShSeqRep*ShSeqLen+LgSeqLen+DataLen+10)
        self.ncofdm_FreqOffCalc_0 = ncofdm.FreqOffCalc(fft_len, fft_len/4, ShSeqLen, ShSeqRep)
        self.fft_vxx_1 = fft.fft_vcc(fft_len, True, (), True, 1)
        self.fft_vxx_0 = fft.fft_vcc(fft_len, False, (()), True, 1)
        self.digital_chunks_to_symbols_xx_0_0_0 = digital.chunks_to_symbols_bc((payload_mod.points()), 1)
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage=0,
        	frequency_offset=0.0004,
        	epsilon=1.0,
        	taps=(1, ),
        	noise_seed=0,
        	block_tags=False
        )
        self.blocks_vector_to_stream_0_1 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, fft_len)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, fft_len)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_threshold_ff_0_0 = blocks.threshold_ff(ShRepThreshold, ShRepThreshold, 0)
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, packet_len, "packet_len")
        self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(8, payload_mod.bits_per_symbol(), length_tag_name, False, gr.GR_LSB_FIRST)
        self.blocks_null_sink_1_0_0_0_1_1_0_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_null_sink_1_0_0_0_1_1_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_null_sink_1_0_0_0_1_0_0_0 = blocks.null_sink(gr.sizeof_int*1)
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc(([1/(math.sqrt(44))]*fft_len))
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(100, 0.01, 4000)
        self.blocks_float_to_int_0 = blocks.float_to_int(1, 1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_sink_1_0_0_0_3 = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"short.dat", False)
        self.blocks_file_sink_1_0_0_0_3.set_unbuffered(False)
        self.blocks_file_sink_1_0_0_0_2 = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"org.dat", False)
        self.blocks_file_sink_1_0_0_0_2.set_unbuffered(False)
        self.blocks_file_sink_1_0_0_0_1_1_1 = blocks.file_sink(gr.sizeof_float*1, fileprefix+"rxshth.dat", False)
        self.blocks_file_sink_1_0_0_0_1_1_1.set_unbuffered(False)
        self.blocks_file_sink_1_0_0_0_1_1_0 = blocks.file_sink(gr.sizeof_float*1, fileprefix+"lgth.dat", False)
        self.blocks_file_sink_1_0_0_0_1_1_0.set_unbuffered(False)
        self.blocks_file_sink_1_0_0_0_0_2_0 = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"txdata.dat", False)
        self.blocks_file_sink_1_0_0_0_0_2_0.set_unbuffered(False)
        self.blocks_file_sink_1_0_0_0_0_2 = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"rxd.dat", False)
        self.blocks_file_sink_1_0_0_0_0_2.set_unbuffered(False)
        self.blocks_file_sink_1_0_0_0_0_0 = blocks.file_sink(gr.sizeof_int*1, fileprefix+"corr.dat", False)
        self.blocks_file_sink_1_0_0_0_0_0.set_unbuffered(False)
        self.blocks_file_sink_1_0_0_0_0 = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"dec.dat", False)
        self.blocks_file_sink_1_0_0_0_0.set_unbuffered(False)
        self.blocks_file_sink_1_0_0_0 = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"long.dat", False)
        self.blocks_file_sink_1_0_0_0.set_unbuffered(False)
        self.blocks_delay_0_0_0_0_0_0_0 = blocks.delay(gr.sizeof_float*1, 2)
        self.blocks_delay_0_0_0_0_0_0 = blocks.delay(gr.sizeof_float*1, 2)
        self.blocks_delay_0_0_0_0_0 = blocks.delay(gr.sizeof_int*1, 1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_mag_0_0_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 200, 10000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.ncofdm_ShortPNdetector_0, 0))    
        self.connect((self.blocks_complex_to_mag_0_0_0, 0), (self.blocks_moving_average_xx_0, 0))    
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_file_sink_1_0_0_0_1_1_0, 0))    
        self.connect((self.blocks_delay_0_0_0_0_0, 0), (self.ncofdm_FreqOffCalc_0, 1))    
        self.connect((self.blocks_delay_0_0_0_0_0_0, 0), (self.blocks_float_to_complex_0, 1))    
        self.connect((self.blocks_delay_0_0_0_0_0_0_0, 0), (self.blocks_float_to_complex_0, 0))    
        self.connect((self.blocks_float_to_complex_0, 0), (self.ncofdm_LongPNcorrV2_0, 1))    
        self.connect((self.blocks_float_to_int_0, 0), (self.blocks_delay_0_0_0_0_0, 0))    
        self.connect((self.blocks_moving_average_xx_0, 0), (self.ncofdm_LongPNcorrV2_0, 2))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.ncofdm_add_cp_underlay_0, 0))    
        self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_chunks_to_symbols_xx_0_0_0, 0))    
        self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_repack_bits_bb_0_0, 0))    
        self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_delay_0_0_0_0_0_0, 0))    
        self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_float_to_int_0, 0))    
        self.connect((self.blocks_throttle_0_0, 0), (self.channels_channel_model_0, 0))    
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_file_sink_1_0_0_0_0, 0))    
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_null_sink_1, 0))    
        self.connect((self.blocks_vector_to_stream_0_1, 0), (self.blocks_file_sink_1_0_0_0_0_2, 0))    
        self.connect((self.channels_channel_model_0, 0), (self.blocks_complex_to_mag_0_0_0, 0))    
        self.connect((self.channels_channel_model_0, 0), (self.blocks_file_sink_1_0_0_0_2, 0))    
        self.connect((self.channels_channel_model_0, 0), (self.ncofdm_LongPNcorrV2_0, 0))    
        self.connect((self.channels_channel_model_0, 0), (self.ncofdm_ShortPNcorr_0, 0))    
        self.connect((self.channels_channel_model_0, 0), (self.ncofdm_stream2fftvector_0, 0))    
        self.connect((self.digital_chunks_to_symbols_xx_0_0_0, 0), (self.ncofdm_ncofdm_carrier_allocator_0, 0))    
        self.connect((self.fft_vxx_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))    
        self.connect((self.fft_vxx_1, 0), (self.blocks_vector_to_stream_0, 0))    
        self.connect((self.ncofdm_FreqOffCalc_0, 0), (self.blocks_delay_0_0_0_0_0_0_0, 0))    
        self.connect((self.ncofdm_LongPNcorrV2_0, 0), (self.blocks_complex_to_real_0, 0))    
        self.connect((self.ncofdm_LongPNcorrV2_0, 1), (self.blocks_file_sink_1_0_0_0, 0))    
        self.connect((self.ncofdm_LongPNcorrV2_0, 2), (self.blocks_file_sink_1_0_0_0_0_0, 0))    
        self.connect((self.ncofdm_LongPNcorrV2_0, 2), (self.blocks_null_sink_1_0_0_0_1_0_0_0, 0))    
        self.connect((self.ncofdm_LongPNcorrV2_0, 1), (self.blocks_null_sink_1_0_0_0_1_1_0, 0))    
        self.connect((self.ncofdm_LongPNcorrV2_0, 0), (self.blocks_null_sink_1_0_0_0_1_1_0_0, 0))    
        self.connect((self.ncofdm_LongPNcorrV2_0, 2), (self.ncofdm_stream2fftvector_0, 1))    
        self.connect((self.ncofdm_ShortPNcorr_0, 1), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.ncofdm_ShortPNcorr_0, 1), (self.blocks_file_sink_1_0_0_0_3, 0))    
        self.connect((self.ncofdm_ShortPNcorr_0, 0), (self.blocks_null_sink_0, 0))    
        self.connect((self.ncofdm_ShortPNcorr_0, 1), (self.ncofdm_FreqOffCalc_0, 0))    
        self.connect((self.ncofdm_ShortPNdetector_0, 1), (self.blocks_file_sink_1_0_0_0_1_1_1, 0))    
        self.connect((self.ncofdm_ShortPNdetector_0, 0), (self.blocks_threshold_ff_0_0, 0))    
        self.connect((self.ncofdm_add_cp_underlay_0, 0), (self.blocks_file_sink_1_0_0_0_0_2_0, 0))    
        self.connect((self.ncofdm_add_cp_underlay_0, 0), (self.blocks_throttle_0_0, 0))    
        self.connect((self.ncofdm_ncofdm_carrier_allocator_0, 0), (self.blocks_vector_to_stream_0_1, 0))    
        self.connect((self.ncofdm_ncofdm_carrier_allocator_0, 0), (self.fft_vxx_0, 0))    
        self.connect((self.ncofdm_stream2fftvector_0, 0), (self.fft_vxx_1, 0))    
Ejemplo n.º 54
0
    def __init__(self, large_sig_len=0.0015, signal_mult=2, freq=433866000):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        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())

        ##################################################
        # Parameters
        ##################################################
        self.large_sig_len = large_sig_len
        self.signal_mult = signal_mult
        self.freq = freq

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 240000

        ##################################################
        # Blocks
        ##################################################
        self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(
            0.2, 1)
        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(-24, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(1, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(50, 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.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 10000, 10000, firdes.WIN_HAMMING,
                            6.76))
        self.blocks_threshold_ff_2 = blocks.threshold_ff(0, 0, 0)
        self.blocks_threshold_ff_1 = blocks.threshold_ff(0, 0, 0)
        self.blocks_sub_xx_2 = blocks.sub_ff(1)
        self.blocks_sub_xx_1 = blocks.sub_ff(1)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "localhost",
                                                     "52001", 10000, False)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff(
            (signal_mult, ))
        self.blocks_moving_average_xx_1 = blocks.moving_average_ff(
            int(samp_rate * large_sig_len), 0.8 / samp_rate / large_sig_len,
            4000)
        self.blocks_float_to_char_1 = blocks.float_to_char(1, 1)
        self.blocks_float_to_char_0_0 = blocks.float_to_char(1, 1)
        self.blocks_delay_1 = blocks.delay(gr.sizeof_float * 1,
                                           int(samp_rate * 0.00005))
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.bitgate_triggered_bits_0 = bitgate.triggered_bits(
            int(samp_rate * large_sig_len * 5), False)
        self.analog_rail_ff_1 = analog.rail_ff(0.001, 1)
        self.analog_rail_ff_0 = analog.rail_ff(0, 1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.bitgate_triggered_bits_0, 'pdus'),
                         (self.blocks_socket_pdu_0, 'pdus'))
        self.connect((self.analog_rail_ff_0, 0),
                     (self.blocks_float_to_char_0_0, 0))
        self.connect((self.analog_rail_ff_1, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.analog_rail_ff_1, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_delay_1, 0),
                     (self.blocks_float_to_char_1, 0))
        self.connect((self.blocks_float_to_char_0_0, 0),
                     (self.bitgate_triggered_bits_0, 1))
        self.connect((self.blocks_float_to_char_1, 0),
                     (self.bitgate_triggered_bits_0, 0))
        self.connect((self.blocks_moving_average_xx_1, 0),
                     (self.blocks_sub_xx_1, 1))
        self.connect((self.blocks_moving_average_xx_1, 0),
                     (self.blocks_sub_xx_2, 1))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_moving_average_xx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.single_pole_iir_filter_xx_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.analog_rail_ff_0, 0))
        self.connect((self.blocks_sub_xx_1, 0), (self.blocks_sub_xx_2, 0))
        self.connect((self.blocks_sub_xx_1, 0),
                     (self.blocks_threshold_ff_1, 0))
        self.connect((self.blocks_sub_xx_2, 0),
                     (self.blocks_threshold_ff_2, 0))
        self.connect((self.blocks_threshold_ff_1, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_threshold_ff_1, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_threshold_ff_2, 0), (self.blocks_delay_1, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.single_pole_iir_filter_xx_0, 0),
                     (self.blocks_sub_xx_1, 0))
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Variables
        ##################################################
        self.threshold = threshold = -70
        self.samp_rate = samp_rate = 2048000
        self.freq = freq = 525200000
        self.fft_size = fft_size = 1024

        ##################################################
        # Blocks
        ##################################################
        _threshold_sizer = wx.BoxSizer(wx.VERTICAL)
        self._threshold_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_threshold_sizer,
        	value=self.threshold,
        	callback=self.set_threshold,
        	label="Threshold",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._threshold_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_threshold_sizer,
        	value=self.threshold,
        	callback=self.set_threshold,
        	minimum=-100,
        	maximum=0,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_threshold_sizer)
        _freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_freq_sizer,
        	value=self.freq,
        	callback=self.set_freq,
        	label="freq",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._freq_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_freq_sizer,
        	value=self.freq,
        	callback=self.set_freq,
        	minimum=478000000,
        	maximum=862000000,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_freq_sizer)
        self.wxgui_numbersink2_1 = numbersink2.number_sink_f(
        	self.GetWin(),
        	unit="signal present",
        	minval=0,
        	maxval=1,
        	factor=1.0,
        	decimal_places=0,
        	ref_level=0,
        	sample_rate=samp_rate,
        	number_rate=15,
        	average=False,
        	avg_alpha=None,
        	label="Signal Detection",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_1.win)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
        	self.GetWin(),
        	unit="dB",
        	minval=-120,
        	maxval=0,
        	factor=1.0,
        	decimal_places=0,
        	ref_level=0,
        	sample_rate=samp_rate,
        	number_rate=15,
        	average=True,
        	avg_alpha=0.030,
        	label="Level",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=freq,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=fft_size,
        	fft_rate=15,
        	average=True,
        	avg_alpha=0.03,
        	title="Spectrum",
        	peak_hold=False,
        	win=window.rectangular,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rtlsdr_source_1 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.rtlsdr_source_1.set_sample_rate(samp_rate)
        self.rtlsdr_source_1.set_center_freq(freq, 0)
        self.rtlsdr_source_1.set_freq_corr(0, 0)
        self.rtlsdr_source_1.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_1.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_1.set_gain_mode(False, 0)
        self.rtlsdr_source_1.set_gain(20, 0)
        self.rtlsdr_source_1.set_if_gain(10, 0)
        self.rtlsdr_source_1.set_bb_gain(5, 0)
        self.rtlsdr_source_1.set_antenna("", 0)
        self.rtlsdr_source_1.set_bandwidth(1, 0)
          
        self.notebook = self.notebook = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "spectrum")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "output")
        self.Add(self.notebook)
        self.fft_vxx_0 = fft.fft_vcc(fft_size, True, (window.blackmanharris(1024)), True, 1)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float*1, fft_size)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(-100, threshold, threshold)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_size)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(fft_size)
        self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, fft_size*fft_size)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_divide_xx_0, 1))    
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_vector_to_stream_0, 0))    
        self.connect((self.blocks_divide_xx_0, 0), (self.blocks_nlog10_ff_0, 0))    
        self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_threshold_ff_0, 0))    
        self.connect((self.blocks_nlog10_ff_0, 0), (self.wxgui_numbersink2_0, 0))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))    
        self.connect((self.blocks_threshold_ff_0, 0), (self.wxgui_numbersink2_1, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.blocks_stream_to_vector_0, 0))    
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_divide_xx_0, 0))    
        self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self.rtlsdr_source_1, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.rtlsdr_source_1, 0), (self.wxgui_fftsink2_0, 0))