0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 function cmds = getBlockCommands(lines)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 % GETLINECOMMANDS get a set of commands from a set of simulink lines.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % M Hewitson 27-03-07
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 disp(' + compiling line list');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 cmds = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 for j=1:length(lines)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 l = lines(j);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 % get src block name
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 srcblock = get(l, 'SrcBlockHandle');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 sbname = get(srcblock, 'Name');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 parent = get(srcblock, 'Parent');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 % get src port number
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 srcport = get(l, 'SrcPortHandle');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 spn = get(srcport, 'PortNumber');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 % Src variable
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 path = strrep(get(srcblock, 'Path'), '/', '_');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 svar = [sbname '_out_' num2str(spn)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 svar = [parent ' ' svar];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 svar = sltpda_reduceVarName(svar);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 svar = sltpda_fixvar(svar);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 % get dst block name
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 dstblock = get(l, 'DstBlockHandle');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 for d=1:length(dstblock)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 dbname = get(dstblock(d), 'Name');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 path = strrep(get(dstblock(d), 'Path'), '/', '_');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 % get dst port number
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 dstport = get(l, 'DstPortHandle');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 dpn = get(dstport(d), 'PortNumber');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 % Dst variable
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 dvar = [dbname '_in_' num2str(dpn)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 dvar = [parent ' ' dvar];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 dvar = sltpda_reduceVarName(dvar);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 dvar = sltpda_fixvar(dvar);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 cmd = [dvar ' = ' svar ';'];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 % store info
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 info.fcn = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 info.params = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 info.plist = plist();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 info.ins = cellstr(svar);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 info.outs = cellstr(dvar);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 info.outsUsed = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 info.cmd = cmd;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 info.name = get(l, 'Name');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 info.handle = get(l, 'Handle');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 info.ranges = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 cmds = [cmds info];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66
|