Interfacing function
eng


DISCRGEN_f

File content


//DISCRGEN_f Scicos discrete time and amplitude signal generator block
//Classical interface function ver1.0 - scilab-3
//30 sept 2004 - IRCOM GROUP - Author : A.Layec
function [x,y,typ]=DISCRGEN_f(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
  graphics=arg1.graphics;exprs=graphics.exprs
  model=arg1.model;
  while %t do
    TEXT=['Set Discrete Generator parameters']

   [ok,frequ,init_state,typ,param,exprs]=getvalue(TEXT,..
        ['Frequency sampling (Hz)';'Initial condition';..
         'Type of generator';'Parameters of generator'],..
         list('vec',-1,'vec',-1,'vec',1,'vec',-1),..
         exprs)

    if ~ok then break,end
    if(size(frequ)==size(init_state)) then
      Nu=size(frequ,'*')
      frequ=frequ(:)
      mess=[]

      for i=1:Nu
        if frequ(i)<0 then
          mess=[mess;'frequency sampling must be positive']
          ok=%f
        end
      end

      if (typ<>1 & typ<>2) then
        mess=[mess;'Type of generator must be 1 or 2']
        ok=%f
      end

      if ~ok then
        message(mess)
      else
        [model,graphics,ok]=check_io(model,graphics,[],Nu,1,[])

        if ok then
          graphics.exprs=exprs
          model.rpar=param(:)
          model.ipar=typ
          model.dstate=init_state
          x.graphics=graphics;
          x.model=model
          break
        end
      end
    else
      message('All parameters must have the same size');
    end
  end

case 'define' then
  Nu=1
  frequ=0.5
  init_state=0
  typ=1
  param=[2*%pi*0.1;2^4]

  model=scicos_model()
  model.sim=list('discrgen',4)
  model.in=[]
  model.out=Nu
  model.evtin=1
  model.evtout=[]
  model.dstate=init_state
  model.rpar=param(:)
  model.ipar=typ
  model.blocktype='d'
  model.firing=[]
  model.dep_ut=[%f %f]

  exprs=[string(frequ);string(init_state);'1';'2*%pi*0.1;2^4']
  gr_i=['txt=[''DISCRGEN''];';
        'xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');']
  x=standard_define([2 2],model,exprs,gr_i)
end
endfunction