Advertisement
Guest User

Untitled

a guest
Feb 16th, 2014
110
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. ##################################################
  3. # Gnuradio Python Flow Graph
  4. # Title: Top Block
  5. # Generated: Sat Feb 15 23:55:08 2014
  6. ##################################################
  7.  
  8. from gnuradio import analog
  9. from gnuradio import blocks
  10. from gnuradio import eng_notation
  11. from gnuradio import gr
  12. from gnuradio.eng_option import eng_option
  13. from gnuradio.filter import firdes
  14. from optparse import OptionParser
  15. import math
  16.  
  17. class top_block(gr.top_block):
  18.  
  19.     def __init__(self):
  20.         gr.top_block.__init__(self, "Top Block")
  21.  
  22.         ##################################################
  23.         # Variables
  24.         ##################################################
  25.         self.samp_rate = samp_rate = 128000
  26.  
  27.         ##################################################
  28.         # Blocks
  29.         ##################################################
  30.         self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_gr_complex*1, "127.0.0.1", 1234, 1472, True)
  31.         self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex*1, "127.0.0.1", 1234, 1472, True)
  32.         self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate/4)
  33.         self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1)
  34.         self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0)
  35.         self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1)
  36.  
  37.         ##################################################
  38.         # Connections
  39.         ##################################################
  40.         self.connect((self.analog_sig_source_x_0, 0), (self.blocks_udp_sink_0, 0))
  41.         self.connect((self.blocks_udp_source_0, 0), (self.analog_quadrature_demod_cf_0, 0))
  42.         self.connect((self.blocks_throttle_0, 0), (self.blocks_null_sink_0, 0))
  43.         self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_throttle_0, 0))
  44.  
  45.  
  46. # QT sink close method reimplementation
  47.  
  48.     def get_samp_rate(self):
  49.         return self.samp_rate
  50.  
  51.     def set_samp_rate(self, samp_rate):
  52.         self.samp_rate = samp_rate
  53.         self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate)
  54.         self.blocks_throttle_0.set_sample_rate(self.samp_rate/4)
  55.  
  56. if __name__ == '__main__':
  57.     parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
  58.     (options, args) = parser.parse_args()
  59.     tb = top_block()
  60.     tb.start()
  61.     raw_input('Press Enter to quit: ')
  62.     tb.stop()
  63.     tb.wait()
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement