[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 01/37: grc: design time values for object-l
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 01/37: grc: design time values for object-like variables |
Date: |
Thu, 17 Jul 2014 20:23:39 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
trondeau pushed a commit to branch master
in repository gnuradio.
commit 81899991d0f658e943fcd6abd2a624aa4268b7d1
Author: Sebastian Koslowski <address@hidden>
Date: Fri Jun 27 14:33:22 2014 +0200
grc: design time values for object-like variables
---
grc/base/Block.py | 7 +++++--
grc/python/Block.py | 10 ++++++++++
grc/python/FlowGraph.py | 2 +-
grc/python/block.dtd | 3 ++-
4 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/grc/base/Block.py b/grc/base/Block.py
index a14ffd9..a8a699f 100644
--- a/grc/base/Block.py
+++ b/grc/base/Block.py
@@ -77,6 +77,7 @@ class Block(Element):
self._block_wrapper_path = n.find('block_wrapper_path')
self._bussify_sink = n.find('bus_sink')
self._bussify_source = n.find('bus_source')
+ self._var_value = n.find('var_value') or '$value'
# get list of param tabs
n_tabs = n.find('param_tab_order') or None
@@ -275,8 +276,10 @@ class Block(Element):
tmpl = str(tmpl)
if '$' not in tmpl: return tmpl
n = dict((p.get_key(), TemplateArg(p)) for p in self.get_params())
- try: return str(Template(tmpl, n))
- except Exception, e: return "-------->\n%s: %s\n<--------"%(e, tmpl)
+ try:
+ return str(Template(tmpl, n))
+ except Exception as err:
+ return "Template error: %s\n %s" % (tmpl, err)
##############################################
# Controller Modify
diff --git a/grc/python/Block.py b/grc/python/Block.py
index 5dffcb3..21f4bad 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 8573f33..6d95db8 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 18e53fd..602339b 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)>
- [Commit-gnuradio] [gnuradio] branch master updated (2bb2b31 -> 001ab47), git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 08/37: uhd: Added more type checking and flexibility to commands and tags, git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 07/37: uhd: Added GRC bindings for command interface, git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 02/37: digital: using new var_value for constellation variables, git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 01/37: grc: design time values for object-like variables,
git <=
- [Commit-gnuradio] [gnuradio] 04/37: uhd: Updated docs, in particular for the command interface, git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 03/37: grc: allow blocks to dynamically hide some of their ports, git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 10/37: uhd: Added checks for lock sensors., git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 17/37: qtgui: allows users to set title and unit of Y axis for qt time plotter., git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 05/37: uhd: Added command interface to uhd source, modified command syntax, git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 16/37: qtgui: adding ability to set grid on/off from grc properties dialog boxes for all qtgui sinks except the "sink" which doesn't support this., git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 12/37: Merge remote-tracking branch 'gnuradio-wg-grc/grc_variable_blocks', git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 22/37: Merge remote-tracking branch 'gnuradio-wg-grc/grc_port_view_options', git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 09/37: uhd: Added example for re-tuning through messages, git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 06/37: uhd: Refactored common stuff from usrp sink and source, git, 2014/07/17