Merged changeset r9285:9377 from jblum/grc into trunk, with distcheck fixes
[debian/gnuradio] / grc / src / grc_gnuradio / Connection.py
1 """
2 Copyright 2008 Free Software Foundation, Inc.
3 This file is part of GNU Radio
4
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.
9
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.
14
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
18 """
19 ##@package grc_gnuradio.Connection
20 #Flow graph connection.
21 #A connection exists between 2 ports.
22 #One port must be input, one output.
23 #The port decided whether it can have the connection.
24 #@author Josh Blum
25
26 from grc.elements.Connection import Connection as _Connection
27
28 class Connection(_Connection):
29         
30         def validate(self):
31                 """
32                 Validate the connections.
33                 The ports must match in type and vector length.
34                 """
35                 _Connection.validate(self) #checks type
36                 #check vector length
37                 source_vlen = self.get_source().get_vlen()
38                 sink_vlen = self.get_sink().get_vlen()
39                 try: assert(source_vlen == sink_vlen)
40                 except AssertionError: self._add_error_message('Source vector length "%s" does not match sink vector length "%s".'%(source_vlen, sink_vlen))
41                 
42