ExternalFunction
This block can be used to call an external function provided by a dynamic library (a .dll or .so file)
Library
Activate/CustomBlocks
Description
This block allows to make a call to an external function provided by a dynamic library (a .dll file or a .so file). The external function arguments must be pointers to numbers (floating types and integer types), and the function should not return any value. The description of the function arguments and the way they are associated with block ports are specified by an OML object created as follows
OMLExternalFunc(dllinfos,funname,types,lang)
where
llinfos:
A cell containing one string used to load the dynamic library by a call to dlopen or LoadLibrary.
funname:
The name of the external function to call.
types:
A cell. Each item of the cell describes an argument of the function to call. The items are in the same order as the arguments of the function to call. Each item is a struct containing the following fields:
lnk: which could have two different types:
a string - it will represent the value of the argument. To retrieve that value the string will be evaluated using the OML eval. The special variables following are added to the environment before calling eval: each input will be represented by a variable named in* (in1 for the first, in2 for the second, etc.) and each output by out* (out1 for the first, etc.). Only the sizes of these variables are known.
a cell containing string(s) - each string could be 'w', 'i*' (i1, i2, etc.) or 'o*' (o1, o2 etc.).
For example, i1 means the value of the first block input will be used for the corresponding argument
o2 means that the value of that argument will be the second output of the block
w means that the value will be buffered
an argument could be linked to at most one input, and at most one output
The following combinations are authorized:
o: the output of the block will be passed to the function
i: the input of the block will be passed to the function, so theoretically the function should not modify that argument
io: the input will be copied into the output and the output will be passed to the function
w: a work, it will be allocated and passed to the function
wi: a work, it will be allocated, and the value of the corresponding input will be copied inside before calling the function
type: the type code using Activate convention: 1 for double, 3 for int32, 4 for int16, 5 for int8, 6 for uint32, 7 for uint16 and 8
for uint8
size: the size of the arguments (a vector of size 1x2). If a size is not know or dynamic, the missing dimension can be specified as a negative integer. Those integers represent variable that are shared by all the items in the cell. Example, if the first argument has size [-1,-2] and the second argument has size [-2,-1] then they have conjugate sizes.
lang:
Currently, only C is supported, so it must be a string equal to 'C'.
Parameters
Name | Label | Description | Data Type | Valid Values |
---|---|---|---|---|
nin | Number of input ports | Number | ||
nout | Number of output ports | Number | ||
externalActivation | External activation | Number | 0 | |
funcObj | Function: instance of the class OMLExternalFunc |
Ports
Name | Type | Description | IO Type | Number |
---|---|---|---|---|
Port 1 | explicit | input | nin | |
Port 2 | explicit | output | nout | |
Port 3 | activation | input | externalActivation |