Interfacing function
eng


VTUNE_f

File content


function [x,y,typ]=VTUNE_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;model=arg1.model;
   exprs=graphics.exprs;

   while %t do

      [ok,gain,coef,plot_func,exprs]=...
        getvalue(['   Tunning characteristic','of Voltage Controlled Oscillator'],...
                 ['Gain';'Coefficient';'Plot function (0:no or winid)'],...
        list('vec',-1,'vec',-1,'vec',1),exprs);

      if ~ok then break,end;

        if (size(gain)==size(coef)) then
           Nu = prod(size(gain));
           [model,graphics,ok]=check_io(model,graphics,Nu,Nu,[],[]);
           if ok then
              graphics.exprs=exprs;
              model.rpar=[gain(:);coef(:)];
              x.graphics=graphics; x.model=model;
              break;
           end
        else
         message('Vector Gain and Vector Coefficient must have the same size');
        end
   end
   
case 'define' then
 Nu=1;
  gain=6.91e9;
  coef=0.15;
  plot_func=0;
  
  model=scicos_model()
  model.sim=list('tanhblk',2)
  model.in=Nu
  model.out=Nu
  model.evtin=[]
  model.evtout=[]
  model.dstate=[]
  model.rpar=[gain;coef]
  model.ipar=[]
  model.blocktype='d'
  model.firing=[]
  model.dep_ut=[%t %f]
  
  gr_i=['thick=xget(''thickness'')';
        'pat=xget(''pattern'')';
        'fnt=xget(''font'')';
        'xarrows(orig(1)+[0.116;0.116]*sz(1),orig(2)+[0.082;0.943]*sz(2),4,-1)';
        'xarrows(orig(1)+[0.078;0.922]*sz(1),orig(2)+[0.145;0.145]*sz(2),4,-1)';
        'txt=''w'';'
        'style=2;'
        'rectstr=stringbox(txt,orig(1)+0.22*sz(1),orig(2)+0.81*sz(2),0,style,1);'
        'w=(rectstr(1,3)-rectstr(1,2))*%zoom;'
        'h=(rectstr(2,2)-rectstr(2,4))*%zoom;'
        'xstringb(orig(1)+0.22*sz(1),orig(2)+0.81*sz(2),txt,w,h,''fill'');'
        'e=gce();'
        'e.font_style=style;'
//         'xstring(orig(1)+0.22*sz(1),orig(2)+0.81*sz(2),"'w"',0,0)';
        'txt=''v'';'
        'style=2;'
        'rectstr=stringbox(txt,orig(1)+0.8*sz(1),orig(2)+0.23*sz(2),0,style,1);'
        'w=(rectstr(1,3)-rectstr(1,2))*%zoom;'
        'h=(rectstr(2,2)-rectstr(2,4))*%zoom;'
        'xstringb(orig(1)+0.8*sz(1),orig(2)+0.23*sz(2),txt,w,h,''fill'');'
        'e=gce();'
        'e.font_style=style;'
//         'xstring(orig(1)+0.8*sz(1),orig(2)+0.23*sz(2),"'v"',0,0)';
        'aa=[0.116;0.122;0.129;0.136;0.143;0.15;0.156;0.163;0.17;';
        '    0.177;0.184;0.19;0.197;0.204;0.211;0.218;0.224;0.231;';
        '    0.238;0.245;0.252;0.258;0.265;0.272;0.279;0.286;0.292;';
        '    0.299;0.306;0.313;0.32;0.326;0.333;0.34;0.347;0.354;';
        '    0.36;0.367;0.374;0.381;0.388;0.394;0.401;0.408;0.415;';
        '    0.422;0.428;0.435;0.442;0.449;0.456;0.462;0.469;0.476;';
        '    0.483;0.49;0.496;0.503;0.51;0.517;0.524;0.53;0.537;0.544;';
        '    0.551;0.558;0.564;0.571;0.578;0.585;0.592;0.598;0.605;';
        '    0.612;0.619;0.626;0.632;0.639;0.646;0.653;0.66;0.666;';
        '    0.673;0.68;0.687;0.694;0.7;0.707;0.714;0.721;0.728;0.734;';
        '    0.741;0.748;0.755;0.762;0.768;0.775;0.782;0.789;0.796;0.796];';
        'bb=[0.145;0.157;0.17;0.183;0.195;0.208;0.22;0.232;0.244;0.256;';
        '    0.268;0.28;0.291;0.303;0.314;0.325;0.336;0.347;0.358;0.369;0.38;';
        '    0.39;0.401;0.411;0.421;0.431;0.441;0.451;0.461;0.47;0.48;0.489;';
        '    0.498;0.508;0.517;0.526;0.534;0.543;0.552;0.56;0.568;0.577;0.585;';
        '    0.593;0.601;0.609;0.616;0.624;0.631;0.638;0.646;0.653;0.66;';
        '    0.667;0.673;0.68;0.686;0.693;0.699;0.705;0.711;0.717;0.723;0.729;';
        '    0.734;0.74;0.745;0.75;0.755;0.76;0.765;0.77;0.775;0.779;0.784;';
        '    0.788;0.792;0.796;0.8;0.804;0.808;0.812;0.815;0.818;0.822;0.825;';
        '    0.828;0.831;0.834;0.836;0.839;0.841;0.844;0.846;0.848;0.85;';
        '    0.852;0.854;0.856;0.857;0.858;0.858]';
        'xpoly(orig(1)+aa*sz(1),orig(2)+bb*sz(2),"'lines"')';
        'txt=''VTUNE'';'
        'style=5;'
        'rectstr=stringbox(txt,orig(1),orig(2),0,style,1);'
        'w=(rectstr(1,3)-rectstr(1,2))*%zoom;'
        'h=(rectstr(2,2)-rectstr(2,4))*%zoom;'
        'xstringb(orig(1)+sz(1)/2-w/2,orig(2)-h-4,txt,w,h,''fill'');'
        'e=gce();'
        'e.font_style=style;'
        'xset(''thickness'',thick)';
        'xset(''pattern'',pat)';
        'xset(''font'',fnt(1),fnt(2))';
       ]
  exprs=[sci2exp(gain);sci2exp(coef);string(plot_func)];
  x=standard_define([2 2],model,exprs,gr_i)
  //x.graphics.id="VTUNE"
end
endfunction