diff options
author | Johnathan Corgan | 2009-08-15 18:06:37 -0700 |
---|---|---|
committer | Johnathan Corgan | 2009-08-15 18:06:37 -0700 |
commit | c9ad0211dac1721ec3f834bb14e71ca50e801721 (patch) | |
tree | 87bf55144ba6a6db15ff486165110c595ae842a3 /grc/python/Port.py | |
parent | ea57c1b52b8bed12296ba51441afcfc57a0b9d34 (diff) | |
parent | 4edaf1e7fc05df0628c05785d5ede285a64670b0 (diff) | |
download | gnuradio-c9ad0211dac1721ec3f834bb14e71ca50e801721.tar.gz gnuradio-c9ad0211dac1721ec3f834bb14e71ca50e801721.tar.bz2 gnuradio-c9ad0211dac1721ec3f834bb14e71ca50e801721.zip |
Merged changes from svn repository trunk.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@11601 221aa14e-8319-0410-a670-987f0aec2ac5
Signed-off-by: Johnathan Corgan <jcorgan@corganenterprises.com>
Diffstat (limited to 'grc/python/Port.py')
-rw-r--r-- | grc/python/Port.py | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/grc/python/Port.py b/grc/python/Port.py index 5a2b047f0..daf8f9ca3 100644 --- a/grc/python/Port.py +++ b/grc/python/Port.py @@ -23,27 +23,23 @@ import Constants class Port(_Port): ##possible port types - TYPES = ['complex', 'float', 'int', 'short', 'byte'] + TYPES = ['complex', 'float', 'int', 'short', 'byte', 'msg'] def __init__(self, block, n): """ Make a new port from nested data. @param block the parent element @param n the nested odict - @return a new port """ - vlen = n.find('vlen') or '1' - nports = n.find('nports') or '' - optional = n.find('optional') or '' #build the port _Port.__init__( self, block=block, n=n, ) - self._nports = nports - self._vlen = vlen - self._optional = bool(optional) + self._nports = n.find('nports') or '' + self._vlen = n.find('vlen') or '' + self._optional = bool(n.find('optional')) def validate(self): _Port.validate(self) @@ -51,6 +47,11 @@ class Port(_Port): except AssertionError: self.add_error_message('Port is not connected.') try: assert self.is_source() or len(self.get_enabled_connections()) <= 1 except AssertionError: self.add_error_message('Port has too many connections.') + if self.get_type() == 'msg': + try: assert not self.get_nports() + except AssertionError: self.add_error_message('A port of type "msg" cannot have "nports" set.') + try: assert self.get_vlen() == 1 + except AssertionError: self.add_error_message('A port of type "msg" must have a "vlen" of 1.') def get_vlen(self): """ @@ -94,6 +95,7 @@ class Port(_Port): 'int': Constants.INT_COLOR_SPEC, 'short': Constants.SHORT_COLOR_SPEC, 'byte': Constants.BYTE_COLOR_SPEC, + 'msg': Constants.MSG_COLOR_SPEC, }[self.get_type()] return {#vlen is non 1 'complex': Constants.COMPLEX_VECTOR_COLOR_SPEC, @@ -104,26 +106,27 @@ class Port(_Port): }[self.get_type()] except: return _Port.get_color(self) + def copy(self, new_key=None): + n = self._n.copy() + if new_key: n['key'] = new_key + return self.__class__(self.get_parent(), n) + class Source(Port): def __init__(self, block, n): self._n = n #save n - #key is port index - n['key'] = str(block._source_count) - block._source_count = block._source_count + 1 + if n['type'] == 'msg': n['key'] = 'msg' + if not n.find('key'): + n['key'] = str(block._source_count) + block._source_count = block._source_count + 1 Port.__init__(self, block, n) - def __del__(self): - self.get_parent()._source_count = self.get_parent()._source_count - 1 - class Sink(Port): def __init__(self, block, n): self._n = n #save n - #key is port index - n['key'] = str(block._sink_count) - block._sink_count = block._sink_count + 1 + if n['type'] == 'msg': n['key'] = 'msg' + if not n.find('key'): + n['key'] = str(block._sink_count) + block._sink_count = block._sink_count + 1 Port.__init__(self, block, n) - - def __del__(self): - self.get_parent()._sink_count = self.get_parent()._sink_count - 1 |