1 % RPP_GENERATE_LIB Generates rpp_lib.slx library for the current target.
3 % Copyright (C) 2013-2015 Czech Technical University in Prague
6 % - Michal Horn <hornmich@fel.cvut.cz>
8 % This document contains proprietary information belonging to Czech
9 % Technical University in Prague. Passing on and copying of this
10 % document, and communication of its contents is not permitted
11 % without prior written authorization.
13 % File : rpp_generate_lib.m
15 % Generates library rpp_lib.slx for targets
18 % http://www.mathworks.com/help/matlab/ref/mex.html
19 % http://www.mathworks.com/help/matlab/matlab_external/custom-building-mex-files.html
21 function rpp_generate_lib()
22 blocks = rpp_get_blocks();
23 d = fullfile(getpref('rpp', 'TargetRoot'), '..', 'blocks');
27 load_system('rpp_lib.slx');
29 new_system('rpp_lib', 'Library');
31 set_param('rpp_lib', 'Lock', 'off');
32 oldBlocks = find_system('rpp_lib', 'Type', 'block');
33 disp('Removing old blocks:');
34 for j=1:length(oldBlocks),
35 disp([' ', oldBlocks{j}]);
36 delete_block(oldBlocks{j});
38 disp('Adding new blocks:');
39 for j=1:length(blocks),
40 blockFilePath=[blocks{j}, '.slx'];
41 disp([' from: ', blockFilePath, ':']);
42 load_system(blockFilePath)
43 newBlocks = find_system(blocks{j}, 'Type', 'block');
44 for k=1:length(newBlocks),
45 [tok, blockName] = strtok(newBlocks{k}, '/');
46 blockName = ['rpp_lib', blockName];
47 disp([' ', newBlocks{k}, ' as ', blockName]);
48 add_block(newBlocks{k}, blockName);
50 close_system(blockFilePath, 0);
54 mv = 9999.9999; %get_param('rpp_lib', 'ModelVersion');
56 {'rpp_lib/General Purpose Digital Input', ...
57 'rpp_lib/General Purpose Digital Input', ...
58 0, mv, 'rpp_block_transform' },
59 {'rpp_lib/General Purpose Digital Output', ...
60 'rpp_lib/General Purpose Digital Output', ...
61 0, mv, 'rpp_block_transform' },
63 set_param('rpp_lib', 'ForwardingTable', ft);
65 disp(['Closing and saving file ', 'rpp_lib.slx']);
66 set_param('rpp_lib', 'Lock', 'on');
67 save_system('rpp_lib');
68 close_system('rpp_lib.slx', 1);