Mercurial > hg > ltpda
comparison m-toolbox/classes/@mfir/update_struct.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 % UPDATE_STRUCT update the input structure to the current ltpda version | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % FUNCTION: update_struct | |
5 % | |
6 % DESCRIPTION: UPDATE_STRUCT update the input structure to the current | |
7 % ltpda version | |
8 % | |
9 % CALL: obj_struct = update_struct(obj_struct, version_str); | |
10 % | |
11 % VERSION: $Id: update_struct.m,v 1.10 2011/03/28 12:45:44 hewitson Exp $ | |
12 % | |
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
14 | |
15 function varargout = update_struct(varargin) | |
16 | |
17 obj_struct = varargin{1}; | |
18 struct_ver = varargin{2}; | |
19 | |
20 % get the version of the current toolbox | |
21 tbx_ver = strtok(getappdata(0, 'ltpda_version')); | |
22 | |
23 % get only the version string without the MATLAB version | |
24 struct_ver = strtok(struct_ver); | |
25 | |
26 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.0 -> 1.9.1' %%%%%%%%%%%%%%%%%%%%%%% | |
27 | |
28 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ... | |
29 strcmp(struct_ver, '1.0') | |
30 | |
31 try | |
32 | |
33 %%% a | |
34 if isfield(obj_struct, 'gain') && ~isempty(obj_struct.gain) && obj_struct.gain ~= 0 | |
35 obj_struct.a = obj_struct.a * obj_struct.gain; | |
36 end | |
37 | |
38 %%% gd | |
39 if ~isfield(obj_struct, 'gd') | |
40 obj_struct.gd = 0; | |
41 end | |
42 | |
43 %%% creator | |
44 if isfield(obj_struct, 'provenance') && ~isfield(obj_struct, 'creator') | |
45 obj_struct.creator = obj_struct.provenance; | |
46 elseif ~isfield(obj_struct, 'creator') | |
47 obj_struct.creator = provenance('Updater 1.0 -> 1.9.1'); | |
48 end | |
49 | |
50 %%%%% hist | |
51 if ~isfield(obj_struct, 'hist') | |
52 if isfield(obj_struct, 'class') | |
53 cn = obj_struct.class; | |
54 else | |
55 cn = 'unknown class. updater'; | |
56 end | |
57 ii = minfo('update_struct', cn, 'ltpda', '', ... | |
58 '$Id: update_struct.m,v 1.10 2011/03/28 12:45:44 hewitson Exp $', ... | |
59 {'Default'}, plist(), 0, 0); | |
60 obj_struct.hist = history(time().utc_epoch_milli, ii, obj_struct.plist); | |
61 end | |
62 | |
63 catch ME | |
64 disp(varargin{1}); | |
65 throw(addCause(ME, MException('MATLAB:LTPDA','### The struct (mfir) above is not from version 1.0'))); | |
66 end | |
67 | |
68 struct_ver = '1.9.1'; | |
69 end | |
70 | |
71 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.1' ->'1.9.2' %%%%%%%%%%%%%%%%%%%%%%% | |
72 | |
73 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ... | |
74 strcmp(struct_ver, '1.9.1') | |
75 | |
76 struct_ver = '1.9.2'; | |
77 end | |
78 | |
79 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.2' ->'1.9.3' %%%%%%%%%%%%%%%%%%%%%%% | |
80 | |
81 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ... | |
82 strcmp(struct_ver, '1.9.2') | |
83 | |
84 struct_ver = '1.9.3'; | |
85 end | |
86 | |
87 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.3' ->'1.9.4' %%%%%%%%%%%%%%%%%%%%%%% | |
88 | |
89 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ... | |
90 strcmp(struct_ver, '1.9.3') | |
91 | |
92 %%% created | |
93 if isfield(obj_struct, 'created') | |
94 obj_struct = rmfield(obj_struct, 'created'); | |
95 end | |
96 | |
97 %%% creator | |
98 if isfield(obj_struct, 'creator') | |
99 obj_struct = rmfield(obj_struct, 'creator'); | |
100 end | |
101 | |
102 struct_ver = '1.9.4'; | |
103 end | |
104 | |
105 %%% ntaps | |
106 if isfield(obj_struct, 'ntaps') | |
107 obj_struct = rmfield(obj_struct, 'ntaps'); | |
108 end | |
109 | |
110 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.4' ->'2.0' %%%%%%%%%%%%%%%%%%%%%%% | |
111 | |
112 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ... | |
113 strcmp(struct_ver, '1.9.4') | |
114 | |
115 struct_ver = '2.0'; | |
116 end | |
117 | |
118 %%%%%%%%%%%%%%%%%%%%%%% Update version '2.0' ->'2.0.1' %%%%%%%%%%%%%%%%%%%%%%% | |
119 | |
120 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ... | |
121 strcmp(struct_ver, '2.0') | |
122 | |
123 struct_ver = '2.0.1'; | |
124 end | |
125 | |
126 %%%%%%%%%%%%%%%%%%%%%%% Update version '2.0.1' ->'2.1' %%%%%%%%%%%%%%%%%%%%%%% | |
127 | |
128 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ... | |
129 strcmp(struct_ver, '2.0.1') | |
130 | |
131 struct_ver = '2.1'; | |
132 end | |
133 | |
134 varargout{1} = obj_struct; | |
135 end | |
136 |