comparison m-toolbox/classes/@pzmodel/setDelay.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 % SETDELAY sets the 'delay' property of the pzmodel object.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: SETDELAY sets the 'delay' property of the pzmodel object.
5 %
6 % CALL: objs.setDelay(val);
7 % objs.setDelay(val1, val2);
8 % objs.setDelay(plist('delay', val));
9 % objs = objs.setDelay(val);
10 %
11 % INPUTS: objs: Can be a vector, matrix, list, or a mix of them.
12 % val: numeric value in seconds
13 % 1. Single vector e.g. 9
14 % Each pzmodel object in objs get this value.
15 % 2. Single vector in a cell-array e.g. {7}
16 % Each pzmodel object in objs get this value.
17 % 3. cell-array with the same number of vectors as in objs
18 % e.g. {12, 2, 5} and 3 pzmodel object in objs
19 % Each pzmodel object in objs get its corresponding
20 % value from the cell-array
21 %
22 % <a href="matlab:utils.helper.displayMethodInfo('pzmodel', 'setDelay')">Parameters Description</a>
23 %
24 % VERSION: $Id: setDelay.m,v 1.11 2011/09/16 11:38:33 hewitson Exp $
25 %
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27
28 function varargout = setDelay(varargin)
29
30 % Check if this is a call from a class method
31 callerIsMethod = utils.helper.callerIsMethod;
32
33 if callerIsMethod
34 sm = varargin{1};
35 values = varargin(2:end);
36
37 else
38 % Check if this is a call for parameters
39 if utils.helper.isinfocall(varargin{:})
40 varargout{1} = getInfo(varargin{3});
41 return
42 end
43
44 import utils.const.*
45 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
46
47 % Collect input variable names
48 in_names = cell(size(varargin));
49 for ii = 1:nargin,in_names{ii} = inputname(ii);end
50
51 % Collect all pzmodel objects
52 [sm, sm_invars, rest] = utils.helper.collect_objects(varargin(:), 'pzmodel', in_names);
53 [pls, invars, rest] = utils.helper.collect_objects(rest(:), 'plist');
54
55 % Define property name
56 pName = 'delay';
57
58 % Get values for the pzmodel objects
59 [sm, values] = processSetterValues(sm, pls, rest, pName);
60
61 % Combine input plists and default PLIST
62 pls = combine(pls, getDefaultPlist());
63
64 end % callerIsMethod
65
66 % Decide on a deep copy or a modify
67 sm = copy(sm, nargout);
68
69 % Loop over pzmodel objects
70 for j=1:numel(sm)
71 sm(j).delay = values{j};
72 if ~callerIsMethod
73 plh = pls.pset(pName, values{j});
74 sm(j).addHistory(getInfo('None'), plh, sm_invars(j), sm(j).hist);
75 end
76 end
77
78 % Set output
79 nObjs = numel(sm);
80 if nargout == nObjs;
81 % List of outputs
82 for ii = 1:nObjs
83 varargout{ii} = sm(ii);
84 end
85 else
86 % Single output
87 varargout{1} = sm;
88 end
89 end
90
91 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
92 % Local Functions %
93 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
94 %--------------------------------------------------------------------------
95 % Get Info Object
96 %--------------------------------------------------------------------------
97 function ii = getInfo(varargin)
98
99 if nargin == 1 && strcmpi(varargin{1}, 'None')
100 sets = {};
101 pl = [];
102 else
103 sets = {'Default'};
104 pl = getDefaultPlist;
105 end
106 % Build info object
107 ii = minfo(mfilename, mfilename('class'), 'ltpda', utils.const.categories.helper, '$Id: setDelay.m,v 1.11 2011/09/16 11:38:33 hewitson Exp $', sets, pl);
108 end
109
110 %--------------------------------------------------------------------------
111 % Get Default Plist
112 %--------------------------------------------------------------------------
113 function plout = getDefaultPlist()
114 persistent pl;
115 if exist('pl', 'var')==0 || isempty(pl)
116 pl = buildplist();
117 end
118 plout = pl;
119 end
120
121 function pl = buildplist()
122 pl = plist({'delay', 'The delay to set [s].'}, paramValue.DOUBLE_VALUE(0));
123 end