示例#1
0
	def setTone(self,freq,amplitude):
		self.signal=freq
		self.amp=amplitude
		self.analog_sig_source_x_0 = analog.sig_source_c(self.samp_rate, analog.GR_COS_WAVE, self.signal, self.amp, 0)
	        ##################################################
       	        # Variables
       	        ##################################################
     	        self.samp = samp = 192000
    	        self.rational_samp = rational_samp = 48000
              	self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
          	        interpolation=samp,
                        decimation=rational_samp,
                        taps=None,
                        fractional_bw=None,
                )
        	self.blocks_wavfile_sink_0 = blocks.wavfile_sink(self.path, 1, rational_samp, 16)
        	self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp,True)
      		self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
      		self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
       		self.analog_sig_source_x_2 = analog.sig_source_c(samp, analog.GR_COS_WAVE, samp/2, 1, 0)
       		 ##################################################
        		# Connections
      		  ##################################################
       		self.connect((self.analog_sig_source_x_2, 0), (self.blocks_multiply_xx_0, 1))
        	self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0))
       	 	self.connect((self.blocks_throttle_0, 0), (self.blocks_complex_to_real_0, 0))
        	self.connect((self.blocks_complex_to_real_0, 0), (self.rational_resampler_xxx_0, 0))
        	self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_wavfile_sink_0, 0))
        	self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_throttle_0, 0))
示例#2
0
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        parser.add_option("-I", "--audio-input", type="string", default="",
                          help="pcm input device name.  E.g., hw:0,0 or /dev/dsp")
        parser.add_option("-O", "--audio-output", type="string", default="",
                          help="pcm output device name")
        parser.add_option("-r", "--sample-rate", type="eng_float", default=192000,
                          help="set sample rate to RATE (192000)")
        parser.add_option("-f", "--frequency", type="eng_float", default=45000)
        parser.add_option("-a", "--amplitude", type="eng_float", default=0.5)

        (options, args) = parser.parse_args ()
        if len(args) != 0:
            parser.print_help()
            raise SystemExit, 1

        sample_rate = int(options.sample_rate)
        ampl = float(options.amplitude)
        if ampl > 1.0: ampl = 1.0

        to_real = blocks.complex_to_real()
        to_imag = blocks.complex_to_imag()

        src = audio.source (sample_rate, options.audio_input)
        firdes_taps = filter.firdes.low_pass_2(1, 1, 0.2, 0.1, 60)
        converter = filter.freq_xlating_fir_filter_fcf ( 1, firdes_taps, 0, sample_rate )
        converter.set_center_freq(0 - options.frequency)
        dst = audio.sink (sample_rate, options.audio_output, True)

        #self.connect(src, converter, to_real, dst)
        self.connect(src, converter)
        self.connect(converter, to_real, (dst,0))
        self.connect(converter, to_imag, (dst,1))
示例#3
0
def topblock(self, carrier=32000, samp_rate = 80000, bw=1000, amp=1):
    gr.top_block.__init__(self, "Top Block")

    ##################################################
    # Variables
    ##################################################
    self.samp_rate = samp_rate 
    self.carrier = carrier 
    self.bw = bw

    self.source = blocks.vector_source_b((0,0), False, 1, [])

    self.sink = blocks.multiply_vcc(1)
    analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, carrier, amp, 0)
    blocks_complex_to_real_0 = blocks.complex_to_real(1)
    stereo = blocks.multiply_const_vff((-1, ))
    self.out = blocks.wavfile_sink("/tmp/outbits.wav", 2, samp_rate)

    ##################################################
    # Connections
    ##################################################
    self.connect((analog_sig_source_x_0, 0), (self.sink, 1))
    self.connect((self.sink, 0), (blocks_complex_to_real_0, 0))
    self.connect((blocks_complex_to_real_0, 0), (self.out, 0))
    self.connect((blocks_complex_to_real_0, 0), (stereo, 0))
    self.connect((stereo, 0), (self.out, 1))
示例#4
0
    def __init__(self, mode, input_rate=0, context=None):
        assert input_rate > 0
        self.__input_rate = input_rate
        gr.hier_block2.__init__(
            self, 'RTTY demodulator',
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signature(1, 1, gr.sizeof_float * 1))
        
        channel_filter = self.__make_channel_filter()

        self.__text = u''
        self.__char_queue = gr.msg_queue(limit=100)
        self.__char_sink = blocks.message_sink(gr.sizeof_char, self.__char_queue, True)

        self.connect(
            self,
            channel_filter,
            self.__make_demodulator(),
            self.__char_sink)
        
        self.connect(
            channel_filter,
            self.__make_audio_filter(),
            blocks.rotator_cc(rotator_inc(self.__demod_rate, 2000 + self.__spacing / 2)),
            blocks.complex_to_real(vlen=1),
            analog.agc2_ff(
                reference=dB(-10),
                attack_rate=8e-1,
                decay_rate=8e-1),
            self)
示例#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)
示例#6
0
  def __init__(self,delay_num,delay_denom):
    gr.hier_block2.__init__(self,"moms",
      gr.io_signature(1,1,gr.sizeof_gr_complex),
      gr.io_signature(1,1,gr.sizeof_gr_complex))

    cmplx_to_real  = blocks.complex_to_real()
    cmplx_to_img   = blocks.complex_to_imag()

    iirf_real = filter.iir_filter_ffd([1.5],[1, -0.5])
    self.moms_real = moms_ff()
    self.moms_real.set_init_ip_fraction(delay_num,delay_denom)

    iirf_imag = filter.iir_filter_ffd([1.5],[1, -0.5])
    self.moms_imag = moms_ff()
    self.moms_imag.set_init_ip_fraction(delay_num,delay_denom)

    float_to_cmplx = blocks.float_to_complex()

    self.connect((self,0),            (cmplx_to_real,0))
    self.connect((self,0),            (cmplx_to_img,0))
    self.connect((cmplx_to_real,0),   (iirf_real,0))
    self.connect((cmplx_to_img,0),    (iirf_imag,0))
    self.connect((iirf_real,0),       (self.moms_real,0))
    self.connect((iirf_imag,0),       (self.moms_imag,0))
    self.connect((self.moms_real,0),  (float_to_cmplx,0))
    self.connect((self.moms_imag,0),  (float_to_cmplx,1))
    self.connect((float_to_cmplx,0),  (self,0))
示例#7
0
    def __init__(self, mode, input_rate=0, context=None):
        assert input_rate > 0
        self.__input_rate = input_rate
        gr.hier_block2.__init__(
            self, type(self).__name__,
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signature(1, 1, gr.sizeof_float * 1))
        
        channel_filter = self.__make_channel_filter()

        self.__text_cell = StringSinkCell(encoding='us-ascii')
        self.__text_sink = self.__text_cell.create_sink_internal()

        self.connect(
            self,
            channel_filter,
            self.__make_demodulator(),
            self.__text_sink)
        
        self.connect(
            channel_filter,
            self.__make_audio_filter(),
            blocks.rotator_cc(rotator_inc(self.__demod_rate, 2000 + self.__spacing / 2)),
            blocks.complex_to_real(vlen=1),
            analog.agc2_ff(
                reference=dB(-10),
                attack_rate=8e-1,
                decay_rate=8e-1),
            self)
示例#8
0
文件: acoust_out.py 项目: npgm/acoust
    def __init__(self):
        gr.top_block.__init__(self, "Acoust Out")

        ##################################################
        # Variables
        ##################################################
        self.transistion = transistion = 100
        self.sps = sps = 2
        self.sideband_rx = sideband_rx = 1000
        self.sideband = sideband = 1000
        self.samp_rate = samp_rate = 48000
        self.payload = payload = 20
        self.interpolation = interpolation = 200
        self.fd = fd = 0
        self.carrier = carrier = 13000

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=interpolation,
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (firdes.band_pass (0.50,samp_rate,carrier-sideband,carrier+sideband,transistion)), -carrier, samp_rate)
        self.digital_gfsk_mod_0 = digital.gfsk_mod(
        	samples_per_symbol=sps,
        	sensitivity=1.0,
        	bt=0.35,
        	verbose=False,
        	log=False,
        )
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blks2_tcp_source_0 = grc_blks2.tcp_source(
        	itemsize=gr.sizeof_char*1,
        	addr="127.0.0.1",
        	port=9000,
        	server=True,
        )
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder(
        		samples_per_symbol=sps,
        		bits_per_symbol=1,
        		preamble="",
        		access_code="",
        		pad_for_usrp=False,
        	),
        	payload_length=payload,
        )
        self.audio_sink_0 = audio.sink(48000, "", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_real_0, 0), (self.audio_sink_0, 0))
        self.connect((self.digital_gfsk_mod_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gfsk_mod_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.blks2_tcp_source_0, 0), (self.blks2_packet_encoder_0, 0))
示例#9
0
 def __init__(self, dst, samp_rate=2e6):
     gr.hier_block2.__init__(self, "record",
             gr.io_signature(1, 1, gr.sizeof_gr_complex),
             gr.io_signature(0, 0, 0))
    
     self._sink = blocks.wavfile_sink(dst, 1, int(samp_rate))
     self._c2 = blocks.complex_to_real(1)
     self.connect(self, self._c2, self._sink)
示例#10
0
def test_complex_to_real():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    complextoreal = blocks.complex_to_real()
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, complextoreal, probe)

    return top, probe
示例#11
0
 def test_complex_to_real(self):
     src_data = (1+2j, 3+4j, 5+6j, 7+8j, 9+10j)
     expected_data = (1.0, 3.0, 5.0, 7.0, 9.0)
     src = blocks.vector_source_c(src_data)
     op = blocks.complex_to_real()
     dst = blocks.vector_sink_f()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertFloatTuplesAlmostEqual(expected_data, dst.data())
示例#12
0
    def __init__(self, txstr="Hello World", carrier=10000, samp_rate = 80000, bw=4000, amp=1):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate 
        self.carrier = carrier 
        self.bw = bw

        ##################################################
        # Blocks
        ##################################################
        self.source = blocks.vector_source_b(tuple(bytearray(txstr)), False, 1, [])

        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=int(samp_rate/bw),
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((CODE_TABLE), CODE_LEN)
        self.blocks_vector_source_x_0 = blocks.vector_source_c([0, sin(pi/4), 1, sin(3*pi/4)], True, 1, [])
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, 4)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(CHUNK_LEN, gr.GR_LSB_FIRST)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, 2)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.audio_sink_0 = audio.sink(samp_rate, "")
        #XXX Hack: 0.07 should actually be parameter amp, but RPI crashes
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, carrier, 0.07, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.source, 0), (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_repeat_0, 0))

        self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_xx_0, 1))

        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_float_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_delay_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_float_to_complex_0, 1))

        self.connect((self.blocks_float_to_complex_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0_0, 1))

        self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.audio_sink_0, 0))
示例#13
0
    def __init__(self, win, sat_name, mode_name):
        gr.hier_block2.__init__(self, "Channel "+str(sat_name)+" "+str(mode_name)+" SSB",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(1, 1, gr.sizeof_gr_complex))

        self.trans = trans = 500
        self.sample_rate = sample_rate = 2048000
        self.low_ssb = low_ssb = 200
        self.high_ssb = high_ssb = 2800
        self.decim = decim = 8
        self.agc_decay = agc_decay = 50e-6

        ##################################################
        # Blocks
        ##################################################
        self.fftsink_audio = fftsink2.fft_sink_f(
            win,
            baseband_freq=0,
            y_per_div=5,
            y_divs=10,
            ref_level=-20,
            ref_scale=2.0,
            sample_rate=32000,
            fft_size=1024,
            fft_rate=15,
            average=True,
            avg_alpha=None,
            title="FFT Plot (Audio - "+sat_name+" "+str(mode_name)+")",
            peak_hold=True,
            )

        self.multiply_const_64 = blocks.multiply_const_vff((0.1, ))
        self.complex_to_real = blocks.complex_to_real(1)

        self.rational_resampler = filter.rational_resampler_ccc(
            interpolation=32,
            decimation=64,
            taps=None,
            fractional_bw=None,
            )
        self.band_pass_filter = filter.fir_filter_ccc(4, filter.firdes.complex_band_pass(
            1, sample_rate/decim, low_ssb, high_ssb, trans, filter.firdes.WIN_HAMMING, 6.76))
        self.agc = analog.agc2_cc(0.1, agc_decay, 0.9, 1.0)
        
        ##################################################
        # Connections
        ##################################################
        #self.connect(self, (self.gr_throttle_0, 0))

        self.connect(self, (self.band_pass_filter, 0))
        self.connect((self.band_pass_filter, 0), (self.agc, 0))
        self.connect((self.agc, 0), (self.rational_resampler, 0))
        self.connect((self.rational_resampler, 0), (self.complex_to_real, 0))
        self.connect((self.complex_to_real, 0), (self.multiply_const_64, 0))
        self.connect((self.multiply_const_64, 0), (self.fftsink_audio, 0))
        self.connect((self.multiply_const_64, 0), self)
示例#14
0
 def __make_sideband_demod(self, upper):
     first = grfilter.fir_filter_ccc(
         1,
         firdes.complex_band_pass(1.0, self.__demod_rate,
             _am_lower_cutoff_freq if upper else -_am_audio_bandwidth,
             _am_audio_bandwidth if upper else -_am_lower_cutoff_freq,
             1000,
             firdes.WIN_HAMMING))
     last = self.__make_dc_blocker()
     self.connect(first, blocks.complex_to_real(), last)
     return first, last
示例#15
0
 def __init__(self):
     gr.top_block.__init__(self, type(self).__name__)
     OptionalDriverMixin.__init__(self)
     
     # replace this with actual demodulator
     # this just proves there is data. mind the dc offset.
     sink = audio.sink(device_name='', sampling_rate=48000)
     decim = blocks.keep_one_in_n(gr.sizeof_gr_complex, 167)
     demod = blocks.complex_to_real()
     self.connect(decim, demod, sink)
     
     self.driver = blocks.vector_source_c([])
     self.driver_connection = (self.driver, decim)
     self.connect(*self.driver_connection)
示例#16
0
    def __init__(self, mode="MODE-S", input_rate=0, audio_rate=0, context=None):
        assert input_rate > 0
        gr.hier_block2.__init__(
            self,
            "Mode S/ADS-B/1090 demodulator",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            # TODO: Add generic support for demodulators with no audio output
            gr.io_signature(2, 2, gr.sizeof_float * 1),
        )
        self.mode = mode
        self.input_rate = input_rate

        # Subprocess
        self.dump1090 = SubprocessSink(args=["dump1090", "--ifile", "-"], itemsize=gr.sizeof_char)

        # Output
        self.band_filter_block = filter = MultistageChannelFilter(
            input_rate=input_rate,
            output_rate=pipe_rate,  # expected by dump1090
            cutoff_freq=pipe_rate / 2,
            transition_width=transition_width,
        )  # TODO optimize filter band
        interleaver = blocks.interleave(gr.sizeof_char)
        self.connect(
            self,
            filter,
            blocks.complex_to_real(1),
            blocks.multiply_const_ff(255.0 / 2),
            blocks.add_const_ff(255.0 / 2),
            blocks.float_to_uchar(),
            (interleaver, 0),
            self.dump1090,
        )

        self.connect(
            filter,
            blocks.complex_to_imag(1),
            blocks.multiply_const_ff(255.0 / 2),
            blocks.add_const_ff(255.0 / 2),
            blocks.float_to_uchar(),
            (interleaver, 1),
        )
        # Dummy audio
        zero = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.throttle = blocks.throttle(gr.sizeof_float, audio_rate)
        self.connect(zero, self.throttle)
        self.connect(self.throttle, (self, 0))
        self.connect(self.throttle, (self, 1))
示例#17
0
	def __init__(self, mode, audio_rate=0, **kwargs):
		if mode == 'LSB':
			lsb = True
		elif mode == 'USB':
			lsb = False
		else:
			raise ValueError('Not an SSB mode: %r' % (mode,))
		demod_rate = audio_rate
		
		SimpleAudioDemodulator.__init__(self,
			mode=mode,
			audio_rate=audio_rate,
			demod_rate=demod_rate,
			band_filter=audio_rate / 2,  # unused
			band_filter_transition=audio_rate / 2,  # unused
			**kwargs)
		input_rate = self.input_rate
		
		half_bandwidth = self.half_bandwidth = 2800 / 2
		if lsb:
			band_mid = -200 - half_bandwidth
		else:
			band_mid = 200 + half_bandwidth
		self.band_filter_low = band_mid - half_bandwidth
		self.band_filter_high = band_mid + half_bandwidth
		self.band_filter_width = half_bandwidth / 5
		self.sharp_filter_block = grfilter.fir_filter_ccc(
			1,
			firdes.complex_band_pass(1.0, demod_rate,
				self.band_filter_low,
				self.band_filter_high,
				self.band_filter_width,
				firdes.WIN_HAMMING))
		
		self.agc_block = analog.agc2_cc(reference=0.25)
		
		self.ssb_demod_block = blocks.complex_to_real(1)
		
		self.connect(
			self,
			self.band_filter_block,
			self.sharp_filter_block,
			self.rf_squelch_block,
			self.agc_block,
			self.ssb_demod_block)
		self.connect(self.sharp_filter_block, self.rf_probe_block)
		self.connect_audio_output(self.ssb_demod_block, self.ssb_demod_block)
示例#18
0
    def __init__(self, mode,
            input_rate=0,
            context=None):
        assert input_rate > 0
        gr.hier_block2.__init__(
            self, 'RTTY demodulator',
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signature(1, 1, gr.sizeof_float * 1),
        )
        self.__text = u''
        
        baud = _DEFAULT_BAUD  # TODO param
        self.baud = baud

        demod_rate = 6000  # TODO optimize this value
        self.samp_rate = demod_rate  # TODO rename
        
        self.__channel_filter = MultistageChannelFilter(
            input_rate=input_rate,
            output_rate=demod_rate,
            cutoff_freq=self.__filter_high,
            transition_width=self.__transition)  # TODO optimize filter band
        self.__sharp_filter = grfilter.fir_filter_ccc(
            1,
            firdes.complex_band_pass(1.0, demod_rate,
                self.__filter_low,
                self.__filter_high,
                self.__transition,
                firdes.WIN_HAMMING))
        self.fsk_demod = RTTYFSKDemodulator(input_rate=demod_rate, baud=baud)
        self.__real = blocks.complex_to_real(vlen=1)
        self.__char_queue = gr.msg_queue(limit=100)
        self.char_sink = blocks.message_sink(gr.sizeof_char, self.__char_queue, True)

        self.connect(
            self,
            self.__channel_filter,
            self.__sharp_filter,
            self.fsk_demod,
            rtty.rtty_decode_ff(rate=demod_rate, baud=baud, polarity=False),
            self.char_sink)
        
        self.connect(
            self.__sharp_filter,
            self.__real,
            self)
示例#19
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 = 1e6

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.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.Add(self.wxgui_scopesink2_0.win)
        self.iir_filter_xxx_0 = filter.iir_filter_ffd((0.000005, ), ([1,1]), True)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 10000, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 100000, 1, 0)
        self.analog_phase_modulator_fc_0 = analog.phase_modulator_fc(100000)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_phase_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.analog_sig_source_x_0_0, 0), (self.iir_filter_xxx_0, 0))    
        self.connect((self.blocks_complex_to_real_0, 0), (self.wxgui_scopesink2_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_0, 0))    
        self.connect((self.iir_filter_xxx_0, 0), (self.analog_phase_modulator_fc_0, 0))    
示例#20
0
    def __init__(self,
            input_rate,
            output_rate=12000,
            output_frequency=1500,
            transition_width=100,
            width=800):
        """Make a new WSPRFilter.

        input_rate: the incomming sample rate

        output_rate: output sample rate

        output_frequency: 0Hz in the complex input will be centered on this
        frequency in the real output

        width, transition_width: passband and transition band widths.
        """

        gr.hier_block2.__init__(
            self, type(self).__name__,
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
            gr.io_signature(1, 1, gr.sizeof_float))

        self.connect(
            self,

            MultistageChannelFilter(
                input_rate=input_rate,
                output_rate=output_rate,
                cutoff_freq=width / 2,
                transition_width=transition_width),

            blocks.rotator_cc(2 * pi * output_frequency / output_rate),

            blocks.complex_to_real(vlen=1),

            analog.agc2_ff(
                reference=dB(-10),
                attack_rate=8e-1,
                decay_rate=8e-1),

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

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

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

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_complex_to_mag_squared_1, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_stream_to_vector_0_0, 0), (self.fft_vxx_0_0, 0))
        self.connect((self.fft_vxx_0_0, 0), (self.blocks_vector_to_stream_0_0, 0))
        self.connect((self.blocks_vector_to_stream_0_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_stream_to_vector_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self, 0))
        self.connect((self.blocks_complex_to_mag_squared_1, 0), (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_float_to_complex_0, 0))
示例#22
0
    def __init__(self, mode, input_rate, context):
        channels = 2
        audio_rate = 10000
        
        gr.hier_block2.__init__(
            self, str('%s demodulator' % (mode,)),
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
            gr.io_signature(1, 1, gr.sizeof_float * channels))

        self.__input_rate = input_rate
        self.__rec_freq_input = 0.0
        self.__signal_type = SignalType(kind='STEREO', sample_rate=audio_rate)

        # Using agc2 rather than feedforward AGC for efficiency, because this runs at the RF rate rather than the audio rate.
        agc_block = analog.agc2_cc(reference=dB(-8))
        agc_block.set_attack_rate(8e-3)
        agc_block.set_decay_rate(8e-3)
        agc_block.set_max_gain(dB(40))
        
        self.connect(
            self,
            agc_block)
        
        channel_joiner = blocks.streams_to_vector(gr.sizeof_float, channels)
        self.connect(channel_joiner, self)
        
        for channel in xrange(0, channels):
            self.connect(
                agc_block,
                grfilter.fir_filter_ccc(1, design_sawtooth_filter(decreasing=channel == 0)),
                blocks.complex_to_mag(1),
                blocks.float_to_complex(),  # So we can use the complex-input band filter. TODO eliminate this for efficiency
                MultistageChannelFilter(
                    input_rate=input_rate,
                    output_rate=audio_rate,
                    cutoff_freq=5000,
                    transition_width=5000),
                blocks.complex_to_real(),
                # assuming below 40Hz is not of interest
                grfilter.dc_blocker_ff(audio_rate // 40, False),
                (channel_joiner, channel))
示例#23
0
    def __init__(self, mode, input_rate=0, context=None):
        assert input_rate > 0
        self.__input_rate = input_rate
        gr.hier_block2.__init__(
            self, type(self).__name__,
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
            gr.io_signature(1, 1, gr.sizeof_float))
        
        channel_filter = self.__make_channel_filter()

        self.__text = u''
        self.__char_queue = gr.msg_queue(limit=100)
        self.__char_sink = blocks.message_sink(gr.sizeof_char, self.__char_queue, True)

        # The output of the channel filter is oversampled so we don't need to
        # interpolate for the audio monitor. So we'll downsample before going into
        # the demodulator.
        samp_per_sym = 8
        downsample = self.__demod_rate / samp_per_sym / self.__symbol_rate
        assert downsample % 1 == 0
        downsample = int(downsample)

        self.connect(
            self,
            channel_filter,
            blocks.keep_one_in_n(gr.sizeof_gr_complex, downsample),
            psk31_coherent_demodulator_cc(samp_per_sym=samp_per_sym),
            psk31_constellation_decoder_cb(
                varicode_decode=True,
                differential_decode=True),
            self.__char_sink)
        
        self.connect(
            channel_filter,
            blocks.rotator_cc(rotator_inc(self.__demod_rate, self.__audio_frequency)),
            blocks.complex_to_real(vlen=1),
            analog.agc2_ff(
                reference=dB(-10),
                attack_rate=8e-1,
                decay_rate=8e-1),
            self)
示例#24
0
    def __init__(self, audio_input, input_rate, audio_output, output_rate, frequency=55000, ampl=1.0):
        gr.top_block.__init__(self)

        if ampl > 1.0: ampl = 1.0

        to_real = blocks.complex_to_real()
        to_imag = blocks.complex_to_imag()
        float_to_complex = blocks.float_to_complex()

        src = audio.source (input_rate, audio_input)
        firdes_taps = filter.firdes.low_pass_2(1, 1, 0.2, 0.1, 60)
        self._converter = filter.freq_xlating_fir_filter_ccf ( 1, firdes_taps, 0, input_rate )
        self._converter.set_center_freq(frequency)
        dst = audio.sink (output_rate, audio_output, True)

        #self.connect(src, converter, to_real, dst)
        self.connect((src, 1), (float_to_complex, 0))
        self.connect((src, 0), (float_to_complex, 1))
        self.connect(float_to_complex, self._converter)
        self.connect(self._converter, to_real, (dst,0))
        self.connect(self._converter, to_imag, (dst,1))
示例#25
0
    def __init__(self, txstr="Hello world", carrier=32000, samp_rate = 80000, bw=1000, amp=1):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate 
        self.carrier = carrier 
        self.bw = bw

        ##################################################
        # Blocks
        ##################################################
        self.source = blocks.vector_source_b(tuple(bytearray(txstr)), False, 1, [])
        blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(1, gr.GR_LSB_FIRST)
        digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(([0,1,1,0]), 2)

        blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, samp_rate/bw)
        #XXX Hack: 0.07 should actually be parameter amp, but RPI crashes
        analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, carrier, 0.07, 0)
        blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        blocks_complex_to_real_0 = blocks.complex_to_real(1)
        audio_sink_0 = audio.sink(samp_rate, "")
        
        self.samp_blocks = [self.source, 
                            blocks_repeat_0,
                            analog_sig_source_x_0,
                            audio_sink_0]

        ##################################################
        # Connections
        ##################################################
        self.connect((self.source, 0), (blocks_packed_to_unpacked_xx_0, 0))
        self.connect((blocks_packed_to_unpacked_xx_0, 0), (digital_chunks_to_symbols_xx_0, 0))
        self.connect((digital_chunks_to_symbols_xx_0, 0), (blocks_repeat_0, 0))

        self.connect((blocks_repeat_0, 0), (blocks_multiply_xx_0_0, 0))
        self.connect((analog_sig_source_x_0, 0), (blocks_multiply_xx_0_0, 1))
        self.connect((blocks_multiply_xx_0_0, 0), (blocks_complex_to_real_0, 0))
        self.connect((blocks_complex_to_real_0, 0), (audio_sink_0, 0))
示例#26
0
 def __do_connect(self):
     self.disconnect_all()
     if self.__use_entire_input_band:
         self.band_filter_block.set_center_freq(0)
         self.connect(
             self,
             self.demod_block,
             blocks.float_to_complex(),  # So we can use the complex-input band filter. TODO eliminate this for efficiency
             self.band_filter_block,
             self.rf_squelch_block,
             self.agc_block,
             blocks.complex_to_real(),
             self.dc_blocker,
         )
         self.connect(self, self.rf_probe_block)
     else:
         self.band_filter_block.set_center_freq(self.__rec_freq_input)
         self.connect(
             self, self.band_filter_block, self.rf_squelch_block, self.agc_block, self.demod_block, self.dc_blocker
         )
         self.connect(self.band_filter_block, self.rf_probe_block)
     self.connect_audio_output(self.dc_blocker)
    def __init__(self, *args, **kwargs):
        """
    Hierarchical block for BPSK demodulation.

    The input is the complex modulated signal at baseband.
        Demodulated packets are sent to the handler.

        @param callback:  function of two args: ok, payload
        @type callback: ok: bool; payload: string
        @param threshold: detect access_code with up to threshold bits wrong (-1 -> use default)
        @type threshold: int

        See ieee802_15_4_demod for remaining parameters.
    """
        try:
            self.callback = kwargs.pop('callback')
            self.threshold = kwargs.pop('threshold')    
            #Return the demodulator
            self.demodulator = kwargs.pop('demodulator')
            self.gui = kwargs.pop('gui')
            self._samples_per_symbol = kwargs.pop('sps')
        except KeyError:
            pass
        gr.hier_block2.__init__(self, "ieee_pkt_receiver",
                        gr.io_signature(1, 1, gr.sizeof_gr_complex),  # Input
                        gr.io_signature(0, 0, 0))  # Output
        
        self._rcvd_pktq = gr.msg_queue()          # holds packets from the PHY
        
        #Create the sink of packets
        self._packet_sink = ieee_868_915.packet_sink(self._rcvd_pktq, self.threshold)
        
        #self.complex_to_float = gr.complex_to_float(1)
        self.complex_to_real = blocks.complex_to_real()
        
        self.connect(self, self.demodulator, self.complex_to_real, self._packet_sink)
      
        self._watcher = _queue_watcher_thread(self._rcvd_pktq, self.callback)
示例#28
0
    def __init__(self):
        gr.top_block.__init__(self, "Cadu Soft")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Cadu Soft")
        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", "cadu_soft")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.symbol_rate = symbol_rate = 500e3
        self.sps = sps = 4
        self.samp_rate = samp_rate = symbol_rate * sps
        self.p = p = 0.1
        self.ntaps = ntaps = 20 * sps
        self.frame_size = frame_size = 501
        self.SNR = SNR = 10.0
        self.value = value = [0, 1]
        self.taps_2 = taps_2 = firdes.root_raised_cosine(
            1, samp_rate, (samp_rate / sps), 0.35, ntaps)

        self.taps = taps = firdes.root_raised_cosine(sps, samp_rate,
                                                     symbol_rate, 0.35, ntaps)

        self.symbol = symbol = [-1, 1]
        self.scramble = scramble = 0
        self.rs = rs = 0
        self.reset = reset = frame_size
        self.noise_original = noise_original = math.sqrt(
            (1) / math.pow(10, (SNR) / 10.0))
        self.linecode = linecode = 0
        self.intDepth = intDepth = 1

        self.decoder = decoder = fec.cc_decoder.make(
            (8068 - 52), 7, 2, ([79, 109]), 29, 6, fec.CC_TAILBITING, False)

        self.cfo = cfo = 0.00
        self.bn = bn = 2 * math.pi * (p / 100)

        ##################################################
        # Blocks
        ##################################################
        self.tdd_nullMsgSink_0 = tdd.nullMsgSink(1)
        self.qtgui_sink_x_0_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / sps,  #bw
            "",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_0_win)

        self.qtgui_sink_x_0_0.enable_rf_freq(False)

        self.pcm_encodeNRZ_0 = pcm.encodeNRZ(linecode)
        self.mapper_prbs_source_b_0 = mapper.prbs_source_b("PRBS31", reset * 8)
        self.mapper_prbs_sink_b_0 = mapper.prbs_sink_b("PRBS31", reset * 8)
        self.fir_filter_xxx_0 = filter.fir_filter_ccc(sps, (taps))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.fec_async_decoder_0 = fec.async_decoder(decoder, False, False,
                                                     8016)
        self.channel_phaseError_0 = channel.phaseError(135)
        self.channel_gsPhaseNoise_0 = channel.gsPhaseNoise(
            math.sqrt(samp_rate / 2), ([
                2.800000000000000e-06, -5.866548800000000e-06,
                3.064241879202000e-06
            ]),
            ([1, -2.555230500000000, 2.114073646727000, -0.558843141309031]))
        self.ccsds_synchronizeCADUSoft_0 = ccsds.synchronizeCADUSoft(
            '1ACFFC1D', 1, 7, 0, 52 + 8016, 1, 0, 'sync')
        self.ccsds_recoverCADUSoft_0 = ccsds.recoverCADUSoft(
            8068 - 52, 0, 'sync')
        self.ccsds_createCADU_0 = ccsds.createCADU(frame_size, '1ACFFC1D', 0,
                                                   'packet_len')
        self.ccsds_convEncoder_0 = ccsds.convEncoder(0)
        self.bpsk_bpskPulseshapeRRC_0 = bpsk.bpskPulseshapeRRC(
            sps, 1.0, samp_rate, samp_rate / (sps), 0.35, 40 * sps)
        self.bpsk_bpskPhaseRecovery_0 = bpsk.bpskPhaseRecovery(
            4, bn,
            math.sqrt(2) / 2, 2)
        self.bpsk_bpskIQMap_0 = bpsk.bpskIQMap()
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate,
                                                 True)
        self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_float * 1, '',
                                                   "sync")
        self.blocks_tag_debug_0.set_display(False)
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, frame_size, "packet_len")
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((-1, ))
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.baseband_debug_channel_model_1_0 = baseband.debug_channel_model_1(
            noise_original / math.sqrt(sps), cfo, 1.0, (1.0, ), 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ccsds_recoverCADUSoft_0, 'cadu'),
                         (self.fec_async_decoder_0, 'in'))
        self.msg_connect((self.fec_async_decoder_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.msg_connect((self.fec_async_decoder_0, 'out'),
                         (self.tdd_nullMsgSink_0, 'in'))
        self.connect((self.baseband_debug_channel_model_1_0, 0),
                     (self.channel_gsPhaseNoise_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.ccsds_synchronizeCADUSoft_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_0, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0),
                     (self.mapper_prbs_sink_b_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0),
                     (self.ccsds_createCADU_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                     (self.ccsds_convEncoder_0, 0))
        self.connect((self.bpsk_bpskIQMap_0, 0),
                     (self.channel_phaseError_0, 0))
        self.connect((self.bpsk_bpskPhaseRecovery_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.bpsk_bpskPhaseRecovery_0, 0),
                     (self.qtgui_sink_x_0_0, 0))
        self.connect((self.bpsk_bpskPulseshapeRRC_0, 0),
                     (self.bpsk_bpskIQMap_0, 0))
        self.connect((self.ccsds_convEncoder_0, 0), (self.pcm_encodeNRZ_0, 0))
        self.connect((self.ccsds_createCADU_0, 0),
                     (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.ccsds_synchronizeCADUSoft_0, 0),
                     (self.blocks_tag_debug_0, 0))
        self.connect((self.ccsds_synchronizeCADUSoft_0, 0),
                     (self.ccsds_recoverCADUSoft_0, 0))
        self.connect((self.channel_gsPhaseNoise_0, 0),
                     (self.fir_filter_xxx_0, 0))
        self.connect((self.channel_phaseError_0, 0),
                     (self.baseband_debug_channel_model_1_0, 0))
        self.connect((self.fir_filter_xxx_0, 0),
                     (self.bpsk_bpskPhaseRecovery_0, 0))
        self.connect((self.mapper_prbs_source_b_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.pcm_encodeNRZ_0, 0),
                     (self.bpsk_bpskPulseshapeRRC_0, 0))
示例#29
0
    def __init__(self, demod_rate, audio_decimation):
        """
        Hierarchical block for demodulating a broadcast FM signal.

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

        Args:
            demod_rate: input sample rate of complex baseband input. (float)
            audio_decimation: how much to decimate demod_rate to get to audio. (integer)
        """
        gr.hier_block2.__init__(self, "wfm_rcv_pll",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
                                gr.io_signature(2, 2, gr.sizeof_float))      # Output signature
        bandwidth = 250e3
        audio_rate = demod_rate / audio_decimation


        # We assign to self so that outsiders can grab the demodulator
        # if they need to.  E.g., to plot its output.
        #
        # input: complex; output: float
        loop_bw = 2*math.pi/100.0
        max_freq = 2.0*math.pi*90e3/demod_rate
        self.fm_demod = analog.pll_freqdet_cf(loop_bw, max_freq,-max_freq)

        # input: float; output: float
        self.deemph_Left  = fm_deemph(audio_rate)
        self.deemph_Right = fm_deemph(audio_rate)

        # compute FIR filter taps for audio filter
        width_of_transition_band = audio_rate / 32
        audio_coeffs = filter.firdes.low_pass(1.0 ,         # gain
                                              demod_rate,      # sampling rate
                                              15000 ,
                                              width_of_transition_band,
                                              filter.firdes.WIN_HAMMING)
        # input: float; output: float
        self.audio_filter = filter.fir_filter_fff(audio_decimation, audio_coeffs)
        if 1:
            # Pick off the stereo carrier/2 with this filter. It attenuated 10 dB so apply 10 dB gain
            # We pick off the negative frequency half because we want to base band by it!
            ##  NOTE  THIS WAS HACKED TO OFFSET INSERTION LOSS DUE TO DEEMPHASIS

            stereo_carrier_filter_coeffs = \
                filter.firdes.complex_band_pass(10.0,
                                                demod_rate,
                                                -19020,
                                                -18980,
                                                width_of_transition_band,
                                                filter.firdes.WIN_HAMMING)

            #print "len stereo carrier filter = ",len(stereo_carrier_filter_coeffs)
            #print "stereo carrier filter ", stereo_carrier_filter_coeffs
            #print "width of transition band = ",width_of_transition_band, " audio rate = ", audio_rate

            # Pick off the double side band suppressed carrier Left-Right audio. It is attenuated 10 dB so apply 10 dB gain

            stereo_dsbsc_filter_coeffs = \
                filter.firdes.complex_band_pass(20.0,
                                                demod_rate,
                                                38000-15000 / 2,
                                                38000+15000 / 2,
                                                width_of_transition_band,
                                                filter.firdes.WIN_HAMMING)
            #print "len stereo dsbsc filter = ",len(stereo_dsbsc_filter_coeffs)
            #print "stereo dsbsc filter ", stereo_dsbsc_filter_coeffs
            # construct overlap add filter system from coefficients for stereo carrier

            self.stereo_carrier_filter = \
                filter.fir_filter_fcc(audio_decimation, stereo_carrier_filter_coeffs)

            # carrier is twice the picked off carrier so arrange to do a complex multiply

            self.stereo_carrier_generator = blocks.multiply_cc();

            # Pick off the rds signal

            stereo_rds_filter_coeffs = \
                filter.firdes.complex_band_pass(30.0,
                                                demod_rate,
                                                57000 - 1500,
                                                57000 + 1500,
                                                width_of_transition_band,
                                                filter.firdes.WIN_HAMMING)
            #print "len stereo dsbsc filter = ",len(stereo_dsbsc_filter_coeffs)
            #print "stereo dsbsc filter ", stereo_dsbsc_filter_coeffs
            # construct overlap add filter system from coefficients for stereo carrier

            self.rds_signal_filter = \
                filter.fir_filter_fcc(audio_decimation, stereo_rds_filter_coeffs)

            self.rds_carrier_generator = blocks.multiply_cc();
            self.rds_signal_generator = blocks.multiply_cc();
            self_rds_signal_processor = blocks.null_sink(gr.sizeof_gr_complex);

            loop_bw = 2*math.pi/100.0
            max_freq = -2.0*math.pi*18990/audio_rate;
            min_freq = -2.0*math.pi*19010/audio_rate;

            self.stereo_carrier_pll_recovery = \
                analog.pll_refout_cc(loop_bw, max_freq, min_freq);
            #self.stereo_carrier_pll_recovery.squelch_enable(False) #pll_refout does not have squelch yet, so disabled for now

            # set up mixer (multiplier) to get the L-R signal at baseband

            self.stereo_basebander = blocks.multiply_cc();

            # pick off the real component of the basebanded L-R signal.  The imaginary SHOULD be zero

            self.LmR_real = blocks.complex_to_real();
            self.Make_Left = blocks.add_ff();
            self.Make_Right = blocks.sub_ff();

            self.stereo_dsbsc_filter = \
                filter.fir_filter_fcc(audio_decimation, stereo_dsbsc_filter_coeffs)

        if 1:

            # send the real signal to complex filter to pick off the carrier and then to one side of a multiplier
            self.connect(self, self.fm_demod, self.stereo_carrier_filter,
                         self.stereo_carrier_pll_recovery, (self.stereo_carrier_generator,0))
            # send the already filtered carrier to the otherside of the carrier
            self.connect(self.stereo_carrier_pll_recovery, (self.stereo_carrier_generator,1))
            # the resulting signal from this multiplier is the carrier with correct phase but at -38000 Hz.

            # send the new carrier to one side of the mixer (multiplier)
            self.connect(self.stereo_carrier_generator, (self.stereo_basebander,0))
            # send the demphasized audio to the DSBSC pick off filter,  the complex
            # DSBSC signal at +38000 Hz is sent to the other side of the mixer/multiplier
            self.connect(self.fm_demod,self.stereo_dsbsc_filter, (self.stereo_basebander,1))
            # the result is BASEBANDED DSBSC with phase zero!

            # Pick off the real part since the imaginary is theoretically zero and then to one side of a summer
            self.connect(self.stereo_basebander, self.LmR_real, (self.Make_Left,0))
            #take the same real part of the DSBSC baseband signal and send it to negative side of a subtracter
            self.connect(self.LmR_real,(self.Make_Right,1))

            # Make rds carrier by taking the squared pilot tone and multiplying by pilot tone
            self.connect(self.stereo_basebander,(self.rds_carrier_generator,0))
            self.connect(self.stereo_carrier_pll_recovery,(self.rds_carrier_generator,1))
            # take signal, filter off rds,  send into mixer 0 channel
            self.connect(self.fm_demod,self.rds_signal_filter,(self.rds_signal_generator,0))
            # take rds_carrier_generator output and send into mixer 1 channel
            self.connect(self.rds_carrier_generator,(self.rds_signal_generator,1))
            # send basebanded rds signal and send into "processor" which for now is a null sink
            self.connect(self.rds_signal_generator,self_rds_signal_processor)


        if 1:
            # pick off the audio, L+R that is what we used to have and send it to the summer
            self.connect(self.fm_demod, self.audio_filter, (self.Make_Left, 1))
            # take the picked off L+R audio and send it to the PLUS side of the subtractor
            self.connect(self.audio_filter,(self.Make_Right, 0))
            # The result of  Make_Left  gets    (L+R) +  (L-R) and results in 2*L
            # The result of Make_Right gets  (L+R) - (L-R) and results in 2*R
            self.connect(self.Make_Left , self.deemph_Left, (self, 0))
            self.connect(self.Make_Right, self.deemph_Right, (self, 1))
    def __init__(self):
        gr.top_block.__init__(self, "HF channel simulation")

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

        ##################################################
        # Blocks
        ##################################################
        self.snrOut = blocks.probe_signal_vf(4)
        self.outSigRMS = blocks.probe_signal_vf(2)

        def _snrVecOut_probe():
            while True:

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

        _snrVecOut_thread = threading.Thread(target=_snrVecOut_probe)
        _snrVecOut_thread.daemon = True
        _snrVecOut_thread.start()

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

        def _outSigRMSVec_probe():
            while True:

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

        _outSigRMSVec_thread = threading.Thread(target=_outSigRMSVec_probe)
        _outSigRMSVec_thread.daemon = True
        _outSigRMSVec_thread.start()

        self.low_pass_filter_2_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 1550, 100, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_2 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 1550, 100, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_1_1 = filter.interp_fir_filter_ccf(
            int(samp_rate / 100),
            firdes.low_pass(ampl[1][0] * (samp_rate / 100.0), samp_rate, 50,
                            25, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_1_0_0 = filter.interp_fir_filter_ccf(
            int(samp_rate / 100),
            firdes.low_pass(ampl[1][1] * (samp_rate / 100.0), samp_rate, 50,
                            25, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_1_0 = filter.interp_fir_filter_ccf(
            int(samp_rate / 100),
            firdes.low_pass(ampl[0][1] * (samp_rate / 100.0), samp_rate, 50,
                            25, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_1 = filter.interp_fir_filter_ccf(
            int(samp_rate / 100),
            firdes.low_pass(ampl[0][0] * (samp_rate / 100.0), samp_rate, 50,
                            25, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 1750 + 100, 600, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 1750 + 100, 600, firdes.WIN_HAMMING,
                            6.76))
        self.epy_block_0_0_0_0 = epy_block_0_0_0_0.blk(fd=fd)
        self.epy_block_0_0_0 = epy_block_0_0_0.blk(fd=fd)
        self.epy_block_0_0 = epy_block_0_0.blk(fd=fd)
        self.epy_block_0 = epy_block_0.blk(fd=fd)
        self.blocks_streams_to_vector_0_0 = blocks.streams_to_vector(
            gr.sizeof_float * 1, 2)
        self.blocks_streams_to_vector_0 = blocks.streams_to_vector(
            gr.sizeof_float * 1, 4)
        self.blocks_selector_0_1 = blocks.selector(gr.sizeof_gr_complex * 1,
                                                   noSpread, 0)
        self.blocks_selector_0_1.set_enabled(True)
        self.blocks_selector_0_0_0 = blocks.selector(gr.sizeof_gr_complex * 1,
                                                     noSpread, 0)
        self.blocks_selector_0_0_0.set_enabled(True)
        self.blocks_selector_0_0 = blocks.selector(gr.sizeof_gr_complex * 1,
                                                   noSpread, 0)
        self.blocks_selector_0_0.set_enabled(True)
        self.blocks_selector_0 = blocks.selector(gr.sizeof_gr_complex * 1,
                                                 noSpread, 0)
        self.blocks_selector_0.set_enabled(True)
        self.blocks_rms_xx_0_1 = blocks.rms_cf(2 * pi * tau_a * 100 /
                                               samp_rate)
        self.blocks_rms_xx_0_0_0 = blocks.rms_ff(2 * pi * tau_a * 10 /
                                                 samp_rate)
        self.blocks_rms_xx_0_0 = blocks.rms_ff(2 * pi * tau_a * 10 / samp_rate)
        self.blocks_rms_xx_0 = blocks.rms_cf(2 * pi * tau_a * 100 / samp_rate)
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_float * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_nlog10_ff_0_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_multiply_xx_1_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0_0_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0_0_0_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0_0_0_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0_0_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_3_0 = blocks.multiply_const_ff(
            en_noise[1])
        self.blocks_multiply_const_vxx_3 = blocks.multiply_const_ff(
            en_noise[0])
        self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_cc(vol[1])
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_cc(vol[0])
        self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_ff(
            2 * sqrt(ampl[1][0]**2 + ampl[1][1]**2) * 2)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_ff(
            2 * sqrt(ampl[0][0]**2 + ampl[0][1]**2) * 2)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_ff(0.5)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(0.5)
        self.blocks_float_to_complex_1_0 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_1 = 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_1_0 = blocks.divide_ff(1)
        self.blocks_divide_xx_1 = blocks.divide_ff(1)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                             int(tau * samp_rate))
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                           int(tau * samp_rate))
        self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_mag_squared_2_1 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_mag_squared_2_0_0 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_mag_squared_2_0 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_mag_squared_2 = blocks.complex_to_mag_squared(1)
        self.blocks_add_xx_1_0 = blocks.add_vff(1)
        self.blocks_add_xx_1 = blocks.add_vff(1)
        self.blocks_add_xx_0_1 = blocks.add_vcc(1)
        self.blocks_add_xx_0_0_0 = blocks.add_vcc(1)
        self.blocks_add_xx_0_0 = blocks.add_vcc(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.audio_source_0 = audio.source(samp_rate, 'hw:CARD=Rubix44,DEV=0',
                                           False)
        self.audio_sink_0 = audio.sink(samp_rate, 'hw:CARD=Rubix44,DEV=0',
                                       False)
        self.analog_sig_source_x_3 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, 1000, 0.3, 0, 0)
        self.analog_sig_source_x_2_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 1850, 1, 0, 0)
        self.analog_sig_source_x_2 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 1850, 1, 0, 0)
        self.analog_sig_source_x_1_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, freqShift, 1, 0, 0)
        self.analog_sig_source_x_1 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, freqShift, 1, 0, 0)
        self.analog_sig_source_x_0_0_1 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -1850, 1, 0, 0)
        self.analog_sig_source_x_0_0_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 1850, 1, 0, 0)
        self.analog_sig_source_x_0_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 1850, 1, 0, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -1850, 1, 0, 0)
        self.analog_noise_source_x_1_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1e-0 * kN, 13)
        self.analog_noise_source_x_1 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1e-0 * kN, 3)
        self.analog_noise_source_x_0_1 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1, 10)
        self.analog_noise_source_x_0_0_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1, 11)
        self.analog_noise_source_x_0_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1, 1)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1, 0)
        self.analog_const_source_x_2_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_2 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_1_1 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, ampl[1][0])
        self.analog_const_source_x_1_0_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, ampl[1][1])
        self.analog_const_source_x_1_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, ampl[0][1])
        self.analog_const_source_x_1 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, ampl[0][0])
        self.analog_const_source_x_0_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.analog_const_source_x_0_0, 0),
                     (self.blocks_float_to_complex_0_0, 1))
        self.connect((self.analog_const_source_x_1, 0),
                     (self.blocks_selector_0, 1))
        self.connect((self.analog_const_source_x_1_0, 0),
                     (self.blocks_selector_0_0, 1))
        self.connect((self.analog_const_source_x_1_0_0, 0),
                     (self.blocks_selector_0_0_0, 1))
        self.connect((self.analog_const_source_x_1_1, 0),
                     (self.blocks_selector_0_1, 1))
        self.connect((self.analog_const_source_x_2, 0),
                     (self.blocks_float_to_complex_1, 1))
        self.connect((self.analog_const_source_x_2_0, 0),
                     (self.blocks_float_to_complex_1_0, 1))
        self.connect((self.analog_noise_source_x_0, 0), (self.epy_block_0, 0))
        self.connect((self.analog_noise_source_x_0_0, 0),
                     (self.epy_block_0_0, 0))
        self.connect((self.analog_noise_source_x_0_0_0, 0),
                     (self.epy_block_0_0_0_0, 0))
        self.connect((self.analog_noise_source_x_0_1, 0),
                     (self.epy_block_0_0_0, 0))
        self.connect((self.analog_noise_source_x_1, 0),
                     (self.low_pass_filter_2, 0))
        self.connect((self.analog_noise_source_x_1_0, 0),
                     (self.low_pass_filter_2_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_0_0_0, 0),
                     (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.analog_sig_source_x_0_0_0_0, 0),
                     (self.blocks_multiply_xx_0_0_1, 1))
        self.connect((self.analog_sig_source_x_0_0_1, 0),
                     (self.blocks_multiply_xx_0_1, 1))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.analog_sig_source_x_1_0, 0),
                     (self.blocks_multiply_xx_1_0, 0))
        self.connect((self.analog_sig_source_x_2, 0),
                     (self.blocks_multiply_xx_0_0_0_0_0, 1))
        self.connect((self.analog_sig_source_x_2_0, 0),
                     (self.blocks_multiply_xx_0_0_0_0_0_0, 1))
        self.connect((self.analog_sig_source_x_3, 0),
                     (self.blocks_multiply_const_vxx_3, 0))
        self.connect((self.analog_sig_source_x_3, 0),
                     (self.blocks_multiply_const_vxx_3_0, 0))
        self.connect((self.audio_source_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.audio_source_0, 1),
                     (self.blocks_float_to_complex_0_0, 0))
        self.connect((self.audio_source_0, 2), (self.blocks_null_sink_0, 0))
        self.connect((self.audio_source_0, 3), (self.blocks_null_sink_0, 1))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_add_xx_0_0, 0),
                     (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.blocks_add_xx_0_0_0, 0),
                     (self.blocks_multiply_const_vxx_2_0, 0))
        self.connect((self.blocks_add_xx_0_1, 0),
                     (self.blocks_multiply_xx_1_0, 1))
        self.connect((self.blocks_add_xx_1, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_add_xx_1_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_2, 0),
                     (self.single_pole_iir_filter_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_2_0, 0),
                     (self.single_pole_iir_filter_xx_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_2_0_0, 0),
                     (self.single_pole_iir_filter_xx_0_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_2_1, 0),
                     (self.single_pole_iir_filter_xx_0_1, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_add_xx_1, 0))
        self.connect((self.blocks_complex_to_real_0_0, 0),
                     (self.blocks_add_xx_1_0, 1))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_multiply_xx_0_0_0_0, 0))
        self.connect((self.blocks_delay_0_0, 0),
                     (self.blocks_multiply_xx_0_0_0_0_1, 0))
        self.connect((self.blocks_divide_xx_1, 0),
                     (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_divide_xx_1_0, 0),
                     (self.blocks_nlog10_ff_0_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_float_to_complex_0_0, 0),
                     (self.blocks_multiply_xx_0_1, 0))
        self.connect((self.blocks_float_to_complex_1, 0),
                     (self.blocks_multiply_xx_0_0_0_0_0, 2))
        self.connect((self.blocks_float_to_complex_1_0, 0),
                     (self.blocks_multiply_xx_0_0_0_0_0_0, 2))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_rms_xx_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.blocks_rms_xx_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_float_to_complex_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.blocks_float_to_complex_1_0, 0))
        self.connect((self.blocks_multiply_const_vxx_2, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_multiply_const_vxx_2_0, 0),
                     (self.blocks_complex_to_real_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_3, 0),
                     (self.blocks_add_xx_1, 1))
        self.connect((self.blocks_multiply_const_vxx_3_0, 0),
                     (self.blocks_add_xx_1_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.blocks_multiply_xx_0_0_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.blocks_rms_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0_0_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0_0_0_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_xx_0_0_0_0_0, 0),
                     (self.blocks_add_xx_0_0, 1))
        self.connect((self.blocks_multiply_xx_0_0_0_0_0, 0),
                     (self.blocks_complex_to_mag_squared_2_0, 0))
        self.connect((self.blocks_multiply_xx_0_0_0_0_0_0, 0),
                     (self.blocks_add_xx_0_0_0, 1))
        self.connect((self.blocks_multiply_xx_0_0_0_0_0_0, 0),
                     (self.blocks_complex_to_mag_squared_2_0_0, 0))
        self.connect((self.blocks_multiply_xx_0_0_0_0_1, 0),
                     (self.blocks_add_xx_0_1, 1))
        self.connect((self.blocks_multiply_xx_0_0_0_1, 0),
                     (self.blocks_add_xx_0_1, 0))
        self.connect((self.blocks_multiply_xx_0_0_1, 0),
                     (self.blocks_delay_0_0, 0))
        self.connect((self.blocks_multiply_xx_0_0_1, 0),
                     (self.blocks_multiply_xx_0_0_0_1, 0))
        self.connect((self.blocks_multiply_xx_0_0_1, 0),
                     (self.blocks_rms_xx_0_1, 0))
        self.connect((self.blocks_multiply_xx_0_1, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0),
                     (self.blocks_add_xx_0_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0),
                     (self.blocks_complex_to_mag_squared_2, 0))
        self.connect((self.blocks_multiply_xx_1_0, 0),
                     (self.blocks_add_xx_0_0_0, 0))
        self.connect((self.blocks_multiply_xx_1_0, 0),
                     (self.blocks_complex_to_mag_squared_2_1, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.blocks_streams_to_vector_0, 2))
        self.connect((self.blocks_nlog10_ff_0_0, 0),
                     (self.blocks_streams_to_vector_0, 3))
        self.connect((self.blocks_null_source_0, 0), (self.audio_sink_0, 2))
        self.connect((self.blocks_null_source_0, 1), (self.audio_sink_0, 3))
        self.connect((self.blocks_rms_xx_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_rms_xx_0_0, 0),
                     (self.blocks_streams_to_vector_0_0, 0))
        self.connect((self.blocks_rms_xx_0_0_0, 0),
                     (self.blocks_streams_to_vector_0_0, 1))
        self.connect((self.blocks_rms_xx_0_1, 0),
                     (self.blocks_multiply_const_vxx_1_0, 0))
        self.connect((self.blocks_selector_0, 0),
                     (self.blocks_multiply_xx_0_0_0, 1))
        self.connect((self.blocks_selector_0_0, 0),
                     (self.blocks_multiply_xx_0_0_0_0, 1))
        self.connect((self.blocks_selector_0_0_0, 0),
                     (self.blocks_multiply_xx_0_0_0_0_1, 1))
        self.connect((self.blocks_selector_0_1, 0),
                     (self.blocks_multiply_xx_0_0_0_1, 1))
        self.connect((self.blocks_streams_to_vector_0, 0), (self.snrOut, 0))
        self.connect((self.blocks_streams_to_vector_0_0, 0),
                     (self.outSigRMS, 0))
        self.connect((self.epy_block_0, 0), (self.low_pass_filter_1, 0))
        self.connect((self.epy_block_0_0, 0), (self.low_pass_filter_1_0, 0))
        self.connect((self.epy_block_0_0_0, 0), (self.low_pass_filter_1_1, 0))
        self.connect((self.epy_block_0_0_0_0, 0),
                     (self.low_pass_filter_1_0_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_multiply_xx_0_0_1, 0))
        self.connect((self.low_pass_filter_1, 0), (self.blocks_selector_0, 0))
        self.connect((self.low_pass_filter_1_0, 0),
                     (self.blocks_selector_0_0, 0))
        self.connect((self.low_pass_filter_1_0_0, 0),
                     (self.blocks_selector_0_0_0, 0))
        self.connect((self.low_pass_filter_1_1, 0),
                     (self.blocks_selector_0_1, 0))
        self.connect((self.low_pass_filter_2, 0),
                     (self.blocks_multiply_xx_0_0_0_0_0, 0))
        self.connect((self.low_pass_filter_2_0, 0),
                     (self.blocks_multiply_xx_0_0_0_0_0_0, 0))
        self.connect((self.single_pole_iir_filter_xx_0, 0),
                     (self.blocks_divide_xx_1, 0))
        self.connect((self.single_pole_iir_filter_xx_0, 0),
                     (self.blocks_streams_to_vector_0, 0))
        self.connect((self.single_pole_iir_filter_xx_0_0, 0),
                     (self.blocks_divide_xx_1, 1))
        self.connect((self.single_pole_iir_filter_xx_0_0, 0),
                     (self.blocks_streams_to_vector_0, 1))
        self.connect((self.single_pole_iir_filter_xx_0_0_0, 0),
                     (self.blocks_divide_xx_1_0, 1))
        self.connect((self.single_pole_iir_filter_xx_0_1, 0),
                     (self.blocks_divide_xx_1_0, 0))
    def __init__(self):
        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())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 300e3

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0_1_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_1_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0_1_0.disable_legend()

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

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

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

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

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

        if not True:
            self.qtgui_time_sink_x_0_1.disable_legend()

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

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

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

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

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.iir_filter_xxx_0 = filter.iir_filter_ffd((1.0 / samp_rate, ),
                                                      ([1, 1]), True)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 10000, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, 1000, 1, 0)
        self.analog_phase_modulator_fc_0 = analog.phase_modulator_fc(2 * 3.14 *
                                                                     5000)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_phase_modulator_fc_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.iir_filter_xxx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.qtgui_time_sink_x_0_1, 0))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.qtgui_time_sink_x_0_1_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.iir_filter_xxx_0, 0),
                     (self.analog_phase_modulator_fc_0, 0))
示例#32
0
    def __init__(self):
        gr.top_block.__init__(self, "Prototype Jr")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Prototype Jr")
        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 = 2400000
        self.gain_1 = gain_1 = 10
        self.gain_0 = gain_0 = 10

        ##################################################
        # Blocks
        ##################################################
        self._gain_1_range = Range(0, 30, 1, 10, 200)
        self._gain_1_win = RangeWidget(self._gain_1_range, self.set_gain_1,
                                       'gain_1', "counter_slider", float)
        self.top_grid_layout.addWidget(self._gain_1_win)
        self._gain_0_range = Range(0, 30, 1, 10, 200)
        self._gain_0_win = RangeWidget(self._gain_0_range, self.set_gain_0,
                                       'gain_0', "counter_slider", float)
        self.top_grid_layout.addWidget(self._gain_0_win)
        self.rtlsdr_source_1 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              'rtl=1')
        self.rtlsdr_source_1.set_time_unknown_pps(osmosdr.time_spec_t())
        self.rtlsdr_source_1.set_sample_rate(samp_rate)
        self.rtlsdr_source_1.set_center_freq(560000000, 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(gain_1, 0)
        self.rtlsdr_source_1.set_if_gain(20, 0)
        self.rtlsdr_source_1.set_bb_gain(20, 0)
        self.rtlsdr_source_1.set_antenna('1', 0)
        self.rtlsdr_source_1.set_bandwidth(0, 0)
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              'rtl=0')
        self.rtlsdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(560000000, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(gain_0, 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', 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
        self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f(
            1024, 100, -1, 1, "", 2)

        self.qtgui_histogram_sink_x_0.set_update_time(0.10)
        self.qtgui_histogram_sink_x_0.enable_autoscale(True)
        self.qtgui_histogram_sink_x_0.enable_accumulate(False)
        self.qtgui_histogram_sink_x_0.enable_grid(False)
        self.qtgui_histogram_sink_x_0.enable_axis_labels(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"
        ]
        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 range(2):
            if len(labels[i]) == 0:
                self.qtgui_histogram_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_histogram_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_histogram_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_histogram_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_histogram_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_histogram_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_histogram_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_histogram_sink_x_0_win = sip.wrapinstance(
            self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_histogram_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_HAMMING,  #wintype
            560000000,  #fc
            samp_rate,  #bw
            "",  #name
            2)
        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(True)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc(128)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(128)
        self.blocks_file_sink_1 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/pi/Downloads/output1', False)
        self.blocks_file_sink_1.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/pi/Downloads/output2', False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_real_1 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_interleaved_char_1 = blocks.complex_to_interleaved_char(
            False)
        self.blocks_complex_to_interleaved_char_0 = blocks.complex_to_interleaved_char(
            False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_interleaved_char_0, 0),
                     (self.blocks_file_sink_1, 0))
        self.connect((self.blocks_complex_to_interleaved_char_1, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.qtgui_histogram_sink_x_0, 0))
        self.connect((self.blocks_complex_to_real_1, 0),
                     (self.qtgui_histogram_sink_x_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_complex_to_interleaved_char_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_complex_to_interleaved_char_1, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.rtlsdr_source_1, 0),
                     (self.blocks_complex_to_real_1, 0))
        self.connect((self.rtlsdr_source_1, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.rtlsdr_source_1, 0), (self.qtgui_freq_sink_x_0, 1))
示例#33
0
    def __init__(self,
                 bfo=1500,
                 callsign='',
                 ip='::',
                 latitude=0,
                 longitude=0,
                 port=7355,
                 recstart=''):
        gr.top_block.__init__(self, "Nayif-1 decoder")

        ##################################################
        # Parameters
        ##################################################
        self.bfo = bfo
        self.callsign = callsign
        self.ip = ip
        self.latitude = latitude
        self.longitude = longitude
        self.port = port
        self.recstart = recstart

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 8
        self.nfilts = nfilts = 16
        self.alpha = alpha = 0.35

        self.variable_constellation_0_0 = variable_constellation_0_0 = digital.constellation_calcdist(
            ([-1, 1]), ([0, 1]), 2, 1).base()

        self.samp_rate = samp_rate = 48000
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), alpha, 11 * sps * nfilts)

        ##################################################
        # Blocks
        ##################################################
        self.sids_submit_0 = sids.submit(
            'http://tlm.pe0sat.nl/tlmdb/frame_db.php', 42017, callsign,
            longitude, latitude, recstart)
        self.sids_print_timestamp_0 = sids.print_timestamp('%Y-%m-%d %H:%M:%S')
        self.funcube_telemetry_parser_0 = ao40.funcube_telemetry_parser()
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_fcf(
            5, (firdes.low_pass(1, samp_rate, 1300, 500)), bfo, samp_rate)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, 0.1, (rrc_taps), nfilts, nfilts / 2, 0.05, 1)
        self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(
            sps, 0.350, 100, 0.01)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_short * 1, ip,
                                                     port, 1472, False)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 32767)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((-1, ))
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(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.ao40_fec_decoder_0 = ao40_fec_decoder()
        self.analog_feedforward_agc_cc_0 = analog.feedforward_agc_cc(1024, 2)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ao40_fec_decoder_0, 'out'),
                         (self.sids_print_timestamp_0, 'in'))
        self.msg_connect((self.ao40_fec_decoder_0, 'out'),
                         (self.sids_submit_0, 'in'))
        self.msg_connect((self.sids_print_timestamp_0, 'out'),
                         (self.funcube_telemetry_parser_0, 'in'))
        self.connect((self.analog_feedforward_agc_cc_0, 0),
                     (self.digital_fll_band_edge_cc_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_multiply_conjugate_cc_0, 1))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.blocks_udp_source_0, 0),
                     (self.blocks_short_to_float_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.ao40_fec_decoder_0, 0))
        self.connect((self.digital_fll_band_edge_cc_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_multiply_conjugate_cc_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_feedforward_agc_cc_0, 0))
示例#34
0
    def __init__(self,
                 amplitude_calibration1=1,
                 amplitude_calibration2=1,
                 ch_rx1=1,
                 ch_rx2=2,
                 ch_tx=1,
                 duration=250000,
                 rx_ip1='192.168.5.100',
                 rx_ip2='192.168.5.100',
                 samp_rate=250000,
                 sig_in='./in.dat',
                 sig_out1='./out1.dat',
                 sig_out2='./out2.dat',
                 tx_ip='192.168.5.100'):
        gr.top_block.__init__(self, "Gr Baseband Async Oii")

        ##################################################
        # Parameters
        ##################################################
        self.amplitude_calibration1 = amplitude_calibration1
        self.amplitude_calibration2 = amplitude_calibration2
        self.ch_rx1 = ch_rx1
        self.ch_rx2 = ch_rx2
        self.ch_tx = ch_tx
        self.duration = duration
        self.rx_ip1 = rx_ip1
        self.rx_ip2 = rx_ip2
        self.samp_rate = samp_rate
        self.sig_in = sig_in
        self.sig_out1 = sig_out1
        self.sig_out2 = sig_out2
        self.tx_ip = tx_ip

        ##################################################
        # Blocks
        ##################################################
        self.red_pitaya_source_0_0 = red_pitaya.source(addr=rx_ip2,
                                                       port=1000 + ch_rx2,
                                                       freq=0,
                                                       rate=samp_rate,
                                                       corr=0)

        self.red_pitaya_source_0 = red_pitaya.source(addr=rx_ip1,
                                                     port=1000 + ch_rx1,
                                                     freq=0,
                                                     rate=samp_rate,
                                                     corr=0)

        self.red_pitaya_sink = red_pitaya.sink(addr=tx_ip,
                                               port=1000 + ch_tx,
                                               freq=0,
                                               rate=samp_rate,
                                               corr=0,
                                               ptt=True)

        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc(
            (amplitude_calibration2, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(
            (amplitude_calibration1, ))
        self.blocks_head_0_1 = blocks.head(gr.sizeof_gr_complex * 1, duration)
        self.blocks_head_0_0 = blocks.head(gr.sizeof_float * 1, duration)
        self.blocks_head_0 = blocks.head(gr.sizeof_float * 1, duration)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_float * 1,
                                                       sig_in, False)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_float * 1,
                                                     sig_out2, False)
        self.blocks_file_sink_0_0.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float * 1,
                                                   sig_out1, False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_head_0, 0))
        self.connect((self.blocks_complex_to_real_0_0, 0),
                     (self.blocks_head_0_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_head_0_1, 0))
        self.connect((self.blocks_head_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_head_0_0, 0), (self.blocks_file_sink_0_0, 0))
        self.connect((self.blocks_head_0_1, 0), (self.red_pitaya_sink, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.blocks_complex_to_real_0_0, 0))
        self.connect((self.red_pitaya_source_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.red_pitaya_source_0_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
示例#35
0
文件: PSK.py 项目: oxovu/telecom
    def __init__(self):
        gr.top_block.__init__(self, "Psk")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Psk")
        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", "PSK")

        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.update_per = update_per = 0.5
        self.samp_rate = samp_rate = 320e3

        ##################################################
        # Blocks
        ##################################################
        self.digital_psk_mod_0 = digital.psk.psk_mod(
            constellation_points=8,
            mod_code="gray",
            differential=True,
            samples_per_symbol=2,
            excess_bw=350e-3,
            verbose=False,
            log=False,
        )
        self.c_qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.c_qtgui_time_sink_x_0.set_update_time(update_per)
        self.c_qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.c_qtgui_time_sink_x_0.disable_legend()

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

        self._c_qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.c_qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._c_qtgui_time_sink_x_0_win)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.b_qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.b_qtgui_waterfall_sink_x_0.set_update_time(update_per / 4)
        self.b_qtgui_waterfall_sink_x_0.enable_grid(False)
        self.b_qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
            self.b_qtgui_waterfall_sink_x_0.disable_legend()

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

        self.b_qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)

        self._b_qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.b_qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._b_qtgui_waterfall_sink_x_0_win)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 2, 1000)), True)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 0.00025, 0)
        self.a_qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024,  #size
            "",  #name
            1  #number of inputs
        )
        self.a_qtgui_const_sink_x_0.set_update_time(update_per)
        self.a_qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.a_qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.a_qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                     qtgui.TRIG_SLOPE_POS, 0.0,
                                                     0, "")
        self.a_qtgui_const_sink_x_0.enable_autoscale(False)
        self.a_qtgui_const_sink_x_0.enable_grid(False)
        self.a_qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
            self.a_qtgui_const_sink_x_0.disable_legend()

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

        self._a_qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.a_qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._a_qtgui_const_sink_x_0_win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.digital_psk_mod_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.c_qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.a_qtgui_const_sink_x_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.b_qtgui_waterfall_sink_x_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.digital_psk_mod_0, 0), (self.blocks_add_xx_0, 0))
示例#36
0
    def __init__(self, sr, bw):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        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.samp_rate = samp_rate = sr
        self.freq = freq = 2400e6
        self.bandwidth = bandwidth = bw

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

        self.qtgui_sink_x_0.enable_rf_freq(False)

        self.osmosdr_source_1 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "bladerf=179")
        self.osmosdr_source_1.set_sample_rate(samp_rate)
        self.osmosdr_source_1.set_center_freq(freq, 0)
        self.osmosdr_source_1.set_freq_corr(0, 0)
        self.osmosdr_source_1.set_dc_offset_mode(0, 0)
        self.osmosdr_source_1.set_iq_balance_mode(0, 0)
        self.osmosdr_source_1.set_gain_mode(True, 0)
        self.osmosdr_source_1.set_gain(25, 0)
        self.osmosdr_source_1.set_if_gain(0, 0)
        self.osmosdr_source_1.set_bb_gain(0, 0)
        self.osmosdr_source_1.set_antenna('RX', 0)
        self.osmosdr_source_1.set_bandwidth(bandwidth, 0)

        self.correctiq_correctiq_0 = correctiq.correctiq()
        self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_float * 1,
                                                       '/dev/shm/dataI.dat',
                                                       False)
        self.blocks_file_sink_0_0_0.set_unbuffered(True)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_float * 1,
                                                     '/dev/shm/dataR.dat',
                                                     False)
        self.blocks_file_sink_0_0.set_unbuffered(True)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.blocks_file_sink_0_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_file_sink_0_0, 0))
        self.connect((self.correctiq_correctiq_0, 0),
                     (self.blocks_complex_to_imag_0, 0))
        self.connect((self.correctiq_correctiq_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.correctiq_correctiq_0, 0), (self.qtgui_sink_x_0, 0))
        self.connect((self.osmosdr_source_1, 0),
                     (self.correctiq_correctiq_0, 0))
示例#37
0
    def __init__(self, fsk_dev=10000, lpf_cutoff=10e3, lpf_trans=1e3):
        gr.top_block.__init__(self, "Afsk Test")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Afsk Test")
        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", "afsk_test")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Parameters
        ##################################################
        self.fsk_dev = fsk_dev
        self.lpf_cutoff = lpf_cutoff
        self.lpf_trans = lpf_trans

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 48000
        self.baud = baud = 1200
        self.samps_per_symb = samps_per_symb = int(samp_rate/baud)
        self.noise_amp = noise_amp = 0.3
        self.mult = mult = (samp_rate)/2/3.141593
        self.decim = decim = 2
        self.bb_gain = bb_gain = .75
        self.alpha = alpha = 0.5

        ##################################################
        # Blocks
        ##################################################
        self._noise_amp_range = Range(0, 1, 0.005, 0.3, 200)
        self._noise_amp_win = RangeWidget(self._noise_amp_range, self.set_noise_amp, "noise_amp", "counter_slider", float)
        self.top_grid_layout.addWidget(self._noise_amp_win, 6,0,1,4)
        self._bb_gain_range = Range(0, 1, .01, .75, 200)
        self._bb_gain_win = RangeWidget(self._bb_gain_range, self.set_bb_gain, 'bb_gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._bb_gain_win, 5,0,1,4)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=decim,
                taps=None,
                fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_f(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        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 "float" == "float" or "float" == "msg_float":
          self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not False)

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

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)

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

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

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

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

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

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

        if not True:
          self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 4,4,3,4)
        self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate/decim, #bw
        	"RX Spectrum", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_1_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_1_0.set_y_axis(-80, 10)
        self.qtgui_freq_sink_x_1_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_1_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_1_0.enable_grid(True)
        self.qtgui_freq_sink_x_1_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_1_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_1_0.enable_control_panel(False)

        if not False:
          self.qtgui_freq_sink_x_1_0.disable_legend()

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

        self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_0_win, 0,4,4,4)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"TX Spectrum", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_1.set_update_time(0.10)
        self.qtgui_freq_sink_x_1.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_1.enable_autoscale(True)
        self.qtgui_freq_sink_x_1.enable_grid(True)
        self.qtgui_freq_sink_x_1.set_fft_average(1.0)
        self.qtgui_freq_sink_x_1.enable_axis_labels(True)
        self.qtgui_freq_sink_x_1.enable_control_panel(False)

        if not False:
          self.qtgui_freq_sink_x_1.disable_legend()

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

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

        self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 0,0,4,4)
        self.pyqt_text_output_0 = pyqt.text_output()
        self._pyqt_text_output_0_win = self.pyqt_text_output_0;
        self.top_layout.addWidget(self._pyqt_text_output_0_win)
        self.pyqt_text_input_0 = pyqt.text_input()
        self._pyqt_text_input_0_win = self.pyqt_text_input_0;
        self.top_grid_layout.addWidget(self._pyqt_text_input_0_win, 4,0,1,4)
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate/decim, lpf_cutoff, lpf_trans, firdes.WIN_HAMMING, 6.76))
        self.kiss_nrzi_encode_0 = kiss.nrzi_encode()
        self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=64, postamble_bytes=16)
        self.kiss_hdlc_deframer_0 = kiss.hdlc_deframer(check_fcs=True, max_length=300)
        self.digital_gfsk_mod_0 = digital.gfsk_mod(
        	samples_per_symbol=samps_per_symb,
        	sensitivity=0.06,
        	bt=1,
        	verbose=False,
        	log=False,
        )
        self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(samps_per_symb*(1+0.0)/decim, 0.25*0.175*0.175, 0.25, 0.175, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False)
        self.blocks_tag_gate_0.set_single_key("packet_len")
        self.blocks_socket_pdu_0_2 = blocks.socket_pdu("UDP_SERVER", '0.0.0.0', '52002', 1024, False)
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((bb_gain, ))
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_add_xx_1 = blocks.add_vcc(1)
        self.audio_sink_0 = audio.sink(samp_rate, '', True)
        self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1700, 1, 0)
        self.analog_quadrature_demod_cf_1 = analog.quadrature_demod_cf((samp_rate/decim)/(2*math.pi*fsk_dev/8.0))
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
        	audio_rate=samp_rate,
        	quad_rate=samp_rate,
        	tau=75e-6,
        	max_dev=5e3,
        	fh=-1.0,
                )
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, noise_amp, 0, 8192)
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0_2, 'pdus'), (self.kiss_hdlc_framer_0, 'in'))
        self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.blocks_socket_pdu_0_2, 'pdus'))
        self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.pyqt_text_output_0, 'pdus'))
        self.msg_connect((self.kiss_hdlc_framer_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.msg_connect((self.pyqt_text_input_0, 'pdus'), (self.kiss_hdlc_framer_0, 'in'))
        self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_1, 0))
        self.connect((self.analog_nbfm_tx_0, 0), (self.blocks_add_xx_1, 1))
        self.connect((self.analog_quadrature_demod_cf_1, 0), (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_1, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_add_xx_1, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_time_sink_x_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.analog_nbfm_tx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_gfsk_mod_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.kiss_nrzi_encode_0, 0))
        self.connect((self.blocks_tag_gate_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_descrambler_bb_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_descrambler_bb_0, 0), (self.kiss_hdlc_deframer_0, 0))
        self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_tag_gate_0, 0))
        self.connect((self.kiss_nrzi_encode_0, 0), (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_1, 0))
        self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_1_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0))
示例#38
0
    def __init__(self):
        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())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 8
        self.nfilts = nfilts = 128
        self.timing_loop_bandwidth = timing_loop_bandwidth = .063
        self.samp_rate = samp_rate = 1000000
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), 0.35, 45 * nfilts)
        self.noise_voltage = noise_voltage = .063
        self.freq_offset = freq_offset = 0
        self.code2 = code2 = '11011010110111011000110011110101100010010011110111'
        self.code1 = code1 = '010110011011101100010101011111101001001110001011010001101010001'

        self.BPSK = BPSK = digital.constellation_calcdist(([-1, 1]), ([0, 1]),
                                                          4, 1).base()

        ##################################################
        # Blocks
        ##################################################
        self._timing_loop_bandwidth_range = Range(.001, .2, .001, .063, 200)
        self._timing_loop_bandwidth_win = RangeWidget(
            self._timing_loop_bandwidth_range, self.set_timing_loop_bandwidth,
            "timing_loop_bandwidth", "counter_slider", float)
        self.top_grid_layout.addWidget(self._timing_loop_bandwidth_win, 0, 0,
                                       1, 1)
        self._noise_voltage_range = Range(0.0, 1, .001, .063, 200)
        self._noise_voltage_win = RangeWidget(self._noise_voltage_range,
                                              self.set_noise_voltage,
                                              "noise_voltage",
                                              "counter_slider", float)
        self.top_grid_layout.addWidget(self._noise_voltage_win, 0, 1, 1, 1)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c(
            15,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0_0.disable_legend()

        labels = [
            'Real part', 'Imaginary Part', '', '', '', '', '', '', '', ''
        ]
        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 = [0, 0, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [0, 0, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

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

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 1, 1,
                                       1, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            15,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['Binary output (1 or 0)', '', '', '', '', '', '', '', '', '']
        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 = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [0, -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.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(True)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0.disable_legend()

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

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 1, 0, 1,
                                       1)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, timing_loop_bandwidth, (rrc_taps), nfilts, nfilts / 2, 1.5, 1)
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=BPSK,
            differential=False,
            samples_per_symbol=sps,
            pre_diff_code=True,
            excess_bw=0.35,
            verbose=False,
            log=False,
        )
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf(
            (0, 1), 1)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=noise_voltage,
            frequency_offset=freq_offset / samp_rate,
            epsilon=1.0,
            taps=(1, ),
            noise_seed=0,
            block_tags=False)
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_char * 1,
                                                   samp_rate, True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate,
                                                 True)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 1)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1,
            '/Users/ampoulog/Documents/gnuradio/Wireless-communication-systems-Lab/Lab3/example6/cat.png',
            True)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/Users/ampoulog/Documents/gnuradio/Wireless-communication-systems-Lab/Lab3/example8/hello_out.png',
            False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blks2_packet_encoder_0_0 = grc_blks2.packet_mod_b(
            grc_blks2.packet_encoder(
                samples_per_symbol=1,
                bits_per_symbol=1,
                preamble='',
                access_code=code2,
                pad_for_usrp=False,
            ),
            payload_length=4,
        )
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(
            grc_blks2.packet_decoder(
                access_code=code2,
                threshold=-1,
                callback=lambda ok, payload: self.blks2_packet_decoder_0.
                recv_pkt(ok, payload),
            ), )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_packet_decoder_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blks2_packet_encoder_0_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_float_to_char_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blks2_packet_encoder_0_0, 0))
        self.connect((self.blocks_throttle_0_0, 0),
                     (self.digital_constellation_modulator_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0),
                     (self.blocks_throttle_0_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_float_to_char_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blks2_packet_decoder_0, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0),
                     (self.blocks_unpacked_to_packed_xx_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.qtgui_const_sink_x_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
示例#39
0
    def __init__(self,
                 ch_port=1,
                 duration=250000,
                 rx_ip='192.168.5.101',
                 samp_rate=250000,
                 sig_in='./in.dat',
                 sig_out='./out.dat',
                 tx_ip='192.168.5.101'):
        gr.top_block.__init__(self, "gr_sandbox")

        ##################################################
        # Parameters
        ##################################################
        self.ch_port = ch_port
        self.duration = duration
        self.rx_ip = rx_ip
        self.samp_rate = samp_rate
        self.sig_in = sig_in
        self.sig_out = sig_out
        self.tx_ip = tx_ip

        ##################################################
        # Blocks
        ##################################################
        self.red_pitaya_source_0 = red_pitaya.source(addr=rx_ip,
                                                     port=1000 + ch_port,
                                                     freq=0,
                                                     rate=samp_rate,
                                                     corr=0)

        self.red_pitaya_sink_0 = red_pitaya.sink(addr=tx_ip,
                                                 port=1000 + ch_port,
                                                 freq=0,
                                                 rate=samp_rate,
                                                 corr=0,
                                                 ptt=True)

        self.blocks_head_0 = blocks.head(gr.sizeof_float * 1, duration)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_float * 1,
                                                       sig_in, False)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float * 1,
                                                   sig_out, False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_head_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.red_pitaya_sink_0, 0))
        self.connect((self.blocks_head_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.red_pitaya_source_0, 0),
                     (self.blocks_complex_to_real_0, 0))
示例#40
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Ud T")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.transistion = transistion = 100
        self.sps = sps = 9
        self.sideband_rx = sideband_rx = 1000
        self.sideband = sideband = 1000
        self.samp_rate = samp_rate = 48000
        self.payload = payload = 5
        self.interpolation = interpolation = 500
        self.carrier = carrier = 23000

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_fftsink2_0_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,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0_0.win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=500,
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (firdes.band_pass (0.50,samp_rate,carrier-sideband,carrier+sideband,transistion)), -carrier, samp_rate)
        self.digital_gfsk_mod_0 = digital.gfsk_mod(
        	samples_per_symbol=sps,
        	sensitivity=1.0,
        	bt=0.35,
        	verbose=False,
        	log=False,
        )
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blks2_tcp_source_0 = grc_blks2.tcp_source(
        	itemsize=gr.sizeof_char*1,
        	addr="127.0.0.1",
        	port=10004,
        	server=True,
        )
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder(
        		samples_per_symbol=sps,
        		bits_per_symbol=1,
        		preamble="",
        		access_code="",
        		pad_for_usrp=False,
        	),
        	payload_length=payload,
        )
        self.audio_sink_0 = audio.sink(48000, "", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gfsk_mod_0, 0))
        self.connect((self.blks2_tcp_source_0, 0), (self.blks2_packet_encoder_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.audio_sink_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0_0, 0))
        self.connect((self.digital_gfsk_mod_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
示例#41
0
    def __init__(self,
                 parameter_0="addr=192.168.10.2",
                 parameter_1="addr=192.168.10.3"):
        gr.top_block.__init__(self, "BPSK_radios")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("BPSK_radios")
        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", "BPSK_radios")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.parameter_0 = parameter_0
        self.parameter_1 = parameter_1

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.variable_qtgui_range_0 = variable_qtgui_range_0 = 630e-3
        self.samp_rate = samp_rate = 32000
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), 0.35, 45 * nfilts)
        self.freq = freq = 2e9
        self.bw = bw = 5e6
        self.Tx_Gain = Tx_Gain = 3
        self.Rx_Gain = Rx_Gain = 30

        ##################################################
        # Blocks
        ##################################################
        self.vocoder_alaw_encode_sb_0 = vocoder.alaw_encode_sb()
        self.vocoder_alaw_decode_bs_0 = vocoder.alaw_decode_bs()
        self._variable_qtgui_range_0_range = Range(0, 1, 1, 630e-3, 200)
        self._variable_qtgui_range_0_win = RangeWidget(
            self._variable_qtgui_range_0_range,
            self.set_variable_qtgui_range_0, "variable_qtgui_range_0",
            "counter_slider", float)
        self.top_layout.addWidget(self._variable_qtgui_range_0_win)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("addr=192.168.10.3", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate * 10)
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_center_freq(freq, 0)
        self.uhd_usrp_source_0.set_gain(Rx_Gain, 0)
        self.uhd_usrp_source_0.set_antenna("TX/RX", 0)
        self.uhd_usrp_source_0.set_bandwidth(bw / 5, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("addr=192.168.10.2", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate * 10)
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()),
                                          uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_center_freq(freq, 0)
        self.uhd_usrp_sink_0.set_gain(Tx_Gain, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        self.uhd_usrp_sink_0.set_bandwidth(bw / 5, 0)
        self.qtgui_sink_x_1 = qtgui.sink_f(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            freq,  #fc
            samp_rate,  #bw
            "Recieved signal",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_1.set_update_time(1.0 / 5)
        self._qtgui_sink_x_1_win = sip.wrapinstance(
            self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_1_win)

        self.qtgui_sink_x_1.enable_rf_freq(False)

        self.qtgui_sink_x_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_KAISER,  #wintype
            freq,  #fc
            samp_rate,  #bw
            "Modulator output",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_win)

        self.qtgui_sink_x_0.enable_rf_freq(True)

        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("BER")

        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.interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff(
            8, (filter.firdes.root_raised_cosine(8, 8, 1.0, 0.5, 22)))
        self.interp_fir_filter_xxx_0.declare_sample_delay(0)
        self.fec_ber_bf_0 = fec.ber_bf(False, 100, -7.0)
        self.digital_simple_framer_0 = digital.simple_framer(20)
        self.digital_simple_correlator_0 = digital.simple_correlator(20)
        self.digital_psk_mod_0 = digital.psk.psk_mod(
            constellation_points=2,
            mod_code="gray",
            differential=False,
            samples_per_symbol=4,
            excess_bw=0.35,
            verbose=False,
            log=False,
        )
        self.digital_psk_demod_0 = digital.psk.psk_demod(
            constellation_points=2,
            differential=False,
            samples_per_symbol=4,
            excess_bw=0.35,
            phase_bw=6.28 / 100.0,
            timing_bw=6.28 / 100.0,
            mod_code="gray",
            verbose=False,
            log=False,
        )
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            "/home/ettus/Música/bensound-photoalbum.wav", True)
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink(
            "testBPSK_sonido.wav", 1, 44100, 16)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 1)
        self.blocks_multiply_const_vxx_4 = blocks.multiply_const_vcc((2, ))
        self.blocks_multiply_const_vxx_3 = blocks.multiply_const_vff(
            (30.5176e-6, ))
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((2, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc(
            (630e-3, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (32.768e3, ))
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, ))
        self.audio_sink_0 = audio.sink(44100, "", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.interp_fir_filter_xxx_0, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.qtgui_sink_x_1, 0))
        self.connect((self.blocks_float_to_short_0, 0),
                     (self.vocoder_alaw_encode_sb_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_float_to_short_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.qtgui_sink_x_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_2, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_3, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_3, 0),
                     (self.blocks_wavfile_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_4, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_multiply_const_vxx_4, 0),
                     (self.digital_psk_demod_0, 0))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.blocks_multiply_const_vxx_3, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.digital_psk_demod_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.digital_psk_demod_0, 0), (self.fec_ber_bf_0, 1))
        self.connect((self.digital_psk_mod_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.digital_simple_correlator_0, 0),
                     (self.vocoder_alaw_decode_bs_0, 0))
        self.connect((self.digital_simple_framer_0, 0),
                     (self.digital_psk_mod_0, 0))
        self.connect((self.digital_simple_framer_0, 0), (self.fec_ber_bf_0, 0))
        self.connect((self.fec_ber_bf_0, 0), (self.qtgui_number_sink_0, 0))
        self.connect((self.interp_fir_filter_xxx_0, 0),
                     (self.digital_simple_correlator_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.blocks_multiply_const_vxx_4, 0))
        self.connect((self.vocoder_alaw_decode_bs_0, 0),
                     (self.blocks_short_to_float_0, 0))
        self.connect((self.vocoder_alaw_encode_sb_0, 0),
                     (self.digital_simple_framer_0, 0))
示例#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.samp_rate = samp_rate = 960000

        ##################################################
        # Blocks
        ##################################################
        self.lab2_part4 = self.lab2_part4 = wx.Notebook(self.GetWin(),
                                                        style=wx.NB_TOP)
        self.lab2_part4.AddPage(grc_wxgui.Panel(self.lab2_part4), "scope")
        self.lab2_part4.AddPage(grc_wxgui.Panel(self.lab2_part4), "fft")
        self.Add(self.lab2_part4)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.lab2_part4.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.lab2_part4.GetPage(0).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_f(
            self.lab2_part4.GetPage(1).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.lab2_part4.GetPage(1).Add(self.wxgui_fftsink2_0.win)
        self.iir_filter_ffd_0 = filter.iir_filter_ffd((1 / 960e3, ), (1, 1),
                                                      True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
                                                 samp_rate)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_sig_source_x_1 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 100000, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, 10000, 1, 0)
        self.analog_phase_modulator_fc_0 = analog.phase_modulator_fc(471000)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.analog_phase_modulator_fc_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.iir_filter_ffd_0, 0),
                     (self.analog_phase_modulator_fc_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.iir_filter_ffd_0, 0))
示例#43
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        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.sps = sps = 45
        self.nfilts = nfilts = 25
        self.samp_rate = samp_rate = 44.1E3
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), 0.35, 45 * nfilts)
        self.fc_slider = fc_slider = 2200

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

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0_0_0.disable_legend()

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

        self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_0_win)
        self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c(
            1024,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                     qtgui.TRIG_SLOPE_POS, 0.0,
                                                     0, "")
        self.qtgui_const_sink_x_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0.enable_grid(True)
        self.qtgui_const_sink_x_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0.disable_legend()

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

        self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_0_win)
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 1.6E3, .6E3, firdes.WIN_HAMMING,
                            6.76))
        self._fc_slider_range = Range(0, 18200, 200, 2200, 150)
        self._fc_slider_win = RangeWidget(self._fc_slider_range,
                                          self.set_fc_slider, 'fc',
                                          "counter_slider", float)
        self.top_layout.addWidget(self._fc_slider_win)
        self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf(
            sps, .063, (rrc_taps), nfilts, nfilts / 2, 1.5, 1)
        self.digital_lms_dd_equalizer_cc_0_0 = digital.lms_dd_equalizer_cc(
            8, .01, 1, BPSK)
        self.digital_diff_decoder_bb_0_0 = digital.diff_decoder_bb(2)
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(.05, 2, False)
        self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb()
        self.blocks_multiply_xx_0_0_0 = blocks.multiply_vcc(1)
        self.blocks_float_to_complex_0_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1)
        self.blks2_tcp_sink_0_0 = grc_blks2.tcp_sink(
            itemsize=gr.sizeof_char * 1,
            addr='127.0.0.1',
            port=4321,
            server=True,
        )
        self.blks2_packet_decoder_0_0 = grc_blks2.packet_demod_b(
            grc_blks2.packet_decoder(
                access_code='',
                threshold=-1,
                callback=lambda ok, payload: self.blks2_packet_decoder_0_0.
                recv_pkt(ok, payload),
            ), )
        self.audio_source_0_0 = audio.source(44100, '', True)
        self.analog_sig_source_x_0_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -4E3, 1, 0)
        self.analog_feedforward_agc_cc_0_0 = analog.feedforward_agc_cc(
            1024, 1.55)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_feedforward_agc_cc_0_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0_0, 0))
        self.connect((self.analog_sig_source_x_0_0_0, 0),
                     (self.blocks_multiply_xx_0_0_0, 1))
        self.connect((self.audio_source_0_0, 0),
                     (self.blocks_float_to_complex_0_0, 0))
        self.connect((self.audio_source_0_0, 0),
                     (self.qtgui_time_sink_x_0_0_0, 0))
        self.connect((self.blks2_packet_decoder_0_0, 0),
                     (self.blks2_tcp_sink_0_0, 0))
        self.connect((self.blocks_complex_to_real_0_0, 0),
                     (self.digital_binary_slicer_fb_0_0, 0))
        self.connect((self.blocks_float_to_complex_0_0, 0),
                     (self.blocks_multiply_xx_0_0_0, 0))
        self.connect((self.blocks_multiply_xx_0_0_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.digital_binary_slicer_fb_0_0, 0),
                     (self.digital_diff_decoder_bb_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.digital_lms_dd_equalizer_cc_0_0, 0))
        self.connect((self.digital_diff_decoder_bb_0_0, 0),
                     (self.blks2_packet_decoder_0_0, 0))
        self.connect((self.digital_lms_dd_equalizer_cc_0_0, 0),
                     (self.blocks_complex_to_real_0_0, 0))
        self.connect((self.digital_lms_dd_equalizer_cc_0_0, 0),
                     (self.qtgui_const_sink_x_0_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0),
                     (self.digital_costas_loop_cc_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.analog_feedforward_agc_cc_0_0, 0))
示例#44
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        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.sps = sps = 45
        self.nfilts = nfilts = 25
        self.samp_rate = samp_rate = 44.1E3
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), 0.35, 45 * nfilts)
        self.fc_slider = fc_slider = 2200

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

        ##################################################
        # Blocks
        ##################################################
        self._fc_slider_range = Range(0, 18200, 200, 2200, 150)
        self._fc_slider_win = RangeWidget(self._fc_slider_range,
                                          self.set_fc_slider, 'fc',
                                          "counter_slider", float)
        self.top_layout.addWidget(self._fc_slider_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=BPSK,
            differential=True,
            samples_per_symbol=sps,
            pre_diff_code=True,
            excess_bw=0.25,
            verbose=False,
            log=False,
        )
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_complex_to_real_1 = blocks.complex_to_real(1)
        self.blks2_tcp_source_0 = grc_blks2.tcp_source(
            itemsize=gr.sizeof_char * 1,
            addr='127.0.0.1',
            port=1233,
            server=False,
        )
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(
            grc_blks2.packet_encoder(
                samples_per_symbol=1,
                bits_per_symbol=1,
                preamble='',
                access_code='',
                pad_for_usrp=False,
            ),
            payload_length=1,
        )
        self.audio_sink_0 = audio.sink(44100, '', True)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, fc_slider, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blks2_packet_encoder_0, 0),
                     (self.digital_constellation_modulator_0, 0))
        self.connect((self.blks2_tcp_source_0, 0),
                     (self.blks2_packet_encoder_0, 0))
        self.connect((self.blocks_complex_to_real_1, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_complex_to_real_1, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_complex_to_real_1, 0))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.blocks_multiply_xx_0, 0))
示例#45
0
    def __init__(self,DRMParameters):
        gr.top_block.__init__(self, "DRM Transmitter 1")

        ##################################################
        # Variables
        ##################################################
        self.text_message = text_message = DRMParameters.text_msg
        self.station_label = station_label = DRMParameters.station_label
        self.msc_prot_level_2 = msc_prot_level_2 = 1
        self.long_interl = long_interl = True
        self.audio_sample_rate = audio_sample_rate = DRMParameters.audio_samp*1000
        self.SO = SO = DRMParameters.so
        self.RM = RM = DRMParameters.rm
        self.tp = tp = drm.transm_params(RM, SO, False, 0, DRMParameters.msc_mod, 0, msc_prot_level_2, DRMParameters.sdc_mod, 0, long_interl, audio_sample_rate, station_label, text_message)
        self.samp_rate = samp_rate = 48e3
        self.usrp_addr = DRMParameters.usrp_id
        self.output_name = DRMParameters.output_name
        self.center_freq = DRMParameters.center_freq*1e6
        self.audio_file = DRMParameters.audio_file

        ##################################################
        # Blocks
        ##################################################
        if DRMParameters.uhd_found:
            self.uhd_usrp_sink_0 = uhd.usrp_sink(
                ",".join((self.usrp_addr, "")),
                uhd.stream_args(
                    cpu_format="fc32",
                    channels=range(1),
                ),
            )
            self.uhd_usrp_sink_0.set_samp_rate(samp_rate * 250 / 48)
            self.uhd_usrp_sink_0.set_center_freq(self.center_freq, 0)
            self.uhd_usrp_sink_0.set_gain(0, 0)
            self.uhd_usrp_sink_0.set_antenna("TXA", 0)
            self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                    interpolation=250,
                    decimation=48,
                    taps=None,
                    fractional_bw=None,
            )
        self.fft_vxx_0 = fft.fft_vcc(tp.ofdm().nfft(), False, (), True, 1)
        self.drm_scrambler_bb_0_1 = drm.scrambler_bb(tp.sdc().L())
        self.drm_scrambler_bb_0_0 = drm.scrambler_bb(tp.fac().L())
        self.drm_scrambler_bb_0 = drm.scrambler_bb(tp.msc().L_MUX())
        self.drm_mlc_fac_bc = drm.make_mlc(
            channel_type="FAC",
            tp=tp
        )

        #SDC Configuration
        self.drm_mlc_sdc_bc= drm.make_mlc(
                channel_type="SDC",
                tp=tp
            )
            
        #MSC Configuration
        self.drm_mlc_msc_bc = drm.make_mlc(
                channel_type="MSC",
                tp=tp
            )
        self.drm_interleaver_cc_0 = drm.interleaver_cc((tp.msc().cell_interl_seq()), long_interl, drm.INTL_DEPTH_DRM)
        self.drm_generate_sdc_b_0 = drm.generate_sdc_b(tp)
        self.drm_generate_fac_b_0 = drm.generate_fac_b(tp)
        self.drm_audio_encoder_sb_0 = drm.audio_encoder_sb(tp)
        self.digital_ofdm_cyclic_prefixer_1 = digital.ofdm_cyclic_prefixer(tp.ofdm().nfft(), tp.ofdm().nfft()+tp.ofdm().nfft()*tp.ofdm().cp_ratio_enum()/tp.ofdm().cp_ratio_denom(), 0, "")
        self.cell_mapping_cc_0 = drm.cell_mapping_cc(tp, (tp.msc().N_MUX() * tp.ofdm().M_TF() * 8, tp.sdc().N() * 8, tp.fac().N() * tp.ofdm().M_TF() * 8))
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1)
        if DRMParameters.pulse_audio:
            self.audio_source_1 = audio.source(audio_sample_rate, "", True)
        else:
            self.blocks_wavfile_source_0 = blocks.wavfile_source(self.audio_file, False)
        if DRMParameters.gen_output:
            self.blocks_wavfile_sink_0 = blocks.wavfile_sink(self.output_name, 1, 48000, 16)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((7e-3, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((32768, ))
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 7000, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))    
        if DRMParameters.gen_output:
            self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_wavfile_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.drm_audio_encoder_sb_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_0, 0))
        if DRMParameters.pulse_audio:
            self.connect((self.audio_source_1, 0), (self.blocks_multiply_const_vxx_0, 0))
        else:
            self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.cell_mapping_cc_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.digital_ofdm_cyclic_prefixer_1, 0), (self.blocks_multiply_const_vxx_1, 0))    
        self.connect((self.drm_audio_encoder_sb_0, 0), (self.drm_scrambler_bb_0, 0))    
        self.connect((self.drm_generate_fac_b_0, 0), (self.drm_scrambler_bb_0_0, 0))    
        self.connect((self.drm_generate_sdc_b_0, 0), (self.drm_scrambler_bb_0_1, 0))    
        self.connect((self.drm_interleaver_cc_0, 0), (self.cell_mapping_cc_0, 0))    
        self.connect((self.drm_mlc_msc_bc, 0), (self.drm_interleaver_cc_0, 0))
        self.connect((self.drm_mlc_sdc_bc, 0), (self.cell_mapping_cc_0, 1))
        self.connect((self.drm_mlc_fac_bc, 0), (self.cell_mapping_cc_0, 2))    
        self.connect((self.drm_scrambler_bb_0, 0), (self.drm_mlc_msc_bc, 0))
        self.connect((self.drm_scrambler_bb_0_0, 0), (self.drm_mlc_fac_bc, 0))    
        self.connect((self.drm_scrambler_bb_0_1, 0), (self.drm_mlc_sdc_bc, 0))
        self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_cyclic_prefixer_1, 0))    
        if DRMParameters.uhd_found:
            self.connect((self.rational_resampler_xxx_0, 0), (self.uhd_usrp_sink_0, 0))
            self.connect((self.blocks_multiply_const_vxx_1, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_null_sink_0, 0))
    def __init__(self,
                 Np,
                 P,
                 modulation,
                 code_rate,
                 code_type="convolutional"
                 ):
        gr.top_block.__init__(self, "Modulation and Coding Scheme")

        ##################################################
        # Variables
        ##################################################
        self.Np = Np
        self.P = P
        self.samp_rate = 100000
        self.puncpat = '11'
        self.snr_db = 10
        if code_rate == '1':
            self.enc_cc = fec.dummy_encoder_make(128)
        else:
            self.enc_cc = fec.cc_encoder_make(128, 7, 2, ([79, 109]), 0, fec.CC_STREAMING, False)
        self.const = digital.constellation_bpsk().base()
        self.get_constellation_from_string(modulation)
        self.get_puncpat_from_string(code_rate)


        ##################################################
        # Blocks
        ##################################################
        self.specest_cyclo_fam_0 = specest.cyclo_fam(self.Np, self.P, self.Np/4)
        self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(4, (firdes.low_pass_2(1, 1, 1/8.0, 1/16.0, 80)))
        self.interp_fir_filter_xxx_0.declare_sample_delay(0)
        self.fec_extended_encoder_0 = fec.extended_encoder(encoder_obj_list=self.enc_cc, threading='capillary', puncpat='11')
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((self.const.points()), 1)
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=10.0**(-self.snr_db/20.0),
            frequency_offset=0.0,
            epsilon=1.0,
            taps=(1.0, ),
            noise_seed=0,
            block_tags=False
        )
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, self.samp_rate,True)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(1, int(np.log2(self.const.arity())), "", False, gr.GR_LSB_FIRST)
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_float*1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*2*self.Np)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(self.samp_rate, analog.GR_COS_WAVE, self.samp_rate/4, 1, 0)
        self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 1000000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0), (self.fec_extended_encoder_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.specest_cyclo_fam_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.channels_channel_model_0, 0))
        self.connect((self.blocks_null_source_0, 0), (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.channels_channel_model_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.interp_fir_filter_xxx_0, 0))
        self.connect((self.fec_extended_encoder_0, 0), (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.specest_cyclo_fam_0, 0), (self.blocks_null_sink_0, 0))
示例#47
0
    def __init__(self, options):
        gr.hier_block2.__init__(self, "transmit_path",
                                gr.io_signature(0, 0, 0),
                                gr.io_signature(1, 1, gr.sizeof_gr_complex))

        common_options.defaults(options)

        config = self.config = station_configuration()

        config.data_subcarriers = options.subcarriers
        config.cp_length = options.cp_length
        config.frame_data_blocks = options.data_blocks
        config._verbose = options.verbose
        config.fft_length = options.fft_length
        config.dc_null = options.dc_null
        config.training_data = default_block_header(config.data_subcarriers,
                                                    config.fft_length,
                                                    config.dc_null, options)
        config.coding = options.coding
        config.bandwidth = options.bandwidth
        config.gui_frame_rate = options.gui_frame_rate
        config.fbmc = options.fbmc

        config.frame_id_blocks = 1  # FIXME

        # digital rms amplitude sent to USRP
        rms_amp = options.rms_amplitude
        self._options = copy.copy(options)

        config.block_length = config.fft_length + config.cp_length
        config.frame_data_part = config.frame_data_blocks + config.frame_id_blocks
        config.frame_length = config.frame_data_part + \
                              config.training_data.no_pilotsyms
        config.subcarriers = config.data_subcarriers + \
                             config.training_data.pilot_subcarriers
        config.virtual_subcarriers = config.fft_length - config.subcarriers - config.dc_null

        # default values if parameters not set
        if rms_amp is None:
            rms_amp = math.sqrt(config.subcarriers)
        config.rms_amplitude = rms_amp

        # check some bounds
        if config.fft_length < config.subcarriers:
            raise SystemError, "Subcarrier number must be less than FFT length"
        if config.fft_length < config.cp_length:
            raise SystemError, "Cyclic prefix length must be less than FFT length"

        ## shortcuts
        blen = config.block_length
        flen = config.frame_length
        dsubc = config.data_subcarriers
        vsubc = config.virtual_subcarriers

        # Adaptive Transmitter Concept
        used_id_bits = config.used_id_bits = 8  #TODO: no constant in source code
        rep_id_bits = config.rep_id_bits = config.data_subcarriers / used_id_bits  #BPSK
        if config.data_subcarriers % used_id_bits <> 0:
            raise SystemError, "Data subcarriers need to be multiple of %d" % (
                used_id_bits)

        # adapt OFDM frame rate and GUI display frame rate
        self.keep_frame_n = int(
            1.0 / (config.frame_length *
                   (config.cp_length + config.fft_length) / config.bandwidth) /
            config.gui_frame_rate)

        ## Allocation Control
        self.allocation_src = allocation_src(
            config.data_subcarriers, config.frame_data_blocks, config.coding,
            "tcp://*:3333", "tcp://" + options.rx_hostname + ":3322")
        if options.static_allocation:  #DEBUG
            # how many bits per subcarrier

            if options.coding:
                mode = 1  # Coding mode 1-9
                bitspermode = [0.5, 1, 1.5, 2, 3, 4, 4.5, 5,
                               6]  # Information bits per mode
                modulbitspermode = [1, 2, 2, 4, 4, 6, 6, 6,
                                    8]  # Coding bits per mode
                bitcount_vec = [
                    (int)(config.data_subcarriers * config.frame_data_blocks *
                          bitspermode[mode - 1])
                ]
                modul_bitcount_vec = [
                    config.data_subcarriers * config.frame_data_blocks *
                    modulbitspermode[mode - 1]
                ]
                bitcount_src = blocks.vector_source_i(bitcount_vec, True, 1)
                modul_bitcount_src = blocks.vector_source_i(
                    modul_bitcount_vec, True, 1)
                bitloading = mode
            else:
                bitloading = 1
                bitcount_vec = [
                    config.data_subcarriers * config.frame_data_blocks *
                    bitloading
                ]
                bitcount_src = blocks.vector_source_i(bitcount_vec, True, 1)
                modul_bitcount_src = bitcount_src

            # id's for frames
            id_vec = range(0, 256)
            id_src = blocks.vector_source_s(id_vec, True, 1)
            # bitloading for ID symbol and then once for data symbols
            #bitloading_vec = [1]*dsubc+[0]*(dsubc/2)+[2]*(dsubc/2)

            #test_allocation = [bitloading]*(int)(config.data_subcarriers/8)+ [0]*(int)(config.data_subcarriers/4*3) + [bitloading]*(int)(config.data_subcarriers/8)
            #bitloading_vec = [1]*dsubc+[bitloading]*dsubc
            test_allocation = [bitloading] * dsubc
            bitloading_vec = [bitloading] * dsubc + test_allocation
            bitloading_src = blocks.vector_source_b(bitloading_vec, True,
                                                    dsubc)
            # bitcount for frames
            #bitcount_vec = [config.data_subcarriers*config.frame_data_blocks*bitloading]
            bitcount_vec = [config.frame_data_blocks * sum(test_allocation)]
            bitcount_src = blocks.vector_source_i(bitcount_vec, True, 1)
            # power loading, here same for all symbols
            #power_vec = [1]*(int)(config.data_subcarriers/8)+ [0]*(int)(config.data_subcarriers/4*3) + [1]*(int)(config.data_subcarriers/8)
            power_vec = [1] * config.data_subcarriers
            power_src = blocks.vector_source_f(power_vec, True, dsubc)
            # mux control stream to mux id and data bits
            mux_vec = [0] * dsubc + [1] * bitcount_vec[0]
            mux_ctrl = blocks.vector_source_b(mux_vec, True, 1)
        else:
            id_src = (self.allocation_src, 0)
            bitcount_src = (self.allocation_src, 4)
            bitloading_src = (self.allocation_src, 2)
            power_src = (self.allocation_src, 1)
            if options.coding:
                modul_bitcount_src = (self.allocation_src, 5)
            else:
                modul_bitcount_src = bitcount_src
            mux_ctrl = ofdm.tx_mux_ctrl(dsubc)
            self.connect(modul_bitcount_src, mux_ctrl)

            #Initial allocation
            self.allocation_src.set_allocation([2] * config.data_subcarriers,
                                               [1] * config.data_subcarriers)
            self.allocation_src.set_allocation_scheme(0)
            if options.benchmarking:
                self.allocation_src.set_allocation(
                    [4] * config.data_subcarriers,
                    [1] * config.data_subcarriers)

        if options.lab_special_case:
            self.allocation_src.set_allocation(
                [0] * (config.data_subcarriers / 4) + [2] *
                (config.data_subcarriers / 2) + [0] *
                (config.data_subcarriers / 4), [1] * config.data_subcarriers)

        if options.log:
            log_to_file(self, id_src, "data/id_src.short")
            log_to_file(self, bitcount_src, "data/bitcount_src.int")
            log_to_file(self, bitloading_src, "data/bitloading_src.char")
            log_to_file(self, power_src, "data/power_src.cmplx")

        ## GUI probe output
        zmq_probe_bitloading = zeromq.pub_sink(gr.sizeof_char, dsubc,
                                               "tcp://*:4445")
        # also skip ID symbol bitloading with keep_one_in_n (side effect)
        # factor 2 for bitloading because we have two vectors per frame, one for id symbol and one for all payload/data symbols
        # factor config.frame_data_part for power because there is one vector per ofdm symbol per frame
        self.connect(bitloading_src,
                     blocks.keep_one_in_n(gr.sizeof_char * dsubc, 2 * 40),
                     zmq_probe_bitloading)
        zmq_probe_power = zeromq.pub_sink(gr.sizeof_float, dsubc,
                                          "tcp://*:4444")
        #self.connect(power_src, blocks.keep_one_in_n(gr.sizeof_gr_complex*dsubc,40), blocks.complex_to_real(dsubc), zmq_probe_power)
        self.connect(power_src,
                     blocks.keep_one_in_n(gr.sizeof_float * dsubc, 40),
                     zmq_probe_power)

        ## Workaround to avoid periodic structure
        seed(1)
        whitener_pn = [
            randint(0, 1) for i in range(used_id_bits * rep_id_bits)
        ]

        ## ID Encoder
        id_enc = self._id_encoder = repetition_encoder_sb(
            used_id_bits, rep_id_bits, whitener_pn)
        self.connect(id_src, id_enc)

        if options.log:
            id_enc_f = gr.char_to_float()
            self.connect(id_enc, id_enc_f)
            log_to_file(self, id_enc_f, "data/id_enc_out.float")

        ## Reference Data Source
        ber_ref_src = ber_reference_source(self._options)
        self.connect(id_src, (ber_ref_src, 0))
        self.connect(bitcount_src, (ber_ref_src, 1))

        if options.log:
            log_to_file(self, ber_ref_src, "data/ber_rec_src_tx.char")

        if options.log:
            log_to_file(self, btrig, "data/bitmap_trig.char")

        ## Bitmap Update Trigger for puncturing
        if not options.nopunct:
            bmaptrig_stream_puncturing = [
                1
            ] + [0] * (config.frame_data_blocks / 2 - 1)

            btrig_puncturing = self._bitmap_trigger_puncturing = blocks.vector_source_b(
                bmaptrig_stream_puncturing, True)
            bmapsrc_stream_puncturing = [1] * dsubc + [2] * dsubc
            bsrc_puncturing = self._bitmap_src_puncturing = blocks.vector_source_b(
                bmapsrc_stream_puncturing, True, dsubc)

        if options.log and options.coding and not options.nopunct:
            log_to_file(self, btrig_puncturing,
                        "data/bitmap_trig_puncturing.char")

        ## Frame Trigger
        ftrig_stream = [1] + [0] * (config.frame_data_part - 1)
        ftrig = self._frame_trigger = blocks.vector_source_b(
            ftrig_stream, True)

        ## Data Multiplexer
        # Input 0: control stream
        # Input 1: encoded ID stream
        # Inputs 2..n: data streams
        dmux = self._data_multiplexer = stream_controlled_mux_b()
        self.connect(mux_ctrl, (dmux, 0))
        self.connect(id_enc, (dmux, 1))

        if options.coding:
            fo = trellis.fsm(1, 2, [91, 121])
            encoder = self._encoder = trellis.encoder_bb(fo, 0)
            unpack = self._unpack = blocks.unpack_k_bits_bb(2)
            self.connect(ber_ref_src, encoder, unpack)

            if options.interleave:
                int_object = trellis.interleaver(2000, 666)
                interlv = trellis.permutation(int_object.K(),
                                              int_object.INTER(), 1,
                                              gr.sizeof_char)

            if not options.nopunct:
                bmaptrig_stream_puncturing = [
                    1
                ] + [0] * (config.frame_data_blocks / 2 - 1)
                btrig_puncturing = self._bitmap_trigger_puncturing = blocks.vector_source_b(
                    bmaptrig_stream_puncturing, True)
                puncturing = self._puncturing = puncture_bb(
                    config.data_subcarriers)
                self.connect(bitloading_src, (puncturing, 1))
                self.connect(self._bitmap_trigger_puncturing, (puncturing, 2))
                self.connect(unpack, puncturing)
                last_block = puncturing

                if options.interleave:
                    self.connect(last_block, interlv)
                    last_block = interlv

                if options.benchmarking:
                    self.connect(last_block,
                                 blocks.head(gr.sizeof_char, options.N),
                                 (dmux, 2))
                else:
                    self.connect(last_block, (dmux, 2))
            else:
                if options.benchmarking:
                    self.connect(unpack, blocks.head(gr.sizeof_char,
                                                     options.N), (dmux, 2))
                else:
                    self.connect(unpack, (dmux, 2))

        else:
            if options.benchmarking:
                self.connect(ber_ref_src, blocks.head(gr.sizeof_char,
                                                      options.N), (dmux, 2))
            else:
                self.connect(ber_ref_src, (dmux, 2))

        if options.log:
            dmux_f = gr.char_to_float()
            self.connect(dmux, dmux_f)
            log_to_file(self, dmux_f, "data/dmux_out.float")

        ## Modulator
        mod = self._modulator = generic_mapper_bcv(config.data_subcarriers,
                                                   config.coding,
                                                   config.frame_data_part)
        self.connect(dmux, (mod, 0))
        self.connect(bitloading_src, (mod, 1))
        #log_to_file(self, mod, "data/mod_out.compl")

        if options.log:
            log_to_file(self, mod, "data/mod_out.compl")
            modi = blocks.complex_to_imag(config.data_subcarriers)
            modr = blocks.complex_to_real(config.data_subcarriers)
            self.connect(mod, modi)
            self.connect(mod, modr)
            log_to_file(self, modi, "data/mod_imag_out.float")
            log_to_file(self, modr, "data/mod_real_out.float")

        ## Power allocator
        pa = self._power_allocator = multiply_frame_fc(config.frame_data_part,
                                                       config.data_subcarriers)
        self.connect(mod, (pa, 0))
        self.connect(power_src, (pa, 1))

        if options.log:
            log_to_file(self, pa, "data/pa_out.compl")

        # Standard Transmitter Parts

        ## Pilot subcarriers
        psubc = self._pilot_subcarrier_inserter = pilot_subcarrier_inserter()
        self.connect(pa, psubc)

        if options.log:
            log_to_file(self, psubc, "data/psubc_out.compl")

        ## Add virtual subcarriers
        if config.fft_length > config.subcarriers:
            vsubc = self._virtual_subcarrier_extender = \
                    vector_padding_dc_null(config.subcarriers, config.fft_length,config.dc_null)
            self.connect(psubc, vsubc)
        else:
            vsubc = self._virtual_subcarrier_extender = psubc

        if options.log:
            log_to_file(self, vsubc, "data/vsubc_out.compl")

        ## IFFT, no window, block shift
        ifft = self._ifft = fft_blocks.fft_vcc(config.fft_length, False, [],
                                               True)
        self.connect(vsubc, ifft)

        if options.log:
            log_to_file(self, ifft, "data/ifft_out.compl")

        ## Pilot blocks (preambles)
        pblocks = self._pilot_block_inserter = pilot_block_inserter(5, False)
        self.connect(ifft, pblocks)

        if options.log:
            log_to_file(self, pblocks, "data/pilot_block_ins_out.compl")

        ## Cyclic Prefix
        cp = self._cyclic_prefixer = cyclic_prefixer(config.fft_length,
                                                     config.block_length)
        self.connect(pblocks, cp)

        lastblock = cp

        if options.log:
            log_to_file(self, cp, "data/cp_out.compl")

        #Digital Amplifier for resource allocation
        #if not options.coding:
        rep = blocks.repeat(gr.sizeof_gr_complex,
                            config.frame_length * config.block_length)
        amp = blocks.multiply_cc()
        self.connect(lastblock, (amp, 0))
        self.connect((self.allocation_src, 3), rep, (amp, 1))
        lastblock = amp

        ## Digital Amplifier
        #amp = self._amplifier = gr.multiply_const_cc(1)
        amp = self._amplifier = ofdm.multiply_const_ccf(1.0)
        self.connect(lastblock, amp)
        self.set_rms_amplitude(rms_amp)

        if options.log:
            log_to_file(self, amp, "data/amp_tx_out.compl")

        ## Tx parameters
        bandwidth = options.bandwidth or 2e6
        bits = 8 * config.data_subcarriers * config.frame_data_blocks  # max. QAM256
        samples_per_frame = config.frame_length * config.block_length
        tb = samples_per_frame / bandwidth
        # set dummy carrier frequency if none available due to baseband mode
        if (options.tx_freq is None):
            options.tx_freq = 0.0
        self.tx_parameters = {'carrier_frequency':options.tx_freq/1e9,'fft_size':config.fft_length, 'cp_size':config.cp_length \
                              , 'subcarrier_spacing':options.bandwidth/config.fft_length/1e3 \
                              , 'data_subcarriers':config.data_subcarriers, 'bandwidth':options.bandwidth/1e6 \
                              , 'frame_length':config.frame_length  \
                              , 'symbol_time':(config.cp_length + config.fft_length)/options.bandwidth*1e6, 'max_data_rate':(bits/tb)/1e6}

        ## Setup Output
        self.connect(amp, self)

        # Display some information about the setup
        if config._verbose:
            self._print_verbage()
    def __init__(self):
        gr.top_block.__init__(self, "Demod")

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 20
        self.nfilts = nfilts = 32
        self.samp_rate = samp_rate = 44100
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), 0.35, 11 * sps * nfilts)
        self.qpsk = qpsk = digital.constellation_rect(([
            0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j
        ]), ([0, 1, 3, 2]), 4, 2, 2, 1, 1).base()
        self.arity = arity = 4

        ##################################################
        # Blocks
        ##################################################
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 1.6e3, .6E3, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_1 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 5000, 100, firdes.WIN_HAMMING, 6.76))
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, 62.8e-3, (rrc_taps), nfilts, nfilts / 2, 1.5, 2)
        self.digital_map_bb_0 = digital.map_bb(([0, 1, 3, 2]))
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            62.8e-3, arity, False)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            qpsk)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(
            15, 1, 10e-3, 2)
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            sys.argv[1], False)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   sys.argv[2], False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -8e3, 1, 0)

        self.blocks_wavfile_sink_0 = blocks.wavfile_sink(
            "/mnt/test.wav", 2, samp_rate, 16)
        self.blocks_complex_to_real_1 = blocks.complex_to_real(1)
        self.blocks_complex_to_imag_1 = blocks.complex_to_imag(1)
        ##################################################
        # Connections
        ##################################################
        # self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_wavfile_source_0, 1),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.low_pass_filter_1, 0))
        self.connect((self.low_pass_filter_1, 0), (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.digital_map_bb_0, 0))
        self.connect((self.digital_map_bb_0, 0),
                     (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                     (self.blocks_file_sink_0, 0))

        #Test wav
        self.connect((self.low_pass_filter_1, 0),
                     (self.blocks_complex_to_imag_1, 0))
        self.connect((self.low_pass_filter_1, 0),
                     (self.blocks_complex_to_real_1, 0))
        self.connect((self.blocks_complex_to_imag_1, 0),
                     (self.blocks_wavfile_sink_0, 1))
        self.connect((self.blocks_complex_to_real_1, 0),
                     (self.blocks_wavfile_sink_0, 0))
示例#49
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.sig_amp = sig_amp = 1
        self.samp_rate = samp_rate = 24e3
        self.ref_amp = ref_amp = .1

        ##################################################
        # Blocks
        ##################################################
        self._sig_amp_range = Range(0.1, 10, .1, 1, 200)
        self._sig_amp_win = RangeWidget(self._sig_amp_range, self.set_sig_amp, "sig_amp", "counter_slider", float)
        self.top_layout.addWidget(self._sig_amp_win)
        self._ref_amp_range = Range(0.1, 10, .1, .1, 200)
        self._ref_amp_win = RangeWidget(self._ref_amp_range, self.set_ref_amp, "ref_amp", "counter_slider", float)
        self.top_layout.addWidget(self._ref_amp_win)
        self.qtgui_time_sink_x_2_0 = qtgui.time_sink_f(
        	1024, #size
        	samp_rate, #samp_rate
        	"Estimacion de tono", #name
        	3 #number of inputs
        )
        self.qtgui_time_sink_x_2_0.set_update_time(5)
        self.qtgui_time_sink_x_2_0.set_y_axis(-1, 1)

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

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

        if not True:
          self.qtgui_time_sink_x_2_0.disable_legend()

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

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

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

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

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

        if not True:
          self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.comina_anc_ff_0 = comina.anc_ff(.8, 2, 100)
        self.blocks_wavfile_sink_0_0 = blocks.wavfile_sink('/home/olaznog/workspace/gr-comina/examples/audio/mag_phase/senal_interferencia.wav', 1, 24000, 8)
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink('/home/olaznog/workspace/gr-comina/examples/audio/mag_phase/ruido_cancelado.wav', 1, 24000, 8)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((ref_amp*cmath.exp(1j*math.pi/2), ))
        self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_sig_source_x_1_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 200, sig_amp, 0)
        self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 200, sig_amp, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_1, 0), (self.blocks_complex_to_real_0_0, 0))
        self.connect((self.analog_sig_source_x_1_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.comina_anc_ff_0, 1))
        self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_time_sink_x_2_0, 2))
        self.connect((self.blocks_complex_to_real_0_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_complex_to_real_0_0, 0), (self.comina_anc_ff_0, 0))
        self.connect((self.blocks_complex_to_real_0_0, 0), (self.qtgui_time_sink_x_2_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_wavfile_sink_0_0, 0))
        self.connect((self.comina_anc_ff_0, 1), (self.blocks_wavfile_sink_0, 0))
        self.connect((self.comina_anc_ff_0, 1), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.comina_anc_ff_0, 0), (self.qtgui_time_sink_x_2_0, 1))
示例#50
0
    def __init__(self,
                 bfo=12000,
                 callsign='',
                 ip='::',
                 latitude=0,
                 longitude=0,
                 port=7355,
                 recstart=''):
        gr.hier_block2.__init__(
            self,
            "LilacSat-1 decoder",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signaturev(2, 2, [gr.sizeof_char * 1, gr.sizeof_char * 1]),
        )

        ##################################################
        # Parameters
        ##################################################
        self.bfo = bfo
        self.callsign = callsign
        self.ip = ip
        self.latitude = latitude
        self.longitude = longitude
        self.port = port
        self.recstart = recstart

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 5
        self.samp_per_sym = samp_per_sym = 5
        self.nfilts = nfilts = 16
        self.alpha = alpha = 0.35

        self.variable_constellation_0_0 = variable_constellation_0_0 = digital.constellation_calcdist(
            ([-1, 1]), ([0, 1]), 2, 1).base()

        self.threshold = threshold = 3
        self.samp_rate = samp_rate = 48000
        self.rrc_taps_0 = rrc_taps_0 = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(samp_per_sym), 0.35,
            11 * samp_per_sym * nfilts)
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), alpha, 11 * sps * nfilts)
        self.nfilts_0 = nfilts_0 = 16

        ##################################################
        # Blocks
        ##################################################
        self.rms_agc_0 = rms_agc(
            alpha=1e-2,
            reference=0.5,
        )
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 10000, 1000, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 6000, 500, firdes.WIN_HAMMING, 6.76))
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, 0.05, (rrc_taps), nfilts, nfilts / 2, 0.01, 1)
        self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(
            sps, 0.350, 100, 0.001)
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(0.1, 2, False)
        self.ccsds_viterbi_0_0 = ccsds_viterbi()
        self.ccsds_viterbi_0 = ccsds_viterbi()
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.ccsds_viterbi_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.ccsds_viterbi_0_0, 0))
        self.connect((self.ccsds_viterbi_0, 0), (self, 0))
        self.connect((self.ccsds_viterbi_0_0, 0), (self, 1))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.digital_fll_band_edge_cc_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_costas_loop_cc_0_0, 0))
        self.connect((self, 0), (self.low_pass_filter_0_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.low_pass_filter_0_0, 0), (self.rms_agc_0, 0))
        self.connect((self.rms_agc_0, 0), (self.digital_fll_band_edge_cc_0, 0))
    def __init__(self, udp_port):
        gr.top_block.__init__(self, "Sigfox Receive Realtime")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 250000
        self.taps = taps = firdes.low_pass(1, samp_rate, 100, 50,
                                           firdes.WIN_HAMMING)
        self.decim_second = decim_second = 250
        self.decim_first = decim_first = 5
        self.udp_port = udp_port

        ##################################################
        # Blocks
        ##################################################
        self.sigfox_packet_sink_scapy_0_1_1_9 = sigfox.packet_sink_scapy()
        self.sigfox_packet_sink_scapy_0_1_1_8 = sigfox.packet_sink_scapy()
        self.sigfox_packet_sink_scapy_0_1_1_7 = sigfox.packet_sink_scapy()
        self.sigfox_Detection_Peak_0 = sigfox.Detection_Peak(
            90, samp_rate / 6.28)
        self.freq_xlating_fir_filter_xxx_0_1_9 = filter.freq_xlating_fir_filter_ccc(
            decim_first, (taps), 0, samp_rate)
        self.freq_xlating_fir_filter_xxx_0_1_8 = filter.freq_xlating_fir_filter_ccc(
            decim_first, (taps), 0, samp_rate)
        self.freq_xlating_fir_filter_xxx_0_1_7 = filter.freq_xlating_fir_filter_ccc(
            decim_first, (taps), 0, samp_rate)
        self.fir_filter_xxx_0_1 = filter.fir_filter_ccc(decim_second, (1, ))
        self.fir_filter_xxx_0_1.declare_sample_delay(0)
        self.fir_filter_xxx_0_0 = filter.fir_filter_ccc(decim_second, (1, ))
        self.fir_filter_xxx_0_0.declare_sample_delay(0)
        self.fir_filter_xxx_0 = filter.fir_filter_ccc(decim_second, (1, ))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.digital_diff_decoder_bb_0_0_0_1_1_9 = digital.diff_decoder_bb(2)
        self.digital_diff_decoder_bb_0_0_0_1_1_8 = digital.diff_decoder_bb(2)
        self.digital_diff_decoder_bb_0_0_0_1_1_7 = digital.diff_decoder_bb(2)
        self.digital_costas_loop_cc_0_0_0_0_0_0_0_1_2_1_1_1_9 = digital.costas_loop_cc(
            6.28 / 100, 2, False)
        self.digital_costas_loop_cc_0_0_0_0_0_0_0_1_2_1_1_1_8 = digital.costas_loop_cc(
            6.28 / 100, 2, False)
        self.digital_costas_loop_cc_0_0_0_0_0_0_0_1_2_1_1_1_7 = digital.costas_loop_cc(
            6.28 / 100, 2, False)
        self.digital_clock_recovery_mm_xx_0_0_1_1_9 = digital.clock_recovery_mm_cc(
            2, 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005)
        self.digital_clock_recovery_mm_xx_0_0_1_1_8 = digital.clock_recovery_mm_cc(
            2, 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005)
        self.digital_clock_recovery_mm_xx_0_0_1_1_7 = digital.clock_recovery_mm_cc(
            2, 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005)
        self.digital_binary_slicer_fb_0_1_1_9 = digital.binary_slicer_fb()
        self.digital_binary_slicer_fb_0_1_1_8 = digital.binary_slicer_fb()
        self.digital_binary_slicer_fb_0_1_1_7 = digital.binary_slicer_fb()
        self.blocks_socket_pdu_0_0_1 = blocks.socket_pdu(
            "UDP_CLIENT", '127.0.0.1', self.udp_port, 10000, False)
        self.blocks_message_debug_0_0_0_1_1 = blocks.message_debug()
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_complex_to_real_0_1_1_9 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0_1_1_8 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0_1_1_7 = blocks.complex_to_real(1)
        self.analog_simple_squelch_cc_1_1_0 = analog.simple_squelch_cc(-20, 1)
        self.analog_pll_freqdet_cf_0 = analog.pll_freqdet_cf(
            6.28 / 100, 6.28 * 110e3 / samp_rate, -6.28 * 110e3 / samp_rate)
        self.analog_const_source_x_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.sigfox_Detection_Peak_0, 'out0'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.sigfox_Detection_Peak_0, 'out1'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.sigfox_Detection_Peak_0, 'out2'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.sigfox_Detection_Peak_0, 'out0'),
                         (self.freq_xlating_fir_filter_xxx_0_1_7, 'freq'))
        self.msg_connect((self.sigfox_Detection_Peak_0, 'out1'),
                         (self.freq_xlating_fir_filter_xxx_0_1_8, 'freq'))
        self.msg_connect((self.sigfox_Detection_Peak_0, 'out2'),
                         (self.freq_xlating_fir_filter_xxx_0_1_9, 'freq'))
        self.msg_connect((self.sigfox_packet_sink_scapy_0_1_1_7, 'out'),
                         (self.blocks_message_debug_0_0_0_1_1, 'print'))
        self.msg_connect((self.sigfox_packet_sink_scapy_0_1_1_7, 'out'),
                         (self.blocks_socket_pdu_0_0_1, 'pdus'))
        self.msg_connect((self.sigfox_packet_sink_scapy_0_1_1_8, 'out'),
                         (self.blocks_message_debug_0_0_0_1_1, 'print'))
        self.msg_connect((self.sigfox_packet_sink_scapy_0_1_1_8, 'out'),
                         (self.blocks_socket_pdu_0_0_1, 'pdus'))
        self.msg_connect((self.sigfox_packet_sink_scapy_0_1_1_9, 'out'),
                         (self.blocks_message_debug_0_0_0_1_1, 'print'))
        self.msg_connect((self.sigfox_packet_sink_scapy_0_1_1_9, 'out'),
                         (self.blocks_socket_pdu_0_0_1, 'pdus'))
        self.connect((self.analog_const_source_x_0, 0),
                     (self.analog_simple_squelch_cc_1_1_0, 0))
        self.connect((self.analog_pll_freqdet_cf_0, 0),
                     (self.sigfox_Detection_Peak_0, 0))
        self.connect((self.analog_simple_squelch_cc_1_1_0, 0),
                     (self.analog_pll_freqdet_cf_0, 0))
        self.connect((self.analog_simple_squelch_cc_1_1_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0_1_7, 0))
        self.connect((self.analog_simple_squelch_cc_1_1_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0_1_8, 0))
        self.connect((self.analog_simple_squelch_cc_1_1_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0_1_9, 0))
        self.connect((self.blocks_complex_to_real_0_1_1_7, 0),
                     (self.digital_binary_slicer_fb_0_1_1_7, 0))
        self.connect((self.blocks_complex_to_real_0_1_1_8, 0),
                     (self.digital_binary_slicer_fb_0_1_1_8, 0))
        self.connect((self.blocks_complex_to_real_0_1_1_9, 0),
                     (self.digital_binary_slicer_fb_0_1_1_9, 0))
        self.connect((self.digital_binary_slicer_fb_0_1_1_7, 0),
                     (self.digital_diff_decoder_bb_0_0_0_1_1_7, 0))
        self.connect((self.digital_binary_slicer_fb_0_1_1_8, 0),
                     (self.digital_diff_decoder_bb_0_0_0_1_1_8, 0))
        self.connect((self.digital_binary_slicer_fb_0_1_1_9, 0),
                     (self.digital_diff_decoder_bb_0_0_0_1_1_9, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0_0_1_1_7, 0),
                     (self.blocks_complex_to_real_0_1_1_7, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0_0_1_1_8, 0),
                     (self.blocks_complex_to_real_0_1_1_8, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0_0_1_1_9, 0),
                     (self.blocks_complex_to_real_0_1_1_9, 0))
        self.connect(
            (self.digital_costas_loop_cc_0_0_0_0_0_0_0_1_2_1_1_1_7, 0),
            (self.fir_filter_xxx_0, 0))
        self.connect(
            (self.digital_costas_loop_cc_0_0_0_0_0_0_0_1_2_1_1_1_8, 0),
            (self.fir_filter_xxx_0_0, 0))
        self.connect(
            (self.digital_costas_loop_cc_0_0_0_0_0_0_0_1_2_1_1_1_9, 0),
            (self.fir_filter_xxx_0_1, 0))
        self.connect((self.digital_diff_decoder_bb_0_0_0_1_1_7, 0),
                     (self.sigfox_packet_sink_scapy_0_1_1_7, 0))
        self.connect((self.digital_diff_decoder_bb_0_0_0_1_1_8, 0),
                     (self.sigfox_packet_sink_scapy_0_1_1_8, 0))
        self.connect((self.digital_diff_decoder_bb_0_0_0_1_1_9, 0),
                     (self.sigfox_packet_sink_scapy_0_1_1_9, 0))
        self.connect((self.fir_filter_xxx_0, 0),
                     (self.digital_clock_recovery_mm_xx_0_0_1_1_7, 0))
        self.connect((self.fir_filter_xxx_0_0, 0),
                     (self.digital_clock_recovery_mm_xx_0_0_1_1_8, 0))
        self.connect((self.fir_filter_xxx_0_1, 0),
                     (self.digital_clock_recovery_mm_xx_0_0_1_1_9, 0))
        self.connect(
            (self.freq_xlating_fir_filter_xxx_0_1_7, 0),
            (self.digital_costas_loop_cc_0_0_0_0_0_0_0_1_2_1_1_1_7, 0))
        self.connect(
            (self.freq_xlating_fir_filter_xxx_0_1_8, 0),
            (self.digital_costas_loop_cc_0_0_0_0_0_0_0_1_2_1_1_1_8, 0))
        self.connect(
            (self.freq_xlating_fir_filter_xxx_0_1_9, 0),
            (self.digital_costas_loop_cc_0_0_0_0_0_0_0_1_2_1_1_1_9, 0))
示例#52
0
    def __init__(self, frame, panel, vbox, argv):
        stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)

        usage="%prog: [options] [input_filename]. \n If you don't specify an input filename the usrp will be used as source\n " \
              "Make sure your input capture file containes interleaved shorts not complex floats"
        parser = OptionParser(option_class=eng_option, usage=usage)
        parser.add_option("-a",
                          "--args",
                          type="string",
                          default="",
                          help="UHD device address args [default=%default]")
        parser.add_option("",
                          "--spec",
                          type="string",
                          default=None,
                          help="Subdevice of UHD device where appropriate")
        parser.add_option("-A",
                          "--antenna",
                          type="string",
                          default=None,
                          help="select Rx Antenna where appropriate")
        parser.add_option("-s",
                          "--samp-rate",
                          type="eng_float",
                          default=1e6,
                          help="set sample rate")
        parser.add_option("-f",
                          "--freq",
                          type="eng_float",
                          default=519.25e6,
                          help="set frequency to FREQ",
                          metavar="FREQ")
        parser.add_option("-g",
                          "--gain",
                          type="eng_float",
                          default=None,
                          help="set gain in dB (default is midpoint)")
        parser.add_option("-c",
                          "--contrast",
                          type="eng_float",
                          default=1.0,
                          help="set contrast (default is 1.0)")
        parser.add_option("-b",
                          "--brightness",
                          type="eng_float",
                          default=0.0,
                          help="set brightness (default is 0)")
        parser.add_option("-p",
                          "--pal",
                          action="store_true",
                          default=False,
                          help="PAL video format (this is the default)")
        parser.add_option("-n",
                          "--ntsc",
                          action="store_true",
                          default=False,
                          help="NTSC video format")
        parser.add_option(
            "-o",
            "--out-filename",
            type="string",
            default="sdl",
            help=
            "For example out_raw_uchar.gray. If you don't specify an output filename you will get a video_sink_sdl realtime output window. You then need to have gr-video-sdl installed)"
        )
        parser.add_option("-r",
                          "--repeat",
                          action="store_false",
                          default=True,
                          help="repeat file in a loop")
        parser.add_option("",
                          "--freq-min",
                          type="eng_float",
                          default=50.25e6,
                          help="Set a minimum frequency [default=%default]")
        parser.add_option("",
                          "--freq-max",
                          type="eng_float",
                          default=900.25e6,
                          help="Set a maximum frequency [default=%default]")

        (options, args) = parser.parse_args()
        if not ((len(args) == 1) or (len(args) == 0)):
            parser.print_help()
            sys.exit(1)

        if len(args) == 1:
            filename = args[0]
        else:
            filename = None

        self.frame = frame
        self.panel = panel

        self.contrast = options.contrast
        self.brightness = options.brightness
        self.state = "FREQ"
        self.freq = 0

        self.tv_freq_min = options.freq_min
        self.tv_freq_max = options.freq_max

        # build graph
        self.u = None

        if not (options.out_filename == "sdl"):
            options.repeat = False

        usrp_rate = options.samp_rate

        if not ((filename is None) or (filename == "usrp")):
            # file is data source
            self.filesource = blocks.file_source(gr.sizeof_short, filename,
                                                 options.repeat)
            self.istoc = blocks.interleaved_short_to_complex()
            self.connect(self.filesource, self.istoc)
            self.src = self.istoc

            options.gain = 0.0
            self.gain = 0.0

        else:  # use a UHD device
            self.u = uhd.usrp_source(device_addr=options.args,
                                     stream_args=uhd.stream_args('fc32'))

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

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

            self.u.set_samp_rate(usrp_rate)
            dev_rate = self.u.get_samp_rate()

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

            self.src = self.u

        self.gain = options.gain

        f2uc = blocks.float_to_uchar()

        # sdl window as final sink
        if not (options.pal or options.ntsc):
            options.pal = True  #set default to PAL

        if options.pal:
            lines_per_frame = 625.0
            frames_per_sec = 25.0
            show_width = 768

        elif options.ntsc:
            lines_per_frame = 525.0
            frames_per_sec = 29.97002997
            show_width = 640

        width = int(usrp_rate / (lines_per_frame * frames_per_sec))
        height = int(lines_per_frame)

        if (options.out_filename == "sdl"):
            #Here comes the tv screen, you have to build and install
            #gr-video-sdl for this (subproject of gnuradio, only in cvs
            #for now)
            try:
                video_sink = video_sdl.sink_uc(frames_per_sec, width, height,
                                               0, show_width, height)
            except:
                print "gr-video-sdl is not installed"
                print "realtime \"sdl\" video output window is not available"
                raise SystemExit, 1
            self.dst = video_sink
        else:
            print "You can use the imagemagick display tool to show the resulting imagesequence"
            print "use the following line to show the demodulated TV-signal:"
            print "display -depth 8 -size " +str(width)+ "x" + str(height) \
                + " gray:" + options.out_filename
            print "(Use the spacebar to advance to next frames)"
            options.repeat = False
            file_sink = blocks.file_sink(gr.sizeof_char, options.out_filename)
            self.dst = file_sink

        self.agc = analog.agc_cc(1e-7, 1.0, 1.0)  #1e-7
        self.am_demod = blocks.complex_to_mag()
        self.set_blacklevel = blocks.add_const_ff(0.0)
        self.invert_and_scale = blocks.multiply_const_ff(
            0.0)  #-self.contrast *128.0*255.0/(200.0)

        # now wire it all together
        #sample_rate=options.width*options.height*options.framerate

        process_type = 'do_no_sync'
        if process_type == 'do_no_sync':
            self.connect(self.src, self.agc, self.am_demod,
                         self.invert_and_scale, self.set_blacklevel, f2uc,
                         self.dst)
        elif process_type == 'do_tv_sync_adv':
            #defaults: gr.tv_sync_adv (double sampling_freq, unsigned
            #int tv_format,bool output_active_video_only=false, bool
            #do_invert=false, double wanted_black_level=0.0, double
            #wanted_white_level=255.0, double avg_alpha=0.1, double
            #initial_gain=1.0, double initial_offset=0.0,bool
            #debug=false)

            #note, this block is not yet in cvs
            self.tv_sync_adv = gr.tv_sync_adv(usrp_rate, 0, False, False, 0.0,
                                              255.0, 0.01, 1.0, 0.0, False)
            self.connect(self.src, self.am_demod, self.invert_and_scale,
                         self.tv_sync_adv, s2f, f2uc, self.dst)

        elif process_type == 'do_nullsink':
            #self.connect (self.src, self.am_demod,self.invert_and_scale,f2uc,video_sink)
            c2r = blocks.complex_to_real()
            nullsink = blocks.null_sink(gr.sizeof_float)
            self.connect(self.src, c2r, nullsink)  #video_sink)
        elif process_type == 'do_tv_sync_corr':
            frame_size = width * height  #int(usrp_rate/25.0)
            nframes = 10  # 32
            search_window = 20 * nframes
            debug = False
            video_alpha = 0.3  #0.1
            corr_alpha = 0.3

            #Note: this block is not yet in cvs
            tv_corr = gr.tv_correlator_ff(frame_size, nframes, search_window,
                                          video_alpha, corr_alpha, debug)
            shift = blocks.add_const_ff(-0.7)

            self.connect(self.src, self.agc, self.am_demod, tv_corr,
                         self.invert_and_scale, self.set_blacklevel, f2uc,
                         self.dst)
        else:  # process_type=='do_test_image':
            src_vertical_bars = analog.sig_source_f(usrp_rate,
                                                    analog.GR_SIN_WAVE,
                                                    10.0 * usrp_rate / 320,
                                                    255, 128)
            self.connect(src_vertical_bars, f2uc, self.dst)

        self._build_gui(vbox, usrp_rate, usrp_rate, usrp_rate)

        frange = self.u.get_freq_range()
        if (frange.start() > self.tv_freq_max
                or frange.stop() < self.tv_freq_min):
            sys.stderr.write(
                "Radio does not support required frequency range.\n")
            sys.exit(1)
        if (options.freq < self.tv_freq_min
                or options.freq > self.tv_freq_max):
            sys.stderr.write(
                "Requested frequency is outside of required frequency range.\n"
            )
            sys.exit(1)

        # set initial values
        self.set_gain(options.gain)
        self.set_contrast(self.contrast)
        self.set_brightness(options.brightness)
        if not (self.set_freq(options.freq)):
            self._set_status_msg("Failed to set initial frequency")
示例#53
0
    def __init__(self):
        gr.top_block.__init__(self, "Uhd Hf Am")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Uhd Hf Am")
        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_hf_am")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2.5e6
        self.rx_freq = rx_freq = 1.0e6
        self.fine_freq = fine_freq = 0
        self.coarse_freq = coarse_freq = 0
        self.volume = volume = 1
        self.usb_lsb = usb_lsb = -1
        self.ssb_am = ssb_am = 0
        self.selection = selection = ((1, 0, 0), (0, 1, 0), (0, 0, 1))
        self.pll_lbw = pll_lbw = 200
        self.pll_freq = pll_freq = 100
        self.lpf_cutoff = lpf_cutoff = 2e3
        self.interp = interp = 48
        self.freq_label = freq_label = rx_freq + fine_freq + coarse_freq
        self.decim = decim = samp_rate / 1e3
        self.decay_rate = decay_rate = 100e-6
        self.audio_ref = audio_ref = 1
        self.audio_max_gain = audio_max_gain = 1
        self.audio_gain = audio_gain = 1
        self.audio_decay = audio_decay = 100
        self.audio_attack = audio_attack = 1000

        ##################################################
        # Blocks
        ##################################################
        self._volume_range = Range(0, 100, .1, 1, 200)
        self._volume_win = RangeWidget(self._volume_range, self.set_volume,
                                       "volume", "counter_slider", float)
        self.top_grid_layout.addWidget(self._volume_win, 7, 0, 1, 4)
        for r in range(7, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._usb_lsb_options = (
            -1,
            1,
        )
        self._usb_lsb_labels = (
            'USB',
            'LSB',
        )
        self._usb_lsb_group_box = Qt.QGroupBox("usb_lsb")
        self._usb_lsb_box = Qt.QHBoxLayout()

        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)

            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)

        self._usb_lsb_button_group = variable_chooser_button_group()
        self._usb_lsb_group_box.setLayout(self._usb_lsb_box)
        for i, label in enumerate(self._usb_lsb_labels):
            radio_button = Qt.QRadioButton(label)
            self._usb_lsb_box.addWidget(radio_button)
            self._usb_lsb_button_group.addButton(radio_button, i)
        self._usb_lsb_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._usb_lsb_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._usb_lsb_options.index(i)))
        self._usb_lsb_callback(self.usb_lsb)
        self._usb_lsb_button_group.buttonClicked[int].connect(
            lambda i: self.set_usb_lsb(self._usb_lsb_options[i]))
        self.top_grid_layout.addWidget(self._usb_lsb_group_box, 5, 5, 1, 1)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(5, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._ssb_am_options = (
            0,
            1,
            2,
        )
        self._ssb_am_labels = (
            'SSB',
            'AM',
            'AM*',
        )
        self._ssb_am_group_box = Qt.QGroupBox("ssb_am")
        self._ssb_am_box = Qt.QHBoxLayout()

        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)

            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)

        self._ssb_am_button_group = variable_chooser_button_group()
        self._ssb_am_group_box.setLayout(self._ssb_am_box)
        for i, label in enumerate(self._ssb_am_labels):
            radio_button = Qt.QRadioButton(label)
            self._ssb_am_box.addWidget(radio_button)
            self._ssb_am_button_group.addButton(radio_button, i)
        self._ssb_am_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._ssb_am_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._ssb_am_options.index(i)))
        self._ssb_am_callback(self.ssb_am)
        self._ssb_am_button_group.buttonClicked[int].connect(
            lambda i: self.set_ssb_am(self._ssb_am_options[i]))
        self.top_grid_layout.addWidget(self._ssb_am_group_box, 4, 4, 1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_freq_range = Range(.2e6, 100e6, 100e3, 1.0e6, 200)
        self._rx_freq_win = RangeWidget(self._rx_freq_range, self.set_rx_freq,
                                        "rx_freq", "counter_slider", float)
        self.top_grid_layout.addWidget(self._rx_freq_win, 4, 0, 1, 4)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._pll_lbw_tool_bar = Qt.QToolBar(self)
        self._pll_lbw_tool_bar.addWidget(Qt.QLabel("pll_lbw" + ": "))
        self._pll_lbw_line_edit = Qt.QLineEdit(str(self.pll_lbw))
        self._pll_lbw_tool_bar.addWidget(self._pll_lbw_line_edit)
        self._pll_lbw_line_edit.returnPressed.connect(lambda: self.set_pll_lbw(
            eng_notation.str_to_num(
                str(self._pll_lbw_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._pll_lbw_tool_bar, 9, 7, 1, 1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(7, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._pll_freq_tool_bar = Qt.QToolBar(self)
        self._pll_freq_tool_bar.addWidget(Qt.QLabel("pll_freq" + ": "))
        self._pll_freq_line_edit = Qt.QLineEdit(str(self.pll_freq))
        self._pll_freq_tool_bar.addWidget(self._pll_freq_line_edit)
        self._pll_freq_line_edit.returnPressed.connect(
            lambda: self.set_pll_freq(
                eng_notation.str_to_num(
                    str(self._pll_freq_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._pll_freq_tool_bar, 9, 6, 1, 1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(6, 7):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._lpf_cutoff_options = (
            2e3,
            3e3,
            4e3,
            8e3,
        )
        self._lpf_cutoff_labels = (
            str(self._lpf_cutoff_options[0]),
            str(self._lpf_cutoff_options[1]),
            str(self._lpf_cutoff_options[2]),
            str(self._lpf_cutoff_options[3]),
        )
        self._lpf_cutoff_tool_bar = Qt.QToolBar(self)
        self._lpf_cutoff_tool_bar.addWidget(Qt.QLabel("lpf_cutoff" + ": "))
        self._lpf_cutoff_combo_box = Qt.QComboBox()
        self._lpf_cutoff_tool_bar.addWidget(self._lpf_cutoff_combo_box)
        for label in self._lpf_cutoff_labels:
            self._lpf_cutoff_combo_box.addItem(label)
        self._lpf_cutoff_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._lpf_cutoff_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._lpf_cutoff_options.index(i)))
        self._lpf_cutoff_callback(self.lpf_cutoff)
        self._lpf_cutoff_combo_box.currentIndexChanged.connect(
            lambda i: self.set_lpf_cutoff(self._lpf_cutoff_options[i]))
        self.top_grid_layout.addWidget(self._lpf_cutoff_tool_bar, 4, 5, 1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(5, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._fine_freq_range = Range(-1e3, 1e3, 1, 0, 200)
        self._fine_freq_win = RangeWidget(self._fine_freq_range,
                                          self.set_fine_freq, "fine_freq",
                                          "counter_slider", float)
        self.top_grid_layout.addWidget(self._fine_freq_win, 6, 0, 1, 4)
        for r in range(6, 7):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._decay_rate_options = (
            100e-6,
            65e-3,
            20e-3,
        )
        self._decay_rate_labels = (
            'Fast',
            'Medium',
            'Slow',
        )
        self._decay_rate_group_box = Qt.QGroupBox("decay_rate")
        self._decay_rate_box = Qt.QHBoxLayout()

        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)

            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)

        self._decay_rate_button_group = variable_chooser_button_group()
        self._decay_rate_group_box.setLayout(self._decay_rate_box)
        for i, label in enumerate(self._decay_rate_labels):
            radio_button = Qt.QRadioButton(label)
            self._decay_rate_box.addWidget(radio_button)
            self._decay_rate_button_group.addButton(radio_button, i)
        self._decay_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._decay_rate_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._decay_rate_options.index(i)))
        self._decay_rate_callback(self.decay_rate)
        self._decay_rate_button_group.buttonClicked[int].connect(
            lambda i: self.set_decay_rate(self._decay_rate_options[i]))
        self.top_grid_layout.addWidget(self._decay_rate_group_box, 4, 6, 1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(6, 7):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._coarse_freq_range = Range(-100e3, 100e3, 1, 0, 200)
        self._coarse_freq_win = RangeWidget(self._coarse_freq_range,
                                            self.set_coarse_freq,
                                            "coarse_freq", "counter_slider",
                                            float)
        self.top_grid_layout.addWidget(self._coarse_freq_win, 5, 0, 1, 4)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._audio_ref_tool_bar = Qt.QToolBar(self)
        self._audio_ref_tool_bar.addWidget(Qt.QLabel("audio_ref" + ": "))
        self._audio_ref_line_edit = Qt.QLineEdit(str(self.audio_ref))
        self._audio_ref_tool_bar.addWidget(self._audio_ref_line_edit)
        self._audio_ref_line_edit.returnPressed.connect(
            lambda: self.set_audio_ref(
                eng_notation.str_to_num(
                    str(self._audio_ref_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._audio_ref_tool_bar, 9, 3, 1, 1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._audio_max_gain_tool_bar = Qt.QToolBar(self)
        self._audio_max_gain_tool_bar.addWidget(
            Qt.QLabel("audio_max_gain" + ": "))
        self._audio_max_gain_line_edit = Qt.QLineEdit(str(self.audio_max_gain))
        self._audio_max_gain_tool_bar.addWidget(self._audio_max_gain_line_edit)
        self._audio_max_gain_line_edit.returnPressed.connect(
            lambda: self.set_audio_max_gain(
                eng_notation.str_to_num(
                    str(self._audio_max_gain_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._audio_max_gain_tool_bar, 9, 5, 1,
                                       1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(5, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._audio_gain_tool_bar = Qt.QToolBar(self)
        self._audio_gain_tool_bar.addWidget(Qt.QLabel("audio_gain" + ": "))
        self._audio_gain_line_edit = Qt.QLineEdit(str(self.audio_gain))
        self._audio_gain_tool_bar.addWidget(self._audio_gain_line_edit)
        self._audio_gain_line_edit.returnPressed.connect(
            lambda: self.set_audio_gain(
                eng_notation.str_to_num(
                    str(self._audio_gain_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._audio_gain_tool_bar, 9, 4, 1, 1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._audio_decay_tool_bar = Qt.QToolBar(self)
        self._audio_decay_tool_bar.addWidget(Qt.QLabel("audio_decay" + ": "))
        self._audio_decay_line_edit = Qt.QLineEdit(str(self.audio_decay))
        self._audio_decay_tool_bar.addWidget(self._audio_decay_line_edit)
        self._audio_decay_line_edit.returnPressed.connect(
            lambda: self.set_audio_decay(
                eng_notation.str_to_num(
                    str(self._audio_decay_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._audio_decay_tool_bar, 9, 2, 1, 1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._audio_attack_tool_bar = Qt.QToolBar(self)
        self._audio_attack_tool_bar.addWidget(Qt.QLabel("audio_attack" + ": "))
        self._audio_attack_line_edit = Qt.QLineEdit(str(self.audio_attack))
        self._audio_attack_tool_bar.addWidget(self._audio_attack_line_edit)
        self._audio_attack_line_edit.returnPressed.connect(
            lambda: self.set_audio_attack(
                eng_notation.str_to_num(
                    str(self._audio_attack_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._audio_attack_tool_bar, 9, 1, 1, 1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.uhd_usrp_source_1 = uhd.usrp_source(
            ",".join(("addr=192.168.10.2", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_1.set_clock_source('external', 0)
        self.uhd_usrp_source_1.set_time_source('external', 0)
        self.uhd_usrp_source_1.set_subdev_spec('A:AB', 0)
        self.uhd_usrp_source_1.set_samp_rate(samp_rate)
        self.uhd_usrp_source_1.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_source_1.set_center_freq(uhd.tune_request(rx_freq, ), 0)
        self.uhd_usrp_source_1.set_gain(0, 0)
        self.uhd_usrp_source_1.set_auto_dc_offset(True, 0)
        self.uhd_usrp_source_1.set_auto_iq_balance(True, 0)
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=4,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
            interpolation=200,
            decimation=int(samp_rate / 1e3),
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=interp,
            decimation=int(decim),
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate / decim * interp / 3,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 8, 0, 1,
                                       4)
        for r in range(8, 9):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_HORIZ, 1)
        self.qtgui_number_sink_0.set_update_time(0.010)
        self.qtgui_number_sink_0.set_title('')

        labels = ["RSSI", '', '', '', '', '', '', '', '', '']
        units = ['', '', '', '', '', '', '', '', '', '']
        colors = [("blue", "red"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_0.set_min(i, 0)
            self.qtgui_number_sink_0.set_max(i, 50)
            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, 5, 6, 1,
                                       1)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(6, 7):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim * interp / 3,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(0.0010)
        self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0.enable_grid(True)
        self.qtgui_freq_sink_x_0_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 6, 4,
                                       3, 2)
        for r in range(6, 9):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim * interp,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.010)
        self.qtgui_freq_sink_x_0.set_y_axis(-120, -10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(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 = ['pre-d', 'processed', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 4, 4,
                                       4)
        for r in range(0, 4):
            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_1 = filter.interp_fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate / decim * interp / 3, 1.5e3, 100,
                            firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            3,
            firdes.low_pass(1, samp_rate / decim * interp, lpf_cutoff, 100,
                            firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.interp_fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate / decim * interp / 3, 1.5e3, 100,
                            firdes.WIN_HAMMING, 6.76))
        self._freq_label_tool_bar = Qt.QToolBar(self)

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

        self._freq_label_tool_bar.addWidget(Qt.QLabel('Tuned Freq' + ": "))
        self._freq_label_label = Qt.QLabel(
            str(self._freq_label_formatter(self.freq_label)))
        self._freq_label_tool_bar.addWidget(self._freq_label_label)
        self.top_grid_layout.addWidget(self._freq_label_tool_bar, 5, 4, 1, 1)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            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(
            rx_freq, samp_rate / int(samp_rate / 1e3) * 200)
        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, 4,
                                       4)
        for r in range(0, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.blocks_multiply_xx_1_0 = 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_matrix_xx_0_0_0 = blocks.multiply_matrix_cc(
            (selection[ssb_am], ), gr.TPP_ALL_TO_ALL)
        self.blocks_multiply_matrix_xx_0 = blocks.multiply_matrix_ff(
            (selection[ssb_am], ), gr.TPP_ALL_TO_ALL)
        self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff(
            (100000, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff(
            (usb_lsb, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (volume, ))
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            1000, 1 / 1000.0, 4000, 1)
        self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.audio_sink_0 = audio.sink(16000, '', True)
        self.analog_sig_source_x_0_0_0 = analog.sig_source_f(
            samp_rate / decim * interp / 3, analog.GR_SIN_WAVE, 1.5e3, 1, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(
            samp_rate / decim * interp / 3, analog.GR_COS_WAVE, 1.5e3, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -1 * (fine_freq + coarse_freq), 1,
            0)
        self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc(
            math.pi / pll_lbw, math.pi / pll_freq, -math.pi / pll_freq)
        self.analog_agc2_xx_0_0 = analog.agc2_ff(audio_attack, audio_decay,
                                                 audio_ref, audio_gain)
        self.analog_agc2_xx_0_0.set_max_gain(audio_max_gain)
        self.analog_agc2_xx_0 = analog.agc2_cc(0.1, decay_rate, .3, 1000)
        self.analog_agc2_xx_0.set_max_gain(65000)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.analog_agc2_xx_0_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_pll_carriertracking_cc_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.analog_pll_carriertracking_cc_0, 0),
                     (self.blocks_multiply_matrix_xx_0_0_0, 2))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.analog_sig_source_x_0_0_0, 0),
                     (self.blocks_multiply_xx_1_0, 1))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_multiply_matrix_xx_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.low_pass_filter_0_1, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_multiply_matrix_xx_0, 2))
        self.connect((self.blocks_complex_to_real_0_0, 0),
                     (self.blocks_multiply_matrix_xx_0, 1))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_multiply_const_vxx_1_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_multiply_matrix_xx_0, 0),
                     (self.analog_agc2_xx_0_0, 0))
        self.connect((self.blocks_multiply_matrix_xx_0_0_0, 0),
                     (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.blocks_multiply_matrix_xx_0_0_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_1_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.analog_pll_carriertracking_cc_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_complex_to_real_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_multiply_matrix_xx_0_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_multiply_matrix_xx_0_0_0, 1))
        self.connect((self.low_pass_filter_0_1, 0),
                     (self.blocks_multiply_xx_1_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.fosphor_qt_sink_c_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.uhd_usrp_source_1, 0), (self.analog_agc2_xx_0, 0))
示例#54
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(
            self, title="Stereo FM receiver and RDS Decoder")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.freq_offset = freq_offset = 250000
        self.freq = freq = 95.8e6
        self.volume = volume = -3
        self.samp_rate = samp_rate = 1e6
        self.gain = gain = 20
        self.freq_tune = freq_tune = freq - freq_offset
        self.capture_base_freq = capture_base_freq = 88e6

        ##################################################
        # Blocks
        ##################################################
        _volume_sizer = wx.BoxSizer(wx.VERTICAL)
        self._volume_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_volume_sizer,
            value=self.volume,
            callback=self.set_volume,
            label='Volume',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._volume_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_volume_sizer,
            value=self.volume,
            callback=self.set_volume,
            minimum=-20,
            maximum=10,
            num_steps=300,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_volume_sizer, 0, 1, 1, 1)
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "BB")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Demod")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Waterfall")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "L+R")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "L-R")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Const")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "x")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "y")
        self.GridAdd(self.nb, 2, 0, 1, 2)
        _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=88e6,
            maximum=108e6,
            num_steps=800,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_freq_sizer, 1, 0, 1, 2)
        self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c(
            self.nb.GetPage(8).GetWin(),
            baseband_freq=0,
            dynamic_range=100,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=512,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='Waterfall Plot',
        )
        self.nb.GetPage(8).Add(self.wxgui_waterfallsink2_1.win)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_f(
            self.nb.GetPage(2).GetWin(),
            baseband_freq=0,
            dynamic_range=100,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=250000,
            fft_size=512,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='Waterfall Plot',
        )
        self.nb.GetPage(2).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_c(
            self.nb.GetPage(6).GetWin(),
            title='Scope Plot',
            sample_rate=2375 * 4,
            v_scale=0.4,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=True,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.nb.GetPage(6).Add(self.wxgui_scopesink2_1.win)
        self.wxgui_fftsink2_1 = fftsink2.fft_sink_c(
            self.nb.GetPage(7).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='FFT Plot',
            peak_hold=False,
        )
        self.nb.GetPage(7).Add(self.wxgui_fftsink2_1.win)
        self.wxgui_fftsink2_0_0_0_1_0_1 = fftsink2.fft_sink_c(
            self.nb.GetPage(5).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=19000,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='RDS',
            peak_hold=False,
        )
        self.nb.GetPage(5).Add(self.wxgui_fftsink2_0_0_0_1_0_1.win)
        self.wxgui_fftsink2_0_0_0_1 = fftsink2.fft_sink_f(
            self.nb.GetPage(4).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=48000,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='L-R',
            peak_hold=False,
        )
        self.nb.GetPage(4).Add(self.wxgui_fftsink2_0_0_0_1.win)
        self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_f(
            self.nb.GetPage(3).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=48000,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='L+R',
            peak_hold=False,
        )
        self.nb.GetPage(3).Add(self.wxgui_fftsink2_0_0_0.win)
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_f(
            self.nb.GetPage(1).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=250000,
            fft_size=1024,
            fft_rate=15,
            average=True,
            avg_alpha=0.8,
            title='FM Demod',
            peak_hold=False,
        )
        self.nb.GetPage(1).Add(self.wxgui_fftsink2_0_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.nb.GetPage(0).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=-30,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=True,
            avg_alpha=0.8,
            title='Baseband',
            peak_hold=False,
        )
        self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win)
        self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(
            2, firdes.root_raised_cosine(1, 19000, 2375, .35, 100))
        self.pfb_arb_resampler_xxx_1 = pfb.arb_resampler_fff(240000.0 / 250000,
                                                             taps=None,
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_1.declare_sample_delay(0)

        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(19000 / 250e3,
                                                             taps=None,
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.gr_rds_parser_0 = rds.parser(True, False, 0)
        self.gr_rds_panel_0 = rds.rdsPanel(freq, self.GetWin())
        self.Add(self.gr_rds_panel_0.panel)
        self.gr_rds_decoder_0 = rds.decoder(False, False)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            label='RF Gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            minimum=0,
            maximum=49.6,
            num_steps=124,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_gain_sizer, 0, 0, 1, 1)
        self.freq_xlating_fir_filter_xxx_2 = filter.freq_xlating_fir_filter_fcf(
            5, (firdes.low_pass(1.0, 240000, 13e3, 3e3, firdes.WIN_HAMMING)),
            38000, 240000)
        self.freq_xlating_fir_filter_xxx_1_0 = filter.freq_xlating_fir_filter_fcc(
            1,
            (firdes.low_pass(2500.0, 250000, 2.6e3, 2e3, firdes.WIN_HAMMING)),
            57e3, 250000)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (firdes.low_pass(1, samp_rate, 80000, 20000)), freq_offset,
            samp_rate)
        self.fir_filter_xxx_1 = filter.fir_filter_fff(
            5, (firdes.low_pass(1.0, 240000, 13e3, 3e3, firdes.WIN_HAMMING)))
        self.fir_filter_xxx_1.declare_sample_delay(0)
        self.digital_psk_demod_0 = digital.psk.psk_demod(
            constellation_points=2,
            differential=False,
            samples_per_symbol=4,
            excess_bw=0.35,
            phase_bw=6.28 / 100.0,
            timing_bw=6.28 / 100.0,
            mod_code="gray",
            verbose=False,
            log=False,
        )
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff(
            (10**(1. * (volume) / 10), ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (10**(1. * (volume) / 10), ))
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(
            gr.sizeof_char * 1, 2)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            '/home/deepstar/Projects/OverTheWire/advent2019/advent2019/steven/northpole-airwaves/northpole-airwaves.wav',
            True)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=samp_rate,
            audio_decimation=int(samp_rate / (250e3)),
        )
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, freq - capture_base_freq, 1, 0)
        self.analog_fm_deemph_0_0_0 = analog.fm_deemph(fs=48000, tau=75e-6)
        self.analog_fm_deemph_0_0 = analog.fm_deemph(fs=48000, tau=75e-6)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.gr_rds_decoder_0, 'out'),
                         (self.gr_rds_parser_0, 'in'))
        self.msg_connect((self.gr_rds_parser_0, 'out'),
                         (self.gr_rds_panel_0, 'in'))
        self.connect((self.analog_fm_deemph_0_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.analog_fm_deemph_0_0_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.freq_xlating_fir_filter_xxx_1_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.pfb_arb_resampler_xxx_1, 0))
        self.connect((self.analog_wfm_rcv_0, 0), (self.wxgui_fftsink2_0_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.analog_fm_deemph_0_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.wxgui_fftsink2_0_0_0_1, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.audio_sink_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.wxgui_fftsink2_1, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.wxgui_waterfallsink2_1, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.analog_fm_deemph_0_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.gr_rds_decoder_0, 0))
        self.connect((self.digital_psk_demod_0, 0),
                     (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.fir_filter_xxx_1, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.fir_filter_xxx_1, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.fir_filter_xxx_1, 0),
                     (self.wxgui_fftsink2_0_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_wfm_rcv_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.wxgui_fftsink2_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_1_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_2, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.root_raised_cosine_filter_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.wxgui_fftsink2_0_0_0_1_0_1, 0))
        self.connect((self.pfb_arb_resampler_xxx_1, 0),
                     (self.fir_filter_xxx_1, 0))
        self.connect((self.pfb_arb_resampler_xxx_1, 0),
                     (self.freq_xlating_fir_filter_xxx_2, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.digital_psk_demod_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.wxgui_scopesink2_1, 0))
示例#55
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        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.vec_length = vec_length = 65536
        self.sinc_sample_locations = sinc_sample_locations = np.arange(-np.pi*4/2.0, np.pi*4/2.0, np.pi/vec_length)
        self.timenow = timenow = datetime.now().strftime("%Y-%m-%d_%H.%M.%S")
        self.sinc = sinc = np.sinc(sinc_sample_locations/np.pi)
        self.prefix = prefix = "/Users/kbandura/grc_data/"
        self.samp_rate = samp_rate = 2.4e6
        self.recfile = recfile = prefix + timenow + ".h5"
        self.integration_time = integration_time = 2
        self.freq = freq = 1420.5e6
        self.display_integration = display_integration = 0.5
        self.custom_window = custom_window = sinc*np.hamming(4*vec_length)

        ##################################################
        # Blocks
        ##################################################
        self.radio_astro_hdf5_sink_1 = radio_astro.hdf5_sink(vec_length, recfile, 'testing', freq - samp_rate/2, samp_rate/vec_length, 'testing')
        self.qtgui_vector_sink_f_0 = qtgui.vector_sink_f(
            vec_length,
            freq - samp_rate/2,
            samp_rate/vec_length,
            "Frequency",
            "PSD",
            "Spectrum",
            1 # Number of inputs
        )
        self.qtgui_vector_sink_f_0.set_update_time(0.10)
        self.qtgui_vector_sink_f_0.set_y_axis(0, 3000)
        self.qtgui_vector_sink_f_0.enable_autoscale(True)
        self.qtgui_vector_sink_f_0.enable_grid(True)
        self.qtgui_vector_sink_f_0.set_x_axis_units("Hz")
        self.qtgui_vector_sink_f_0.set_y_axis_units("arb")
        self.qtgui_vector_sink_f_0.set_ref_level(0)

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

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

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

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

        if not True:
          self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.fft_vxx_0 = fft.fft_vcc(vec_length, True, (window.rectangular(vec_length)), True, 1)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float*1, vec_length)
        self.blocks_stream_to_vector_0_2 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, vec_length)
        self.blocks_stream_to_vector_0_1 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, vec_length)
        self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, vec_length)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, vec_length)
        self.blocks_nlog10_ff_0_0 = blocks.nlog10_ff(10, vec_length, 0)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_multiply_const_vxx_0_2 = blocks.multiply_const_vcc((custom_window[-vec_length:]))
        self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vcc((custom_window[2*vec_length:3*vec_length]))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((custom_window[vec_length:2*vec_length]))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((custom_window[0:vec_length]))
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(vec_length)
        self.blocks_integrate_xx_0_0 = blocks.integrate_ff(int(display_integration*samp_rate/vec_length), vec_length)
        self.blocks_integrate_xx_0 = blocks.integrate_ff(int((integration_time)*samp_rate/vec_length)/int(display_integration*samp_rate/vec_length), vec_length)
        self.blocks_delay_0_0_0_0 = blocks.delay(gr.sizeof_gr_complex*1, 3*vec_length)
        self.blocks_delay_0_0_0 = blocks.delay(gr.sizeof_gr_complex*1, 2*vec_length)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex*1, vec_length)
        self.blocks_complex_to_real_0_0 = blocks.complex_to_real(vec_length)
        self.blocks_add_xx_0 = blocks.add_vcc(vec_length)
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, 1, 0, 8192)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_delay_0_0, 0))
        self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_delay_0_0_0, 0))
        self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_delay_0_0_0_0, 0))
        self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_complex_to_real_0_0, 0), (self.blocks_integrate_xx_0_0, 0))
        self.connect((self.blocks_delay_0_0, 0), (self.blocks_stream_to_vector_0_0, 0))
        self.connect((self.blocks_delay_0_0_0, 0), (self.blocks_stream_to_vector_0_2, 0))
        self.connect((self.blocks_delay_0_0_0_0, 0), (self.blocks_stream_to_vector_0_1, 0))
        self.connect((self.blocks_integrate_xx_0, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_integrate_xx_0, 0), (self.radio_astro_hdf5_sink_1, 0))
        self.connect((self.blocks_integrate_xx_0_0, 0), (self.blocks_integrate_xx_0, 0))
        self.connect((self.blocks_integrate_xx_0_0, 0), (self.blocks_nlog10_ff_0_0, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_real_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 3))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_xx_0, 2))
        self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0_2, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_nlog10_ff_0_0, 0), (self.qtgui_vector_sink_f_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_multiply_const_vxx_0_2, 0))
        self.connect((self.blocks_stream_to_vector_0_0, 0), (self.blocks_multiply_const_vxx_0_1, 0))
        self.connect((self.blocks_stream_to_vector_0_1, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_stream_to_vector_0_2, 0), (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_nlog10_ff_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_multiply_conjugate_cc_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_multiply_conjugate_cc_0, 1))
示例#56
0
文件: chu.py 项目: artemies/gr-ham
    def __init__(self):
        gr.top_block.__init__(self, "Chu")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Chu")
        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", "chu")

        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 = 1200000
        self.upconverter_lo_freq = upconverter_lo_freq = 0
        self.space_tone = space_tone = 2025
        self.offset = offset = 100000
        self.mark_tone = mark_tone = 2225
        self.gain = gain = 10
        self.decimation = decimation = samp_rate // 48000
        self.chu_freq = chu_freq = 3330000
        self.channel_rate = channel_rate = 4800

        ##################################################
        # Blocks
        ##################################################
        self._gain_range = Range(0, 50, 0.4, 10, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain,
                                     'RX gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._gain_win)
        self.root_raised_cosine_filter_0 = filter.fir_filter_fff(
            1, firdes.root_raised_cosine(1, channel_rate, 300, 0.35, 100))
        self.qtgui_waterfall_sink_x_1 = qtgui.waterfall_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_1.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_1.enable_grid(False)
        self.qtgui_waterfall_sink_x_1.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_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_1.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_1.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_1.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_1_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_1_win)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.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.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

        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(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_grid_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.osmosdr_source_1 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "")
        self.osmosdr_source_1.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_source_1.set_sample_rate(samp_rate)
        self.osmosdr_source_1.set_center_freq(
            chu_freq - offset + upconverter_lo_freq, 0)
        self.osmosdr_source_1.set_freq_corr(0, 0)
        self.osmosdr_source_1.set_gain(gain, 0)
        self.osmosdr_source_1.set_if_gain(20, 0)
        self.osmosdr_source_1.set_bb_gain(20, 0)
        self.osmosdr_source_1.set_antenna('', 0)
        self.osmosdr_source_1.set_bandwidth(0, 0)
        self.low_pass_filter_1 = filter.fir_filter_ccf(
            10,
            firdes.low_pass(1000, samp_rate / 25, 200, 50, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            decimation,
            firdes.low_pass(1, samp_rate, 20000, 5000, firdes.WIN_HAMMING,
                            6.76))
        self.ham_chu_decode_0 = ham.chu_decode()
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_multiply_xx_2 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 0.5)
        self.blocks_add_const_vxx_0 = blocks.add_const_ff(-1)
        self.band_pass_filter_0 = filter.fir_filter_ccc(
            1,
            firdes.complex_band_pass(1, samp_rate / decimation, 200, 2800, 200,
                                     firdes.WIN_HAMMING, 6.76))
        self.audio_sink_0_0 = audio.sink(48000, '', True)
        self.analog_sig_source_x_1 = analog.sig_source_c(
            samp_rate / decimation, analog.GR_COS_WAVE,
            -(space_tone + mark_tone) / 2, 1, 0, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -offset, 1, 0, 0)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            channel_rate / (3.1416 * (mark_tone - space_tone)))
        self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc(
            3.1416 / 500, 1.8, -1.8)
        self.analog_agc_xx_0 = analog.agc_ff(1e-1, 0.02, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0), (self.audio_sink_0_0, 0))
        self.connect((self.analog_pll_carriertracking_cc_0, 0),
                     (self.band_pass_filter_0, 0))
        self.connect((self.analog_pll_carriertracking_cc_0, 0),
                     (self.blocks_multiply_xx_2, 0))
        self.connect((self.analog_pll_carriertracking_cc_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.root_raised_cosine_filter_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_multiply_xx_2, 1))
        self.connect((self.band_pass_filter_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.analog_agc_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_multiply_xx_2, 0),
                     (self.low_pass_filter_1, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.ham_chu_decode_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.analog_pll_carriertracking_cc_0, 0))
        self.connect((self.low_pass_filter_1, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.low_pass_filter_1, 0),
                     (self.qtgui_waterfall_sink_x_1, 0))
        self.connect((self.osmosdr_source_1, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
示例#57
0
def complex_to_real(N):
    op = blocks.complex_to_real()
    tb = helper(N, op, gr.sizeof_gr_complex, gr.sizeof_float, 1, 1)
    return tb
示例#58
0
    def __init__(self):
        gr.top_block.__init__(self, "Random Fec Fam")

        ##################################################
        # Variables
        ##################################################
        self.rate = rate = 2
        self.polys = polys = [109, 79]
        self.k = k = 7
        self.frame_size = frame_size = 500
        self.Np = Np = 32
        self.snr_db = snr_db = 10
        self.samp_rate = samp_rate = 100000
        self.puncpat = puncpat = '11'


        self.enc_cc = enc_cc = fec.cc_encoder_make(frame_size*8, k, rate, (polys), 0, fec.CC_TERMINATED, False)


        self.const = const = digital.constellation_16qam().base()

        self.P = P = 256
        self.L = L = Np/4

        ##################################################
        # Blocks
        ##################################################
        self.specest_cyclo_fam_0 = specest.cyclo_fam(Np, P, Np/4)
        self.random = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 10000)), True)
        self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(4, (firdes.low_pass_2(1, 1, 1/8.0, 1/16.0, 80)))
        self.interp_fir_filter_xxx_0.declare_sample_delay(0)
        self.fec_extended_encoder_0_0_0 = fec.extended_encoder(encoder_obj_list=enc_cc, threading= None, puncpat=puncpat)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((const.points()), 1)
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage=10.0**(-snr_db/20.0),
        	frequency_offset=0.0,
        	epsilon=1.0,
        	taps=(1.0, ),
        	noise_seed=0,
        	block_tags=False
        )
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(1, int(np.log2(const.arity())), "", False, gr.GR_MSB_FIRST)
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_float*1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*2*Np)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, samp_rate/4, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.specest_cyclo_fam_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.channels_channel_model_0, 0))
        self.connect((self.blocks_null_source_0, 0), (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.channels_channel_model_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.interp_fir_filter_xxx_0, 0))
        self.connect((self.fec_extended_encoder_0_0_0, 0), (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.random, 0), (self.fec_extended_encoder_0_0_0, 0))
        self.connect((self.specest_cyclo_fam_0, 0), (self.blocks_null_sink_0, 0))
示例#59
0
    def __init__(self, subdev="A:0", devid="addr=192.168.10.2", frequency=1.4125e9, fftsize=8192):
        grc_wxgui.top_block_gui.__init__(self, title="Total Power Radiometer - N200")

        ##################################################
        # Parameters
        ##################################################
        self.subdev = subdev
        self.devid = devid
        self.frequency = frequency
        self.fftsize = fftsize

        ##################################################
        # Variables
        ##################################################
        self.GUI_samp_rate = GUI_samp_rate = 10e6
        self.samp_rate = samp_rate = int(GUI_samp_rate)
        self.prefix = prefix = "tpr_"
        self.text_samp_rate = text_samp_rate = GUI_samp_rate
        self.text_deviceID = text_deviceID = subdev
        self.text_Device_addr = text_Device_addr = devid
        self.spec_data_fifo = spec_data_fifo = "spectrum_" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat"
        self.spavg = spavg = 1
        self.scope_rate = scope_rate = 2
        self.recfile_tpr = recfile_tpr = prefix + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat"
        self.recfile_kelvin = recfile_kelvin = prefix+"kelvin" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat"
        self.rec_button_tpr = rec_button_tpr = 1
        self.rec_button_iq = rec_button_iq = 1
        self.noise_amplitude = noise_amplitude = .5
        self.integ = integ = 2
        self.gain = gain = 26
        self.freq = freq = frequency
        self.file_rate = file_rate = 2.0
        self.fftrate = fftrate = int(samp_rate/fftsize)
        self.det_rate = det_rate = int(20.0)
        self.dc_gain = dc_gain = 1
        self.calib_2 = calib_2 = -342.774
        self.calib_1 = calib_1 = 4.0755e3
        self.add_noise = add_noise = 0

        ##################################################
        # Blocks
        ##################################################
        self.Main = self.Main = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.Main.AddPage(grc_wxgui.Panel(self.Main), "N200 Control Panel")
        self.Main.AddPage(grc_wxgui.Panel(self.Main), "TPR Measurements")
        self.Add(self.Main)
        _spavg_sizer = wx.BoxSizer(wx.VERTICAL)
        self._spavg_text_box = forms.text_box(
        	parent=self.Main.GetPage(0).GetWin(),
        	sizer=_spavg_sizer,
        	value=self.spavg,
        	callback=self.set_spavg,
        	label="Spectral Averaging (Seconds)",
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._spavg_slider = forms.slider(
        	parent=self.Main.GetPage(0).GetWin(),
        	sizer=_spavg_sizer,
        	value=self.spavg,
        	callback=self.set_spavg,
        	minimum=1,
        	maximum=20,
        	num_steps=20,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Main.GetPage(0).GridAdd(_spavg_sizer, 1, 1, 1, 1)
        self._rec_button_tpr_chooser = forms.button(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.rec_button_tpr,
        	callback=self.set_rec_button_tpr,
        	label="Record TPR Data",
        	choices=[0,1],
        	labels=['Stop','Start'],
        )
        self.Main.GetPage(0).GridAdd(self._rec_button_tpr_chooser, 4, 1, 1, 1)
        self._rec_button_iq_chooser = forms.button(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.rec_button_iq,
        	callback=self.set_rec_button_iq,
        	label="Record I/Q Data",
        	choices=[0,1],
        	labels=['Stop','Start'],
        )
        self.Main.GetPage(0).GridAdd(self._rec_button_iq_chooser, 4, 0, 1, 1)
        _integ_sizer = wx.BoxSizer(wx.VERTICAL)
        self._integ_text_box = forms.text_box(
        	parent=self.Main.GetPage(0).GetWin(),
        	sizer=_integ_sizer,
        	value=self.integ,
        	callback=self.set_integ,
        	label="Integration Time (Seconds)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._integ_slider = forms.slider(
        	parent=self.Main.GetPage(0).GetWin(),
        	sizer=_integ_sizer,
        	value=self.integ,
        	callback=self.set_integ,
        	minimum=1,
        	maximum=60,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Main.GetPage(0).GridAdd(_integ_sizer, 0, 2, 1, 1)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
        	parent=self.Main.GetPage(0).GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	label="RF Gain (dB)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._gain_slider = forms.slider(
        	parent=self.Main.GetPage(0).GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	minimum=0,
        	maximum=50,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Main.GetPage(0).GridAdd(_gain_sizer, 0, 1, 1, 1)
        self._freq_text_box = forms.text_box(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label="Center Frequency (Hz)",
        	converter=forms.float_converter(),
        )
        self.Main.GetPage(0).GridAdd(self._freq_text_box, 0, 0, 1, 1)
        self._dc_gain_chooser = forms.radio_buttons(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.dc_gain,
        	callback=self.set_dc_gain,
        	label="DC Gain",
        	choices=[1, 10, 100, 1000, 10000],
        	labels=[],
        	style=wx.RA_HORIZONTAL,
        )
        self.Main.GetPage(0).GridAdd(self._dc_gain_chooser, 1, 0, 1, 1)
        self._calib_2_text_box = forms.text_box(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.calib_2,
        	callback=self.set_calib_2,
        	label="Calibration value 2",
        	converter=forms.float_converter(),
        )
        self.Main.GetPage(0).GridAdd(self._calib_2_text_box, 3, 1, 1, 1)
        self._calib_1_text_box = forms.text_box(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.calib_1,
        	callback=self.set_calib_1,
        	label="Calibration value 1",
        	converter=forms.float_converter(),
        )
        self.Main.GetPage(0).GridAdd(self._calib_1_text_box, 3, 0, 1, 1)
        self._GUI_samp_rate_chooser = forms.radio_buttons(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.GUI_samp_rate,
        	callback=self.set_GUI_samp_rate,
        	label="Sample Rate (BW)",
        	choices=[1e6,2e6,5e6,10e6,25e6],
        	labels=['1 MHz','2 MHz','5 MHz','10 MHz','25 MHz'],
        	style=wx.RA_HORIZONTAL,
        )
        self.Main.GetPage(0).GridAdd(self._GUI_samp_rate_chooser, 1, 3, 1, 1)
        self.wxgui_scopesink2_2 = scopesink2.scope_sink_f(
        	self.Main.GetPage(1).GetWin(),
        	title="Total Power",
        	sample_rate=2,
        	v_scale=.1,
        	v_offset=0,
        	t_scale=100,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_STRIPCHART,
        	y_axis_label="power level",
        )
        self.Main.GetPage(1).Add(self.wxgui_scopesink2_2.win)
        self.wxgui_numbersink2_2 = numbersink2.number_sink_f(
        	self.GetWin(),
        	unit="Units",
        	minval=0,
        	maxval=1,
        	factor=1.0,
        	decimal_places=10,
        	ref_level=0,
        	sample_rate=GUI_samp_rate,
        	number_rate=15,
        	average=False,
        	avg_alpha=None,
        	label="Number Plot",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_2.win)
        self.wxgui_numbersink2_0_0 = numbersink2.number_sink_f(
        	self.Main.GetPage(1).GetWin(),
        	unit="",
        	minval=0,
        	maxval=.2,
        	factor=1,
        	decimal_places=6,
        	ref_level=0,
        	sample_rate=scope_rate,
        	number_rate=15,
        	average=True,
        	avg_alpha=.01,
        	label="Raw Power level",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.Main.GetPage(1).Add(self.wxgui_numbersink2_0_0.win)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
        	self.Main.GetPage(1).GetWin(),
        	unit="Kelvin",
        	minval=0,
        	maxval=400,
        	factor=1,
        	decimal_places=6,
        	ref_level=0,
        	sample_rate=scope_rate,
        	number_rate=15,
        	average=False,
        	avg_alpha=None,
        	label="Calibrated Temperature",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.Main.GetPage(1).Add(self.wxgui_numbersink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.Main.GetPage(0).GetWin(),
        	baseband_freq=freq,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=20,
        	ref_scale=2.0,
        	sample_rate=GUI_samp_rate,
        	fft_size=1024,
        	fft_rate=5,
        	average=True,
        	avg_alpha=0.1,
        	title="Spectrum",
        	peak_hold=False,
        	size=(800,400),
        )
        self.Main.GetPage(0).Add(self.wxgui_fftsink2_0.win)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join((devid, "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(GUI_samp_rate)
        self.uhd_usrp_source_0.set_center_freq(freq, 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        (self.uhd_usrp_source_0).set_processor_affinity([0])
        self._text_samp_rate_static_text = forms.static_text(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.text_samp_rate,
        	callback=self.set_text_samp_rate,
        	label="Samp rate",
        	converter=forms.float_converter(),
        )
        self.Main.GetPage(0).GridAdd(self._text_samp_rate_static_text, 2, 0, 1, 1)
        self._text_deviceID_static_text = forms.static_text(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.text_deviceID,
        	callback=self.set_text_deviceID,
        	label="SubDev",
        	converter=forms.str_converter(),
        )
        self.Main.GetPage(0).GridAdd(self._text_deviceID_static_text, 2, 1, 1, 1)
        self._text_Device_addr_static_text = forms.static_text(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.text_Device_addr,
        	callback=self.set_text_Device_addr,
        	label="Device Address",
        	converter=forms.str_converter(),
        )
        self.Main.GetPage(0).GridAdd(self._text_Device_addr_static_text, 2, 2, 1, 1)
        self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(1.0/((samp_rate*integ)/2.0), 1)
        (self.single_pole_iir_filter_xx_0).set_processor_affinity([1])
        _noise_amplitude_sizer = wx.BoxSizer(wx.VERTICAL)
        self._noise_amplitude_text_box = forms.text_box(
        	parent=self.Main.GetPage(0).GetWin(),
        	sizer=_noise_amplitude_sizer,
        	value=self.noise_amplitude,
        	callback=self.set_noise_amplitude,
        	label='noise_amplitude',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._noise_amplitude_slider = forms.slider(
        	parent=self.Main.GetPage(0).GetWin(),
        	sizer=_noise_amplitude_sizer,
        	value=self.noise_amplitude,
        	callback=self.set_noise_amplitude,
        	minimum=.01,
        	maximum=1,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Main.GetPage(0).GridAdd(_noise_amplitude_sizer, 3, 2, 1, 1)
        self.logpwrfft_x_0 = logpwrfft.logpwrfft_c(
        	sample_rate=samp_rate,
        	fft_size=fftsize,
        	ref_scale=2,
        	frame_rate=fftrate,
        	avg_alpha=1.0/float(spavg*fftrate),
        	average=True,
        )
        self.blocks_peak_detector_xb_0 = blocks.peak_detector_fb(0.25, 0.40, 10, 0.001)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((calib_1, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((dc_gain, ))
        self.blocks_keep_one_in_n_4 = blocks.keep_one_in_n(gr.sizeof_float*1, samp_rate/det_rate)
        self.blocks_keep_one_in_n_3 = blocks.keep_one_in_n(gr.sizeof_float*fftsize, fftrate)
        self.blocks_keep_one_in_n_1 = blocks.keep_one_in_n(gr.sizeof_float*1, int(det_rate/file_rate))
        self.blocks_file_sink_5 = blocks.file_sink(gr.sizeof_float*fftsize, spec_data_fifo, False)
        self.blocks_file_sink_5.set_unbuffered(True)
        self.blocks_file_sink_4 = blocks.file_sink(gr.sizeof_float*1, recfile_tpr, False)
        self.blocks_file_sink_4.set_unbuffered(True)
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_gr_complex*1, prefix+"iq_raw" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat", False)
        self.blocks_file_sink_1.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, recfile_kelvin, False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_mag_squared_1 = blocks.complex_to_mag_squared(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.blocks_add_const_vxx_1 = blocks.add_const_vff((calib_2, ))
        self.blks2_valve_2 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(rec_button_iq))
        self.blks2_valve_1 = grc_blks2.valve(item_size=gr.sizeof_float*1, open=bool(0))
        self.blks2_valve_0 = grc_blks2.valve(item_size=gr.sizeof_float*1, open=bool(rec_button_tpr))
        self._add_noise_chooser = forms.button(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.add_noise,
        	callback=self.set_add_noise,
        	label="Noise Source",
        	choices=[0,1],
        	labels=['Off','On'],
        )
        self.Main.GetPage(0).GridAdd(self._add_noise_chooser, 3, 3, 1, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_valve_0, 0), (self.blocks_file_sink_4, 0))    
        self.connect((self.blks2_valve_1, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.blks2_valve_2, 0), (self.blocks_file_sink_1, 0))    
        self.connect((self.blocks_add_const_vxx_1, 0), (self.blks2_valve_1, 0))    
        self.connect((self.blocks_add_const_vxx_1, 0), (self.wxgui_numbersink2_0, 0))    
        self.connect((self.blocks_char_to_float_0, 0), (self.wxgui_numbersink2_2, 0))    
        self.connect((self.blocks_complex_to_mag_squared_1, 0), (self.single_pole_iir_filter_xx_0, 0))    
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_peak_detector_xb_0, 0))    
        self.connect((self.blocks_keep_one_in_n_1, 0), (self.blks2_valve_0, 0))    
        self.connect((self.blocks_keep_one_in_n_1, 0), (self.blocks_multiply_const_vxx_1, 0))    
        self.connect((self.blocks_keep_one_in_n_1, 0), (self.wxgui_scopesink2_2, 0))    
        self.connect((self.blocks_keep_one_in_n_3, 0), (self.blocks_file_sink_5, 0))    
        self.connect((self.blocks_keep_one_in_n_4, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_keep_one_in_n_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_numbersink2_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_const_vxx_1, 0))    
        self.connect((self.blocks_peak_detector_xb_0, 0), (self.blocks_char_to_float_0, 0))    
        self.connect((self.logpwrfft_x_0, 0), (self.blocks_keep_one_in_n_3, 0))    
        self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_keep_one_in_n_4, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blks2_valve_2, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_mag_squared_1, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_real_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.logpwrfft_x_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0))    
示例#60
0
    def __init__(self,
                 antenna="",
                 baudrate=9600.0,
                 bb_freq=0.0,
                 bw=0.0,
                 dc_removal="False",
                 decoded_data_file_path="/tmp/.satnogs/data/data",
                 dev_args="",
                 doppler_correction_per_sec=20,
                 enable_iq_dump=0,
                 excess_bw=0.5,
                 file_path="test.wav",
                 framing="ax25",
                 gain=0.0,
                 gain_mode="Overall",
                 iq_file_path="/tmp/iq.dat",
                 lo_offset=100e3,
                 max_cfo=2000.0,
                 other_settings="",
                 ppm=0,
                 rigctl_port=4532,
                 rx_freq=100e6,
                 samp_rate_rx=0.0,
                 soapy_rx_device="driver=invalid",
                 stream_args="",
                 tune_args="",
                 udp_IP="127.0.0.1",
                 udp_port=16887,
                 waterfall_file_path="/tmp/waterfall.dat"):
        gr.top_block.__init__(self, "satnogs_bpsk UDP")

        ##################################################
        # Parameters
        ##################################################
        self.antenna = antenna
        self.baudrate = baudrate
        self.bb_freq = bb_freq
        self.bw = bw
        self.dc_removal = dc_removal
        self.decoded_data_file_path = decoded_data_file_path
        self.dev_args = dev_args
        self.doppler_correction_per_sec = doppler_correction_per_sec
        self.enable_iq_dump = enable_iq_dump
        self.excess_bw = excess_bw
        self.file_path = file_path
        self.framing = framing
        self.gain = gain
        self.gain_mode = gain_mode
        self.iq_file_path = iq_file_path
        self.lo_offset = lo_offset
        self.max_cfo = max_cfo
        self.other_settings = other_settings
        self.ppm = ppm
        self.rigctl_port = rigctl_port
        self.rx_freq = rx_freq
        self.samp_rate_rx = samp_rate_rx
        self.soapy_rx_device = soapy_rx_device
        self.stream_args = stream_args
        self.tune_args = tune_args
        self.udp_IP = udp_IP
        self.udp_port = udp_port
        self.waterfall_file_path = waterfall_file_path

        ##################################################
        # Variables
        ##################################################
        self.variable_ax25_decoder_0 = variable_ax25_decoder_0 = satnogs.ax25_decoder_make(
            'GND', 0, True, True, True, 1024)
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.audio_samp_rate = audio_samp_rate = 48000
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), excess_bw, 11 * sps * nfilts)
        self.if_freq = if_freq = 12000
        self.decimation = decimation = satnogs.find_decimation(
            baudrate, 2, audio_samp_rate, sps)
        self.bpsk_constellation = bpsk_constellation = digital.constellation_bpsk(
        ).base()
        self.available_framings = available_framings = {
            'ax25': variable_ax25_decoder_0
        }

        ##################################################
        # Blocks
        ##################################################
        self.soapy_source_0 = None
        # Make sure that the gain mode is valid
        if (gain_mode not in ['Overall', 'Specific', 'Settings Field']):
            raise ValueError(
                "Wrong gain mode on channel 0. Allowed gain modes: "
                "['Overall', 'Specific', 'Settings Field']")

        dev = soapy_rx_device

        # Stream arguments for every activated stream
        tune_args = [tune_args]
        settings = [other_settings]

        # Setup the device arguments
        dev_args = dev_args

        self.soapy_source_0 = soapy.source(1, dev, dev_args, stream_args,
                                           tune_args, settings, samp_rate_rx,
                                           "fc32")

        self.soapy_source_0.set_dc_removal(
            0, bool(distutils.util.strtobool(dc_removal)))

        # Set up DC offset. If set to (0, 0) internally the source block
        # will handle the case if no DC offset correction is supported
        self.soapy_source_0.set_dc_offset(0, 0)

        # Setup IQ Balance. If set to (0, 0) internally the source block
        # will handle the case if no IQ balance correction is supported
        self.soapy_source_0.set_iq_balance(0, 0)

        self.soapy_source_0.set_agc(0, False)

        # generic frequency setting should be specified first
        self.soapy_source_0.set_frequency(0, rx_freq - lo_offset)

        self.soapy_source_0.set_frequency(0, "BB", bb_freq)

        # Setup Frequency correction. If set to 0 internally the source block
        # will handle the case if no frequency correction is supported
        self.soapy_source_0.set_frequency_correction(0, ppm)

        self.soapy_source_0.set_antenna(0, antenna)

        self.soapy_source_0.set_bandwidth(0, bw)

        if (gain_mode != 'Settings Field'):
            # pass is needed, in case the template does not evaluare anything
            pass
            self.soapy_source_0.set_gain(0, gain)
        self.satnogs_waterfall_sink_0_0 = satnogs.waterfall_sink(
            baudrate * decimation, rx_freq, 10, 1024, waterfall_file_path, 1)
        self.satnogs_udp_msg_sink_0_0 = satnogs.udp_msg_sink(
            udp_IP, udp_port, 1500)
        self.satnogs_tcp_rigctl_msg_source_0 = satnogs.tcp_rigctl_msg_source(
            "127.0.0.1", rigctl_port, False,
            int(1000.0 / doppler_correction_per_sec) + 1, 1500)
        self.satnogs_ogg_encoder_0 = satnogs.ogg_encoder(
            file_path, audio_samp_rate, 1.0)
        self.satnogs_json_converter_0 = satnogs.json_converter()
        self.satnogs_iq_sink_0_0 = satnogs.iq_sink(16768, iq_file_path, False,
                                                   enable_iq_dump)
        self.satnogs_frame_file_sink_0_1_0 = satnogs.frame_file_sink(
            decoded_data_file_path, 0)
        self.satnogs_frame_decoder_0_0 = satnogs.frame_decoder(
            available_framings[framing], 1 * 1)
        self.satnogs_doppler_compensation_0 = satnogs.doppler_compensation(
            samp_rate_rx, rx_freq, lo_offset, baudrate * decimation, 1, 0)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
            audio_samp_rate / (baudrate * decimation), taps=None, flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, audio_samp_rate, 0.42 * audio_samp_rate / 2.0,
                            0.05 * audio_samp_rate, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            decimation // sps,
            firdes.low_pass(
                1, baudrate * decimation,
                baudrate / 2 + excess_bw * baudrate / 2 + abs(max_cfo),
                baudrate / 10.0, firdes.WIN_HAMMING, 6.76))
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, 2.0 * math.pi / 100.0, rrc_taps, nfilts, nfilts / 2, 1.5, 1)
        self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb(
            bpsk_constellation, 2.0 * math.pi / 100.0, -0.25, 0.25)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short * 1, udp_IP,
                                                 7355, 1472, True)
        self.blocks_rotator_cc_0_0 = blocks.rotator_cc(
            2.0 * math.pi * (if_freq / audio_samp_rate))
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 32767)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_agc2_xx_0_0 = analog.agc2_cc(0.01, 0.001, 0.015, 1.0)
        self.analog_agc2_xx_0_0.set_max_gain(65536)
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-3, 1e-3, 0.5, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.satnogs_frame_decoder_0_0, 'out'),
                         (self.satnogs_json_converter_0, 'in'))
        self.msg_connect((self.satnogs_json_converter_0, 'out'),
                         (self.satnogs_frame_file_sink_0_1_0, 'frame'))
        self.msg_connect((self.satnogs_json_converter_0, 'out'),
                         (self.satnogs_udp_msg_sink_0_0, 'in'))
        self.msg_connect((self.satnogs_tcp_rigctl_msg_source_0, 'freq'),
                         (self.satnogs_doppler_compensation_0, 'doppler'))
        self.connect((self.analog_agc2_xx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.analog_agc2_xx_0_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_float_to_short_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.satnogs_ogg_encoder_0, 0))
        self.connect((self.blocks_float_to_short_0, 0),
                     (self.blocks_udp_sink_0, 0))
        self.connect((self.blocks_rotator_cc_0_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.digital_constellation_receiver_cb_0, 0),
                     (self.satnogs_frame_decoder_0_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_constellation_receiver_cb_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_rotator_cc_0_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.analog_agc2_xx_0_0, 0))
        self.connect((self.satnogs_doppler_compensation_0, 0),
                     (self.analog_agc2_xx_0, 0))
        self.connect((self.satnogs_doppler_compensation_0, 0),
                     (self.satnogs_iq_sink_0_0, 0))
        self.connect((self.satnogs_doppler_compensation_0, 0),
                     (self.satnogs_waterfall_sink_0_0, 0))
        self.connect((self.soapy_source_0, 0),
                     (self.satnogs_doppler_compensation_0, 0))