Mercurial > hg > ltpda
diff m-toolbox/classes/@ssmblock/getPortsWithName.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/classes/@ssmblock/getPortsWithName.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,44 @@ +% GETPORTSWITHNAME get all ports with the matching name. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% DESCRIPTION: GETPORTSWITHNAME get all ports with the matching name. +% +% CALL: ports = getPortsWithName(ssmblocks, name) +% [ports, indices] = getPortsWithName(ssmblocks, plist('name', aName)) +% +% VERSION: $Id: getPortsWithName.m,v 1.6 2011/04/08 08:56:31 hewitson Exp $ +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +function varargout = getPortsWithName(varargin) + error('This function is deprecated and will be deleted') + + [objs, in_vars, rest] = utils.helper.collect_objects(varargin(:), 'ssmblock'); + [pl, in_vars, rest] = utils.helper.collect_objects(rest, 'plist'); + + ports = []; + indices = {}; + + + if isa(pl, 'plist') + name = pl.find('name'); + end + for kk=1:numel(rest) + if ischar(rest{kk}) + name = rest{kk}; + end + end + + for kk=1:numel(objs) + idx = strcmpi(name, {objs(kk).ports.name}); + ports = [ports objs(kk).ports(idx)]; + indices = [indices {find(idx)}]; + end + + if nargout == 1 + varargout{1} = ports; + elseif nargout == 2 + varargout{1} = ports; + varargout{2} = indices; + end + +end