[Scilab-users] Xcos Debugging : block number, Flag and tutorial

Serge Steer Serge.Steer at inria.fr
Tue Jul 29 12:22:07 CEST 2014


Le 29/07/2014 10:16, Quentin Mazué a écrit :
> Hi,
>
> I need to make some debugging in Xcos, and for that I use the block "DEBUG"
> with the code below:
>
> -------------------------------------------------------------------------
> xcos_debug_gui(flag,block);
> warnBlockByUID(block.label, "ERROR");
> n=curblock();
> f=%cpr.sim.funs(n)
> path=%cpr.corinv(n);
> t=scicos_time();
> printf("flag=%d, t=%g, n=%d, f=%s \n", flag,t,n,f)
> if n==5 then
> 	printf("u=%g, y=%g \n ------- \n", block.inptr(1), block.outptr(1))
> 	pause
> end
> -------------------------------------------------------------------------
>
> 1)
> I have some difficulties in a huge diagram (several hundreds of blocks) to
> find the block I want to analyze. Indeed I need to get the block number in
> the scs_m structure and until now I use the following procedure:
>
> During the debugging I wait until the simulation stop (at Flag = 1 for
> example)
> I use a loop with the getlabelblock(i) function until it gives me the label
> of the block I want to follow.
> I stop the simulation
> I correct the line n==5 to n==i (i : block number that I want to follow)
> I start again the simulation
>
> => Is there a simpler way to get the block number?
You can use %cpr.sim.uids(curblock()) to get the UID of the current 
block and you can use it suspend execution when this bloc is called

if %cpr.sim.uids(n)=="50cd0851:14781837c95:-7f41" the
	printf("u=%g, y=%g \n ------- \n", block.inptr(1), block.outptr(1))
	pause
end


>
> => Why the function "xcos_blocks_info(%cpr)" detailed page 209 in the book
> "Scilab de la théorie à la pratique" written by Serge Steer and Yvon Degré
> does not exist in Scilab 5.5.0? This function could be useful because we
> have a direct correlation between block number and their uid.
Please find it attached
> 2)
> Is there a list of all flag signification in Xcos?
> How/When/in which order are these flags called in Xcos?
Yes,  a table is given in the book "Scilab de la théorie à la pratique"
> 3)
> Are there some tutorials to explain how to debug an Xcos Diagram?
There are some details on how to  debug the scheduling in the same book. 
But debug may have a lot of meanings...

Serge Steer

-------------- next part --------------
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) - 2013 - INRIA -Serge Steer
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution.  The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
function info=xcos_blocks_info(cpr);
//creates a tabular of the blocks used
  sim=cpr.sim;
  nblk=sim.nb;
  funs=sim.funs;
  labels=sim.labels;
  ptr=sim.xptr;sel=find(ptr(1:$-1)<ptr(2:$));
  indx=emptystr(nblk,1);
  indx(sel)=string(ptr(sel))+":"+string(ptr(sel+1)-1);

  ptr=sim.zptr;sel=find(ptr(1:$-1)<ptr(2:$));
  indz=emptystr(nblk,1);
  indz(sel)=string(ptr(sel))+":"+string(ptr(sel+1)-1);

  ptr=sim.ozptr;sel=find(ptr(1:$-1)<ptr(2:$));
  indoz=emptystr(nblk,1);
  indoz(sel)=string(ptr(sel))+":"+string(ptr(sel+1)-1);
  
  ptr=sim.rpptr;sel=find(ptr(1:$-1)<ptr(2:$));
  indrp=emptystr(nblk,1);
  indrp(sel)=string(ptr(sel))+":"+string(ptr(sel+1)-1);

  ptr=sim.ipptr;sel=find(ptr(1:$-1)<ptr(2:$));
  indip=emptystr(nblk,1);
  indip(sel)=string(ptr(sel))+":"+string(ptr(sel+1)-1);

  ptr=sim.opptr;sel=find(ptr(1:$-1)<ptr(2:$));
  indop=emptystr(nblk,1);
  indop(sel)=string(ptr(sel))+":"+string(ptr(sel+1)-1);

  info=["block number","simulation function","uid","rpar index","ipar"+...
        " index","opar index","z index","oz index","x index"];
  for i=1:nblk
    info=[info;
          string(i),funs(i),labels(i),indrp(i),indip(i),indop(i),indz(i),indoz(i),indx(i)];
  end
endfunction



More information about the users mailing list