Mercurial > hg > ltpda
comparison m-toolbox/sltpda/getIOblockCommands.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 function cmds = getIOblockCommands(blocks) | |
2 | |
3 % GETIOBLOCKCOMMANDS get a set of commands from a set of sLTPDA blocks. | |
4 % | |
5 % M Hewitson 27-03-07 | |
6 % | |
7 | |
8 disp(' + compiling IO block list'); | |
9 | |
10 cmds = []; | |
11 | |
12 for j=1:length(blocks) | |
13 | |
14 b = blocks(j); | |
15 | |
16 blocktype = get(b, 'blocktype'); | |
17 name = get(b, 'Name'); | |
18 masktype = get(b, 'MaskType'); | |
19 parent = get(b, 'Parent'); | |
20 | |
21 % split parent name to get block name | |
22 idx = findstr('/', parent); | |
23 blockname = strrep(parent(max(idx)+1:end), ' ', '_'); | |
24 | |
25 % get my port number | |
26 pn = get(b, 'Port'); | |
27 | |
28 fcn = name; | |
29 fcn = sltpda_fixvar(fcn); | |
30 | |
31 % If I am an output port, map my line src to blockname_portnum | |
32 switch blocktype | |
33 case 'Outport' | |
34 | |
35 if ~isempty(blockname) | |
36 l = get(b, 'LineHandles'); | |
37 l = get(l.Inport, 'Handle'); | |
38 % get src block name | |
39 srcblock = get(l, 'SrcBlockHandle'); | |
40 sbname = get(srcblock, 'Name'); | |
41 | |
42 % get src port number | |
43 srcport = get(l, 'SrcPortHandle'); | |
44 spn = get(srcport, 'PortNumber'); | |
45 % Src variable | |
46 svar = [ sbname '_out_' num2str(spn)]; | |
47 svar = [parent ' ' svar]; | |
48 svar = sltpda_reduceVarName(svar); | |
49 svar = sltpda_fixvar(svar); | |
50 % dvar = [ blockname '_out_' num2str(pn)]; | |
51 dvar = [ parent '_out_' num2str(pn)]; | |
52 dvar = sltpda_reduceVarName(dvar); | |
53 dvar = sltpda_fixvar(dvar); | |
54 cmd = [dvar ' = ' svar ';']; | |
55 | |
56 % store info | |
57 info.fcn = ''; | |
58 info.params = []; | |
59 info.plist = plist(); | |
60 info.ins = cellstr(svar); | |
61 info.outs = cellstr(dvar); | |
62 info.outsUsed = []; | |
63 info.cmd = cmd; | |
64 info.name = get(b, 'Name'); | |
65 info.handle = get(b, 'Handle'); | |
66 info.ranges = []; | |
67 | |
68 cmds = [cmds info]; | |
69 end | |
70 % If I am an input port, map my output to parent_name_in_N | |
71 case 'Inport' | |
72 | |
73 svar = [ name '_out_' num2str(1)]; | |
74 svar = [parent ' ' svar]; | |
75 svar = sltpda_reduceVarName(svar); | |
76 svar = sltpda_fixvar(svar); | |
77 | |
78 l = get(b, 'LineHandles'); | |
79 l = get(l.Inport, 'Handle'); | |
80 dvar = [ parent '_in_' num2str(pn)]; | |
81 dvar = sltpda_reduceVarName(dvar); | |
82 dvar = sltpda_fixvar(dvar); | |
83 cmd = [svar ' = ' dvar ';']; | |
84 | |
85 % store info | |
86 info.fcn = ''; | |
87 info.params = []; | |
88 info.plist = plist(); | |
89 info.ins = cellstr(dvar); | |
90 info.outs = cellstr(svar); | |
91 info.outsUsed = []; | |
92 info.cmd = cmd; | |
93 info.name = get(b, 'Name'); | |
94 info.handle = get(b, 'Handle'); | |
95 info.ranges = []; | |
96 | |
97 cmds = [cmds info]; | |
98 | |
99 otherwise | |
100 warning('### Unknown block type'); | |
101 end | |
102 | |
103 end |