diff m-toolbox/sltpda/sltpda_parse_model.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/sltpda/sltpda_parse_model.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,58 @@
+function cmds = sltpda_parse_model(mdlfile)
+
+% SLTPDA_PARSE_MODEL Parse an sLTPDA model file and produce a runable m-file.
+% 
+% M Hewitson 27-03-07
+% 
+% $Id: sltpda_parse_model.m,v 1.4 2007/05/06 12:17:38 hewitson Exp $
+% 
+
+
+banner = sprintf('===========     parsing ''%s''      ===========', mdlfile);
+disp(banner);
+disp(' ');
+
+% load the model into memory
+load_system(mdlfile);
+
+% parse model elements
+sys      = get_param(mdlfile, 'Handle');
+blocks   = find_system(sys, 'FindAll', 'on', 'type', 'block');
+lines    = find_system(sys, 'FindAll', 'on', 'type', 'line');
+oblocks  = find_system(sys, 'FindAll', 'on', 'BlockType', 'Outport');
+iblocks  = find_system(sys, 'FindAll', 'on', 'BlockType', 'Inport');
+ioblocks = [iblocks;oblocks];
+
+% compile commands
+vcmds = getVarBlockCommands(blocks);
+bcmds  = getBlockCommands(blocks);
+lcmds  = getLineCommands(lines);
+iocmds = getIOblockCommands(ioblocks);
+cmds   = [bcmds lcmds iocmds];
+
+% go through commands and make list of commands
+% in order required to execute
+ 
+%-------- now sort the commands
+% % 
+% for j=1:length(cmds)
+%   disp(cmds(j))
+% end
+
+cmds = [vcmds cmds];
+cmds = sortCmds(cmds);
+
+% 
+% for j=1:length(cmds)
+%   disp(cmds(j))
+% end
+
+
+bannerEnd = [];
+while length(bannerEnd) < length(banner)
+  bannerEnd = [bannerEnd '='];
+end
+disp(' ');
+disp(bannerEnd);
+
+disp(' ')