Interfacing function
eng


GENINT_f

File content


//GENINT_f Scicos Random Integer Generator block
//Classical interface function ver1.0 - scilab-2.7
//13 octobre 2003 - IRCOM GROUP - Author : A.Layec
function [x,y,typ]=GENINT_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,nbit,typ,exprs]=getvalue('Scicos Random Integer Generator',...
      ['Number of bits per Integer';'Type'],...
      list('vec',-1,'vec',-1),exprs);

      if ~ok then break,end;

        if size(nbit)==size(typ) then
          nboutput=prod(size(nbit));
          [model,graphics,ok]=check_io(model,graphics,[],nboutput,1,[]);
          if ok then
             graphics.exprs=exprs;
             model.dstate=zeros(nboutput,1);
             alpha=int([nbit typ]);
             model.ipar=alpha(:);
             x.graphics=graphics; x.model=model;
             break;
          end
          else
          message('Vector Number of bits and Vector type must have the same size');
        end
   end

case 'define' then
  nbit=1;
  nboutput=1;
  typ=0;

  model=scicos_model()
  model.sim=list('genint',4)
  model.in=[]
  model.out=nboutput
  model.evtin=1
  model.evtout=[]
  model.dstate=zeros(1,1)
  model.rpar=[]
  model.ipar=[nbit typ]
  model.blocktype='d'
  model.firing=[]
  model.dep_ut=[%f %f]

  gr_i=['txt=[''Random'';''Integer'';''Generator''];';
    'xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');']
  label=[sci2exp(nbit);sci2exp(typ)];
  x=standard_define([2.5 2],model,label,gr_i)
end
endfunction