15 Useful Functions
15.1 standard_define Scicos block initial definition function
CALLING SEQUENCE :
o=standard_define(sz,model,dlg,gr_i)
PARAMETERS :
- o
: Scicos block data structure (see scicos_block)
- sz
: 2 vector, giving the initial block width and height
- model
: initial model data structure definition (see scicos_model)
- dlg
: vector of character strings,initial parameters expressions
- gr_i
: vector of character strings, initial icon definition instructions
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 :
- o
: Scicos block data structure (see scicos_block)
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 :
- o
: Scicos block data structure (see scicos_block)
- x
: vector of x coordinates of the block regular and event input ports
- y
: vector of y coordinates of the block regular and event output ports
- typ
: vector of input ports types (+1 : regular port; -1:event port)
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 :
- o
: Scicos block data structure (see scicos_block)
- x
: x coordinate of the block origin (bottom left corner)
- y
: y coordinate of the block origin (bottom left corner)
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 :
- o
: Scicos block data structure (see scicos_block)
- x
: vector of x coordinates of the block regular and event output ports
- y
: vector of y coordinates of the block regular and event output ports
- typ
: vector of output ports types (+1 : regular port; -1:event port)
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 :
- state
: Scilab tlist contains scicosim initial state. Usually generated by Scicos
Compile or Run menus (see scicos_cpr for more details).
- tcur
: initial simulation time
- tf
: final simulation time (Unused with options 'start' and 'finish'
- sim
: Scilab tlist. Usually generated by Scicos
Compile menu (see scicos_cpr for more details).
- tol
: 4 vector [atol,rtol,ttol,deltat] where atol, rtol are respectively the
absolute and relative tolerances for ode solver (see ode), ttol is the precision on event dates. deltat is maximum integration
interval for each call to ode solver.
- t
: final reached time
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:
- 1
Use Scicos to define a block diagram, compile it.
- 2
Save the compiled diagram using Save,SaveAs Scicos menus .
- 3
In Scilab, load saved file using load function. You get
variables scicos_ver, scs_m, cpr
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()
- 4
Extract state, sim out of cpr
- 5
Execute [state,t]=scicosim(state,0,tf,sim,'start' [,tolerances]) for initialisation.
- 6
Execute [state,t]=scicosim(state,0,tf,sim,'run' [,tolerances]) for simulation from 0 to tf. Many successives such calls may be
performed changing initial and final time.
- 7
Execute [state,t]=scicosim(state,0,tf,sim,'finish' [,tolerances]) at the very end of the simulation to close files,...
For advanced user it is possible to "manually" change some parameters
or state values
See Also :
scicos
X, scicos_cpr
X
15.7 curblock get current block index in a Scicos simulation function
CALLING SEQUENCE :
k=curblock()
PARAMETERS :
- k
: integer, index of the block corresponding to the Scilab simulation
function where this function is called.
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 :
- k
: integer, index of the block. if k is omitted kis
supposed to be equal to curblock().
- label
: a character string, The label of kth block (see Label button
in Block menu.
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 :
- name
: a character string, the name of the required structure
- v
: vector of the structure value
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 :
- name
: a character string, the name of the required structure
- v
: vector of the new structure value
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