[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 02/22: grc: add domain attribute to ports
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 02/22: grc: add domain attribute to ports |
Date: |
Tue, 23 Dec 2014 09:38:56 +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 30ff5da2bf36ebb98852f6be9c098447022818cd
Author: Sebastian Koslowski <address@hidden>
Date: Tue Dec 2 22:20:46 2014 +0100
grc: add domain attribute to ports
---
grc/base/Connection.py | 13 +++++++++----
grc/base/Port.py | 8 +++++++-
grc/blocks/gr_stream_domain.xml | 15 +++++++++++++++
grc/python/Connection.py | 2 +-
grc/python/block.dtd | 5 +++--
5 files changed, 35 insertions(+), 8 deletions(-)
diff --git a/grc/base/Connection.py b/grc/base/Connection.py
index b35ca91..dd74f2d 100644
--- a/grc/base/Connection.py
+++ b/grc/base/Connection.py
@@ -81,10 +81,15 @@ class Connection(Element):
The ports must match in type.
"""
Element.validate(self)
- source_type = self.get_source().get_type()
- sink_type = self.get_sink().get_type()
- if source_type != sink_type:
- self.add_error_message('Source type "%s" does not match sink type
"%s".'%(source_type, sink_type))
+ platform = self.get_parent().get_parent()
+ source_domain = self.get_source().get_domain()
+ sink_domain = self.get_sink().get_domain()
+ if (source_domain, sink_domain) not in
platform.get_connection_templates():
+ self.add_error_message('No connection known for domains "%s",
"%s"' % (source_domain, sink_domain))
+ multiple_sinks =
platform.get_domain(key=self.get_source().get_domain())['multiple_sinks']
+ if not multiple_sinks and len(self.get_source().get_connections()) > 1:
+ self.add_error_message('Source domain "%s" can have only one
downstream block' % source_domain)
+
def get_enabled(self):
"""
diff --git a/grc/base/Port.py b/grc/base/Port.py
index be32d15..f8a9a6d 100644
--- a/grc/base/Port.py
+++ b/grc/base/Port.py
@@ -18,6 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA
"""
from Element import Element
+from . Constants import DEFAULT_DOMAIN
class Port(Element):
@@ -36,6 +37,7 @@ class Port(Element):
self._name = n['name']
self._key = n['key']
self._type = n['type']
+ self._domain = n.find('domain') or DEFAULT_DOMAIN
self._hide = n.find('hide') or ''
self._dir = dir
self._type_evaluated = None # updated on rewrite()
@@ -48,7 +50,10 @@ class Port(Element):
"""
Element.validate(self)
if self.get_type() not in self.get_types():
- self.add_error_message('Type "%s" is not a possible
type.'%self.get_type())
+ self.add_error_message('Type "%s" is not a possible type.' %
self.get_type())
+ platform = self.get_parent().get_parent().get_parent()
+ if self.get_domain() not in platform.get_domains():
+ self.add_error_message('Domain key "%s" is not registered.' %
self.get_domain())
def rewrite(self):
"""resolve dependencies in for type and hide"""
@@ -85,6 +90,7 @@ class Port(Element):
def get_type(self):
return self.get_parent().resolve_dependencies(self._type) \
if self._type_evaluated is None else self._type_evaluated
+ def get_domain(self): return self._domain
def get_hide(self): return self._hide_evaluated
def get_connections(self):
diff --git a/grc/blocks/gr_stream_domain.xml b/grc/blocks/gr_stream_domain.xml
new file mode 100644
index 0000000..c7b2bc2
--- /dev/null
+++ b/grc/blocks/gr_stream_domain.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##GNU Radio default domain 'gr_stream'
+###################################################
+ -->
+ <domain>
+ <name>GR Stream</name>
+ <key>gr_stream</key>
+ <connection>
+ <source_domain>gr_stream</source_domain>
+ <sink_domain>gr_stream</sink_domain>
+ <make></make>
+ </connection>
+</domain>
diff --git a/grc/python/Connection.py b/grc/python/Connection.py
index 7f235b1..dff98c6 100644
--- a/grc/python/Connection.py
+++ b/grc/python/Connection.py
@@ -42,8 +42,8 @@ class Connection(_Connection, _GUIConnection):
Validate the connections.
The ports must match in io size.
"""
- Element.validate(self)
source_size = Constants.TYPE_TO_SIZEOF[self.get_source().get_type()] *
self.get_source().get_vlen()
sink_size = Constants.TYPE_TO_SIZEOF[self.get_sink().get_type()] *
self.get_sink().get_vlen()
if source_size != sink_size:
self.add_error_message('Source IO size "%s" does not match sink IO
size "%s".'%(source_size, sink_size))
+ _Connection.validate(self)
diff --git a/grc/python/block.dtd b/grc/python/block.dtd
index 576b428..8cfd3dd 100644
--- a/grc/python/block.dtd
+++ b/grc/python/block.dtd
@@ -32,8 +32,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA
<!ELEMENT param_tab_order (tab+)>
<!ELEMENT param (base_key?, name, key, value?, type?, hide?, option*, tab?)>
<!ELEMENT option (name, key, opt*)>
-<!ELEMENT sink (name, type, vlen?, nports?, optional?, hide?)>
-<!ELEMENT source (name, type, vlen?, nports?, optional?, hide?)>
+<!ELEMENT sink (name, type, vlen?, domain?, nports?, optional?, hide?)>
+<!ELEMENT source (name, type, vlen?, domain?, nports?, optional?, hide?)>
<!--
Bottom level elements.
Character data only.
@@ -53,6 +53,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA
<!ELEMENT type (#PCDATA)>
<!ELEMENT hide (#PCDATA)>
<!ELEMENT vlen (#PCDATA)>
+<!ELEMENT domain (#PCDATA)>
<!ELEMENT nports (#PCDATA)>
<!ELEMENT bus_structure_sink (#PCDATA)>
<!ELEMENT bus_structure_source (#PCDATA)>
- [Commit-gnuradio] [gnuradio] 06/22: grc: domain-specific port keys, (continued)
- [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, 2014/12/23
- [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 <=
- [Commit-gnuradio] [gnuradio] 01/22: grc: add domain xml DTD and parsing, git, 2014/12/23