Mercurial > hg > ltpda
comparison m-toolbox/classes/@ltpda_uoh/addHistory.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 % ADDHISTORY Add a history-object to the ltpda_uo object. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: Add a history-object to the ltpda_uoh object. | |
5 % | |
6 % CALL: obj = addHistory(obj, minfo, h_pl, var_name, inhists, ...); | |
7 % obj = addHistory(obj, minfo, h_pl, var_name, ismodifier, inhists, ...); | |
8 % | |
9 % VERSION: $Id: addHistory.m,v 1.32 2011/08/16 05:16:04 hewitson Exp $ | |
10 % | |
11 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
12 | |
13 function varargout = addHistory(varargin) | |
14 | |
15 persistent lastProcTime; | |
16 | |
17 | |
18 % The object to add history to | |
19 obj = varargin{1}; | |
20 | |
21 %%% Decide on a deep copy or a modify | |
22 obj = copy(obj, nargout); | |
23 | |
24 % Copy the history plist because we may modify it below | |
25 if isa(varargin{3}, 'plist') | |
26 pl = copy(varargin{3},1); | |
27 else | |
28 pl = varargin{3}; | |
29 end | |
30 | |
31 %%% Add history to all objects | |
32 for ii = 1:numel(obj) | |
33 if ~isempty(pl) | |
34 % 1. replace ltpda_uoh in pl with their history | |
35 % 2. empty the description field of a parameter ('desc') | |
36 % 3. remove the options | |
37 N = pl.nparams; | |
38 for jj=1:N | |
39 p = pl.params(jj); | |
40 if isa(p.getVal, 'ltpda_uoh') | |
41 p.setVal([p.getVal.hist]); | |
42 else | |
43 p.setVal(p.getVal); | |
44 end | |
45 p.setDesc(''); | |
46 end | |
47 end | |
48 % Remove Password from the history-plist | |
49 if isa(pl, 'plist') && pl.isparam('password') | |
50 pl = pl.remove('password'); | |
51 end | |
52 % Remove Username from the history-plist | |
53 if isa(pl, 'plist') && pl.isparam('username') | |
54 pl = pl.remove('username'); | |
55 end | |
56 % Remove the 'sets' and the corresponding 'plists' from the minfo | |
57 % object. They are not important for the history step. | |
58 varargin{2}.clearSets(); | |
59 | |
60 % handle processing time | |
61 t0 = time(); | |
62 proctime = t0.utc_epoch_milli; | |
63 | |
64 if isempty(lastProcTime) | |
65 lastProcTime = proctime; | |
66 else | |
67 if proctime == lastProcTime | |
68 proctime = proctime+1; | |
69 end | |
70 lastProcTime = proctime; | |
71 end | |
72 | |
73 % set UUID | |
74 uuid = char(java.util.UUID.randomUUID); | |
75 obj(ii).UUID = uuid; | |
76 | |
77 h = history(proctime, varargin{2}, pl, varargin{4}, uuid, varargin{5:end}); | |
78 h.setObjectClass(class(obj(ii))); | |
79 obj(ii).setHist(h); | |
80 | |
81 end | |
82 | |
83 %%% Prepare output | |
84 varargout{1} = obj; | |
85 end |