3 // Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
4 // Copyright (C) DIGITEO - 2010 - Jérôme PICARD
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 // See the file ../license.txt
23 function scs_m=do_version(scs_m,version)
25 // available versions of Scicos
26 availableVersions = [ ..
46 if ~or(version==availableVersions) then
47 error("No version update defined to "+version+" version")
50 if version=="scicos2.2" then scs_m=do_version22(scs_m);version="scicos2.3";end
51 if version=="scicos2.3" then scs_m=do_version23(scs_m);version="scicos2.3.1";end
52 if version=="scicos2.3.1" then scs_m=do_version231(scs_m); version="scicos2.4";end
53 if version=="scicos2.4" then scs_m=do_version251(scs_m),version="scicos2.5.1";end
54 if version=="scicos2.5.1" then
57 disp("This is an old scicos diagram. I have to translate.")
58 scs_m=do_versionxx(scs_m);scs_m=do_version27(scs_m);version="scicos2.7";
59 disp("I am now going to clean your diagram. Block numbers may change.")
60 scs_m=do_purge(scs_m);
61 disp("Save the diagram (under a different name just in case)")
64 if version=="scicos2.7" then
65 disp("This is an old scicos diagram. I have to translate. Be patient.")
66 scs_m=do_version271(scs_m),
67 version="scicos2.7.1";
69 if version=="scicos2.7.1" then scs_m=do_version272(scs_m),version="scicos2.7.2";end
70 if version=="scicos2.7.2" then scs_m=do_version273(scs_m),version="scicos2.7.3";end
71 if version=="scicos2.7.3" | version=="scicos4" |...
72 version=="scicos4.0.1" | version=="scicos4.0.2" then
74 //*** do certification ***//
75 scs_m=update_scs_m(scs_m,version);
76 //*** update scope ***//
77 scs_m=do_version42(scs_m);
78 //*********************************//
80 if version=="scicos4.2" then
81 ncl=lines(); lines(0);
83 //*** do certification ***//
84 scs_m=update_scs_m(scs_m,version);
85 scs_m=do_version43(scs_m);
89 if or(version==["scicos4.3";"scicos4.4"]) then
90 ncl=lines(); lines(0);
92 scs_m=update_scs_m(scs_m,version);
93 scs_m=do_version43(scs_m);
94 scs_m.version = version;
99 function scs_m_new=do_version43(scs_m)
100 //disp('do_version43');
104 scs_m_new.props.options.ID(1)=[scs_m.props.options.ID(1)(1),scs_m.props.options.ID(1)(2),2,1];
105 scs_m_new.props.options.ID(2)=[scs_m.props.options.ID(2)(1),scs_m.props.options.ID(2)(2),10,1];
108 for j=1:n //loop on objects
110 if typeof(o)=="Block" then
113 // Clear the doc fields if it contains a function pointer
114 if type(o.doc) == 15 & size(o.doc) > 1 & (type(o.doc(1)) == 11 | type(o.doc(1)) == 13) then
115 scs_m_new.objs(j).doc = list();
119 if omod.sim=="super"|omod.sim=="csuper"|omod.sim(1)=="asuper" then
120 rpar=do_version43(omod.rpar)
121 scs_m_new.objs(j).model.rpar=rpar
124 //@@ Change gr_i of MUX if needed
128 "rectstr=stringbox(txt,orig(1),orig(2),0,style,1);"
129 "if ~exists(''%zoom'') then %zoom=1, end;"
130 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
131 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
132 "xstringb(orig(1)+sz(1)/2-w/2,orig(2)-h-4,txt,w,h,''fill'');"
134 "e.font_style=style;"]
136 if id=="Mux" then id="",end
137 scs_m_new.objs(j).graphics.id=id
138 if (type(scs_m_new.objs(j).graphics.gr_i)==15) then
139 if scs_m_new.objs(j).graphics.gr_i(1) == " " then
140 scs_m_new.objs(j).graphics.gr_i=list(gr_i,scs_m_new.objs(j).graphics.gr_i(2))
143 if scs_m_new.objs(j).graphics.gr_i == " " then
144 scs_m_new.objs(j).graphics.gr_i=gr_i
148 //@@ Change gr_i of DEMUX if needed
149 elseif o.gui=="DEMUX" then
150 gr_i=["txt=''Demux'';"
152 "rectstr=stringbox(txt,orig(1),orig(2),0,style,1);"
153 "if ~exists(''%zoom'') then %zoom=1, end;"
154 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
155 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
156 "xstringb(orig(1)+sz(1)/2-w/2,orig(2)-h-4,txt,w,h,''fill'');"
158 "e.font_style=style;"]
160 if id=="Demux" then id="",end
161 scs_m_new.objs(j).graphics.id=id
162 if (type(scs_m_new.objs(j).graphics.gr_i)==15) then
163 if scs_m_new.objs(j).graphics.gr_i(1) == "" then
164 scs_m_new.objs(j).graphics.gr_i=list(gr_i,scs_m_new.objs(j).graphics.gr_i(2))
167 if scs_m_new.objs(j).graphics.gr_i == "" then
168 scs_m_new.objs(j).graphics.gr_i=gr_i
172 //@@ Change gr_i of FROMWSB
173 elseif o.gui=="FROMWSB" then
174 gr_i=["xstringb(orig(1),orig(2),''From workspace'',sz(1),sz(2),''fill'')"
177 "rectstr=stringbox(txt,orig(1),orig(2),0,style,1);"
178 "if ~exists(''%zoom'') then %zoom=1, end;"
179 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
180 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
181 "xstringb(orig(1)+sz(1)/2-w/2,orig(2)-h-4,txt,w,h,''fill'');"
183 "e.font_style=style;"]
185 scs_m_new.objs(j).graphics.id=id
186 if (type(scs_m_new.objs(j).graphics.gr_i)==15) then
187 scs_m_new.objs(j).graphics.gr_i=list(gr_i,scs_m_new.objs(j).graphics.gr_i(2))
189 scs_m_new.objs(j).graphics.gr_i=gr_i
192 //@@ Change gr_i of TOWS_c
193 elseif o.gui=="TOWS_c" then
194 gr_i=["xstringb(orig(1),orig(2),''To workspace'',sz(1),sz(2),''fill'')"
197 "rectstr=stringbox(txt,orig(1),orig(2),0,style,1);"
198 "if ~exists(''%zoom'') then %zoom=1, end;"
199 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
200 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
201 "xstringb(orig(1)+sz(1)/2-w/2,orig(2)-h-4,txt,w,h,''fill'');"
203 "e.font_style=style;"]
205 scs_m_new.objs(j).graphics.id=id
206 if (type(scs_m_new.objs(j).graphics.gr_i)==15) then
207 scs_m_new.objs(j).graphics.gr_i=list(gr_i,scs_m_new.objs(j).graphics.gr_i(2))
209 scs_m_new.objs(j).graphics.gr_i=gr_i
212 //@@ Change gr_i of INTEGRAL_m if needed
213 elseif o.gui=="INTEGRAL_m" | o.gui=="INTEGRAL" then
214 gr_i=["thick=xget(''thickness'')"
215 "pat=xget(''pattern'')"
217 "xpoly(orig(1)+[0.7;0.62;0.549;0.44;0.364;0.291]*sz(1),orig(2)+[0.947;0.947;0.884;0.321;0.255;0.255]*sz(2),"'lines"')"
220 "rectstr=stringbox(txt,orig(1),orig(2),0,style,1);"
221 "if ~exists(''%zoom'') then %zoom=1, end;"
222 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
223 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
224 "xstringb(orig(1)+sz(1)/2-w/2,orig(2)-h-4,txt,w,h,''fill'');"
226 "e.font_style=style;"
227 "xset(''thickness'',thick)"
228 "xset(''pattern'',pat)"
229 "xset(''font'',fnt(1),fnt(2))"]
230 old_gri=["thick=xget(''thickness'')"
231 "pat=xget(''pattern'')"
233 "xpoly(orig(1)+[0.7;0.62;0.549;0.44;0.364;0.291]*sz(1),orig(2)+[0.947;0.947;0.884;0.321;0.255;0.255]*sz(2),"'lines"')"
234 "xset(''thickness'',thick)"
235 "xset(''pattern'',pat)"
236 "xset(''font'',fnt(1),fnt(2))"
239 if id=="1/s" then id="",end
240 scs_m_new.objs(j).graphics.id=id
241 if (type(scs_m_new.objs(j).graphics.gr_i)==15) then
242 if scs_m_new.objs(j).graphics.gr_i(1) == old_gri then
243 scs_m_new.objs(j).graphics.gr_i=list(gr_i,scs_m_new.objs(j).graphics.gr_i(2))
246 if scs_m_new.objs(j).graphics.gr_i == old_gri then
247 scs_m_new.objs(j).graphics.gr_i=gr_i
251 //@@ Change gr_i of PRODUCT if needed
252 elseif o.gui=="PRODUCT" then
253 gr_i=["[x,y,typ]=standard_inputs(o) ";
255 "if ~arg1.graphics.flip then dd=6*sz(1)/8,de=-sz(1)/8,end"
256 "for k=1:size(x,''*'')";
257 "if size(sgn,1)>1 then"
259 " xstring(orig(1)+dd,y(k)-4,''*'')";
261 " xstring(orig(1)+dd,y(k)-4,''/'')";
265 "xx=sz(1)*[.8 .8 .4 .4]+orig(1)+de";
266 "yy=sz(2)*[.2 .8 .8 .2]+orig(2)";
267 "xpoly(xx,yy,''lines'')"
270 "rectstr=stringbox(txt,orig(1),orig(2),0,style,1);"
271 "if ~exists(''%zoom'') then %zoom=1, end;"
272 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
273 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
274 "xstringb(orig(1)+sz(1)/2-w/2,orig(2)-h-4,txt,w,h,''fill'');"
276 "e.font_style=style;"]
277 old_gri=["[x,y,typ]=standard_inputs(o) ";
279 "if ~arg1.graphics.flip then dd=6*sz(1)/8,de=-sz(1)/8,end"
280 "for k=1:size(x,''*'')";
281 "if size(sgn,1)>1 then"
283 " xstring(orig(1)+dd,y(k)-4,''*'')";
285 " xstring(orig(1)+dd,y(k)-4,''/'')";
289 "xx=sz(1)*[.8 .8 .4 .4]+orig(1)+de";
290 "yy=sz(2)*[.2 .8 .8 .2]+orig(2)";
291 "xpoly(xx,yy,''lines'')"]
293 if id=="1/s" then id="",end
294 scs_m_new.objs(j).graphics.id=id
295 if (type(scs_m_new.objs(j).graphics.gr_i)==15) then
296 if scs_m_new.objs(j).graphics.gr_i(1) == old_gri then
297 scs_m_new.objs(j).graphics.gr_i=list(gr_i,scs_m_new.objs(j).graphics.gr_i(2))
300 if scs_m_new.objs(j).graphics.gr_i == old_gri then
301 scs_m_new.objs(j).graphics.gr_i=gr_i
305 //@@ Change gr_i of DERIV if needed
306 elseif o.gui=="DERIV" then
307 gr_i=["xstringb(orig(1),orig(2),'' du/dt '',sz(1),sz(2),''fill'');"
310 "rectstr=stringbox(txt,orig(1),orig(2),0,style,1);"
311 "if ~exists(''%zoom'') then %zoom=1, end;"
312 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
313 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
314 "xstringb(orig(1)+sz(1)/2-w/2,orig(2)-h-4,txt,w,h,''fill'');"
316 "e.font_style=style;"]
317 old_gri=["xstringb(orig(1),orig(2),'' du/dt '',sz(1),sz(2),''fill'');"]
319 if id=="s" then id="",end
320 scs_m_new.objs(j).graphics.id=id
321 if (type(scs_m_new.objs(j).graphics.gr_i)==15) then
322 if scs_m_new.objs(j).graphics.gr_i(1) == old_gri then
323 scs_m_new.objs(j).graphics.gr_i=list(gr_i,scs_m_new.objs(j).graphics.gr_i(2))
326 if scs_m_new.objs(j).graphics.gr_i(1) == old_gri then
327 scs_m_new.objs(j).graphics.gr_i=gr_i
331 //@@ Change gr_i of JKFLIPFLOP if needed
332 elseif o.gui=="JKFLIPFLOP" then
333 gr_i=["[x,y,typ]=standard_inputs(o) ";
334 "dd=sz(1)/8,de=5.5*sz(1)/8";
336 "if ~exists(''%zoom'') then %zoom=1, end;"
337 "rectstr=stringbox(txt,orig(1)+dd,y(1)-4,0,1,1);"
338 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
339 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
340 "xstringb(orig(1)+dd,y(1)-4,txt,w,h,''fill'')";
342 "rectstr=stringbox(txt,orig(1)+dd,y(2)-4,0,1,1);"
343 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
344 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
345 "xstringb(orig(1)+dd,y(2)-4,txt,w,h,''fill'')";
347 "rectstr=stringbox(txt,orig(1)+dd,y(3)-4,0,1,1);"
348 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
349 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
350 "xstringb(orig(1)+dd,y(3)-4,txt,w,h,''fill'')";
351 "[x,y,typ]=standard_outputs(o) ";
353 "rectstr=stringbox(txt,orig(1)+de,y(1)-4,0,1,1);"
354 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
355 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
356 "xstringb(orig(1)+de,y(1)-4,txt,w,h,''fill'')";
358 "rectstr=stringbox(txt,orig(1)+4.5*dd,y(2)-4,0,1,1);"
359 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
360 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
361 "xstringb(orig(1)+4.5*dd,y(2)-4,txt,w,h,''fill'')";
362 "txt=''JK FLIP-FLOP'';"
364 "rectstr=stringbox(txt,orig(1),orig(2),0,style,1);"
365 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
366 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
367 "xstringb(orig(1)+sz(1)/2-w/2,orig(2)-h-4,txt,w,h,''fill'');"
369 "e.font_style=style;"]
370 old_gri=["[x,y,typ]=standard_inputs(o) ";
371 "dd=sz(1)/8,de=6*sz(1)/8";
372 "xstring(orig(1)+dd,y(1)-4,''J'')";
373 "xstring(orig(1)+dd,y(2)-4,''clk'')";
374 "xstring(orig(1)+dd,y(3)-4,''K'')";
375 "[x,y,typ]=standard_outputs(o) ";
376 "xstring(orig(1)+de,y(1)-4,''Q'')";
377 "xstring(orig(1)+5*dd,y(2)-4,''!Q'')"]
379 if id=="JK FLIP-FLOP" then id="",end
380 scs_m_new.objs(j).graphics.id=id
381 if (type(scs_m_new.objs(j).graphics.gr_i)==15) then
382 if scs_m_new.objs(j).graphics.gr_i(1) == old_gri then
383 scs_m_new.objs(j).graphics.gr_i=list(gr_i,scs_m_new.objs(j).graphics.gr_i(2))
386 if scs_m_new.objs(j).graphics.gr_i(1) == old_gri then
387 scs_m_new.objs(j).graphics.gr_i=gr_i
391 //@@ Change gr_i of SRFLIPFLOP if needed
392 elseif o.gui=="SRFLIPFLOP" then
393 gr_i=["[x,y,typ]=standard_inputs(o) ";
394 "dd=sz(1)/8,de=5.5*sz(1)/8";
396 "if ~exists(''%zoom'') then %zoom=1, end;"
397 "rectstr=stringbox(txt,orig(1)+dd,y(1)-4,0,1,1);"
398 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
399 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
400 "xstringb(orig(1)+dd,y(1)-4,txt,w,h,''fill'')";
402 "rectstr=stringbox(txt,orig(1)+dd,y(2)-4,0,1,1);"
403 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
404 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
405 "xstringb(orig(1)+dd,y(2)-4,txt,w,h,''fill'')";
406 "[x,y,typ]=standard_outputs(o) ";
408 "rectstr=stringbox(txt,orig(1)+de,y(1)-4,0,1,1);"
409 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
410 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
411 "xstringb(orig(1)+de,y(1)-4,txt,w,h,''fill'')";
413 "rectstr=stringbox(txt,orig(1)+4.5*dd,y(2)-4,0,1,1);"
414 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
415 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
416 "xstringb(orig(1)+4.5*dd,y(2)-4,txt,w,h,''fill'')";
417 "txt=''SR FLIP-FLOP'';"
419 "rectstr=stringbox(txt,orig(1),orig(2),0,style,1);"
420 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
421 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
422 "xstringb(orig(1)+sz(1)/2-w/2,orig(2)-h-4,txt,w,h,''fill'');"
424 "e.font_style=style;"]
425 old_gri=["[x,y,typ]=standard_inputs(o) ";
426 "dd=sz(1)/8,de=6*sz(1)/8";
427 "xstring(orig(1)+dd,y(1)-4,''S'')";
428 "xstring(orig(1)+dd,y(2)-4,''R'')";
429 "[x,y,typ]=standard_outputs(o) ";
430 "xstring(orig(1)+de,y(1)-4,''Q'')";
431 "xstring(orig(1)+5*dd,y(2)-4,''!Q'')"]
433 if id=="SR FLIP-FLOP" then id="",end
434 scs_m_new.objs(j).graphics.id=id
435 if (type(scs_m_new.objs(j).graphics.gr_i)==15) then
436 if scs_m_new.objs(j).graphics.gr_i(1) == old_gri then
437 scs_m_new.objs(j).graphics.gr_i=list(gr_i,scs_m_new.objs(j).graphics.gr_i(2))
440 if scs_m_new.objs(j).graphics.gr_i(1) == old_gri then
441 scs_m_new.objs(j).graphics.gr_i=gr_i
445 //@@ Change gr_i of DLATCH if needed
446 elseif o.gui=="DLATCH" then
447 gr_i=["[x,y,typ]=standard_inputs(o) ";
448 "dd=sz(1)/8,de=5.5*sz(1)/8";
450 "if ~exists(''%zoom'') then %zoom=1, end;"
451 "rectstr=stringbox(txt,orig(1)+dd,y(1)-4,0,1,1);"
452 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
453 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
454 "xstringb(orig(1)+dd,y(1)-4,txt,w,h,''fill'')";
456 "rectstr=stringbox(txt,orig(1)+dd,y(2)-4,0,1,1);"
457 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
458 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
459 "xstringb(orig(1)+dd,y(2)-4,txt,w,h,''fill'')";
461 "rectstr=stringbox(txt,orig(1)+de,y(1)-4,0,1,1);"
462 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
463 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
464 "xstringb(orig(1)+de,y(1)-4,txt,w,h,''fill'')";
466 "rectstr=stringbox(txt,orig(1)+4.5*dd,y(2)-4,0,1,1);"
467 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
468 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
469 "xstringb(orig(1)+4.5*dd,y(2)-4,txt,w,h,''fill'')";
472 "rectstr=stringbox(txt,orig(1),orig(2),0,style,1);"
473 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
474 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
475 "xstringb(orig(1)+sz(1)/2-w/2,orig(2)-h-4,txt,w,h,''fill'');"
477 "e.font_style=style;"]
478 old_gri=["[x,y,typ]=standard_inputs(o) ";
479 "dd=sz(1)/8,de=6*sz(1)/8";
480 "xstring(orig(1)+dd,y(1)-4,''D'')";
481 "xstring(orig(1)+dd,y(2)-4,''C'')";
482 "xstring(orig(1)+de,y(1)-4,''Q'')";
483 "xstring(orig(1)+5*dd,y(2)-4,''!Q'')"]
485 if id=="DLATCH" then id="",end
486 scs_m_new.objs(j).graphics.id=id
487 if (type(scs_m_new.objs(j).graphics.gr_i)==15) then
488 if scs_m_new.objs(j).graphics.gr_i(1) == old_gri then
489 scs_m_new.objs(j).graphics.gr_i=list(gr_i,scs_m_new.objs(j).graphics.gr_i(2))
492 if scs_m_new.objs(j).graphics.gr_i(1) == old_gri then
493 scs_m_new.objs(j).graphics.gr_i=gr_i
497 //@@ Change gr_i of DFLIPFLOP if needed
498 elseif o.gui=="DFLIPFLOP" then
499 gr_i=["[x,y,typ]=standard_inputs(o) ";
500 "dd=sz(1)/8,de=5.5*sz(1)/8";
502 "if ~exists(''%zoom'') then %zoom=1, end;"
503 "rectstr=stringbox(txt,orig(1)+dd,y(1)-4,0,1,1);"
504 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
505 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
506 "xstringb(orig(1)+dd,y(1)-4,txt,w,h,''fill'')";
508 "rectstr=stringbox(txt,orig(1)+dd,y(2)-4,0,1,1);"
509 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
510 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
511 "xstringb(orig(1)+dd,y(2)-4,txt,w,h,''fill'')";
513 "rectstr=stringbox(txt,orig(1)+dd,y(3)-4,0,1,1);"
514 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
515 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
516 "xstringb(orig(1)+dd,y(3)-4,txt,w,h,''fill'')";
517 "[x,y,typ]=standard_outputs(o) ";
519 "rectstr=stringbox(txt,orig(1)+de,y(1)-4,0,1,1);"
520 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
521 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
522 "xstringb(orig(1)+de,y(1)-4,txt,w,h,''fill'')";
524 "rectstr=stringbox(txt,orig(1)+4.5*dd,y(2)-4,0,1,1);"
525 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
526 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
527 "xstringb(orig(1)+4.5*dd,y(2)-4,txt,w,h,''fill'')";
528 "txt=''D FLIP-FLOP'';"
530 "rectstr=stringbox(txt,orig(1),orig(2),0,style,1);"
531 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
532 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
533 "xstringb(orig(1)+sz(1)/2-w/2,orig(2)-h-4,txt,w,h,''fill'');"
535 "e.font_style=style;"]
536 old_gri=["[x,y,typ]=standard_inputs(o) ";
537 "dd=sz(1)/8,de=6*sz(1)/8";
538 "xstring(orig(1)+dd,y(1)-4,''D'')";
539 "xstring(orig(1)+dd,y(2)-4,''clk'')";
540 "xstring(orig(1)+dd,y(3)-4,''en'')";
541 "[x,y,typ]=standard_outputs(o) ";
542 "xstring(orig(1)+de,y(1)-4,''Q'')";
543 "xstring(orig(1)+5*dd,y(2)-4,''!Q'')"]
545 if id=="D FLIP-FLOP" then id="",end
546 scs_m_new.objs(j).graphics.id=id
547 if (type(scs_m_new.objs(j).graphics.gr_i)==15) then
548 if scs_m_new.objs(j).graphics.gr_i(1) == old_gri then
549 scs_m_new.objs(j).graphics.gr_i=list(gr_i,scs_m_new.objs(j).graphics.gr_i(2))
552 if scs_m_new.objs(j).graphics.gr_i(1) == old_gri then
553 scs_m_new.objs(j).graphics.gr_i=gr_i
557 //@@ Change gr_i of CLKGotoTagVisibility if needed
558 elseif o.gui=="CLKGotoTagVisibility" then
559 gr_i=["xstringb(orig(1),orig(2),[''{''+arg1.graphics.exprs(1)+''}''],sz(1),sz(2),''fill'');";
560 "wd=xget(''wdim'').*[1.016,1.12];";
561 "thick=xget(''thickness'');xset(''thickness'',2);";
562 "p=wd(2)/wd(1);p=1;";
563 "xarcs([orig(1)+0.05*sz(1);";
564 "orig(2)+0.95*sz(2);";
568 "360*64],scs_color(5));";
569 "txt=[''Goto Tag'';''Visibility'' ];"
572 "axes_font_style = gh_axes.font_style ;"
573 "axes_font_size = gh_axes.font_size ;"
574 "gh_axes.font_style = 5;"
575 "gh_axes.font_size = 1;"
576 "rectstr=stringbox(txt,orig(1),orig(2),0,style,1);"
577 "if ~exists(''%zoom'') then %zoom=1, end;"
578 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
579 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
580 "xstringb(orig(1)+sz(1)/2-w/2,orig(2)-h-5,txt,w,h,''fill'');"
581 "gh_axes.font_style = axes_font_style ;"
582 "gh_axes.font_size = axes_font_size ;"
583 "xset(''thickness'',thick)"]
584 old_gri=["xstringb(orig(1),orig(2),[''{''+arg1.graphics.exprs(1)+''}''],sz(1),sz(2),''fill'');";
585 "wd=xget(''wdim'').*[1.016,1.12];";
586 "thick=xget(''thickness'');xset(''thickness'',2);";
587 "p=wd(2)/wd(1);p=1;";
588 "xarcs([orig(1)+0.05*sz(1);";
589 "orig(2)+0.95*sz(2);";
593 "360*64],scs_color(5));";
594 "xset(''thickness'',thick)"]
596 if id==["Goto Tag";"Visibility"] then id="",end
597 scs_m_new.objs(j).graphics.id=id
598 if (type(scs_m_new.objs(j).graphics.gr_i)==15) then
599 if scs_m_new.objs(j).graphics.gr_i(1) == old_gri then
600 scs_m_new.objs(j).graphics.gr_i=list(gr_i,scs_m_new.objs(j).graphics.gr_i(2))
603 if scs_m_new.objs(j).graphics.gr_i(1) == old_gri then
604 scs_m_new.objs(j).graphics.gr_i=gr_i
608 //@@ Change gr_i of GotoTagVisibilityMO if needed
609 elseif o.gui=="GotoTagVisibilityMO" then
610 gr_i=["xstringb(orig(1),orig(2),[''{''+arg1.graphics.exprs(1)+''}''],sz(1),sz(2),''fill'');";
611 "wd=xget(''wdim'').*[1.016,1.12];";
612 "thick=xget(''thickness'');xset(''thickness'',2);";
613 "p=wd(2)/wd(1);p=1;";
614 "xarcs([orig(1)+0.05*sz(1);";
615 "orig(2)+0.95*sz(2);";
619 "360*64],scs_color(3));";
620 "txt=[''Goto Tag'';''Visibility'' ];"
623 "axes_font_style = gh_axes.font_style ;"
624 "axes_font_size = gh_axes.font_size ;"
625 "gh_axes.font_style = 5;"
626 "gh_axes.font_size = 1;"
627 "rectstr=stringbox(txt,orig(1),orig(2),0,style,1);"
628 "if ~exists(''%zoom'') then %zoom=1, end;"
629 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
630 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
631 "xstringb(orig(1)+sz(1)/2-w/2,orig(2)-h-5,txt,w,h,''fill'');"
632 "gh_axes.font_style = axes_font_style ;"
633 "gh_axes.font_size = axes_font_size ;"
634 "xset(''thickness'',thick)"]
635 old_gri=["xstringb(orig(1),orig(2),[''{''+arg1.graphics.exprs(1)+''}''],sz(1),sz(2),''fill'');";
636 "wd=xget(''wdim'').*[1.016,1.12];";
637 "thick=xget(''thickness'');xset(''thickness'',2);";
638 "p=wd(2)/wd(1);p=1;";
639 "xarcs([orig(1)+0.05*sz(1);";
640 "orig(2)+0.95*sz(2);";
644 "360*64],scs_color(3));";
645 "xset(''thickness'',thick)"]
647 if id==["Goto Tag";"Visibility"] then id="",end
648 scs_m_new.objs(j).graphics.id=id
649 if (type(scs_m_new.objs(j).graphics.gr_i)==15) then
650 if scs_m_new.objs(j).graphics.gr_i(1) == old_gri then
651 scs_m_new.objs(j).graphics.gr_i=list(gr_i,scs_m_new.objs(j).graphics.gr_i(2))
654 if scs_m_new.objs(j).graphics.gr_i(1) == old_gri then
655 scs_m_new.objs(j).graphics.gr_i=gr_i
659 //@@ Change gr_i of GotoTagVisibility if needed
660 elseif o.gui=="GotoTagVisibility" then
661 gr_i=["xstringb(orig(1),orig(2),[''{''+arg1.graphics.exprs(1)+''}''],sz(1),sz(2),''fill'');"
662 "txt=[''Goto Tag'';''Visibility'' ];"
665 "axes_font_style = gh_axes.font_style ;"
666 "axes_font_size = gh_axes.font_size ;"
667 "gh_axes.font_style = 5;"
668 "gh_axes.font_size = 1;"
669 "rectstr=stringbox(txt,orig(1),orig(2),0,style,1);"
670 "if ~exists(''%zoom'') then %zoom=1, end;"
671 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
672 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
673 "xstringb(orig(1)+sz(1)/2-w/2,orig(2)-h-5,txt,w,h,''fill'');"
674 "gh_axes.font_style = axes_font_style ;"
675 "gh_axes.font_size = axes_font_size ;"]
676 old_gri=["xstringb(orig(1),orig(2),[''{''+arg1.graphics.exprs(1)+''}''],sz(1),sz(2),''fill'');"]
678 if id==["Goto Tag";"Visibility"] then id="",end
679 scs_m_new.objs(j).graphics.id=id
680 if (type(scs_m_new.objs(j).graphics.gr_i)==15) then
681 if scs_m_new.objs(j).graphics.gr_i(1) == old_gri then
682 scs_m_new.objs(j).graphics.gr_i=list(gr_i,scs_m_new.objs(j).graphics.gr_i(2))
685 if scs_m_new.objs(j).graphics.gr_i(1) == old_gri then
686 scs_m_new.objs(j).graphics.gr_i=gr_i
690 //@@ Change gr_i of Inductor if needed
691 elseif o.gui=="Inductor" then
692 gr_i=["tt=linspace(0.04,0.96,100)'';"
693 "xpoly(tt*sz(1)+orig(1),+orig(2)+abs(sin(18*(tt-0.04)))*sz(2),""lines"");";
694 "xx=orig(1)+[0 0.04 0.04 0.04 0]*sz(1);";
695 "yy=orig(2)+[1/2 1/2 0 1/2 1/2]*sz(2);";
697 "xx=orig(1)+[0.96 0.96 1 0.96 0.96 ]*sz(1);";
698 "yy=orig(2)+[abs(sin(18*0.92)) 1/2 1/2 1/2 abs(sin(18*0.92))]*sz(2);";
702 "rectstr=stringbox(txt,orig(1),orig(2),0,style,1);"
703 "if ~exists(''%zoom'') then %zoom=1, end;"
704 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
705 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
706 "xstringb(orig(1)+sz(1)/2-w/2,orig(2)-h-4,txt,w,h,''fill'');"
708 old_gri=["tt=linspace(0.04,0.96,100)'';"
709 "xpoly(tt*sz(1)+orig(1),+orig(2)+abs(sin(18*(tt-0.04)))*sz(2),""lines"");";
710 "xx=orig(1)+[0 0.04 0.04 0.04 0]*sz(1);";
711 "yy=orig(2)+[1/2 1/2 0 1/2 1/2]*sz(2);";
713 "xx=orig(1)+[0.96 0.96 1 0.96 0.96 ]*sz(1);";
714 "yy=orig(2)+[abs(sin(18*0.92)) 1/2 1/2 1/2 abs(sin(18*0.92))]*sz(2);";
716 "rect=xstringl(0,0,''L=''+L)"
717 "xstring(orig(1)+(sz(1)-rect(3))/2,orig(2)-rect(4)*1.2,''L=''+L)"]
718 if (type(scs_m_new.objs(j).graphics.gr_i)==15) then
719 if scs_m_new.objs(j).graphics.gr_i(1) == old_gri then
720 scs_m_new.objs(j).graphics.gr_i=list(gr_i,scs_m_new.objs(j).graphics.gr_i(2))
723 if scs_m_new.objs(j).graphics.gr_i(1) == old_gri then
724 scs_m_new.objs(j).graphics.gr_i=gr_i
728 //@@ Change gr_i of Capacitor if needed
729 elseif o.gui=="Capacitor" then
730 gr_i=["xset(''thickness'',2)"
731 "xx=orig(1)+[0 1/3 1/3 1/3 ]*sz(1);";
732 "yy=orig(2)+[1/2 1/2 1 0]*sz(2);";
734 "xsegs(orig(1)+ sz(1)*2/3*[1 1 1 3/2],orig(2)+(sz(2)*1/2)*[2 0 1 1],0);";
736 " xrects([orig(1)+sz(1)*1/2;orig(2)+sz(2);sz(1)*1/6;sz(2)],scs_color(33));"
737 " xstring(orig(1)+sz(1)*1/12,orig(2)+sz(2)*3/4,''+'');";
738 " xstring(orig(1)+sz(1)*7/8,orig(2)+sz(2)*3/4,''-'');";
740 " xrects([orig(1)+sz(1)*1/3;orig(2)+sz(2);sz(1)*1/6;sz(2)],scs_color(33));"
741 " xstring(orig(1)+sz(1)*1/12,orig(2)+sz(2)*3/4,''-'');";
742 " xstring(orig(1)+sz(1)*7/8,orig(2)+sz(2)*3/4,''+'');";
746 "rectstr=stringbox(txt,orig(1),orig(2),0,style,1);"
747 "if ~exists(''%zoom'') then %zoom=1, end;"
748 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
749 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
750 "xstringb(orig(1)+sz(1)/2-w/2,orig(2)-h-4,txt,w,h,''fill'');"
752 "e.font_style=style;"]
753 old_gri=["xset(''thickness'',2)"
754 "xx=orig(1)+[0 1/3 1/3 1/3 ]*sz(1);";
755 "yy=orig(2)+[1/2 1/2 1 0]*sz(2);";
757 "xsegs(orig(1)+ sz(1)*2/3*[1 1 1 3/2],orig(2)+(sz(2)*1/2)*[2 0 1 1],0);";
759 " xrects([orig(1)+sz(1)*1/2;orig(2)+sz(2);sz(1)*1/6;sz(2)],scs_color(33));"
760 " xstring(orig(1)+sz(1)*1/12,orig(2)+sz(2)*3/4,''+'');";
761 " xstring(orig(1)+sz(1)*7/8,orig(2)+sz(2)*3/4,''-'');";
763 " xrects([orig(1)+sz(1)*1/3;orig(2)+sz(2);sz(1)*1/6;sz(2)],scs_color(33));"
764 " xstring(orig(1)+sz(1)*1/12,orig(2)+sz(2)*3/4,''-'');";
765 " xstring(orig(1)+sz(1)*7/8,orig(2)+sz(2)*3/4,''+'');";
767 "rect=xstringl(0,0,''C=''+C)"
768 "xstring(orig(1)+(sz(1)-rect(3))/2,orig(2)-rect(4)*1.2,''C= ''+C);"]
769 if (type(scs_m_new.objs(j).graphics.gr_i)==15) then
770 if scs_m_new.objs(j).graphics.gr_i(1) == old_gri then
771 scs_m_new.objs(j).graphics.gr_i=list(gr_i,scs_m_new.objs(j).graphics.gr_i(2))
774 if scs_m_new.objs(j).graphics.gr_i(1) == old_gri then
775 scs_m_new.objs(j).graphics.gr_i=gr_i
779 //@@ Change gr_i of Resistor if needed
780 elseif o.gui=="Resistor" then
781 gr_i=["xx=[0,1,1,7,7,8,7,7,1,1]/8;";
782 "yy=[1,1,0,0,1,1,1,2,2,1]/2;";
783 "xpoly(orig(1)+xx*sz(1),orig(2)+yy*sz(2)); "
786 "rectstr=stringbox(txt,orig(1),orig(2),0,style,1);"
787 "if ~exists(''%zoom'') then %zoom=1, end;"
788 "w=(rectstr(1,3)-rectstr(1,2))*%zoom;"
789 "h=(rectstr(2,2)-rectstr(2,4))*%zoom;"
790 "xstringb(orig(1)+sz(1)/2-w/2,orig(2)-h-4,txt,w,h,''fill'');"
792 old_gri=["xx=[0,1,1,7,7,8,7,7,1,1]/8;";
793 "yy=[1,1,0,0,1,1,1,2,2,1]/2;";
794 "xpoly(orig(1)+xx*sz(1),orig(2)+yy*sz(2)); "
795 "rect=xstringl(0,0,''R=''+R)"
796 "xstring(orig(1)+(sz(1)-rect(3))/2,orig(2)-rect(4)*1.2,''R=''+R);"]
797 if (type(scs_m_new.objs(j).graphics.gr_i)==15) then
798 if scs_m_new.objs(j).graphics.gr_i(1) == old_gri then
799 scs_m_new.objs(j).graphics.gr_i=list(gr_i,scs_m_new.objs(j).graphics.gr_i(2))
802 if scs_m_new.objs(j).graphics.gr_i(1) == old_gri then
803 scs_m_new.objs(j).graphics.gr_i=gr_i
813 //*** update scope ***//
814 function scs_m_new=do_version42(scs_m)
817 for j=1:n //loop on objects
819 if typeof(o)=="Block" then
822 if omod.sim=="super"|omod.sim=="csuper" then
823 rpar=do_version42(omod.rpar)
824 scs_m_new.objs(j).model.rpar=rpar
825 //name of gui and sim list change
826 elseif o.gui=="SCOPE_f" then
827 scs_m_new.objs(j).gui="CSCOPE"
828 scs_m_new.objs(j).model.dstate=[]
829 //Alan's patch 01/10/07 : remove the last parameter
830 // (inheritance not used in cscope)
831 ipar = scs_m_new.objs(j).model.ipar(:);
832 scs_m_new.objs(j).model.ipar = ipar(1:$-1);
833 scs_m_new.objs(j).model.sim=list("cscope", 4)
834 in = scs_m_new.objs(j).model.in(:);
837 scs_m_new.objs(j).model.in2 = in2;
838 scs_m_new.objs(j).model.intyp = in2;
839 //Alan's patch 04/10/07 : update exprs
840 exprs = scs_m.objs(j).graphics.exprs;
841 if size(exprs)<9 then exprs(9)="0",end // compatibility
842 if size(exprs)<10 then exprs(10)=emptystr(),end // compatibility
843 scs_m_new.objs(j).graphics.exprs=exprs;
844 elseif o.gui=="CSCOPE" then
845 //Alan's patch 04/10/07 : update exprs
846 exprs = scs_m.objs(j).graphics.exprs;
847 if size(exprs)<10 then exprs(10)=emptystr(),end // compatibility
848 scs_m_new.objs(j).graphics.exprs=exprs;
849 elseif o.gui=="BOUNCEXY" then
850 in = scs_m_new.objs(j).model.in(:);
853 scs_m_new.objs(j).model.in2 = in2;
854 scs_m_new.objs(j).model.intyp = in2;
855 elseif o.gui=="MSCOPE_f" then
856 //Alan's patch 04/10/07 : update exprs
857 exprs = scs_m.objs(j).graphics.exprs;
858 if size(exprs)<10 then exprs(10)="0",end // compatibility
859 if size(exprs)<11 then exprs(11)=emptystr(),end // compatibility
860 scs_m_new.objs(j).graphics.exprs=exprs;
861 scs_m_new.objs(j).gui="CMSCOPE"
862 scs_m_new.objs(j).model.dstate=[]
863 scs_m_new.objs(j).model.sim=list("cmscope", 4)
864 in = scs_m_new.objs(j).model.in(:);
866 B=stripblanks(scs_m.objs(j).graphics.exprs(8));
869 scs_m_new.objs(j).graphics.exprs(8) = B;
870 rpar=scs_m_new.objs(j).model.rpar(:);
871 N=scs_m_new.objs(j).model.ipar(2);
876 scs_m_new.objs(j).model.rpar = [rpar(1);period(:);rpar(3:size(rpar,1))]
878 scs_m_new.objs(j).model.in2 = in2;
879 scs_m_new.objs(j).model.intyp = in2;
880 elseif o.gui=="ANIMXY_f" then
881 scs_m_new.objs(j).gui="CANIMXY"
882 scs_m_new.objs(j).model.dstate=[]
883 scs_m_new.objs(j).model.sim=list("canimxy", 4)
884 in = scs_m_new.objs(j).model.in(:);
887 scs_m_new.objs(j).model.in2 = in2;
888 scs_m_new.objs(j).model.intyp = in2;
889 scs_m_new.objs(j).graphics.exprs = [string(1);scs_m_new.objs(j).graphics.exprs(:)]
890 scs_m_new.objs(j).model.ipar = [scs_m_new.objs(j).model.ipar(:);1]
891 //Alan's patch 04/10/07 : update exprs
892 exprs = scs_m_new.objs(j).graphics.exprs(:)
893 if size(exprs,"*")==8 then exprs=[1;exprs(1:3);"[]";"[]";exprs(4:8)],end
894 scs_m_new.objs(j).graphics.exprs=exprs;
895 elseif o.gui=="EVENTSCOPE_f" then
896 scs_m_new.objs(j).gui="CEVENTSCOPE"
897 scs_m_new.objs(j).model.dstate=[]
898 scs_m_new.objs(j).model.sim=list("cevscpe", 4)
899 in = scs_m_new.objs(j).model.in(:);
902 scs_m_new.objs(j).model.in2 = in2;
903 scs_m_new.objs(j).model.intyp = in2;
904 elseif o.gui=="FSCOPE_f" then
905 scs_m_new.objs(j).gui="CFSCOPE"
906 scs_m_new.objs(j).model.dstate=[]
907 scs_m_new.objs(j).model.sim=list("cfscope", 4)
908 in = scs_m_new.objs(j).model.in(:);
911 scs_m_new.objs(j).model.in2 = in2;
912 scs_m_new.objs(j).model.intyp = in2;
913 //Alan's patch 04/10/07 : update exprs
914 exprs = scs_m.objs(j).graphics.exprs;
915 if size(exprs)<9 then exprs(9)="0",end // compatibility
916 scs_m_new.objs(j).graphics.exprs=exprs;
917 elseif o.gui=="SCOPXY_f" then
918 scs_m_new.objs(j).gui="CSCOPXY"
919 scs_m_new.objs(j).model.dstate=[]
920 scs_m_new.objs(j).model.sim=list("cscopxy", 4)
921 in = scs_m_new.objs(j).model.in(:);
924 scs_m_new.objs(j).model.in2 = in2;
925 scs_m_new.objs(j).model.intyp = in2;
926 scs_m_new.objs(j).graphics.exprs = [string(1);scs_m_new.objs(j).graphics.exprs(:)]
927 scs_m_new.objs(j).model.ipar = [scs_m_new.objs(j).model.ipar(:);1]
928 elseif o.gui=="CMSCOPE" then
929 //Alan's patch 04/10/07 : update exprs
930 exprs = scs_m.objs(j).graphics.exprs;
931 if size(exprs)<11 then exprs(11)=emptystr(),end // compatibility
932 scs_m_new.objs(j).graphics.exprs=exprs;
933 scs_m_new.objs(j).model.dstate=[]
934 in = scs_m_new.objs(j).model.in(:);
936 B=stripblanks(scs_m.objs(j).graphics.exprs(8));
939 scs_m_new.objs(j).graphics.exprs(8)=B;
940 rpar=scs_m_new.objs(j).model.rpar(:);
941 N=scs_m_new.objs(j).model.ipar(2);
946 scs_m_new.objs(j).model.rpar = [rpar(1);period(:);rpar(3:size(rpar,1))]
948 scs_m_new.objs(j).model.in2 = in2;
949 scs_m_new.objs(j).model.intyp = in2;
950 elseif o.gui=="IN_f" then
951 scs_m_new.objs(j).model.out = -1;
952 scs_m_new.objs(j).model.out2 = -2;
953 scs_m_new.objs(j).model.outtyp = -1;
954 elseif o.gui=="OUT_f" then
955 scs_m_new.objs(j).model.in = -1;
956 scs_m_new.objs(j).model.in2 = -2;
957 scs_m_new.objs(j).model.intyp = -1;
958 elseif o.gui=="INIMPL_f" then
959 scs_m_new.objs(j).model.out = -1;
960 scs_m_new.objs(j).model.out2 = 1;
961 scs_m_new.objs(j).model.outtyp = -1;
962 elseif o.gui=="OUTIMPL_f" then
963 scs_m_new.objs(j).model.in = -1;
964 scs_m_new.objs(j).model.in2 = 1;
965 scs_m_new.objs(j).model.intyp = -1;
971 function scs_m_new=do_version273(scs_m)
974 for i=1:n //loop on objects
976 if typeof(o)=="Block" then
979 if T($)<>"equations" then
981 scicos_setfield(1,T,omod)
982 scicos_setfield($+1,list(),omod)
984 if omod.sim=="super"|omod.sim=="csuper" then
985 rpar=do_version273(omod.rpar)
986 scicos_setfield($+1,getfield($,omod),omod)
987 scicos_setfield($-1,0,omod)
989 elseif omod.sim(1)=="ifthel" then // |omod.sim(1)=='eselect' then
990 scicos_setfield($+1,getfield($,omod),omod)
991 scicos_setfield($-1,1,omod)
992 scicos_setfield($-2,1,omod)
994 scicos_setfield($+1,getfield($,omod),omod)
995 scicos_setfield($-1,0,omod)
1001 scicos_setfield(1,xx,omod)
1004 elseif typeof(o)=="Link" then
1005 if size(o.from,"*")==2 then o.from(3)=0;end
1006 if size(o.to,"*")==2 then o.to(3)=1;end
1013 function scs_m_new=do_version272(scs_m)
1016 for i=1:lstsize(scs_m.objs)
1018 if typeof(scs_m.objs(i))=="Block" then
1019 grphic=scs_m.objs(i).graphics
1020 chmps=size(getfield(1,grphic))
1021 if or(getfield(1,grphic)=="in_implicit")&..
1022 size(grphic.in_implicit,"*")==size(grphic.pin,"*") then
1023 in_implicit=grphic.in_implicit
1026 in_implicit=I(ones(grphic.pin(:)));
1029 if or(getfield(1,grphic)=="out_implicit")&..
1030 size(grphic.out_implicit,"*")==size(grphic.pout,"*") then
1031 out_implicit=grphic.out_implicit
1034 out_implicit=I(ones(grphic.pout(:)));
1037 scs_m_new.objs(i).graphics=scicos_new(["graphics","orig","sz","flip","exprs","pin",..
1038 "pout","pein","peout","gr_i","id","in_implicit","out_implicit"],..
1039 grphic.orig,grphic.sz,grphic.flip,grphic.exprs,grphic.pin,..
1040 grphic.pout,grphic.pein,grphic.peout,grphic.gr_i,grphic.id,..
1041 in_implicit,out_implicit)
1043 if or(scs_m_new.objs(i).model.sim==["super","csuper"]) then
1044 rpar=do_version272(scs_m_new.objs(i).model.rpar)
1045 scs_m_new.objs(i).model.rpar=rpar
1051 function scs_m_new=do_version271(scs_m)
1054 for i=1:n //loop on objects
1056 if typeof(o)=="Block" then
1058 if omod.sim=="super"|omod.sim=="csuper" then
1059 rpar=do_version271(omod.rpar)
1060 scicos_setfield($+1,0,omod)
1062 elseif omod.sim=="zcross" then
1063 scicos_setfield($+1,omod.in,omod)
1064 omod.sim=list(omod.sim,1)
1065 elseif omod.sim=="lusat" then
1066 scicos_setfield($+1,2*omod.in,omod)
1067 omod.sim=list(omod.sim,1)
1069 scicos_setfield($+1,0,omod)
1071 scicos_setfield(1,[getfield(1,omod),"nzcross"],omod)
1078 function scs_m=do_version251(scs_m)
1083 if o(1)=="Block" then
1085 if model(1)=="super"|model(1)=="csuper" then
1086 model(8)=do_version251(model(8))
1089 elseif o(5)=="SOM_f" then
1090 if and(model(8)==1) then
1092 model(1)=list("plusblk",2)
1096 scs_m(k)(3)(1)=list("sum",2)
1099 elseif o(5)=="AFFICH_f" then
1100 scs_m(k)(3)(7)=[0;-1;0;0;1;1]
1101 scs_m(k)(2)(9)=["xset(''font'',ipar(1),ipar(2))";
1102 "str='' ''+part(''0'',ones(1,ipar(5)-ipar(6)-2))+''.''+part(''0'',ones(1,ipar(6)))"
1103 "rr=xstringl(orig(1),orig(2),str)"
1104 "xstring(orig(1)+max(0,(sz(1)-rr(3))/2),orig(2)+max(0,(sz(2)-rr(4))/2),str)"]
1105 elseif o(5)=="c_block" then
1106 model(1)(2)=model(1)(2)-int(model(1)(2)/1000)*1000+2000
1108 tt=scs_m(k)(2)(4)(2)
1109 ii=grep(tt,"machine.h")
1110 if size(ii,"*")==1 then
1111 tt(ii)="#include <machine.h>",
1112 scs_m(k)(2)(4)(2)=tt
1115 elseif o(1)=="Link" then
1116 if size(o(2),"*")==1 then
1117 o(2)=o(2)*[1;1];o(3)=o(3)*[1;1];
1123 messagebox(["Diagram contains obsolete signed blocks sum"
1124 "They are drawn in brown, they work as before but,"
1125 "please replace them with the new block sum"],"modal")
1129 function scs_m=do_version231(scs_m)
1130 //2.3.1 to 2.4 version
1131 if size(scs_m(1))<5 then scs_m(1)(5)=" ",end //compatibility
1132 if type(scs_m(1)(5))<>10 then scs_m(1)(5)=" ",end //compatibility
1133 if size(scs_m(1))<6 then //compatibility
1136 wpar(7)=list(%t,[0.8 0.8 0.8])
1143 if size(scs_m(1)(1),"*") <4 then scs_m(1)(1)=[scs_m(1)(1),0,0],end //compatibility
1146 scs_m(1)(1)(2)=max(scs_m(1)(1)(2),450)
1147 if size(scs_m(1))<6 then
1148 options=default_options()
1149 doc=list() //documentation structure
1159 if size(wsiz,"*")<6 then //compatibility
1160 if size(wsiz,"*")<4 then wsiz(3)=0;wsiz(4)=0;end
1161 wsiz(5)=wsiz(1);wsiz(6)=wsiz(2);
1164 if type(scs_m(1)(7))==15 then //options
1166 options=default_options()
1167 options("3D")(1)=old_opt(1)
1168 options("Cmap")=old_opt(2)
1175 if o(1)=="Block" then
1177 if model(1)=="super"|model(1)=="csuper" then
1178 model(8)=do_version231(model(8))
1181 elseif model(1)(1)=="ifthel" then
1182 model(1)=list("ifthel",-1)
1184 elseif model(1)(1)=="eselect" then
1185 model(1)=list("eselect",-1)
1193 function x_new=do_version23(scs_m)
1200 if o(1)=="Link" then
1201 elseif o(1)=="Block" then
1203 if model(1)=="super"|model(1)=="csuper" then
1204 model(8)=do_version23(model(8))
1217 function o=block2_version(o)
1218 if o(3)(6)<>[] then o(3)(12)(2)=%t;end
1223 function o=block_version(o)
1224 [graphics,model]=o(2:3)
1225 for k=2:5, model(k)=ones(model(k),1),end
1231 case "ABSBLK_f" then
1235 gr_i="xstringb(orig(1),orig(2),''abs'',sz(1),sz(2),''fill'')"
1236 case "ANIMXY_f" then
1237 [rpar,ipar]=model([8:9])
1238 model(9)=[model(9);0;[-1;-1];[-1;-1]]
1239 win=ipar(1);N=ipar(3);clrs=ipar(4);siz=ipar(5)
1240 xmin=rpar(1);xmax=rpar(2);ymin=rpar(3);ymax=rpar(4)
1241 label=[string(clrs);
1251 gr_i=["thick=xget(''thickness'');xset(''thickness'',2);";
1252 "t=(0:0.3:2*%pi)'';";
1253 "xx=orig(1)+(1/5+(cos(2.2*t)+1)*3/10)*sz(1);";
1254 "yy=orig(2)+(1/4.3+(sin(t)+1)*3/10)*sz(2);";
1255 "xpoly(xx,yy,''lines'');"
1256 "xset(''thickness'',thick);"]
1258 rpar=model(8);in=model(2);nin=sum(in)
1260 write(%io(2),["Pb with BOUND_f block";
1261 "previously block has more than one input port";
1262 "It is better to change it with the new block version";
1263 "preceded by a multiplexer"])
1265 thresh=rpar(1:nin),v=rpar(nin+1:2*nin)
1266 label=[strcat(sci2exp(thresh));
1268 gr_i=["thick=xget(''thickness'');xset(''thickness'',2);";
1269 "xx=orig(1)+[1/5;1/2;1/2;1-1/5]*sz(1);";
1270 "yy=orig(2)+[1/2;1/2;1-1/5;1-1/5]*sz(2);";
1271 "xpoly(xx,yy,''lines'');";
1272 "xset(''thickness'',1);";
1273 "xpoly(orig(1)+[1/9;1/5]*sz(1),orig(2)+[1/2;1/2]*sz(2),''lines'');";
1274 "xpoly(orig(1)+[1/2;1-1/9]*sz(1),orig(2)+[1/2;1/2]*sz(2),''lines'');";
1275 "xpoly(orig(1)+[1/2;1/2]*sz(1),orig(2)+[1/9;1/2]*sz(2),''lines'');";
1276 "xpoly(orig(1)+[1/2;1/2]*sz(1),orig(2)+[1-1/5;1-1/9]*sz(2),''lines'');";
1277 "xset(''thickness'',thick);"]
1278 case "CLINDUMMY_f" then
1280 gr_i=["xstringb(orig(1),orig(2),[''DUMMY'';''CLSS''],sz(1),sz(2),''fill'');"]
1285 case "CLKOUT_f" then
1289 case "CLKSPLIT_f" then
1292 case "CLKSOM_f" then
1301 if oo(ko)(3)(1)=="evtdly" then
1307 list([0,0],[2,2],%t,[],[],[],[],0,..
1309 ["wd=xget(''wdim'').*[1.016,1.12];";
1310 "thick=xget(''thickness'');xset(''thickness'',2);";
1311 "p=wd(2)/wd(1);p=1;";
1312 "rx=sz(1)*p/2;ry=sz(2)/2;";
1313 "xarcs([orig(1)+0.05*sz(1);";
1314 "orig(2)+0.95*sz(2);";
1318 " 360*64],scs_color(5));";
1319 "xset(''thickness'',1);";
1320 "xx=[orig(1)+rx orig(1)+rx;";
1321 " orig(1)+rx orig(1)+rx+0.6*rx*cos(%pi/6)];";
1322 "yy=[orig(2)+ry orig(2)+ry ;";
1323 " orig(2)+1.8*ry orig(2)+ry+0.6*ry*sin(%pi/6)];";
1324 "xsegs(xx,yy,scs_color(10));";
1325 "xset(''thickness'',thick);"],[])),..
1326 list("csuper",[],[],[],1,[]," ",..
1327 list(list([600,400,0,0],"foo",[],[]),..
1328 list("Block",list([399,162],[20,20],%t,"1",[],[],6,[],[]),..
1329 list("output",[],[],1,[],[],[],[],1,"d",[],[%f,%f]," ",list())," ","CLKOUT_f"),..
1330 list("Block",list([320,232],[40,40],%t,["0.1";"0.1"],[],[],7,4,..
1332 "txt=[''Delay'';string(dt)];";
1333 "xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');"]),..
1334 list("evtdly",[],[],1,1,[],[],0.1,[],"d",0.1,[%f,%f]," ",list())," ","EVTDLY_f"),..
1335 list("Link",[340;340;380.71066],[226.28571;172;172],"drawlink"," ",[0,0],[5,-1],[3,1],..
1337 list("Block",list([380.71066;172],[1,1],%t," ",[],[],4,[6;7]),..
1338 list("lsplit",[],[],1,[1;1],[],[],[],[],"d",[-1,-1],[%t,%f]," ",list())," ","CLKSPLIT_f"),..
1339 list("Link",[380.71066;399],[172;172],"drawlink"," ",[0,0],[5,-1],[5,1],[2,1]),..
1340 list("Link",[380.71066;380.71066;340;340],[172;301.9943;301.9943;277.71429],"drawlink"," ",..
1341 [0,0],[5,-1],[5,2],[3,1])),[],"h",[],[%f,%f])," ","CLOCK_f")
1346 xx(2)(4)=string([dt;dt])
1359 model(13)=" ";model(14)=list()
1368 ipar=model(9);model(9)=[]
1369 ns=size(model(6),"*");nin=1;nout=1;
1371 A=matrix(rpar(1:ns*ns),ns,ns);
1372 B=matrix(rpar(ns*ns+1:ns*(ns+nin)),ns,nin);
1373 C=matrix(rpar(ns*(ns+nin)+1:ns*(ns+nin+nout)),nout,ns);
1374 D=rpar(ns*(ns+nin+nout)+1);
1375 H=ss2tf(syslin("c",A,B,C,D));
1382 label=[sci2exp(num);sci2exp(den)]
1383 gr_i=["xstringb(orig(1),orig(2),[''Num(s)'';''-----'';''Den(s)''],sz(1),sz(2),''fill'');"]
1385 in=model(2);out=model(3)
1391 A=matrix(rpar(1:ns*ns),ns,ns)
1392 B=matrix(rpar(ns*ns+1:ns*(ns+nin)),ns,nin)
1393 C=matrix(rpar(ns*(ns+nin)+1:ns*(ns+nin+nout)),nout,ns)
1394 D=matrix(rpar(ns*(ns+nin+nout)+1:ns*(ns+nin+nout)+(nin*nout)),nout,nin)
1395 label=[ strcat(sci2exp(A));
1399 strcat(sci2exp(x0))]
1400 gr_i=["txt=[''xd=Ax+Bu'';''y=Cx+Du''];";
1401 "xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');"]
1402 model(2)=nin;model(3)=nout
1404 C=model(8);model(3)=sum(model(3))
1405 label=[strcat(sci2exp(C))]
1406 gr_i=["model=arg1(3);C=model(8);";
1407 "dx=sz(1)/5;dy=sz(2)/10;";
1408 "w=sz(1)-2*dx;h=sz(2)-2*dy;";
1409 "xstringb(orig(1)+dx,orig(2)+dy,string(C),w,h,''fill'');"]
1410 case "COSBLK_f" then
1411 in=model(2);nin=sum(in)
1413 write(%io(2),["Pb with COSBLK_f block";
1414 "previously block has more than one input port";
1415 "It is better to change it with the new block version";
1416 "preceded by a multiplexer and followed by a demultiplxer"])
1419 gr_i=["xstringb(orig(1),orig(2),[''cos''],sz(1),sz(2),''fill'');"]
1422 gr_i=["model=arg1(3);rpar=model(8);ipar=model(9);n=ipar(1);";
1423 "thick=xget(''thickness'');xset(''thickness'',2);";
1424 "xx=rpar(1:n);yy=rpar(n+1:2*n);";
1425 "rect=rpar(2*n+1:2*n+4);";
1426 "mxx=rect(3)-rect(1);";
1427 "mxy=rect(4)-rect(2);";
1428 "xx=orig(1)+sz(1)*(1/10+(4/5)*((xx-rect(1))/mxx));";
1429 "yy=orig(2)+sz(2)*(1/10+(4/5)*((yy-rect(2))/mxy));";
1430 "xpoly(xx,yy,''lines'');";
1431 "xset(''thickness'',thick);"]
1438 if oo(ko)(3)(1)=="evtdly" then
1440 elseif oo(ko)(3)(1)=="register" then
1444 if dt==[]|z0==[] then
1445 write(%io(2), "Pb with DELAY_f block dt or z0 not found")
1451 o(3)(8)(4)(2)(4)=sci2exp(z0)
1452 o(3)(8)(5)(2)(4)=sci2exp(dt)
1455 o(3)(8)(4)(3)(7)=z0(:)
1458 gr_i=["b1=xstringl(0,0,''e'');";
1459 "b2=xstringl(0,0,''-Ts'');";
1460 "h=-b1(2)+max(0,sz(2)-0.5*b1(4)+b2(4))/2;";
1461 "w=max(0,sz(1)-b1(3)-b1(4))/2;";
1462 "xstring(orig(1)+w,orig(2)+h,''e'');";
1463 "xstring(orig(1)+w+b1(3)/2,orig(2)+h+b1(4)*0.5,''-Ts'');"]
1464 case "DLRADAPT_f" then
1465 [dstate,rpar,ipar]=model(7:9)
1471 rn=matrix(rpar(npt+1:npt+m*npt)+%i*rpar(npt+m*npt+1:npt+2*m*npt),npt,m)
1472 rd=matrix(rpar(npt+2*m*npt+1:npt+(2*m+n)*npt)+..
1473 %i*rpar(npt+(2*m+n)*npt+1:npt+2*(m+n)*npt),npt,n)
1474 g=rpar(npt+2*(m+n)*npt+1:npt+2*(m+n)*npt+npt)
1475 last_u=dstate(1:m);last_y=dstate(m+1:m+n)
1482 gr_i=["txt=[''N(z,p)'';''-----'';''D(z,p)''];";
1483 "xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');"]
1485 model(9)=[];model(10)="d"
1486 ns=size(model(7),"*");nin=1;nout=1;
1488 A=matrix(rpar(1:ns*ns),ns,ns);
1489 B=matrix(rpar(ns*ns+1:ns*(ns+nin)),ns,nin);
1490 C=matrix(rpar(ns*(ns+nin)+1:ns*(ns+nin+nout)),nout,ns);
1491 D=rpar(ns*(ns+nin+nout)+1);
1492 H=ss2tf(syslin("d",A,B,C,D));
1499 label=[sci2exp(num);sci2exp(den)]
1500 gr_i=["txt=[''Num(z)'';''-----'';''Den(z)''];";
1501 "xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');"]
1503 in=model(2);out=model(3)
1506 x0=model(6),rpar=model(8)
1508 A=matrix(rpar(1:ns*ns),ns,ns)
1509 B=matrix(rpar(ns*ns+1:ns*(ns+nin)),ns,nin)
1510 C=matrix(rpar(ns*(ns+nin)+1:ns*(ns+nin+nout)),nout,ns)
1511 D=matrix(rpar(ns*(ns+nin+nout)+1:ns*(ns+nin+nout)+(nin*nout)),nout,nin)
1513 label=[ strcat(sci2exp(A));
1517 strcat(sci2exp(x0))]
1518 gr_i=["txt=[''x+=Ax+Bu'';''y=Cx+Du''];";
1519 "xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');"]
1520 case "EVENTSCOPE_f" then
1521 [nclock,rpar,ipar]=model([4 8 9])
1526 clrs=[1;3;5;7;9;11;13;15];
1527 model(9)=[win;1;clrs;wpos(:);wdim(:)]
1528 label=[sci2exp(nclock);
1529 strcat(sci2exp(clrs)," ");
1534 gr_i=["thick=xget(''thickness'');xset(''thickness'',2);";
1535 "xrect(orig(1)+sz(1)/10,orig(2)+(1-1/10)*sz(2),sz(1)*8/10,sz(2)*8/10);";
1536 "xx=[orig(1)+sz(1)/5,orig(1)+sz(1)/5;";
1537 "orig(1)+(1-1/5)*sz(1),orig(1)+sz(1)/5];";
1538 "yy=[orig(2)+sz(2)/5,orig(2)+sz(2)/5;";
1539 "orig(2)+sz(2)/5,orig(2)+(1-1/5)*sz(2)];";
1541 "t=(0:0.3:2*%pi)'';";
1542 "xx=orig(1)+(1/5+3*t/(10*%pi))*sz(1);";
1543 "yy=orig(2)+(1/4.3+(sin(t)+1)*3/10)*sz(2);";
1544 "xpoly(xx,yy,''lines'');";
1545 "xset(''thickness'',thick);"]
1546 case "EVTDLY_f" then
1548 if model(11) then ff=0; else ff=-1; end
1550 label=[string(dt);string(ff)]
1551 gr_i=["dt=model(8);";
1552 "txt=[''Delay'';string(dt)];";
1553 "xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');"]
1554 case "EVTGEN_f" then
1557 gr_i=["xstringb(orig(1),orig(2),''Event'',sz(1),sz(2),''fill'');"]
1559 write(%io(2),"FOR block nor more exist")
1567 model(13)=" ";model(14)=list()
1576 gain=matrix(model(8),out,in)
1577 label=[strcat(sci2exp(gain))]
1578 gr_i=["[nin,nout]=model(2:3);";
1579 "if nin*nout==1 then gain=string(model(8)),else gain=''Gain'',end";
1582 "xx=orig(1)+ [1 4 1 1]*dx;";
1583 "yy=orig(2)+sz(2)-[1 5 9 1]*dy;";
1584 "xpoly(xx,yy,''lines'');";
1585 "w=sz(1)-2*dx;h=sz(2)-2*dy;";
1586 "xstringb(orig(1)+dx,orig(2)+dy,gain,w,h,''fill'');"]
1587 case "GENERAL_f" then
1588 in=model(2);out=model(5)
1589 label=[strcat(sci2exp(in));strcat(sci2exp(out))]
1590 gr_i=["xstringb(orig(1),orig(2),''GENERAL'',sz(1),sz(2),''fill'');"]
1591 case "GENSIN_f" then
1593 label=[string(rpar(1));string(rpar(2));string(rpar(3))]
1594 gr_i=["txt=[''sinusoid'';''generator''];";
1595 "xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');"]
1596 case "GENSQR_f" then
1599 label=string(Amplitude)
1600 gr_i=["txt=[''square wave'';''generator''];";
1601 "xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');"]
1605 gr_i=["xstringb(orig(1),orig(2),''STOP'',sz(1),sz(2),''fill'');"]
1606 case "IFTHEL_f" then
1609 gr_i=["txt=[''If in>=0'';'' '';'' then else''];";
1610 "xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');"]
1611 case "INTEGRAL_f" then
1613 label=strcat(sci2exp(x0))
1614 gr_i=["xstringb(orig(1),orig(2),'' 1/s '',sz(1),sz(2),''fill'');"]
1615 case "INVBLK_f" then
1616 model(2)=-1;model(3)=-1
1618 gr_i=["xstringb(orig(1),orig(2),''1/u'',sz(1),sz(2),''fill'');"]
1624 case "LOGBLK_f" then
1628 model(2)=-1;model(3)=-1
1629 gr_i=["xstringb(orig(1),orig(2),''log'',sz(1),sz(2),''fill'');"]
1630 case "LOOKUP_f" then
1632 gr_i=["rpar=model(8);n=size(rpar,''*'')/2;";
1633 "thick=xget(''thickness'');xset(''thickness'',2);";
1634 "xx=rpar(1:n);yy=rpar(n+1:2*n);";
1635 "mnx=min(xx);xx=xx-mnx*ones(xx);mxx=max(xx);";
1636 "xx=orig(1)+sz(1)*(1/10+(4/5)*xx/mxx);";
1637 "mnx=min(yy);yy=yy-mnx*ones(yy);mxx=max(yy);";
1638 "yy=orig(2)+sz(2)*(1/10+(4/5)*yy/mxx);";
1639 "xpoly(xx,yy,''lines'');";
1640 "xset(''thickness'',thick);"]
1643 in=model(2);nin=sum(in)
1645 write(%io(2),["Pb with MAX_f block";
1646 "previously block has more than one input port";
1647 "It is better to change it with the new block version";
1648 "preceded by a multiplexer"])
1651 gr_i=["xstringb(orig(1),orig(2),''Max'',sz(1),sz(2),''fill'');"]
1652 case "MCLOCK_f" then
1654 gr_i=["txt=[''2freq clock'';'' f/n f''];";
1655 "xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'')"]
1656 case "MFCLCK_f" then
1659 label=[string(dt);string(nn)]
1660 gr_i=["txt=[''M. freq'';''clock''];";
1661 "xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'')"]
1663 in=model(2);nin=sum(in)
1665 write(%io(2),["Pb with MIN_f block";
1666 "previously block has more than one input port";
1667 "It is better to change it with the new block version";
1668 "preceded by a multiplexer"])
1671 gr_i=["xstringb(orig(1),orig(2),''MIN'',sz(1),sz(2),''fill'')"]
1672 case "NEGTOPOS_f" then
1674 gr_i=["xstringb(orig(1),orig(2),'' - to + '',sz(1),sz(2),''fill'');"]
1680 case "POSTONEG_f" then
1682 gr_i=["xstringb(orig(1),orig(2),'' + to - '',sz(1),sz(2),''fill'')"]
1683 case "POWBLK_f" then
1684 in=model(2);nin=sum(in)
1686 write(%io(2),["Pb with MIN_f block";
1687 "previously block has more than one input port";
1688 "It is better to change it with the new block version";
1689 "preceded by a multiplexer and followed by a demux"])
1691 if model(8)<>[] then
1698 gr_i=["xstringb(orig(1),orig(2),''u^a'',sz(1),sz(2),''fill'');"]
1702 model(1)=list("prod",2)
1704 rpar=model(8);ipar=model(9);
1707 label=[string(pas);string(meth)]
1708 gr_i=["thick=xget(''thickness'');xset(''thickness'',2);";
1709 "xx=orig(1)+[1;2;2;3;3;4;4]/5*sz(1);";
1710 "yy= orig(2)+[1;1;2;2;3;3;4]/5*sz(2);";
1711 "xpoly(xx,yy,''lines'');";
1712 "xset(''thickness'',thick);"]
1714 rpar=model(8);flag=model(9);
1715 out=model(3);nout=sum(out)
1717 write(%io(2),["Pb with RAND_f block";
1718 "previously block has more than one output port";
1719 "It is better to change it with the new block version";
1720 " followed by a demux"])
1724 b=rpar(nout+1:2*nout)
1725 label=[string(flag);sci2exp(a(:));sci2exp(b(:))]
1726 gr_i=["txt=[''random'';''generator''];";
1727 "xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'')"]
1728 case "REGISTER_f" then
1730 label=strcat(string(z0),";")
1732 gr_i=["dly=model(8);";
1733 "txt=[''Shift'';''Register'';string(dly)];";
1734 "xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'')"]
1742 model(13)=" ";model(14)=list()
1750 [out,state,ipar]=model([3 7 9])
1752 ievt=ipar(3);N=ipar(4);
1753 imask=5+ipar(1)+ipar(2)
1754 if ievt<>0 then tmask=ipar(imask),else tmask=[],end
1755 outmask=ipar(imask+ievt:imask+nout+ievt-1)
1757 ievt=ipar(3);N=ipar(4);
1758 imask=5+ipar(1)+ipar(2)
1759 if ievt<>0 then tmask=ipar(imask),else tmask=[],end
1760 outmask=ipar(imask+ievt:imask+nout+ievt-1)
1763 if lfil>0 then fname=ascii(ipar(5:4+lfil)),else fname=" ",end
1764 if lfmt>0 then Fmt=ascii(ipar(5+lfil:4+lfil+lfmt)),else Fmt=" ",end
1765 label=[ sci2exp(tmask);
1771 gr_i=["txt=[''read from'';''input file''];";
1772 "xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'')"]
1775 minp=rpar(1),maxp=rpar(2),pente=rpar(3)
1776 label=[string(minp);string(maxp);string(pente)]
1778 gr_i=["thick=xget(''thickness'');xset(''thickness'',2);";
1779 "xx=orig(1)+[4/5;1/2+1/5;1/2-1/5;1/5]*sz(1);";
1780 "yy=orig(2)+[1-1/5;1-1/5;1/5;1/5]*sz(2);";
1781 "xpoly(xx,yy,''lines'');";
1782 "xset(''thickness'',thick)"]
1783 case "SAWTOOTH_f" then
1785 gr_i=["txt=[''sawtooth'';''generator''];";
1786 "xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');"]
1788 [in,rpar,ipar]=model([2 8 9])
1789 in=model(2);nin=sum(in)
1791 write(%io(2),["Pb with SCOPE_f block";
1792 "previously block has more than one input port";
1793 "It is better to change it with the new block version";
1794 "preceded by a multiplexer"])
1796 win=ipar(1);N=ipar(3);
1798 if size(clrs,"*")<8 then clrs(8)=1;end
1802 model(9)=[win;1;N;clrs;wpos(:);wdim(:)]
1803 dt=rpar(1);ymin=rpar(2);ymax=rpar(3);per=rpar(4)
1804 label=[strcat(string(clrs)," ");
1813 gr_i=["thick=xget(''thickness'');xset(''thickness'',2);";
1814 "xrect(orig(1)+sz(1)/10,orig(2)+(1-1/10)*sz(2),sz(1)*8/10,sz(2)*8/10);";
1815 "xx=[orig(1)+sz(1)/5,orig(1)+sz(1)/5;";
1816 "orig(1)+(1-1/5)*sz(1),orig(1)+sz(1)/5];";
1817 "yy=[orig(2)+sz(2)/5,orig(2)+sz(2)/5;";
1818 "orig(2)+sz(2)/5,orig(2)+(1-1/5)*sz(2)];";
1820 "t=(0:0.3:2*%pi)'';";
1821 "xx=orig(1)+(1/5+3*t/(10*%pi))*sz(1);";
1822 "yy=orig(2)+(1/4.3+(sin(t)+1)*3/10)*sz(2);";
1823 "xpoly(xx,yy,''lines'');";
1824 "xset(''thickness'',thick)"]
1825 case "SCOPXY_f" then
1826 [rpar,ipar]=model(8:9)
1827 win=ipar(1);N=ipar(3);clrs=-ipar(4);siz=ipar(5)
1828 xmin=rpar(1);xmax=rpar(2);ymin=rpar(3);ymax=rpar(4)
1831 label=[sci2exp(clrs);
1841 model(9)=[win;1;N;clrs;siz;1;wpos(:);wdim(:)]
1842 gr_i=["thick=xget(''thickness'');xset(''thickness'',2);";
1843 "t=(0:0.2:2*%pi)'';";
1844 "xx=orig(1)+(1/5+(cos(3*t)+1)*3/10)*sz(1);";
1845 "yy=orig(2)+(1/4.3+(sin(t+1)+1)*3/10)*sz(2);";
1846 "xpoly(xx,yy,''lines'');";
1847 "xset(''thickness'',thick)"]
1848 case "SELECT_f" then
1849 z0=model(7);nin=size(model(2),1);
1850 label=[string(nin);string(z0-1)]
1851 model(1)=list("selector",2)
1852 gr_i=["xstringb(orig(1),orig(2),''Selector'',sz(1),sz(2),''fill'');"]
1853 case "SINBLK_f" then
1854 in=model(2);nin=sum(in)
1856 write(%io(2),["Pb with MIN_f block";
1857 "previously block has more than one input port";
1858 "It is better to change it with the new block version";
1859 "preceded by a multiplexer and followed by a demux"])
1862 gr_i=["xstringb(orig(1),orig(2),''sin'',sz(1),sz(2),''fill'')"]
1866 model(1)=list("sum",2)
1873 gr_i=["thick=xget(''thickness'');xset(''thickness'',2);";
1874 "xx=orig(1)+ [2 4 4]*(sz(1)/7);";
1875 "yy=orig(2)+sz(2)-[2 2 6]*(sz(2)/10);";
1876 "xrects([xx;yy;[sz(1)/7;sz(2)/5]*ones(1,3)]);";
1877 "xx=orig(1)+ [1 2 3 4 5 6 3.5 3.5 3.5 4 5 5.5 5.5 5.5]*sz(1)/7;";
1878 "yy=orig(2)+sz(2)-[3 3 3 3 3 3 3 7 7 7 7 7 7 3 ]*sz(2)/10;";
1880 "xset(''thickness'',thick)"]
1881 case "TANBLK_f" then
1882 in=model(2);nin=sum(in)
1884 write(%io(2),["Pb with TANBLK_f block";
1885 "previously block has more than one input port";
1886 "It is better to change it with the new block version";
1887 "preceded by a multiplexer and followed by a demux"])
1890 gr_i=["xstringb(orig(1),orig(2),''tan'',sz(1),sz(2),''fill'');"]
1892 in=model(2);nin=sum(in)
1893 out=model(3);nout=sum(out)
1894 x0=model(6),rpar=model(8)
1896 ns=prod(size(x0));nin=nin-ns
1897 A=matrix(rpar(1:ns*ns),ns,ns)
1898 B=matrix(rpar(ns*ns+1:ns*(ns+nin)),ns,nin)
1899 C=matrix(rpar(ns*(ns+nin)+1:ns*(ns+nin+nout)),nout,ns)
1900 D=matrix(rpar(ns*(ns+nin+nout)+1:ns*(ns+nin+nout)+(nin*nout)),nout,nin)
1903 label=[strcat(sci2exp(A));
1907 strcat(sci2exp(x0))]
1908 gr_i=["txt=[''Jump'';''(A,B,C,D)''];";
1909 "xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'')"]
1927 font=ipar(1);siz=ipar(2)
1928 label=[graphics(4);string(font);string(siz)]
1932 gr_i=["wd=xget(''wdim'').*[1.016,1.12];";
1933 "thick=xget(''thickness'');xset(''thickness'',2);";
1934 "p=wd(2)/wd(1);p=1;";
1935 "rx=sz(1)*p/2;ry=sz(2)/2;";
1936 "xarc(orig(1)+0.05*sz(1),orig(2)+0.95*sz(2),0.9*sz(1)*p,0.9*sz(2),0,360*64);";
1937 "xset(''thickness'',1);";
1938 "xx=[orig(1)+rx orig(1)+rx;";
1939 "orig(1)+rx orig(1)+rx+0.6*rx*cos(%pi/6)];";
1940 "yy=[orig(2)+ry orig(2)+ry ;";
1941 " orig(2)+1.8*ry orig(2)+ry+0.6*ry*sin(%pi/6)];";
1943 "xset(''thickness'',thick);"]
1945 in=model(2);nin=sum(in)
1947 write(%io(2),["Pb with MIN_f block";
1948 "previously block has more than one input port";
1949 "It is better to change it with the new block version";
1950 "preceded by a multiplexer"])
1953 gr_i=["xstringb(orig(1),orig(2),''Trash'',sz(1),sz(2),''fill'')"]
1956 [in,ipar]=model([2 9])
1962 if lfil>0 then fname=ascii(ipar(5:4+lfil)),else fname=" ",end
1963 if lfmt>0 then Fmt=ascii(ipar(5+lfil:4+lfil+lfmt)),else Fmt=" ",end
1969 gr_i=["txt=[''write to'';''output file''];";
1970 "xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'')"]
1971 case "ZCROSS_f" then
1973 label=strcat(sci2exp(in))
1974 gr_i=["xstringb(orig(1),orig(2),''Zcross'',sz(1),sz(2),''fill'');"]
1975 case "func_block" then
1976 write(%io(2),["PB with func_block";
1977 "version change is not implemented"])
1979 gr_i=["xstringb(orig(1),orig(2),''Func'',sz(1),sz(2),''fill'');"]
1981 rpar=model(8);gain=rpar(1);phase=rpar(2)
1982 label=[string(gain);string(phase)]
1984 case "sci_block" then
1985 write(%io(2),["PB with sci_block";
1986 "version change is not implemented"])
1988 gr_i=["xstringb(orig(1),orig(2),''Sci_Block'',sz(1),sz(2),''fill'');"]
1989 case "scifunc_block" then
1990 write(%io(2),["PB with scifunc_block";
1991 "version change is not implemented"])
1992 i1=model(2);o1=model(3);ci1=model(4);co1=model(5);x1=model(6);
1993 z1=model(7);auto1=model(11);type_1=model(10);
1994 tt=model(9),rpar=model(8)
1995 label=list([sci2exp(i1);sci2exp(o1);sci2exp(ci1);sci2exp(co1);
1996 strcat(sci2exp(x1));strcat(sci2exp(z1));type_1;
1997 strcat(sci2exp(rpar));sci2exp(auto1)],tt)
1999 gr_i=["xstringb(orig(1),orig(2),''Scifunc'',sz(1),sz(2),''fill'');"]
2000 case "standard_block" then
2001 write(%io(2),["PB with standard_block";
2002 "version change is not implemented"])
2006 disp(blocktype+" unknown, parameters values may be lost, please check")
2020 function o=replace_firing(o)
2023 if firing==%f|firing==0 then
2024 o(3)(11)=-ones(cout)
2025 //disp('firing changed from %f to '+sci2exp(o(3)(11))+' in '+o(3)(1)(1))
2026 elseif firing==%t|firing==1 then
2028 //disp('firing changed from %t to '+sci2exp(o(3)(11))+' in '+o(3)(1)(1))
2029 elseif firing==[] then
2032 write(%io(2),"Problem with block "+o(3)(1)(1))
2037 function x_new=do_version22(scs_m)
2042 if size(wsiz,"*")>=4 then x_new=scs_m,return,end
2044 wpar(3)(4)=wpar(4)+1
2049 if o(1)=="Link" then
2050 elseif o(1)=="Block" then
2052 if model(1)=="super"|model(1)=="csuper" then
2053 model(8)=do_version22(model(8))
2060 elseif o(1)=="Text" then
2067 function scs_m_new=do_version27(scs_m)
2068 if typeof(scs_m)=="diagram" then
2069 //following code reported into do_version273
2071 // nlstsize=lstsize(scs_m_new.objs)
2073 // if typeof(scs_m_new.objs(k))=='Link' then
2074 // o=scs_m_new.objs(k)
2075 // if size(o.from,'*')==2 then o.from(3)=0,end
2076 // if size(o.to,'*')==2 then o.to(3)=1,end
2077 // scs_m_new.objs(k)=o
2078 // elseif typeof(scs_m_new.objs(k))=='Block' then
2085 scs_m_new=scicos_diagram()
2087 if tf==[] then tf=100;end
2089 if size(tol,"*")<4 then tol(4)=tf+1,end
2090 if size(tol,"*")<5 then tol(5)=0,end
2091 if size(tol,"*")<6 then tol(6)=0,end
2092 for iix=size(scs_m(1))+1:10,scs_m(1)(iix)=[];end
2093 scs_m_new.props=scicos_params(wpar=scs_m(1)(1),Title=scs_m(1)(2),..
2095 context=scs_m(1)(5),options=scs_m(1)(7),..
2098 if scs_m(1)(7).Background==[] then
2099 scs_m_new.props.options.Background=[8 1]
2102 scs_m_new.objs(1)=mlist("Deleted") // not to change the internal numbering
2104 back_col=8 //white background
2108 for i=2:n //loop on objects
2110 if o(1)=="Block" then
2111 if size(o(2)) > 8 then
2112 if type(o(2)(9))==15 then
2114 if o(2)(9)(2)<>[] then
2115 back_col=o(2)(9)(2);,
2121 gr_i=convert_gri(o(5),gr_io);
2122 if gr_i==[] then gr_i=gr_io;, end
2123 elseif size(o(2)) < 9 then
2127 gr_i=list(gr_i,back_col)
2130 if size(o(3))<=12 then
2131 mdl(13)=""; mdl(14)=[] ; mdl(15)="";
2132 elseif size(o(3))<=13 then
2133 mdl(14)=[] ; mdl(15)="";
2134 elseif size(o(3))<=14 then
2138 if mdl(1)(1)=="super"|mdl(1)(1)=="csuper" then
2139 if type(mdl(8))==15 then
2140 mdl(8)=do_version27(mdl(8))
2144 graphics=scicos_graphics27(orig=o(2)(1),sz=o(2)(2),flip=o(2)(3),..
2145 exprs=o(2)(4),pin=o(2)(5),pout=o(2)(6),..
2146 pein=o(2)(7),peout=o(2)(8),gr_i=gr_i,..
2150 model=scicos_model27(sim=mdl(1),in=mdl(2),out=mdl(3),evtin=mdl(4),..
2151 evtout=mdl(5),state=mdl(6),dstate=mdl(7),..
2152 rpar=mdl(8),ipar=mdl(9),blocktype=mdl(10),..
2153 firing=mdl(11),dep_ut=mdl(12),label=mdl(13))
2156 objsi=scicos_block(graphics=graphics,model=model,gui=o(5),..
2158 if objsi.gui=="ESELECT_f" then objsi.model.sim(2)=-2,end
2159 scs_m_new.objs(i)=objsi
2161 elseif o(1)=="Link" then
2162 from=o(8);from(3)=0;
2165 objsi=scicos_link(xx=o(2),yy=o(3),id=o(5),thick=o(6),..
2166 ct=o(7),from=from,to=to)
2167 scs_m_new.objs(i)=objsi
2168 elseif o(1)=="Text" then
2170 objsi=TEXT_f("define")
2171 objsi.model.rpar=o(3)(8)
2172 objsi.model.ipar=o(3)(9)
2173 objsi.graphics.orig=o(2)(1)
2174 objsi.graphics.sz=o(2)(2)
2175 objsi.graphics.exprs=o(2)(4)
2176 scs_m_new.objs(i)=objsi
2177 elseif o(1)=="Deleted" then
2178 scs_m_new.objs(i)=mlist("Deleted")
2182 [%cpr,edited]=resume(list(),%t) // doit etre enleve
2185 function gr_i=convert_gri(name,gri)
2188 case "BIGSOM_f" then
2189 gr_i=["[x,y,typ]=standard_inputs(o) ";
2191 "for k=1:size(x,''*'')";
2192 " if sgn(k)>0 then";
2193 " xstring(orig(1)+sz(1)/8 ,y(k)-4,''+'')";
2195 " xstring(orig(1)+sz(1)/8 ,y(k)-4,''-'')";
2198 "xx=sz(1)*[.8 .4 0.75 .4 .8]+orig(1)";
2199 "yy=sz(2)*[.8 .8 .5 .2 .2]+orig(2)";
2200 "xpoly(xx,yy,''lines'')"]
2203 gr_i=["dx=sz(1)/5;dy=sz(2)/10;";
2204 "w=sz(1)-2*dx;h=sz(2)-2*dy;";
2206 "xstringb(orig(1)+dx,orig(2)+dy,txt,w,h,''fill'');"]
2209 gr_i=["model=arg1.model;rpar=model.rpar;ipar=model.ipar;n=ipar(1);";
2210 "thick=xget(''thickness'');xset(''thickness'',2);";
2211 "xx=rpar(1:n);yy=rpar(n+1:2*n);";
2212 "rect=rpar(2*n+1:2*n+4);";
2213 "mxx=rect(3)-rect(1);";
2214 "mxy=rect(4)-rect(2);";
2215 "xx=orig(1)+sz(1)*(1/10+(4/5)*((xx-rect(1))/mxx));";
2216 "yy=orig(2)+sz(2)*(1/10+(4/5)*((yy-rect(2))/mxy));";
2217 "xpoly(xx,yy,''lines'');";
2218 "xset(''thickness'',thick);"]
2220 case "EVTDLY_f" then
2221 gr_i=["dt=model.rpar;";
2222 "txt=[''Delay'';string(dt)];";
2223 "xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');"]
2225 case "EVTGEN_f" then
2226 gr_i=["tt=model.firing;";
2227 "txt=[''Event at'';''time ''+string(tt)];";
2228 "xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');"]
2235 "xx=orig(1)+ [1 4 1 1]*dx;";
2236 "yy=orig(2)+sz(2)-[1 5 9 1]*dy;";
2237 "xpoly(xx,yy,''lines'');";
2238 "w=sz(1)-2*dx;h=sz(2)-2*dy;";
2239 "xstringb(orig(1)+dx,orig(2)+dy,gain,w,h,''fill'');"]
2241 case "LOOKUP_f" then
2242 gr_i=["rpar=model.rpar;n=size(rpar,''*'')/2;";
2243 "thick=xget(''thickness'');xset(''thickness'',2);";
2244 "xx=rpar(1:n);yy=rpar(n+1:2*n);";
2245 "mnx=min(xx);xx=xx-mnx*ones(xx);mxx=max(xx);";
2246 "xx=orig(1)+sz(1)*(1/10+(4/5)*xx/mxx);";
2247 "mnx=min(yy);yy=yy-mnx*ones(yy);mxx=max(yy);";
2248 "yy=orig(2)+sz(2)*(1/10+(4/5)*yy/mxx);";
2249 "xpoly(xx,yy,''lines'');";
2250 "xset(''thickness'',thick);"]
2252 case "REGISTER_f" then
2254 gr_i=["dly=model.rpar;";
2255 "txt=[''Shift'';''Register'';string(dly)];";
2256 "xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'')"]
2257 case "SWITCH_f" then
2259 gr_i="xstringb(orig(1),orig(2),[''switch'';string(model.ipar+1)],sz(1),sz(2),''fill'');"
2260 case "EXPBLK_f" then
2261 gr_i="xstringb(orig(1),orig(2),''a^u'',sz(1),sz(2),''fill'');"
2262 case "POWBLK_f" then
2263 gr_i="xstringb(orig(1),orig(2),''u^a'',sz(1),sz(2),''fill'');"
2269 function scs_m_new=do_versionxx(scs_m)
2270 //A SUPPRIMER CF ci dessus
2271 if typeof(scs_m)=="diagram" then scs_m_new=scs_m,return,end
2272 if typeof(scs_m(1))<>"params" then scs_m_new=scs_m,return,end
2273 scs_m_new=scicos_diagram()
2274 scs_m_new.props=scs_m(1)
2275 scs_m_new.objs(1)=mlist("Deleted") // not to change the internal numbering
2277 for i=2:n //loop on objects
2280 if typeof(o)=="Block" then
2281 if o.model.sim(1)=="super"| o.model.sim(1)=="csuper" then
2282 scs_m_new.objs(i).model.rpar=do_versionxx(o.model.rpar)
2290 function model=scicos_model27(v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13)
2291 //initialisation de model scicos_new
2292 if exists("sim","local")==0 then sim="",end
2293 if exists("in","local")==0 then in=[],end
2294 if exists("out","local")==0 then out=[],end
2295 if exists("evtin","local")==0 then evtin=[],end
2296 if exists("evtout","local")==0 then evtout=[],end
2297 if exists("state","local")==0 then state=[],end
2298 if exists("dstate","local")==0 then dstate=[],end
2299 if exists("rpar","local")==0 then rpar=[],end
2300 if exists("ipar","local")==0 then ipar=[],end
2301 if exists("blocktype","local")==0 then blocktype="c",end
2302 if exists("firing","local")==0 then firing=[],end
2303 if exists("dep_ut","local")==0 then dep_ut=[%f %f],end
2304 if exists("label","local")==0 then label="",end
2306 model=scicos_new(["model","sim","in","out","evtin","evtout","state","dstate",..
2307 "rpar","ipar","blocktype","firing","dep_ut","label"],..
2308 sim,in,out,evtin,evtout,state,dstate,..
2309 rpar,ipar,blocktype,firing,dep_ut,label)
2312 function graphics=scicos_graphics27(v1,v2,v3,v4,v5,v6,v7,v8,v9,v10)
2313 //initialisation de graphics scicos_new
2314 if exists("orig","local")==0 then orig=[0 0],end
2315 if exists("sz","local")==0 then sz=[20 20],end
2316 if exists("flip","local")==0 then flip=%t,end
2317 if exists("exprs","local")==0 then exprs=[],end
2318 if exists("pin","local")==0 then pin=[],end
2319 if exists("pout","local")==0 then pout=[],end
2320 if exists("pein","local")==0 then pein=[],end
2321 if exists("peout","local")==0 then peout=[],end
2322 if exists("gr_i","local")==0 then gr_i=[],end
2323 if exists("id","local")==0 then id="",end
2325 graphics=scicos_new(["graphics","orig","sz","flip","exprs","pin",..
2326 "pout","pein","peout","gr_i","id"],..
2327 orig,sz,flip,exprs,pin,pout,pein,peout,gr_i,id)