Interfacing function
eng


Time_f

File content


//Time_f Scicos time signal block
//Classical interface function ver1.0 - scilab-2.7
//19 novembre 2003 - IRCOM GROUP - Author : A.Layec
function [x,y,typ]=Time_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 time assessing parameter.';..
          ' Output will be a monotonic function';..
          ' representing the time.';..
          ' t(i+1) = t(i) + 1/Freq_sampling';..
          ' at each input event'];
   [ok,frequ,init_state,exprs]=getvalue(TEXT,..
        ['Frequency sampling (Hz)';'Initial condition'],..
         list('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 ~ok then
       message(mess)
     else
       [model,graphics,ok]=check_io(model,graphics,[],Nu,1,[])

         if ok then
           graphics.exprs=exprs
           model.rpar=frequ(:)
           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

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

  exprs=[string(frequ),string(init_state)]
  gr_i=['txt=[''Time signal''];';
    'xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');']
  x=standard_define([2 2],model,exprs,gr_i)
end
endfunction