Interfacing function
eng


PCLOCK_f

File content


function [x,y,typ]=PCLOCK_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
  // paths to updatable parameters or states
  ppath = list(1,2)
  newpar=list();
  y=0;
  for path=ppath do
    np=size(path,'*')
    spath=list()
    for k=1:np
      spath($+1)='model'
      spath($+1)='rpar'
      spath($+1)='objs'
      spath($+1)=path(k)
    end
    xx=arg1(spath)// get the block
    execstr('xxn='+xx.gui+'(''set'',xx)')
    if diffobjs(xxn,xx) then 
	model=xx.model
	 model_n=xxn.model
	 if ~is_modelica_block(xx) then
             modified=or(model.sim<>model_n.sim)|..
	     ~isequal(model.state,model_n.state)|..
	     ~isequal(model.dstate,model_n.dstate)|..
	     ~isequal(model.rpar,model_n.rpar)|..
	     ~isequal(model.ipar,model_n.ipar)|..
	     ~isequal(model.label,model_n.label)
      if or(model.in<>model_n.in)|or(model.out<>model_n.out) then  
	  needcompile=1
	end
	if or(model.firing<>model_n.firing)  then 
	  needcompile=2
	end
	if (size(model.in,'*')<>size(model_n.in,'*'))|..
        (size(model.out,'*')<>size(model_n.out,'*')) then  
         needcompile=4  
       end  
	if model.sim=='input'|model.sim=='output' then
	  if model.ipar<>model_n.ipar then
	    needcompile=4
	  end
	end
	if or(model.blocktype<>model_n.blocktype)|..
	      or(model.dep_ut<>model_n.dep_ut)  then 
	  needcompile=4
	end
	if (model.nzcross<>model_n.nzcross)|(model.nmode<>model_n.nmode) then 
	  needcompile=4
	end
	if prod(size(model_n.sim))>1 then
	  if model_n.sim(2)>1000 then 
	    if model.sim(1)<>model_n.sim(1) then
	      needcompile=4
	    end
	  end
	end
      else 
	modified=or(model_n<>model)
	eq=model.equations;eqn=model_n.equations;
	if or(eq.model<>eqn.model)|or(eq.inputs<>eqn.inputs)|..
				      or(eq.outputs<>eqn.outputs) then  
	  needcompile=4
	end
      end
      // parameter or states changed
      arg1(spath)=xxn// Update
      newpar(size(newpar)+1)=path// Notify modification
      y=max(y,needcompile)
    end
  end
  x=arg1
  typ=newpar
case 'define' then
scs_m_1=scicos_diagram()
scs_m_1.props=tlist(..
["params","wpar","title","tol","tf","context","void1","options","void2","void3",..
"doc"],[600,450,0,0,600,450],"PCLOCK_f",[0.0001;1.000E-06;1.000E-10;100001;0;0;0],270," ",[],..
tlist(["scsopt","3D","Background","Link","ID","Cmap"],list(%t,33),[8,1],[1,5],..
list([5,1],[4,1]),[0.8,0.8,0.8]),[],[],list())
scs_m_1.objs(1)=mlist(["Block","graphics","model","gui","doc"],..
                mlist(..
                ["graphics","orig","sz","flip","exprs","pin","pout","pein",..
                "peout","gr_i","id","in_implicit","out_implicit"],..
                [273.70536,308.45238],[60,40],%t,["0.1";"0"],7,[],5,[5;3;4],..
                list(..
                ["txt=[''Phase'';''Modulator''];";
                "xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');"],8),"","E",..
                []),..
                mlist(..
                ["model","sim","in","out","evtin","evtout","state","dstate",..
                "rpar","ipar","blocktype","firing","dep_ut","label","nzcross",..
                "nmode","equations"],list("pevtdly",4),1,[],1,[1;1;1],[],0,1,[],..
                "d",[0;-1;-1],[%f,%f],"",0,0,list()),"PEVTDLY_f",list())
scs_m_1.objs(2)=mlist(["Block","graphics","model","gui","doc"],..
                mlist(..
                ["graphics","orig","sz","flip","exprs","pin","pout","pein",..
                "peout","gr_i","id","in_implicit","out_implicit"],..
                [295.37202,264.55357],[16.666667,16.666667],%t,[],[],[],[0;3;4],..
                9,..
                list(..
                ["rx=sz(1)*p/2;ry=sz(2)/2";
                "xsegs(orig(1)+rx*[1/2.3 1;2-1/2.3 1],orig(2)+ry*[1 2-1/2.3;1,1/2.3],0)"],..
                8),"",[],[]),..
                mlist(..
                ["model","sim","in","out","evtin","evtout","state","dstate",..
                "rpar","ipar","blocktype","firing","dep_ut","label","nzcross",..
                "nmode","equations"],"sum",[],[],[1;1;1],1,[],[],[],[],"d",-1,..
                [%f,%f],"",0,0,list()),"CLKSOMV_f",list())
scs_m_1.objs(3)=mlist(["Link","xx","yy","id","thick","ct","from","to"],..
                [303.70536;303.70536],[302.7381;281.22024],"drawlink",[0,0],..
                [5,-1],[1,2,0],[2,2,1])
scs_m_1.objs(4)=mlist(["Link","xx","yy","id","thick","ct","from","to"],..
                [318.70536;318.70536;312.03869],[302.7381;272.8869;272.8869],..
                "drawlink",[0,0],[5,-1],[1,3,0],[2,3,1])
scs_m_1.objs(5)=mlist(["Link","xx","yy","id","thick","ct","from","to"],..
                [288.70536;288.70536;252.87202;252.87202;303.70536;303.70536],..
                [302.7381;292.08333;292.08333;367.23214;367.23214;354.16667],..
                "drawlink",[0,0],[5,-1],[1,1,0],[1,1,1])
scs_m_1.objs(6)=mlist(["Block","graphics","model","gui","doc"],..
                mlist(..
                ["graphics","orig","sz","flip","exprs","pin","pout","pein",..
                "peout","gr_i","id","in_implicit","out_implicit"],..
                [225.13393,318.45238],[20,20],%t,"1",[],7,[],[],list(" ",8),"",..
                [],"E"),..
                mlist(..
                ["model","sim","in","out","evtin","evtout","state","dstate",..
                "rpar","ipar","blocktype","firing","dep_ut","label","nzcross",..
                "nmode","equations"],"input",[],-1,[],[],[],[],[],1,"c",[],..
                [%f,%f],"",0,0,list()),"IN_f",list())
scs_m_1.objs(7)=mlist(["Link","xx","yy","id","thick","ct","from","to"],..
                [245.13393;265.13393],[328.45238;328.45238],"drawlink",[0,0],..
                [1,1],[6,1,0],[1,1,1])
scs_m_1.objs(8)=mlist(["Block","graphics","model","gui","doc"],..
                mlist(..
                ["graphics","orig","sz","flip","exprs","pin","pout","pein",..
                "peout","gr_i","id","in_implicit","out_implicit"],..
                [293.70536,206.93452],[20,30],%t,"1",[],[],9,[],list(" ",8),"",..
                [],[]),..
                mlist(..
                ["model","sim","in","out","evtin","evtout","state","dstate",..
                "rpar","ipar","blocktype","firing","dep_ut","label","nzcross",..
                "nmode","equations"],"output",[],[],1,[],[],[],[],1,"d",[],..
                [%f,%f],"",0,0,list()),"CLKOUTV_f",list())
scs_m_1.objs(9)=mlist(["Link","xx","yy","id","thick","ct","from","to"],..
                [303.70536;303.70536],[266.93452;236.93452],"drawlink",[0,0],..
                [5,-1],[2,1,0],[8,1,1])
model = mlist(..
["model","sim","in","out","evtin","evtout","state","dstate","rpar","ipar","blocktype",..
"firing","dep_ut","label","nzcross","nmode","equations"],"csuper",-1,[],[],1,[],[],..
scs_m_1,[],"h",[],[%f,%f],"",0,0,list())
  //gr_i='xstringb(orig(1),orig(2),''PEVTDLY2_f'',sz(1),sz(2),''fill'')';
  gr_i=list(['wd=xget(''wdim'').*[1.016,1.12];';
	       'thick=xget(''thickness'');xset(''thickness'',2);';
	       'p=wd(2)/wd(1);p=1;';
	       'rx=sz(1)*p/2;ry=sz(2)/2;';
	       'xarcs([orig(1)+0.05*sz(1);';
	       'orig(2)+0.95*sz(2);';
	       '   0.9*sz(1)*p;';
	       '   0.9*sz(2);';
	       '   0;';
	       '   360*64],scs_color(5));';
	       'xset(''thickness'',1);';
	       'xx=[orig(1)+rx    orig(1)+rx;';
	       '    orig(1)+rx    orig(1)+rx+0.6*rx*cos(%pi/6)];';
	       'yy=[orig(2)+ry    orig(2)+ry ;';
	       '  orig(2)+1.8*ry  orig(2)+ry+0.6*ry*sin(%pi/6)];';
	       'xsegs(xx,yy,scs_color(10));';
	       'xset(''thickness'',thick);'],8)
  x=standard_define([2 2],model,[],gr_i)
end
endfunction