File: check_io.sci

package info (click to toggle)
scilab 2.4-1
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 55,196 kB
  • ctags: 38,019
  • sloc: ansic: 231,970; fortran: 148,976; tcl: 7,099; makefile: 4,585; sh: 2,978; csh: 154; cpp: 101; asm: 39; sed: 5
file content (106 lines) | stat: -rw-r--r-- 2,192 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
function [model,graphics,ok]=check_io(model,graphics,in,out,clkin,clkout)
// check_io first check if given number of ports agree with block connection
// and then changes block structure
//%parameters
// model   : initial and resulting block model structure
// graphics: initial and resulting block graphics structure
// in      : new input ports sizes
// nout    : new output ports sizes
// nclkin  : new event input ports sizes
// nclkout : new event output ports sizes
// ok      : error flag
//           ok==%f : some of input parameters are incorrects or
//                    attempt to add/delete ports when some are connected
//           ok==%t  : changes of block structure has been performed
//!
// Copyright INRIA
in=int(in(:));nin=size(in,1)

out=int(out(:));nout=size(out,1);

clkin=int(clkin(:));nclkin=size(clkin,1);
if nclkin>0 then
  if mini(clkin)<1 then
    message('Event input ports sizes must be positive')
    ok=%f
    return
  end
end


clkout=int(clkout(:));nclkout=size(clkout,1);
if nclkout>0 then
  if mini(clkout)<1 then
    message('Event output ports sizes must be positive')
    ok=%f
    return
  end
end



[label,ip1,op1,cip1,cop1]=graphics(4:8)

[in1,out1,clkin1,clkout1]=model(2:5)

n1=size(in1,'*');n=size(in,'*')
if n1>n then
  if or(ip1(n+1:$)>0) then
    message('Connected ports cannot be suppressed')
    ok=%f
    return
  end
  ip1=ip1(1:n)
else
  ip1=[ip1;zeros(n-n1,1)]
end

n1=size(out1,'*');n=size(out,'*')
if n1>n then
  if or(op1(n+1:$)>0) then
    message('Connected ports cannot be suppressed')
    ok=%f
    return
  end
  op1=op1(1:n)
else
  op1=[op1;zeros(n-n1,1)]
end

n1=size(clkin1,'*');n=size(clkin,'*')
if n1>n then
  if or(cip1(n+1:$)>0) then
    message('Connected ports cannot be suppressed')
    ok=%f
    return
  end
  cip1=cip1(1:n)
else
  cip1=[cip1;zeros(n-n1,1)];
end

n1=size(clkout1,'*');n=size(clkout,'*')
if n1>n then
  if or(cop1(n+1:$)>0) then
    message('Connected ports cannot be suppressed')
    ok=%f
    return
  end
  cop1=cop1(1:n);
else
  cop1=[cop1;zeros(n-n1,1)];
end

ok=%t
graphics(5)=ip1
graphics(6)=op1
graphics(7)=cip1
graphics(8)=cop1
model(2)=in
model(3)=out
model(4)=clkin
model(5)=clkout