From 7ed83c72dbd079a50a421661a874c3ac94a34bd6 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 5 Dec 2010 17:21:07 -0500 Subject: grc: added qtgui support to grc (just added sink) --- grc/blocks/Makefile.am | 1 + grc/blocks/block_tree.xml | 1 + grc/blocks/options.xml | 8 +++ grc/blocks/qtgui_sink_x.xml | 123 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 133 insertions(+) create mode 100644 grc/blocks/qtgui_sink_x.xml (limited to 'grc/blocks') diff --git a/grc/blocks/Makefile.am b/grc/blocks/Makefile.am index 18420a013..ea3c94cbe 100644 --- a/grc/blocks/Makefile.am +++ b/grc/blocks/Makefile.am @@ -203,6 +203,7 @@ dist_ourdata_DATA = \ pad_source.xml \ parameter.xml \ probe_function.xml \ + qtgui_sink_x.xml \ random_source_x.xml \ root_raised_cosine_filter.xml \ trellis_encoder_xx.xml \ diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml index 610a88102..644841884 100644 --- a/grc/blocks/block_tree.xml +++ b/grc/blocks/block_tree.xml @@ -47,6 +47,7 @@ wxgui_waterfallsink2 wxgui_histosink2 wxgui_termsink + qtgui_sink_x Operators diff --git a/grc/blocks/options.xml b/grc/blocks/options.xml index 4d0dd2899..62ceeba0f 100644 --- a/grc/blocks/options.xml +++ b/grc/blocks/options.xml @@ -15,6 +15,10 @@ from grc_gnuradio import wxgui as grc_wxgui import wx #end if +#if $generate_options() == 'qt_gui' +from PyQt4 import QtGui +import sys +#end if #if $generate_options() != 'hb' from optparse import OptionParser from gnuradio.eng_option import eng_option @@ -61,6 +65,10 @@ else: self.stop(); self.wait() WX GUI wx_gui + - - Graphical Sinks - wxgui_numbersink2 - wxgui_scopesink2 - wxgui_fftsink2 - wxgui_constellationsink2 - wxgui_waterfallsink2 - wxgui_histosink2 - wxgui_termsink - qtgui_sink_x - Operators gr_add_xx @@ -139,7 +128,7 @@ gr_pll_freqdet_cf gr_pll_refout_cc - gr_fll_band_edge_cc + gr_fll_band_edge_cc gr_correlate_access_code_bb gr_pn_correlator_cc @@ -263,7 +252,7 @@ gr_additive_scrambler_bb - Vocoders + Vocoders blks2_cvsd_encode blks2_cvsd_decode @@ -311,7 +300,5 @@ xmlrpc_server xmlrpc_client - - notebook diff --git a/grc/blocks/notebook.xml b/grc/blocks/notebook.xml deleted file mode 100644 index d41db9e2d..000000000 --- a/grc/blocks/notebook.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - Notebook - notebook - from grc_gnuradio import wxgui as grc_wxgui - #set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self' -self.$(id) = wx.Notebook($(parent).GetWin(), style=$style) -#for $label in $labels() -self.$(id).AddPage(grc_wxgui.Panel(self.$(id)), "$label") -#end for -#if not $grid_pos() -$(parent).Add(self.$(id)) -#else -$(parent).GridAdd(self.$(id), $(', '.join(map(str, $grid_pos())))) -#end if - - Tab Orientation - style - wx.NB_TOP - enum - - - - - - - Labels - labels - ['tab1', 'tab2', 'tab3'] - raw - - - Grid Position - grid_pos - - grid_pos - - - Notebook - notebook - - notebook - - isinstance($labels, (list, tuple)) - all(map(lambda x: isinstance(x, str), $labels)) - len($labels) > 0 - -Use the Grid Position (row, column, row span, column span) to position the graphical element in the window. - -Use the Notebook Param (notebook-id, page-index) to place the graphical element inside of a notebook page. - - -- cgit From fedf4fbc9d217926ecbb1917d3c995516d88a8a9 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 1 Mar 2011 18:18:53 -0800 Subject: qtgui-grc: enable start/stop control through qt widgets --- grc/blocks/options.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'grc/blocks') diff --git a/grc/blocks/options.xml b/grc/blocks/options.xml index e6c7e0287..b27ea900c 100644 --- a/grc/blocks/options.xml +++ b/grc/blocks/options.xml @@ -105,7 +105,7 @@ else: self.stop(); self.wait() True bool -#if $generate_options() == 'wx_gui' +#if $generate_options() in ('qt_gui', 'wx_gui') #if $run() part #else -- cgit From 7070c10d7ac59adcd597c18ec2c83b1b59ed87e9 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 6 Mar 2011 11:18:27 -0800 Subject: grc: rework the probe blocks and how they fit into grc Removed the source on all probe blocks. Advertise the probe-able function in the docs. Added missing signal probe block. Removed probe function and variable sink blocks. Removed all supporting grc_gnuradio python files. Added variable_function_probe block that can probe arbitrary functions on a block. All the code needed by the function probe is available is the make tag. To display the value of a probe block, use the variable probe block, and a gui widget. To disply the value of a stream, do the same but use the signal probe block. Simple see :-) If more types other than floats need to be read from the stream, the signal probe should be extended. --- grc/blocks/Makefile.am | 4 +- grc/blocks/blks2_variable_sink_x.xml | 77 ---------------------------------- grc/blocks/block_tree.xml | 4 +- grc/blocks/gr_probe_avg_mag_sqrd_x.xml | 22 +++------- grc/blocks/gr_probe_density_b.xml | 15 +++---- grc/blocks/gr_probe_mpsk_snr_c.xml | 39 +++-------------- grc/blocks/gr_probe_signal_f.xml | 19 +++++++++ grc/blocks/probe_function.xml | 44 ------------------- grc/blocks/variable_function_probe.xml | 51 ++++++++++++++++++++++ 9 files changed, 89 insertions(+), 186 deletions(-) delete mode 100644 grc/blocks/blks2_variable_sink_x.xml create mode 100644 grc/blocks/gr_probe_signal_f.xml delete mode 100644 grc/blocks/probe_function.xml create mode 100644 grc/blocks/variable_function_probe.xml (limited to 'grc/blocks') diff --git a/grc/blocks/Makefile.am b/grc/blocks/Makefile.am index d9ec0896e..15c641fbc 100644 --- a/grc/blocks/Makefile.am +++ b/grc/blocks/Makefile.am @@ -60,7 +60,6 @@ dist_ourdata_DATA = \ blks2_tcp_sink.xml \ blks2_tcp_source.xml \ blks2_valve.xml \ - blks2_variable_sink_x.xml \ blks2_wfm_rcv.xml \ blks2_wfm_rcv_pll.xml \ blks2_wfm_tx.xml \ @@ -158,6 +157,7 @@ dist_ourdata_DATA = \ gr_probe_avg_mag_sqrd_x.xml \ gr_probe_density_b.xml \ gr_probe_mpsk_snr_c.xml \ + gr_probe_signal_f.xml \ gr_pwr_squelch_xx.xml \ gr_quadrature_demod_cf.xml \ gr_rational_resampler_base_xxx.xml \ @@ -201,7 +201,6 @@ dist_ourdata_DATA = \ pad_sink.xml \ pad_source.xml \ parameter.xml \ - probe_function.xml \ random_source_x.xml \ root_raised_cosine_filter.xml \ trellis_encoder_xx.xml \ @@ -221,6 +220,7 @@ dist_ourdata_DATA = \ usrp_simple_source_x.xml \ variable.xml \ variable_config.xml \ + variable_function_probe.xml \ virtual_sink.xml \ virtual_source.xml \ xmlrpc_client.xml \ diff --git a/grc/blocks/blks2_variable_sink_x.xml b/grc/blocks/blks2_variable_sink_x.xml deleted file mode 100644 index 5709c9f76..000000000 --- a/grc/blocks/blks2_variable_sink_x.xml +++ /dev/null @@ -1,77 +0,0 @@ - - - - Variable Sink - blks2_variable_sink_x - from grc_gnuradio import blks2 as grc_blks2 - grc_blks2.variable_sink_$(type.fcn)( - vlen=$vlen, - decim=$decim, - callback=self.set_$(variable()), -) - set_decim($decim) - - Type - type - enum - - - - - - - - Variable - variable - - string - - - Decimation - decim - 1 - int - - - Vec Length - vlen - 1 - int - - $vlen > 0 - - in - $type - $vlen - - -Read samples from the input stream and \ -write one in every decimation samples to the variable. - -The variable must be the id of an existing variable block. - - diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml index 50c463f55..e9a0c1591 100644 --- a/grc/blocks/block_tree.xml +++ b/grc/blocks/block_tree.xml @@ -26,7 +26,6 @@ Sinks - blks2_variable_sink_x gr_vector_sink_x gr_null_sink gr_file_sink @@ -261,7 +260,7 @@ gr_probe_avg_mag_sqrd_x gr_probe_density_b gr_probe_mpsk_snr_c - probe_function + gr_probe_signal_f USRP @@ -276,6 +275,7 @@ Variables variable variable_config + variable_function_probe parameter diff --git a/grc/blocks/gr_probe_avg_mag_sqrd_x.xml b/grc/blocks/gr_probe_avg_mag_sqrd_x.xml index eb855956a..ac409ad67 100644 --- a/grc/blocks/gr_probe_avg_mag_sqrd_x.xml +++ b/grc/blocks/gr_probe_avg_mag_sqrd_x.xml @@ -7,15 +7,10 @@ Probe Avg Mag^2 gr_probe_avg_mag_sqrd_x - from grc_gnuradio import blks2 as grc_blks2 - grc_blks2.probe_avg_mag_sqrd_$(type)( - threshold=$threshold, - alpha=$alpha, - probe_rate=$probe_rate, -) + from gnuradio import gr + gr.probe_avg_mag_sqrd_$(type)($threshold, $alpha) set_alpha($alpha) set_threshold($threshold) - set_probe_rate($probe_rate) Type type @@ -43,18 +38,11 @@ 1 real - - Probe Rate - probe_rate - 10 - real - in $type.input - - out - float - + +Available functions to probe: level + diff --git a/grc/blocks/gr_probe_density_b.xml b/grc/blocks/gr_probe_density_b.xml index 74d3b0a2b..8e0e2c964 100644 --- a/grc/blocks/gr_probe_density_b.xml +++ b/grc/blocks/gr_probe_density_b.xml @@ -7,13 +7,9 @@ Probe Density gr_probe_density_b - from grc_gnuradio import blks2 as grc_blks2 - grc_blks2.probe_density_b( - alpha=$alpha, - probe_rate=$probe_rate, -) + from gnuradio import gr + gr.probe_density_b($alpha) set_alpha($alpha) - set_probe_rate($probe_rate) Alpha alpha @@ -30,8 +26,7 @@ in byte - - out - float - + +Available functions to probe: density + diff --git a/grc/blocks/gr_probe_mpsk_snr_c.xml b/grc/blocks/gr_probe_mpsk_snr_c.xml index 7f562d2f3..38211b55f 100644 --- a/grc/blocks/gr_probe_mpsk_snr_c.xml +++ b/grc/blocks/gr_probe_mpsk_snr_c.xml @@ -7,49 +7,20 @@ Probe MPSK SNR gr_probe_mpsk_snr_c - from grc_gnuradio import blks2 as grc_blks2 - grc_blks2.probe_mpsk_snr_c( - type='$type', - alpha=$alpha, - probe_rate=$probe_rate, -) + from gnuradio import gr + gr.probe_mpsk_snr_c($alpha) set_alpha($alpha) - set_probe_rate($probe_rate) - - Type - type - enum - - - - Alpha alpha 1 real - - Probe Rate - probe_rate - 10 - real - in complex - - out - float - + +Available functions to probe: signal_mean, noise_variance + diff --git a/grc/blocks/gr_probe_signal_f.xml b/grc/blocks/gr_probe_signal_f.xml new file mode 100644 index 000000000..e1847788a --- /dev/null +++ b/grc/blocks/gr_probe_signal_f.xml @@ -0,0 +1,19 @@ + + + + Probe Signal + gr_probe_signal_f + from gnuradio import gr + gr.probe_signal_f() + + in + float + + +Available functions to probe: level + + diff --git a/grc/blocks/probe_function.xml b/grc/blocks/probe_function.xml deleted file mode 100644 index ac0b3dcde..000000000 --- a/grc/blocks/probe_function.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - Probe Function - probe_function - from grc_gnuradio import blks2 as grc_blks2 - grc_blks2.probe_function( - probe_callback=self.$(block_id()).$(function_name()), - probe_rate=$probe_rate, -) - set_probe_rate($probe_rate) - - Block ID - block_id - my_block_0 - string - - - Function Name - function_name - get_number - string - - - Probe Rate - probe_rate - 10 - real - - - out - float - - -Polls a function of an arbitrary block and writes the value to the output port. \ -The block id is the id of another block in the flow graph. \ -The function name is the name of a function in the said block. \ -The function should take no arguments and return a floating point or integer number. - - diff --git a/grc/blocks/variable_function_probe.xml b/grc/blocks/variable_function_probe.xml new file mode 100644 index 000000000..695d2f56c --- /dev/null +++ b/grc/blocks/variable_function_probe.xml @@ -0,0 +1,51 @@ + + + + Function Probe + variable_function_probe + import time + import threading + self.$(id) = $(id) = $value + #slurp +def _$(id)_probe(): + while True: + self.set_$(id)(self.$(block_id()).$(function_name())()) + time.sleep(1.0/($poll_rate)) +_$(id)_thread = threading.Thread(target=_$(id)_probe) +_$(id)_thread.daemon = True +_$(id)_thread.start() + self.set_$(id)($value) + + Value + value + 0 + raw + + + Block ID + block_id + my_block_0 + string + + + Function Name + function_name + get_number + string + + + Poll Rate (Hz) + poll_rate + 10 + real + + +Periodically probe a function and set its value to this variable. + +To poll a stream for a level, use this with the probe signal block. + + -- cgit From 4e0fb789e55e26bc16990a257c57494f3d3e6100 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 7 Mar 2011 11:43:34 -0800 Subject: grc: added function args to probe block and documentation --- grc/blocks/gr_probe_avg_mag_sqrd_x.xml | 4 +++- grc/blocks/gr_probe_density_b.xml | 4 +++- grc/blocks/gr_probe_mpsk_snr_c.xml | 4 +++- grc/blocks/gr_probe_signal_f.xml | 4 +++- grc/blocks/variable_function_probe.xml | 18 +++++++++++++++++- 5 files changed, 29 insertions(+), 5 deletions(-) (limited to 'grc/blocks') diff --git a/grc/blocks/gr_probe_avg_mag_sqrd_x.xml b/grc/blocks/gr_probe_avg_mag_sqrd_x.xml index ac409ad67..6bf706ae1 100644 --- a/grc/blocks/gr_probe_avg_mag_sqrd_x.xml +++ b/grc/blocks/gr_probe_avg_mag_sqrd_x.xml @@ -43,6 +43,8 @@ $type.input -Available functions to probe: level +Available functions to probe: level() + +Use with the function probe block. diff --git a/grc/blocks/gr_probe_density_b.xml b/grc/blocks/gr_probe_density_b.xml index 8e0e2c964..3a91256aa 100644 --- a/grc/blocks/gr_probe_density_b.xml +++ b/grc/blocks/gr_probe_density_b.xml @@ -27,6 +27,8 @@ byte -Available functions to probe: density +Available functions to probe: density() + +Use with the function probe block. diff --git a/grc/blocks/gr_probe_mpsk_snr_c.xml b/grc/blocks/gr_probe_mpsk_snr_c.xml index 38211b55f..5687e867d 100644 --- a/grc/blocks/gr_probe_mpsk_snr_c.xml +++ b/grc/blocks/gr_probe_mpsk_snr_c.xml @@ -21,6 +21,8 @@ complex -Available functions to probe: signal_mean, noise_variance +Available functions to probe: signal_mean(), noise_variance() + +Use with the function probe block. diff --git a/grc/blocks/gr_probe_signal_f.xml b/grc/blocks/gr_probe_signal_f.xml index e1847788a..5c38e816f 100644 --- a/grc/blocks/gr_probe_signal_f.xml +++ b/grc/blocks/gr_probe_signal_f.xml @@ -14,6 +14,8 @@ float -Available functions to probe: level +Available functions to probe: level() + +Use with the function probe block. diff --git a/grc/blocks/variable_function_probe.xml b/grc/blocks/variable_function_probe.xml index 695d2f56c..49f48fc89 100644 --- a/grc/blocks/variable_function_probe.xml +++ b/grc/blocks/variable_function_probe.xml @@ -13,7 +13,7 @@ #slurp def _$(id)_probe(): while True: - self.set_$(id)(self.$(block_id()).$(function_name())()) + self.set_$(id)(self.$(block_id()).$(function_name())($(function_args()))) time.sleep(1.0/($poll_rate)) _$(id)_thread = threading.Thread(target=_$(id)_probe) _$(id)_thread.daemon = True @@ -37,6 +37,13 @@ _$(id)_thread.start() get_number string + + Function Args + function_args + + string + #if $function_args() then 'none' else 'part'# + Poll Rate (Hz) poll_rate @@ -46,6 +53,15 @@ _$(id)_thread.start() Periodically probe a function and set its value to this variable. +Set the values for block ID, function name, and function args appropriately: \ +Block ID should be the ID of another block in this flow graph. \ +Function name should be the name of a class method on that block. \ +Function args are the parameters passed into that function. \ +For a function with no arguments, leave function args blank. + +The values will used literally, and generated into the following form: +self.block_id.function_name(function_args) + To poll a stream for a level, use this with the probe signal block. -- cgit From 9121b75d68a0c90deee814edffe387480b52019b Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 7 Mar 2011 18:40:57 -0800 Subject: qtgui-grc: minor tweaks to the various things --- grc/blocks/variable_function_probe.xml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'grc/blocks') diff --git a/grc/blocks/variable_function_probe.xml b/grc/blocks/variable_function_probe.xml index 49f48fc89..269966c70 100644 --- a/grc/blocks/variable_function_probe.xml +++ b/grc/blocks/variable_function_probe.xml @@ -13,7 +13,9 @@ #slurp def _$(id)_probe(): while True: - self.set_$(id)(self.$(block_id()).$(function_name())($(function_args()))) + val = self.$(block_id()).$(function_name())($(function_args())) + try: self.set_$(id)(val) + except AttributeError, e: pass time.sleep(1.0/($poll_rate)) _$(id)_thread = threading.Thread(target=_$(id)_probe) _$(id)_thread.daemon = True @@ -57,7 +59,8 @@ Set the values for block ID, function name, and function args appropriately: \ Block ID should be the ID of another block in this flow graph. \ Function name should be the name of a class method on that block. \ Function args are the parameters passed into that function. \ -For a function with no arguments, leave function args blank. +For a function with no arguments, leave function args blank. \ +When passing a string for the function arguments, quote the string literal: '"arg"'. The values will used literally, and generated into the following form: self.block_id.function_name(function_args) -- cgit