1 | #!/usr/bin/env python3
|
2 | # -*- coding: utf-8 -*-
|
3 |
|
4 | #
|
5 | # SPDX-License-Identifier: GPL-3.0
|
6 | #
|
7 | # GNU Radio Python Flow Graph
|
8 | # Title: Not titled yet
|
9 | # GNU Radio version: 3.9.0.0-git
|
10 |
|
11 | from distutils.version import StrictVersion
|
12 |
|
13 | if __name__ == '__main__':
|
14 | import ctypes
|
15 | import sys
|
16 | if sys.platform.startswith('linux'):
|
17 | try:
|
18 | x11 = ctypes.cdll.LoadLibrary('libX11.so')
|
19 | x11.XInitThreads()
|
20 | except:
|
21 | print("Warning: failed to XInitThreads()")
|
22 |
|
23 | from PyQt5 import Qt
|
24 | from gnuradio import qtgui
|
25 | from gnuradio.filter import firdes
|
26 | import sip
|
27 | from gnuradio import analog
|
28 | from gnuradio import blocks
|
29 | from gnuradio import gr
|
30 | import sys
|
31 | import signal
|
32 | from argparse import ArgumentParser
|
33 | from gnuradio.eng_arg import eng_float, intx
|
34 | from gnuradio import eng_notation
|
35 |
|
36 | from gnuradio import qtgui
|
37 |
|
38 | class or(gr.top_block, Qt.QWidget):
|
39 |
|
40 | def __init__(self):
|
41 | gr.top_block.__init__(self, "Not titled yet", catch_exceptions=True)
|
42 | Qt.QWidget.__init__(self)
|
43 | self.setWindowTitle("Not titled yet")
|
44 | qtgui.util.check_set_qss()
|
45 | try:
|
46 | self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
|
47 | except:
|
48 | pass
|
49 | self.top_scroll_layout = Qt.QVBoxLayout()
|
50 | self.setLayout(self.top_scroll_layout)
|
51 | self.top_scroll = Qt.QScrollArea()
|
52 | self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
|
53 | self.top_scroll_layout.addWidget(self.top_scroll)
|
54 | self.top_scroll.setWidgetResizable(True)
|
55 | self.top_widget = Qt.QWidget()
|
56 | self.top_scroll.setWidget(self.top_widget)
|
57 | self.top_layout = Qt.QVBoxLayout(self.top_widget)
|
58 | self.top_grid_layout = Qt.QGridLayout()
|
59 | self.top_layout.addLayout(self.top_grid_layout)
|
60 |
|
61 | self.settings = Qt.QSettings("GNU Radio", "or")
|
62 |
|
63 | try:
|
64 | if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
|
65 | self.restoreGeometry(self.settings.value("geometry").toByteArray())
|
66 | else:
|
67 | self.restoreGeometry(self.settings.value("geometry"))
|
68 | except:
|
69 | pass
|
70 |
|
71 | ##################################################
|
72 | # Variables
|
73 | ##################################################
|
74 | self.samp_rate = samp_rate = 32000
|
75 |
|
76 | ##################################################
|
77 | # Blocks
|
78 | ##################################################
|
79 | self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
|
80 | 1024, #size
|
81 | samp_rate, #samp_rate
|
82 | "", #name
|
83 | 1 #number of inputs
|
84 | )
|
85 | self.qtgui_time_sink_x_0.set_update_time(0.10)
|
86 | self.qtgui_time_sink_x_0.set_y_axis(-1, 1)
|
87 |
|
88 | self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")
|
89 |
|
90 | self.qtgui_time_sink_x_0.enable_tags(True)
|
91 | self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
|
92 | self.qtgui_time_sink_x_0.enable_autoscale(False)
|
93 | self.qtgui_time_sink_x_0.enable_grid(False)
|
94 | self.qtgui_time_sink_x_0.enable_axis_labels(True)
|
95 | self.qtgui_time_sink_x_0.enable_control_panel(False)
|
96 | self.qtgui_time_sink_x_0.enable_stem_plot(False)
|
97 |
|
98 |
|
99 | labels = ['Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5',
|
100 | 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10']
|
101 | widths = [1, 1, 1, 1, 1,
|
102 | 1, 1, 1, 1, 1]
|
103 | colors = ['blue', 'red', 'green', 'black', 'cyan',
|
104 | 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue']
|
105 | alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
|
106 | 1.0, 1.0, 1.0, 1.0, 1.0]
|
107 | styles = [1, 1, 1, 1, 1,
|
108 | 1, 1, 1, 1, 1]
|
109 | markers = [-1, -1, -1, -1, -1,
|
110 | -1, -1, -1, -1, -1]
|
111 |
|
112 |
|
113 | for i in range(2):
|
114 | if len(labels[i]) == 0:
|
115 | if (i % 2 == 0):
|
116 | self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2))
|
117 | else:
|
118 | self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2))
|
119 | else:
|
120 | self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
|
121 | self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
|
122 | self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
|
123 | self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
|
124 | self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
|
125 | self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])
|
126 |
|
127 | self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
|
128 | self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win)
|
129 | self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
|
130 | self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0, 0)
|
131 |
|
132 |
|
133 |
|
134 | ##################################################
|
135 | # Connections
|
136 | ##################################################
|
137 | self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0))
|
138 | self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_0, 0))
|
139 |
|
140 |
|
141 | def closeEvent(self, event):
|
142 | self.settings = Qt.QSettings("GNU Radio", "or")
|
143 | self.settings.setValue("geometry", self.saveGeometry())
|
144 | event.accept()
|
145 |
|
146 | def get_samp_rate(self):
|
147 | return self.samp_rate
|
148 |
|
149 | def set_samp_rate(self, samp_rate):
|
150 | self.samp_rate = samp_rate
|
151 | self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate)
|
152 | self.blocks_throttle_0.set_sample_rate(self.samp_rate)
|
153 | self.qtgui_time_sink_x_0.set_samp_rate(self.samp_rate)
|
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 | def main(top_block_cls=or, options=None):
|
160 |
|
161 | if StrictVersion("4.5.0") <= StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
|
162 | style = gr.prefs().get_string('qtgui', 'style', 'raster')
|
163 | Qt.QApplication.setGraphicsSystem(style)
|
164 | qapp = Qt.QApplication(sys.argv)
|
165 |
|
166 | tb = top_block_cls()
|
167 |
|
168 | tb.start()
|
169 |
|
170 | tb.show()
|
171 |
|
172 | def sig_handler(sig=None, frame=None):
|
173 | Qt.QApplication.quit()
|
174 |
|
175 | signal.signal(signal.SIGINT, sig_handler)
|
176 | signal.signal(signal.SIGTERM, sig_handler)
|
177 |
|
178 | timer = Qt.QTimer()
|
179 | timer.start(500)
|
180 | timer.timeout.connect(lambda: None)
|
181 |
|
182 | def quitting():
|
183 | tb.stop()
|
184 | tb.wait()
|
185 |
|
186 | qapp.aboutToQuit.connect(quitting)
|
187 | qapp.exec_()
|
188 |
|
189 | if __name__ == '__main__':
|
190 | main()
|