comparison m-toolbox/classes/@timespan/setEndT.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 % SETENDT sets the 'endT' property of the timespan objects.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: SETENDT sets the 'endT' property of the timespan objects.
5 %
6 % CALL: objs.setEndT(val);
7 % objs.setEndT(val1, val2);
8 % objs.setEndT(plist('endt', val));
9 % objs = objs.setEndT(val);
10 %
11 % INPUTS: objs: Can be a vector, matrix, list, or a mix of them.
12 % val: String or numeric values
13 % 1. Single string e.g. '14:00:00'
14 % Each timespan object in objs get this value.
15 % 2. Single string in a cell-array e.g. {12345}
16 % Each timespan object in objs get this value.
17 % 3. cell-array with the same number of strings as in objs
18 % e.g. {'14:00:00', 123, '15:00:00'} and 3 timespan objects in objs
19 % Each timespan objects in objs get its corresponding
20 % value from the cell-array
21 %
22 % <a href="matlab:utils.helper.displayMethodInfo('timespan', 'setEndT')">Parameters Description</a>
23 %
24 % VERSION: $Id: setEndT.m,v 1.14 2011/09/16 11:40:35 hewitson Exp $
25 %
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27
28 function varargout = setEndT(varargin)
29
30 % Check if this is a call from a class method
31 callerIsMethod = utils.helper.callerIsMethod;
32
33 if callerIsMethod
34 as = 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 timespan objects
52 [as, ts_invars, rest] = utils.helper.collect_objects(varargin(:), 'timespan', in_names);
53 [pls, invars, rest] = utils.helper.collect_objects(rest(:), 'plist');
54
55 % Define property name
56 pName = 'endT';
57
58 % Get values for the timespan objects
59 [as, values] = processSetterValues(as, 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 bs = copy(as, nargout);
68
69 % Loop over timespan objects
70 for j=1:numel(bs)
71
72 %%% If the time is a string then convert the string into a time-object.
73 tt = values{1};
74 if ischar(tt)
75 tt = time(tt);
76 elseif isnumeric(tt)
77 tt = time(tt);
78 end
79
80 bs(j).endT = tt;
81 if ~callerIsMethod
82 plh = pls.pset(pName, values{j});
83 bs(j).addHistory(getInfo('None'), plh, ts_invars(j), bs(j).hist);
84 end
85 end
86
87 % Set output
88 if nargout == numel(bs)
89 % List of outputs
90 for ii = 1:numel(bs)
91 varargout{ii} = bs(ii);
92 end
93 else
94 % Single output
95 varargout{1} = bs;
96 end
97 end
98
99 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
100 % Local Functions %
101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
102 %--------------------------------------------------------------------------
103 % Get Info Object
104 %--------------------------------------------------------------------------
105 function ii = getInfo(varargin)
106
107 if nargin == 1 && strcmpi(varargin{1}, 'None')
108 sets = {};
109 pl = [];
110 else
111 sets = {'Default'};
112 pl = getDefaultPlist;
113 end
114 % Build info object
115 ii = minfo(mfilename, mfilename('class'), 'ltpda', utils.const.categories.helper, '$Id: setEndT.m,v 1.14 2011/09/16 11:40:35 hewitson Exp $', sets, pl);
116 end
117
118 %--------------------------------------------------------------------------
119 % Get Default Plist
120 %--------------------------------------------------------------------------
121 function plout = getDefaultPlist()
122 persistent pl;
123 if exist('pl', 'var')==0 || isempty(pl)
124 pl = buildplist();
125 end
126 plout = pl;
127 end
128
129 function pl = buildplist()
130 pl = plist({'endT', 'End time of the time span.'}, paramValue.EMPTY_STRING);
131 end