Xcos tests: allow CONSTRAINT2_c, EXTRACT, LOOKUP2D, MPBLOCK, MCLOCK_f, ENDBLK and...
[scilab.git] / scilab / modules / scicos_blocks / macros / Misc / ENDBLK.sci
1 //  Scicos
2 //
3 //  Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
4 //
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.
9 //
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.
14 //
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 //
19 // See the file ../license.txt
20 //
21
22 function [x,y,typ]=ENDBLK(job,arg1,arg2)
23     x=[];
24     y=[];
25     typ=[];
26     select job
27     case "set" then
28         // look for the internal edge trigger block
29         for i=1:length(arg1.model.rpar.objs) do
30             o = arg1.model.rpar.objs(i);
31             if typeof(o) == "Block" & o.gui == "END_c" then
32                 ppath = list(i);
33                 break;
34             end
35         end
36         newpar=list();
37         y=0;
38         for path=ppath do
39             np=size(path,"*")
40             spath=list()
41             for k=1:np
42                 spath($+1)="model"
43                 spath($+1)="rpar"
44                 spath($+1)="objs"
45                 spath($+1)=path(k)
46             end
47             xx=arg1(spath)// get the block
48             execstr("xxn="+xx.gui+"(''set'',xx)")
49             if diffobjs(xxn,xx)==1 then
50                 model=xx.model
51                 model_n=xxn.model
52                 if ~is_modelica_block(xx) then
53                     modified=or(model.sim<>model_n.sim)|..
54                     ~isequal(model.state,model_n.state)|..
55                     ~isequal(model.dstate,model_n.dstate)|..
56                     ~isequal(model.odstate,model_n.odstate)|..
57                     ~isequal(model.rpar,model_n.rpar)|..
58                     ~isequal(model.ipar,model_n.ipar)|..
59                     ~isequal(model.opar,model_n.opar)|..
60                     ~isequal(model.label,model_n.label)
61                     if or(model.in<>model_n.in)|or(model.out<>model_n.out)|..
62                         or(model.in2<>model_n.in2)|or(model.out2<>model_n.out2)|..
63                         or(model.outtyp<>model_n.outtyp)|or(model.intyp<>model_n.intyp) then
64                         needcompile=1
65                     end
66                     if or(model.firing<>model_n.firing) then
67                         needcompile=2
68                     end
69                     if (size(model.in,"*")<>size(model_n.in,"*"))|..
70                         (size(model.out,"*")<>size(model_n.out,"*"))|..
71                         (size(model.evtin,"*")<>size(model_n.evtin,"*")) then
72                         needcompile=4
73                     end
74                     if model.sim=="input"|model.sim=="output" then
75                         if model.ipar<>model_n.ipar then
76                             needcompile=4
77                         end
78                     end
79                     if or(model.blocktype<>model_n.blocktype)|..
80                         or(model.dep_ut<>model_n.dep_ut) then
81                         needcompile=4
82                     end
83                     if (model.nzcross<>model_n.nzcross)|(model.nmode<>model_n.nmode) then
84                         needcompile=4
85                     end
86                     if prod(size(model_n.sim))>1 then
87                         if model_n.sim(2)>1000 then
88                             if model.sim(1)<>model_n.sim(1) then
89                                 needcompile=4
90                             end
91                         end
92                     end
93                 else
94                     modified=or(model_n<>model)
95                     eq=model.equations;eqn=model_n.equations;
96                     if or(eq.model<>eqn.model)|or(eq.inputs<>eqn.inputs)|..
97                         or(eq.outputs<>eqn.outputs) then
98                         needcompile=4
99                     end
100                 end
101                 //parameter or states changed
102                 arg1(spath)=xxn// Update
103                 newpar(size(newpar)+1)=path// Notify modification
104                 y=max(y,needcompile)
105             end
106         end
107         x=arg1
108         typ=newpar
109     case "define" then
110         scs_m_1=scicos_diagram(..
111         version="scicos4.2",..
112         props=scicos_params(..
113         wpar=[-159.096,811.104,-121.216,617.984,1323,1008,331,284,630,480,0,7,1.4],..
114         Title="ENDBLK",..
115         tol=[0.0001,0.000001,1.000E-10,100001,0,0],..
116         tf=100000,..
117         context=" ",..
118         void1=[],..
119         options=tlist(["scsopt","3D","Background","Link","ID","Cmap"],list(%t,33),[8,1],[1,5],..
120         list([5,1],[4,1]),[0.8,0.8,0.8]),..
121         void2=[],..
122         void3=[],..
123         doc=list()))
124         scs_m_1.objs(1)=scicos_block(..
125         gui="END_c",..
126         graphics=scicos_graphics(..
127         orig=[272.104,249.11733],..
128         sz=[40,40],..
129         flip=%t,..
130         theta=0,..
131         exprs="1.000E+08",..
132         pin=[],..
133         pout=[],..
134         pein=2,..
135         peout=2,..
136         gr_i=[],..
137         id="",..
138         in_implicit=[],..
139         out_implicit=[]),..
140         model=scicos_model(..
141         sim=list("scicosexit",4),..
142         in=[],..
143         in2=[],..
144         intyp=1,..
145         out=[],..
146         out2=[],..
147         outtyp=1,..
148         evtin=1,..
149         evtout=1,..
150         state=[],..
151         dstate=[],..
152         odstate=list(),..
153         rpar=[],..
154         ipar=[],..
155         opar=list(),..
156         blocktype="d",..
157         firing=1.000E+08,..
158         dep_ut=[%f,%f],..
159         label="",..
160         nzcross=0,..
161         nmode=0,..
162         equations=list()),..
163         doc=list())
164         scs_m_1.objs(2)=scicos_link(..
165         xx=[292.104;292.104;261.83733;261.83733;292.104;292.104],..
166         yy=[243.40305;234.45067;234.45067;305.584;305.584;294.83162],..
167         id="drawlink",..
168         thick=[0,0],..
169         ct=[5,-1],..
170         from=[1,1,0],..
171         to=[1,1,1])
172         model=scicos_model(..
173         sim="csuper",..
174         in=[],..
175         in2=[],..
176         intyp=1,..
177         out=[],..
178         out2=[],..
179         outtyp=1,..
180         evtin=[],..
181         evtout=[],..
182         state=[],..
183         dstate=[],..
184         odstate=list(),..
185         rpar=scs_m_1,..
186         ipar=[],..
187         opar=list(),..
188         blocktype="h",..
189         firing=[],..
190         dep_ut=[%f,%f],..
191         label="",..
192         nzcross=0,..
193         nmode=0,..
194         equations=list())
195         gr_i=[];
196         x=standard_define([2 2],model,[],gr_i)
197     end
198 endfunction