commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r11256 - in gnuradio/branches/developers/jblum/grc/grc


From: jblum
Subject: [Commit-gnuradio] r11256 - in gnuradio/branches/developers/jblum/grc/grc: blocks python
Date: Sun, 21 Jun 2009 19:03:19 -0600 (MDT)

Author: jblum
Date: 2009-06-21 19:03:19 -0600 (Sun, 21 Jun 2009)
New Revision: 11256

Modified:
   gnuradio/branches/developers/jblum/grc/grc/blocks/variable.xml
   gnuradio/branches/developers/jblum/grc/grc/blocks/variable_check_box.xml
   gnuradio/branches/developers/jblum/grc/grc/blocks/variable_chooser.xml
   gnuradio/branches/developers/jblum/grc/grc/blocks/variable_config.xml
   gnuradio/branches/developers/jblum/grc/grc/blocks/variable_slider.xml
   gnuradio/branches/developers/jblum/grc/grc/blocks/variable_static_text.xml
   gnuradio/branches/developers/jblum/grc/grc/blocks/variable_text_box.xml
   gnuradio/branches/developers/jblum/grc/grc/python/FlowGraph.py
   gnuradio/branches/developers/jblum/grc/grc/python/Generator.py
   gnuradio/branches/developers/jblum/grc/grc/python/flow_graph.tmpl
Log:
Use the variable blocks themselves to provide callbacks for setting the 
variables.
Simplifies code in the generator and template. Also fixes a bug I just created 
in this branch.



Modified: gnuradio/branches/developers/jblum/grc/grc/blocks/variable.xml
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/blocks/variable.xml      
2009-06-21 19:23:06 UTC (rev 11255)
+++ gnuradio/branches/developers/jblum/grc/grc/blocks/variable.xml      
2009-06-22 01:03:19 UTC (rev 11256)
@@ -9,6 +9,7 @@
        <key>variable</key>
        <var_make>self.$(id) = $(id) = $value</var_make>
        <make></make>
+       <callback>self.set_$(id)($value)</callback>
        <param>
                <name>Value</name>
                <key>value</key>

Modified: 
gnuradio/branches/developers/jblum/grc/grc/blocks/variable_check_box.xml
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/blocks/variable_check_box.xml    
2009-06-21 19:23:06 UTC (rev 11255)
+++ gnuradio/branches/developers/jblum/grc/grc/blocks/variable_check_box.xml    
2009-06-22 01:03:19 UTC (rev 11256)
@@ -28,6 +28,7 @@
 #else
 self.GridAdd(self.$(id)_check_box, $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])
 #end if</make>
+       <callback>self.set_$(id)($value)</callback>
        <callback>self.$(id)_check_box.set_value($id)</callback>
        <param>
                <name>Label</name>

Modified: gnuradio/branches/developers/jblum/grc/grc/blocks/variable_chooser.xml
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/blocks/variable_chooser.xml      
2009-06-21 19:23:06 UTC (rev 11255)
+++ gnuradio/branches/developers/jblum/grc/grc/blocks/variable_chooser.xml      
2009-06-22 01:03:19 UTC (rev 11256)
@@ -32,6 +32,7 @@
 #else
 self.GridAdd(self.$(id)_chooser, $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])
 #end if</make>
+       <callback>self.set_$(id)($value)</callback>
        <callback>self.$(id)_chooser.set_value($id)</callback>
        <param>
                <name>Label</name>

Modified: gnuradio/branches/developers/jblum/grc/grc/blocks/variable_config.xml
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/blocks/variable_config.xml       
2009-06-21 19:23:06 UTC (rev 11255)
+++ gnuradio/branches/developers/jblum/grc/grc/blocks/variable_config.xml       
2009-06-22 01:03:19 UTC (rev 11256)
@@ -17,6 +17,7 @@
 except: $(id) = $value
 self.$(id) = $(id)</var_make>
        <make></make>
+       <callback>self.set_$(id)($value)</callback>
        <callback>self._$(id)_config.set($section, $option, str($writeback))
 self._$(id)_config.write(open($config_file, 'w'))</callback>
        <param>

Modified: gnuradio/branches/developers/jblum/grc/grc/blocks/variable_slider.xml
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/blocks/variable_slider.xml       
2009-06-21 19:23:06 UTC (rev 11255)
+++ gnuradio/branches/developers/jblum/grc/grc/blocks/variable_slider.xml       
2009-06-22 01:03:19 UTC (rev 11256)
@@ -42,6 +42,7 @@
 #else
 self.GridAdd(_$(id)_sizer, $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])
 #end if</make>
+       <callback>self.set_$(id)($value)</callback>
        <callback>self.$(id)_slider.set_value($id)</callback>
        <callback>self.$(id)_text_box.set_value($id)</callback>
        <param>

Modified: 
gnuradio/branches/developers/jblum/grc/grc/blocks/variable_static_text.xml
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/blocks/variable_static_text.xml  
2009-06-21 19:23:06 UTC (rev 11255)
+++ gnuradio/branches/developers/jblum/grc/grc/blocks/variable_static_text.xml  
2009-06-22 01:03:19 UTC (rev 11256)
@@ -31,6 +31,7 @@
 #else
 self.GridAdd(self.$(id)_static_text, $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])
 #end if</make>
+       <callback>self.set_$(id)($value)</callback>
        <callback>self.$(id)_static_text.set_value($id)</callback>
        <param>
                <name>Label</name>

Modified: 
gnuradio/branches/developers/jblum/grc/grc/blocks/variable_text_box.xml
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/blocks/variable_text_box.xml     
2009-06-21 19:23:06 UTC (rev 11255)
+++ gnuradio/branches/developers/jblum/grc/grc/blocks/variable_text_box.xml     
2009-06-22 01:03:19 UTC (rev 11256)
@@ -31,6 +31,7 @@
 #else
 self.GridAdd(self.$(id)_text_box, $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])
 #end if</make>
+       <callback>self.set_$(id)($value)</callback>
        <callback>self.$(id)_text_box.set_value($id)</callback>
        <param>
                <name>Label</name>

Modified: gnuradio/branches/developers/jblum/grc/grc/python/FlowGraph.py
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/python/FlowGraph.py      
2009-06-21 19:23:06 UTC (rev 11255)
+++ gnuradio/branches/developers/jblum/grc/grc/python/FlowGraph.py      
2009-06-22 01:03:19 UTC (rev 11256)
@@ -114,7 +114,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(), 
var.get_param('value').get_value()) for var in variables])
+               id2expr = dict([(var.get_id(), _get_value_expr(var)) for var in 
variables])
                #sort according to dependency
                sorted_ids = expr_utils.sort_variables(id2expr)
                #create list of sorted variable blocks

Modified: gnuradio/branches/developers/jblum/grc/grc/python/Generator.py
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/python/Generator.py      
2009-06-21 19:23:06 UTC (rev 11255)
+++ gnuradio/branches/developers/jblum/grc/grc/python/Generator.py      
2009-06-22 01:03:19 UTC (rev 11256)
@@ -102,28 +102,9 @@
                        expr_utils.expr_replace(cb, replace_dict)
                        for cb in sum([block.get_callbacks() for block in 
self._flow_graph.get_enabled_blocks()], [])
                ]
-               #map var id to the expression
-               var_id2expr = dict(
-                       [(var.get_id(), 
expr_utils.expr_replace(var.get_make().split('\n')[0], replace_dict))
-                       for var in parameters + variables]
-               )
-               #create graph structure for variables
-               variable_graph = expr_utils.get_graph(var_id2expr)
-               #map var id to direct dependents
-               #for each var id, make a list of all 2nd order edges
-               #use all edges of that id that are not also 2nd order edges
-               #meaning: list variables the ONLY depend directly on this 
variable
-               #and not variables that also depend indirectly on this variable
-               var_id2deps = dict(
-                       [(var_id, filter(lambda e: e not in 
sum([list(variable_graph.get_edges(edge))
-                               for edge in variable_graph.get_edges(var_id)], 
[]), variable_graph.get_edges(var_id)
-                               )
-                       )
-                       for var_id in var_ids]
-               )
                #map var id to callbacks
                var_id2cbs = dict(
-                       [(var_id, filter(lambda c: var_id in 
expr_utils.expr_split(c), callbacks))
+                       [(var_id, filter(lambda c: 
expr_utils.get_variable_dependencies(c, [var_id]), callbacks))
                        for var_id in var_ids]
                )
                #load the namespace
@@ -137,8 +118,6 @@
                        'blocks': blocks,
                        'connections': connections,
                        'generate_options': self._generate_options,
-                       'var_id2expr': var_id2expr,
-                       'var_id2deps': var_id2deps,
                        'var_id2cbs': var_id2cbs,
                }
                #build the template

Modified: gnuradio/branches/developers/jblum/grc/grc/python/flow_graph.tmpl
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/python/flow_graph.tmpl   
2009-06-21 19:23:06 UTC (rev 11255)
+++ gnuradio/branches/developers/jblum/grc/grc/python/flow_graph.tmpl   
2009-06-22 01:03:19 UTC (rev 11256)
@@ -10,8 +10,6 @@
 address@hidden blocks the signal blocks
 address@hidden connections the connections
 address@hidden generate_options the type of flow graph
address@hidden var_id2expr variable id map to expression
address@hidden var_id2deps variable id map to direct dependencies
 address@hidden var_id2cbs variable id map to callback strings
 ########################################################
 #def indent($code)
@@ -169,9 +167,6 @@
        #set $id = $var.get_id()
        def set_$(id)(self, $id):
                self.$id = $id
-       #for $dep in $var_id2deps[$id]
-               self.set_$(dep)($var_id2expr[$dep])
-       #end for
        #for $callback in $var_id2cbs[$id]
                $indent($callback)
        #end for





reply via email to

[Prev in Thread] Current Thread [Next in Thread]