Mercurial > hg > ltpda
view m-toolbox/classes/@ssm/setPortDescriptions.m @ 52:daf4eab1a51e database-connection-manager tip
Fix. Default password should be [] not an empty string
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 07 Dec 2011 17:29:47 +0100 |
parents | f0afece42f48 |
children |
line wrap: on
line source
% SETPORTDESCRIPTIONS Sets descriptions of the specified SSM ports. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % DESCRIPTION: SETPORTDESCRIPTIONS Sets descriptions of the specified SSM ports. % % CALL: obj = obj.setPortDescriptions('block_type', blockIndex, portIndices, {'block_description1', ...}); % obj = obj.setPortDescriptions('block_type', blockIndex, {'old1', ...}, {'block_description1', ...}); % obj = obj.setPortDescriptions('block_type', blockname, portName, newPortDescription); % % blockname may be a double, a string or a cellstr of size 1 % portName may be a double, a string or a cellstr % newPortDescription may be a string or a cellstr % % <a href="matlab:utils.helper.displayMethodInfo('ssm', 'setPortDescriptions')">Parameters Description</a> % % VERSION: $Id: setPortDescriptions.m,v 1.13 2011/04/08 08:56:22 hewitson Exp $ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function varargout = setPortDescriptions(varargin) warning('This function is deprecated and will soon be removed. Please use ssm/setPortPorperties instead') %%% Check if this is a call for parameters if utils.helper.isinfocall(varargin{:}) varargout{1} = getInfo(varargin{3}); return end import utils.const.* utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename); % Collect input variable names in_names = cell(size(varargin)); for ii = 1:nargin,in_names{ii} = inputname(ii);end [sys, ssm_invars, rest] = utils.helper.collect_objects(varargin(:), 'ssm', in_names); [pl, invars2, rest] = utils.helper.collect_objects(rest(:), 'plist'); if ~isempty(rest) pl = combine(pl, plist(rest{:})); end pl = combine(pl, getDefaultPlist()); %%% Internal call: Only one object + don't look for a plist internal = strcmp(varargin{end}, 'internal'); sys = copy(sys, nargout); %% parameters field = pl.find('field'); blockId = pl.find('block'); portIds = pl.find('ports'); newDescriptions = pl.find('descriptions'); if ischar(newDescriptions) newDescriptions = {newDescriptions}; end if ischar(blockId) blockId = {blockId}; end if ischar(portIds) portIds = {portIds}; end %% Some error checking.... if isempty(field) error('### Please specify the field of the block to modify'); end if numel(newDescriptions) ~= numel(portIds) error('### Please specify one new description per port'); end if numel(blockId)~=1 error('### Please specify the name or the index of the block containing the port(s) to modify'); end %% Loop over the input ssm objects for kk = 1:numel(sys) blocks = sys(kk).(field); % get the block if isnumeric(blockId) block = blocks(blockId); else pos = findBlockWithNames(blocks, blockId{1}); block = blocks(pos); end if isempty(block) if isnumeric(blockId) error('### block ''%d'' not found in SSM model ''%s'' %s', blockId, sys(kk).name, field); else error('### block ''%s'' not found in SSM model ''%s'' %s', blockId, sys(kk).name, field); end end %% now setting port descriptions oldNames = block.portNames; oldNames = oldNames{1}; if isa(portIds, 'double') block.ports(portIds).setDescription(newDescriptions) elseif iscellstr(portIds) for i=1:numel(portIds) position = strcmpi(oldNames, portIds{i}); if sum(position)==0 error(['block named ' portIds{i} ' could not be found in system ' sys(kk).name]) end block.ports(position).setDescription(newDescriptions(i)); end end if ~internal % append history step sys(kk).addHistory(getInfo('None'), pl, ssm_invars(kk), sys(kk).hist); end end % End loop over blocks %% Set output if nargout == numel(sys) for ii = 1:numel(sys) varargout{ii} = sys(ii); end else varargout{1} = sys; end end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Local Functions % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % FUNCTION: getInfo % % DESCRIPTION: Get Info Object % % HISTORY: 11-07-07 M Hewitson % Creation. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function ii = getInfo(varargin) if nargin == 1 && strcmpi(varargin{1}, 'None') sets = {}; pl = []; else sets = {'Default'}; pl = getDefaultPlist; end % Build info object ii = minfo(mfilename, 'ssm', 'ltpda', utils.const.categories.helper, '$Id: setPortDescriptions.m,v 1.13 2011/04/08 08:56:22 hewitson Exp $', sets, pl); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % FUNCTION: getDefaultPlist % % DESCRIPTION: Get Default Plist % % HISTORY: 11-07-07 M Hewitson % Creation. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function plo = getDefaultPlist() plo = plist(); % field p = param({'field', 'The field containing the port to be changed.'}, {1, {'inputs', 'outputs', 'states'}, paramValue.SINGLE}); plo.append(p); % block p = param({'block', 'Identifiers (strings or indices) of the block containing the port you want to modify.'}, paramValue.EMPTY_STRING); plo.append(p); % ports p = param({'ports', 'Identifiers (strings or indices) of the ports you want to modify.'}, paramValue.EMPTY_STRING); plo.append(p); % descriptions p = param({'descriptions', 'The new description(s) you want to set to the port(s). Use a cell-array, one entry for each port.'}, ... paramValue.EMPTY_STRING); plo.append(p); end