diff options
author | Sebastian Koslowski <sebastian.koslowski@gmail.com> | 2017-10-26 18:32:10 +0200 |
---|---|---|
committer | Sebastian Koslowski <sebastian.koslowski@gmail.com> | 2017-10-26 18:32:10 +0200 |
commit | 5ba75e6cbf432a39e94efb9ec915259e1424c3e4 (patch) | |
tree | 4cb9f3684fc9e9ca84d63d8f0da1e304f70bd00b /grc | |
parent | 06acc2eb6a3caee1aa26506935877da15eeec1b6 (diff) | |
parent | 4804d1fdb6950d2b2ec5707cd8a362f01ed2cf90 (diff) |
Merge branch 'github/pr/1481' into merges/python3
Diffstat (limited to 'grc')
33 files changed, 761 insertions, 1226 deletions
diff --git a/grc/blocks/CMakeLists.txt b/grc/blocks/CMakeLists.txt index 2dbc7c6d0d..f5ec6dd214 100644 --- a/grc/blocks/CMakeLists.txt +++ b/grc/blocks/CMakeLists.txt @@ -21,40 +21,39 @@ include(GrPython) file(GLOB yml_files "*.yml") -file(GLOB xml_files "*.xml") -macro(REPLACE_IN_FILE _xml_block match replace) - set(xml_block_src "${CMAKE_CURRENT_SOURCE_DIR}/${_xml_block}") - set(xml_block "${CMAKE_CURRENT_BINARY_DIR}/${_xml_block}") +macro(REPLACE_IN_FILE _yml_block match replace) + set(yml_block_src "${CMAKE_CURRENT_SOURCE_DIR}/${_yml_block}") + set(yml_block "${CMAKE_CURRENT_BINARY_DIR}/${_yml_block}") - list(REMOVE_ITEM xml_files "${xml_block_src}") - file(READ "${xml_block_src}" xml_block_src_text) + list(REMOVE_ITEM yml_files "${yml_block_src}") + file(READ "${yml_block_src}" yml_block_src_text) string(REPLACE "${match}" "${replace}" - xml_block_text "${xml_block_src_text}") - file(WRITE "${xml_block}" "${xml_block_text}") + yml_block_text "${yml_block_src_text}") + file(WRITE "${yml_block}" "${yml_block_text}") - list(APPEND generated_xml_files "${xml_block}") + list(APPEND generated_yml_files "${yml_block}") endmacro() -macro(GEN_BLOCK_XML _generator _xml_block) +macro(GEN_BLOCK_YML _generator _yml_block) set(generator ${CMAKE_CURRENT_SOURCE_DIR}/${_generator}) - set(xml_block ${CMAKE_CURRENT_BINARY_DIR}/${_xml_block}) - list(APPEND generated_xml_files ${xml_block}) + set(yml_block ${CMAKE_CURRENT_BINARY_DIR}/${_yml_block}) + list(APPEND generated_yml_files ${yml_block}) add_custom_command( - DEPENDS ${generator} OUTPUT ${xml_block} - COMMAND ${PYTHON_EXECUTABLE} ${generator} ${xml_block} + DEPENDS ${generator} OUTPUT ${yml_block} + COMMAND ${PYTHON_EXECUTABLE} ${generator} ${yml_block} ) endmacro() -GEN_BLOCK_XML(variable_struct.xml.py variable_struct.xml) +GEN_BLOCK_YML(variable_struct.block.yml.py variable_struct.block.yml) if(DESIRED_QT_VERSION EQUAL 4) - REPLACE_IN_FILE(options.xml PyQt5 PyQt4) + REPLACE_IN_FILE(options.yml PyQt5 PyQt4) endif() -add_custom_target(grc_generated_xml ALL DEPENDS ${generated_xml_files}) +add_custom_target(grc_generated_yml ALL DEPENDS ${generated_yml_files}) install( - FILES ${yml_files} ${xml_files} ${generated_xml_files} + FILES ${yml_files} ${generated_yml_files} DESTINATION ${GRC_BLOCKS_DIR} ) diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml deleted file mode 100644 index 2a063f1f60..0000000000 --- a/grc/blocks/block_tree.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0"?> -<cat> - <name>[Core]</name> - <cat> - <name>Misc</name> - <block>pad_source</block> - <block>pad_sink</block> - <block>virtual_source</block> - <block>virtual_sink</block> - - <block>epy_module</block> - - <block>note</block> - <block>import</block> - </cat> - <cat> - <name>Variables</name> - <block>variable</block> - <block>variable_struct</block> - <block>variable_config</block> - <block>variable_function_probe</block> - <block>parameter</block> - </cat> -</cat> diff --git a/grc/blocks/grc.tree.yml b/grc/blocks/grc.tree.yml new file mode 100644 index 0000000000..c84a6dc478 --- /dev/null +++ b/grc/blocks/grc.tree.yml @@ -0,0 +1,15 @@ +'[Core]': +- Misc: + - pad_source + - pad_sink + - virtual_source + - virtual_sink + - epy_module + - note + - import +- Variables: + - variable + - variable_struct + - variable_config + - variable_function_probe + - parameter diff --git a/grc/blocks/import.block.yml b/grc/blocks/import.block.yml new file mode 100644 index 0000000000..2d36b7396d --- /dev/null +++ b/grc/blocks/import.block.yml @@ -0,0 +1,20 @@ +id: import_ +label: Import + +parameters: +- id: imports + label: Import + dtype: import + +templates: + imports: ${imports} + +documentation: |- + Import additional python modules into the namespace. + + Examples: + from gnuradio.filter import firdes + import math,cmath + from math import pi + +file_format: 1 diff --git a/grc/blocks/import.xml b/grc/blocks/import.xml deleted file mode 100644 index 58e99a2d01..0000000000 --- a/grc/blocks/import.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Import python modules into the namespace -################################################### - --> -<block> - <name>Import</name> - <key>import</key> - <import>$imports</import> - <make></make> - <param> - <name>Import</name> - <key>imports</key> - <value></value> - <type>import</type> - </param> - <doc> -Import additional python modules into the namespace. - -Examples: -from gnuradio.filter import firdes -import math,cmath -from math import pi - </doc> -</block> diff --git a/grc/blocks/note.block.yml b/grc/blocks/note.block.yml new file mode 100644 index 0000000000..3f21a75ceb --- /dev/null +++ b/grc/blocks/note.block.yml @@ -0,0 +1,9 @@ +id: note +label: Note + +parameters: +- id: note + label: Note + dtype: string + +file_format: 1 diff --git a/grc/blocks/note.xml b/grc/blocks/note.xml deleted file mode 100644 index db6687c033..0000000000 --- a/grc/blocks/note.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Note Block (dummy) -################################################### - --> -<block> - <name>Note</name> - <key>note</key> - <make></make> - <param> - <name>Note</name> - <key>note</key> - <value></value> - <type>string</type> - </param> -</block> diff --git a/grc/blocks/options.block.yml b/grc/blocks/options.block.yml new file mode 100644 index 0000000000..ab18f8ae5f --- /dev/null +++ b/grc/blocks/options.block.yml @@ -0,0 +1,146 @@ +id: options +label: Options + +parameters: +- id: title + label: Title + dtype: string + hide: ${ ('none' if title else 'part') } +- id: author + label: Author + dtype: string + hide: ${ ('none' if author else 'part') } +- id: description + label: Description + dtype: string + hide: ${ ('none' if description else 'part') } +- id: window_size + label: Canvas Size + dtype: int_vector + hide: part +- id: generate_options + label: Generate Options + dtype: enum + default: qt_gui + options: [qt_gui, bokeh_gui, no_gui, hb, hb_qt_gui] + option_labels: [QT GUI, Bokeh GUI, No GUI, Hier Block, Hier Block (QT GUI)] +- id: category + label: Category + dtype: string + default: '[GRC Hier Blocks]' + hide: ${ ('none' if generate_options.startswith('hb') else 'all') } +- id: run_options + label: Run Options + dtype: enum + default: prompt + options: [run, prompt] + option_labels: [Run to Completion, Prompt for Exit] + hide: ${ ('none' if generate_options == 'no_gui' else 'all') } +- id: placement + label: Widget Placement + dtype: int_vector + default: (0,0) + hide: ${ ('part' if generate_options == 'bokeh_gui' else 'all') } +- id: sizing_mode + label: Sizing Mode + dtype: enum + default: fixed + options: [fixed, stretch_both, scale_width, scale_height, scale_both] + option_labels: [Fixed, Stretch Both, Scale Width, Scale Height, Scale Both] + hide: ${ ('part' if generate_options == 'bokeh_gui' else 'all') } +- id: run + label: Run + dtype: bool + default: 'True' + options: ['True', 'False'] + option_labels: [Autostart, 'Off'] + hide: ${ ('all' if generate_options not in ('qt_gui', 'bokeh_gui') else ('part' + if run else 'none')) } +- id: max_nouts + label: Max Number of Output + dtype: int + default: '0' + hide: ${ ('all' if generate_options.startswith('hb') else ('none' if max_nouts + else 'part')) } +- id: realtime_scheduling + label: Realtime Scheduling + dtype: enum + options: ['', '1'] + option_labels: ['Off', 'On'] + hide: ${ ('all' if generate_options.startswith('hb') else ('none' if realtime_scheduling + else 'part')) } +- id: qt_qss_theme + label: QSS Theme + dtype: file_open + hide: ${ ('all' if generate_options != 'qt_gui' else ('none' if qt_qss_theme else + 'part')) } +- id: thread_safe_setters + label: Thread-safe setters + category: Advanced + dtype: enum + options: ['', '1'] + option_labels: ['Off', 'On'] + hide: part +- id: run_command + label: Run Command + category: Advanced + dtype: string + default: '{python} -u {filename}' + hide: ${ ('all' if generate_options.startswith('hb') else 'part') } +- id: hier_block_src_path + label: Hier Block Source Path + category: Advanced + dtype: string + default: '.:' + hide: part + +asserts: +- ${ not window_size or len(window_size) == 2 } +- ${ not window_size or 300 <= window_size[0] <= 4096 } +- ${ not window_size or 300 <= window_size[1] <= 4096 } +- ${ len(placement) == 4 or len(placement) == 2 } +- ${ all(i >= 0 for i in placement) } + +templates: + imports: |- + from gnuradio import gr + from gnuradio.filter import firdes + % if generate_options == 'qt_gui': + from PyQt5 import Qt + import sys + % endif + % if generate_options == 'bokeh_gui': + import time + import signal + import functools + from bokeh.client import push_session + from bokeh.plotting import curdoc + % endif + % if not generate_options.startswith('hb'): + from argparse import ArgumentParser + from gnuradio.eng_arg import eng_float, intx + from gnuradio import eng_notation + % endif + callbacks: + - 'if ${run}: self.start() + + else: self.stop(); self.wait()' + +documentation: |- + The options block sets special parameters for the flow graph. Only one option block is allowed per flow graph. + + Title, author, and description parameters are for identification purposes. + + The window size controls the dimensions of the flow graph editor. The window size (width, height) must be between (300, 300) and (4096, 4096). + + The generate options controls the type of code generated. Non-graphical flow graphs should avoid using graphical sinks or graphical variable controls. + + In a graphical application, run can be controlled by a variable to start and stop the flowgraph at runtime. + + The id of this block determines the name of the generated file and the name of the class. For example, an id of my_block will generate the file my_block.py and class my_block(gr.... + + The category parameter determines the placement of the block in the block selection window. The category only applies when creating hier blocks. To put hier blocks into the root category, enter / for the category. + + The Max Number of Output is the maximum number of output items allowed for any block in the flowgraph; to disable this set the max_nouts equal to 0.Use this to adjust the maximum latency a flowgraph can exhibit. + +file_format: 1 diff --git a/grc/blocks/options.xml b/grc/blocks/options.xml deleted file mode 100644 index 5fa4fc1b17..0000000000 --- a/grc/blocks/options.xml +++ /dev/null @@ -1,250 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Options Block: -## options for window size, -## and flow graph building. -################################################### - --> -<block> - <name>Options</name> - <key>options</key> - <import>from gnuradio import gr</import> - <import>from gnuradio.filter import firdes</import> - <import>#if $generate_options() == 'qt_gui' -from PyQt5 import Qt -import sys -#end if -#if $generate_options() == 'bokeh_gui' -import time -import signal -import functools -from bokeh.client import push_session -from bokeh.plotting import curdoc -#end if -#if not $generate_options().startswith('hb') -from argparse import ArgumentParser -from gnuradio.eng_arg import eng_float, intx -from gnuradio import eng_notation -#end if</import> - <make></make> - <callback>if $run: self.start() -else: self.stop(); self.wait()</callback> - <param> - <name>Title</name> - <key>title</key> - <value></value> - <type>string</type> - <hide>#if $title() then 'none' else 'part'#</hide> - </param> - <param> - <name>Author</name> - <key>author</key> - <value></value> - <type>string</type> - <hide>#if $author() then 'none' else 'part'#</hide> - </param> - <param> - <name>Description</name> - <key>description</key> - <value></value> - <type>string</type> - <hide>#if $description() then 'none' else 'part'#</hide> - </param> - <param> - <name>Canvas Size</name> - <key>window_size</key> - <value></value> - <type>int_vector</type> - <hide>part</hide> - </param> - <param> - <name>Generate Options</name> - <key>generate_options</key> - <value>qt_gui</value> - <type>enum</type> - <option> - <name>QT GUI</name> - <key>qt_gui</key> - </option> - <option> - <name>Bokeh GUI</name> - <key>bokeh_gui</key> - </option> - <option> - <name>No GUI</name> - <key>no_gui</key> - </option> - <option> - <name>Hier Block</name> - <key>hb</key> - </option> - <option> - <name>Hier Block (QT GUI)</name> - <key>hb_qt_gui</key> - </option> - </param> - <param> - <name>Category</name> - <key>category</key> - <value>[GRC Hier Blocks]</value> - <type>string</type> - <hide>#if $generate_options().startswith('hb') then 'none' else 'all'#</hide> - </param> - <param> - <name>Run Options</name> - <key>run_options</key> - <value>prompt</value> - <type>enum</type> - <hide>#if $generate_options() == 'no_gui' then 'none' else 'all'#</hide> - <option> - <name>Run to Completion</name> - <key>run</key> - </option> - <option> - <name>Prompt for Exit</name> - <key>prompt</key> - </option> - </param> - <param> - <name>Widget Placement</name> - <key>placement</key> - <value>(0,0)</value> - <type>int_vector</type> - <hide>#if $generate_options() == 'bokeh_gui' then 'part' else 'all'#</hide> - </param> - <param> - <name>Sizing Mode</name> - <key>sizing_mode</key> - <value>fixed</value> - <type>enum</type> - <hide>#if $generate_options() == 'bokeh_gui' then 'part' else 'all'#</hide> - <option> - <name>Fixed</name> - <key>fixed</key> - </option> - <option> - <name>Stretch Both</name> - <key>stretch_both</key> - </option> - <option> - <name>Scale Width</name> - <key>scale_width</key> - </option> - <option> - <name>Scale Height</name> - <key>scale_height</key> - </option> - <option> - <name>Scale Both</name> - <key>scale_both</key> - </option> - </param> - <param> - <name>Run</name> - <key>run</key> - <value>True</value> - <type>bool</type> - <hide>#if $generate_options() not in ('qt_gui', 'bokeh_gui') then 'all' else ('part' if $run() else 'none')#</hide> - <option> - <name>Autostart</name> - <key>True</key> - </option> - <option> - <name>Off</name> - <key>False</key> - </option> - </param> - <param> - <name>Max Number of Output</name> - <key>max_nouts</key> - <value>0</value> - <type>int</type> - <hide>#if $generate_options().startswith('hb') then 'all' else ('none' if $max_nouts() else 'part')#</hide> - </param> - <param> - <name>Realtime Scheduling</name> - <key>realtime_scheduling</key> - <value></value> - <type>enum</type> - <hide>#if $generate_options().startswith('hb') then 'all' else ('none' if $realtime_scheduling() else 'part')#</hide> - <option> - <name>Off</name> - <key></key> - </option> - <option> - <name>On</name> - <key>1</key> - </option> - </param> - <param> - <name>QSS Theme</name> - <key>qt_qss_theme</key> - <value></value> - <type>file_open</type> - <hide>#if $generate_options() != 'qt_gui' then 'all' else ('none' if $qt_qss_theme() else 'part')#</hide> - </param> - <param> - <name>Thread-safe setters</name> - <key>thread_safe_setters</key> - <value></value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Off</name> - <key></key> - </option> - <option> - <name>On</name> - <key>1</key> - </option> - <tab>Advanced</tab> - </param> - <param> - <name>Run Command</name> - <key>run_command</key> - <value>{python} -u {filename}</value> - <type>string</type> - <hide>#if $generate_options().startswith('hb') then 'all' else 'part'</hide> - <tab>Advanced</tab> - </param> - <param> - <name>Hier Block Source Path</name> - <key>hier_block_src_path</key> - <value>.:</value> - <type>string</type> - <hide>part</hide> - <tab>Advanced</tab> - </param> - <check>not $window_size or len($window_size) == 2</check> - <check>not $window_size or 300 <= $(window_size)[0] <= 4096</check> - <check>not $window_size or 300 <= $(window_size)[1] <= 4096</check> - <check>len($placement) == 4 or len($placement) == 2</check> - <check>all(i >= 0 for i in $(placement))</check> - <doc> -The options block sets special parameters for the flow graph. \ -Only one option block is allowed per flow graph. - -Title, author, and description parameters are for identification purposes. - -The window size controls the dimensions of the flow graph editor. \ -The window size (width, height) must be between (300, 300) and (4096, 4096). - -The generate options controls the type of code generated. \ -Non-graphical flow graphs should avoid using graphical sinks or graphical variable controls. - -In a graphical application, \ -run can be controlled by a variable to start and stop the flowgraph at runtime. - -The id of this block determines the name of the generated file and the name of the class. \ -For example, an id of my_block will generate the file my_block.py and class my_block(gr.... - -The category parameter determines the placement of the block in the block selection window. \ -The category only applies when creating hier blocks. \ -To put hier blocks into the root category, enter / for the category. - -The Max Number of Output is the maximum number of output items allowed for any block \ -in the flowgraph; to disable this set the max_nouts equal to 0.\ -Use this to adjust the maximum latency a flowgraph can exhibit. - </doc> -</block> diff --git a/grc/blocks/pad_sink.block.yml b/grc/blocks/pad_sink.block.yml new file mode 100644 index 0000000000..d304a998b4 --- /dev/null +++ b/grc/blocks/pad_sink.block.yml @@ -0,0 +1,51 @@ +id: pad_sink +label: Pad Sink + +parameters: +- id: label + label: Label + dtype: string + default: out +- id: type + label: Input Type + dtype: enum + options: [complex, float, int, short, byte, bit, message, ''] + option_labels: [Complex, Float, Int, Short, Byte, Bits, Message, Wildcard] + option_attributes: + size: [gr.sizeof_gr_complex, gr.sizeof_float, gr.sizeof_int, gr.sizeof_short, + gr.sizeof_char, gr.sizeof_char, '0', '0'] + hide: part +- id: vlen + label: Vec Length + dtype: int + default: '1' + hide: ${ 'part' if vlen == 1 else 'none' } +- id: num_streams + label: Num Streams + dtype: int + default: '1' + hide: part +- id: optional + label: Optional + dtype: bool + default: 'False' + options: ['True', 'False'] + option_labels: [Optional, Required] + hide: part + +inputs: +- domain: stream + dtype: ${ type } + vlen: ${ vlen } + multiplicity: ${ num_streams } + +asserts: +- ${ vlen > 0 } +- ${ num_streams > 0 } + +documentation: |- + The inputs of this block will become the outputs to this flow graph when it is instantiated as a hierarchical block. + + Pad sink will be ordered alphabetically by their ids. The first pad sink will have an index of 0. + +file_format: 1 diff --git a/grc/blocks/pad_sink.xml b/grc/blocks/pad_sink.xml deleted file mode 100644 index 8ea8871d2e..0000000000 --- a/grc/blocks/pad_sink.xml +++ /dev/null @@ -1,103 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Pad Sink: IO Pads -################################################### - --> -<block> - <name>Pad Sink</name> - <key>pad_sink</key> - <make></make> - <param> - <name>Label</name> - <key>label</key> - <value>out</value> - <type>string</type> - </param> - <param> - <name>Input Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>size:gr.sizeof_gr_complex</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>size:gr.sizeof_float</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>size:gr.sizeof_int</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>size:gr.sizeof_short</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>size:gr.sizeof_char</opt> - </option> - <option> - <name>Bits</name> - <key>bit</key> - <opt>size:gr.sizeof_char</opt> - </option> - <option> - <name>Message</name> - <key>message</key> - <opt>size:0</opt> - </option> - <option> - <name>Wildcard</name> - <key></key> - <opt>size:0</opt> - </option> - </param> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - - <param> - <name>Num Streams</name> - <key>num_streams</key> - <value>1</value> - <type>int</type> - </param> - <param> - <name>Optional</name> - <key>optional</key> - <value>False</value> - <type>bool</type> - <hide>part</hide> - <option> - <name>Optional</name> - <key>True</key> - </option> - <option> - <name>Required</name> - <key>False</key> - </option> - </param> - <check>$vlen > 0</check> - <check>$num_streams > 0</check> - <sink> - <name>in</name> - <type>$type</type> - <vlen>$vlen</vlen> - <nports>$num_streams</nports> - </sink> - <doc> -The inputs of this block will become the outputs to this flow graph when it is instantiated as a hierarchical block. - -Pad sink will be ordered alphabetically by their ids. The first pad sink will have an index of 0. - </doc> -</block> diff --git a/grc/blocks/pad_source.block.yml b/grc/blocks/pad_source.block.yml new file mode 100644 index 0000000000..92f7a8b822 --- /dev/null +++ b/grc/blocks/pad_source.block.yml @@ -0,0 +1,51 @@ +id: pad_source +label: Pad Source + +parameters: +- id: label + label: Label + dtype: string + default: in +- id: type + label: Output Type + dtype: enum + options: [complex, float, int, short, byte, bit, message, ''] + option_labels: [Complex, Float, Int, Short, Byte, Bits, Message, Wildcard] + option_attributes: + size: [gr.sizeof_gr_complex, gr.sizeof_float, gr.sizeof_int, gr.sizeof_short, + gr.sizeof_char, gr.sizeof_char, '0', '0'] + hide: part +- id: vlen + label: Vec Length + dtype: int + default: '1' + hide: ${ 'part' if vlen == 1 else 'none' } +- id: num_streams + label: Num Streams + dtype: int + default: '1' + hide: part +- id: optional + label: Optional + dtype: bool + default: 'False' + options: ['True', 'False'] + option_labels: [Optional, Required] + hide: part + +outputs: +- domain: stream + dtype: ${ type } + vlen: ${ vlen } + multiplicity: ${ num_streams } + +asserts: +- ${ vlen > 0 } +- ${ num_streams > 0 } + +documentation: |- + The outputs of this block will become the inputs to this flow graph when it is instantiated as a hierarchical block. + + Pad sources will be ordered alphabetically by their ids. The first pad source will have an index of 0. + +file_format: 1 diff --git a/grc/blocks/pad_source.xml b/grc/blocks/pad_source.xml deleted file mode 100644 index 3d8ccbed6a..0000000000 --- a/grc/blocks/pad_source.xml +++ /dev/null @@ -1,104 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Pad Source: IO Pads -################################################### - --> -<block> - <name>Pad Source</name> - <key>pad_source</key> - <make></make> - <param> - <name>Label</name> - <key>label</key> - <value>in</value> - <type>string</type> - </param> - <param> - <name>Output Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>size:gr.sizeof_gr_complex</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>size:gr.sizeof_float</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>size:gr.sizeof_int</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>size:gr.sizeof_short</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>size:gr.sizeof_char</opt> - </option> - <option> - <name>Bits</name> - <key>bit</key> - <opt>size:gr.sizeof_char</opt> - </option> - <option> - <name>Message</name> - <key>message</key> - <opt>size:0</opt> - </option> - <option> - <name>Wildcard</name> - <key></key> - <opt>size:0</opt> - </option> - </param> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - - <param> - <name>Num Streams</name> - <key>num_streams</key> - <value>1</value> - <type>int</type> - </param> - - <param> - <name>Optional</name> - <key>optional</key> - <value>False</value> - <type>bool</type> - <hide>part</hide> - <option> - <name>Optional</name> - <key>True</key> - </option> - <option> - <name>Required</name> - <key>False</key> - </option> - </param> - <check>$vlen > 0</check> - <check>$num_streams > 0</check> - <source> - <name>out</name> - <type>$type</type> - <vlen>$vlen</vlen> - <nports>$num_streams</nports> - </source> - <doc> -The outputs of this block will become the inputs to this flow graph when it is instantiated as a hierarchical block. - -Pad sources will be ordered alphabetically by their ids. The first pad source will have an index of 0. - </doc> -</block> diff --git a/grc/blocks/parameter.block.yml b/grc/blocks/parameter.block.yml new file mode 100644 index 0000000000..ac97c7d319 --- /dev/null +++ b/grc/blocks/parameter.block.yml @@ -0,0 +1,55 @@ +id: parameter +label: Parameter + +parameters: +- id: label + label: Label + dtype: string + hide: ${ ('none' if label else 'part') } +- id: value + label: Value + dtype: ${ type.type } + default: '0' +- id: type + label: Type + dtype: enum + options: ['', complex, eng_float, intx, long, str] + option_labels: [None, Complex, Float, Int, Long, String] + option_attributes: + type: [raw, complex, real, int, int, string] + hide: ${ ('none' if type else 'part') } +- id: short_id + label: Short ID + dtype: string + hide: ${ 'all' if not type else ('none' if short_id else 'part') } +- id: hide + label: Show + dtype: enum + options: [none, part] + option_labels: [Always, Only in Properties] + hide: part + +asserts: +- ${ len(short_id) in (0, 1) } +- ${ short_id == '' or short_id.isalpha() } + +templates: + var_make: self.${id} = ${id} + make: ${value} + +documentation: |- + This block represents a parameter to the flow graph. A parameter can be used to pass command line arguments into a top block. Or, parameters can pass arguments into an instantiated hierarchical block. + + The paramater value cannot depend on any variables. + + Leave the label blank to use the parameter id as the label. + + When type is not None, this parameter also becomes a command line option of the form: + + -[short_id] --[id] [value] + + The Short ID field may be left blank. + + To disable showing the parameter on the hierarchical block in GRC, use Only in Properties option in the Show field. + +file_format: 1 diff --git a/grc/blocks/parameter.xml b/grc/blocks/parameter.xml deleted file mode 100644 index f01527acb0..0000000000 --- a/grc/blocks/parameter.xml +++ /dev/null @@ -1,118 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Parameter block: a grc variable with key, value -################################################### - --> -<block> - <name>Parameter</name> - <key>parameter</key> - <var_make>self.$(id) = $(id)</var_make> - <make>$value</make> - <param> - <name>Label</name> - <key>label</key> - <value></value> - <type>string</type> - <hide>#if $label() then 'none' else 'part'#</hide> - </param> - <param> - <name>Value</name> - <key>value</key> - <value>0</value> - <type>$type.type</type> - </param> - <param> - <name>Type</name> - <key>type</key> - <value></value> - <type>enum</type> - <hide>#if $type() then 'none' else 'part'#</hide> - <option> - <name>None</name> - <key></key> - <opt>type:raw</opt> - </option> - <option> - <name>Complex</name> - <key>complex</key> - <opt>type:complex</opt> - </option> - <option> - <name>Float</name> - <key>eng_float</key> - <opt>type:real</opt> - </option> - <option> - <name>Int</name> - <key>intx</key> - <opt>type:int</opt> - </option> - <option> - <name>Long</name> - <key>long</key> - <opt>type:int</opt> - </option> - <option> - <name>String</name> - <key>str</key> - <opt>type:string</opt> - </option> - <!-- Do not forget to add option value type handler import into - grc/python/flow_graph.tmpl for each new type. --> - <!-- not supported yet in tmpl - <option> - <name>Boolean</name> - <key>bool</key> - <opt>type:bool</opt> - </option> - --> - </param> - <param> - <name>Short ID</name> - <key>short_id</key> - <value></value> - <type>string</type> - <hide>#if not $type() -all#slurp -#elif $short_id() -none#slurp -#else -part#slurp -#end if</hide> - </param> - <param> - <name>Show</name> - <key>hide</key> - <value></value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Always</name> - <key>none</key> <!--## Do not hide the parameter value--> - </option> - <option> - <name>Only in Properties</name> - <key>part</key> <!--## Partially hide the parameter value--> - </option> - </param> - <check>len($short_id) in (0, 1)</check> - <check>$short_id == '' or $(short_id).isalpha()</check> - <doc> -This block represents a parameter to the flow graph. \ -A parameter can be used to pass command line arguments into a top block. \ -Or, parameters can pass arguments into an instantiated hierarchical block. - -The paramater value cannot depend on any variables. - -Leave the label blank to use the parameter id as the label. - -When type is not None, this parameter also becomes a command line option of the form: - --[short_id] --[id] [value] - -The Short ID field may be left blank. - -To disable showing the parameter on the hierarchical block in GRC, use Only in Properties option in the Show field. - </doc> -</block> diff --git a/grc/blocks/variable.block.yml b/grc/blocks/variable.block.yml new file mode 100644 index 0000000000..fa62dabe87 --- /dev/null +++ b/grc/blocks/variable.block.yml @@ -0,0 +1,19 @@ +id: variable +label: Variable + +parameters: +- id: value + label: Value + dtype: raw + default: '0' +value: ${ value } + +templates: + var_make: self.${id} = ${id} = ${value} + callbacks: + - self.set_${id}(${value}) + +documentation: |- + This block maps a value to a unique variable. This variable block has no graphical representation. + +file_format: 1 diff --git a/grc/blocks/variable.xml b/grc/blocks/variable.xml deleted file mode 100644 index afee0f5d4a..0000000000 --- a/grc/blocks/variable.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Variable block: a grc variable with key, value -################################################### - --> -<block> - <name>Variable</name> - <key>variable</key> - <var_make>self.$(id) = $(id) = $value</var_make> - <make></make> - <callback>self.set_$(id)($value)</callback> - <param> - <name>Value</name> - <key>value</key> - <value>0</value> - <type>raw</type> - </param> - <doc> -This block maps a value to a unique variable. \ -This variable block has no graphical representation. - </doc> -</block> diff --git a/grc/blocks/variable_config.block.yml b/grc/blocks/variable_config.block.yml new file mode 100644 index 0000000000..bb64ea2a8f --- /dev/null +++ b/grc/blocks/variable_config.block.yml @@ -0,0 +1,58 @@ +id: variable_config +label: Variable Config + +parameters: +- id: value + label: Default Value + dtype: ${ type } + default: '0' +- id: type + label: Type + dtype: enum + default: real + options: [real, int, bool, string] + option_labels: [Float, Int, Bool, String] + option_attributes: + get: [getfloat, getint, getboolean, get] +- id: config_file + label: Config File + dtype: file_open + default: default +- id: section + label: Section + dtype: string + default: main +- id: option + label: Option + dtype: string + default: key +- id: writeback + label: WriteBack + dtype: raw + default: None +value: ${ value } + +templates: + imports: import ConfigParser + var_make: 'self._${id}_config = ConfigParser.ConfigParser() + + self._${id}_config.read(${config_file}) + + try: ${id} = self._${id}_config.${type.get}(${section}, ${option}) + + except: ${id} = ${value} + + self.${id} = ${id}' + callbacks: + - self.set_${id}(${value}) + - "self._${id}_config = ConfigParser.ConfigParser()\nself._${id}_config.read(${config_file})\n\ + if not self._${id}_config.has_section(${section}):\n\tself._${id}_config.add_section(${section})\n\ + self._${id}_config.set(${section}, ${option}, str(${writeback}))\nself._${id}_config.write(open(${config_file},\ + \ 'w'))" + +documentation: |- + This block represents a variable that can be read from a config file. + + To save the value back into the config file: enter the name of another variable into the writeback param. When the other variable is changed at runtime, the config file will be re-written. + +file_format: 1 diff --git a/grc/blocks/variable_config.xml b/grc/blocks/variable_config.xml deleted file mode 100644 index 11bff9edc2..0000000000 --- a/grc/blocks/variable_config.xml +++ /dev/null @@ -1,88 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Variable Config block: -## a variable that reads and writes to a config file -################################################### - --> -<block> - <name>Variable Config</name> - <key>variable_config</key> - <import>import ConfigParser</import> - <var_make>self._$(id)_config = ConfigParser.ConfigParser() -self._$(id)_config.read($config_file) -try: $(id) = self._$(id)_config.$(type.get)($section, $option) -except: $(id) = $value -self.$(id) = $(id)</var_make> - <make></make> - <callback>self.set_$(id)($value)</callback> - <callback>self._$(id)_config = ConfigParser.ConfigParser() -self._$(id)_config.read($config_file) -if not self._$(id)_config.has_section($section): - self._$(id)_config.add_section($section) -self._$(id)_config.set($section, $option, str($writeback)) -self._$(id)_config.write(open($config_file, 'w'))</callback> - <param> - <name>Default Value</name> - <key>value</key> - <value>0</value> - <type>$type</type> - </param> - <param> - <name>Type</name> - <key>type</key> - <value>real</value> - <type>enum</type> - <option> - <name>Float</name> - <key>real</key> - <opt>get:getfloat</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>get:getint</opt> - </option> - <option> - <name>Bool</name> - <key>bool</key> - <opt>get:getboolean</opt> - </option> - <option> - <name>String</name> - <key>string</key> - <opt>get:get</opt> - </option> - </param> - <param> - <name>Config File</name> - <key>config_file</key> - <value>default</value> - <type>file_open</type> - </param> - <param> - <name>Section</name> - <key>section</key> - <value>main</value> - <type>string</type> - </param> - <param> - <name>Option</name> - <key>option</key> - <value>key</value> - <type>string</type> - </param> - <param> - <name>WriteBack</name> - <key>writeback</key> - <value>None</value> - <type>raw</type> - </param> - <doc> -This block represents a variable that can be read from a config file. - -To save the value back into the config file: \ -enter the name of another variable into the writeback param. \ -When the other variable is changed at runtime, the config file will be re-written. - </doc> -</block> 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 diff --git a/grc/blocks/variable_function_probe.xml b/grc/blocks/variable_function_probe.xml deleted file mode 100644 index 47c11b29fe..0000000000 --- a/grc/blocks/variable_function_probe.xml +++ /dev/null @@ -1,78 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Variable function probe -################################################### - --> -<block> - <name>Function Probe</name> - <key>variable_function_probe</key> - <import>import time</import> - <import>import threading</import> - <var_make>self.$(id) = $(id) = $value</var_make> - <make> -def _$(id)_probe(): - while True: - #set $obj = 'self' + ('.' + $block_id() if $block_id() else '') - val = $(obj).$(function_name())($(function_args())) - try: - self.set_$(id)(val) - except AttributeError: - pass - time.sleep(1.0 / ($poll_rate)) -_$(id)_thread = threading.Thread(target=_$(id)_probe) -_$(id)_thread.daemon = True -_$(id)_thread.start() - </make> - <callback>self.set_$(id)($value)</callback> - <param> - <name>Block ID</name> - <key>block_id</key> - <value>my_block_0</value> - <type>string</type> - </param> - <param> - <name>Function Name</name> - <key>function_name</key> - <value>get_number</value> - <type>string</type> - </param> - <param> - <name>Function Args</name> - <key>function_args</key> - <value></value> - <type>string</type> - <hide>#if $function_args() then 'none' else 'part'#</hide> - </param> - <param> - <name>Poll Rate (Hz)</name> - <key>poll_rate</key> - <value>10</value> - <type>real</type> - </param> - <param> - <name>Initial Value</name> - <key>value</key> - <value>0</value> - <type>raw</type> - <hide>part</hide> - </param> - <doc> -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. - </doc> -</block> diff --git a/grc/blocks/variable_struct.block.yml.py b/grc/blocks/variable_struct.block.yml.py new file mode 100644 index 0000000000..19b29982e7 --- /dev/null +++ b/grc/blocks/variable_struct.block.yml.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python + +MAX_NUM_FIELDS = 20 + +HEADER = """\ +id: variable_struct +label: Struct Variable + +parameters: +""" + +TEMPLATES = """\ + +templates: + imports: "def struct(data): return type('Struct', (object,), data)()" + var_make: |- + self.${{id}} = ${{id}} = struct({{ + % for i in range({0}): + <% + field = getVar('field' + str(i)) + %> + % if len(str(field)) > 2: + ${{field}}: getVar('value' + str(i)), + % endif + % endfor + }}) + var_value: |- + struct({{ + % for i in range({0}): + <% + field = getVar('field' + str(i)) + %> + % if len(str(field)) > 2: + ${{field}}: getVar('field' + str(i)), + % endif + % endfor + }}) +""" + +FIELD0 = """\ +- id: field0 + label: Field 0 + category: Fields + dtype: string + default: ${field0} + hide: part +""" + +FIELDS = """\ +- id: field{0} + label: Field {0} + category: Fields + dtype: string + hide: part +""" + +VALUES = """\ +- id: value{0} + label: ${{field{0}}} + dtype: raw + default: '0' + hide: ${{ 'none' if field{0} else 'all' }} +""" + +ASSERTS = """\ +- ${{ (str(field{0}) or "a")[0].isalpha() }} +- ${{ (str(field{0}) or "a").isalnum() }} +""" + +FOOTER = """\ + +documentation: |- + This is a simple struct/record like variable. + + Attribute/field names can be specified in the tab 'Fields'. + For each non-empty field a parameter with type raw is shown. + Value access via the dot operator, e.g. "variable_struct_0.field0" + +file_format: 1 +""" + + +def make_yml(num_fields): + return ''.join(( + HEADER.format(num_fields), + FIELD0, ''.join(FIELDS.format(i) for i in range(1, num_fields)), + ''.join(VALUES.format(i) for i in range(num_fields)), + 'value: ${value}\n\nasserts:\n', + ''.join(ASSERTS.format(i) for i in range(num_fields)), + ''.join(TEMPLATES.format(num_fields)), + FOOTER + )) + + +if __name__ == '__main__': + import sys + try: + filename = sys.argv[1] + except IndexError: + filename = __file__[:-3] + + data = make_yml(MAX_NUM_FIELDS) + + with open(filename, 'wb') as fp: + fp.write(data.encode()) diff --git a/grc/blocks/variable_struct.xml.py b/grc/blocks/variable_struct.xml.py deleted file mode 100644 index c0d3dac355..0000000000 --- a/grc/blocks/variable_struct.xml.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python - -MAX_NUM_FIELDS = 20 - -HEADER = """\ -<block> - <name>Struct Variable</name> - <key>variable_struct</key> - <import>def struct(data): return type('Struct', (object,), data)()</import> - <var_make>self.$id = $id = struct({{#slurp -#for $i in range({0}): -#set $field = $getVar('field' + str(i)) -#if len(str($field)) > 2 -$field: $getVar('value' + str(i)), #slurp -#end if -#end for -}})</var_make> - <var_value>struct({{#slurp -#for $i in range({0}): -#set $field = $getVar('field' + str(i)) -#if len(str($field)) > 2 -$field: $getVar('value' + str(i)), #slurp -#end if -#end for -}})</var_value> - <make></make> -""" - -FIELD0 = """\ - <param> - <name>Field 0</name> - <key>field0</key> - <value>field0</value> - <type>string</type> - <hide>part</hide> - <tab>Fields</tab> - </param> -""" - -FIELDS = """\ - <param> - <name>Field {0}</name> - <key>field{0}</key> - <value></value> - <type>string</type> - <hide>part</hide> - <tab>Fields</tab> - </param> -""" - -VALUES = """\ - <param> - <name>$field{0}()</name> - <key>value{0}</key> - <value>0</value> - <type>raw</type> - <hide>#if $field{0}() then 'none' else 'all'#</hide> - </param> -""" - -CHECKS = """\ - <check>($str($field{0}) or "a")[0].isalpha()</check> - <check>($str($field{0}) or "a").isalnum()</check> -""" - -FOOTER = """\ - <doc>This is a simple struct/record like variable. - -Attribute/field names can be specified in the tab 'Fields'. -For each non-empty field a parameter with type raw is shown. -Value access via the dot operator, e.g. "variable_struct_0.field0" - </doc> -</block> -""" - - -def make_xml(num_fields): - return ''.join(( - HEADER.format(num_fields), - FIELD0, ''.join(FIELDS.format(i) for i in range(1, num_fields)), - ''.join(VALUES.format(i) for i in range(num_fields)), - ''.join(CHECKS.format(i) for i in range(num_fields)), - FOOTER - )) - - -if __name__ == '__main__': - import sys - try: - filename = sys.argv[1] - except IndexError: - filename = __file__[:-3] - - data = make_xml(MAX_NUM_FIELDS) - - with open(filename, 'wb') as fp: - fp.write(data.encode()) diff --git a/grc/blocks/virtual_sink.block.yml b/grc/blocks/virtual_sink.block.yml new file mode 100644 index 0000000000..4a2fd0108e --- /dev/null +++ b/grc/blocks/virtual_sink.block.yml @@ -0,0 +1,13 @@ +id: virtual_sink +label: Virtual Sink + +parameters: +- id: stream_id + label: Stream ID + dtype: stream_id + +inputs: +- domain: stream + dtype: '' + +file_format: 1 diff --git a/grc/blocks/virtual_sink.xml b/grc/blocks/virtual_sink.xml deleted file mode 100644 index 35fb27e67c..0000000000 --- a/grc/blocks/virtual_sink.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Virtual Sink -################################################### - --> -<block> - <name>Virtual Sink</name> - <key>virtual_sink</key> - <make></make> - <param> - <name>Stream ID</name> - <key>stream_id</key> - <value></value> - <type>stream_id</type> - </param> - <sink> - <name>in</name> - <type></type> - </sink> -</block> diff --git a/grc/blocks/virtual_source.block.yml b/grc/blocks/virtual_source.block.yml new file mode 100644 index 0000000000..cec987702a --- /dev/null +++ b/grc/blocks/virtual_source.block.yml @@ -0,0 +1,13 @@ +id: virtual_source +label: Virtual Source + +parameters: +- id: stream_id + label: Stream ID + dtype: stream_id + +outputs: +- domain: stream + dtype: '' + +file_format: 1 diff --git a/grc/blocks/virtual_source.xml b/grc/blocks/virtual_source.xml deleted file mode 100644 index e0c7754492..0000000000 --- a/grc/blocks/virtual_source.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Virtual Source -################################################### - --> -<block> - <name>Virtual Source</name> - <key>virtual_source</key> - <make></make> - <param> - <name>Stream ID</name> - <key>stream_id</key> - <value></value> - <type>stream_id</type> - </param> - <source> - <name>out</name> - <type></type> - </source> -</block> diff --git a/grc/tests/resources/file1.block.yml b/grc/tests/resources/file1.block.yml new file mode 100644 index 0000000000..f486c89ea8 --- /dev/null +++ b/grc/tests/resources/file1.block.yml @@ -0,0 +1,38 @@ +id: block_key +label: testname + +parameters: +- id: vlen + label: Vec Length + category: test + dtype: int + default: '1' + hide: ${ 'part' if vlen == 1 else 'none' } +- id: out_type + label: Vec Length + dtype: string + default: complex + hide: part +- id: a + label: Alpha + dtype: ${ (out_type) } + default: '0' + +inputs: +- domain: stream + dtype: complex + vlen: ${ 2 * vlen } +- domain: message + id: in2 + +outputs: +- domain: stream + dtype: ${ out_type } + vlen: ${ vlen } +asserts: +- ${ vlen > 0 } + +templates: + make: blocks.complex_to_mag_squared(${vlen}) + +file_format: 1 diff --git a/grc/tests/resources/file1.xml b/grc/tests/resources/file1.xml deleted file mode 100644 index f03288b85d..0000000000 --- a/grc/tests/resources/file1.xml +++ /dev/null @@ -1,58 +0,0 @@ -<?xml version="1.0"?> -<!-- -Copyright 2014 Free Software Foundation, Inc. -This file is part of GNU Radio - -GNU Radio Companion is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2 of the License, or (at your -option) any later version. - -GNU Radio Companion is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ---> -<block> - <name>testname</name> - <key>block_key</key> - <make>blocks.complex_to_mag_squared($(vlen))</make> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - <tab>test</tab> - </param> - <param> - <name>Vec Length</name> - <key>out_type</key> - <value>complex</value> - <type>string</type> - </param> - <param> - <name>Alpha</name> - <key>a</key> - <value>0</value> - <type>($out_type)</type> - </param> - <check>$vlen > 0</check> - <sink> - <name>in</name> - <type>complex</type> - <vlen>2 * $vlen</vlen> - </sink> - <sink> - <name>in2</name> - <type>message</type> - </sink> - <source> - <name>out</name> - <type>$out_type</type> - <vlen>$vlen</vlen> - </source> -</block> diff --git a/grc/tests/resources/file2.block.yml b/grc/tests/resources/file2.block.yml new file mode 100644 index 0000000000..459527260c --- /dev/null +++ b/grc/tests/resources/file2.block.yml @@ -0,0 +1,31 @@ +id: blocks_and_const_xx +label: And Const + +parameters: +- id: type + label: IO Type + dtype: enum + options: [int, short, byte] + option_attributes: + fcn: [ii, ss, bb] + hide: part +- id: const + label: Constant + dtype: int + default: '0' + +inputs: +- domain: stream + dtype: ${ type } + +outputs: +- domain: stream + dtype: ${ type } + +templates: + imports: from gnuradio import blocks + make: blocks.and_const_${type.fcn}(${const}) + callbacks: + - set_k(${const}) + +file_format: 1 diff --git a/grc/tests/resources/file2.xml b/grc/tests/resources/file2.xml deleted file mode 100644 index 1300c7f5a1..0000000000 --- a/grc/tests/resources/file2.xml +++ /dev/null @@ -1,80 +0,0 @@ -<?xml version="1.0"?> -<!-- -Copyright 2014 Free Software Foundation, Inc. -This file is part of GNU Radio - -GNU Radio Companion is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2 of the License, or (at your -option) any later version. - -GNU Radio Companion is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ---> -<!-- -################################################### -## And Const Block: -## all types, 1 output, 1 input & const -################################################### - --> -<block> - <name>And Const</name> - <key>blocks_and_const_xx</key> - <category>test</category> - <throttle>1</throttle> - <import>from gnuradio import blocks</import> - <make>blocks.and_const_$(type.fcn)($const)</make> - <callback>set_k($const)</callback> - <param> - <name>IO Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Int</name> - <key>int</key> - <opt>fcn:ii</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>fcn:ss</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>fcn:bb</opt> - </option> - </param> - <param> - <name>Constant</name> - <key>const</key> - <value>0</value> - <type>${type}</type> - <hide>#if $log then 'none' else 'part'#</hide> - </param> - <sink> - <name>in</name> - <type>$type</type> - </sink> - <source> - <name>out</name> - <type>$(type.fcn)</type> - </source> - <doc> -This block creates a variable check box. \ -Leave the label blank to use the variable id as the label. - -A check box selects between two values of similar type. \ -Te values do not necessarily need to be of boolean type. - -The GUI hint can be used to position the widget within the application. \ -The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \ -Both the tab specification and the grid position are optional. - </doc> -</block> diff --git a/grc/tests/resources/file3.block.yml b/grc/tests/resources/file3.block.yml new file mode 100644 index 0000000000..e53515d134 --- /dev/null +++ b/grc/tests/resources/file3.block.yml @@ -0,0 +1,66 @@ +id: variable_qtgui_check_box +label: QT GUI Check Box + +parameters: +- id: label + label: Label + dtype: string + hide: ${ ('none' if label else 'part') } +- id: type + label: Type + dtype: enum + default: int + options: [real, int, string, bool, raw] + option_labels: [Float, Integer, String, Boolean, Any] + option_attributes: + conv: [float, int, str, bool, eval] + hide: part +- id: value + label: Default Value + dtype: ${ type } + default: 'True' +- id: 'true' + label: 'True' + dtype: ${ type } + default: 'True' +- id: 'false' + label: 'False' + dtype: ${ type } + default: 'False' +- id: gui_hint + label: GUI Hint + dtype: gui_hint + hide: part +value: ${ value } + +asserts: +- ${value in (true, false)} + +templates: + imports: from PyQt4 import Qt + var_make: self.${id} = ${id} = ${value} + callbacks: + - self.set_${id}(${value}) + - self._${id}_callback(${id}) + make: |- + <% + win = '_%s_check_box'%id + if not label: + label = id + %> + ${win} = Qt.QCheckBox(${label}) + self._${id}_choices = {True: ${true}, False: ${false}} + self._${id}_choices_inv = dict((v,k) for k,v in self._${id}_choices.iteritems()) + self._${id}_callback = lambda i: Qt.QMetaObject.invokeMethod(${win}, "setChecked", Qt.Q_ARG("bool", self._${id}_choices_inv[i])) + self._${id}_callback(self.${id}) + ${win}.stateChanged.connect(lambda i: self.set_${id}(self._${id}_choices[bool(i)])) + ${gui_hint()(win)} + +documentation: |- + This block creates a variable check box. Leave the label blank to use the variable id as the label. + + A check box selects between two values of similar type. Te values do not necessarily need to be of boolean type. + + The GUI hint can be used to position the widget within the application. The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. Both the tab specification and the grid position are optional. + +file_format: 1 diff --git a/grc/tests/resources/file3.xml b/grc/tests/resources/file3.xml deleted file mode 100644 index 71753badb1..0000000000 --- a/grc/tests/resources/file3.xml +++ /dev/null @@ -1,100 +0,0 @@ -<?xml version="1.0"?> -<!-- -Copyright 2014 Free Software Foundation, Inc. -This file is part of GNU Radio - -GNU Radio Companion is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2 of the License, or (at your -option) any later version. - -GNU Radio Companion is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ---> -<!-- -################################################### -##Variable Check Box: -## a gui check box form -################################################### - --> -<block> - <name>QT GUI Check Box</name> - <key>variable_qtgui_check_box</key> - <import>from PyQt4 import Qt</import> - <var_make>self.$(id) = $(id) = $value</var_make> - <make>#set $win = '_%s_check_box'%$id -#if not $label() - #set $label = '"%s"'%$id -#end if -$win = Qt.QCheckBox($label) -self._$(id)_choices = {True: $true, False: $false} -self._$(id)_choices_inv = dict((v,k) for k,v in self._$(id)_choices.iteritems()) -self._$(id)_callback = lambda i: Qt.QMetaObject.invokeMethod($(win), "setChecked", Qt.Q_ARG("bool", self._$(id)_choices_inv[i])) -self._$(id)_callback(self.$id) -$(win).stateChanged.connect(lambda i: self.set_$(id)(self._$(id)_choices[bool(i)])) -$(gui_hint()($win))</make> - <callback>self.set_$(id)($value)</callback> - <callback>self._$(id)_callback($id)</callback> - <param> - <name>Label</name> - <key>label</key> - <value></value> - <type>string</type> - <hide>#if $label() then 'none' else 'part'#</hide> - </param> - <param> - <name>Type</name> - <key>type</key> - <value>int</value> - <type>enum</type> - <hide>part</hide> - <option><name>Float</name><key>real</key><opt>conv:float</opt></option> - <option><name>Integer</name><key>int</key><opt>conv:int</opt></option> - <option><name>String</name><key>string</key><opt>conv:str</opt></option> - <option><name>Boolean</name><key>bool</key><opt>conv:bool</opt></option> - <option><name>Any</name><key>raw</key><opt>conv:eval</opt></option> - </param> - <param> - <name>Default Value</name> - <key>value</key> - <value>True</value> - <type>$type</type> - </param> - <param> - <name>True</name> - <key>true</key> - <value>True</value> - <type>$type</type> - </param> - <param> - <name>False</name> - <key>false</key> - <value>False</value> - <type>$type</type> - </param> - <param> - <name>GUI Hint</name> - <key>gui_hint</key> - <value></value> - <type>gui_hint</type> - <hide>part</hide> - </param> - <check>$value in ($true, $false)</check> - <doc> -This block creates a variable check box. \ -Leave the label blank to use the variable id as the label. - -A check box selects between two values of similar type. \ -Te values do not necessarily need to be of boolean type. - -The GUI hint can be used to position the widget within the application. \ -The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \ -Both the tab specification and the grid position are optional. - </doc> -</block> |