diff options
Diffstat (limited to 'macros/Events')
-rw-r--r-- | macros/Events/ANDBLK.sci | 109 | ||||
-rw-r--r-- | macros/Events/ANDLOG_f.sci | 41 | ||||
-rw-r--r-- | macros/Events/CLKSOMV_f.sci | 43 | ||||
-rw-r--r-- | macros/Events/CLKSOM_f.sci | 42 | ||||
-rw-r--r-- | macros/Events/CLKSPLIT_f.sci | 81 | ||||
-rw-r--r-- | macros/Events/END_c.sci | 60 | ||||
-rw-r--r-- | macros/Events/EVTDLY_c.sci | 74 | ||||
-rw-r--r-- | macros/Events/EVTDLY_f.sci | 74 | ||||
-rw-r--r-- | macros/Events/EVTGEN_f.sci | 59 | ||||
-rw-r--r-- | macros/Events/EVTVARDLY.sci | 59 | ||||
-rw-r--r-- | macros/Events/HALT_f.sci | 60 | ||||
-rw-r--r-- | macros/Events/IFTHEL_f.sci | 82 | ||||
-rw-r--r-- | macros/Events/MCLOCK_f.sci | 141 | ||||
-rw-r--r-- | macros/Events/MFCLCK_f.sci | 62 | ||||
-rw-r--r-- | macros/Events/M_freq.sci | 110 | ||||
-rw-r--r-- | macros/Events/VirtualCLK0.sci | 42 | ||||
-rw-r--r-- | macros/Events/freq_div.sci | 287 |
17 files changed, 1426 insertions, 0 deletions
diff --git a/macros/Events/ANDBLK.sci b/macros/Events/ANDBLK.sci new file mode 100644 index 00000000..70bfcff7 --- /dev/null +++ b/macros/Events/ANDBLK.sci @@ -0,0 +1,109 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=ANDBLK(job,arg1,arg2) + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1 + case "define" then + andlog=ANDLOG_f("define") + andlog.graphics.orig=[194,133] + andlog.graphics.sz=[60,60] + andlog.graphics.flip=%t + andlog.graphics.pout=9 + andlog.graphics.pein=[4;11] + + input_port1=CLKIN_f("define") + input_port1.graphics.orig=[149,287] + input_port1.graphics.sz=[20,20] + input_port1.graphics.flip=%t + input_port1.graphics.exprs="1" + input_port1.graphics.peout=4 + input_port1.model.ipar=1 + + output_port=CLKOUT_f("define") + output_port.graphics.orig=[450,83] + output_port.graphics.sz=[20,20] + output_port.graphics.flip=%t + output_port.graphics.exprs="1" + output_port.graphics.pein=8 + output_port.model.ipar=1 + + input_port2=CLKIN_f("define") + input_port2.graphics.orig=[141,330] + input_port2.graphics.sz=[20,20] + input_port2.graphics.flip=%t + input_port2.graphics.exprs="2" + input_port2.graphics.peout=6 + input_port2.model.ipar=2 + + ifthel=IFTHEL_f("define") + ifthel.graphics.orig=[331,137] + ifthel.graphics.sz=[60,60] + ifthel.graphics.flip=%t + ifthel.graphics.pin=9 + ifthel.graphics.pein=12 + ifthel.graphics.peout=[8;0] + + split=CLKSPLIT_f("define") + split.graphics.orig=[234;275.78348] + split.graphics.pein=6, + split.graphics.peout=[11;12] + + + diagram=scicos_diagram() + diagram.objs(1)=andlog + diagram.objs(2)=input_port1 + diagram.objs(3)=output_port + diagram.objs(4)=scicos_link(xx=[169;214;214],yy=[297;297;198.71],.. + ct=[5,-1],from=[2,1],to=[1,1]) + diagram.objs(5)=input_port2 + diagram.objs(6)=scicos_link(xx=[161;234;234],yy=[340;340;275.78],.. + ct=[5,-1],from=[5,1],to=[10,1]) + diagram.objs(7)=ifthel + diagram.objs(8)=scicos_link(xx=[351;351;450],yy=[131.29;93;93],.. + ct=[5,-1],from=[7,1],to=[3,1]) + diagram.objs(9)=scicos_link(xx=[262.57;322.43],yy=[163;167],.. + ct=[1,1],from=[1,1],to=[7,1]) + diagram.objs(10)=split + diagram.objs(11)=scicos_link(xx=[234;234],yy=[275.78;198.71],.. + ct=[5,-1],from=[10,1],to=[1,2]) + diagram.objs(12)=scicos_link(xx=[234;361;361],yy=[275.78;275.78;202.71],.. + ct=[5,-1],from=[10,2],to=[7,1]) + x=scicos_block() + x.gui="ANDBLK" + x.graphics.sz=[2,2] + x.graphics.gr_i=[]; + x.graphics.pein=[0;0] + x.graphics.peout=0 + x.model.sim="csuper" + x.model.evtin=[1;1] + x.model.evtout=1 + x.model.blocktype="h" + x.model.firing=%f + x.model.dep_ut=[%f %f] + x.model.rpar=diagram; + + end +endfunction diff --git a/macros/Events/ANDLOG_f.sci b/macros/Events/ANDLOG_f.sci new file mode 100644 index 00000000..01c9adb7 --- /dev/null +++ b/macros/Events/ANDLOG_f.sci @@ -0,0 +1,41 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=ANDLOG_f(job,arg1,arg2) + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + case "define" then + model=scicos_model() + model.sim="andlog" + model.out=1 + model.evtin=[1;1] + model.blocktype="d" + model.firing=[] + model.dep_ut=[%f %f] + + gr_i=[] + x=standard_define([3 3],model,[],gr_i) + end +endfunction diff --git a/macros/Events/CLKSOMV_f.sci b/macros/Events/CLKSOMV_f.sci new file mode 100644 index 00000000..aece0064 --- /dev/null +++ b/macros/Events/CLKSOMV_f.sci @@ -0,0 +1,43 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=CLKSOMV_f(job,arg1,arg2) + x=[]; + y=[]; + typ=[]; + p=1 //pixel sizes ratio + select job + case "set" then + x=arg1; + case "define" then + + model=scicos_model() + model.sim="sum" + model.evtin=[1;1;1] + model.evtout=1 + model.blocktype="d" + model.firing=-1 + model.dep_ut=[%f %f] + + gr_i=[] + x=standard_define([2 2],model,[],gr_i) + end +endfunction diff --git a/macros/Events/CLKSOM_f.sci b/macros/Events/CLKSOM_f.sci new file mode 100644 index 00000000..ff4470f9 --- /dev/null +++ b/macros/Events/CLKSOM_f.sci @@ -0,0 +1,42 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=CLKSOM_f(job,arg1,arg2) + x=[]; + y=[]; + typ=[]; + p=1 //pixel sizes ratio + select job + case "set" then + x=arg1; + case "define" then + model=scicos_model() + model.sim="sum" + model.evtin=[1;1;1] + model.evtout=1 + model.blocktype="d" + model.firing=-1 + model.dep_ut=[%f %f] + + gr_i=[] + x=standard_define([1 1]/1.2,model,[],gr_i) + end +endfunction diff --git a/macros/Events/CLKSPLIT_f.sci b/macros/Events/CLKSPLIT_f.sci new file mode 100644 index 00000000..518b7b37 --- /dev/null +++ b/macros/Events/CLKSPLIT_f.sci @@ -0,0 +1,81 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ] = CLKSPLIT_f(job,arg1,arg2) + //** 22 Jun 2006: I found a problem here from scicos_new + //** 23 ... but it was not here :( + //** 26 June 2006: eliniating the /scicos_blocks/Events/<duplicate> ! + + x=[]; + y=[]; + typ=[]; + + select job + + case "set" then + x=arg1; + + case "define" then + model=scicos_model() + model.sim="split" + model.evtin=1 + model.evtout=[1;1] + model.blocktype="d" + model.firing=[%f,%f,%f] //???? + model.dep_ut=[%f %f] + x = standard_define([1 1]/3,model,[],[]) + end //** ...select job + +endfunction +//**---------------------------------------------------------- + +//** 26 Jun 2006: The original source code +//function [x,y,typ]=CLKSPLIT_f(job,arg1,arg2) +//// Copyright INRIA +//x=[];y=[],typ=[]; +//select job +//case 'plot' then +//case 'getinputs' then +// orig=arg1.graphics.orig; +// x=orig(1) +// y=orig(2) +// typ=-ones(x) +//case 'getoutputs' then +// orig=arg1.graphics.orig; +// x=[1,1]*orig(1) +// y=[1,1]*orig(2) +// typ=-ones(x) +//case 'getorigin' then +// [x,y]=standard_origin(arg1) +//case 'set' then +// x=arg1; +//case 'define' then +// model=scicos_model() +// model.sim='split' +// model.evtin=1 +// model.evtout=[1;1] +// model.blocktype='d' +// model.firing=[%f,%f,%f] //???? +// model.dep_ut=[%f %f] +// +// x=standard_define([1 1]/3,model,[],[]) +//end +//endfunction diff --git a/macros/Events/END_c.sci b/macros/Events/END_c.sci new file mode 100644 index 00000000..f014d708 --- /dev/null +++ b/macros/Events/END_c.sci @@ -0,0 +1,60 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=END_c(job,arg1,arg2) + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + graphics=arg1.graphics; + exprs=graphics.exprs + model=arg1.model; + while %t do + [ok,tf,exprs]=scicos_getvalue("Set final simulation time",.. + ["Final simulation time"],list("vec",1),exprs) + if ~ok then + break, + end + if ok then + graphics.exprs=exprs + model.firing=tf + x.graphics=graphics; + x.model=model + break + end + end + case "define" then + tf=100000000 + model=scicos_model() + model.sim=list("scicosexit",4) + model.evtin=1 + model.evtout=1 + model.firing=tf + model.blocktype="d" + model.dep_ut=[%f %f] + + exprs=string(tf) + gr_i=[] + x=standard_define([2 2],model,exprs,gr_i) + end +endfunction diff --git a/macros/Events/EVTDLY_c.sci b/macros/Events/EVTDLY_c.sci new file mode 100644 index 00000000..e4a0e02c --- /dev/null +++ b/macros/Events/EVTDLY_c.sci @@ -0,0 +1,74 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=EVTDLY_c(job,arg1,arg2) + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + graphics=arg1.graphics; + exprs=graphics.exprs + model=arg1.model; + while %t do + [ok,dt,ff,exprs]=scicos_getvalue(["Set Event Delay block parameters"; + "Delay is the delay between an input event "; + " and the generated output event"; + "Block may initially generate an output event before "; + " any input event. ""Date of initial output event"""; + " gives the date of this event. Set a negative value"; + " to disable any output event."],.. + ["Delay";"Date of initial output event"],.. + list("vec",1,"vec",1),exprs) + if ~ok then + break, + end + if dt<=0 then + message("Delay must be positive") + ok=%f + end + if ok then + graphics.exprs=exprs + model.rpar=[dt;ff] + model.firing=ff + x.graphics=graphics; + x.model=model + break + end + end + case "define" then + dt=0.1 + ff=0.0 + model=scicos_model() + model.sim=list("evtdly4",4) + model.evtin=1 + model.evtout=1 + model.rpar=[dt;ff] + model.blocktype="d" + model.firing=ff + model.dep_ut=[%f %f] + + exprs=[string(dt);sci2exp(ff)] + gr_i=[] + x=standard_define([3 2],model,exprs,gr_i) + end +endfunction diff --git a/macros/Events/EVTDLY_f.sci b/macros/Events/EVTDLY_f.sci new file mode 100644 index 00000000..4a2f243e --- /dev/null +++ b/macros/Events/EVTDLY_f.sci @@ -0,0 +1,74 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=EVTDLY_f(job,arg1,arg2) + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + graphics=arg1.graphics; + exprs=graphics.exprs + model=arg1.model; + while %t do + [ok,dt,ff,exprs]=scicos_getvalue(["Set Event Delay block parameters"; + "Delay is the delay between an input event "; + " and the generated output event"; + "Block may initially generate an output event before "; + " any input event. ""Date of initial output event"""; + " gives the date of this event. Set a negative value"; + " if no initial event required"],.. + ["Delay";"Date of initial output event"],.. + list("vec",1,"vec",1),exprs) + if ~ok then + break, + end + if dt<=0 then + message("Delay must be positive") + ok=%f + end + if ok then + graphics.exprs=exprs + model.rpar=dt + model.firing=ff + x.graphics=graphics; + x.model=model + break + end + end + case "define" then + dt=0.1 + ff=dt + model=scicos_model() + model.sim="evtdly" + model.evtin=1 + model.evtout=1 + model.rpar=dt + model.blocktype="d" + model.firing=ff + model.dep_ut=[%f %f] + + exprs=[string(dt);sci2exp(ff)] + gr_i=[] + x=standard_define([2 2],model,exprs,gr_i) + end +endfunction diff --git a/macros/Events/EVTGEN_f.sci b/macros/Events/EVTGEN_f.sci new file mode 100644 index 00000000..b76ccc68 --- /dev/null +++ b/macros/Events/EVTGEN_f.sci @@ -0,0 +1,59 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=EVTGEN_f(job,arg1,arg2) + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + graphics=arg1.graphics; + exprs=graphics.exprs + model=arg1.model; + while %t do + [ok,tt,exprs]=scicos_getvalue("Set Event time",.. + ["Event Time"],list("vec",1),exprs) + if ~ok then + break, + end + graphics.exprs=exprs + if model.firing<>tt then + model.firing=tt + end + x.graphics=graphics; + x.model=model + break + end + case "define" then + tt=0 + model=scicos_model() + model.sim="trash" + model.evtout=1 + model.blocktype="d" + model.firing=tt + model.dep_ut=[%f %f] + + exprs=string(tt) + gr_i=[] + x=standard_define([3 2],model,exprs,gr_i) + end +endfunction diff --git a/macros/Events/EVTVARDLY.sci b/macros/Events/EVTVARDLY.sci new file mode 100644 index 00000000..ff438de7 --- /dev/null +++ b/macros/Events/EVTVARDLY.sci @@ -0,0 +1,59 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=EVTVARDLY(job,arg1,arg2) + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + graphics=arg1.graphics; + exprs=graphics.exprs + model=arg1.model; + while %t do + [ok,fir,exprs]=scicos_getvalue("Set parameter of variable event delay",.. + "Initial event firing time (<0 if absent)",.. + list("vec",1),exprs) + if ~ok then + break, + end + graphics.exprs=exprs + model.firing=fir + x.graphics=graphics; + x.model=model + break + end + case "define" then + model=scicos_model() + model.sim=list("evtvardly",4) + model.in=1 + model.evtin=1 + model.evtout=1 + model.blocktype="d" + model.firing=-1 + model.blocktype="c" + model.dep_ut=[%t %f] + exprs=string(model.firing) + gr_i=[] + x=standard_define([2 2],model,exprs,gr_i) + end +endfunction diff --git a/macros/Events/HALT_f.sci b/macros/Events/HALT_f.sci new file mode 100644 index 00000000..f6f5881f --- /dev/null +++ b/macros/Events/HALT_f.sci @@ -0,0 +1,60 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=HALT_f(job,arg1,arg2) + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + graphics=arg1.graphics; + exprs=graphics.exprs + model=arg1.model; + while %t do + [ok,n,exprs]=scicos_getvalue("Set Halt block parameters",.. + ["State on halt"],list("vec",1),exprs) + if ~ok then + break, + end + if ok then + graphics.exprs=exprs + model.ipar=n + x.graphics=graphics; + x.model=model + break + end + end + case "define" then + n=0 + model=scicos_model() + model.sim="hltblk" + model.evtin=1 + model.dstate=0 + model.ipar=0 + model.blocktype="d" + model.dep_ut=[%f %f] + + exprs=string(n) + gr_i=[] + x=standard_define([2 2],model,exprs,gr_i) + end +endfunction diff --git a/macros/Events/IFTHEL_f.sci b/macros/Events/IFTHEL_f.sci new file mode 100644 index 00000000..2261a5f0 --- /dev/null +++ b/macros/Events/IFTHEL_f.sci @@ -0,0 +1,82 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=IFTHEL_f(job,arg1,arg2) + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + graphics=arg1.graphics; + exprs=graphics.exprs + model=arg1.model; + if exprs==[] then + exprs=string(1); + end + if size(exprs,"*")==1 then + exprs(2)=string(1); + end + while %t do + [ok,inh,nmod,exprs]=scicos_getvalue("Set parameters",.. + ["Inherit (1: no, 0: yes)";"zero-crossing (0: no, 1: yes)"],.. + list("vec",1,"vec",1),exprs) + if ~ok then + break, + end + model.dep_ut=[%t %f]; //compatibility + if nmod<>0 then + nmod=1, + end + if inh<>1 then + inh=[]; + end + [model,graphics,ok]=check_io(model,graphics,1,[],inh,[1;1]) + if ok then + graphics.exprs=exprs; + model.evtin=inh; + model.sim(2)=-1 + model.nmode=nmod + model.nzcross=nmod + x.graphics=graphics; + x.model=model + break + end + end + case "define" then + model=scicos_model() + model.sim=list("ifthel",-1) + model.in=1 + model.in2=1 + model.intyp=-1 + model.evtin=1 + model.evtout=[1;1] + model.blocktype="l" + model.firing=[-1 -1] + model.dep_ut=[%t %f] + model.nmode=1 + model.nzcross=1 + + gr_i=[] + exprs=[string(model.in);string(model.nmode)]; + x=standard_define([3 3],model,exprs,gr_i) + end +endfunction diff --git a/macros/Events/MCLOCK_f.sci b/macros/Events/MCLOCK_f.sci new file mode 100644 index 00000000..2dd62f6f --- /dev/null +++ b/macros/Events/MCLOCK_f.sci @@ -0,0 +1,141 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=MCLOCK_f(job,arg1,arg2) + x=[]; + y=[]; + typ=[]; + select job + case "set" then + // look for the clock block + for i=1:length(arg1.model.rpar.objs) do + o = arg1.model.rpar.objs(i); + if typeof(o) == "Block" & o.gui == "MFCLCK_f" then + path = i; + break; + end + end + + newpar=list(); + spath=list("model","rpar","objs",path) + xx=arg1(spath)// get the block + execstr("xxn="+xx.gui+"(''set'',xx)") + if or(xxn<>xx) then + // parameter or states changed + arg1(spath)=xxn// Update + newpar(size(newpar)+1)=path// Notify modification + end + x=arg1 + y=0 + typ=newpar + case "define" then + nn=2 + dt=0.1 + exprs=[string(dt);string(nn)] + + mfclck=MFCLCK_f("define") + mfclck.graphics.orig=[334,199] + mfclck.graphics.sz=[40,40] + mfclck.graphics.flip=%t + mfclck.graphics.exprs=exprs + mfclck.graphics.pein=12 + mfclck.graphics.peout=[4;3] + mfclck.model.rpar=0.1 + mfclck.model.ipar=nn + mfclck.model.firing=[-1 0] + + clksom=CLKSOM_f("define") + clksom.graphics.orig=[457,161] + clksom.graphics.sz=[16.666667,16.666667] + clksom.graphics.flip=%t + clksom.graphics.exprs=["0.1";"0.1"] + clksom.graphics.pein=[4;9;0] + clksom.graphics.peout=5 + + output_port1=CLKOUT_f("define") + output_port1.graphics.orig=[509,261] + output_port1.graphics.sz=[20,20] + output_port1.graphics.flip=%t + output_port1.graphics.exprs="1" + output_port1.graphics.pein=10 + output_port1.model.ipar=1 + + output_port2=CLKOUT_f("define") + output_port2.graphics.orig=[509,142] + output_port2.graphics.sz=[20,20] + output_port2.graphics.flip=%t + output_port2.graphics.exprs="2" + output_port2.graphics.pein=13 + output_port2.model.ipar=2 + + + split1=CLKSPLIT_f("define") + split1.graphics.orig=[411.92504;169.33333] + split1.graphics.pein=3, + split1.graphics.peout=[9;10] + + split2=CLKSPLIT_f("define") + split2.graphics.orig=[482.45315;169.33333] + split2.graphics.pein=5 + split2.graphics.peout=[12;13] + + gr_i=[] + + diagram=scicos_diagram(); + diagram.objs(1)=mfclck + diagram.objs(2)=clksom + diagram.objs(3)=scicos_link(xx=[360.7;360.7;411.9],.. + yy=[193.3;169.3;169.3],.. + ct=[10,-1],from=[1,2],to=[8,1]) + diagram.objs(4)=scicos_link(xx=[347.3;347.3;461.8;461.8],.. + yy=[193.3;155.5;155.5;161],.. + ct=[10,-1],from=[1,1],to=[2,1]) + diagram.objs(5)=scicos_link(xx=[468.9;482.5],yy=[169.3;169.3],.. + ct=[10,-1],from=[2,1],to=[11,1]) + + diagram.objs(6)=output_port1 + diagram.objs(7)=output_port2 + diagram.objs(8)=split1 + + diagram.objs(9)=scicos_link(xx=[411.9;457],.. + yy=[169.3;169.3],.. + ct=[10,-1],from=[8,1],to=[2,2]) + diagram.objs(10)=scicos_link(xx=[411.9;411.9;509],yy=[169.3;271;271],.. + ct=[10,-1],from=[8,2],to=[6,1]) + + diagram.objs(11)=split2 + + diagram.objs(12)=scicos_link(xx=[482.5;489.6;489.6;354;354],.. + yy=[169.3;169.3;338.3;338.3;244.7],.. + ct=[10,-1],from=[11,1],to=[1,1]) + diagram.objs(13)=scicos_link(xx=[482.4;482.4;509],yy=[169.3;152;152],.. + ct=[10,-1],from=[11,2],to=[7,1]) + x=scicos_block() + x.gui="MCLOCK_f" + x.graphics.sz=[3,2] + x.graphics.gr_i=gr_i + x.model.sim="csuper" + x.model.evtout=[1;1] + x.model.blocktype="h" + x.model.rpar=diagram + x.graphics.peout=[0;0] + end +endfunction diff --git a/macros/Events/MFCLCK_f.sci b/macros/Events/MFCLCK_f.sci new file mode 100644 index 00000000..db49bc22 --- /dev/null +++ b/macros/Events/MFCLCK_f.sci @@ -0,0 +1,62 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=MFCLCK_f(job,arg1,arg2) + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + graphics=arg1.graphics; + exprs=graphics.exprs + model=arg1.model; + [ok,dt,nn,exprs]=scicos_getvalue("Set Multifrequency clock parameters",.. + ["basic period (1/f)";"multiply by (n)"],list("vec",1,"vec",1),exprs) + if ok then + model.ipar=nn + model.rpar=dt; + hh=model.firing; + hh(2)=0; + model.firing=hh //compatibility + graphics.exprs=exprs + x.graphics=graphics; + x.model=model + end + case "define" then + nn=2 + dt=0.1 + model=scicos_model() + model.sim="mfclck" + model.evtin=1 + model.evtout=[1;1] + model.dstate=0 + model.rpar=dt + model.ipar=nn + model.blocktype="d" + model.firing=[-1 0] + model.dep_ut=[%f %f] + + exprs=[string(dt);string(nn)] + gr_i=[] + x=standard_define([3 2],model,exprs,gr_i) + end +endfunction diff --git a/macros/Events/M_freq.sci b/macros/Events/M_freq.sci new file mode 100644 index 00000000..59c4699e --- /dev/null +++ b/macros/Events/M_freq.sci @@ -0,0 +1,110 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=M_freq(job,arg1,arg2) + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + graphics=arg1.graphics; + model=arg1.model; + exprs=graphics.exprs + while %t do + [ok,frequ,offset,exprs]=scicos_getvalue("Set block parameters",.. + ["Sample time";"Offset"],.. + list("vec",-1,"vec",-1),exprs) + if ~ok then + break, + end + offset=offset(:); + frequ=frequ(:); + if (size(frequ,"*"))<>(size(offset,"*")) then + message("offset and frequency must have the same size"); + ok=%f; + elseif or(frequ<0) then + message("Frequency must be a positif number"); + ok=%f; + elseif or(abs(offset) > frequ) then + message("The |Offset| must be less than the Frequency"); + ok=%f + end + if ok then + [m,den,off,count,m1,fir,frequ,offset,ok]=mfrequ_clk(frequ,offset); + end + if ok then + model.opar=list(m,double(den),off,count) + mn=(2**size(m1,"*"))-1; + [model,graphics,ok]=set_io(model,graphics,list(),list(),1,ones(mn,1)) + if mn>3 then + graphics.sz=[40+(mn-3)*10 40] + else + graphics.sz=[50 40] + end + model.firing=fir; + graphics.exprs=exprs + x.graphics=graphics + x.model=model + break + end + end + case "define" then + model=scicos_model() + model.sim=list("m_frequ",4) + model.evtout=[1;1;1] + model.evtin=1 + model.rpar=[] + model.opar=list([1 1 0;1 1 1;1 3 2],1,0,0); + model.blocktype="d" + model.firing=[0 -1 -1] + model.dep_ut=[%f %f] + exprs=[sci2exp([1;2]);sci2exp([0;0])] + gr_i=[] + x=standard_define([3 2],model,exprs,gr_i) + end +endfunction + +function [m,k]=uni(fr,of) + k=[]; + m=[]; + ot=[]; + for i=1:size(fr,"*") + istreated=%f; + ind=find(m==fr(i)); + if ind==[] then + m=[m;fr(i)]; + ot=[ot;of(i)]; + k=[k;i]; + else + for j=ind + if of(i)==ot(j) then + istreated=%t + end + end + if ~istreated then + m=[m;fr(i)]; + ot=[ot;of(i)] + k=[k;i]; + end + end + end +endfunction diff --git a/macros/Events/VirtualCLK0.sci b/macros/Events/VirtualCLK0.sci new file mode 100644 index 00000000..b17f1e98 --- /dev/null +++ b/macros/Events/VirtualCLK0.sci @@ -0,0 +1,42 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// +function [x,y,typ]=VirtualCLK0(job,arg1,arg2) + // Copyright INRIA + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + case "define" then + model=scicos_model() + model.sim="vrtclk0" + model.evtin=1 + model.opar=list() + model.ipar=[] + model.blocktype="d" + model.firing=-1 + model.dep_ut=[%f %f] + + exprs=[] + x=standard_define([2 2],model,exprs," ") + end +endfunction diff --git a/macros/Events/freq_div.sci b/macros/Events/freq_div.sci new file mode 100644 index 00000000..4fae5ea5 --- /dev/null +++ b/macros/Events/freq_div.sci @@ -0,0 +1,287 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=freq_div(job,arg1,arg2) + x=[]; + y=[]; + typ=[]; + select job + case "set" then + // look for the modulo block + for i=1:length(arg1.model.rpar.objs) do + o = arg1.model.rpar.objs(i); + if typeof(o) == "Block" & o.gui == "Modulo_Count" then + path = i; + break; + end + end + + // paths to updatable parameters or states + newpar=list(); + y=0; + spath=list() + spath($+1)="model" + spath($+1)="rpar" + spath($+1)="objs" + spath($+1)=path + + xx=arg1(spath)// get the block + //execstr('xxn='+xx.gui+'(''set'',xx)') + xxn=xx; + graphics=xx.graphics; + exprs=graphics.exprs + model=xx.model; + while %t do + [ok,%ph,%df,exprs]=scicos_getvalue.. + ("Set frequency division block parameters",.. + ["Phase (0 to division factor -1)";"Division factor"],.. + list("vec",1,"vec",1),exprs) + if ~ok then + break, + end + if ok then + if %df<1 then + %df=1, + end + %ph=abs(%ph) + if %ph>%df-1 then + %ph=%df-1, + end + graphics.exprs=exprs + model.ipar=%df; + model.dstate=%ph; + xxn.graphics=graphics; + xxn.model=model + break + end + end + + + if diffobjs(xxn,xx) then + model=xx.model + model_n=xxn.model + if ~is_modelica_block(xx) then + modified=or(model.sim<>model_n.sim)|.. + ~isequal(model.state,model_n.state)|.. + ~isequal(model.dstate,model_n.dstate)|.. + ~isequal(model.rpar,model_n.rpar)|.. + ~isequal(model.ipar,model_n.ipar)|.. + ~isequal(model.label,model_n.label) + if or(model.in<>model_n.in)|or(model.out<>model_n.out) then + needcompile=1 + end + if or(model.firing<>model_n.firing) then + needcompile=2 + end + if model.sim=="input"|model.sim=="output" then + if model.ipar<>model_n.ipar then + needcompile=4 + end + end + if or(model.blocktype<>model_n.blocktype)|.. + or(model.dep_ut<>model_n.dep_ut) then + needcompile=4 + end + if (model.nzcross<>model_n.nzcross)|(model.nmode<>model_n.nmode) then + needcompile=4 + end + if prod(size(model_n.sim))>1 then + if model_n.sim(2)>1000 then + if model.sim(1)<>model_n.sim(1) then + needcompile=4 + end + end + end + else + modified=or(model_n<>model) + eq=model.equations;eqn=model_n.equations; + if or(eq.model<>eqn.model)|or(eq.inputs<>eqn.inputs)|.. + or(eq.outputs<>eqn.outputs) then + needcompile=4 + end + end + // parameter or states changed + arg1(spath)=xxn// Update + newpar(size(newpar)+1)=1// Notify modification + y=max(y,needcompile) + end + x=arg1 + typ=newpar + case "define" then + scs_m_1=scicos_diagram(); + scs_m_1.objs(1) = Modulo_Count("define"); + scs_m_1.objs(2) = CLKINV_f("define"); + scs_m_1.objs(3) = CLKOUTV_f("define"); + scs_m_1.objs(4) = IFTHEL_f("define"); + scs_m_1.objs(5) = CLKSPLIT_f("define"); + scs_m_1.objs(6) = scicos_link(); + scs_m_1.objs(7) = scicos_link(); + scs_m_1.objs(8) = scicos_link(); + scs_m_1.objs(9) = scicos_link(); + scs_m_1.objs(10) = scicos_link(); + + // Modulo_Count + blk = scs_m_1.objs(1); + graphics = blk.graphics; + model = blk.model; + + graphics.orig = [0 -100]; + graphics.sz = [60 40]; + + graphics.exprs = ["0";"3"]; + model.dstate = 3; + model.ipar = 3; + + graphics.pout = 7; + graphics.pein = 10; + + blk.graphics = graphics; + blk.model = model; + scs_m_1.objs(1) = blk; + + // CLKINV_f + blk = scs_m_1.objs(2); + graphics = blk.graphics; + model = blk.model; + + graphics.orig = [120 0]; + graphics.sz = [20 20]; + + graphics.exprs = ["1"]; + model.ipar = 1; + + graphics.peout = 6; + + blk.graphics = graphics; + blk.model = model; + scs_m_1.objs(2) = blk; + + // CLKOUTV_f + blk = scs_m_1.objs(3); + graphics = blk.graphics; + model = blk.model; + + graphics.orig = [130 -160]; + graphics.sz = [20 20]; + + graphics.exprs = ["1"]; + model.ipar = 1; + + graphics.pein = 8; + + blk.graphics = graphics; + blk.model = model; + scs_m_1.objs(3) = blk; + + // IFTHEL_f + blk = scs_m_1.objs(4); + graphics = blk.graphics; + model = blk.model; + + graphics.orig = [100 -100]; + graphics.sz = [60 40]; + + graphics.exprs = ["1";"0"]; + model.ipar = 1; + + graphics.pin = 7; + graphics.pein = 9; + graphics.peout = [0;8]; + + blk.graphics = graphics; + blk.model = model; + scs_m_1.objs(4) = blk; + + // CLKSPLIT_f + blk = scs_m_1.objs(5); + graphics = blk.graphics; + model = blk.model; + + graphics.orig = [127 -33]; + graphics.sz = [7 7]; + + graphics.pein = 6; + graphics.peout = [9;10]; + + blk.graphics = graphics; + blk.model = model; + scs_m_1.objs(5) = blk; + + // CLKINV_f -> CLKSPLIT_f + lnk = scs_m_1.objs(6); + + lnk.ct = [5 -1]; + lnk.from = [2 1 0]; + lnk.to = [5 1 1]; + + scs_m_1.objs(6) = lnk; + + // Modulo_Count -> IFTHEL_f + lnk = scs_m_1.objs(7); + + lnk.from = [1 1 0]; + lnk.to = [4 1 1]; + + scs_m_1.objs(7) = lnk; + + // IFTHEL_f -> CLKOUTV_f + lnk = scs_m_1.objs(8); + + lnk.ct = [5 -1]; + lnk.from = [4 2 0]; + lnk.to = [3 1 1]; + + scs_m_1.objs(8) = lnk; + + // CLKSPLIT_f -> IFTHEL_f + lnk = scs_m_1.objs(9); + + lnk.ct = [5 -1]; + lnk.from = [5 1 0]; + lnk.to = [4 1 1]; + + scs_m_1.objs(9) = lnk; + + // CLKSPLIT_f -> Modulo_Count + lnk = scs_m_1.objs(10); + + lnk.xx = [0 30 1]; + lnk.yy = [0 -30 1]; + + lnk.ct = [5 -1]; + lnk.from = [5 2 0]; + lnk.to = [1 1 1]; + + scs_m_1.objs(10) = lnk; + + clear blk lnk + + model=scicos_model(); + model.sim = "csuper"; + model.evtin = 1; + model.evtout = 1; + model.rpar = scs_m_1; + + gr_i=[]; + x=standard_define([3 2],model,[],gr_i) + end +endfunction + |