3 // Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 // See the file ../license.txt
22 function [model,graphics,ok]=check_io(model,graphics,in,out,clkin,clkout,in_implicit,out_implicit)
23 // check_io first check if given number of ports agree with block connection
24 // and then changes block structure
26 // model : initial and resulting block model structure
27 // graphics: initial and resulting block graphics structure
28 // in : new input ports sizes
29 // nout : new output ports sizes
30 // nclkin : new event input ports sizes
31 // nclkout : new event output ports sizes
32 // in_impl : index of implicit input ports, the other ports are supposed to be explicit
33 // out_impl: index of implicit output ports , the other ports are supposed to be explicit
35 // ok==%f : some of input parameters are incorrects or
36 // attempt to add/delete ports when some are connected
37 // ok==%t : changes of block structure has been performed
39 if argn(2)<=6 then in_implicit=[],out_implicit=[],end
40 // check_io first check if given number of ports agree with block connection
41 in=int(in(:));nin=size(in,1)
43 out=int(out(:));nout=size(out,1);
45 clkin=int(clkin(:));nclkin=size(clkin,1);
48 message('Event input ports sizes must be positive')
55 clkout=int(clkout(:));nclkout=size(clkout,1);
57 if mini(clkout)<1 then
58 message('Event output ports sizes must be positive')
65 [label,ip1,op1,cip1,cop1]=(graphics.exprs,graphics.pin,graphics.pout,..
66 graphics.pein,graphics.peout)
68 [in1,out1,clkin1,clkout1]=(model.in,model.out,model.evtin,model.evtout)
70 n1=size(in1(:,1),'*');n=size(in(:,1),'*')
72 if or(ip1(n+1:$)>0) then
73 message('Connected ports cannot be suppressed')
79 ip1=[ip1;zeros(n-n1,1)]
82 n1=size(out1,'*');n=size(out,'*')
84 if or(op1(n+1:$)>0) then
85 message('Connected ports cannot be suppressed')
91 op1=[op1;zeros(n-n1,1)]
94 n1=size(clkin1,'*');n=size(clkin,'*')
96 if or(cip1(n+1:$)>0) then
97 message('Connected ports cannot be suppressed')
103 cip1=[cip1;zeros(n-n1,1)];
106 n1=size(clkout1,'*');n=size(clkout,'*')
108 if or(cop1(n+1:$)>0) then
109 message('Connected ports cannot be suppressed')
115 cop1=[cop1;zeros(n-n1,1)];
122 in_impl=I(ones(ip1)); in_impl(in_implicit)='I';
123 kk=size(graphics.in_implicit,'*')
124 k=find(ip1<>0) //connected links
126 if or(graphics.in_implicit(k)<>in_impl(k)) then
127 message('Connected ports types cannot be changed')
137 out_impl=I(ones(op1)); out_impl(out_implicit)='I';
138 kk=size(graphics.out_implicit,'*')
139 k=find(op1<>0) //connected links
141 if or(graphics.out_implicit(k)<>out_impl(k)) then
142 message('Connected ports types cannot be changed')
156 graphics.in_implicit=in_impl
157 graphics.out_implicit=out_impl
159 if size(in1,2)<=1 then
161 elseif size(in1,2)==2 then //This appears not to be useful, retained if case of?
162 disp("check_io : unexpected case")
163 model.in=[in,2*ones(in)];
166 if size(out1,2)<=1 then
168 elseif size(out1,2)==2 then //This appears not to be useful, retained if case of?
169 disp("check_io : unexpected case")
170 model.out=[out,2*ones(out)];