Skip to content

Commit

Permalink
Final merge of GSoC work into master
Browse files Browse the repository at this point in the history
  • Loading branch information
kkpatel1 committed Sep 6, 2017
2 parents f68ab8f + e86e91a commit 053ee64
Show file tree
Hide file tree
Showing 77 changed files with 4,456 additions and 924 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2011,2012,2014,2016 Free Software Foundation, Inc.
# Copyright 2011,2012,2014,2016,2017 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
Expand Down
4 changes: 0 additions & 4 deletions examples/README

This file was deleted.

124 changes: 124 additions & 0 deletions examples/const_sink_c.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
##################################################
# GNU Radio Python Flow Graph
# Title: Time Sink Float values example
##################################################

if __name__ == '__main__':
import ctypes
import sys

if sys.platform.startswith('linux'):
try:
x11 = ctypes.cdll.LoadLibrary('libX11.so')
x11.XInitThreads()
except:
print "Warning: failed to XInitThreads()"

import functools
import signal
import time

import bokehgui
from bokeh.client import push_session
from bokeh.plotting import curdoc
from gnuradio import analog, blocks, gr


class top_block(gr.top_block):
def __init__(self, doc):
gr.top_block.__init__(self, "Top Block")
self.doc = doc
self.widget_lst = []
self.plot_lst = []

##################################################
# Variables
##################################################
self.samp_rate = samp_rate = 32000

##################################################
# Blocks
##################################################
self.bokehgui_const_sink_c_proc_0 = bokehgui.time_sink_c_proc(1024,
samp_rate,
"Waterfall Sink",
1)
self.bokehgui_const_sink_c_0 = bokehgui.const_sink_c(self.doc,
self.plot_lst,
self.bokehgui_const_sink_c_proc_0)
self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
samp_rate, True)
self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate,
analog.GR_COS_WAVE,
500, 3, 0)
self.analog_noise_source_x_0 = analog.noise_source_c(
analog.GR_GAUSSIAN, 0.00, 0)
self.blocks_add_xx_0 = blocks.add_vcc(1)

##################################################
# Customizing the plot
##################################################
self.bokehgui_const_sink_c_0.initialize(legend_list = ['Signal1'],
update_time = 100)

self.bokehgui_const_sink_c_0.set_y_label('Q Channel')
self.bokehgui_const_sink_c_0.set_x_label('I Channel')
self.bokehgui_const_sink_c_0.set_layout(1, 1, 1, 1)

self.doc.add_root(bokehgui.BokehLayout.create_layout(self.plot_lst))
##################################################
# Connections
##################################################
self.connect((self.analog_sig_source_x_0, 0),
(self.blocks_add_xx_0, 0))
self.connect((self.analog_noise_source_x_0, 0),
(self.blocks_add_xx_0, 1))
self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0))
self.connect((self.blocks_throttle_0, 0),
(self.bokehgui_const_sink_c_proc_0, 0))

def get_samp_rate(self):
return self.samp_rate

def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate
self.blocks_throttle_0.set_sample_rate(self.samp_rate)
self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate)
self.bokehgui_const_sink_c_0.set_frequency_range(
[0, self.samp_rate / 2])


def main(top_block_cls = top_block, options = None):
serverProc, port = bokehgui.utils.create_server()

def killProc(signum, frame, tb):
tb.stop()
tb.wait()
serverProc.terminate()
serverProc.kill()

time.sleep(1)
try:
# Define the document instance
doc = curdoc()
session = push_session(doc, session_id = "test",
url = "http://localhost:" + port + "/bokehgui")
# Create Top Block instance
tb = top_block_cls(doc)
try:
tb.start()
signal.signal(signal.SIGTERM, functools.partial(killProc, tb = tb))
session.loop_until_closed()
finally:
print "Exiting the simulation. Stopping Bokeh Server"
tb.stop()
tb.wait()
finally:
serverProc.terminate()
serverProc.kill()


if __name__ == '__main__':
main()
92 changes: 59 additions & 33 deletions examples/freq_sink_f.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,24 @@
if __name__ == '__main__':
import ctypes
import sys

if sys.platform.startswith('linux'):
try:
x11 = ctypes.cdll.LoadLibrary('libX11.so')
x11.XInitThreads()
except:
print "Warning: failed to XInitThreads()"

import time, signal, functools

from gnuradio import analog
from gnuradio import blocks
from gnuradio import gr
from gnuradio.filter import firdes
import functools
import signal
import time

import bokehgui
from bokeh.client import push_session
from bokeh.plotting import curdoc
import bokehgui
from gnuradio import analog, blocks, gr
from gnuradio.filter import firdes


class top_block(gr.top_block):
def __init__(self, doc):
Expand All @@ -41,25 +42,38 @@ def __init__(self, doc):
##################################################
# Blocks
##################################################
self.bokehgui_freq_sink_f_proc_0 = bokehgui.freq_sink_f_proc(1024, firdes.WIN_BLACKMAN_hARRIS, 0, samp_rate/2, "Frequency Sink", 2)
self.bokehgui_freq_sink_f_0 = bokehgui.freq_sink_f(self.doc, self.plot_lst, self.bokehgui_freq_sink_f_proc_0)
self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True)
self.blocks_throttle_1 = blocks.throttle(gr.sizeof_float*1, samp_rate,True)
self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 5000, 3, 0)
self.analog_sig_source_x_1 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0)
self.analog_noise_source_x_0 = analog.noise_source_f(analog.GR_GAUSSIAN, 0.001, 0)
self.analog_noise_source_x_1 = analog.noise_source_f(analog.GR_GAUSSIAN, 0.01, 0)
self.bokehgui_freq_sink_f_proc_0 = bokehgui.freq_sink_f_proc(1024,
firdes.WIN_BLACKMAN_hARRIS,
0,
samp_rate / 2,
"Frequency Sink",
2)
self.bokehgui_freq_sink_f_0 = bokehgui.freq_sink_f(self.doc,
self.plot_lst,
self.bokehgui_freq_sink_f_proc_0)
self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
samp_rate, True)
self.blocks_throttle_1 = blocks.throttle(gr.sizeof_float * 1,
samp_rate, True)
self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate,
analog.GR_COS_WAVE,
5000, 3, 0)
self.analog_sig_source_x_1 = analog.sig_source_f(samp_rate,
analog.GR_COS_WAVE,
1000, 1, 0)
self.analog_noise_source_x_0 = analog.noise_source_f(
analog.GR_GAUSSIAN, 0.001, 0)
self.analog_noise_source_x_1 = analog.noise_source_f(
analog.GR_GAUSSIAN, 0.01, 0)
self.blocks_add_xx_0 = blocks.add_vff(1)
self.blocks_add_xx_1 = blocks.add_vff(1)

##################################################
# Customizing the plot
##################################################
self.bokehgui_freq_sink_f_0.initialize(legend_list = ['Signal (5000 Hz)',
'Signal (1000 Hz)',
],
update_time = 100
)
self.bokehgui_freq_sink_f_0.initialize(
legend_list = ['Signal (5000 Hz)', 'Signal (1000 Hz)', ],
update_time = 100)

self.bokehgui_freq_sink_f_0.set_x_label('Frequency (Hz)')
self.bokehgui_freq_sink_f_0.set_y_label('Relative Gain (dB)')
Expand All @@ -69,20 +83,26 @@ def __init__(self, doc):
self.bokehgui_freq_sink_f_0.set_line_style(1, 'dashed')
self.bokehgui_freq_sink_f_0.set_line_width(1, 1)
self.bokehgui_freq_sink_f_0.enable_max_hold()
self.bokehgui_freq_sink_f_0.set_layout(1,1,1,1)
self.bokehgui_freq_sink_f_0.set_layout(1, 1, 1, 1)

self.doc.add_root(bokehgui.BokehLayout.create_layout(self.plot_lst))
##################################################
# Connections
##################################################
self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_1, 0))
self.connect((self.analog_sig_source_x_1, 0), (self.blocks_add_xx_0, 0))
self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1))
self.connect((self.analog_noise_source_x_1, 0), (self.blocks_add_xx_1, 1))
self.connect((self.analog_sig_source_x_0, 0),
(self.blocks_add_xx_1, 0))
self.connect((self.analog_sig_source_x_1, 0),
(self.blocks_add_xx_0, 0))
self.connect((self.analog_noise_source_x_0, 0),
(self.blocks_add_xx_0, 1))
self.connect((self.analog_noise_source_x_1, 0),
(self.blocks_add_xx_1, 1))
self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_1, 0))
self.connect((self.blocks_add_xx_1, 0), (self.blocks_throttle_0, 0))
self.connect((self.blocks_throttle_0, 0), (self.bokehgui_freq_sink_f_proc_0, 0))
self.connect((self.blocks_throttle_1, 0), (self.bokehgui_freq_sink_f_proc_0, 1))
self.connect((self.blocks_throttle_0, 0),
(self.bokehgui_freq_sink_f_proc_0, 0))
self.connect((self.blocks_throttle_1, 0),
(self.bokehgui_freq_sink_f_proc_0, 1))

def get_samp_rate(self):
return self.samp_rate
Expand All @@ -91,33 +111,39 @@ def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate
self.blocks_throttle_0.set_sample_rate(self.samp_rate)
self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate)
self.bokehgui_freq_sink_f_0.set_frequency_range([0, self.samp_rate/2])
self.bokehgui_freq_sink_f_0.set_frequency_range(
[0, self.samp_rate / 2])


def main(top_block_cls = top_block, options = None):
serverProc, port = bokehgui.utils.create_server()

def main(top_block_cls=top_block, options=None):
serverProc = bokehgui.utils.create_server()
def killProc(signum, frame, tb):
tb.stop()
tb.wait()
serverProc.terminate()
serverProc.kill()

time.sleep(1)
try:
# Define the document instance
doc = curdoc()
session = push_session(doc, session_id="test")
session = push_session(doc, session_id = "test",
url = "http://localhost:" + port + "/bokehgui")
# Create Top Block instance
tb = top_block_cls(doc)
try:
tb.start()
signal.signal(signal.SIGTERM, functools.partial(killProc, tb=tb))
signal.signal(signal.SIGTERM, functools.partial(killProc, tb = tb))
session.loop_until_closed()
finally:
print "Exiting the simulation. Stopping Bokeh Server"
tb.stop()
tb.wait()
tb.wait()
finally:
serverProc.terminate()
serverProc.kill()


if __name__ == '__main__':
main()
24 changes: 16 additions & 8 deletions examples/test_bokehgui.grc
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,6 @@
<key>_coordinate</key>
<value>(256, 324)</value>
</param>
<param>
<key>gui_hint</key>
<value></value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
Expand Down Expand Up @@ -146,10 +142,6 @@
<key>_coordinate</key>
<value>(720, 292)</value>
</param>
<param>
<key>gui_hint</key>
<value></value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
Expand Down Expand Up @@ -1089,6 +1081,14 @@
<key>maxhold</key>
<value>True</value>
</param>
<param>
<key>maxoutbuf</key>
<value>0</value>
</param>
<param>
<key>minoutbuf</key>
<value>0</value>
</param>
<param>
<key>name</key>
<value>Complex Frequency Sink</value>
Expand Down Expand Up @@ -1460,6 +1460,14 @@
<key>maxhold</key>
<value>True</value>
</param>
<param>
<key>maxoutbuf</key>
<value>0</value>
</param>
<param>
<key>minoutbuf</key>
<value>0</value>
</param>
<param>
<key>name</key>
<value>Float Frequency Sink</value>
Expand Down
Loading

0 comments on commit 053ee64

Please sign in to comment.