From 24b3c103b859737d086d4813d6d345882b926e81 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Fri, 18 Sep 2009 20:37:05 -0700
Subject: bug fix for handling loading of dynamic params
---
grc/base/Block.py | 24 +++++++++++++++++-------
grc/base/FlowGraph.py | 1 -
grc/todo.txt | 2 --
3 files changed, 17 insertions(+), 10 deletions(-)
(limited to 'grc')
diff --git a/grc/base/Block.py b/grc/base/Block.py
index cb21c3958..43f9ba4e9 100644
--- a/grc/base/Block.py
+++ b/grc/base/Block.py
@@ -233,12 +233,22 @@ class Block(Element):
"""
Import this block's params from nested data.
Any param keys that do not exist will be ignored.
+ Since params can be dynamically created based another param,
+ call rewrite, and repeat the load until the params stick.
+ This call to rewrite will also create any dynamic ports
+ that are needed for the connections creation phase.
@param n the nested data odict
"""
- params_n = n.findall('param')
- for param_n in params_n:
- key = param_n.find('key')
- value = param_n.find('value')
- #the key must exist in this block's params
- if key in self.get_param_keys():
- self.get_param(key).set_value(value)
+ get_hash = lambda: reduce(lambda x, y: x | y, [hash(param) for param in self.get_params()], 0)
+ my_hash = 0
+ while get_hash() != my_hash:
+ params_n = n.findall('param')
+ for param_n in params_n:
+ key = param_n.find('key')
+ value = param_n.find('value')
+ #the key must exist in this block's params
+ if key in self.get_param_keys():
+ self.get_param(key).set_value(value)
+ #store hash and call rewrite
+ my_hash = get_hash()
+ self.rewrite()
diff --git a/grc/base/FlowGraph.py b/grc/base/FlowGraph.py
index ce370ca24..7c51ef42a 100644
--- a/grc/base/FlowGraph.py
+++ b/grc/base/FlowGraph.py
@@ -184,7 +184,6 @@ class FlowGraph(Element):
#only load the block when the block key was valid
if block: block.import_data(block_n)
else: Messages.send_error_load('Block key "%s" not found in %s'%(key, self.get_parent()))
- self.rewrite() #rewrite all blocks before connections are made (ex: nports)
#build the connections
for connection_n in connections_n:
#try to make the connection
diff --git a/grc/todo.txt b/grc/todo.txt
index 7fa68e523..b4e3af39d 100644
--- a/grc/todo.txt
+++ b/grc/todo.txt
@@ -69,8 +69,6 @@
* threads dont die on exit in probe and variable sink
* align param titles in properties dialog
* weird grid params misbehaving
-* the block's import data does not handle variable params
- * call rewrite after load, if new params appear, try load again...
##################################################
# Future
--
cgit
From 803943020c3d53686f2b65a70cd24a780b46c925 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Fri, 18 Sep 2009 23:27:06 -0700
Subject: xor that hash
---
grc/base/Block.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'grc')
diff --git a/grc/base/Block.py b/grc/base/Block.py
index 43f9ba4e9..203e878e4 100644
--- a/grc/base/Block.py
+++ b/grc/base/Block.py
@@ -239,7 +239,7 @@ class Block(Element):
that are needed for the connections creation phase.
@param n the nested data odict
"""
- get_hash = lambda: reduce(lambda x, y: x | y, [hash(param) for param in self.get_params()], 0)
+ get_hash = lambda: reduce(lambda x, y: x ^ y, [hash(param) for param in self.get_params()], 0)
my_hash = 0
while get_hash() != my_hash:
params_n = n.findall('param')
--
cgit
From fd37328c778ea8014e9ea9d932e61e5d229dd012 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Fri, 25 Sep 2009 00:24:48 -0700
Subject: Added a run options to the "no gui" generate options. The user can
select between run to completion and prompt for exit.
Also fixed the props dialog is changed function to have better hashes.
Now we hash a tuple of all "relevant" items which is "order aware".
Since xoring the individual hashes proved faulty when 2 params alternated hiding.
---
grc/blocks/options.xml | 29 +++++++++++++++++++++++------
grc/gui/PropsDialog.py | 11 +++++------
grc/python/flow_graph.tmpl | 5 +++++
3 files changed, 33 insertions(+), 12 deletions(-)
(limited to 'grc')
diff --git a/grc/blocks/options.xml b/grc/blocks/options.xml
index 1798a69f8..4d0dd2899 100644
--- a/grc/blocks/options.xml
+++ b/grc/blocks/options.xml
@@ -77,20 +77,37 @@ else: self.stop(); self.wait()
string#if $generate_options() == 'hb' then 'none' else 'all'#
+
+ Run Options
+ run_options
+ prompt
+ enum
+ #if $generate_options() == 'no_gui' then 'none' else 'all'#
+
+
+
RunrunTruebool
- #if $generate_options() == 'wx_gui'
- #if str($run) == 'True'
-part#slurp
+
+#if $generate_options() == 'wx_gui'
+ #if $run()
+ part
#else
-none#slurp
+ none
#end if
#else
-all#slurp
-#end if
+ all
+#end if
+
-
-
RunrunTruebool
-
-#if $generate_options() == 'wx_gui'
- #if $run()
- part
+ #if $generate_options() == 'wx_gui'
+ #if str($run) == 'True'
+part#slurp
#else
- none
+none#slurp
#end if
#else
- all
-#end if
-
+all#slurp
+#end if
+
+
RunrunTruebool
- #if $generate_options() == 'wx_gui'
- #if str($run) == 'True'
-part#slurp
+
+#if $generate_options() == 'wx_gui'
+ #if $run()
+ part
#else
-none#slurp
+ none
#end if
#else
-all#slurp
-#end if
+ all
+#end if
+
+
+ Num Ports
+ num_ports
+ 1
+ int
+
Vec Lengthvlen1int
+ $num_ports > 0$vlen > 0in$type$vlen
+ $num_ports
diff --git a/grc/blocks/gr_nop.xml b/grc/blocks/gr_nop.xml
index 127a78a55..bd884d6b8 100644
--- a/grc/blocks/gr_nop.xml
+++ b/grc/blocks/gr_nop.xml
@@ -39,21 +39,30 @@
size:gr.sizeof_char
+
+ Num Ports
+ num_ports
+ 1
+ int
+
Vec Lengthvlen1int
+ $num_ports > 0$vlen > 0in$type$vlen
+ $num_ports
--
cgit