diff options
Diffstat (limited to 'grc/python')
-rw-r--r-- | grc/python/Block.py | 2 | ||||
-rw-r--r-- | grc/python/Connection.py | 3 | ||||
-rw-r--r-- | grc/python/Constants.py | 2 | ||||
-rw-r--r-- | grc/python/Generator.py | 4 | ||||
-rw-r--r-- | grc/python/Port.py | 15 | ||||
-rw-r--r-- | grc/python/block.dtd | 4 | ||||
-rw-r--r-- | grc/python/flow_graph.tmpl | 13 |
7 files changed, 32 insertions, 11 deletions
diff --git a/grc/python/Block.py b/grc/python/Block.py index 957fee18e..6693f6f86 100644 --- a/grc/python/Block.py +++ b/grc/python/Block.py @@ -70,6 +70,8 @@ class Block(_Block): (self._sources, self.get_parent().get_parent().Source), (self._sinks, self.get_parent().get_parent().Sink), ): + #TODO #FIXME we want to filter out msg ports and run the regular code below this line + if any([port.get_type() == 'msg' for port in ports.values()]): continue #how many ports? num_ports = len(ports) #do nothing for 0 ports diff --git a/grc/python/Connection.py b/grc/python/Connection.py index d8a894bb1..5eba9f24d 100644 --- a/grc/python/Connection.py +++ b/grc/python/Connection.py @@ -21,6 +21,9 @@ from .. base.Connection import Connection as _Connection class Connection(_Connection): + def is_msg(self): + return self.get_source().get_type() == self.get_sink().get_type() == 'msg' + def validate(self): """ Validate the connections. diff --git a/grc/python/Constants.py b/grc/python/Constants.py index 2f629d1bf..439a52420 100644 --- a/grc/python/Constants.py +++ b/grc/python/Constants.py @@ -61,4 +61,4 @@ SHORT_VECTOR_COLOR_SPEC = '#CCCC33' BYTE_VECTOR_COLOR_SPEC = '#CC66CC' ID_COLOR_SPEC = '#DDDDDD' WILDCARD_COLOR_SPEC = '#FFFFFF' -MSG_COLOR_SPEC = '#FF6600' +MSG_COLOR_SPEC = '#777777' diff --git a/grc/python/Generator.py b/grc/python/Generator.py index 33be4a726..ed7995716 100644 --- a/grc/python/Generator.py +++ b/grc/python/Generator.py @@ -98,7 +98,8 @@ Add a Misc->Throttle block to your flow graph to avoid CPU congestion.''') #list of regular blocks (all blocks minus the special ones) blocks = filter(lambda b: b not in (imports + parameters + variables + probes + notebooks), blocks) + probes #list of connections where each endpoint is enabled - connections = self._flow_graph.get_enabled_connections() + connections = filter(lambda c: not c.is_msg(), self._flow_graph.get_enabled_connections()) + messages = filter(lambda c: c.is_msg(), self._flow_graph.get_enabled_connections()) #list of variable names var_ids = [var.get_id() for var in parameters + variables] #prepend self. @@ -124,6 +125,7 @@ Add a Misc->Throttle block to your flow graph to avoid CPU congestion.''') 'parameters': parameters, 'blocks': blocks, 'connections': connections, + 'messages': messages, 'generate_options': self._generate_options, 'var_id2cbs': var_id2cbs, } diff --git a/grc/python/Port.py b/grc/python/Port.py index c01884cc3..14adc0618 100644 --- a/grc/python/Port.py +++ b/grc/python/Port.py @@ -105,10 +105,11 @@ class Source(Port): def __init__(self, block, n): self._n = n #save n - if n['type'] != 'msg': #key is port index + if n['type'] == 'msg': n['key'] = 'msg' + else: n['key'] = str(block._source_count) block._source_count = block._source_count + 1 - Port.__init__(self, block, n) + Port.__init__(self, block, n) def __del__(self): self.get_parent()._source_count = self.get_parent()._source_count - 1 @@ -117,14 +118,14 @@ class Sink(Port): def __init__(self, block, n): self._n = n #save n - if n['type'] != 'msg': #key is port index + if n['type'] == 'msg': n['key'] = 'msg' + else: n['key'] = str(block._sink_count) block._sink_count = block._sink_count + 1 - Port.__init__(self, block, n) + Port.__init__(self, block, n) def __del__(self): self.get_parent()._sink_count = self.get_parent()._sink_count - 1 -#TODO merge source and sink classes into port class -#TODO check that key is only defined if and only if type is message -#TODO check that nports is undefined when type is message +#TODO check that nports and vlen is undefined when type is message +#TODO only allow up to one port of type msg diff --git a/grc/python/block.dtd b/grc/python/block.dtd index 8681d1255..7c6c39811 100644 --- a/grc/python/block.dtd +++ b/grc/python/block.dtd @@ -31,8 +31,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA --> <!ELEMENT param (name, key, value?, type, hide?, option*)> <!ELEMENT option (name, key, opt*)> -<!ELEMENT sink (name, key?, type, vlen?, nports?, optional?)> -<!ELEMENT source (name, key?, type, vlen?, nports?, optional?)> +<!ELEMENT sink (name, type, vlen?, nports?, optional?)> +<!ELEMENT source (name, type, vlen?, nports?, optional?)> <!-- Bottom level elements. Character data only. diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl index b537c43e2..df346dd16 100644 --- a/grc/python/flow_graph.tmpl +++ b/grc/python/flow_graph.tmpl @@ -10,6 +10,7 @@ ##@param parameters the paramater blocks ##@param blocks the signal blocks ##@param connections the connections +##@param messages the msg type connections ##@param generate_options the type of flow graph ##@param var_id2cbs variable id map to callback strings ######################################################## @@ -125,6 +126,18 @@ class $(class_name)(gr.hier_block2): $indent($ctrl.get_make()) #end for ######################################################## +##Create Message Queues +######################################################## +#if $messages + + $DIVIDER + # Message Queues + $DIVIDER +#end if +#for $msg in $messages + $(msg.get_source().get_parent().get_id())_msgq = $(msg.get_sink().get_parent().get_id())_msgq = gr.msg_queue(2) +#end for +######################################################## ##Create Blocks ######################################################## #if $blocks |