summaryrefslogtreecommitdiff
path: root/grc/blocks
diff options
context:
space:
mode:
Diffstat (limited to 'grc/blocks')
-rw-r--r--grc/blocks/CMakeLists.txt36
-rw-r--r--grc/blocks/block_tree.xml30
-rw-r--r--grc/blocks/bus_sink.xml27
-rw-r--r--grc/blocks/bus_source.xml27
-rw-r--r--grc/blocks/bus_structure_sink.xml18
-rw-r--r--grc/blocks/bus_structure_source.xml18
-rw-r--r--grc/blocks/dummy.xml11
-rw-r--r--grc/blocks/epy_block.xml58
-rw-r--r--grc/blocks/epy_module.xml32
-rw-r--r--grc/blocks/gr_message_domain.xml19
-rw-r--r--grc/blocks/gr_stream_domain.xml18
-rw-r--r--grc/blocks/grc.tree.yml15
-rw-r--r--grc/blocks/import.block.yml20
-rw-r--r--grc/blocks/import.xml26
-rw-r--r--grc/blocks/message.domain.yml10
-rw-r--r--grc/blocks/note.block.yml9
-rw-r--r--grc/blocks/note.xml17
-rw-r--r--grc/blocks/options.block.yml146
-rw-r--r--grc/blocks/options.xml250
-rw-r--r--grc/blocks/pad_sink.block.yml51
-rw-r--r--grc/blocks/pad_sink.xml103
-rw-r--r--grc/blocks/pad_source.block.yml51
-rw-r--r--grc/blocks/pad_source.xml104
-rw-r--r--grc/blocks/parameter.block.yml55
-rw-r--r--grc/blocks/parameter.xml116
-rw-r--r--grc/blocks/stream.domain.yml10
-rw-r--r--grc/blocks/variable.block.yml19
-rw-r--r--grc/blocks/variable.xml23
-rw-r--r--grc/blocks/variable_config.block.yml58
-rw-r--r--grc/blocks/variable_config.xml88
-rw-r--r--grc/blocks/variable_function_probe.block.yml54
-rw-r--r--grc/blocks/variable_function_probe.xml78
-rw-r--r--grc/blocks/variable_struct.block.yml.py105
-rw-r--r--grc/blocks/variable_struct.xml.py97
-rw-r--r--grc/blocks/virtual_sink.xml21
-rw-r--r--grc/blocks/virtual_source.xml21
36 files changed, 621 insertions, 1220 deletions
diff --git a/grc/blocks/CMakeLists.txt b/grc/blocks/CMakeLists.txt
index d46b1febbe..f5ec6dd214 100644
--- a/grc/blocks/CMakeLists.txt
+++ b/grc/blocks/CMakeLists.txt
@@ -20,40 +20,40 @@
########################################################################
include(GrPython)
-file(GLOB xml_files "*.xml")
+file(GLOB yml_files "*.yml")
-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 ${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 3125864d4d..0000000000
--- a/grc/blocks/block_tree.xml
+++ /dev/null
@@ -1,30 +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>bus_sink</block>
- <block>bus_source</block>
- <block>bus_structure_sink</block>
- <block>bus_structure_source</block>
-
- <block>epy_block</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/bus_sink.xml b/grc/blocks/bus_sink.xml
deleted file mode 100644
index 029820dc2c..0000000000
--- a/grc/blocks/bus_sink.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##Bus Sink
-###################################################
- -->
-<block>
- <name>Bus Sink</name>
- <key>bus_sink</key>
- <make>$yesno.yesno</make>
-
- <param>
- <name>On/Off</name>
- <key>yesno</key>
- <type>enum</type>
- <option>
- <name>On</name>
- <key>on</key>
- <opt>yesno:True</opt>
- </option>
- <option>
- <name>Off</name>
- <key>off</key>
- <opt>yesno:False</opt>
- </option>
- </param>
-</block>
diff --git a/grc/blocks/bus_source.xml b/grc/blocks/bus_source.xml
deleted file mode 100644
index e5b5c2b9bf..0000000000
--- a/grc/blocks/bus_source.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##Bus Sink
-###################################################
- -->
-<block>
- <name>Bus Source</name>
- <key>bus_source</key>
- <make>$yesno.yesno</make>
-
- <param>
- <name>On/Off</name>
- <key>yesno</key>
- <type>enum</type>
- <option>
- <name>On</name>
- <key>on</key>
- <opt>yesno:True</opt>
- </option>
- <option>
- <name>Off</name>
- <key>off</key>
- <opt>yesno:False</opt>
- </option>
- </param>
-</block>
diff --git a/grc/blocks/bus_structure_sink.xml b/grc/blocks/bus_structure_sink.xml
deleted file mode 100644
index 3adac92810..0000000000
--- a/grc/blocks/bus_structure_sink.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##Bus Sink
-###################################################
- -->
-<block>
- <name>Bus Sink Structure</name>
- <key>bus_structure_sink</key>
- <make>None</make>
-
- <param>
- <name>Structure</name>
- <key>struct</key>
- <value></value>
- <type>raw</type>
- </param>
-</block>
diff --git a/grc/blocks/bus_structure_source.xml b/grc/blocks/bus_structure_source.xml
deleted file mode 100644
index 34e7c049a2..0000000000
--- a/grc/blocks/bus_structure_source.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##Bus Sink
-###################################################
- -->
-<block>
- <name>Bus Source Structure</name>
- <key>bus_structure_source</key>
- <make>None</make>
-
- <param>
- <name>Structure</name>
- <key>struct</key>
- <value></value>
- <type>raw</type>
- </param>
-</block>
diff --git a/grc/blocks/dummy.xml b/grc/blocks/dummy.xml
deleted file mode 100644
index c0ca3b6698..0000000000
--- a/grc/blocks/dummy.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##Dummy Block
-###################################################
--->
-<block>
- <name>Missing Block</name>
- <key>dummy_block</key>
- <make>raise NotImplementedError()</make>
-</block>
diff --git a/grc/blocks/epy_block.xml b/grc/blocks/epy_block.xml
deleted file mode 100644
index 65e78c4062..0000000000
--- a/grc/blocks/epy_block.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0"?>
-<block>
- <name>Python Block</name>
- <key>epy_block</key>
- <import></import>
- <make></make>
- <param><!-- Cache the last working block IO to keep FG sane -->
- <name>Block Io</name>
- <key>_io_cache</key>
- <type>string</type>
- <hide>all</hide>
- </param>
- <param>
- <name>Code</name>
- <key>_source_code</key>
- <value>"""
-Embedded Python Blocks:
-
-Each time this file is saved, GRC will instantiate the first class it finds
-to get ports and parameters of your block. The arguments to __init__ will
-be the parameters. All of them are required to have default values!
-"""
-
-import numpy as np
-from gnuradio import gr
-
-
-class blk(gr.sync_block): # other base classes are basic_block, decim_block, interp_block
- """Embedded Python Block example - a simple multiply const"""
-
- def __init__(self, example_param=1.0): # only default arguments here
- """arguments to this function show up as parameters in GRC"""
- gr.sync_block.__init__(
- self,
- name='Embedded Python Block', # will show up in GRC
- in_sig=[np.complex64],
- out_sig=[np.complex64]
- )
- # if an attribute with the same name as a parameter is found,
- # a callback is registered (properties work, too).
- self.example_param = example_param
-
- def work(self, input_items, output_items):
- """example: multiply with constant"""
- output_items[0][:] = input_items[0] * self.example_param
- return len(output_items[0])
-</value>
- <type>_multiline_python_external</type>
- <hide>part</hide>
- </param>
- <doc>This block represents an arbitrary GNU Radio Python Block.
-
-Its source code can be accessed through the parameter 'Code' which opens your editor. Each time you save changes in the editor, GRC will update the block. This includes the number, names and defaults of the parameters, the ports (stream and message) and the block name and documentation.
-
-Block Documentation:
-(will be replaced the docstring of your block class)
-</doc>
-</block>
diff --git a/grc/blocks/epy_module.xml b/grc/blocks/epy_module.xml
deleted file mode 100644
index fa3e5f91f4..0000000000
--- a/grc/blocks/epy_module.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0"?>
-<block>
- <name>Python Module</name>
- <key>epy_module</key>
- <import>import $id # embedded python module</import>
- <make></make>
- <param>
- <name>Code</name>
- <key>source_code</key>
- <value># this module will be imported in the into your flowgraph</value>
- <type>_multiline_python_external</type>
- <hide>part</hide>
- </param>
- <doc>This block lets you embed a python module in your flowgraph.
-
-Code you put in this module is accessible in other blocks using the ID of this
-block. Example:
-
-If you put
-
- a = 2
-
- def double(arg):
- return 2 * arg
-
-in a Python Module Block with the ID 'stuff' you can use code like
-
- stuff.a # evals to 2
- stuff.double(3) # evals to 6
-
-to set parameters of other blocks in your flowgraph.</doc>
-</block>
diff --git a/grc/blocks/gr_message_domain.xml b/grc/blocks/gr_message_domain.xml
deleted file mode 100644
index bc8add99ab..0000000000
--- a/grc/blocks/gr_message_domain.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##GNU Radio default domain 'gr_message'
-###################################################
- -->
- <domain>
- <name>GR Message</name>
- <key>gr_message</key>
- <color>#000</color>
- <multiple_sources>True</multiple_sources>
- <connection>
- <source_domain>gr_message</source_domain>
- <sink_domain>gr_message</sink_domain>
- <make>#slurp
- self.msg_connect($make_port_sig($source), $make_port_sig($sink))#slurp
- </make>
- </connection>
-</domain>
diff --git a/grc/blocks/gr_stream_domain.xml b/grc/blocks/gr_stream_domain.xml
deleted file mode 100644
index 66026448ca..0000000000
--- a/grc/blocks/gr_stream_domain.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##GNU Radio default domain 'gr_stream'
-###################################################
- -->
- <domain>
- <name>GR Stream</name>
- <key>gr_stream</key>
- <color>#000</color>
- <connection>
- <source_domain>gr_stream</source_domain>
- <sink_domain>gr_stream</sink_domain>
- <make>#slurp
- self.connect($make_port_sig($source), $make_port_sig($sink))#slurp
- </make>
- </connection>
-</domain>
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 59f807bacb..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>$import</import>
- <make></make>
- <param>
- <name>Import</name>
- <key>import</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/message.domain.yml b/grc/blocks/message.domain.yml
new file mode 100644
index 0000000000..7e6cc529d9
--- /dev/null
+++ b/grc/blocks/message.domain.yml
@@ -0,0 +1,10 @@
+id: message
+label: Message
+color: "#FFFFFF"
+
+multiple_connections_per_input: true
+multiple_connections_per_output: true
+
+templates:
+- type: [message, message]
+ connect: self.msg_connect(${ make_port_sig(source) }, ${ make_port_sig(sink) })
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 bff88cec85..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>Bokeh GUI</name>
- <key>bokeh_gui</key>
- </option>
- <option>
- <name>QT GUI</name>
- <key>qt_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() in ('qt_gui', 'bokeh_gui') then ('part' if $run() else 'none') else 'all'#</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 ('none' if $qt_qss_theme() else 'part') else 'all'#</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 &lt;= $(window_size)[0] &lt;= 4096</check>
- <check>not $window_size or 300 &lt;= $(window_size)[1] &lt;= 4096</check>
- <check>len($placement) == 4 or len($placement) == 2</check>
- <check>all(i &gt;= 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 &gt; 0</check>
- <check>$num_streams &gt; 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 &gt; 0</check>
- <check>$num_streams &gt; 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..387cbbf181
--- /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 parameter 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 95d03e1412..0000000000
--- a/grc/blocks/parameter.xml
+++ /dev/null
@@ -1,116 +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>string</key>
- <opt>type:string</opt>
- </option>
- <!-- 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/stream.domain.yml b/grc/blocks/stream.domain.yml
new file mode 100644
index 0000000000..a4d786f8b4
--- /dev/null
+++ b/grc/blocks/stream.domain.yml
@@ -0,0 +1,10 @@
+id: stream
+label: Stream
+color: "#000000"
+
+multiple_connections_per_input: false
+multiple_connections_per_output: true
+
+templates:
+- type: [stream, stream]
+ connect: self.connect(${ make_port_sig(source) }, ${ make_port_sig(sink) })
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 de4411e975..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, 'w') as fp:
- fp.write(data.encode())
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.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>