summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Koslowski <koslowski@kit.edu>2014-12-02 22:20:46 +0100
committerSebastian Koslowski <koslowski@kit.edu>2014-12-02 22:41:53 +0100
commit30ff5da2bf36ebb98852f6be9c098447022818cd (patch)
tree8aa515bf9289ea12138fd59e709795c3464c3e75
parent8d579a42871b157a7e360ba89d0925d81950e021 (diff)
grc: add domain attribute to ports
-rw-r--r--grc/base/Connection.py13
-rw-r--r--grc/base/Port.py8
-rw-r--r--grc/blocks/gr_stream_domain.xml15
-rw-r--r--grc/python/Connection.py2
-rw-r--r--grc/python/block.dtd5
5 files changed, 35 insertions, 8 deletions
diff --git a/grc/base/Connection.py b/grc/base/Connection.py
index b35ca91050..dd74f2d660 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 be32d15a91..f8a9a6d123 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 0000000000..c7b2bc2369
--- /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 7f235b190b..dff98c66a4 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 576b428111..8cfd3dd392 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)>