comparison m-toolbox/m/etc/.#ltpda_startup.m.1.93 @ 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 % This is the startup file for ltpda. It should be run once in the MATLAB
2 % session before using any features of ltpda. The best way to ensure this
3 % is to create a file called startup.m and put this somewhere in your
4 % MATLAB path. In this file you should have the command 'ltpda_startup'.
5 %
6 % M Hewitson 16-03-07
7 %
8 % $Id: ltpda_startup.m,v 1.93 2011/04/09 13:59:04 hewitson Exp $
9 %
10 function ltpda_startup
11
12 % For the case that the user calls 'ltpda_startup' in his current MATLAB
13 % session again it is necessary to destroy ALL java objects.
14 setappdata(0, 'LTPDApreferences', []);
15
16 % Remove the repository manager
17 rm = getappdata(0, 'LTPDARepositoryManager');
18 if ~isempty(rm)
19 delete(rm);
20 end
21 setappdata(0, 'LTPDARepositoryManager', []);
22
23 clear java
24 clear classes
25
26 %--------------------------------------------------------------------------
27 % If the mex files of LTPDA are not working on your system, you can
28 % recompile them by setting this flag to 1 then run ltpda_startup. After
29 % compilation, set it back to 0.
30 %
31 % This is often required on Linux machines due to the difficulties of
32 % distributing mex files on Linux.
33 COMPILE_MEX = 0;
34
35 %-----------------------------------------------------------------------
36 % Decide if using or not the LTPDA print and plot settings
37 USE_LTPDA_PLOT = false;
38 USE_LTPDA_PRINT = false;
39
40 %--------------------------------------------------------------------------
41 %--------------------------------------------------------------------------
42 %--------------------------------------------------------------------------
43 %--------------------------------------------------------------------------
44 %--------------------------------------------------------------------------
45 %--------------------------------------------------------------------------
46 %--------------------------------------------------------------------------
47 %--------------------------------------------------------------------------
48 %--------------------------------------------------------------------------
49 %--------------------------------------------------------------------------
50 %--------------------------------------------------------------------------
51 %--------------------------------------------------------------------------
52 %--------------------------------------------------------------------------
53 %--------------------------------------------------------------------------
54 %--------------------------------------------------------------------------
55 %--------------------------------------------------------------------------
56 %--------------------------------------------------------------------------
57 %--------------------------------------------------------------------------
58 %--------------------------------------------------------------------------
59 %--------------------------------------------------------------------------
60 %--------------------------------------------------------------------------
61 %--------------------------------------------------------------------------
62 %--------------------------------------------------------------------------
63 %--------------------------------------------------------------------------
64 %--------------------------------------------------------------------------
65 %--------------------------------------------------------------------------
66 %--------------------------------------------------------------------------
67 %--------------------------------------------------------------------------
68
69
70 %--------------------------------------------------------------------------
71 %--------------------------------------------------------------------------
72 % NO NEED TO EDIT BELOW HERE
73 %--------------------------------------------------------------------------
74 %--------------------------------------------------------------------------
75
76 v = ver('LTPDA');
77
78 %--------------------------------------------------------------------------
79 % format of numbers on MATLAB terminal
80 format long g
81
82 % ------------------------------------------------------------------------
83 % MySQL LTPDA Repository Server Settings
84 %
85
86 DBDRIVER = 'com.mysql.jdbc.Driver'; % Set LTPDA Repository database driver
87
88 %------------------------------------------------------------------------
89 % JAVA extensions
90
91
92
93 % Add all jar files in 'ltpda_toolbox/ltpda/jar' to path
94 jardir = fullfile(fileparts(which('ltpda_startup')), '..', '..', 'jar');
95 jars = dir(jardir);
96 for c = 1:numel(jars)
97 s = jars(c);
98 [path, name, ext] = fileparts(s.name);
99 if strcmp(ext, '.jar')
100 javaaddpath(fullfile(jardir, s.name));
101 end
102 end
103 % Add all jar files in 'ltpda_toolbox/ltpda/jar/lib' to path
104 jardir = fullfile(fileparts(which('ltpda_startup')), '..', '..', 'jar', 'lib');
105 jars = dir(jardir);
106 for c = 1:numel(jars)
107 s = jars(c);
108 [path, name, ext] = fileparts(s.name);
109 if strcmp(ext, '.jar')
110 javaaddpath(fullfile(jardir, s.name));
111 end
112 end
113
114 % Add all jar files in extension modules to path
115 installExtensionJarFiles;
116
117 % ------------------------------------------------------------------------
118 % General Variables
119 setappdata(0, 'xmlsetsize', 50000); % Max size of an xml data set <Set></Set>
120
121 setappdata(0, 'ltpda_default_plot_colors', { ...
122 [0 0 1], ... % 'b'
123 [1 0 0], ... % 'r'
124 [0 1 0], ... % 'g'
125 [0 0 0], ... % 'k'
126 [0 1 1], ... % 'c'
127 [1 0 1], ... % 'm'
128 [0.565 0.247 0.667], ... % pink
129 [0.722 0.420 0.274], ... % siena
130 [0.659 0.541 0.000], ... % ocra
131 [1 0.604 0.208], ... % orange
132 [0.502 0.502 0.502], ... % dark grey
133 [0.733 0.824 0.082], ... % ill green
134 [0.318 0.557 0.675], ... % cobalto
135 [0.8 0.2 0.2], ...
136 [0.2 0.2 0.8], ...
137 [0.2 0.9 0.2], ...
138 [0.37 0.9 0.83], ...
139 [0.888 0.163 0.9], ...
140 [0 0 0], ...
141 [0 207 255]/255, ...
142 [255 128 0]/255, ...
143 [143 0 0]/255, ...
144 [255 207 0]/255, ...
145 [0.9 0.266 0.593]});
146
147 % ------------------------------------------------------------------------
148 % Version Variables
149
150 NOT_INSTALLED = 'Not installed';
151 matlab_version = NOT_INSTALLED;
152 sigproc_version = NOT_INSTALLED;
153 symbolic_math_version = NOT_INSTALLED;
154 optimization_version = NOT_INSTALLED;
155 database_version = NOT_INSTALLED;
156 control_version = NOT_INSTALLED;
157 statistics_version = NOT_INSTALLED;
158 ltpda_version = NOT_INSTALLED;
159
160 vs = ver;
161 for jj = 1:length(vs)
162 v = vs(jj);
163 switch v.Name
164 case 'MATLAB'
165 matlab_version = [v.Version ' ' v.Release];
166 case 'Signal Processing Toolbox'
167 sigproc_version = [v.Version ' ' v.Release];
168 case 'Symbolic Math Toolbox'
169 symbolic_math_version = [v.Version ' ' v.Release];
170 case 'Optimization Toolbox'
171 optimization_version = [v.Version ' ' v.Release];
172 case 'Database Toolbox'
173 database_version = [v.Version ' ' v.Release];
174 case 'Control System Toolbox'
175 control_version = [v.Version ' ' v.Release];
176 case 'Statistics Toolbox'
177 statistics_version = [v.Version ' ' v.Release];
178 case 'LTPDA Toolbox'
179 ltpda_version = [v.Version ' ' v.Release];
180 end
181 end
182
183 setappdata(0, 'matlab_version', matlab_version);
184 setappdata(0, 'sigproc_version', sigproc_version);
185 setappdata(0, 'symbolic_math_version', symbolic_math_version);
186 setappdata(0, 'optimization_version', optimization_version);
187 setappdata(0, 'database_version', database_version);
188 setappdata(0, 'control_version', control_version);
189 setappdata(0, 'statistics_version', statistics_version);
190 setappdata(0, 'ltpda_version', ltpda_version);
191 setappdata(0, 'ltpda_required_matlab_version', '7.6');
192
193 %--------------------------------------------------------------------------
194 % do we need to compile mex files?
195 if COMPILE_MEX
196 currdir = pwd;
197 [path, name, ext, vers] = fileparts(which('ltpda_startup'));
198 parts = regexp(path, 'ltpda/', 'split');
199 cd(fullfile(parts{1}, 'ltpda', 'src'));
200 compileAll;
201 cd(currdir);
202 end
203
204 %--------------------------------------------------------------------------
205 % Start matlab pool if parallel toolbox is installed
206 if exist('parfor', 'builtin')==5 && exist('matlabpool','file')==2
207 % try
208 % matlabpool open 2
209 % end
210 end
211
212 % -------------------------------------------------------------------------
213 % import some things
214
215 import utils.const.*
216
217 % -------------------------------------------------------------------------
218 % Launch some things
219
220 % ltpdalauncher;
221
222
223
224
225 %--------------------------------------------------------------------------
226 % Check and load user parameters
227 %
228 loadPrefs;
229
230
231 %--------------------------------------------------------------------------
232 % set page properties for printing
233 if USE_LTPDA_PRINT
234 set(0, 'DefaultFigurePaperOrientation','landscape');
235 set(0, 'DefaultFigurePaperType','A4');
236 set(0, 'DefaultFigurePaperUnits', 'centimeters');
237 set(0, 'DefaultFigurePaperPositionMode', 'manual');
238 set(0, 'DefaultFigurePaperPosition', [3.56 2.03 22.56 16.92]);
239 end
240
241 % ------------------------------------------------------------------------
242 % Backup MATLAB's plot settings
243 utils.plottools.backupDefaultPlotSettings();
244
245 %--------------------------------------------------------------------------
246 % Plot settings
247 if USE_LTPDA_PLOT
248 set(0, 'DefaultAxesXColor', [0 0 0]);
249 set(0, 'DefaultAxesYColor', [0 0 0]);
250 set(0, 'defaultfigurenumbertitle', 'on');
251 set(0, 'DefaultFigureColor', 'w');
252 set(0, 'DefaultFigurePosition', [0 0 1200 700]);
253 set(0, 'DefaultAxesPosition', [0.13 0.15 0.775 0.75]);
254 end
255
256 % Add user model paths
257 prefs = getappdata(0, 'LTPDApreferences');
258 searchPaths = prefs.getModelsPrefs.getSearchPaths;
259 for jj = 1:searchPaths.size()
260 addpath(genpath(char(searchPaths.get(jj-1))));
261 end
262
263 % Install extensions
264 utils.helper.installExtensions;
265
266 %--------------------------------------------------------------------------
267 % Activate correct helptoc.xml file (depending on MATLAB version)
268
269 % Define MATLAB helptoc version
270 matlabRelease = version('-release');
271 switch matlabRelease
272 case {'2008a', '2008b', '2009a'}
273 matlabRelease = 'R2009a';
274 case '2009b'
275 matlabRelease = 'R2009b';
276 case '2010a'
277 matlabRelease = 'R2010a';
278 otherwise
279 matlabRelease = 'R2010a';
280 end
281
282 % Get info.xml path
283 infoPath = which('info.xml');
284 [infoLocation, infoName, infoExt] = fileparts(infoPath);
285
286 % read info.xml file in order to get the helptoc.xml path
287 infoXML = xmlread('info.xml');
288 tbNameNode = infoXML.getElementsByTagName('name');
289 tbName = tbNameNode.item(0).getFirstChild.getData;
290 if strcmp(tbName, 'LTPDA')
291 helpLocationNodes = infoXML.getElementsByTagName('help_location');
292 helpLocation = char(helpLocationNodes.item(0).getFirstChild.getTextContent);
293 else % Otherwise error out
294 error('Can not find info.xml file for My Toolbox');
295 end
296
297 helptocLocation = fullfile(infoLocation, helpLocation);
298
299 helptocSource = fullfile(helptocLocation, strcat('helptoc', matlabRelease, '.xml'));
300 helptocDest = fullfile(helptocLocation, 'helptoc.xml');
301
302 copyfile(helptocSource, helptocDest);
303
304 % Set LTPDA Root dir
305 ltpdaroot = strrep(which('ao'), fullfile('ltpda', 'classes', '@ao', 'ao.m'), '');
306 setappdata(0, 'LTPDAROOT', ltpdaroot);
307
308
309 % Show logo
310 showLogo();
311
312 % Now we need to clear in order to register the newly install class
313 % methods coming from the extensions
314 mc;
315
316 % ---- Start Repository Manager
317 LTPDARepositoryManager;
318
319 end
320
321 function installExtensionJarFiles
322 % We'll need to get all the users extension modules to look for jar
323 % files.
324 v = ver('LTPDA');
325 nv = utils.helper.ver2num(v(1).Version);
326 prefs = mpipeline.ltpdapreferences.LTPDAPreferences.loadFromDisk(LTPDAprefs.preffile, nv);
327 jextPaths = prefs.getExtensionsPrefs.getSearchPaths;
328 setappdata(0, 'LTPDApreferences', []);
329 clear prefs;
330
331 extPaths = [];
332 for kk=0:jextPaths.size-1
333 extPaths = [extPaths {char(jextPaths.get(kk))}];
334 end
335 clear jextPaths;
336
337 for kk=1:numel(extPaths)
338 p = extPaths{kk};
339 files = dir(fullfile(p, 'jar'));
340 for ff=1:numel(files)
341 f = files(ff);
342 [path, name, ext] = fileparts(f.name);
343 if strcmp(ext, '.jar')
344 javaaddpath(fullfile(p, 'jar', f.name));
345 end
346 end
347 end
348 end
349
350
351 function loadPrefs
352 if exist(LTPDAprefs.preffile, 'file') == 2
353
354 % we just go ahead
355 LTPDAprefs.loadPrefs;
356
357 else
358
359 % Check for old prefs file
360 if exist(LTPDAprefs.oldpreffile, 'file') == 2
361
362 % load it
363 pl = plist(LTPDAprefs.oldpreffile);
364
365 % Now make a new preferences file
366 LTPDAprefs.loadPrefs;
367 prefs = getappdata(0, 'LTPDApreferences');
368 prefs = LTPDAprefs.upgradeFromPlist(prefs, pl);
369
370 prefs.writeToDisk;
371
372 else
373
374 % Copy the default preferences file to MATLAB's preference directory.
375 defPrefsFile = fullfile(fileparts(which('ltpda_startup')), 'ltpda_prefs2.xml');
376 copyfile(defPrefsFile, prefdir() );
377
378 % Build the default prefs
379 LTPDAprefs.loadPrefs;
380
381 % Show a GUI to allow the user to edit the prefs for the first time
382 LTPDAprefs;
383
384 end
385 end
386 end
387
388 function showLogo()
389
390 v = ver('LTPDA');
391
392 logo = {...
393 ' ',...
394 ' **** ',...
395 ' ** ',...
396 ' ------------- ',...
397 ' //// / \\\\ ',...
398 ' /// / \\\ ',...
399 ' | / | ',...
400 ' ** | +----+ / +----+ | ** ',...
401 ' ***| | |//-------| | |*** ',...
402 ' ** | +----+ /+----+ | ** ',...
403 ' | / | ',...
404 ' \\\ / /// ',...
405 ' \\\\ // //// ',...
406 ' ------------- ',...
407 ' ** ',...
408 ' **** ',...
409 };
410
411 l1 = '+----------------------------------------------------+';
412 ll = length(l1);
413
414 disp(l1);
415 disp('| |')
416 for jj = 1:length(logo)
417 disp([utils.prog.strpad(sprintf('| %s ', char(logo{jj})), ll-1) '|']);
418 end
419 disp([utils.prog.strpad('|', ll-1) '|'])
420 disp([utils.prog.strpad(sprintf('| Welcome to the %s', v.Name), ll-1) '|'])
421 disp([utils.prog.strpad('|', ll-1) '|'])
422 disp([utils.prog.strpad(sprintf('| Version: %s', v.Version), ll-1) '|'])
423 disp([utils.prog.strpad(sprintf('| Release: %s', v.Release), ll-1) '|'])
424 disp([utils.prog.strpad(sprintf('| Date: %s', v.Date), ll-1) '|'])
425 disp([utils.prog.strpad('|', ll-1) '|'])
426 disp(l1);
427
428 end
429
430
431 % END