Previous Next Contents

15  Useful Functions

15.1   standard_define Scicos block initial definition function




CALLING SEQUENCE :

o=standard_define(sz,model,dlg,gr_i)



PARAMETERS :




DESCRIPTION :

This function creates the initial block data structure given the initial size sz, this initial model definition model, the initial parameters expressions dlg and initial icon definition instructions gr_i


See Also : scicos_model X



15.2   standard_draw Scicos block drawing function




CALLING SEQUENCE :

standard_draw(o)



PARAMETERS :




DESCRIPTION :

standard_draw is the Scilab function used to display standard blocks in interfacing functions.

It draws a block with a rectangular shape with any number of regular or event input respectively on the left and right faces of the block (if not flipped), event input or output respectively on the top and bottom faces of the block. Number of ports, size, origin, orientation, background color, icon of the block are taken from the block data structure o
.


See Also : scicos_block X



15.3   standard_input get Scicos block input port positions




CALLING SEQUENCE :

[x,y,typ]=standard_input(o)



PARAMETERS :




DESCRIPTION :

standard_input is the Scilab function used to get standard blocks input port position and types in interfacing functions.

Port positions are computed, each time they are required, as a function of block dimensions.




See Also : scicos_block X



15.4   standard_origin Scicos block origin function




CALLING SEQUENCE :

[x,y]=standard_draw(o)



PARAMETERS :




DESCRIPTION :

standard_origin is the Scilab function used to get standard blocks position in interfacing functions.




See Also : scicos_block X



15.5   standard_output get Scicos block output port positions




CALLING SEQUENCE :

[x,y,typ]=standard_output(o)



PARAMETERS :




DESCRIPTION :

standard_output is the Scilab function used to get standard blocks output port position and types in interfacing functions.

Port positions are computed, each time they are required, as a function of block dimensions.




See Also : scicos_block X



15.6   scicosim Scicos simulation function




CALLING SEQUENCE :

[state,t]=scicosim(state,0,tf,sim,'start' [,tol])
[state,t]=scicosim(state,tcur,tf,sim,'run' [,tol])
[state,t]=scicosim(state,tcur,tf,sim,'finish' [,tol])



PARAMETERS :




DESCRIPTION :

Simulator for Scicos compiled diagram. Usually scicosim is called by scicos to perform simulation of a diagram.

But scicosim
may also be called outside Scicos. Typical usage in such a case may be: scs_m is the diagram Scicos main data structure.

cpr
is the data structure list(state,sim,cor,corinv) if the diagram had been compiled before saved, else cpr=list()


See Also : scicos X, scicos_cpr X



15.7   curblock get current block index in a Scicos simulation function




CALLING SEQUENCE :

k=curblock()



PARAMETERS :




DESCRIPTION :

During simulation it may be interesting to get the index of the current block to trace execution, to get its label, to animate the block icon according to simulation...

For block with a computational function written in Scilab, Scilab primitive function curblock()
allows to get the index of the current block in the compiled data structure.

To obtain path to the block in the Scicos main structure user may uses the corinv
table (see scicos_cpr).

For block with a computational function written in C user may uses the C function k=C2F(getcurblock)()
. Where C2F is the C compilation macro defined in <SCIDIR>/routines/machine.h

For block with a computational function written in Fortran user may uses the integer function k=getcurblock().


See Also : getblocklabel X, getscicosvars X, setscicosvars X, scicos_cpr X, scicos_main X



15.8   getblocklabel get label of a Scicos block at running time




CALLING SEQUENCE :

label=getblocklabel()
label=getblocklabel(k)



PARAMETERS :




DESCRIPTION :

For display or debug purpose it may be usefull to give label to particular blocks of a diagram. This may be done using Scicos editor (Label button in Block menu). During simulation, value of these labels may be obtained in any Scilab block with getblocklabel Scilab primitive function.

For C or fortran computational functions, user may use C2F(getlabel)
to get a block label. See routines/scicos/import.c file for more details

Block indexes are those relative to the compile structurecpr
.




See Also : curblock X, getscicosvars X, setscicosvars X



15.9   getscicosvars get Scicos data structure while running




CALLING SEQUENCE :

v=getscicosvars(name)


PARAMETERS :




DESCRIPTION :

This function may be used in a Scilab block to get value of some particular global data while running. It allows to write diagram monitoring blocks.

for example the instruction disp(getscicosvars('x'))
displays the entire continuous state of the diagram.
x=getscicosvars('x');
xptr=getscicosvars('xptr');
disp(x(xptr(k):xptr(k+1)-1))
displays the continuous state of the k block

|=========================================================|
| name     |  data structure definition                   |
|=========================================================|
|'x'       | continuous state                             |
|'xptr'    | continuous state splitting vector            |
|'z'       | discrete state                               |
|'zptr'    | discrete  state splitting vector             |
|'rpar'    | real parameters vector                       |
|'rpptr'   | rpar  splitting vector                       |
|'ipar'    | integer parameters vector                    |
|'ipptr'   | ipar  splitting vector                       |
|'outtb'   | vector of all input/outputs values           |
|'inpptr'  | inplnk splitting vector                      |
|'outptr'  | outlnk splitting vector                      |
|'inplnk'  | vector of input port values address in lnkptr |
|'outlnk'  | vector of output port values address in lnpkpr|
|'lnkptr'  | outtb splitting vector                       |
|=========================================================|
See scicos_cpr for more detail on these data structures.

For C or fortran computational function the C procedure C2F(getscicosvars)
may used. See routines/scicos/import.c file for more details.


See Also : setscicosvars X, scicosim X, curblock X, scicos_cpr X, getblocklabel X



15.10   setscicosvars set Scicos data structure while running




CALLING SEQUENCE :

setscicosvars(name,v)


PARAMETERS :




DESCRIPTION :

This function may be used in a Scilab block to set value of some particular global data while running. It allows to write diagram supervisor blocks.

for example the instructions
x=getscicosvars('x');
xptr=getscicosvars('xptr');
x(xptr(k):xptr(k+1)-1)=xk
setscicosvars('x',x)
Changes the continuous state of the k block to xk.

|=========================================================|
| name     |  data structure definition                   |
|=========================================================|
|'x'       | continuous state                             |
|'xptr'    | continuous state splitting vector            |
|'z'       | discrete state                               |
|'zptr'    | discrete  state splitting vector             |
|'rpar'    | real parameters vector                       |
|'rpptr'   | rpar  splitting vector                       |
|'ipar'    | integer parameters vector                    |
|'ipptr'   | ipar  splitting vector                       |
|'outtb'   | vector of all input/outputs values           |
|'inpptr'  | inplnk splitting vector                      |
|'outptr'  | outlnk splitting vector                      |
|'inplnk'  | vector of input port values address in lnkptr |
|'outlnk'  | vector of output port values address in lnpkpr|
|'lnkptr'  | outtb splitting vector                       |
|=========================================================|
See scicos_cpr for more detail on these data structures.

For C or fortran computational function the C procedure C2F(setscicosvars)
may used. See routines/scicos/import.c file for more details.

Warning: The use of this function requires a deep knowledge on how scicosim works, it must be used very carefully. Unpredicted parameters, state, link values changes may produce erroneous simulations.


See Also : getscicosvars X, scicosim X, curblock X, scicos_cpr X, getblocklabel X


Previous Next Contents