Fonction d'interfaçage
fr
SRRCF_c
//SRRCF_c Scicos Square Root Raised Cosine Filter block
//Classical interface function ver1.0 - scilab-4.1
//27 mars 2007 - INRIA - Author : A.Layec
function [x,y,typ]=SRRCF_c(job,arg1,arg2)
// Copyright INRIA
x=[];y=[];typ=[]
select job
case 'plot' then
standard_draw(arg1)
case 'getinputs' then
[x,y,typ]=standard_inputs(arg1)
case 'getoutputs' then
[x,y,typ]=standard_outputs(arg1)
case 'getorigin' then
[x,y]=standard_origin(arg1)
case 'set' then
x=arg1;
model=arg1.model;
graphics=arg1.graphics;
exprs=graphics.exprs;
while %t do
[ok,insz,ne,r,nb_coef,gain,herit,plot_rep,exprs]=...
getvalue('Set Square Root Raised Cosine Filter',...
['Size of input vectors';...
'Samples per symbol';...
'Roll-Off Factor';...
'Length of impulse response';...
'Filter Gain';...
'Inherit (no:0, yes:1)';...
'Plot impulse response (0:no or winid)'],...
list('vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',1,'vec',1),exprs);
if ~ok then break,end;
//value checking
if find(insz<0)<>[] then
message('Size of input vectors must be >0')
ok=%f
end
if ok then
if find(r<0|r>1)<>[] then
message('Roll-Off factor must be >0 and <1')
ok=%f
end
end
//cross size checking
if ok then
if ~and(size(ne)==size(r)&size(r)==size(gain)&size(r)==size(nb_coef)) then
message(['Frequency sampling vector, vector of Roll-Off, '+...
'vector of Gain and';
'vector ''length of impulse response'' must have the same size']);
ok=%f
else
nfir=size(insz,'*'); //nb filtres
nrep=size(r,'*'); //nb de rep. impuls.
if (nfir<>1&nrep<>1&nfir<>nrep) then
message(['Number of impulse response is different from 1 and is different from '+...
'number of input vectors';'Please check.']);
ok=%f
elseif (nfir==1)&(nrep>1)
message(['You have defined many impulse response for only one';
'input vector. Please check.']);
ok=%f
else
ne=ne(:)
r=r(:)
nb_coef=nb_coef(:)
gain=gain(:)
if plot_rep>0 then
for j=1:nrep
if execstr('puls=filter_tap(1,nb_coef(j),ne(j),r(j),gain(j))','errcatch')<>0 then
message(['Bad parameters in the computation of the impulse response';
'Please try another set of parameters for filter '+string(j)])
ok=%f
break
end
win=xget("window")
xset("window",int(plot_rep+j-1))
xset("wdim",300,200)
xbasc()
plot2d3(1:nb_coef(j),puls,,"111",,rect=[0,min(puls),nb_coef(j),max(puls)]);
xset("window",win);
end
end
end
end
end
if ok then
model.in=sum(insz);
model.out=sum(insz);
//model.dstate=zeros(sum(nb_coef),1);
model.dstate=[];
model.ipar=[nfir;nrep;ones(nrep,1);ne(:);nb_coef(:);insz(:)];
//model.rpar=pulse(:);
model.rpar=[r(:);gain(:)];
graphics.exprs=exprs;
sz=model.in;
if herit==1 then
[model,graphics,ok]=check_io(model,graphics,[sz],[sz],[],[]);
else
[model,graphics,ok]=check_io(model,graphics,[sz],[sz],1,[]);
end
x.model=model
x.graphics=graphics;
break
end
end
case 'define' then
insz=1
ne=12
typ=1
nb_coef=4*ne*1 + 1
r=0.35
gain=1
herit=0
plot_rep=0
nu=sum(insz) //taile du port d'entrée
nfir=size(insz,'*'); //nbre de filtre
nrep=size(r,'*'); //nbre de rep. impuls.
model=scicos_model()
model.sim=list('com_filter',4)
model.in=nu
model.out=nu
model.evtin=1
model.evtout=[]
//model.dstate=zeros(sum(nb_coef),1)
model.dstate=[]
model.ipar=[nfir;nrep;typ(:);ne(:);nb_coef(:);insz(:)]
model.rpar=[r(:);gain(:)]
model.blocktype='d'
model.firing=[]
model.dep_ut=[%t %f]
exprs=[string(insz),string(ne),string(r),string(nb_coef),string(gain),...
string(herit),string(plot_rep)]
gr_i=['thick=xget(''thickness'');';
'pat=xget(''pattern'');';
'fnt=xget(''font'');';
'a=orig(1)+sz(1)/10;';
'b=a+sz(1)*8/10;';
'd=orig(2)+(1-1/10)*sz(2);';
'c=d-sz(2)*8/10;';
'xset(''thickness'',1.5);';
'yy1=[0.176,0.231,0.273,'+..
'0.283,0.249,0.180,'+..
'0.094,0.024,0,'+..
'0.048,0.176,0.369,'+..
'0.592,0.801,0.949];'
'yy=[yy1,0.98,yy1($:-1:1)];'
'xx=(a:(b-a)/30:b);'
'xpoly(xx,(yy)*(d-c)+c);'
'txt=''SRRCF'';'
'style=5;'
'rectstr=stringbox(txt,orig(1),orig(2),0,style,1);'
'w=(rectstr(1,3)-rectstr(1,2))*%zoom;'
'h=(rectstr(2,2)-rectstr(2,4))*%zoom;'
'xstringb(orig(1)+sz(1)/2-w/2,orig(2)-h-4,txt,w,h,''fill'');'
'e=gce();'
'e.font_style=style;'
'xset(''thickness'',thick);'
'xset(''pattern'',pat);'
'xset(''font'',fnt(1),fnt(2));'
]
x=standard_define([2.5 2],model,exprs,gr_i)
end
endfunction