Mercurial > hg > ltpda
comparison m-toolbox/classes/@smodel/display.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 % DISPLAY overloads display functionality for smodel objects. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: DISPLAY overloads display functionality for smodel objects. | |
5 % | |
6 % CALL: txt = display(smodel) | |
7 % | |
8 % INPUT: smodel - ltpda model object | |
9 % | |
10 % OUTPUT: txt - cell array with strings to display the model object | |
11 % | |
12 % <a href="matlab:utils.helper.displayMethodInfo('smodel', 'display')">Parameters Description</a> | |
13 % | |
14 % VERSION: $Id: display.m,v 1.15 2011/05/09 21:56:57 mauro Exp $ | |
15 % | |
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
17 | |
18 function varargout = display(varargin) | |
19 | |
20 %%% Check if this is a call for parameters | |
21 if utils.helper.isinfocall(varargin{:}) | |
22 varargout{1} = getInfo(varargin{3}); | |
23 return | |
24 end | |
25 | |
26 objs = utils.helper.collect_objects(varargin(:), 'smodel'); | |
27 | |
28 txt = {}; | |
29 | |
30 % Print emtpy object | |
31 if isempty(objs) | |
32 hdr = sprintf('------ %s -------', class(objs)); | |
33 ftr(1:length(hdr)) = '-'; | |
34 txt = [txt; {hdr}]; | |
35 txt = [txt; sprintf('empty-object [%d,%d]',size(objs))]; | |
36 txt = [txt; {ftr}]; | |
37 end | |
38 | |
39 for ii=1:numel(objs) | |
40 banner = sprintf('---- symbolic model %d ----', ii); | |
41 txt{end+1} = banner; | |
42 | |
43 % get key and value | |
44 name = objs(ii).name; | |
45 | |
46 % display name | |
47 txt{end+1} = [' name: ' name]; | |
48 | |
49 % display expression | |
50 if isnumeric(objs(ii).expr) | |
51 if numel(objs(ii).expr) > 30 | |
52 svals = [mat2str(objs(ii).expr(1:30))]; | |
53 svals = [svals(1:end-1) ' ...]']; | |
54 else | |
55 svals = mat2str(objs(ii).expr); | |
56 end | |
57 txt{end+1} = [' expr: ' svals]; | |
58 else | |
59 expr = char(objs(ii).expr); | |
60 if numel(expr) > 100 | |
61 expr = expr(1:100); | |
62 end | |
63 txt{end+1} = [' expr: ' expr]; | |
64 end | |
65 | |
66 % display params | |
67 txt{end+1} = [' params: ' utils.prog.cell2str(objs(ii).params)]; | |
68 pstr = '{'; | |
69 for kk=1:numel(objs(ii).values) | |
70 valstr = mat2str(objs(ii).values{kk}); | |
71 if length(valstr) > 30 | |
72 valstr = [valstr(1:30) '...]']; | |
73 end | |
74 if kk > 1 | |
75 pstr = [pstr ', ' valstr]; | |
76 else | |
77 pstr = [pstr valstr]; | |
78 end | |
79 end | |
80 pstr = [pstr '}']; | |
81 | |
82 % display values | |
83 txt{end+1} = [' values: ' pstr]; | |
84 | |
85 % display xvar | |
86 switch class(objs(ii).xvar) | |
87 case 'char' | |
88 sxvar = objs(ii).xvar; | |
89 case 'cell' | |
90 sxvar = '{'; | |
91 for kk=1:numel(objs(ii).xvar) | |
92 valstr = objs(ii).xvar{kk}; | |
93 if kk > 1 | |
94 sxvar = [sxvar ', ' valstr]; | |
95 else | |
96 sxvar = [sxvar valstr]; | |
97 end | |
98 end | |
99 sxvar = [sxvar '}']; | |
100 otherwise | |
101 error(['### Wrong class ' class(objs(ii).xvals) ' for the property ''xvar''']); | |
102 end | |
103 txt{end+1} = [' xvar: ' sxvar]; | |
104 | |
105 % display trans | |
106 switch class(objs(ii).trans) | |
107 case 'char' | |
108 strans = objs(ii).trans; | |
109 case 'cell' | |
110 strans = '{'; | |
111 for kk = 1:numel(objs(ii).trans) | |
112 valstr = objs(ii).trans{kk}; | |
113 if kk > 1 | |
114 strans = [strans ', ' valstr]; | |
115 else | |
116 strans = [strans valstr]; | |
117 end | |
118 end | |
119 strans = [strans '}']; | |
120 otherwise | |
121 error(['### Wrong class ' class(objs(ii).trans) ' for the property ''trans''']); | |
122 end | |
123 txt{end+1} = [' trans: ' strans]; | |
124 | |
125 % display xvals | |
126 switch class(objs(ii).xvals) | |
127 case 'double' | |
128 if numel(objs(ii).xvals) > 30 | |
129 svals = [mat2str(objs(ii).xvals(1:30))]; | |
130 svals = [svals(1:end-1) ' ...]']; | |
131 else | |
132 svals = mat2str(objs(ii).xvals); | |
133 end | |
134 case 'cell' | |
135 svals = '{'; | |
136 for kk=1:numel(objs(ii).xvals) | |
137 if isa(objs(ii).xvals{kk}, 'ao') | |
138 valstr = ['[' class(objs(ii).xvals{kk}.data) ' ao]']; | |
139 else | |
140 valstr = mat2str(objs(ii).xvals{kk}); | |
141 if length(valstr) > 50 | |
142 valstr = [valstr(1:50) '...]']; | |
143 end | |
144 end | |
145 if kk > 1 | |
146 svals = [svals ', ' valstr]; | |
147 else | |
148 svals = [svals valstr]; | |
149 end | |
150 end | |
151 svals = [svals '}']; | |
152 case 'ao' | |
153 svals = ['[' class(objs(ii).xvals.data) ' ao]']; | |
154 otherwise | |
155 error(['### Wrong class ' class(objs(ii).xvals) ' for the property ''xvals''']); | |
156 end | |
157 txt{end+1} = [' xvals: ' svals]; | |
158 | |
159 % display xunits | |
160 txt{end+1} = sprintf(' xunits: %s', strtrim(char(objs(ii).xunits))); | |
161 | |
162 % display yunits | |
163 txt{end+1} = sprintf(' yunits: %s', strtrim(char(objs(ii).yunits))); | |
164 | |
165 % display aliasNames | |
166 txt{end+1} = sprintf(' aliasNames: %s', utils.helper.val2str(objs(ii).aliasNames)); | |
167 | |
168 % display aliasValues | |
169 txt{end+1} = sprintf('aliasValues: %s', utils.helper.val2str(objs(ii).aliasValues)); | |
170 | |
171 % display description | |
172 txt{end+1} = sprintf('description: %s', objs(ii).description); | |
173 | |
174 % display UUID | |
175 txt{end+1} = sprintf(' UUID: %s', objs(ii).UUID); | |
176 | |
177 banner_end(1:length(banner)) = '-'; | |
178 txt{end+1} = banner_end; | |
179 end | |
180 | |
181 if nargout == 0 | |
182 for ii=1:length(txt) | |
183 disp(txt{ii}); | |
184 end | |
185 else | |
186 varargout{1} = txt; | |
187 end | |
188 | |
189 end | |
190 | |
191 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
192 % Local Functions % | |
193 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
194 | |
195 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
196 % | |
197 % FUNCTION: getInfo | |
198 % | |
199 % DESCRIPTION: Get Info Object | |
200 % | |
201 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
202 | |
203 function ii = getInfo(varargin) | |
204 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
205 sets = {}; | |
206 pl = []; | |
207 else | |
208 sets = {'Default'}; | |
209 pl = getDefaultPlist; | |
210 end | |
211 % Build info object | |
212 ii = minfo(mfilename, 'smodel', 'ltpda', utils.const.categories.output, '$Id: display.m,v 1.15 2011/05/09 21:56:57 mauro Exp $', sets, pl); | |
213 ii.setModifier(false); | |
214 ii.setOutmin(0); | |
215 end | |
216 | |
217 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
218 % | |
219 % FUNCTION: getDefaultPlist | |
220 % | |
221 % DESCRIPTION: Get Default Plist | |
222 % | |
223 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
224 | |
225 function plout = getDefaultPlist() | |
226 persistent pl; | |
227 if exist('pl', 'var')==0 || isempty(pl) | |
228 pl = buildplist(); | |
229 end | |
230 plout = pl; | |
231 end | |
232 | |
233 function pl = buildplist() | |
234 pl = plist.EMPTY_PLIST; | |
235 end |