Mercurial > hg > ltpda
comparison m-toolbox/classes/@ao/setReferenceTime.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 % SETREFERENCETIME sets the t0 to the new value but doesn't move the data in time | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: SETREFERENCETIME sets the t0 to the new value but doesn't | |
5 % move the data in time. | |
6 % | |
7 % CALL: objs.setReferenceTime(val); | |
8 % objs.setReferenceTime(val1, val2); | |
9 % objs.setReferenceTime(plist('t0', val)); | |
10 % objs = objs.setReferenceTime(val); | |
11 % | |
12 % INPUTS: objs: Can be a vector, matrix, list, or a mix of them. | |
13 % val: A time-string or number | |
14 % 1. Single value e.g. '14:00:00' | |
15 % Each AO in objs get this value. | |
16 % 2. Single value in a cell-array e.g. {4} | |
17 % Each AO in objs get this value. | |
18 % 3. cell-array with the same number of values as in objs | |
19 % e.g. {'14:00:00, 5, '15:00:00'} and 3 AOs in objs | |
20 % Each AO in objs get its corresponding value from the | |
21 % cell-array | |
22 % | |
23 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'setReferenceTime')">Parameters Description</a> | |
24 % | |
25 % VERSION: $Id: setReferenceTime.m,v 1.3 2011/09/16 05:04:03 hewitson Exp $ | |
26 % | |
27 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
28 | |
29 function varargout = setReferenceTime(varargin) | |
30 | |
31 % Check if this is a call from a class method | |
32 callerIsMethod = utils.helper.callerIsMethod; | |
33 | |
34 if callerIsMethod | |
35 as = varargin{1}; | |
36 t0 = varargin{2}; | |
37 | |
38 if ~iscell(t0) | |
39 t0 = {t0}; | |
40 end | |
41 | |
42 % Replicate the values | |
43 values = cell(size(as)); | |
44 values(:) = t0; | |
45 | |
46 else | |
47 % Check if this is a call for parameters | |
48 if utils.helper.isinfocall(varargin{:}) | |
49 varargout{1} = getInfo(varargin{3}); | |
50 return | |
51 end | |
52 | |
53 import utils.const.* | |
54 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename); | |
55 | |
56 % Collect input variable names | |
57 in_names = cell(size(varargin)); | |
58 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
59 | |
60 % Collect all AOs and PLISTs | |
61 [as, ao_invars, rest] = utils.helper.collect_objects(varargin(:), 'ao', in_names); | |
62 [pls, invars, rest] = utils.helper.collect_objects(rest(:), 'plist'); | |
63 | |
64 % Define property name | |
65 pName = 't0'; | |
66 | |
67 % Get values for the AOs | |
68 [as, values] = processSetterValues(as, pls, rest, pName); | |
69 | |
70 % If no values are specified and there are more than one AOs then take | |
71 % the last AO to be the container (y-values). | |
72 if isempty(values) && numel(as) >= 2 | |
73 values = {as(end).y}; | |
74 as(end) = []; | |
75 end | |
76 | |
77 % Combine input plists and default PLIST | |
78 pls = applyDefaults(getDefaultPlist(), pls); | |
79 | |
80 end % callerIsMethod | |
81 | |
82 % Decide on a deep copy or a modify | |
83 bs = copy(as, nargout); | |
84 | |
85 % Loop over AOs | |
86 for jj = 1:numel(bs) | |
87 bs(jj).data.setToffset(bs(jj).data.toffset - double(time(values{jj}) - bs(jj).data.t0)*1e3); | |
88 bs(jj).data.setT0(values{jj}); | |
89 if ~callerIsMethod | |
90 plh = pls.pset(pName, values{jj}); | |
91 bs(jj).addHistory(getInfo('None'), plh, ao_invars(jj), bs(jj).hist); | |
92 end | |
93 end | |
94 | |
95 % Set output | |
96 varargout = utils.helper.setoutputs(nargout, bs); | |
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, 'ao', 'ltpda', utils.const.categories.helper, '$Id: setReferenceTime.m,v 1.3 2011/09/16 05:04:03 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') || isempty(pl) | |
124 pl = buildplist(); | |
125 end | |
126 plout = pl; | |
127 end | |
128 | |
129 function pl = buildplist() | |
130 pl = plist({'t0', ['The time to set.<br>' ... | |
131 'You can enter the t0 as a string or as a number. If you want to enter a number please enter this number and convert the type with a right click on the number to a double.']}, ... | |
132 {1, {'14:00:00 10-10-2009'}, paramValue.OPTIONAL}); | |
133 end |