commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r8960 - in grc/trunk: notes src/grc/elements src/grc/g


From: jblum
Subject: [Commit-gnuradio] r8960 - in grc/trunk: notes src/grc/elements src/grc/gui src/grc_gnuradio
Date: Mon, 21 Jul 2008 00:20:24 -0600 (MDT)

Author: jblum
Date: 2008-07-21 00:20:24 -0600 (Mon, 21 Jul 2008)
New Revision: 8960

Modified:
   grc/trunk/notes/todo.txt
   grc/trunk/src/grc/elements/Block.py
   grc/trunk/src/grc/gui/BlockTreeWindow.py
   grc/trunk/src/grc_gnuradio/Block.py
Log:
moved checks to grc_gnuradio, block tree window uses unique keys

Modified: grc/trunk/notes/todo.txt
===================================================================
--- grc/trunk/notes/todo.txt    2008-07-21 00:38:16 UTC (rev 8959)
+++ grc/trunk/notes/todo.txt    2008-07-21 06:20:24 UTC (rev 8960)
@@ -13,11 +13,9 @@
 -hotkeys in action descriptions
 -log slider gui control
 -variable resolution graph structure
--move checks from grc Block to grc_gnuradio specific
 
 ############ Problems: ####################
 -catch error on open non-existant files
--block tree window maps block by name
 -variables dependent on variables that change
 
 ############ Suggestions: ####################

Modified: grc/trunk/src/grc/elements/Block.py
===================================================================
--- grc/trunk/src/grc/elements/Block.py 2008-07-21 00:38:16 UTC (rev 8959)
+++ grc/trunk/src/grc/elements/Block.py 2008-07-21 06:20:24 UTC (rev 8960)
@@ -65,7 +65,6 @@
                key = n['key']
                category = Utils.exists_or_else(n, 'category', '')
                params = Utils.listify(n, 'param')
-               checks = Utils.listify(n, 'check')
                sources = Utils.listify(n, 'source')
                sinks = Utils.listify(n, 'sink')
                #build the block
@@ -101,8 +100,6 @@
                        except AssertionError: self._exit_with_error('Key "%s" 
already exists in params'%key)
                        #store the param
                        self._params[key] = param
-               #store the checks
-               self._checks = checks
                #create the source objects
                self._sources = odict()
                for source in map(lambda n: 
self.get_parent().get_parent().Source(self, n), sources):
@@ -157,13 +154,6 @@
                        except AssertionError:
                                for msg in c.get_error_messages():
                                        self._add_error_message('%s: %s'%(c, 
msg))
-               for check in self._checks:
-                       check_res = self.resolve_dependencies(check)
-                       try:
-                               check_eval = 
self.get_parent().evaluate(check_res)
-                               try: assert(check_eval)
-                               except AssertionError: 
self._add_error_message('Check "%s" failed.'%check)
-                       except: self._add_error_message('Check "%s" did not 
evaluate.'%check)
 
        def __str__(self): return 'Block - %s - %s(%s)'%(self.get_id(), 
self.get_name(), self.get_key())
 

Modified: grc/trunk/src/grc/gui/BlockTreeWindow.py
===================================================================
--- grc/trunk/src/grc/gui/BlockTreeWindow.py    2008-07-21 00:38:16 UTC (rev 
8959)
+++ grc/trunk/src/grc/gui/BlockTreeWindow.py    2008-07-21 06:20:24 UTC (rev 
8960)
@@ -32,10 +32,10 @@
 
        def __init__(self, platform, get_flow_graph):
                """!
-               SignalBlockSelectionWindow constructor.
-               Show all possible signal blocks in this dialog.
-               Each signal block is represented by a gtk label of its tag and 
an add button.
-               The add button tells the flow graph to create the selected 
block. and add it to the flow graph.
+               BlockTreeWindow constructor.
+               Create a tree view of the possible blocks in the platform.
+               The tree view nodes will be category names, the leaves will be 
block names.
+               A mouse double click or button press action will trigger the 
add block event.
                @param platform the particular platform will all block 
prototypes
                @param get_flow_graph get the selected flow graph
                """
@@ -44,7 +44,7 @@
                self.platform = platform
                self.get_flow_graph = get_flow_graph
                #make the tree model for holding blocks
-               self.treestore = gtk.TreeStore(gobject.TYPE_STRING)
+               self.treestore = gtk.TreeStore(gobject.TYPE_STRING, 
gobject.TYPE_STRING)
                self.treeview = gtk.TreeView(self.treestore)
                self.treeview.set_enable_search(False) #disable pop up search 
box
                self.treeview.add_events(gtk.gdk.BUTTON_PRESS_MASK)
@@ -65,15 +65,13 @@
                self.add_button = gtk.Button(None, 'gtk-add')
                self.add_button.connect('clicked', self._handle_add_button)
                self.pack_start(self.add_button, False)
-               #map names to keys
-               self.names = dict()
                #map categories to iters
                self.categories = dict()
                #add blocks and categories
                self.platform.load_block_tree(self)
                #initialize
                self._handle_selection_change()
-               
+
        def add_block(self, block, category):
                """!
                Add a block with category to this selection window.
@@ -81,16 +79,11 @@
                @param block the block object
                @param category the category string
                """
-               if block.get_name() in self.names.keys():
-                       print '%s has more than one block with name 
"%s".'%(self.platform, block.get_name())
-                       print 'Although block names do not have to be unique, 
this gui requires that that are.'
-                       print 'Please rename the block to avoid problems.'
-                       return
                _BlockTree.add_block(self, block, category)
                new_iter = 
self.treestore.insert_before(self.categories[category], None)
                self.treestore.set_value(new_iter, 0, block.get_name())
-               self.names[block.get_name()] = block.get_key()
-               
+               self.treestore.set_value(new_iter, 1, block.get_key())
+
        def add_category(self, category):
                """!
                Add a category to this selection window.
@@ -128,7 +121,6 @@
                selection = self.treeview.get_selection()
                treestore, iter = selection.get_selected()
                if iter and not treestore.iter_has_child(iter):
-                       name = treestore.get_value(iter, 0)
-                       key = self.names[name]
+                       key = treestore.get_value(iter, 1)
                        self.get_flow_graph().add_new_block(key)
 

Modified: grc/trunk/src/grc_gnuradio/Block.py
===================================================================
--- grc/trunk/src/grc_gnuradio/Block.py 2008-07-21 00:38:16 UTC (rev 8959)
+++ grc/trunk/src/grc_gnuradio/Block.py 2008-07-21 06:20:24 UTC (rev 8960)
@@ -25,12 +25,12 @@
 import extract_docs
 
 class Block(_Block):
-       
+
        ##for make source to keep track of indexes
        _source_count = 0
        ##for make sink to keep track of indexes
        _sink_count = 0
-               
+
        def __init__(self, flow_graph, n):
                """
                Make a new block from nested data.
@@ -40,25 +40,41 @@
                """
                self.self_flag = False
                #grab the data
-               doc = Utils.exists_or_else(n, 'doc', '')        
+               doc = Utils.exists_or_else(n, 'doc', '')
                imports = map(lambda i: i.strip(), Utils.listify(n, 'import'))
                make = n['make']
-               callbacks = Utils.listify(n, 'callback')                        
+               checks = Utils.listify(n, 'check')
+               callbacks = Utils.listify(n, 'callback')
                #build the block
                _Block.__init__(
-                       self,                   
-                       flow_graph=flow_graph, 
+                       self,
+                       flow_graph=flow_graph,
                        n=n,
                )
                self._doc = doc
                self._imports = imports
                self._make = make
-               self._callbacks = callbacks     
-               
+               self._callbacks = callbacks
+               self._checks = checks
+
        def validate(self):
+               """!
+               Validate this block.
+               Call the base class validate.
+               Evaluate the checks: each check must evaluate to True.
+               Adjust the nports.
+               """
                _Block.validate(self)
+               #evaluate the checks
+               for check in self._checks:
+                       check_res = self.resolve_dependencies(check)
+                       try:
+                               check_eval = 
self.get_parent().evaluate(check_res)
+                               try: assert check_eval
+                               except AssertionError: 
self._add_error_message('Check "%s" failed.'%check)
+                       except: self._add_error_message('Check "%s" did not 
evaluate.'%check)
                for ports, Port in (
-                       (self._sources, self.get_parent().get_parent().Source), 
+                       (self._sources, self.get_parent().get_parent().Source),
                        (self._sinks, self.get_parent().get_parent().Sink),
                ):
                        #how many ports?
@@ -92,13 +108,13 @@
                                        ports[key] = port
                                self.update()
                                continue
-               
-       def get_doc(self): 
+
+       def get_doc(self):
                doc = self._doc.strip('\n').replace('\\\n', '')
-               #merge custom doc with doxygen docs 
+               #merge custom doc with doxygen docs
                return '\n'.join([doc, 
extract_docs.extract(self.get_key())]).strip('\n')
-       
-       def get_imports(self): 
+
+       def get_imports(self):
                """!
                Resolve all import statements.
                Split each import statement at newlines.
@@ -107,9 +123,9 @@
                @return a list of import statements
                """
                return filter(lambda i: i, sum(map(lambda i: 
self.resolve_dependencies(i).split('\n'), self._imports), []))
-       
+
        def get_make(self): return self.resolve_dependencies(self._make)
-       
+
        def get_callbacks(self):
                """!
                Get a list of function callbacks for this block.





reply via email to

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