diff options
author | Tom Rondeau | 2011-10-17 13:37:04 -0400 |
---|---|---|
committer | Tom Rondeau | 2011-10-17 13:37:04 -0400 |
commit | fef3fe57c75ce6011c87bc894472639d385fcb21 (patch) | |
tree | 8a11749b2a06a8fa5d42af9911cf556d1c41c608 /grc | |
parent | 07324710bdf7eba63417e5591ff37c7641a3f7ab (diff) | |
parent | a4dbd973fc6376bacf3c45e63aba61a471c468b3 (diff) | |
download | gnuradio-fef3fe57c75ce6011c87bc894472639d385fcb21.tar.gz gnuradio-fef3fe57c75ce6011c87bc894472639d385fcb21.tar.bz2 gnuradio-fef3fe57c75ce6011c87bc894472639d385fcb21.zip |
Merge branch 'next' into dig_ofdm
Diffstat (limited to 'grc')
-rw-r--r-- | grc/blocks/gr_complex_to_float.xml | 4 | ||||
-rw-r--r-- | grc/blocks/gr_float_to_complex.xml | 4 | ||||
-rw-r--r-- | grc/python/Block.py | 14 | ||||
-rw-r--r-- | grc/python/Connection.py | 15 | ||||
-rw-r--r-- | grc/python/Constants.py | 32 | ||||
-rw-r--r-- | grc/python/Platform.py | 15 | ||||
-rw-r--r-- | grc/python/Port.py | 28 |
7 files changed, 66 insertions, 46 deletions
diff --git a/grc/blocks/gr_complex_to_float.xml b/grc/blocks/gr_complex_to_float.xml index 5b02c3d34..05681b0b9 100644 --- a/grc/blocks/gr_complex_to_float.xml +++ b/grc/blocks/gr_complex_to_float.xml @@ -23,12 +23,12 @@ <vlen>$vlen</vlen> </sink> <source> - <name>out</name> + <name>re</name> <type>float</type> <vlen>$vlen</vlen> </source> <source> - <name>out</name> + <name>im</name> <type>float</type> <vlen>$vlen</vlen> <optional>1</optional> diff --git a/grc/blocks/gr_float_to_complex.xml b/grc/blocks/gr_float_to_complex.xml index a1644efd7..a42cff358 100644 --- a/grc/blocks/gr_float_to_complex.xml +++ b/grc/blocks/gr_float_to_complex.xml @@ -18,12 +18,12 @@ </param> <check>$vlen > 0</check> <sink> - <name>in</name> + <name>re</name> <type>float</type> <vlen>$vlen</vlen> </sink> <sink> - <name>in</name> + <name>im</name> <type>float</type> <vlen>$vlen</vlen> <optional>1</optional> diff --git a/grc/python/Block.py b/grc/python/Block.py index 424706d68..4baf36dc6 100644 --- a/grc/python/Block.py +++ b/grc/python/Block.py @@ -75,22 +75,28 @@ class Block(_Block, _GUIBlock): """ _Block.rewrite(self) + def rectify(ports): + #restore integer contiguity after insertion + #rectify the port names with the index + for i, port in enumerate(ports): + port._key = str(i) + port._name = port._n['name'] + if len(ports) > 1: port._name += str(i) + def insert_port(get_ports, get_port, key): prev_port = get_port(str(int(key)-1)) get_ports().insert( get_ports().index(prev_port)+1, prev_port.copy(new_key=key), ) - #restore integer contiguity after insertion - for i, port in enumerate(get_ports()): port._key = str(i) + rectify(get_ports()) def remove_port(get_ports, get_port, key): port = get_port(key) for connection in port.get_connections(): self.get_parent().remove_element(connection) get_ports().remove(port) - #restore integer contiguity after insertion - for i, port in enumerate(get_ports()): port._key = str(i) + rectify(get_ports()) #adjust nports for get_ports, get_port in ( diff --git a/grc/python/Connection.py b/grc/python/Connection.py index 39f915740..218baf074 100644 --- a/grc/python/Connection.py +++ b/grc/python/Connection.py @@ -17,6 +17,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA """ +import Constants +from .. base.Element import Element from .. base.Connection import Connection as _Connection from .. gui.Connection import Connection as _GUIConnection @@ -32,11 +34,10 @@ class Connection(_Connection, _GUIConnection): def validate(self): """ Validate the connections. - The ports must match in type and vector length. + The ports must match in io size. """ - _Connection.validate(self) #checks type - #check vector length - source_vlen = self.get_source().get_vlen() - sink_vlen = self.get_sink().get_vlen() - if source_vlen != sink_vlen: - self.add_error_message('Source vector length "%s" does not match sink vector length "%s".'%(source_vlen, sink_vlen)) + 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)) diff --git a/grc/python/Constants.py b/grc/python/Constants.py index 868c822aa..4a234f080 100644 --- a/grc/python/Constants.py +++ b/grc/python/Constants.py @@ -45,6 +45,38 @@ FLOW_GRAPH_TEMPLATE = os.path.join(DATA_DIR, 'flow_graph.tmpl') BLOCK_DTD = os.path.join(DATA_DIR, 'block.dtd') DEFAULT_FLOW_GRAPH = os.path.join(DATA_DIR, 'default_flow_graph.grc') +CORE_TYPES = ( #name, key, sizeof, color + ('Complex Float 64', 'fc64', 16, '#72f313'), + ('Complex Float 32', 'fc32', 8, '#3399FF'), + ('Complex Integer 32', 'sc32', 8, '#00b789'), + ('Complex Integer 16', 'sc16', 4, '#f37913'), + ('Complex Integer 8', 'sc8', 2, '#ff0e7f'), + ('Float 64', 'f64', 8, '#86a8fa'), + ('Float 32', 'f32', 4, '#FF8C69'), + ('Integer 32', 's32', 4, '#00FF99'), + ('Integer 16', 's16', 2, '#FFFF66'), + ('Integer 8', 's8', 1, '#FF66FF'), + ('Message Queue', 'msg', 0, '#777777'), + ('Wildcard', '', 0, '#FFFFFF'), +) + +ALIAS_TYPES = { + 'complex' : (8, '#3399FF'), + 'float' : (4, '#FF8C69'), + 'int' : (4, '#00FF99'), + 'short' : (2, '#FFFF66'), + 'byte' : (1, '#FF66FF'), +} + +TYPE_TO_COLOR = dict() +TYPE_TO_SIZEOF = dict() +for name, key, sizeof, color in CORE_TYPES: + TYPE_TO_COLOR[key] = color + TYPE_TO_SIZEOF[key] = sizeof +for key, (sizeof, color) in ALIAS_TYPES.iteritems(): + TYPE_TO_COLOR[key] = color + TYPE_TO_SIZEOF[key] = sizeof + #coloring COMPLEX_COLOR_SPEC = '#3399FF' FLOAT_COLOR_SPEC = '#FF8C69' diff --git a/grc/python/Platform.py b/grc/python/Platform.py index a9c2b18ad..e036361ff 100644 --- a/grc/python/Platform.py +++ b/grc/python/Platform.py @@ -32,20 +32,7 @@ from Constants import \ DEFAULT_FLOW_GRAPH, BLOCKS_DIRS import Constants -COLORS = (#title, #color spec - ('Complex', Constants.COMPLEX_COLOR_SPEC), - ('Float', Constants.FLOAT_COLOR_SPEC), - ('Integer', Constants.INT_COLOR_SPEC), - ('Short', Constants.SHORT_COLOR_SPEC), - ('Byte', Constants.BYTE_COLOR_SPEC), - ('Complex Vector', Constants.COMPLEX_VECTOR_COLOR_SPEC), - ('Float Vector', Constants.FLOAT_VECTOR_COLOR_SPEC), - ('Integer Vector', Constants.INT_VECTOR_COLOR_SPEC), - ('Short Vector', Constants.SHORT_VECTOR_COLOR_SPEC), - ('Byte Vector', Constants.BYTE_VECTOR_COLOR_SPEC), - ('Wildcard', Constants.WILDCARD_COLOR_SPEC), - ('Message', Constants.MSG_COLOR_SPEC), -) +COLORS = [(name, color) for name, key, sizeof, color in Constants.CORE_TYPES] class Platform(_Platform, _GUIPlatform): diff --git a/grc/python/Port.py b/grc/python/Port.py index 3846b0f4e..9baa81110 100644 --- a/grc/python/Port.py +++ b/grc/python/Port.py @@ -79,7 +79,7 @@ class Port(_Port, _GUIPort): self._vlen = n.find('vlen') or '' self._optional = bool(n.find('optional')) - def get_types(self): return ('complex', 'float', 'int', 'short', 'byte', 'msg', '') + def get_types(self): return Constants.TYPE_TO_SIZEOF.keys() def validate(self): _Port.validate(self) @@ -146,22 +146,16 @@ class Port(_Port, _GUIPort): @return a hex color code. """ try: - if self.get_vlen() == 1: - return {#vlen is 1 - 'complex': Constants.COMPLEX_COLOR_SPEC, - 'float': Constants.FLOAT_COLOR_SPEC, - '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, - 'float': Constants.FLOAT_VECTOR_COLOR_SPEC, - 'int': Constants.INT_VECTOR_COLOR_SPEC, - 'short': Constants.SHORT_VECTOR_COLOR_SPEC, - 'byte': Constants.BYTE_VECTOR_COLOR_SPEC, - }[self.get_type()] + color = Constants.TYPE_TO_COLOR[self.get_type()] + if self.get_vlen() == 1: return color + color_val = int(color[1:], 16) + r = (color_val >> 16) & 0xff + g = (color_val >> 8) & 0xff + b = (color_val >> 0) & 0xff + r = max(r-50, 0) + g = max(g-50, 0) + b = max(b-50, 0) + return '#%.2x%.2x%.2x'%(r, g, b) except: return _Port.get_color(self) def copy(self, new_key=None): |