diff options
author | Sebastian Koslowski <koslowski@kit.edu> | 2014-12-05 10:24:08 +0100 |
---|---|---|
committer | Sebastian Koslowski <koslowski@kit.edu> | 2014-12-05 10:24:08 +0100 |
commit | eb40a41ec28d5f8320d9c0abcb7a2aa2602b9872 (patch) | |
tree | 2a5b96dec2b1ffa3f6f04c7c15ed96df1d24418c /grc | |
parent | 9372ec7daf7856de7c0e1fe782836a5c722c1473 (diff) |
grc: add gr_message domain
Diffstat (limited to 'grc')
-rw-r--r-- | grc/base/Constants.py | 4 | ||||
-rw-r--r-- | grc/base/Port.py | 9 | ||||
-rw-r--r-- | grc/blocks/gr_message_domain.xml | 15 | ||||
-rw-r--r-- | grc/gui/Connection.py | 4 | ||||
-rw-r--r-- | grc/gui/Port.py | 6 | ||||
-rw-r--r-- | grc/python/Connection.py | 4 | ||||
-rw-r--r-- | grc/python/Port.py | 10 |
7 files changed, 43 insertions, 9 deletions
diff --git a/grc/base/Constants.py b/grc/base/Constants.py index 15f72ad09b..efae0ecbb5 100644 --- a/grc/base/Constants.py +++ b/grc/base/Constants.py @@ -34,5 +34,7 @@ DEFAULT_PARAM_TAB = "General" ADVANCED_PARAM_TAB = "Advanced" # Port domains -DEFAULT_DOMAIN ="gr_stream" DOMAIN_DTD = os.path.join(DATA_DIR, 'domain.dtd') +GR_STREAM_DOMAIN = "gr_stream" +GR_MESSAGE_DOMAIN = "gr_message" +DEFAULT_DOMAIN = GR_STREAM_DOMAIN diff --git a/grc/base/Port.py b/grc/base/Port.py index f8a9a6d123..b393ba9600 100644 --- a/grc/base/Port.py +++ b/grc/base/Port.py @@ -18,7 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA """ from Element import Element -from . Constants import DEFAULT_DOMAIN +from . Constants import GR_STREAM_DOMAIN, GR_MESSAGE_DOMAIN class Port(Element): @@ -37,7 +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._domain = n['domain'] self._hide = n.find('hide') or '' self._dir = dir self._type_evaluated = None # updated on rewrite() @@ -61,6 +61,11 @@ class Port(Element): self._type_evaluated = self.get_parent().resolve_dependencies(self._type) hide = self.get_parent().resolve_dependencies(self._hide).strip().lower() self._hide_evaluated = False if hide in ('false', 'off', '0') else bool(hide) + # update domain if was deduced from (dynamic) port type + if self._domain == GR_STREAM_DOMAIN and self._type_evaluated == "message": + self._domain = GR_MESSAGE_DOMAIN + if self._domain == GR_MESSAGE_DOMAIN and self._type_evaluated != "message": + self._domain = GR_STREAM_DOMAIN def __str__(self): if self.is_source(): diff --git a/grc/blocks/gr_message_domain.xml b/grc/blocks/gr_message_domain.xml new file mode 100644 index 0000000000..dbacfcddf3 --- /dev/null +++ b/grc/blocks/gr_message_domain.xml @@ -0,0 +1,15 @@ +<?xml version="1.0"?> +<!-- +################################################### +##GNU Radio default domain 'gr_message' +################################################### + --> + <domain> + <name>GR Message</name> + <key>gr_message</key> + <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> + </connection> +</domain> diff --git a/grc/gui/Connection.py b/grc/gui/Connection.py index 8fea6f096c..e8e925c04c 100644 --- a/grc/gui/Connection.py +++ b/grc/gui/Connection.py @@ -23,6 +23,8 @@ import Colors from Constants import CONNECTOR_ARROW_BASE, CONNECTOR_ARROW_HEIGHT import gtk +from .. base.Constants import GR_MESSAGE_DOMAIN + class Connection(Element): """ A graphical connection for ports. @@ -89,7 +91,7 @@ class Connection(Element): self.clear() #FIXME do i want this here? #source connector source = self.get_source() - if source.get_type() == "message": + if source.get_domain() == GR_MESSAGE_DOMAIN: self.line_attributes[1] = gtk.gdk.LINE_ON_OFF_DASH X, Y = source.get_connector_coordinate() x1, y1 = self.x1 + X, self.y1 + Y diff --git a/grc/gui/Port.py b/grc/gui/Port.py index 995750a7c6..9abda878bf 100644 --- a/grc/gui/Port.py +++ b/grc/gui/Port.py @@ -22,7 +22,7 @@ from Constants import \ PORT_SEPARATION, CONNECTOR_EXTENSION_MINIMAL, \ CONNECTOR_EXTENSION_INCREMENT, \ PORT_LABEL_PADDING, PORT_MIN_WIDTH, PORT_LABEL_HIDDEN_WIDTH, PORT_FONT -from .. base.Constants import DEFAULT_DOMAIN +from .. base.Constants import DEFAULT_DOMAIN, GR_MESSAGE_DOMAIN import Utils import Actions import Colors @@ -54,7 +54,9 @@ class Port(Element): Element.create_shapes(self) if self.get_hide(): return # this port is hidden, no need to create shapes - if self.get_domain() != DEFAULT_DOMAIN: + if self.get_domain() == GR_MESSAGE_DOMAIN: + pass + elif self.get_domain() != DEFAULT_DOMAIN: self.line_attributes[0] = 2 #get current rotation rotation = self.get_rotation() diff --git a/grc/python/Connection.py b/grc/python/Connection.py index dff98c66a4..86ec08cb53 100644 --- a/grc/python/Connection.py +++ b/grc/python/Connection.py @@ -18,7 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA """ import Constants -from .. base.Element import Element +from .. base.Constants import GR_MESSAGE_DOMAIN from .. base.Connection import Connection as _Connection from .. gui.Connection import Connection as _GUIConnection @@ -32,7 +32,7 @@ class Connection(_Connection, _GUIConnection): return self.get_source().get_type() == self.get_sink().get_type() == 'msg' def is_message(self): - return self.get_source().get_type() == self.get_sink().get_type() == 'message' + 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/Port.py b/grc/python/Port.py index cfeabf8560..fdeb14a4a6 100644 --- a/grc/python/Port.py +++ b/grc/python/Port.py @@ -18,9 +18,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA """ from .. base.Port import Port as _Port +from .. base.Constants import DEFAULT_DOMAIN, GR_MESSAGE_DOMAIN from .. gui.Port import Port as _GUIPort import Constants + def _get_source_from_virtual_sink_port(vsp): """ Resolve the source port that is connected to the given virtual sink port. @@ -91,8 +93,14 @@ class Port(_Port, _GUIPort): dir: the direction """ self._n = n + if n['type'] == 'message': + n['domain'] = GR_MESSAGE_DOMAIN + if 'domain' not in n: + n['domain'] = DEFAULT_DOMAIN + elif n['domain'] == GR_MESSAGE_DOMAIN: + n['key'] = n['name'] + n['type'] = 'message' # for port color if n['type'] == 'msg': n['key'] = 'msg' - if n['type'] == 'message': n['key'] = n['name'] if dir == 'source' and not n.find('key'): n['key'] = str(block._source_count) block._source_count += 1 |