2 Copyright 2008 Free Software Foundation, Inc.
3 This file is part of GNU Radio
5 GNU Radio Companion is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 GNU Radio Companion is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20 from .. base.Port import Port as _Port
26 TYPES = ['complex', 'float', 'int', 'short', 'byte']
28 def __init__(self, block, n):
30 Make a new port from nested data.
31 @param block the parent element
32 @param n the nested odict
35 vlen = utils.exists_or_else(n, 'vlen', '1')
36 nports = utils.exists_or_else(n, 'nports', '')
37 optional = utils.exists_or_else(n, 'optional', '')
46 self._optional = bool(optional)
50 Get the vector length.
51 If the evaluation of vlen cannot be cast to an integer, return 1.
52 @return the vector length or 1
54 vlen = self.get_parent().resolve_dependencies(self._vlen)
55 try: return int(self.get_parent().get_parent().evaluate(vlen))
60 Get the number of ports.
61 If already blank, return a blank
62 If the evaluation of nports cannot be cast to an integer, return 1.
63 @return the number of ports or 1
65 nports = self.get_parent().resolve_dependencies(self._nports)
66 #return blank if nports is blank
67 if not nports: return ''
69 nports = int(self.get_parent().get_parent().evaluate(nports))
74 def get_optional(self): return bool(self._optional)
78 Get the color that represents this port's type.
79 Codes differ for ports where the vec length is 1 or greater than 1.
80 @return a hex color code.
83 if self.get_vlen() == 1:
91 return {#vlen is non 1
98 except: return _Port.get_color(self)
103 An empty port has no connections.
104 Not empty of optional is set.
105 @return true if empty
107 return not self.get_optional() and not self.get_connections()
111 def __init__(self, block, n):
114 n['key'] = str(block._source_count)
115 block._source_count = block._source_count + 1
116 Port.__init__(self, block, n)
119 self.get_parent()._source_count = self.get_parent()._source_count - 1
123 def __init__(self, block, n):
126 n['key'] = str(block._sink_count)
127 block._sink_count = block._sink_count + 1
128 Port.__init__(self, block, n)
131 self.get_parent()._sink_count = self.get_parent()._sink_count - 1