[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 09/22: grc: make Generator use gr_message d
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 09/22: grc: make Generator use gr_message domain |
Date: |
Tue, 23 Dec 2014 09:38:57 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 2c9079afda99349a8a5914c15d55d3d86a50eaca
Author: Sebastian Koslowski <address@hidden>
Date: Fri Dec 5 11:52:02 2014 +0100
grc: make Generator use gr_message domain
---
grc/blocks/gr_message_domain.xml | 6 +++++-
grc/blocks/gr_stream_domain.xml | 4 +++-
grc/python/Connection.py | 4 ----
grc/python/FlowGraph.py | 17 +++++++++++-----
grc/python/Generator.py | 8 +++-----
grc/python/flow_graph.tmpl | 42 +++++++++++-----------------------------
6 files changed, 34 insertions(+), 47 deletions(-)
diff --git a/grc/blocks/gr_message_domain.xml b/grc/blocks/gr_message_domain.xml
index dbacfcd..7e2b4cf 100644
--- a/grc/blocks/gr_message_domain.xml
+++ b/grc/blocks/gr_message_domain.xml
@@ -10,6 +10,10 @@
<connection>
<source_domain>gr_message</source_domain>
<sink_domain>gr_message</sink_domain>
- <make> self.connect($make_port_sig($source),
$make_port_sig($sink))</make>
+ <make>#slurp
+ #set endpoint_a = $make_port_sig($source)[1:-1]
+ #set endpoint_b = $make_port_sig($sink)[1:-1]
+ self.msg_connect($endpoint_a, $endpoint_b)#slurp
+ </make>
</connection>
</domain>
diff --git a/grc/blocks/gr_stream_domain.xml b/grc/blocks/gr_stream_domain.xml
index 89c15d2..047f4a2 100644
--- a/grc/blocks/gr_stream_domain.xml
+++ b/grc/blocks/gr_stream_domain.xml
@@ -10,6 +10,8 @@
<connection>
<source_domain>gr_stream</source_domain>
<sink_domain>gr_stream</sink_domain>
- <make> self.connect($make_port_sig($source),
$make_port_sig($sink))</make>
+ <make>#slurp
+ self.connect($make_port_sig($source), $make_port_sig($sink))#slurp
+ </make>
</connection>
</domain>
diff --git a/grc/python/Connection.py b/grc/python/Connection.py
index 86ec08c..0a6cf5f 100644
--- a/grc/python/Connection.py
+++ b/grc/python/Connection.py
@@ -18,7 +18,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA
"""
import Constants
-from .. base.Constants import GR_MESSAGE_DOMAIN
from .. base.Connection import Connection as _Connection
from .. gui.Connection import Connection as _GUIConnection
@@ -31,9 +30,6 @@ class Connection(_Connection, _GUIConnection):
def is_msg(self):
return self.get_source().get_type() == self.get_sink().get_type() ==
'msg'
- def is_message(self):
- return self.get_source().get_domain() == self.get_sink().get_domain()
== GR_MESSAGE_DOMAIN
-
def is_bus(self):
return self.get_source().get_type() == self.get_sink().get_type() ==
'bus'
diff --git a/grc/python/FlowGraph.py b/grc/python/FlowGraph.py
index 977200d..03280cc 100644
--- a/grc/python/FlowGraph.py
+++ b/grc/python/FlowGraph.py
@@ -146,12 +146,19 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph):
key_offset = 0
pads = self.get_pad_sources() if port.is_source() else
self.get_pad_sinks()
for pad in pads:
- if pad.get_param('type').get_evaluated() == "message":
- continue
+ # using the block type param instead of the port domain here
+ # to stress that hier block generation is domain agnostic
+ is_message_pad = pad.get_param('type').get_evaluated() == "message"
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())
+ if is_message_pad:
+ key = pad.get_param('label').get_value()
+ else:
+ key = str(key_offset + int(port.get_key()))
+ return key
+ else:
+ # assuming we have either only sources or sinks
+ if not is_message_pad:
+ key_offset += len(pad.get_ports())
return -1
def get_imports(self):
diff --git a/grc/python/Generator.py b/grc/python/Generator.py
index 78e8031..2f9f085 100644
--- a/grc/python/Generator.py
+++ b/grc/python/Generator.py
@@ -164,10 +164,9 @@ class TopBlockGenerator(object):
#list of regular blocks (all blocks minus the special ones)
blocks = filter(lambda b: b not in (imports + parameters), blocks)
#list of connections where each endpoint is enabled
- connections = filter(lambda c: not (c.is_bus() or c.is_msg() or
c.is_message()), self._flow_graph.get_enabled_connections())
+ connections = filter(lambda c: not (c.is_bus() or c.is_msg()),
self._flow_graph.get_enabled_connections())
connection_templates =
self._flow_graph.get_parent().get_connection_templates()
- messages = filter(lambda c: c.is_msg(),
self._flow_graph.get_enabled_connections())
- messages2 = filter(lambda c: c.is_message(),
self._flow_graph.get_enabled_connections())
+ msgs = 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.
@@ -193,8 +192,7 @@ class TopBlockGenerator(object):
'blocks': blocks,
'connections': connections,
'connection_templates': connection_templates,
- 'messages': messages,
- 'messages2': messages2,
+ 'msgs': msgs,
'generate_options': self._generate_options,
'var_id2cbs': var_id2cbs,
}
diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl
index 3769e0a..d66c258 100644
--- a/grc/python/flow_graph.tmpl
+++ b/grc/python/flow_graph.tmpl
@@ -8,7 +8,7 @@
address@hidden parameters the paramater blocks
address@hidden blocks the signal blocks
address@hidden connections the connections
address@hidden messages the msg type connections
address@hidden msgs the msg type connections
address@hidden generate_options the type of flow graph
address@hidden var_id2cbs variable id map to callback strings
########################################################
@@ -145,13 +145,13 @@ gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)),
[$(', '.join($size_strs))])
########################################################
##Create Message Queues
########################################################
-#if $messages
+#if $msgs
$DIVIDER
# Message Queues
$DIVIDER
#end if
-#for $msg in $messages
+#for $msg in $msgs
$(msg.get_source().get_parent().get_id())_msgq_out =
$(msg.get_sink().get_parent().get_id())_msgq_in = gr.msg_queue(2)
#end for
########################################################
@@ -189,10 +189,16 @@ gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)),
[$(', '.join($size_strs))])
########################################################
#def make_port_sig($port)
#if $port.get_parent().get_key() in ('pad_source', 'pad_sink')
-(self, $flow_graph.get_pad_port_global_key($port))#slurp
+ #set block = 'self'
+ #set key = $flow_graph.get_pad_port_global_key($port)
#else
-(self.$port.get_parent().get_id(), $port.get_key())#slurp
+ #set block = 'self.' + $port.get_parent().get_id()
+ #set key = $port.get_key()
#end if
+ #if not $key.isdigit()
+ #set key = repr($key)
+ #end if
+($block, $key)#slurp
#end def
#if $connections
@@ -215,32 +221,6 @@ gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)), [$(',
'.join($size_strs))])
#end for
########################################################
-##Create Message Connections
-########################################################
-#if $messages2
- $DIVIDER
- # Message Connections
- $DIVIDER
-#end if
-#for $msg in $messages2
- #set $sr = $msg.get_source()
- #set $source = "self.%s"%($sr.get_parent().get_id())
- #set $source_port = $sr.get_key();
- #if $sr.get_parent().get_key() == "pad_source"
- #set $source = "self"
- #set $source_port =
$sr.get_parent().get_param("label").get_value();
- #end if
- #set $sk = $msg.get_sink()
- #set $sink = "self.%s"%($sk.get_parent().get_id())
- #set $sink_port = $sk.get_name();
- #if $sk.get_parent().get_key() == "pad_sink"
- #set $sink = "self"
- #set $sink_port = $sk.get_parent().get_param("label").get_value();
- #end if
- self.msg_connect($source, "$source_port", $sink, "$sink_port")
-#end for
-
-########################################################
## QT sink close method reimplementation
########################################################
#if $generate_options == 'qt_gui'
- [Commit-gnuradio] [gnuradio] 08/22: grc: add gr_message domain, (continued)
- [Commit-gnuradio] [gnuradio] 08/22: grc: add gr_message domain, git, 2014/12/23
- [Commit-gnuradio] [gnuradio] 12/22: grc: port connections by domain, block name in generated code, git, 2014/12/23
- [Commit-gnuradio] [gnuradio] 10/22: grc: add multiple_sources flag to domain.dtd, git, 2014/12/23
- [Commit-gnuradio] [gnuradio] 13/22: runtime: whitespace fixes, git, 2014/12/23
- [Commit-gnuradio] [gnuradio] 15/22: runtime: add tests for new decorators in hier_block2, git, 2014/12/23
- [Commit-gnuradio] [gnuradio] 14/22: runtime: refactor top/hier block python wrappers, git, 2014/12/23
- [Commit-gnuradio] [gnuradio] 17/22: grc: fix connections error log and color, git, 2014/12/23
- [Commit-gnuradio] [gnuradio] 11/22: grc: PEP8 fixes in Generator, git, 2014/12/23
- [Commit-gnuradio] [gnuradio] 16/22: grc: add domain property color and use it for connections, git, 2014/12/23
- [Commit-gnuradio] [gnuradio] 06/22: grc: domain-specific port keys, git, 2014/12/23
- [Commit-gnuradio] [gnuradio] 09/22: grc: make Generator use gr_message domain,
git <=
- [Commit-gnuradio] [gnuradio] 03/22: grc: draw ports with custom domain differently, git, 2014/12/23
- [Commit-gnuradio] [gnuradio] 22/22: Merge remote-tracking branch 'gnuradio-wg-grc/master_grcwg', git, 2014/12/23
- [Commit-gnuradio] [gnuradio] 04/22: grc: don't fail for unknown domains, git, 2014/12/23
- [Commit-gnuradio] [gnuradio] 19/22: Merge branch 'port_domains' into master_grcwg, git, 2014/12/23
- [Commit-gnuradio] [gnuradio] 05/22: grc: use domain connection templates in Generator, git, 2014/12/23
- [Commit-gnuradio] [gnuradio] 21/22: Merge remote-tracking branch 'skoslowski/msg_connect_extended', git, 2014/12/23
- [Commit-gnuradio] [gnuradio] 18/22: grc: port domain code clean-up, git, 2014/12/23
- [Commit-gnuradio] [gnuradio] 20/22: Merge branch 'maint', git, 2014/12/23
- [Commit-gnuradio] [gnuradio] 02/22: grc: add domain attribute to ports, git, 2014/12/23
- [Commit-gnuradio] [gnuradio] 01/22: grc: add domain xml DTD and parsing, git, 2014/12/23