Rev Author Line No. Line
4918 kaklik 1 #!/usr/bin/env python
2 ##################################################
3 # Gnuradio Python Flow Graph
4 # Title: Top Block
5 # Author: Jakub Kakona
6 # Generated: Sat May 3 15:10:31 2014
7 ##################################################
8  
9 from gnuradio import analog
10 from gnuradio import audio
11 from gnuradio import blocks
12 from gnuradio import eng_notation
13 from gnuradio import filter
14 from gnuradio import gr
15 from gnuradio import wxgui
16 from gnuradio.eng_option import eng_option
17 from gnuradio.fft import window
18 from gnuradio.filter import firdes
19 from gnuradio.wxgui import forms
20 from gnuradio.wxgui import scopesink2
21 from gnuradio.wxgui import waterfallsink2
22 from grc_gnuradio import wxgui as grc_wxgui
23 from optparse import OptionParser
24 import wx
25  
26 class top_block(grc_wxgui.top_block_gui):
27  
28 def __init__(self):
29 grc_wxgui.top_block_gui.__init__(self, title="Top Block")
30 _icon_path = "/usr/local/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
31 self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))
32  
33 ##################################################
34 # Variables
35 ##################################################
36 self.variable_slider_0 = variable_slider_0 = 1
37 self.samp_rate = samp_rate = 5e6
38  
39 ##################################################
40 # Blocks
41 ##################################################
42 self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
43 self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "RF signal")
44 self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Scope")
45 self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Demod")
46 self.Add(self.notebook_0)
47 _variable_slider_0_sizer = wx.BoxSizer(wx.VERTICAL)
48 self._variable_slider_0_text_box = forms.text_box(
49 parent=self.notebook_0.GetPage(2).GetWin(),
50 sizer=_variable_slider_0_sizer,
51 value=self.variable_slider_0,
52 callback=self.set_variable_slider_0,
53 label='variable_slider_0',
54 converter=forms.float_converter(),
55 proportion=0,
56 )
57 self._variable_slider_0_slider = forms.slider(
58 parent=self.notebook_0.GetPage(2).GetWin(),
59 sizer=_variable_slider_0_sizer,
60 value=self.variable_slider_0,
61 callback=self.set_variable_slider_0,
62 minimum=0,
63 maximum=10,
64 num_steps=100,
65 style=wx.SL_HORIZONTAL,
66 cast=float,
67 proportion=1,
68 )
69 self.notebook_0.GetPage(2).Add(_variable_slider_0_sizer)
70 self.wxgui_waterfallsink2_2 = waterfallsink2.waterfall_sink_f(
71 self.notebook_0.GetPage(2).GetWin(),
72 baseband_freq=0,
73 dynamic_range=100,
74 ref_level=0,
75 ref_scale=2.0,
76 sample_rate=48e3,
77 fft_size=512,
78 fft_rate=15,
79 average=False,
80 avg_alpha=None,
81 title="Demodulated Audio",
82 win=window.hamming,
83 )
84 self.notebook_0.GetPage(2).Add(self.wxgui_waterfallsink2_2.win)
85 self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c(
86 self.notebook_0.GetPage(2).GetWin(),
87 baseband_freq=0,
88 dynamic_range=100,
89 ref_level=0,
90 ref_scale=2.0,
91 sample_rate=500e3,
92 fft_size=512,
93 fft_rate=15,
94 average=False,
95 avg_alpha=None,
96 title="IF Plot",
97 win=window.blackmanharris,
98 )
99 self.notebook_0.GetPage(2).Add(self.wxgui_waterfallsink2_1.win)
100 self.wxgui_waterfallsink2_0_0 = waterfallsink2.waterfall_sink_c(
101 self.notebook_0.GetPage(0).GetWin(),
102 baseband_freq=0,
103 dynamic_range=100,
104 ref_level=0,
105 ref_scale=2.0,
106 sample_rate=samp_rate,
107 fft_size=4096,
108 fft_rate=15,
109 average=False,
110 avg_alpha=None,
111 title="ADC1 Waterfall Plot",
112 size=(4096, 500),
113 )
114 self.notebook_0.GetPage(0).Add(self.wxgui_waterfallsink2_0_0.win)
115 self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
116 self.notebook_0.GetPage(0).GetWin(),
117 baseband_freq=0,
118 dynamic_range=100,
119 ref_level=0,
120 ref_scale=2.0,
121 sample_rate=samp_rate,
122 fft_size=512,
123 fft_rate=15,
124 average=False,
125 avg_alpha=None,
126 title="ADC2 Waterfall Plot",
127 win=window.hanning,
128 )
129 self.notebook_0.GetPage(0).Add(self.wxgui_waterfallsink2_0.win)
130 self.wxgui_scopesink2_1 = scopesink2.scope_sink_f(
131 self.notebook_0.GetPage(1).GetWin(),
132 title="Scope Plot",
133 sample_rate=samp_rate/2,
134 v_scale=0,
135 v_offset=0,
136 t_scale=1e-2,
137 ac_couple=False,
138 xy_mode=False,
139 num_inputs=2,
140 trig_mode=wxgui.TRIG_MODE_AUTO,
141 y_axis_label="Counts",
142 )
143 self.notebook_0.GetPage(1).Add(self.wxgui_scopesink2_1.win)
144 self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
145 self.notebook_0.GetPage(1).GetWin(),
146 title="Scope Plot",
147 sample_rate=samp_rate,
148 v_scale=0,
149 v_offset=0,
150 t_scale=0,
151 ac_couple=False,
152 xy_mode=False,
153 num_inputs=4,
154 trig_mode=wxgui.TRIG_MODE_AUTO,
155 y_axis_label="Counts",
156 )
157 self.notebook_0.GetPage(1).Add(self.wxgui_scopesink2_0.win)
158 self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
159 interpolation=48,
160 decimation=500,
161 taps=None,
162 fractional_bw=None,
163 )
164 self.low_pass_filter_0 = filter.fir_filter_ccf(int(samp_rate/500e3), firdes.low_pass(
165 1, samp_rate, 100e3, 1e6, firdes.WIN_HAMMING, 6.76))
166 self.blocks_vector_to_streams_0 = blocks.vector_to_streams(gr.sizeof_short*1, 10)
167 self.blocks_throttle_2 = blocks.throttle(gr.sizeof_short*10, samp_rate/2)
168 self.blocks_short_to_float_2_0 = blocks.short_to_float(1, 1)
169 self.blocks_short_to_float_2 = blocks.short_to_float(1, 1)
170 self.blocks_short_to_float_1_0 = blocks.short_to_float(1, 1)
171 self.blocks_short_to_float_1 = blocks.short_to_float(1, 1)
172 self.blocks_short_to_float_0_0 = blocks.short_to_float(1, 1)
173 self.blocks_short_to_float_0 = blocks.short_to_float(1, 1)
174 self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((variable_slider_0, ))
175 self.blocks_interleave_0_2 = blocks.interleave(gr.sizeof_short*1)
176 self.blocks_interleave_0_1 = blocks.interleave(gr.sizeof_short*1)
177 self.blocks_interleave_0_0 = blocks.interleave(gr.sizeof_short*1)
178 self.blocks_interleave_0 = blocks.interleave(gr.sizeof_short*1)
179 self.blocks_float_to_complex_0_0 = blocks.float_to_complex(1)
180 self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
181 self.blocks_file_source_0 = blocks.file_source(gr.sizeof_short*10, "/home/kaklik/GNU_radio/2014.04.15.17.02.48.dat", True)
182 self.audio_sink_0 = audio.sink(48000, "", True)
183 self.analog_wfm_rcv_0 = analog.wfm_rcv(
184 quad_rate=500e3,
185 audio_decimation=1,
186 )
187  
188 ##################################################
189 # Connections
190 ##################################################
191 self.connect((self.blocks_vector_to_streams_0, 2), (self.blocks_interleave_0_2, 0))
192 self.connect((self.blocks_vector_to_streams_0, 3), (self.blocks_interleave_0_2, 1))
193 self.connect((self.blocks_vector_to_streams_0, 4), (self.blocks_interleave_0_1, 0))
194 self.connect((self.blocks_vector_to_streams_0, 5), (self.blocks_interleave_0_1, 1))
195 self.connect((self.blocks_vector_to_streams_0, 6), (self.blocks_interleave_0_0, 0))
196 self.connect((self.blocks_vector_to_streams_0, 7), (self.blocks_interleave_0_0, 1))
197 self.connect((self.blocks_vector_to_streams_0, 8), (self.blocks_interleave_0, 0))
198 self.connect((self.blocks_vector_to_streams_0, 9), (self.blocks_interleave_0, 1))
199 self.connect((self.blocks_short_to_float_1, 0), (self.blocks_float_to_complex_0, 1))
200 self.connect((self.blocks_short_to_float_0, 0), (self.blocks_float_to_complex_0, 0))
201 self.connect((self.blocks_short_to_float_0_0, 0), (self.blocks_float_to_complex_0_0, 0))
202 self.connect((self.blocks_short_to_float_1_0, 0), (self.blocks_float_to_complex_0_0, 1))
203 self.connect((self.blocks_vector_to_streams_0, 0), (self.blocks_short_to_float_2, 0))
204 self.connect((self.blocks_vector_to_streams_0, 1), (self.blocks_short_to_float_2_0, 0))
205 self.connect((self.blocks_short_to_float_2, 0), (self.wxgui_scopesink2_1, 0))
206 self.connect((self.blocks_short_to_float_2_0, 0), (self.wxgui_scopesink2_1, 1))
207 self.connect((self.blocks_short_to_float_0_0, 0), (self.wxgui_scopesink2_0, 0))
208 self.connect((self.blocks_short_to_float_1_0, 0), (self.wxgui_scopesink2_0, 1))
209 self.connect((self.blocks_short_to_float_0, 0), (self.wxgui_scopesink2_0, 2))
210 self.connect((self.blocks_short_to_float_1, 0), (self.wxgui_scopesink2_0, 3))
211 self.connect((self.blocks_interleave_0_2, 0), (self.blocks_short_to_float_0_0, 0))
212 self.connect((self.blocks_interleave_0_1, 0), (self.blocks_short_to_float_1_0, 0))
213 self.connect((self.blocks_interleave_0_0, 0), (self.blocks_short_to_float_0, 0))
214 self.connect((self.blocks_interleave_0, 0), (self.blocks_short_to_float_1, 0))
215 self.connect((self.blocks_throttle_2, 0), (self.blocks_vector_to_streams_0, 0))
216 self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_2, 0))
217 self.connect((self.blocks_float_to_complex_0_0, 0), (self.wxgui_waterfallsink2_0_0, 0))
218 self.connect((self.blocks_float_to_complex_0, 0), (self.wxgui_waterfallsink2_0, 0))
219 self.connect((self.blocks_float_to_complex_0_0, 0), (self.low_pass_filter_0, 0))
220 self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0))
221 self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_0, 0))
222 self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
223 self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0))
224 self.connect((self.low_pass_filter_0, 0), (self.wxgui_waterfallsink2_1, 0))
225 self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_waterfallsink2_2, 0))
226  
227  
228 # QT sink close method reimplementation
229  
230 def get_variable_slider_0(self):
231 return self.variable_slider_0
232  
233 def set_variable_slider_0(self, variable_slider_0):
234 self.variable_slider_0 = variable_slider_0
235 self.blocks_multiply_const_vxx_0.set_k((self.variable_slider_0, ))
236 self._variable_slider_0_slider.set_value(self.variable_slider_0)
237 self._variable_slider_0_text_box.set_value(self.variable_slider_0)
238  
239 def get_samp_rate(self):
240 return self.samp_rate
241  
242 def set_samp_rate(self, samp_rate):
243 self.samp_rate = samp_rate
244 self.blocks_throttle_2.set_sample_rate(self.samp_rate/2)
245 self.low_pass_filter_0.set_taps(firdes.low_pass(1, self.samp_rate, 100e3, 1e6, firdes.WIN_HAMMING, 6.76))
246 self.wxgui_scopesink2_0.set_sample_rate(self.samp_rate)
247 self.wxgui_waterfallsink2_0.set_sample_rate(self.samp_rate)
248 self.wxgui_scopesink2_1.set_sample_rate(self.samp_rate/2)
249 self.wxgui_waterfallsink2_0_0.set_sample_rate(self.samp_rate)
250  
251 if __name__ == '__main__':
252 import ctypes
253 import os
254 if os.name == 'posix':
255 try:
256 x11 = ctypes.cdll.LoadLibrary('libX11.so')
257 x11.XInitThreads()
258 except:
259 print "Warning: failed to XInitThreads()"
260 parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
261 (options, args) = parser.parse_args()
262 tb = top_block()
263 tb.Start(True)
264 tb.Wait()
265