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
|
// 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
|