comparison m-toolbox/classes/@ssmblock/containsPort.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % CONTAINSPORT returns true if the inputs block(s) contain the given port.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: CONTAINSPORT returns true if the inputs block(s) contain
5 % contain the given port.
6 %
7 % CALL: results = containsPort(ssmblocks, portname)
8 % results = containsPort(ssmblocks, portobject)
9 % results = containsPort(ssmblocks, plist('port', portname))
10 % results = containsPort(ssmblocks, plist('port', portobject))
11 %
12 % VERSION: $Id: containsPort.m,v 1.5 2011/04/08 08:56:31 hewitson Exp $
13 %
14 %
15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16 function varargout = containsPort(varargin)
17 error('This function is deprecated and will be deleted')
18
19 [blocks, invars, rest] = utils.helper.collect_objects(varargin(:), 'ssmblock');
20 [port, invars, rest] = utils.helper.collect_objects(rest, 'ssmport');
21 [pl, invars, rest] = utils.helper.collect_objects(rest, 'plist');
22
23 results = [];
24
25 % the port name to check for
26 pfind = '';
27
28 % port in plist
29 if isa(pl, 'plist')
30 pfind = pl.find('port');
31 if isa(pfind, 'ssmport')
32 pfind = pfind.name;
33 end
34 end
35
36 % port in input args overides plist
37 if isa(port, 'ssmport')
38 pfind = port.name;
39 end
40
41 % check for a port name in the 'rest' - overides plist and port object
42 for kk=1:numel(rest)
43 if ischar(rest{kk})
44 pfind = rest{kk};
45 end
46 end
47
48 % loop over blocks
49 for kk=1:numel(blocks)
50 results(kk) = false;
51 block = blocks(kk);
52 for ll=1:numel(block.ports)
53 bp = block.ports(ll);
54 % check this port
55 if strcmpi(bp.name, pfind)
56 results(kk) = true;
57 end
58 end
59 end
60
61 varargout{1} = results;
62 end