Fonction d'interfaçage
fr
DAC_c
//DAC_c Digital to Analog Converter block
//Classical interface function ver1.0 - scilab-3.0
//8 Mars 2006 - INRIA - Author : A.Layec
function [x,y,typ]=DAC_c(job,arg1,arg2)
x=[];y=[];typ=[]
select job
case 'plot' then
x=arg1;
graphics=arg1.graphics;
if graphics.flip then
graphics.gr_i(1)(5)='xstringb(orig(1)+sz(1)*0.1,orig(2)+sz(2)*0.15,txt,sz(1)*0.7,sz(2)*0.7,''fill'');'
graphics.gr_i(1)(7)='xpoly(orig(1)+[0.05;0.05;0.7;0.95;0.7;0.05]*sz(1),orig(2)+[0.9;0.1;0.1;0.5;0.9;0.9]*sz(2),""lines"")'
else
graphics.gr_i(1)(5)='xstringb(orig(1)+sz(1)*0.2,orig(2)+sz(2)*0.15,txt,sz(1)*0.7,sz(2)*0.7,''fill'');'
graphics.gr_i(1)(7)='xpoly(orig(1)+[0.95;0.95;0.3;0.05;0.3;0.95]*sz(1),orig(2)+[0.9;0.1;0.1;0.5;0.9;0.9]*sz(2),""lines"")'
end
x.graphics=graphics;
standard_draw(x)
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;
graphics=arg1.graphics;model=arg1.model;
exprs=graphics.exprs;
while %t do
text=['Set Digital to Analog Converter Block'];
[ok,q,vmin,nbit,cc2,herit,exprs]=getvalue(text,...
['Step';'Minimun output value';'Number of bits';...
'2''s complement (0:no, 1:yes)';'Inherit (no:0, yes:1)'],...
list('vec',-1,'vec',-1,'vec',-1,'vec',1,'vec',1),exprs);
if ~ok then break,end;
if (size(vmin)==size(q)&size(q)==size(nbit)&size(q)==size(cc2)) then
Nu = prod(size(q));
if herit==1 then
model.evtin=[]
[model,graphics,ok]=check_io(model,graphics,Nu,Nu,[],[]);
else
model.evtin=1
[model,graphics,ok]=check_io(model,graphics,Nu,Nu,1,[]);
end
model.in=Nu
model.out=Nu
if ok then
graphics.exprs=exprs;
rpar=[q;vmin];
model.rpar=rpar(:);
alpha=int([nbit;cc2]);
model.ipar=alpha(:);
x.graphics=graphics; x.model=model;
break;
end
else
message('All parameters (except the last) must have the same size');
end
end
case 'define' then
Nu=1;
nbit=8;
q=0.1;
vmin=0;
cc2=1;
herit=1;
model=scicos_model()
model.sim=list('dac',4)
model.in=Nu
model.out=Nu
model.evtin=[]
model.evtout=[]
model.dstate=[]
model.rpar=[q;vmin]
model.ipar=[nbit;cc2]
model.blocktype='d'
model.firing=[]
model.dep_ut=[%t %f]
gr_i=['txt=[''DAC''];';
'thick=xget(''thickness'')'
'pat=xget(''pattern'')'
'fnt=xget(''font'')'
'xstringb(orig(1)+sz(1)*0.1,orig(2)+sz(2)*0.15,txt,sz(1)*0.7,sz(2)*0.7,''fill'');'
'xset(''thickness'',2)'
'xpoly(orig(1)+[0.95;0.95;0.3;0.05;0.3;0.95]*sz(1),orig(2)+[0.9;0.1;0.1;0.5;0.9;0.9]*sz(2),""lines"")'
'xset(''thickness'',thick)'
'xset(''pattern'',pat)'
'xset(''font'',fnt(1),fnt(2))'
]
label=[sci2exp(q),sci2exp(vmin),sci2exp(nbit),sci2exp(cc2),string(herit)];
x=standard_define([2 2],model,label,gr_i)
end
endfunction