Skip to content

Commit 053ee64

Browse files
committed
Final merge of GSoC work into master
2 parents f68ab8f + e86e91a commit 053ee64

File tree

77 files changed

+4456
-924
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+4456
-924
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2011,2012,2014,2016 Free Software Foundation, Inc.
1+
# Copyright 2011,2012,2014,2016,2017 Free Software Foundation, Inc.
22
#
33
# This file is part of GNU Radio
44
#

examples/README

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/const_sink_c.py

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#!/usr/bin/env python2
2+
# -*- coding: utf-8 -*-
3+
##################################################
4+
# GNU Radio Python Flow Graph
5+
# Title: Time Sink Float values example
6+
##################################################
7+
8+
if __name__ == '__main__':
9+
import ctypes
10+
import sys
11+
12+
if sys.platform.startswith('linux'):
13+
try:
14+
x11 = ctypes.cdll.LoadLibrary('libX11.so')
15+
x11.XInitThreads()
16+
except:
17+
print "Warning: failed to XInitThreads()"
18+
19+
import functools
20+
import signal
21+
import time
22+
23+
import bokehgui
24+
from bokeh.client import push_session
25+
from bokeh.plotting import curdoc
26+
from gnuradio import analog, blocks, gr
27+
28+
29+
class top_block(gr.top_block):
30+
def __init__(self, doc):
31+
gr.top_block.__init__(self, "Top Block")
32+
self.doc = doc
33+
self.widget_lst = []
34+
self.plot_lst = []
35+
36+
##################################################
37+
# Variables
38+
##################################################
39+
self.samp_rate = samp_rate = 32000
40+
41+
##################################################
42+
# Blocks
43+
##################################################
44+
self.bokehgui_const_sink_c_proc_0 = bokehgui.time_sink_c_proc(1024,
45+
samp_rate,
46+
"Waterfall Sink",
47+
1)
48+
self.bokehgui_const_sink_c_0 = bokehgui.const_sink_c(self.doc,
49+
self.plot_lst,
50+
self.bokehgui_const_sink_c_proc_0)
51+
self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
52+
samp_rate, True)
53+
self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate,
54+
analog.GR_COS_WAVE,
55+
500, 3, 0)
56+
self.analog_noise_source_x_0 = analog.noise_source_c(
57+
analog.GR_GAUSSIAN, 0.00, 0)
58+
self.blocks_add_xx_0 = blocks.add_vcc(1)
59+
60+
##################################################
61+
# Customizing the plot
62+
##################################################
63+
self.bokehgui_const_sink_c_0.initialize(legend_list = ['Signal1'],
64+
update_time = 100)
65+
66+
self.bokehgui_const_sink_c_0.set_y_label('Q Channel')
67+
self.bokehgui_const_sink_c_0.set_x_label('I Channel')
68+
self.bokehgui_const_sink_c_0.set_layout(1, 1, 1, 1)
69+
70+
self.doc.add_root(bokehgui.BokehLayout.create_layout(self.plot_lst))
71+
##################################################
72+
# Connections
73+
##################################################
74+
self.connect((self.analog_sig_source_x_0, 0),
75+
(self.blocks_add_xx_0, 0))
76+
self.connect((self.analog_noise_source_x_0, 0),
77+
(self.blocks_add_xx_0, 1))
78+
self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0))
79+
self.connect((self.blocks_throttle_0, 0),
80+
(self.bokehgui_const_sink_c_proc_0, 0))
81+
82+
def get_samp_rate(self):
83+
return self.samp_rate
84+
85+
def set_samp_rate(self, samp_rate):
86+
self.samp_rate = samp_rate
87+
self.blocks_throttle_0.set_sample_rate(self.samp_rate)
88+
self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate)
89+
self.bokehgui_const_sink_c_0.set_frequency_range(
90+
[0, self.samp_rate / 2])
91+
92+
93+
def main(top_block_cls = top_block, options = None):
94+
serverProc, port = bokehgui.utils.create_server()
95+
96+
def killProc(signum, frame, tb):
97+
tb.stop()
98+
tb.wait()
99+
serverProc.terminate()
100+
serverProc.kill()
101+
102+
time.sleep(1)
103+
try:
104+
# Define the document instance
105+
doc = curdoc()
106+
session = push_session(doc, session_id = "test",
107+
url = "http://localhost:" + port + "/bokehgui")
108+
# Create Top Block instance
109+
tb = top_block_cls(doc)
110+
try:
111+
tb.start()
112+
signal.signal(signal.SIGTERM, functools.partial(killProc, tb = tb))
113+
session.loop_until_closed()
114+
finally:
115+
print "Exiting the simulation. Stopping Bokeh Server"
116+
tb.stop()
117+
tb.wait()
118+
finally:
119+
serverProc.terminate()
120+
serverProc.kill()
121+
122+
123+
if __name__ == '__main__':
124+
main()

examples/freq_sink_f.py

Lines changed: 59 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,24 @@
88
if __name__ == '__main__':
99
import ctypes
1010
import sys
11+
1112
if sys.platform.startswith('linux'):
1213
try:
1314
x11 = ctypes.cdll.LoadLibrary('libX11.so')
1415
x11.XInitThreads()
1516
except:
1617
print "Warning: failed to XInitThreads()"
1718

18-
import time, signal, functools
19-
20-
from gnuradio import analog
21-
from gnuradio import blocks
22-
from gnuradio import gr
23-
from gnuradio.filter import firdes
19+
import functools
20+
import signal
21+
import time
2422

23+
import bokehgui
2524
from bokeh.client import push_session
2625
from bokeh.plotting import curdoc
27-
import bokehgui
26+
from gnuradio import analog, blocks, gr
27+
from gnuradio.filter import firdes
28+
2829

2930
class top_block(gr.top_block):
3031
def __init__(self, doc):
@@ -41,25 +42,38 @@ def __init__(self, doc):
4142
##################################################
4243
# Blocks
4344
##################################################
44-
self.bokehgui_freq_sink_f_proc_0 = bokehgui.freq_sink_f_proc(1024, firdes.WIN_BLACKMAN_hARRIS, 0, samp_rate/2, "Frequency Sink", 2)
45-
self.bokehgui_freq_sink_f_0 = bokehgui.freq_sink_f(self.doc, self.plot_lst, self.bokehgui_freq_sink_f_proc_0)
46-
self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True)
47-
self.blocks_throttle_1 = blocks.throttle(gr.sizeof_float*1, samp_rate,True)
48-
self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 5000, 3, 0)
49-
self.analog_sig_source_x_1 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0)
50-
self.analog_noise_source_x_0 = analog.noise_source_f(analog.GR_GAUSSIAN, 0.001, 0)
51-
self.analog_noise_source_x_1 = analog.noise_source_f(analog.GR_GAUSSIAN, 0.01, 0)
45+
self.bokehgui_freq_sink_f_proc_0 = bokehgui.freq_sink_f_proc(1024,
46+
firdes.WIN_BLACKMAN_hARRIS,
47+
0,
48+
samp_rate / 2,
49+
"Frequency Sink",
50+
2)
51+
self.bokehgui_freq_sink_f_0 = bokehgui.freq_sink_f(self.doc,
52+
self.plot_lst,
53+
self.bokehgui_freq_sink_f_proc_0)
54+
self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
55+
samp_rate, True)
56+
self.blocks_throttle_1 = blocks.throttle(gr.sizeof_float * 1,
57+
samp_rate, True)
58+
self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate,
59+
analog.GR_COS_WAVE,
60+
5000, 3, 0)
61+
self.analog_sig_source_x_1 = analog.sig_source_f(samp_rate,
62+
analog.GR_COS_WAVE,
63+
1000, 1, 0)
64+
self.analog_noise_source_x_0 = analog.noise_source_f(
65+
analog.GR_GAUSSIAN, 0.001, 0)
66+
self.analog_noise_source_x_1 = analog.noise_source_f(
67+
analog.GR_GAUSSIAN, 0.01, 0)
5268
self.blocks_add_xx_0 = blocks.add_vff(1)
5369
self.blocks_add_xx_1 = blocks.add_vff(1)
5470

5571
##################################################
5672
# Customizing the plot
5773
##################################################
58-
self.bokehgui_freq_sink_f_0.initialize(legend_list = ['Signal (5000 Hz)',
59-
'Signal (1000 Hz)',
60-
],
61-
update_time = 100
62-
)
74+
self.bokehgui_freq_sink_f_0.initialize(
75+
legend_list = ['Signal (5000 Hz)', 'Signal (1000 Hz)', ],
76+
update_time = 100)
6377

6478
self.bokehgui_freq_sink_f_0.set_x_label('Frequency (Hz)')
6579
self.bokehgui_freq_sink_f_0.set_y_label('Relative Gain (dB)')
@@ -69,20 +83,26 @@ def __init__(self, doc):
6983
self.bokehgui_freq_sink_f_0.set_line_style(1, 'dashed')
7084
self.bokehgui_freq_sink_f_0.set_line_width(1, 1)
7185
self.bokehgui_freq_sink_f_0.enable_max_hold()
72-
self.bokehgui_freq_sink_f_0.set_layout(1,1,1,1)
86+
self.bokehgui_freq_sink_f_0.set_layout(1, 1, 1, 1)
7387

7488
self.doc.add_root(bokehgui.BokehLayout.create_layout(self.plot_lst))
7589
##################################################
7690
# Connections
7791
##################################################
78-
self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_1, 0))
79-
self.connect((self.analog_sig_source_x_1, 0), (self.blocks_add_xx_0, 0))
80-
self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1))
81-
self.connect((self.analog_noise_source_x_1, 0), (self.blocks_add_xx_1, 1))
92+
self.connect((self.analog_sig_source_x_0, 0),
93+
(self.blocks_add_xx_1, 0))
94+
self.connect((self.analog_sig_source_x_1, 0),
95+
(self.blocks_add_xx_0, 0))
96+
self.connect((self.analog_noise_source_x_0, 0),
97+
(self.blocks_add_xx_0, 1))
98+
self.connect((self.analog_noise_source_x_1, 0),
99+
(self.blocks_add_xx_1, 1))
82100
self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_1, 0))
83101
self.connect((self.blocks_add_xx_1, 0), (self.blocks_throttle_0, 0))
84-
self.connect((self.blocks_throttle_0, 0), (self.bokehgui_freq_sink_f_proc_0, 0))
85-
self.connect((self.blocks_throttle_1, 0), (self.bokehgui_freq_sink_f_proc_0, 1))
102+
self.connect((self.blocks_throttle_0, 0),
103+
(self.bokehgui_freq_sink_f_proc_0, 0))
104+
self.connect((self.blocks_throttle_1, 0),
105+
(self.bokehgui_freq_sink_f_proc_0, 1))
86106

87107
def get_samp_rate(self):
88108
return self.samp_rate
@@ -91,33 +111,39 @@ def set_samp_rate(self, samp_rate):
91111
self.samp_rate = samp_rate
92112
self.blocks_throttle_0.set_sample_rate(self.samp_rate)
93113
self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate)
94-
self.bokehgui_freq_sink_f_0.set_frequency_range([0, self.samp_rate/2])
114+
self.bokehgui_freq_sink_f_0.set_frequency_range(
115+
[0, self.samp_rate / 2])
116+
117+
118+
def main(top_block_cls = top_block, options = None):
119+
serverProc, port = bokehgui.utils.create_server()
95120

96-
def main(top_block_cls=top_block, options=None):
97-
serverProc = bokehgui.utils.create_server()
98121
def killProc(signum, frame, tb):
99122
tb.stop()
100123
tb.wait()
101124
serverProc.terminate()
102125
serverProc.kill()
126+
103127
time.sleep(1)
104128
try:
105129
# Define the document instance
106130
doc = curdoc()
107-
session = push_session(doc, session_id="test")
131+
session = push_session(doc, session_id = "test",
132+
url = "http://localhost:" + port + "/bokehgui")
108133
# Create Top Block instance
109134
tb = top_block_cls(doc)
110135
try:
111136
tb.start()
112-
signal.signal(signal.SIGTERM, functools.partial(killProc, tb=tb))
137+
signal.signal(signal.SIGTERM, functools.partial(killProc, tb = tb))
113138
session.loop_until_closed()
114139
finally:
115140
print "Exiting the simulation. Stopping Bokeh Server"
116141
tb.stop()
117-
tb.wait()
142+
tb.wait()
118143
finally:
119144
serverProc.terminate()
120145
serverProc.kill()
121146

147+
122148
if __name__ == '__main__':
123149
main()

examples/test_bokehgui.grc

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,6 @@
107107
<key>_coordinate</key>
108108
<value>(256, 324)</value>
109109
</param>
110-
<param>
111-
<key>gui_hint</key>
112-
<value></value>
113-
</param>
114110
<param>
115111
<key>_rotation</key>
116112
<value>0</value>
@@ -146,10 +142,6 @@
146142
<key>_coordinate</key>
147143
<value>(720, 292)</value>
148144
</param>
149-
<param>
150-
<key>gui_hint</key>
151-
<value></value>
152-
</param>
153145
<param>
154146
<key>_rotation</key>
155147
<value>0</value>
@@ -1089,6 +1081,14 @@
10891081
<key>maxhold</key>
10901082
<value>True</value>
10911083
</param>
1084+
<param>
1085+
<key>maxoutbuf</key>
1086+
<value>0</value>
1087+
</param>
1088+
<param>
1089+
<key>minoutbuf</key>
1090+
<value>0</value>
1091+
</param>
10921092
<param>
10931093
<key>name</key>
10941094
<value>Complex Frequency Sink</value>
@@ -1460,6 +1460,14 @@
14601460
<key>maxhold</key>
14611461
<value>True</value>
14621462
</param>
1463+
<param>
1464+
<key>maxoutbuf</key>
1465+
<value>0</value>
1466+
</param>
1467+
<param>
1468+
<key>minoutbuf</key>
1469+
<value>0</value>
1470+
</param>
14631471
<param>
14641472
<key>name</key>
14651473
<value>Float Frequency Sink</value>

0 commit comments

Comments
 (0)