Interfacing function
eng


ZGEN_f

File content


//ZGEN_f Scicos discret generator block
//Classical interface function ver1.0 - scilab-3
//8 juillet 2004 - IRCOM GROUP - Author : A.Layec
function [x,y,typ]=ZGEN_f(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,ny,nl,z,herit,exprs]=getvalue('Scicos Discrete generator block',...
      ['Size of outputs';'Size of memory word';...
      'Initial discrete state';'Inherit (no:0, yes:1)'],...
      list('vec',1,'vec',1,'vec',-1,'vec',1),exprs);

      if ~ok then break,end;

      if(size(z,'*')<>nl+1) then
       message("Size of inital discrete state must be the Size of memory word+1");
       ok=%f
      end
      
      if ok then
        if herit==1 then
            model.dep_ut=[%t %f]
            [model,graphics,ok]=check_io(model,graphics,[],ny,[],[])
        else
            model.dep_ut=[%f %f]
            [model,graphics,ok]=check_io(model,graphics,[],ny,1,[])
        end
        model.out=ny
        model.dstate=z(:)
        model.ipar=nl
        graphics.exprs=exprs
        x.graphics=graphics; x.model=model;
        break
      end
   end


case 'define' then
  ny=16
  nl=128
  z=zeros(128+1,1)
  herit=0

  model=scicos_model()
  model.sim=list('z_gen',4)
  model.in=[]
  model.out=[ny]
  model.evtin=[1]
  model.evtout=[]
  model.dstate=zeros(128+1,1)
  model.rpar=[]
  model.ipar=nl
  model.blocktype='d'
  model.firing=[]
  model.dep_ut=[%f %f]

  gr_i=['txt=[''Z_gen''];';
    'xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');']
  exprs=[string(ny),string(nl),string('zeros(128+1,1)'),string(herit)]
  x=standard_define([2 2],model,exprs,gr_i)
end
endfunction