diff options
author | jblum | 2009-05-01 20:28:04 +0000 |
---|---|---|
committer | jblum | 2009-05-01 20:28:04 +0000 |
commit | a3ba8cf268816af51c4bb39ea7ecd7e85ea0807b (patch) | |
tree | 21dbd446e92672a56b323e005088d3c03edc238f /grc/src/platforms/base/FlowGraph.py | |
parent | 6ce881caaacdd60a8bea37584c7286e08bea97a7 (diff) | |
download | gnuradio-a3ba8cf268816af51c4bb39ea7ecd7e85ea0807b.tar.gz gnuradio-a3ba8cf268816af51c4bb39ea7ecd7e85ea0807b.tar.bz2 gnuradio-a3ba8cf268816af51c4bb39ea7ecd7e85ea0807b.zip |
Merged grc developer branch r10679:10938
Misc fixes and internal changes.
Added help menu for usage tips.
Added drag and drop for blocks.
Removed callback controls, adopted forms.
Any type can have enumerated options.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@10941 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'grc/src/platforms/base/FlowGraph.py')
-rw-r--r-- | grc/src/platforms/base/FlowGraph.py | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/grc/src/platforms/base/FlowGraph.py b/grc/src/platforms/base/FlowGraph.py index aeb66ac7e..747038bfb 100644 --- a/grc/src/platforms/base/FlowGraph.py +++ b/grc/src/platforms/base/FlowGraph.py @@ -1,5 +1,5 @@ """ -Copyright 2008 Free Software Foundation, Inc. +Copyright 2008, 2009 Free Software Foundation, Inc. This file is part of GNU Radio GNU Radio Companion is free software; you can redistribute it and/or @@ -17,7 +17,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA """ -from ... import utils from ... utils import odict from Element import Element from Block import Block @@ -37,7 +36,7 @@ class FlowGraph(Element): #initialize Element.__init__(self, platform) #inital blank import - self.import_data({'flow_graph': {}}) + self.import_data() def _get_unique_id(self, base_id=''): """ @@ -179,9 +178,9 @@ class FlowGraph(Element): n['timestamp'] = time.ctime() n['block'] = [block.export_data() for block in self.get_blocks()] n['connection'] = [connection.export_data() for connection in self.get_connections()] - return {'flow_graph': n} + return odict({'flow_graph': n}) - def import_data(self, n): + def import_data(self, n=None): """ Import blocks and connections into this flow graph. Clear this flowgraph of all previous blocks and connections. @@ -190,19 +189,16 @@ class FlowGraph(Element): """ #remove previous elements self._elements = list() - #the flow graph tag must exists, or use blank data - if 'flow_graph' in n.keys(): fg_n = n['flow_graph'] - else: - Messages.send_error_load('Flow graph data not found, loading blank flow graph.') - fg_n = {} - blocks_n = utils.listify(fg_n, 'block') - connections_n = utils.listify(fg_n, 'connection') + #use blank data if none provided + fg_n = n and n.find('flow_graph') or odict() + blocks_n = fg_n.findall('block') + connections_n = fg_n.findall('connection') #create option block self._options_block = self.get_parent().get_new_block(self, 'options') self._options_block.get_param('id').set_value('options') #build the blocks for block_n in blocks_n: - key = block_n['key'] + key = block_n.find('key') if key == 'options': block = self._options_block else: block = self.get_new_block(key) #only load the block when the block key was valid @@ -210,21 +206,14 @@ class FlowGraph(Element): else: Messages.send_error_load('Block key "%s" not found in %s'%(key, self.get_parent())) #build the connections for connection_n in connections_n: - #test that the data tags exist - try: - assert('source_block_id' in connection_n.keys()) - assert('sink_block_id' in connection_n.keys()) - assert('source_key' in connection_n.keys()) - assert('sink_key' in connection_n.keys()) - except AssertionError: continue #try to make the connection try: #get the block ids - source_block_id = connection_n['source_block_id'] - sink_block_id = connection_n['sink_block_id'] + source_block_id = connection_n.find('source_block_id') + sink_block_id = connection_n.find('sink_block_id') #get the port keys - source_key = connection_n['source_key'] - sink_key = connection_n['sink_key'] + source_key = connection_n.find('source_key') + sink_key = connection_n.find('sink_key') #verify the blocks block_ids = map(lambda b: b.get_id(), self.get_blocks()) assert(source_block_id in block_ids) |