Advertisement
Guest User

top_block.py

a guest
Oct 29th, 2013
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.86 KB | None | 0 0
  1. #!/usr/bin/env python
  2. ##################################################
  3. # Gnuradio Python Flow Graph
  4. # Title: Top Block
  5. # Generated: Tue Oct 29 16:09:12 2013
  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 import wxgui
  13. from gnuradio.eng_option import eng_option
  14. from gnuradio.filter import firdes
  15. from gnuradio.wxgui import scopesink2
  16. from grc_gnuradio import wxgui as grc_wxgui
  17. from optparse import OptionParser
  18. import test
  19. import wx
  20.  
  21. class top_block(grc_wxgui.top_block_gui):
  22.  
  23.     def __init__(self):
  24.         grc_wxgui.top_block_gui.__init__(self, title="Top Block")
  25.  
  26.         ##################################################
  27.         # Variables
  28.         ##################################################
  29.         self.samp_rate = samp_rate = 32000
  30.  
  31.         ##################################################
  32.         # Blocks
  33.         ##################################################
  34.         self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
  35.             self.GetWin(),
  36.             title="Scope Plot",
  37.             sample_rate=samp_rate,
  38.             v_scale=0,
  39.             v_offset=0,
  40.             t_scale=0,
  41.             ac_couple=False,
  42.             xy_mode=False,
  43.             num_inputs=1,
  44.             trig_mode=wxgui.TRIG_MODE_AUTO,
  45.             y_axis_label="Counts",
  46.         )
  47.         self.Add(self.wxgui_scopesink2_0.win)
  48.         self.test_square3_ff_0 = test.square3_ff()
  49.         self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate)
  50.         self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0)
  51.  
  52.         ##################################################
  53.         # Connections
  54.         ##################################################
  55.         self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0))
  56.         self.connect((self.blocks_throttle_0, 0), (self.test_square3_ff_0, 0))
  57.         self.connect((self.test_square3_ff_0, 0), (self.wxgui_scopesink2_0, 0))
  58.  
  59.  
  60. # QT sink close method reimplementation
  61.  
  62.     def get_samp_rate(self):
  63.         return self.samp_rate
  64.  
  65.     def set_samp_rate(self, samp_rate):
  66.         self.samp_rate = samp_rate
  67.         self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate)
  68.         self.blocks_throttle_0.set_sample_rate(self.samp_rate)
  69.         self.wxgui_scopesink2_0.set_sample_rate(self.samp_rate)
  70.  
  71. if __name__ == '__main__':
  72.     import ctypes
  73.     import os
  74.     if os.name == 'posix':
  75.         try:
  76.             x11 = ctypes.cdll.LoadLibrary('libX11.so')
  77.             x11.XInitThreads()
  78.         except:
  79.             print "Warning: failed to XInitThreads()"
  80.     parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
  81.     (options, args) = parser.parse_args()
  82.     tb = top_block()
  83.     tb.Start(True)
  84.     tb.Wait()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement