Interfacing function
eng


CONVOLGEN_f

File content


//CONVOLGEN_f Scicos convol block
//Classical interface function ver1.0 - scilab-3
//29 janvier 2004  Author : - IRCOM GROUP - A.Layec
function [x,y,typ]=CONVOLGEN_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,nu,rep,herit,plot_rep,exprs]=getvalue('Set convolution block',...
      ['Size of input';'Vector of impulse response';...
       'Inherit (no:0, yes:1)';'Plot impulse response (0/1)?'],...
      list('vec',1,'vec',-1,'vec',1,'vec',1),exprs)

      if ~ok then break,end;

      if ok then
          nb=size(rep,'*')
          m=2^(int(log(nu+nb-1)/log(2))+1)
          if plot_rep<>0 then
             win=xget("window")
             xset("window",int(plot_rep))
             xset("wdim",300,200)
             xbasc()
             plot2d3(1:nb,rep,,"111",,rect=[0,min(rep),nb_coef,max(rep)]);
             xset("window",win);
          end

          if herit==1 then
            model.dep_ut=[%f %f]
            [model,graphics,ok]=check_io(model,graphics,[nu],[nu],[],[])
          else
            model.dep_ut=[%f %f]
            [model,graphics,ok]=check_io(model,graphics,[nu],[nu],1,[])
          end
          graphics.exprs=exprs
          model.ipar=m
          model.in=[nu]
          model.out=[nu]
          model.dstate=zeros(nb,1)
          model.rpar=rep(:)
          x.graphics=graphics;x.model=model
          break;
      end
   end

case 'define' then
  nu=256
  herit=1
  rep=1
  plot_rep=0
  nb=size(rep,'*')
  m=2^(int(log(nu+nb-1)/log(2))+1)

  model=scicos_model()
  model.sim=list('convol',4)
  model.in=[nu]
  model.out=[nu]
  model.evtin=[]
  model.evtout=[]
  model.dstate=zeros(nb,1)
  model.rpar=rep(:)
  model.ipar=m
  model.blocktype='d'
  model.firing=[]
  model.dep_ut=[%f %f]

  gr_i=['txt=[''Convol''];';
    'xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');']
  exprs=[string(nu),string(rep),string(herit),string(plot_rep)]
  x=standard_define([2 2],model,exprs,gr_i)
end
endfunction