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/variable_function_probe.xml | 51 ++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 grc/blocks/variable_function_probe.xml (limited to 'grc/blocks/variable_function_probe.xml') 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/variable_function_probe.xml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'grc/blocks/variable_function_probe.xml') 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/variable_function_probe.xml') 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