Advertisement
Guest User

Untitled

a guest
Dec 8th, 2011
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.86 KB | None | 0 0
  1. #!/usr/bin/env python
  2. from gnuradio import gr
  3. from gnuradio import uhd
  4. from time import sleep, time
  5. from grc_gnuradio import blks2 as grc_blks2
  6.  
  7.  
  8. class top_block(gr.top_block):
  9.         def __init__(self):
  10.                 gr.top_block.__init__(self, "Top Block")
  11.  
  12.                # self.uhd = uhd.usrp_source(
  13.                 #        device_addr="",
  14.                  #       io_type=uhd.io_type.COMPLEX_FLOAT32,
  15.                 #        num_channels=1,
  16.                 #)
  17.                 #self.uhd.set_samp_rate(8000000)
  18.                 #self.uhd.set_center_freq(860000000, 0)
  19.                 #self.uhd.set_gain(10, 0)
  20. #
  21.                 self.sink_queue = gr.msg_queue(10240)
  22.                 self.msg_sink = gr.message_sink(gr.sizeof_float, self.sink_queue, False)
  23.  
  24.                 self.sig = gr.sig_source_f(8000000, gr.GR_SIN_WAVE, 350, .5, 0)
  25.                 self.null_sink = gr.null_sink(gr.sizeof_float)
  26.                 self.valve = grc_blks2.valve(gr.sizeof_float, bool(1))
  27.                 self.null_sink2 = gr.null_sink(gr.sizeof_float)
  28.                 self.valve2 = grc_blks2.valve(gr.sizeof_float, bool(1))
  29.  
  30.  
  31.                 self.connect(self.sig, self.msg_sink)
  32.                 self.connect(self.sig, self.valve, self.null_sink)
  33.                 self.connect(self.sig, self.valve2, self.null_sink2)
  34.  
  35.                 #self.connect(self.sig, self.msg_sink)
  36.  
  37. if __name__ == '__main__':
  38.         tb = top_block()
  39.         tb.start()
  40.         sleep(1)
  41.         while(1):
  42.                 while(tb.sink_queue.count()>0):
  43.                         tb.sink_queue.flush()
  44.                         #tb.lock()
  45.                         #tb.unlock()
  46.                         tb.valve.set_open(bool(0))
  47.                         tb.valve.set_open(bool(1))
  48.  
  49.                         sleep(0.001)
  50.                 print 'noflow'
  51.                 sleep(0.5)
  52.         tb.stop()
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement