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