EPC – External program call
Block SymbolLicensing group: ADVANCED
Function Description
The EPC block executes an external program upon a rising edge
(offon)
occurring at the EXEC input. The name and options of the program are defined by the cmd
parameter. The format is the same as if the program was executed from the command line of
the operating system.
It is possible to pass data from the REXYGEN system to the external program via files. The
formatting of the files is defined by the format parameter. All the currently supported formats
are textual and simple, which allows straightforward processing of the data in arbitrary
program. Use e.g.
values=load(’-ASCII’, ’epc_inputVec1’);
for loading the data in MATLAB or
values=read(’epc_inputVec1’,-1,32);
in SCILAB. The filename and number of columns must be adjusted for the given project. Data
exchange in the opposite direction is naturally also supported, the REXYGEN system can read
the files in the same format.
The block works in two modes. In basic mode, the rising edge on the EXEC input triggers reading the data on inputs and storing them in the ifns file. The values of the i-th input vector uVec<i> are stored in the i-th file from the ifns list. In sampling mode, the data from the input vectors are stored in each period of the control algorithm. In both cases the values from one time instant form one line in the file.
Analogically, the data from output files are copied to the outputs of the block (one line from the i-th file in the ofns list to the i-th output vector yVec<i>).
The inputs working in the sampling mode are defined by the sl list (comma-separated numbers). The outputs work always in the sampling mode – the last values are kept when the end of file is reached. The copying of data to input files can be blocked by the DSI input, the same holds for output data and the DSO input.
Use the RTOV block to combine individual signals into a vector one for the uVec input. The RTOV blocks can be chained, therefore it is possible to create a vector of arbitrary dimension. Similarly, use the VTOR block to demultiplex a vector signal to individual signals.
Inputs
uVec1..uVec8 | Input vector signal | Reference |
EXEC | External program is called on rising edge | Bool |
RESET | Block reset (deletes the input and output files and terminates the external program) | Bool |
DSI | Disable inputs sampling | Bool |
DSO | Disable outputs sampling | Bool |
Outputs
yVec1..yVec8 | Output vector signal | Reference |
DONE | External program finished | Bool |
BUSY | External program running | Bool |
ERR | Error flag | Bool |
errID | Error code | Error |
|
|
|
res | External program return code | Long (I32) |
icnt | Current input sample | Long (I32) |
ocnt | Current output sample | Long (I32) |
Parameters
cmd | Operating system command to execute | String |
ifns | Input filenames (separated by semicolon) epc_uVec1;epc_uVec2 | String |
ofns | Output filenames (separated by semicolon) epc_yVec1;epc_yVec2 | String |
sl | List of inputs working in the sampling mode. The format of the list is e.g. 1,3..5,8. Third-party programs (Simulink, OPC clients etc.) work with an integer number, which is a binary mask, i.e. 157 (binary 10011101) in the mentioned case. 0 255 85 | Long (I32) |
ifm | Maximum number of input samples 10000 | Long (I32) |
format | Format of input and output files 1 | Long (I32) |
|
|
|
nmax | Maximum output vectors length 2 1000000 100 | Long (I32) |
Notes
- The called external program has the same priority as the calling task. This priority
is high, in some cases higher than operating-system-kernel tasks. On Linux based
systems, it is possible to lower the priority by using the chrt command:
chrt -o 0 extprg.sh,
where extprg.sh is the original external program. - The size of signals is limited by parameter nmax. Bigger parameter means bigger memory consumption, so choose this parameter as small as possible.
- The filenames must respect the naming conventions of the target platform operating system. It is recommended to use only alphanumeric characters and an underscore to avoid problems. Also respect the capitalization, e.g. Linux is case-sensitive.
- The block also creates copies of the ifns and ofns files for implementation reasons. The names of these files are extended by the underscore character.
- The ifns and ofns paths are relative to the folder where the archives of the REXYGEN system are stored. It is recommended to define a symbolic link to a RAM-drive inside this folder for improved performance. On the other hand, for long series of data it is better to store the data on a permanent storage medium because the data can be appended e.g. after a power-failure recovery.
- The OSCALL block can be used for execution of some operating system functions.
[Back to top] [Up] [Next]
2024 © REX Controls s.r.o., www.rexygen.com