SGSLP – Set, get, save and load parameters

Block SymbolLicensing group: ADVANCED

Function Description
The SGSLP block is a special function block for manipulation with parameters of other function blocks in the REXYGEN system configuration. It works also in the Matlab-Simulink system but its scope is limited to the .mdl file it is included in.

The block can manage up to 16 parameter sets, which are numbered from 0 to 15. The number of parameter sets is given by the nps parameter and the active set is defined by the ips input. If the ips input remains unconnected, the active parameter set is ips = 0. Each set contains up to 16 different parameters defined by the string parameters sc0 to sc15. Thus the SGSLP block can work with a maximum of 256 parameters of the REXYGEN system. An empty sci string means that no parameter is specified, otherwise one of the following syntaxes is used:

  1. <block>:<param> – Specifies one function block named block and its parameter param. The same block and parameter are used for all nps parameter sets in this case.
  2. <block>:<param><sep><block>:<param> – This syntax allows the parameters to differ among the parameter sets. In general, each sci string can contain up to 16 items in the form <blok>:<param> separated by comma or semi-colon. E.g. the third item of these is active for ips = 2. There should be exactly nps items in each non-empty sci string. If there is less items than nps none of the below described operations can be executed on the incomplete parameter set.

It is recommended not to use both syntaxes in one SGSLP block, all 16 sci strings should have the same form. The first syntax is for example used when producing nps types of goods, where many parameters must be changed for each type of production. The second syntax is usually used for saving user-defined parameters to disk (see the SAVE operation below). In that case it is desirable to arrange automated switching of the ips input (e.g. using the ATMT block from the LOGIC library).

The broot parameter is suitable when all blocks whose parameters are to be controlled by the SGSLP block reside in the same subsystem or deeper in the hierarchy. It is inserted in front of each <block> substring in the sci parameters. The ’.’ character stands for the subsystem where the SGSLP block is located. No quotation marks are used to define the parameter, they are used here solely to highlight a single character. If the broot parameter is an empty string, all <block> items must contain full path. For example, to create a connection to the CNR block and its parameter ycn located in the same subsystem as the SGSLP block, broot = . and sc0 = CNR:ycn must be set. Or it is possible to leave the broot parameter empty and put the ’.’ character to the sc0 string. See the GETPR or SETPR blocks description for more details about full paths in the REXYGEN system.

The SGSLP block executes one of the below described operations when a rising edge (off on) occurs at the input of the same name. The operations are:

SET – Sets the parameters of the corresponding parameter set ips to the values of the input signals ui. In case the parameter is successfully set, the same value is also sent to the yi output.
GET – Gets the parameters of the corresponding parameter set ips. In case the parameter is successfully read, its value is sent to the yi output.
SAVE – Saves the parameters of the corresponding parameter set ips to a file on the target platform. The parameters of the procedure and the format of the resulting file are described below.
LOAD – Loads the parameters of the corresponding parameter set ips from a file on the target platform. This operation is executed also during the initialization of the block but only when 0 ips0 nps 1. The parameters of the procedure and the format of the file are described below.

The LOAD and SAVE operations work with a file on the target platform. The name of the file is given by the fname parameter and the following rules:

  • If no extension is specified in the fname parameter, the .rxs (ReX Status file) extension is added.
  • A backup file is created when overwriting the file. The file name is preserved, only the extension is modified by adding the ’ ’ character right after the ’.’ (e.g. when no extension is specified, the backup file has a . rxs extension.
  • The path is relative to the folder where the archives of the REXYGEN system are stored. The file should be located on a media which is not erased by system restart (flash drive or hard drive, not RAM).

The SAVE operation stores the data in a text file. Two lines are added for each parameter sci, i = 0,,m, where m < 16 defines the nonempty scm string with the highest number. The lines have the form:

  • "<block>:<param>", …, "<block>:<param>"
  • <value>, …, <value>

There are nps individual items "<block>:<param>" which are separated by commas. The second line contains the same number of <value> items which contain the value of the parameter at the same position in the line above. Note that the format of the file remains the same even for sci containing only one <block>:<param> item (see the syntax no. 1 above). The "<block>:<param>" item is always listed nps-times in the file, which allows seamless switching of the sci parameters syntax without modifying the file.

Consider using the SILO block if working with only a few values.



i-th analog input signal, i = 0,,15

Double (F64)


Parameter set index (numbered from zero)

Long (I32)


Set the parameters of the ips parameter set according to the values of the ui inputs. The values can be found at the yi outputs after a successful operation.



Get the parameters of the ips parameter set. The values can be found at the yi outputs after a successful operation.



Save the ips parameter set to a file on the target device



Load the ips parameter set from a file on the target device




i-th analog output signal, i = 0,,15

Double (F64)


Error flag


off ..

No error

on ...

An error occurred (see iE)


Error or warning code of the last operation

Long (I32)

0 ....

Operation successful

1 ....

Fatal error of the Matlab system (only in Simulink), the block is no longer executed

2 ....

Error opening the file for reading (LOAD operation)

3 ....

Error opening the file for writing (SAVE operation)

4 ....

Incorrect file format

5 ....

The ips parameter set not found in the file

6 ....

Parameter not found in the configuration, name mismatch (LOAD operation)

7 ....

Unexpected end of file

8 ....

Error writing to file (disk full?)

9 ....

Parameter syntax error (the ’:’ character not found)

10 ...

Only whitespace in the parameter name

11 ...

Error creating the backup file

12 ...

Error obtaining the parameter value by the GET operation (non-existing parameter?)

13 ...

Error setting the parameter value by the SET operation (non-existing parameter?)

14 ...

Timeout during obtaining/setting the parameter

15 ...

The specified parameter is read-only

16 ...

The ips parameter is out of range



Number of parameter sets   1  16 1

Long (I32)


Index of parameter set to load and set during the block initialization. No set is read for ips0 < 0 or ips0 nps   -1  15

Long (I32)


Precision (number of digits) for storing the values of double type in a file   2  15 12

Long (I32)


Requested column width in the status file. Spaces are appended to the parameter value when necessary.   0  22

Long (I32)


Name of the file the SAVE and LOAD operations work with  status



Root block in hierarchy, inserted at the beginning of all sci parameters, see the description above  .



Strings defining the connection of ui inputs and yi outputs to the parameters, i = 0,,15, see details above


2022 © REX Controls s.r.o.,