Programming scicos blocks
fr -
eng
sci_struct - Scicos block structure of a scilab computational function
A Scicos computational function of type 5 can be realized by the use of a Scilab function.
That function doesn't really differs from all other scilab function : one can use all functions and
instructions of the scilab language inside that function to do the computation.
Such a function must be written in a file with extension .sci, must be loaded inside scilab by the
common loading scilab function (exec, getf, getd, genlib,...) and must have
two right hand side arguments and one left hand side argument, as the following calling sequence :
function block=myblock(block,flag)
...
//your computational instructions
...
endfunction
When the simulator is calling such a computational function, it build a scilab structure (in the previous exemple this is the named block rhs/lhs arguments) from his own internal C reprensation of a block structure (see C_struct
for more details about the C structure of scicos
blocks).
That scilab structure is a scilab typed list variable that has the following fields :
!scicos_block nevprt funpt type scsptr nz z noz ozsz oztyp !
!oz nx x xd res nin insz inptr nout outsz outptr nevout !
!evout nrpar rpar nipar ipar nopar oparsz opartyp opar ng g !
!ztyp jroot label work nmode mode !
Each fields are then accessible inside the scilab computational function by the use of :
block.field
- block.nin : a scalar that gives the number of regular input ports.
This is a read only data.
- block.insz : a vector of size 3*nin, that gives the dimensions and types of the regular input ports.
- block.insz(1:nin) : are the first dimensions.
- block.insz(nin+1:2*nin) : are the second dimensions.
- block.insz(2*nin+1:3*nin) : are the type of data (C coding).
This is a read only data.
- block.inptr : a list of size nin that enclosed typed matrices for regular input ports.
Each element correspond to only one regular input port. Then i-th matrix
of the block.inptr list will have the dimensions [block.insz(i), block.insz(nin+i)] and
the type block.insz(2*nin+i).
The data type that can be provided by regular input ports are :
- 1 : matrix of real numbers,
- 2 : matrix of complex numbers,
- 3 : matrix of int32 numbers,
- 4 : matrix of int16 numbers,
- 5 : matrix of int8 numbers,
- 6 : matrix of uint32 numbers,
- 7 : matrix of uint16 numbers,
- 8 : matrix of uint8 numbers.
This is a read only data.
- block.nout : a scalar that gives the number of regular output ports.
This is a read only data.
- block.outsz : a vector of size 3*nout, that gives the dimensions and types of the regular output ports.
- block.outsz(1:nout) : are the first dimensions.
- block.outsz(nout+1:2*nout) : are the second dimensions.
- block.outsz(2*nout+1:3*nout) : are the type of data (C coding).
This is a read only data.
- block.outptr : a list of size nout that enclosed typed matrices for regular output ports.
Each element correspond to only one regular output port. Then i-th matrix
of the block.outptr list will have the dimensions [block.outsz(i), block.outsz(nin+i)] and
the type block.outsz(2*nin+i).
The data type that can be provided by regular output ports are :
- 1 : matrix of real numbers,
- 2 : matrix of complex numbers,
- 3 : matrix of int32 numbers,
- 4 : matrix of int16 numbers,
- 5 : matrix of int8 numbers,
- 6 : matrix of uint32 numbers,
- 7 : matrix of uint16 numbers,
- 8 : matrix of uint8 numbers.
Values of regular output ports will be saved in the C structure
of
the block only for flag=6 and flag=1.
- block.nevprt : a scalar given the event input port number (binary coding)
which have activated the block. This is a read only data.
- block.nevout : a scalar given the number of output event port of the block.
This is a read only data.
- block.evout : a vector of size nevout corresponding to the register
of output event.
Values of output event register will be saved in the C structure
of
the block only for flag=3.
- block.nrpar : a scalar given the number of real parameters.
This is a read only data.
- block.rpar : a vector of size nrpar corresponding to the real parameter register.
This is a read only data.
- block.nipar : a scalar given the number of integer parameters.
This is a read only data.
- block.ipar : a vector of size nipar correspondig to the integer parameter register.
This is a read only data.
- block.nopar : a scalar given the number of object parameters.
This is a read only data.
- block.oparsz : a matrix of size nopar,2, that respectively gives the first and the second
dimension of object parameters. This is a read only data.
- block.opartyp : a vector of size nopar given the C coding type of data.
This is a read only data.
- block.opar : a list of size nopar given the values of object parameters.
Each element of opar can be either a typed matrix or a list.
Only matrix that encloses numbers of type real, complex, int32, int16, int8,
uint32, uint16 and uint8 are allowed, all other types of scilab data will
be enclosed in a sub-list. This is a read only data.
- block.nz : a scalar given the number of discrete state for the block.
This is a read only data.
- block.z : a vector of size nz corresponding to the discrete state register.
Values of discrete state register will be saved in the C structure
of
the block only for flag=4, flag=6, flag=2 and flag=5.
- block.noz : a scalar that gives the number of discrete object state.
This is a read only data.
- block.ozsz : a matrix of size noz,2, that respectively gives the first and the second
dimension of discrete object state. This is a read only data.
- block.oztyp : a vector of size noz given the C coding type of data.
- block.oz : a list of size noz given the values of discrete object states.
Each element of oz can be either a typed matrix or a list.
Only matrix that encloses numbers of type real, complex, int32, int16, int8,
uint32, uint16 and uint8 are allowed, all other types of scilab data will
be enclosed in a sub-list.
Values of discrete object state will be saved in the C structure
of
the block only for flag=4, flag=6, flag=2 and flag=5.
- block.nx : a scalar given the number of continuous state for the block.
This is a read only data.
- block.x : a vector of size nx given the value of the continuous state register.
Values of the continuous state register will be saved in the C structure
of
the block only for flag=4, flag=6 and flag=2.
- block.xd : a vector of size nx given the value of the derivative continuous state register.
Values of the derivative continuous state register will be saved in the C structure
of
the block only for flag=4, flag=6, flag=0 and flag=2.
- block.res : a vector of size nx corresponding to the Differential Algebraic Equation (DAE) residual.
Values of that register will be saved in the C structure
of
the block only for flag=0, and flag=10.
- block.ng : a scalar given the number of zero crossing surfaces for the block.
This is a read only data.
- block.g : a vector of size ng corresponding to the zero crossing register.
Values of that register will be saved in the C structure
of
the block only for flag=9.
- block.nmode : a scalar given the number of mode for the block.
This is a read only data.
- block.mode : a vector of size mode that corresponds to the mode register.
Values of that register will be saved in the C structure
of
the block only for flag=9, with phase_simulation=1.
- block.type : a scalar given the type of the block.
This is a read only data.
- block.label : a string given the label of the block.
This is a read only data.
Alan Layec INRIA