EPC – External program call

Block SymbolLicensing group: ADVANCED
Qt SVG Document Exported by REXYGEN Studio uVec1 uVec2 uVec3 uVec4 uVec5 uVec6 uVec7 uVec8 EXEC RESET DSI DSO yVec1 yVec2 yVec3 yVec4 yVec5 yVec6 yVec7 yVec8 DONE BUSY ERR errID res icnt ocnt EPC

Function Description
The EPC block executes an external program when a rising edge (off on) is detected at the EXEC input. The program’s name and parameters are specified in the cmd parameter, formatted exactly as they would be in the operating system’s command line.

Data can be passed between the REXYGEN system and the external program via files. The file format, specified by the format parameter, is text-based to ensure compatibility and ease of use with various software tools. For instance, data can be loaded in MATLAB with the command:

    values = load(’-ASCII’, ’epc_inputVec1’);

and in SCILAB with:

    values = read(’epc_inputVec1’, -1, 32);

Adjust the file name and number of columns according to your specific project needs. Data can also be retrieved back into the REXYGEN system using the same file format.

The EPC block operates in two modes:

Basic Mode:
Triggered by a rising edge on EXEC, this mode reads the current input data and stores it in designated files specified by the ifns parameter. Each i-th input vector uVec<i> is saved to its corresponding i-th file.
Sampling Mode:
In this mode, data from the input vectors are continually saved to files at each algorithm cycle, facilitating real-time data logging.

In both modes, data from one time instant are saved in one line in the file. Similarly, data from output files are retrieved and mapped to the block outputs (yVec<i>), with each line from the i-th output file going to the i-th output vector.

The inputs working in the sampling mode are defined by the sl list (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.). 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.

To merge multiple signals into one vector, use the RTOV block. To split a vector into individual signals, use the VTOR block. These blocks can be chained for processing vectors of any size, increasing the block’s flexibility in handling complex data structures.

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 also used for execution of some operating system functions.

This block does not propagate the signal quality. More information can be found in the 1.4 section.

Input

uVec1..uVec8

Input vector signal

Reference

EXEC

External program is called on rising edge

Bool

RESET

Block reset

Bool

DSI

Disable inputs sampling

Bool

DSO

Disable outputs sampling

Bool

Parameter

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 sampled inputs (comma-separated)   0  255 85

Long (I32)

ifm

Maximum number of input samples  10000

Long (I32)

format

Format of input and output files  1

Long (I32)

1 ....

Space-delimited values

2 ....

CSV (decimal point and commas)

3 ....

CSV (decimal comma and semicolons)

nmax

Maximum output vector length   2  1000000 100

Long (I32)

Output

yVec1..yVec8

Output vector signal

Reference

DONE

External program finished

Bool

BUSY

External program running

Bool

ERR

Error indicator

Bool

errID

Error code

Error

res

External program return code

Long (I32)

icnt

Current input sample

Long (I32)

ocnt

Current output sample

Long (I32)

2024 © REX Controls s.r.o., www.rexygen.com