Rev Author Line No. Line
2572 kaklik 1 #!/usr/bin/env python
2 ##################################################
3 # Gnuradio Python Flow Graph
4 # Title: Top Block
5 # Generated: Sat Nov 12 20:35:22 2011
6 ##################################################
7  
8 from PyQt4 import Qt
9 from gnuradio import eng_notation
10 from gnuradio import gr
11 from gnuradio.eng_option import eng_option
12 from gnuradio.gr import firdes
13 from gnuradio.qtgui import qtgui
14 from optparse import OptionParser
15 import sip
16 import sys
17  
18 class top_block(gr.top_block, Qt.QWidget):
19  
20 def __init__(self):
21 gr.top_block.__init__(self, "Top Block")
22 Qt.QWidget.__init__(self)
23 self.setWindowTitle("Top Block")
24 self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
25 self.top_scroll_layout = Qt.QVBoxLayout()
26 self.setLayout(self.top_scroll_layout)
27 self.top_scroll = Qt.QScrollArea()
28 self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
29 self.top_scroll_layout.addWidget(self.top_scroll)
30 self.top_scroll.setWidgetResizable(True)
31 self.top_widget = Qt.QWidget()
32 self.top_scroll.setWidget(self.top_widget)
33 self.top_layout = Qt.QVBoxLayout(self.top_widget)
34 self.top_grid_layout = Qt.QGridLayout()
35 self.top_layout.addLayout(self.top_grid_layout)
36  
37  
38 ##################################################
39 # Variables
40 ##################################################
41 self.samp_rate = samp_rate = 250000
42  
43 ##################################################
44 # Blocks
45 ##################################################
46 self.qtgui_sink_x_0 = qtgui.sink_f(
47 1024, #fftsize
48 firdes.WIN_BLACKMAN_hARRIS, #wintype
49 0, #fc
50 samp_rate, #bw
51 "QT GUI Plot", #name
52 True, #plotfreq
53 True, #plotwaterfall
54 True, #plottime
55 True, #plotconst
56 )
57 self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
58 self.top_layout.addWidget(self._qtgui_sink_x_0_win)
59 self.gr_short_to_float_0 = gr.short_to_float()
60 self.gr_file_source_0 = gr.file_source(gr.sizeof_short*1, "/dev/ttyUSB0", True)
61  
62 ##################################################
63 # Connections
64 ##################################################
65 self.connect((self.gr_file_source_0, 0), (self.gr_short_to_float_0, 0))
66 self.connect((self.gr_short_to_float_0, 0), (self.qtgui_sink_x_0, 0))
67  
68 def get_samp_rate(self):
69 return self.samp_rate
70  
71 def set_samp_rate(self, samp_rate):
72 self.samp_rate = samp_rate
73 self.qtgui_sink_x_0.set_frequency_range(0, self.samp_rate)
74  
75 if __name__ == '__main__':
76 parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
77 (options, args) = parser.parse_args()
78 qapp = Qt.QApplication(sys.argv)
79 tb = top_block()
80 tb.start()
81 tb.show()
82 qapp.exec_()
83 tb.stop()
84