summaryrefslogtreecommitdiff
path: root/grc/python
diff options
context:
space:
mode:
authorTom Rondeau <tom@trondeau.com>2014-07-11 10:03:27 -0400
committerTom Rondeau <tom@trondeau.com>2014-07-11 10:03:27 -0400
commit62831422ae4b2a817a997153468008db38e06598 (patch)
tree4aca7097fbfae8bf1890194c90ad43e44b572db5 /grc/python
parent2bb2b31476cb33e9c1bbb196fffba3a857b4f75a (diff)
parent6d9dfac64806ad2d1eb77a9ae909e4b9d66ea7fd (diff)
Merge remote-tracking branch 'gnuradio-wg-grc/grc_variable_blocks'
Diffstat (limited to 'grc/python')
-rw-r--r--grc/python/Block.py10
-rw-r--r--grc/python/FlowGraph.py2
-rw-r--r--grc/python/block.dtd3
3 files changed, 13 insertions, 2 deletions
diff --git a/grc/python/Block.py b/grc/python/Block.py
index 7a1c3a254f..9556e8f061 100644
--- a/grc/python/Block.py
+++ b/grc/python/Block.py
@@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
from .. base.Block import Block as _Block
from .. gui.Block import Block as _GUIBlock
+from . FlowGraph import _variable_matcher
import extract_docs
class Block(_Block, _GUIBlock):
@@ -90,6 +91,14 @@ class Block(_Block, _GUIBlock):
if not self.get_parent().evaluate(check_res):
self.add_error_message('Check "%s" failed.'%check)
except: self.add_error_message('Check "%s" did not evaluate.'%check)
+ # for variables check the value (only if var_value is used
+ if _variable_matcher.match(self.get_key()) and self._var_value != '$value':
+ value = self._var_value
+ try:
+ value = self.get_var_value()
+ self.get_parent().evaluate(value)
+ except Exception as err:
+ self.add_error_message('Value "%s" cannot be evaluated:\n%s' % (value, err))
def rewrite(self):
"""
@@ -169,6 +178,7 @@ class Block(_Block, _GUIBlock):
def get_make(self): return self.resolve_dependencies(self._make)
def get_var_make(self): return self.resolve_dependencies(self._var_make)
+ def get_var_value(self): return self.resolve_dependencies(self._var_value)
def get_callbacks(self):
"""
diff --git a/grc/python/FlowGraph.py b/grc/python/FlowGraph.py
index 114f708cb2..daec2d4310 100644
--- a/grc/python/FlowGraph.py
+++ b/grc/python/FlowGraph.py
@@ -262,7 +262,7 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph):
#load variables
for variable in self.get_variables():
try:
- e = eval(variable.get_param('value').to_code(), n, n)
+ e = eval(variable.get_var_value(), n, n)
n[variable.get_id()] = e
except: pass
#make namespace public
diff --git a/grc/python/block.dtd b/grc/python/block.dtd
index 18e53fda2a..602339ba7c 100644
--- a/grc/python/block.dtd
+++ b/grc/python/block.dtd
@@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Top level element.
A block contains a name, ...parameters list, and list of IO ports.
-->
-<!ELEMENT block (name, key, category?, throttle?, import*, var_make?, make, callback*, param_tab_order?, param*, bus_sink?, bus_source?, check*, sink*, source*, bus_structure_sink?, bus_structure_source?, doc?, grc_source?)>
+<!ELEMENT block (name, key, category?, throttle?, import*, var_make?, var_value?, make, callback*, param_tab_order?, param*, bus_sink?, bus_source?, check*, sink*, source*, bus_structure_sink?, bus_structure_source?, doc?, grc_source?)>
<!--
Sub level elements.
-->
@@ -57,6 +57,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
<!ELEMENT bus_structure_sink (#PCDATA)>
<!ELEMENT bus_structure_source (#PCDATA)>
<!ELEMENT var_make (#PCDATA)>
+<!ELEMENT var_value (#PCDATA)>
<!ELEMENT make (#PCDATA)>
<!ELEMENT value (#PCDATA)>
<!ELEMENT callback (#PCDATA)>