Changeset 8960
- Timestamp:
- 07/21/08 00:20:24
- Files:
-
- grc/trunk/notes/todo.txt (modified) (1 diff)
- grc/trunk/src/grc/elements/Block.py (modified) (3 diffs)
- grc/trunk/src/grc/gui/BlockTreeWindow.py (modified) (6 diffs)
- grc/trunk/src/grc_gnuradio/Block.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
grc/trunk/notes/todo.txt
r8956 r8960 14 14 -log slider gui control 15 15 -variable resolution graph structure 16 -move checks from grc Block to grc_gnuradio specific17 16 18 17 ############ Problems: #################### 19 18 -catch error on open non-existant files 20 -block tree window maps block by name21 19 -variables dependent on variables that change 22 20 grc/trunk/src/grc/elements/Block.py
r8956 r8960 66 66 category = Utils.exists_or_else(n, 'category', '') 67 67 params = Utils.listify(n, 'param') 68 checks = Utils.listify(n, 'check')69 68 sources = Utils.listify(n, 'source') 70 69 sinks = Utils.listify(n, 'sink') … … 102 101 #store the param 103 102 self._params[key] = param 104 #store the checks105 self._checks = checks106 103 #create the source objects 107 104 self._sources = odict() … … 158 155 for msg in c.get_error_messages(): 159 156 self._add_error_message('%s: %s'%(c, msg)) 160 for check in self._checks:161 check_res = self.resolve_dependencies(check)162 try:163 check_eval = self.get_parent().evaluate(check_res)164 try: assert(check_eval)165 except AssertionError: self._add_error_message('Check "%s" failed.'%check)166 except: self._add_error_message('Check "%s" did not evaluate.'%check)167 157 168 158 def __str__(self): return 'Block - %s - %s(%s)'%(self.get_id(), self.get_name(), self.get_key()) grc/trunk/src/grc/gui/BlockTreeWindow.py
r8956 r8960 33 33 def __init__(self, platform, get_flow_graph): 34 34 """! 35 SignalBlockSelectionWindow constructor.36 Show all possible signal blocks in this dialog.37 Each signal block is represented by a gtk label of its tag and an add button.38 The add button tells the flow graph to create the selected block. and add it to the flow graph.35 BlockTreeWindow constructor. 36 Create a tree view of the possible blocks in the platform. 37 The tree view nodes will be category names, the leaves will be block names. 38 A mouse double click or button press action will trigger the add block event. 39 39 @param platform the particular platform will all block prototypes 40 40 @param get_flow_graph get the selected flow graph … … 45 45 self.get_flow_graph = get_flow_graph 46 46 #make the tree model for holding blocks 47 self.treestore = gtk.TreeStore(gobject.TYPE_STRING )47 self.treestore = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING) 48 48 self.treeview = gtk.TreeView(self.treestore) 49 49 self.treeview.set_enable_search(False) #disable pop up search box … … 66 66 self.add_button.connect('clicked', self._handle_add_button) 67 67 self.pack_start(self.add_button, False) 68 #map names to keys69 self.names = dict()70 68 #map categories to iters 71 69 self.categories = dict() … … 74 72 #initialize 75 73 self._handle_selection_change() 76 74 77 75 def add_block(self, block, category): 78 76 """! … … 82 80 @param category the category string 83 81 """ 84 if block.get_name() in self.names.keys():85 print '%s has more than one block with name "%s".'%(self.platform, block.get_name())86 print 'Although block names do not have to be unique, this gui requires that that are.'87 print 'Please rename the block to avoid problems.'88 return89 82 _BlockTree.add_block(self, block, category) 90 83 new_iter = self.treestore.insert_before(self.categories[category], None) 91 84 self.treestore.set_value(new_iter, 0, block.get_name()) 92 self. names[block.get_name()] = block.get_key()93 85 self.treestore.set_value(new_iter, 1, block.get_key()) 86 94 87 def add_category(self, category): 95 88 """! … … 129 122 treestore, iter = selection.get_selected() 130 123 if iter and not treestore.iter_has_child(iter): 131 name = treestore.get_value(iter, 0) 132 key = self.names[name] 124 key = treestore.get_value(iter, 1) 133 125 self.get_flow_graph().add_new_block(key) 134 126 grc/trunk/src/grc_gnuradio/Block.py
r8865 r8960 26 26 27 27 class Block(_Block): 28 28 29 29 ##for make source to keep track of indexes 30 30 _source_count = 0 31 31 ##for make sink to keep track of indexes 32 32 _sink_count = 0 33 33 34 34 def __init__(self, flow_graph, n): 35 35 """ … … 41 41 self.self_flag = False 42 42 #grab the data 43 doc = Utils.exists_or_else(n, 'doc', '') 43 doc = Utils.exists_or_else(n, 'doc', '') 44 44 imports = map(lambda i: i.strip(), Utils.listify(n, 'import')) 45 45 make = n['make'] 46 callbacks = Utils.listify(n, 'callback') 46 checks = Utils.listify(n, 'check') 47 callbacks = Utils.listify(n, 'callback') 47 48 #build the block 48 49 _Block.__init__( 49 self, 50 flow_graph=flow_graph, 50 self, 51 flow_graph=flow_graph, 51 52 n=n, 52 53 ) … … 54 55 self._imports = imports 55 56 self._make = make 56 self._callbacks = callbacks 57 57 self._callbacks = callbacks 58 self._checks = checks 59 58 60 def validate(self): 61 """! 62 Validate this block. 63 Call the base class validate. 64 Evaluate the checks: each check must evaluate to True. 65 Adjust the nports. 66 """ 59 67 _Block.validate(self) 68 #evaluate the checks 69 for check in self._checks: 70 check_res = self.resolve_dependencies(check) 71 try: 72 check_eval = self.get_parent().evaluate(check_res) 73 try: assert check_eval 74 except AssertionError: self._add_error_message('Check "%s" failed.'%check) 75 except: self._add_error_message('Check "%s" did not evaluate.'%check) 60 76 for ports, Port in ( 61 (self._sources, self.get_parent().get_parent().Source), 77 (self._sources, self.get_parent().get_parent().Source), 62 78 (self._sinks, self.get_parent().get_parent().Sink), 63 79 ): … … 93 109 self.update() 94 110 continue 95 96 def get_doc(self): 111 112 def get_doc(self): 97 113 doc = self._doc.strip('\n').replace('\\\n', '') 98 #merge custom doc with doxygen docs 114 #merge custom doc with doxygen docs 99 115 return '\n'.join([doc, extract_docs.extract(self.get_key())]).strip('\n') 100 101 def get_imports(self): 116 117 def get_imports(self): 102 118 """! 103 119 Resolve all import statements. … … 108 124 """ 109 125 return filter(lambda i: i, sum(map(lambda i: self.resolve_dependencies(i).split('\n'), self._imports), [])) 110 126 111 127 def get_make(self): return self.resolve_dependencies(self._make) 112 128 113 129 def get_callbacks(self): 114 130 """!
