Interfacing function
eng


PFD_f

File content


//PFD_f Scicos Phase/Frequency tristate Detector block
//Classical interface function ver1.0 - scilab-3
//9 juin 2004 - IRCOM GROUP - Author : A.Layec
function [x,y,typ]=PFD_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,d_puls,outcur,leakcur,sig,exprs]=getvalue('Scicos Phase/Frequency tristate Detector',...
      ['Lenght of anti-backlash pulse (0:No pulse/Length of pulse [s])';...
      'Output current [A]';'Mean of Leakage current [A] (0:No constant leakage)';...
      'Variance of leakage current [A] (0:No variance)'],...
      list('vec',-1,'vec',-1,'vec',-1,'vec',-1),exprs);

      if ~ok then break,end;

        if ( (size(d_puls)==size(outcur))&(size(d_puls)==size(leakcur))&(size(d_puls)==size(sig)) ) then
           Nu = prod(size(d_puls));
           //[model,graphics,ok]=check_io(model,graphics,[],Nu,[1;1],[]);
           if ok then
            if (sum(leakcur)==0 & sum(sig)==0) then
              typ_noise=0;
            elseif (sum(leakcur)<>0 & sum(sig)==0) then
              typ_noise=1;
            elseif (sum(leakcur)==0 & sum(sig)<>0) then
              typ_noise=2;
            elseif (sum(leakcur)<>0 & sum(sig)<>0) then
              typ_noise=2;
            else
              typ_noise=0;            
            end  
            if d_puls<>0 then
             [model,graphics,ok]=check_io(model,graphics,[],Nu,[1;1;1],[1])
             model.sim=list('pfdt',4)
             model.out=Nu
             model.evtin=[1;1;1]
             model.evtout=[1]
             model.firing=[-1]
             model.rpar=[d_puls;outcur;leakcur;sig]
             model.ipar=[typ_noise]
             model.dstate=[zeros(1,Nu);zeros(1,Nu);zeros(1,Nu);zeros(1,Nu);zeros(1,Nu)]
            else
             [model,graphics,ok]=check_io(model,graphics,[],Nu,[1;1],[])
             model.sim=list('pfd',4)
             model.out=Nu
             model.evtin=[1;1]
             model.evtout=[]
             model.firing=[]
             model.rpar=[outcur;leakcur;sig]
             model.ipar=[typ_noise]
             model.dstate=[zeros(1,Nu);zeros(1,Nu)]
            end
              graphics.exprs=exprs;              
              x.graphics=graphics; x.model=model;
              break;
           end
        else
         message('Vector Output current and Vector Leakage current must have the same size');
        end
   end

case 'define' then
  Nu=1
  d_puls=0
  outcur=5e-3
  leakcur=1e-9
  sig=0
  typ_noise=1
  
  
  model=scicos_model()
  model.sim=list('pfd',4)
  model.in=[]
  model.out=Nu
  model.evtin=[1;1]
  model.evtout=[]
  model.dstate=[zeros(1,Nu);zeros(1,Nu)]
  model.rpar=[outcur;leakcur;sig]
  model.ipar=[typ_noise]
  model.blocktype='d'
  model.firing=[]
  model.dep_ut=[%f %f]

  gr_i=['txt=[''PFD''];';
    'xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');']
  exprs=[sci2exp(d_puls),sci2exp(outcur),sci2exp(leakcur),sci2exp(sig)];
  x=standard_define([2.5 2],model,exprs,gr_i)
end
endfunction