commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r8869 - in grc/trunk/src: grc/gui grc_gnuradio grc_gnu


From: jblum
Subject: [Commit-gnuradio] r8869 - in grc/trunk/src: grc/gui grc_gnuradio grc_gnuradio/blocks grc_gnuradio/blocks/sinks grc_gnuradio/blocks/sources grc_gnuradio/data
Date: Fri, 11 Jul 2008 14:52:14 -0600 (MDT)

Author: jblum
Date: 2008-07-11 14:52:11 -0600 (Fri, 11 Jul 2008)
New Revision: 8869

Modified:
   grc/trunk/src/grc/gui/NotebookPage.py
   grc/trunk/src/grc_gnuradio/FlowGraph.py
   grc/trunk/src/grc_gnuradio/Generator.py
   grc/trunk/src/grc_gnuradio/blocks/options.xml
   grc/trunk/src/grc_gnuradio/blocks/preferences.xml
   grc/trunk/src/grc_gnuradio/blocks/sinks/pad_sink.xml
   grc/trunk/src/grc_gnuradio/blocks/sources/pad_source.xml
   grc/trunk/src/grc_gnuradio/data/flow_graph.tmpl
Log:
hier block generation

Modified: grc/trunk/src/grc/gui/NotebookPage.py
===================================================================
--- grc/trunk/src/grc/gui/NotebookPage.py       2008-07-11 17:30:12 UTC (rev 
8868)
+++ grc/trunk/src/grc/gui/NotebookPage.py       2008-07-11 20:52:11 UTC (rev 
8869)
@@ -35,13 +35,13 @@
 
 class Page(gtk.HBox):
        """A page in the notebook."""
-       
+
        def __init__(self, main_window, flow_graph, file_path=''):
                """
                Page constructor.
                @param main_window main window
                @param file_path path to a flow graph file
-               """             
+               """
                self._flow_graph = flow_graph
                self.set_pid(None)
                #import the file
@@ -54,13 +54,13 @@
                ############################################################
                ParseXML.validate_dtd(file_path, os.path.join(DATA_DIR, 
'flow_graph.dtd'))
                initial_state = ParseXML.from_file(file_path)
-               self.state_cache = StateCache(initial_state)                    
        
-               self.set_saved(True)    
-               #parse xml success, initialize page             
+               self.state_cache = StateCache(initial_state)
+               self.set_saved(True)
+               #parse xml success, initialize page
                gtk.HBox.__init__(self, False, 0)
-               self.show()             
+               self.show()
                #tab box to hold label and close button
-               self.tab = gtk.HBox(False, 0)                   
+               self.tab = gtk.HBox(False, 0)
                #setup tab label
                self.label = gtk.Label()
                self.tab.pack_start(self.label, False)
@@ -75,12 +75,12 @@
                button.connect("clicked", self._handle_button)
                button.set_relief(gtk.RELIEF_NONE)
                button.add(image_box)
-               #button size            
+               #button size
                w, h = gtk.icon_size_lookup_for_settings(button.get_settings(), 
gtk.ICON_SIZE_MENU)
                button.set_size_request(w+6, h+6)
-               self.tab.pack_start(button, False)              
+               self.tab.pack_start(button, False)
                self.tab.show_all()
-               
+
        def get_generator(self):
                """!
                Get the generator object for this flow graph.
@@ -90,7 +90,7 @@
                        self.get_flow_graph(),
                        self.get_file_path(),
                )
-               
+
        def _handle_button(self, button):
                """
                The button was clicked.
@@ -99,49 +99,49 @@
                """
                self.main_window.page_to_be_closed = self
                self.main_window.handle_states(FLOW_GRAPH_CLOSE)
-               
+
        def set_text(self, text):
                """
                Set the text in this label.
                @param text the new text
                """
                self.label.set_text(text)
-               
+
        def get_tab(self):
                """
                Get the gtk widget for this page's tab.
-               @return gtk widget 
+               @return gtk widget
                """
                return self.tab
-               
+
        def get_pid(self):
                """!
                Get the pid for the flow graph.
                @return the pid number
                """
                return self.pid
-       
+
        def set_pid(self, pid):
                """!
                Set the pid number.
                @param pid the new pid number
                """
                self.pid = pid
-               
+
        def get_flow_graph(self):
                """!
                Get the flow graph.
                @return the flow graph
                """
                return self._flow_graph
-       
+
        def get_file_path(self):
                """!
                Get the file path for the flow graph.
                @return the file path or ''
                """
                return self.file_path
-       
+
        def set_file_path(self, file_path=''):
                """!
                Set the file path, '' for no file path.
@@ -149,21 +149,21 @@
                """
                if file_path: self.file_path = os.path.abspath(file_path)
                else: self.file_path = ''
-       
+
        def get_saved(self):
                """!
                Get the saved status for the flow graph.
                @return true if saved
                """
                return self.saved
-       
+
        def set_saved(self, saved=True):
                """!
                Set the saved status.
                @param saved boolean status
                """
-               self.saved = saved 
-       
+               self.saved = saved
+
        def get_state_cache(self):
                """!
                Get the state cache for the flow graph.

Modified: grc/trunk/src/grc_gnuradio/FlowGraph.py
===================================================================
--- grc/trunk/src/grc_gnuradio/FlowGraph.py     2008-07-11 17:30:12 UTC (rev 
8868)
+++ grc/trunk/src/grc_gnuradio/FlowGraph.py     2008-07-11 20:52:11 UTC (rev 
8869)
@@ -27,6 +27,38 @@
 
 class FlowGraph(_FlowGraph):
 
+       def _get_io_signature(self, pad_key):
+               """!
+               Get an io signature for this flow graph.
+               The pad key determines the directionality of the io signature.
+               @param pad_key a string of pad_source or pad_sink
+               @return a string tuple of type, num_ports, port_size
+               """
+               pads = filter(lambda b: b.get_key() == pad_key, 
self.get_blocks())
+               if not pads: return '', '0', '0'
+               pad = pads[0] #take only the first, user should not have more 
than 1
+               nports = pad.get_param('nports').to_code()
+               type = pad.get_param('type').to_code()
+               size = pad.get_param('type').get_opt('size')
+               vlen = pad.get_param('vlen').to_code()
+               return type, nports, "%s*%s"%(size, vlen)
+
+       def get_input_signature(self):
+               """!
+               Get the io signature for the input side of this flow graph.
+               The io signature with be "0", "0" if no pad source is present.
+               @return a string tuple of type, num_ports, port_size
+               """
+               return self._get_io_signature('pad_source')
+
+       def get_output_signature(self):
+               """!
+               Get the io signature for the output side of this flow graph.
+               The io signature with be "0", "0" if no pad sink is present.
+               @return a string tuple of type, num_ports, port_size
+               """
+               return self._get_io_signature('pad_sink')
+
        def get_imports(self):
                """!
                Get a set of all import statments in this flow graph namespace.

Modified: grc/trunk/src/grc_gnuradio/Generator.py
===================================================================
--- grc/trunk/src/grc_gnuradio/Generator.py     2008-07-11 17:30:12 UTC (rev 
8868)
+++ grc/trunk/src/grc_gnuradio/Generator.py     2008-07-11 20:52:11 UTC (rev 
8869)
@@ -37,32 +37,34 @@
 FLOW_GRAPH_TEMPLATE = os.path.join(PATH, 'data', 'flow_graph.tmpl')
 
 class Generator(object):
-       
+
        def __init__(self, flow_graph, file_path):
                self._flow_graph = flow_graph
-               self._file_path = file_path.replace(FLOW_GRAPH_FILE_EXTENSION, 
'') + '.py'
-               
+               filename = self._flow_graph.get_option('id') + '.py'
+               dirname = os.path.dirname(file_path)
+               self._file_path = os.path.join(dirname, filename)
+
        def get_file_path(self): return self._file_path
-               
+
        def write(self):
                #generate
                open(self.get_file_path(), 'w').write(str(self))
                mode = stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | 
stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP | stat.S_IROTH
-               os.chmod(self.get_file_path(), mode)            
-               
+               os.chmod(self.get_file_path(), mode)
+
        def get_popen(self):
                """!
                Generate and execute this python flow graph.
                @param file_path the file path of the flow graph
                @return a popen object
-               """             
+               """
                #execute
                cmds = [PYEXEC, self.get_file_path()]
                if self._flow_graph.get_option('generate_options') == 'no_gui':
-                       cmds = ['xterm', '-e'] + cmds                   
+                       cmds = ['xterm', '-e'] + cmds
                p = subprocess.Popen(args=cmds, stdout=subprocess.PIPE, 
stderr=subprocess.STDOUT, shell=False, universal_newlines=True)
                return p
-                               
+
        def __str__(self):
                """!
                Convert the flow graph to python code.
@@ -74,7 +76,7 @@
                blocks = sorted(self._flow_graph.get_blocks(), lambda x, y: 
cmp(x.get_id(), y.get_id()))
                blocks = filter(lambda b: b not in (imports + variables) and 
b.get_enabled(), blocks)
                namespace = {
-                       'imports':      imports,
+                       'imports': imports,
                        'flow_graph': self._flow_graph,
                        'variables': variables,
                        'blocks': blocks,

Modified: grc/trunk/src/grc_gnuradio/blocks/options.xml
===================================================================
--- grc/trunk/src/grc_gnuradio/blocks/options.xml       2008-07-11 17:30:12 UTC 
(rev 8868)
+++ grc/trunk/src/grc_gnuradio/blocks/options.xml       2008-07-11 20:52:11 UTC 
(rev 8869)
@@ -1,9 +1,9 @@
 <?xml version="1.0"?>
 <!DOCTYPE block SYSTEM "./block.dtd">
-<!-- 
+<!--
 ###################################################
 ##Options Block:
-## options for window size, 
+## options for window size,
 ## and flow graph building.
 ###################################################
  -->
@@ -21,19 +21,19 @@
                <name>Title</name>
                <key>title</key>
                <value>untitled</value>
-               <type>string</type>             
+               <type>string</type>
        </param>
        <param>
                <name>Author</name>
                <key>author</key>
                <value>unknown</value>
-               <type>string</type>             
+               <type>string</type>
        </param>
        <param>
                <name>Description</name>
                <key>description</key>
                <value>gnuradio flow graph</value>
-               <type>string</type>                     
+               <type>string</type>
        </param>
        <param>
                <name>Window Size</name>
@@ -48,24 +48,28 @@
                <type>enum</type>
                <option>
                        <name>WX GUI</name>
-                       <key>wx_gui</key>       
+                       <key>wx_gui</key>
                </option>
                <option>
                        <name>No GUI</name>
-                       <key>no_gui</key>       
+                       <key>no_gui</key>
                </option>
-       </param>        
+               <option>
+                       <name>Hier Block</name>
+                       <key>hb</key>
+               </option>
+       </param>
        <check>len($window_size) == 2</check>
        <check>300 &lt;= $(window_size)[0] &lt;= 2048</check>
        <check>300 &lt;= $(window_size)[1] &lt;= 2048</check>
        <doc>
 The options block sets special parameters for the flow graph. \
-Only one option block is allowed per flow graph. 
+Only one option block is allowed per flow graph.
 
-Title, author, and description parameters are for identification purposes. 
+Title, author, and description parameters are for identification purposes.
 
 The window size controls the dimensions of the flow graph editor. \
-The window size (width, height) must be between (300, 300) and (2048, 2048). 
+The window size (width, height) must be between (300, 300) and (2048, 2048).
 
 The generate options controls the type of code generated (wx-graphical or 
non-graphical). \
 Non-graphical flow graphs should avoid using graphical sinks or graphical 
variable controls.

Modified: grc/trunk/src/grc_gnuradio/blocks/preferences.xml
===================================================================
--- grc/trunk/src/grc_gnuradio/blocks/preferences.xml   2008-07-11 17:30:12 UTC 
(rev 8868)
+++ grc/trunk/src/grc_gnuradio/blocks/preferences.xml   2008-07-11 20:52:11 UTC 
(rev 8869)
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <!DOCTYPE block SYSTEM "./block.dtd">
-<!-- 
+<!--
 ###################################################
 ##Global Preferences:
 ##     This block should not appear in the tree.
@@ -15,19 +15,19 @@
                <name>File Open</name>
                <key>file_open</key>
                <value></value>
-               <type>string</type>     
+               <type>string</type>
        </param>
        <param>
                <name>Files Open</name>
                <key>files_open</key>
                <value></value>
-               <type>string</type>     
+               <type>string</type>
        </param>
        <param>
                <name>Window Size</name>
                <key>window_size</key>
                <value>800, 600</value>
-               <type>int_vector</type> 
+               <type>int_vector</type>
        </param>
        <!-- Snap to Grid -->
        <param>
@@ -37,11 +37,11 @@
                <type>enum</type>
                <option>
                        <name>Off</name>
-                       <key>off</key>          
+                       <key>off</key>
                </option>
                <option>
                        <name>On</name>
-                       <key>on</key>           
+                       <key>on</key>
                </option>
        </param>
        <param>
@@ -51,19 +51,19 @@
                <type>enum</type>
                <option>
                        <name>10 pixels</name>
-                       <key>10</key>           
+                       <key>10</key>
                </option>
                <option>
                        <name>20 pixels</name>
-                       <key>20</key>           
+                       <key>20</key>
                </option>
                <option>
                        <name>50 pixels</name>
-                       <key>50</key>           
+                       <key>50</key>
                </option>
                <option>
                        <name>100 pixels</name>
-                       <key>100</key>          
+                       <key>100</key>
                </option>
        </param>
        <param>
@@ -73,11 +73,11 @@
                <type>enum</type>
                <option>
                        <name>Show</name>
-                       <key>show</key>         
+                       <key>show</key>
                </option>
                <option>
                        <name>Hide</name>
-                       <key>hide</key>         
+                       <key>hide</key>
                </option>
        </param>
        <!-- Appearance Prefs -->
@@ -88,11 +88,11 @@
                <type>enum</type>
                <option>
                        <name>Show</name>
-                       <key>show</key>         
+                       <key>show</key>
                </option>
                <option>
                        <name>Hide</name>
-                       <key>hide</key>         
+                       <key>hide</key>
                </option>
        </param>
        <param>
@@ -102,11 +102,11 @@
                <type>enum</type>
                <option>
                        <name>Show</name>
-                       <key>show</key>         
+                       <key>show</key>
                </option>
                <option>
                        <name>Hide</name>
-                       <key>hide</key>         
+                       <key>hide</key>
                </option>
        </param>
        <param>
@@ -116,11 +116,11 @@
                <type>enum</type>
                <option>
                        <name>Show</name>
-                       <key>show</key>         
+                       <key>show</key>
                </option>
                <option>
                        <name>Hide</name>
-                       <key>hide</key>         
+                       <key>hide</key>
                </option>
        </param>
        <!-- Misc Prefs -->
@@ -131,11 +131,11 @@
                <type>enum</type>
                <option>
                        <name>Yes</name>
-                       <key>yes</key>          
+                       <key>yes</key>
                </option>
                <option>
                        <name>No</name>
-                       <key>no</key>           
+                       <key>no</key>
                </option>
        </param>
 </block>

Modified: grc/trunk/src/grc_gnuradio/blocks/sinks/pad_sink.xml
===================================================================
--- grc/trunk/src/grc_gnuradio/blocks/sinks/pad_sink.xml        2008-07-11 
17:30:12 UTC (rev 8868)
+++ grc/trunk/src/grc_gnuradio/blocks/sinks/pad_sink.xml        2008-07-11 
20:52:11 UTC (rev 8869)
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <!DOCTYPE block SYSTEM "../block.dtd">
-<!-- 
+<!--
 ###################################################
 ##Pad Sink: IO Pads
 ###################################################
@@ -11,9 +11,9 @@
        <make></make>
        <param>
                <name>Num Inputs</name>
-               <key>num_inputs</key>
+               <key>nports</key>
                <value>1</value>
-               <type>int</type>                
+               <type>int</type>
        </param>
        <param>
                <name>Input Type</name>
@@ -22,46 +22,48 @@
                <option>
                        <name>Complex</name>
                        <key>complex</key>
-                       <opt>size:gr.sizeof_gr_complex</opt>                    
                
+                       <opt>size:gr.sizeof_gr_complex</opt>
                </option>
                <option>
                        <name>Float</name>
                        <key>float</key>
-                       <opt>size:gr.sizeof_float</opt>                 
+                       <opt>size:gr.sizeof_float</opt>
                </option>
                <option>
                        <name>Int</name>
                        <key>int</key>
-                       <opt>size:gr.sizeof_int</opt>                           
+                       <opt>size:gr.sizeof_int</opt>
                </option>
                <option>
                        <name>Short</name>
                        <key>short</key>
-                       <opt>size:gr.sizeof_short</opt>                         
        
+                       <opt>size:gr.sizeof_short</opt>
                </option>
                <option>
                        <name>Byte</name>
                        <key>byte</key>
-                       <opt>size:gr.sizeof_char</opt>                          
                
+                       <opt>size:gr.sizeof_char</opt>
                </option>
-       </param>        
+       </param>
        <param>
                <name>Vec Length</name>
                <key>vlen</key>
                <value>1</value>
-               <type>int</type>                
+               <type>int</type>
        </param>
        <check>$vlen &gt; 0</check>
-       <check>0 &lt; $num_inputs</check>
+       <check>0 &lt; $nports</check>
        <sink>
                <name>in</name>
                <type>$type</type>
                <vlen>$vlen</vlen>
-               <nports>$num_inputs</nports>
-       </sink> 
+               <nports>$nports</nports>
+       </sink>
        <doc>
 This is a sink pad block for creating hierarchical flow graphs. \
 The inputs of this block will become the outputs to this flow graph when it is 
instantiated as a hierarchical block. \
 Limit one sink pad block per flow graph.
+
+Remember to set the generate options to hier block.
        </doc>
 </block>

Modified: grc/trunk/src/grc_gnuradio/blocks/sources/pad_source.xml
===================================================================
--- grc/trunk/src/grc_gnuradio/blocks/sources/pad_source.xml    2008-07-11 
17:30:12 UTC (rev 8868)
+++ grc/trunk/src/grc_gnuradio/blocks/sources/pad_source.xml    2008-07-11 
20:52:11 UTC (rev 8869)
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <!DOCTYPE block SYSTEM "../block.dtd">
-<!-- 
+<!--
 ###################################################
 ##Pad Source: IO Pads
 ###################################################
@@ -11,9 +11,9 @@
        <make></make>
        <param>
                <name>Num Outputs</name>
-               <key>num_outputs</key>
+               <key>nports</key>
                <value>1</value>
-               <type>int</type>                
+               <type>int</type>
        </param>
        <param>
                <name>Output Type</name>
@@ -22,46 +22,48 @@
                <option>
                        <name>Complex</name>
                        <key>complex</key>
-                       <opt>size:gr.sizeof_gr_complex</opt>                    
                
+                       <opt>size:gr.sizeof_gr_complex</opt>
                </option>
                <option>
                        <name>Float</name>
                        <key>float</key>
-                       <opt>size:gr.sizeof_float</opt>                 
+                       <opt>size:gr.sizeof_float</opt>
                </option>
                <option>
                        <name>Int</name>
                        <key>int</key>
-                       <opt>size:gr.sizeof_int</opt>                           
+                       <opt>size:gr.sizeof_int</opt>
                </option>
                <option>
                        <name>Short</name>
                        <key>short</key>
-                       <opt>size:gr.sizeof_short</opt>                         
        
+                       <opt>size:gr.sizeof_short</opt>
                </option>
                <option>
                        <name>Byte</name>
                        <key>byte</key>
-                       <opt>size:gr.sizeof_char</opt>                          
                
+                       <opt>size:gr.sizeof_char</opt>
                </option>
-       </param>        
+       </param>
        <param>
                <name>Vec Length</name>
                <key>vlen</key>
                <value>1</value>
-               <type>int</type>                
+               <type>int</type>
        </param>
        <check>$vlen &gt; 0</check>
-       <check>0 &lt; $num_outputs</check>
+       <check>0 &lt; $nports</check>
        <source>
                <name>out</name>
                <type>$type</type>
                <vlen>$vlen</vlen>
-               <nports>$num_outputs</nports>
-       </source>       
+               <nports>$nports</nports>
+       </source>
        <doc>
 This is a source pad block for creating hierarchical flow graphs. \
 The outputs of this block will become the inputs to this flow graph when it is 
instantiated as a hierarchical block. \
 Limit one source pad block per flow graph.
+
+Remember to set the generate options to hier block.
        </doc>
 </block>

Modified: grc/trunk/src/grc_gnuradio/data/flow_graph.tmpl
===================================================================
--- grc/trunk/src/grc_gnuradio/data/flow_graph.tmpl     2008-07-11 17:30:12 UTC 
(rev 8868)
+++ grc/trunk/src/grc_gnuradio/data/flow_graph.tmpl     2008-07-11 20:52:11 UTC 
(rev 8869)
@@ -21,14 +21,31 @@
 $DIVIDER
 
 ########################################################
-##     Create Imports
+##Create Imports
 ########################################################
 #for $imp in $imports
 $imp
 #end for
 
+########################################################
+##Create Variables
+##     Write out the first line the variable make.
+########################################################
+#for $var in $variables
+       #set $code = $var.get_make().splitlines()[0]
+$var.get_id() = $code
+#end for
+
+########################################################
+##Create Class
+##     Write the class declaration for a top or hier block.
+##     The variable names are the arguments to __init__.
+##     The variable declaration above provide default values.
+##     Determine the absolute icon path (wx gui only).
+##     Setup the IO signature (hier block only).
+########################################################
 #set $class_name = $flow_graph.get_option('id')
-#set $var_ids_str = ', '.join(['self'] + [var.get_id() for var in $variables])
+#set $var_ids_str = ', '.join(['self'] + ['%s=%s'%(var.get_id(), var.get_id()) 
for var in $variables])
 #if $gui_type == 'wx_gui'
        #import os
        #from grc.Constants import MAIN_WINDOW_PREFIX,DATA_DIR
@@ -50,11 +67,28 @@
 class $(class_name)(gr.top_block):
 
        def __init__($var_ids_str):
-               gr.top_block.__init__(self)
+               gr.top_block.__init__(self, "$flow_graph.get_option('title')")
+#elif $gui_type == 'hb'
+       #set $in_sig = $flow_graph.get_input_signature()
+       #set $out_sig = $flow_graph.get_output_signature()
+class $(class_name)(gr.hier_block2):
+
+       def __init__($var_ids_str):
+               gr.hier_block2.__init__(
+                       self,
+                       "$flow_graph.get_option('title')",
+                       gr.io_signature($in_sig[1], $in_sig[1], $in_sig[2]),
+                       gr.io_signature($out_sig[1], $out_sig[1], $out_sig[2]),
+               )
 #end if
 
 ########################################################
-##     Create Variables
+##Create Variables
+##     Remove the first line of the variable make,
+##     This line will be handled in the main section.
+##     Set the variable to a property of self.
+##     Write the variable make (minus the first line).
+##     Indent the variable make with 2 tabs.
 ########################################################
                $DIVIDER
                # Variables
@@ -68,7 +102,8 @@
 #end for
 
 ########################################################
-##     Create Blocks
+##Create Blocks
+##     Write the block make, and indent with 2 tabs.
 ########################################################
                $DIVIDER
                # Blocks
@@ -79,7 +114,9 @@
 #end for
 
 ########################################################
-##     Create Connections
+##Create Connections
+##     The port name should be the id of the parent block.
+##     However, port names for IO pads should be self.
 ########################################################
                $DIVIDER
                # Connections
@@ -87,21 +124,30 @@
 #for $con in $connections
        #set $source = $con.get_source()
        #set $sink = $con.get_sink()
-               $("self.connect((self.%s, %s), (self.%s, %s))"%(
-                               $source.get_parent().get_id(), 
+       #if $source.get_parent().get_key() == 'pad_source'
+               #set $source_name = 'self'
+       #else
+               #set $source_name = 'self.' + $source.get_parent().get_id()
+       #end if
+       #if $sink.get_parent().get_key() == 'pad_sink'
+               #set $sink_name = 'self'
+       #else
+               #set $sink_name = 'self.' + $sink.get_parent().get_id()
+       #end if
+               $("self.connect((%s, %s), (%s, %s))"%(
+                               $source_name,
                                $source.get_key(),
-                               $sink.get_parent().get_id(), 
+                               $sink_name,
                                $sink.get_key(),
                        )
                )
 #end for
 
 ########################################################
-##     Create Callbacks
+##Create Callbacks
+##     Determine block callbacks that depend on the variable.
+##     Write a set method for this variable that calls the callbacks.
 ########################################################
-       $DIVIDER
-       # Callbacks
-       $DIVIDER
 #for $var in $variables
        #set $id = $var.get_id()
        #set $var_callbacks = filter(lambda c: id in ''.join(c.split('(')[1:]), 
$callbacks)
@@ -112,18 +158,20 @@
        #end for
 
 #end for
+########################################################
+##Create Main
+##     For top block code, generate a main routine.
+##     Instantiate the top block and run as gui or cli.
+########################################################
+#if $gui_type != 'hb'
 if __name__ == '__main__':
-#for $var in $variables
-       #set $code = $var.get_make().splitlines()[0]
-       $var.get_id() = $code
-#end for
-       #set $var_ids_str = ', '.join(["%s=%s"%(var.get_id(), var.get_id()) for 
var in $variables])
-       tb = $(class_name)($var_ids_str)
-#if $gui_type == 'wx_gui'
+       tb = $(class_name)()
+       #if $gui_type == 'wx_gui'
        tb.Run()
-#elif $gui_type == 'no_gui'
+       #elif $gui_type == 'no_gui'
        tb.start()
        raw_input('Press Enter to quit: ')
        tb.stop()
+       #end if
 #end if
 





reply via email to

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