[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9450 - in gnuradio/trunk/grc: data/grc_gnuradio src/g
From: |
jblum |
Subject: |
[Commit-gnuradio] r9450 - in gnuradio/trunk/grc: data/grc_gnuradio src/grc_gnuradio |
Date: |
Fri, 29 Aug 2008 14:55:07 -0600 (MDT) |
Author: jblum
Date: 2008-08-29 14:55:06 -0600 (Fri, 29 Aug 2008)
New Revision: 9450
Modified:
gnuradio/trunk/grc/data/grc_gnuradio/flow_graph.tmpl
gnuradio/trunk/grc/src/grc_gnuradio/FlowGraph.py
gnuradio/trunk/grc/src/grc_gnuradio/Generator.py
Log:
separated controls and variables generation, removed evaluation dependency on
variables extraction
Modified: gnuradio/trunk/grc/data/grc_gnuradio/flow_graph.tmpl
===================================================================
--- gnuradio/trunk/grc/data/grc_gnuradio/flow_graph.tmpl 2008-08-29
20:02:46 UTC (rev 9449)
+++ gnuradio/trunk/grc/data/grc_gnuradio/flow_graph.tmpl 2008-08-29
20:55:06 UTC (rev 9450)
@@ -5,6 +5,7 @@
address@hidden imports the import statements
address@hidden flow_graph the flow_graph
address@hidden variables the variable blocks
address@hidden controls the variables with gui controls
address@hidden parameters the paramater blocks
address@hidden blocks the signal blocks
address@hidden connections the connections
@@ -83,7 +84,7 @@
########################################################
##Create Variables
## Set the variable to a property of self.
-## Write the variable make, and indent with 2 tabs.
+## Write the first line of the variable make.
########################################################
#if $variables
@@ -92,11 +93,25 @@
$DIVIDER
#end if
#for $var in $variables
- #set $code = '\n\t\t'.join($var.get_make().splitlines())
- $var.get_id() = $code
- self.$var.get_id() = $var.get_id()
+ #set $code = $var.get_make().splitlines()[0]
+ self.$var.get_id() = $var.get_id() = $code
#end for
########################################################
+##Create Controls
+## Write the variable make (excluding first line).
+## Indent each line with 2 tabs.
+########################################################
+#if $controls
+
+ $DIVIDER
+ # Controls
+ $DIVIDER
+#end if
+#for $ctrl in $controls
+ #set $code = '\n\t\t'.join($ctrl.get_make().splitlines()[1:])
+ $code
+#end for
+########################################################
##Create Blocks
## Write the block make, and indent with 2 tabs.
########################################################
Modified: gnuradio/trunk/grc/src/grc_gnuradio/FlowGraph.py
===================================================================
--- gnuradio/trunk/grc/src/grc_gnuradio/FlowGraph.py 2008-08-29 20:02:46 UTC
(rev 9449)
+++ gnuradio/trunk/grc/src/grc_gnuradio/FlowGraph.py 2008-08-29 20:55:06 UTC
(rev 9450)
@@ -24,6 +24,22 @@
from Block import Block
from Connection import Connection
+def get_variable_code(variable):
+ """!
+ Get the code representation for a variable.
+ Normally this is the value parameter.
+ For the variable chooser, use the index and choices.
+ Avoid using the to_code method of the variables,
+ as this forces evaluation before the variables are evaluated.
+ @param variable the variable block
+ @return the code string
+ """
+ if variable.get_key() == 'variable_chooser':
+ choices = variable.get_param('choices').get_value()
+ value_index = variable.get_param('value_index').get_value()
+ return "(%s)[%s]"%(choices, value_index)
+ return variable.get_param('value').get_value()
+
class FlowGraph(_FlowGraph):
def _get_io_signature(self, pad_key):
@@ -87,9 +103,7 @@
id2var = dict([(var.get_id(), var) for var in variables])
#map var id to variable code
#variable code is a concatenation of all param code (without
the id param)
- id2expr = dict([(var.get_id(),
- ' '.join([param.to_code() for param in filter(lambda p:
p.get_key() != 'id', var.get_params())])
- ) for var in variables])
+ id2expr = dict([(var.get_id(), get_variable_code(var)) for var
in variables])
#sort according to dependency
sorted_ids = expr_utils.sort_variables(id2expr)
#create list of sorted variable blocks
@@ -130,12 +144,7 @@
#load variables
for variable in self.get_variables():
try:
- if variable.get_key() ==
'variable_chooser':
- choices =
variable.get_param('choices').to_code()
- value_index =
variable.get_param('value_index').to_code()
- e = eval("%s[%s]"%(choices,
value_index), n, n)
- else:
- e =
eval(variable.get_param('value').to_code(), n, n)
+ e = eval(get_variable_code(variable),
n, n)
n[variable.get_id()] = e
except: pass
#make namespace public
Modified: gnuradio/trunk/grc/src/grc_gnuradio/Generator.py
===================================================================
--- gnuradio/trunk/grc/src/grc_gnuradio/Generator.py 2008-08-29 20:02:46 UTC
(rev 9449)
+++ gnuradio/trunk/grc/src/grc_gnuradio/Generator.py 2008-08-29 20:55:06 UTC
(rev 9450)
@@ -76,6 +76,8 @@
imports = self._flow_graph.get_imports()
variables = self._flow_graph.get_variables()
parameters = self._flow_graph.get_parameters()
+ #list of variables with controls
+ controls = filter(lambda v:
v.get_key().startswith('variable_'), variables)
#list of blocks not including variables and imports and
parameters and disabled
blocks = sorted(self._flow_graph.get_enabled_blocks(), lambda
x, y: cmp(x.get_id(), y.get_id()))
blocks = filter(lambda b: b not in (imports + parameters +
variables), blocks)
@@ -117,6 +119,7 @@
'imports': imports,
'flow_graph': self._flow_graph,
'variables': variables,
+ 'controls': controls,
'parameters': parameters,
'blocks': blocks,
'connections': connections,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9450 - in gnuradio/trunk/grc: data/grc_gnuradio src/grc_gnuradio,
jblum <=