From fc9df36159a97fd691c585ce3c7556987aefe38a Mon Sep 17 00:00:00 2001 From: jblum Date: Thu, 22 Jan 2009 00:32:48 +0000 Subject: [PATCH 1/1] cmd line options with param block git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@10282 221aa14e-8319-0410-a670-987f0aec2ac5 --- .../platforms/python/blocks/parameter.xml | 48 ++++++++++++++++++- grc/data/platforms/python/flow_graph.tmpl | 11 ++++- grc/todo.txt | 1 - 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/grc/data/platforms/python/blocks/parameter.xml b/grc/data/platforms/python/blocks/parameter.xml index b9dcce42..de208501 100644 --- a/grc/data/platforms/python/blocks/parameter.xml +++ b/grc/data/platforms/python/blocks/parameter.xml @@ -7,6 +7,7 @@ Parameter parameter + from optparse import OptionParser $value Label @@ -18,7 +19,50 @@ Value value 0 - raw + $type.type + + + Type + type + + enum + $type.hide + + + + + + This block represents a parameter to the flow graph, \ @@ -27,5 +71,7 @@ used when the flow graph is instantiated as a hier 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 --[id] [value]. diff --git a/grc/data/platforms/python/flow_graph.tmpl b/grc/data/platforms/python/flow_graph.tmpl index a5fbc64b..a9256574 100644 --- a/grc/data/platforms/python/flow_graph.tmpl +++ b/grc/data/platforms/python/flow_graph.tmpl @@ -179,7 +179,16 @@ class $(class_name)(gr.hier_block2): ######################################################## #if $generate_options != 'hb' if __name__ == '__main__': - tb = $(class_name)() + parser = OptionParser() + #set $args = list() + #for $param in $parameters + #if $param.get_param('type').get_value() + parser.add_option("--$param.get_id()", dest="$param.get_id()", type="$param.get_param('type').get_value()", default=$param.get_make()) + #silent $args.append('%s=options.%s'%($param.get_id(), $param.get_id())) + #end if + #end for + (options, args) = parser.parse_args() + tb = $(class_name)($(', '.join($args))) #if $generate_options == 'wx_gui' tb.Run() #elif $generate_options == 'no_gui' diff --git a/grc/todo.txt b/grc/todo.txt index 54302e40..d9b03d80 100644 --- a/grc/todo.txt +++ b/grc/todo.txt @@ -1,7 +1,6 @@ ################################################## # Blocks ################################################## --optparse block -ofdm wrappers -controlled step block -simplify simple usrp -- 2.30.2