Interfacing function
eng


ZGEN_c

File content


//ZGEN_c Scicos discrete buffer generator block
//Classical interface function ver1.0 - scilab-4.1
//20 mars 2007 - INRIA - Author : A.Layec
function [x,y,typ]=ZGEN_c(job,arg1,arg2)
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;
   graphics=arg1.graphics;model=arg1.model;
   exprs=graphics.exprs;

   while %t do
      [ok,z,ny,ci_cnt,exprs]=getvalue('Scicos discrete generator block',...
          ['Initial buffer state';
           'Size of outputs';
           'Initial counter value';],...
          list('vec',-1,'vec',1,'vec',1),exprs);

      if ~ok then break,end;
      nz=size(z,'*')
      if(nz==0) then
        message("Size of inital buffer state must be positive");
        ok=%f
      elseif(ny>nz) then
        message("Size of ouput must be less or equal "+...
                "than the size of the buffer");
        ok=%f
      elseif(ci_cnt>=nz) then
        message("Initial counter value must be less "+...
                "than the size of the buffer");
        ok=%f
      end

      if ok then
        model.out=ny
        [model,graphics,ok]=check_io(model,graphics,[],ny,1,[]);
        model.dstate=[z(:);ci_cnt]
        model.ipar=nz
        graphics.exprs=exprs
        x.graphics=graphics; x.model=model;
        break
      end
   end


case 'define' then
  ny=16
  z=zeros(128,1)
  nz=size(z,'*')
  ci_cnt=0

  model=scicos_model()
  model.sim=list('z_gen',4)
  model.in=[]
  model.out=[ny]
  model.evtin=[1]
  model.evtout=[]
  model.dstate=[z(:);ci_cnt]
  model.rpar=[]
  model.ipar=nz
  model.blocktype='d'
  model.firing=[]
  model.dep_ut=[%f %f]

  gr_i=['txt=[''BUFFER''];';
        'xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');'
        'txt=''In'';'
        '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;']
  exprs=[string('zeros(128,1)'),string(ny),string(ci_cnt)]
  x=standard_define([2 2],model,exprs,gr_i)
end
endfunction