Mercurial > hg > ltpda
comparison m-toolbox/m/helper/addHistoryStep.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 % ADDHISTORYSTEP Adds a history step of a non LTPDA method to object with history. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: Adds a history step of a non LTPDA method to object with | |
5 % history. | |
6 % | |
7 % CALL: obj = addHistoryStep(obj, minfo, h_pl, ver, var_name, inhists, ...); | |
8 % | |
9 % INPUT: obj: Object with histry like AOs, SSMs, MFIRs, MIIRs, ... | |
10 % h_pl: Plist which should go into the history. | |
11 % ver: cvs version of the user defined method. Only | |
12 % necessary if no minfo is passed in. | |
13 % minfo: Information object of the function. If not defined | |
14 % this method will take the following: | |
15 % minfo(CALLED_METHOD, 'none', '', 'User defined', ver, {'Default'}, h_pl); | |
16 % var_name: Cell-array with the variable manes of the object(s) | |
17 % inhists: History objects which should be add to the input | |
18 % object. e.g. [a.hist b.hist] | |
19 % | |
20 % REMARK: Don't use this method inside a sub function | |
21 % | |
22 % VERSION: $Id: addHistoryStep.m,v 1.9 2011/03/25 13:32:09 ingo Exp $ | |
23 % | |
24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
25 | |
26 function varargout = addHistoryStep(varargin) | |
27 | |
28 % Get the calling method name from the | |
29 stack = dbstack(); | |
30 | |
31 if numel(stack) < 2 | |
32 error('### Please use this method only inside a method'); | |
33 end | |
34 | |
35 mthdName = stack(2).name; | |
36 | |
37 % Collect objects | |
38 objs = utils.helper.collect_objects(varargin(:), ''); | |
39 pls = utils.helper.collect_objects(varargin(:), 'plist'); | |
40 mi = utils.helper.collect_objects(varargin(:), 'minfo'); | |
41 ver = utils.helper.collect_objects(varargin(:), 'char'); | |
42 invars = utils.helper.collect_objects(varargin(:), 'cell'); | |
43 in_hists = utils.helper.collect_objects(varargin(:), 'history'); | |
44 | |
45 % Check that the input objects are objects with history | |
46 if ~isa(objs, 'ltpda_uoh') | |
47 error('### The input objects must be derived from the ltpda_uoh class like ao, ssm, mfir, ...'); | |
48 end | |
49 | |
50 % If the user doesn't pass in an minfo object then create a default one. | |
51 if isempty(mi) | |
52 if isempty(ver) | |
53 ver = 'No version'; | |
54 end | |
55 if ~isempty(pls) | |
56 pls.combine(); | |
57 end | |
58 mi = minfo(mthdName, 'none', '', utils.const.categories.user, ver, {'Default'}, pls); | |
59 end | |
60 | |
61 % Modify plist object | |
62 if ~isempty(pls) | |
63 % Make sure that we have only one PLIST | |
64 pls.combine(); | |
65 | |
66 % 1. replace ltpda_uoh in pls with their history | |
67 % 2. empty the description field of a parameter ('desc') | |
68 % 3. remove the options | |
69 for jj=1:pls.nparams | |
70 p = pls.params(jj); | |
71 if isa(p.getVal, 'ltpda_uoh') | |
72 p.setVal([p.getVal.hist]); | |
73 end | |
74 p.setDesc(''); | |
75 p.setVal(p.getVal); | |
76 end | |
77 end | |
78 % Remove Password from the history-plist | |
79 if isa(pls, 'plist') && pls.isparam('password') | |
80 pls.remove('password'); | |
81 end | |
82 % Remove Username from the history-plist | |
83 if isa(pls, 'plist') && pls.isparam('username') | |
84 pls.remove('username'); | |
85 end | |
86 | |
87 % Remove the 'sets' and the corresponding 'plists' from the minfo | |
88 % object. They are not important for the history step. | |
89 mi.clearSets(); | |
90 | |
91 % Add history to all objects | |
92 for ii = 1:numel(objs) | |
93 pause(0.001) | |
94 t0 = time(); | |
95 | |
96 % set UUID | |
97 uuid = char(java.util.UUID.randomUUID); | |
98 objs(ii).setUUID(uuid); | |
99 | |
100 % Create new history object | |
101 h = history(t0.utc_epoch_milli, mi, pls, invars, uuid, in_hists); | |
102 h.setObjectClass(class(objs(ii))); | |
103 | |
104 % Set the new history | |
105 objs(ii).setHist(h); | |
106 | |
107 end | |
108 | |
109 % Prepare output | |
110 varargout{1} = objs; | |
111 end | |
112 | |
113 | |
114 | |
115 |