diff options
author | Andrej Rode <mail@andrejro.de> | 2018-06-23 23:41:42 +0200 |
---|---|---|
committer | Andrej Rode <mail@andrejro.de> | 2018-06-24 00:03:35 +0200 |
commit | 167a6152bad060fc53dd29e0fa79ef83eff1be5b (patch) | |
tree | a01049672d9d7d1bf3d295ed96698a323941f8e8 /grc/blocks/variable_function_probe.block.yml | |
parent | 3c8e6008b092287246234001db7cf1a4038300da (diff) | |
parent | fcd002b6ac82e1e0c1224e24506410ff0833e1aa (diff) |
Merge branch 'python3_fix' into next
Manual merge conflict resolution has been applied to following
conflicts:
* Typos:
* gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py
* gr-blocks/python/blocks/qa_wavfile.py
* gr-filter/examples/gr_filtdes_api.py
* grc/blocks/parameter.xml
* gr-uhd/python/uhd/__init__.py
* ValueError -> RuntimeError:
* gr-blocks/python/blocks/qa_hier_block2.py
* relative Imports & other Py3k:
* gr-digital/python/digital/psk_constellations.py
* gr-digital/python/digital/qam_constellations.py
* gr-digital/python/digital/test_soft_decisions.py
* gr-digital/python/digital/gfsk.py
* SequenceCompleter:
* gr-utils/python/modtool/modtool_add.py
* gr-utils/python/modtool/modtool_rename.py
* gr-utils/python/modtool/modtool_rm.py
* Updated API on next:
* gr-blocks/grc/blocks_file_source.xml
* gr-blocks/python/blocks/qa_file_source_sink.py
* gr-qtgui/grc/qtgui_time_sink_x.xml
* GRC Py3k Updates:
* grc/core/Block.py
* grc/core/Constants.py
* grc/core/Platform.py
* grc/core/utils/odict.py
* grc/gui/Actions.py
* grc/gui/Block.py
* grc/gui/Executor.py
* grc/gui/Port.py
Diffstat (limited to 'grc/blocks/variable_function_probe.block.yml')
-rw-r--r-- | grc/blocks/variable_function_probe.block.yml | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/grc/blocks/variable_function_probe.block.yml b/grc/blocks/variable_function_probe.block.yml new file mode 100644 index 0000000000..702ab5d60e --- /dev/null +++ b/grc/blocks/variable_function_probe.block.yml @@ -0,0 +1,54 @@ +id: variable_function_probe +label: Function Probe + +parameters: +- id: block_id + label: Block ID + dtype: string + default: my_block_0 +- id: function_name + label: Function Name + dtype: string + default: get_number +- id: function_args + label: Function Args + dtype: string + hide: ${ ('none' if function_args else 'part') } +- id: poll_rate + label: Poll Rate (Hz) + dtype: real + default: '10' +- id: value + label: Initial Value + dtype: raw + default: '0' + hide: part +value: ${ value } + +templates: + imports: |- + import time + import threading + var_make: self.${id} = ${id} = ${value} + make: "\ndef _${id}_probe():\n while True:\n <% obj = 'self' + ('.'\ + \ + block_id if block_id else '') %>\n val = ${obj}.${function_name}(${function_args})\n\ + \ try:\n self.set_${id}(val)\n except AttributeError:\n\ + \ pass\n time.sleep(1.0 / (${poll_rate}))\n_${id}_thread\ + \ = threading.Thread(target=_${id}_probe)\n_${id}_thread.daemon = True\n_${id}_thread.start()\n\ + \ " + callbacks: + - self.set_${id}(${value}) + +documentation: |- + 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. An empty Block ID references the flow graph itself. 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. 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) + or, if the Block ID is empty, + self.function_name(function_args) + + To poll a stream for a level, use this with the probe signal block. + +file_format: 1 |