Interfacing function
eng


CHARGEPUMP_f

File content


//CHARGEPUMP_f Scicos Charge Pump block
//Classical interface function ver1.0 - scilab-2.7
//9 octobre 2003 - IRCOM GROUP - Author : A.Layec
//11 janvier 2005 : Type 4/Rajout option pour bruit 
//                  uniforme sur courant de fuite
function [x,y,typ]=CHARGEPUMP_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,outcur,leakcur,sig,herit,exprs]=getvalue('Scicos Charge Pump block',...
      ['Output current [A]';'Mean of Leakage current [A] (0:No constant leakage)';...
      'Variance of leakage current [A] (0:No variance)';'Inherit (no:0, yes:1)'],...
      list('vec',-1,'vec',-1,'vec',-1,'vec',1),exprs);

      if ~ok then break,end;

        if (size(outcur)==size(leakcur) & size(outcur)==size(sig)) then
         Nu = prod(size(outcur));
         if herit==1 then
           model.dep_ut=[%t %f]
           [model,graphics,ok]=check_io(model,graphics,[Nu;Nu],Nu,[],[])
         else
           model.dep_ut=[%t %f]
           [model,graphics,ok]=check_io(model,graphics,[Nu;Nu],Nu,1,[])
         end
         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
            graphics.exprs=exprs;
            model.rpar=[outcur;leakcur;sig];
            model.ipar=typ_noise;
            x.graphics=graphics; x.model=model;
            break;
         end
        else
         message('All parameters must have the same size');
        end
   end

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

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