Retaining Data with Variables of the Persistence Manager

Persistent variables are managed in the Persistence Manager of the CODESYS Application Composer. The functionality of the Persistence Manager does not need any special memory on the controller in order to preserve values and data.

Declaration

In the declarations, the variables managed in the Persistence Manager are marked with the pragma {attribute 'ac_persist'}.

The pragma makes sure that the variable with this attribute is managed in the Persistence Manager of the Application Composer. The variable value is retained even if you change the declaration of the variable, delete a variable from the application, or add a new one. The value is retained even if you change the data type and use the appropriate conversions.

Mechanism

The variables of the Persistence Manager are stored with their values in an external archive file in TXT format.

The application code is extended with the code of the Persistence Manager, which leads to a greater memory requirement. This is at the expense of performance. Moreover, reading and especially writing a large number of persistent variables can take a long time. As a result, the executing task also blocks the execution for a long time.

Functionality

  • You can load and edit the TXT file in an external editor such as Notepad++.
  • You can use the persistent variables of the file in another application.
  • You can configure the behavior of persistent variables by defining persistence groups, assigning variables to them, and configuring the groups with their own save and read behavior.

See also