Interfacing function
eng


VECTOMEMOSCOPE_f

File content


//VECTOMEMOSCOPE_f Scicos vector memory visualization block
//Classical interface function ver1.0 - scilab-2.7
//28 janvier 2004 - IRCOM GROUP - Author : A.Layec
function [x,y,typ]=VECTOMEMOSCOPE_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(o)
case 'getoutputs' then
  x=[];y=[];typ=[];
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
    [ok,clrs,win,wpos,wdim,..
            x_dim,y_dim,in_size,xvector,num_win,GRAPHlabel,grid,p2d3,herit,exprs]=getvalue(..
        'Set Scope parameters',..
        ['Color (>0) or mark (<0) ';
        'Output window number';
        'Output window position';
        'Output window sizes';
        'Xmin Xmax';
        'Ymin Ymax';
        'In size';
        'X vector';
        'Number of windows';
        'Graph label';
        'Xgrid(0/1)';
        'plot2d3(0/1)';
        'Inherit (no:0, yes:1)'],..
        list('vec',1,'vec',1,'vec',-1,'vec',-1,'vec',2,..
        'vec',2,'vec',-1,'vec',-1,'vec',1,'str',1,'vec',1,'vec',1,'vec',1),exprs)
    if ~ok then break,end //user cancel modification
     xmin=x_dim(1);xmax=x_dim(2);
     ymin=y_dim(1);ymax=y_dim(2);
     l_win=length(xvector)
    mess=[]
    if size(wpos,'*')<>0 &size(wpos,'*')<>2 then
      mess=[mess;'Window position must be [] or a 2 vector';' ']
      ok=%f
    end
    if size(wdim,'*')<>0 &size(wdim,'*')<>2 then
      mess=[mess;'Window dim must be [] or a 2 vector';' ']
      ok=%f
    end
    if win<0 then
      mess=[mess;'Window number can''t be negative';' ']
      ok=%f
    end
    if ymin>=ymax then
      mess=[mess;'Ymax must be greater than Ymin';' ']
      ok=%f
    end
    if xmin>=xmax then
      mess=[mess;'Xmax must be greater than Xmin';' ']
      ok=%f
    end
    if in_size==0 then
      mess=[mess;'Xvector must be defined';' ']
      ok=%f
    end
    if length(GRAPHlabel)>40 then
      mess=[mess;'Graph label too long (max 40)';' ']
      ok=%f
    end
    if ~or(grid==[0 1]) then
      mess=[mess;'Xgrid option must be 0 or 1';' ']
      ok=%f
    end
    if ~or(p2d3==[0 1]) then
      mess=[mess;'Plot2d3 option must be 0 or 1';' ']
      ok=%f
    end
    if ~ok then
      message(['Some specified values are inconsistent:';
                 ' ';mess])
    end
    if ok then
      if herit==1 then
        model.dep_ut=[%t %f]
        [model,graphics,ok]=check_io(model,graphics,in_size,[],[],[])
      else
        model.dep_ut=[%f %f]
        [model,graphics,ok]=check_io(model,graphics,in_size,[],1,[])
      end
    end

    if ok then
      if wpos==[] then wpos=[-1;-1];end
      if wdim==[] then wdim=[-1;-1];end
      rpar=[xmin;xmax;ymin;ymax;xvector(:)]
      GRAPHlabelsize=length(GRAPHlabel)
      GRAPHlabelCODE=str2code(GRAPHlabel)
      option=grid+p2d3*2
      ipar=[win;clrs;num_win;1;1;wpos(:);wdim(:);l_win;option;..
              GRAPHlabelsize;GRAPHlabelCODE(:)];
      model.dstate=0
      model.rpar=rpar(:)
      model.ipar=ipar(:)
      graphics.exprs=exprs;
      x.graphics=graphics;x.model=model
      break
    end
  end
case 'define' then
  win=1
  wdim=[300;200]
  wpos=[-1;-1]
  clrs=1
  xvector=-20:5:20
  in_size=1024
  l_win=length(xvector)
  num_win=1
  GRAPHlabel='VECTOMEMOSCOPE.C'
  GRAPHlabelsize=length(GRAPHlabel)
  GRAPHlabelCODE=str2code(GRAPHlabel)
  xmin=-15;xmax=+15
  ymin=-15;ymax=+15
  grid=0
  p2d3=0
  option=grid+p2d3*2
  herit=1

  model=scicos_model()
  model.sim=list('vectomemoscope',2)
  model.in=in_size
  model.out=[]
  model.evtin=[]
  model.evtout=[]
  model.dstate=0
  model.ipar=[win;clrs;num_win;1;1;wpos;wdim;l_win;option;GRAPHlabelsize;GRAPHlabelCODE(:)]
  model.rpar=[xmin;xmax;ymin;ymax;xvector(:)]
  model.blocktype='d'
  model.firing=[]
  model.dep_ut=[%t %f]

  exprs=[string(clrs);
         string(win);
         sci2exp([]);
         sci2exp(wdim);
         string(xmin)+" "+string(xmax);
         string(ymin)+" "+string(ymax);
         string(in_size);
         strcat(string(xvector),' ');
         string(num_win);
         GRAPHlabel;
         string(grid);
         string(p2d3);
         string(herit)];
  gr_i=['txt=[''VectoMemo'';''Scope'']';'xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');']
  x=standard_define([2 2],model,exprs,gr_i)
end
endfunction