File size: 3,925 Bytes
39e01c4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | // 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]=CLOCK_f(job,arg1,arg2)
x=[];
y=[];
typ=[];
select job
case "set" then
// look for the internal edge trigger block
for i=1:length(arg1.model.rpar.objs) do
o = arg1.model.rpar.objs(i);
if typeof(o) == "Block" & o.gui == "EVTDLY_f" then
path = i;
break;
end
end
newpar=list();
xx=arg1.model.rpar.objs(path)// get the evtdly block
exprs=xx.graphics.exprs
model=xx.model;
t0_old=model.firing
dt_old= model.rpar
model_n=model
while %t do
[ok,dt,t0,exprs0]=scicos_getvalue(..
_("Set Clock block parameters"),..
_(["Period";"Init time"]),list("vec",1,"vec",1),exprs)
if ~ok then
break,
end
if dt<=0 then
message(_("Period must be > 0"))
ok=%f
end
if ok then
xx.graphics.exprs=exprs0
model.rpar=dt
model.firing=t0
xx.model=model
arg1.model.rpar.objs(path)=xx// Update
break
end
end
if ~and([t0_old dt_old]==[t0 dt])|~and(exprs0==exprs) then
// parameter changed
newpar(size(newpar)+1)=path// Notify modification
end
if t0_old<>t0 then
needcompile=2,
else
needcompile=0,
end
x=arg1
y=needcompile
typ=newpar
case "define" then
evtdly=EVTDLY_f("define")
evtdly.graphics.orig=[320,232]
evtdly.graphics.sz=[40,40]
evtdly.graphics.exprs=["0.1";"0.1"]
evtdly.graphics.pein=6
evtdly.graphics.peout=3
evtdly.model.rpar=0.1
evtdly.model.firing=0.1
output_port=CLKOUT_f("define")
output_port.graphics.orig=[399,162]
output_port.graphics.sz=[20,20]
output_port.graphics.exprs="1"
output_port.graphics.pein=5
output_port.model.ipar=1
split=CLKSPLIT_f("define")
split.graphics.orig=[380.71066;172]
split.graphics.pein=3,
split.graphics.peout=[5;6]
gr_i=[]
diagram=scicos_diagram();
diagram.objs(1)=output_port
diagram.objs(2)=evtdly
diagram.objs(3)=scicos_link(xx=[340;340;380.71],..
yy=[226.29;172;172],..
ct=[5,-1],from=[2,1],to=[4,1])
diagram.objs(4)=split
diagram.objs(5)=scicos_link(xx=[380.71;399],yy=[172;172],..
ct=[5,-1],from=[4,1],to=[1,1])
diagram.objs(6)=scicos_link(xx=[380.71;380.71;340;340],..
yy=[172;302;302;277.71],..
ct=[5,-1],from=[4,2],to=[2,1])
x=scicos_block()
x.gui="CLOCK_f"
x.graphics.sz=[2,2]
x.graphics.gr_i=gr_i
x.graphics.peout=0
x.model.sim="csuper"
x.model.evtout=1
x.model.blocktype="h"
x.model.firing=%f
x.model.dep_ut=[%f %f]
x.model.rpar=diagram
end
endfunction
|