[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 10/22: grc: add multiple_sources flag to do
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 10/22: grc: add multiple_sources flag to domain.dtd |
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 2008a6e3976a74c31747d99f41d38a8aef72c569
Author: Sebastian Koslowski <address@hidden>
Date: Fri Dec 5 14:17:15 2014 +0100
grc: add multiple_sources flag to domain.dtd
---
grc/base/Connection.py | 24 +++++++++++++++++-------
grc/base/Platform.py | 5 ++++-
grc/base/domain.dtd | 3 ++-
grc/blocks/gr_message_domain.xml | 1 +
grc/python/Port.py | 2 --
5 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/grc/base/Connection.py b/grc/base/Connection.py
index abe8b4f..3a2de5b 100644
--- a/grc/base/Connection.py
+++ b/grc/base/Connection.py
@@ -85,14 +85,24 @@ class Connection(Element):
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))
-
- if (source_domain in platform.get_domains() and
+ self.add_error_message('No connection known for domains "%s", "%s"'
+ % (source_domain, sink_domain))
+ too_many_other_sinks = (
+ source_domain in platform.get_domains() and
not platform.get_domain(key=source_domain)['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)
-
+ len(self.get_source().get_enabled_connections()) > 1
+ )
+ too_many_other_sources = (
+ sink_domain in platform.get_domains() and
+ not platform.get_domain(key=sink_domain)['multiple_sources'] and
+ len(self.get_sink().get_enabled_connections()) > 1
+ )
+ if too_many_other_sinks:
+ self.add_error_message(
+ 'Domain "%s" can have only one downstream block' %
source_domain)
+ if too_many_other_sources:
+ self.add_error_message(
+ 'Domain "%s" can have only one upstream block' % sink_domain)
def get_enabled(self):
"""
diff --git a/grc/base/Platform.py b/grc/base/Platform.py
index 744b546..75b4901 100644
--- a/grc/base/Platform.py
+++ b/grc/base/Platform.py
@@ -143,9 +143,12 @@ class Platform(_Element):
print >> sys.stderr, 'Warning: Domain with key "%s" already
exists.\n\tIgnoring: %s' % (key, xml_file)
return
+ to_bool = lambda s, d: d if s is None else \
+ s.lower() not in ('false', 'off', '0', '')
self._domains[key] = dict(
name=n.find('name') or key,
- multiple_sinks=n.find('multiple_sinks') or True
+ multiple_sinks=to_bool(n.find('multiple_sinks'), True),
+ multiple_sources=to_bool(n.find('multiple_sources'), False),
)
for connection_n in n.findall('connection'):
source_domain = connection_n.find('source_domain') or
DEFAULT_DOMAIN
diff --git a/grc/base/domain.dtd b/grc/base/domain.dtd
index 3c50687..1dc2959 100644
--- a/grc/base/domain.dtd
+++ b/grc/base/domain.dtd
@@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public
License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-->
-<!ELEMENT domain (name, key, multiple_sinks?, connection*)>
+<!ELEMENT domain (name, key, multiple_sinks?, multiple_sources?, connection*)>
<!--
Sub level elements.
-->
@@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA
<!ELEMENT name (#PCDATA)>
<!ELEMENT key (#PCDATA)>
<!ELEMENT multiple_sinks (#PCDATA)>
+<!ELEMENT multiple_sources (#PCDATA)>
<!ELEMENT make (#PCDATA)>
<!ELEMENT source_domain (#PCDATA)>
<!ELEMENT sink_domain (#PCDATA)>
diff --git a/grc/blocks/gr_message_domain.xml b/grc/blocks/gr_message_domain.xml
index 7e2b4cf..443f600 100644
--- a/grc/blocks/gr_message_domain.xml
+++ b/grc/blocks/gr_message_domain.xml
@@ -7,6 +7,7 @@
<domain>
<name>GR Message</name>
<key>gr_message</key>
+ <multiple_sources>True</multiple_sources>
<connection>
<source_domain>gr_message</source_domain>
<sink_domain>gr_message</sink_domain>
diff --git a/grc/python/Port.py b/grc/python/Port.py
index fdeb14a..4cd07a9 100644
--- a/grc/python/Port.py
+++ b/grc/python/Port.py
@@ -128,8 +128,6 @@ class Port(_Port, _GUIPort):
_Port.validate(self)
if not self.get_enabled_connections() and not self.get_optional():
self.add_error_message('Port is not connected.')
- if not self.is_source() and (not self.get_type() == "message") and
len(self.get_enabled_connections()) > 1:
- self.add_error_message('Port has too many connections.')
#message port logic
if self.get_type() == 'msg':
if self.get_nports():
- [Commit-gnuradio] [gnuradio] branch master updated (3427a66 -> 2402ccc), git, 2014/12/23
- [Commit-gnuradio] [gnuradio] 07/22: grc: per element line styles (for custom domain ports and message connections), git, 2014/12/23
- [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 <=
- [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, 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