summaryrefslogtreecommitdiff
path: root/grc/python/FlowGraph.py
diff options
context:
space:
mode:
authorSebastian Koslowski <koslowski@kit.edu>2014-06-13 10:42:29 +0200
committerJohnathan Corgan <johnathan@corganlabs.com>2014-06-13 14:33:05 -0700
commite620fa41fcddc467be6ddde777e702a3d4c399a9 (patch)
tree0ad2d8e5adf0fa240d0dbba94cf9f6df4bf04168 /grc/python/FlowGraph.py
parenta8d28ad5338a5044acbbc5c84abb20b7365c9afa (diff)
grc: fix pad port keys in connect()
Diffstat (limited to 'grc/python/FlowGraph.py')
-rw-r--r--grc/python/FlowGraph.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/grc/python/FlowGraph.py b/grc/python/FlowGraph.py
index bf98c7ab38..8573f33fc4 100644
--- a/grc/python/FlowGraph.py
+++ b/grc/python/FlowGraph.py
@@ -107,6 +107,23 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph):
pads = filter(lambda b: b.get_key() == 'pad_sink', self.get_enabled_blocks())
return sorted(pads, lambda x, y: cmp(x.get_id(), y.get_id()))
+ def get_pad_port_global_key(self, port):
+ """
+ Get the key for a port of a pad source/sink to use in connect()
+ This takes into account that pad blocks may have multiple ports
+
+ Returns:
+ the key (str)
+ """
+ key_offset = 0
+ pads = self.get_pad_sources() if port.is_source() else self.get_pad_sinks()
+ for pad in pads:
+ if port.get_parent() == pad:
+ return str(key_offset + int(port.get_key()))
+ # assuming we have either only sources or sinks
+ key_offset += len(pad.get_ports())
+ return -1
+
def get_msg_pad_sources(self):
ps = self.get_pad_sources();
return filter(lambda b: b.get_param('type').get_evaluated() == 'message', ps);