Maintaining Data Consistency for Multicore Operation

By default, the IEC program of the visualization (Visu_Prg) runs in its own task (VISU_TASK). The visualization generally displays data from the main application. The data from the main application is processed in another task. For this reason, data consistency is an important topic when the application is run on a multicore controller.

It is important to know that there is no atomic (time indivisible) assignment for the STRING and WSTRING data types as well as for structured data. The date must not be changed when a date of these types is passed. However, if the date is changed by a task other than VISU_TASK, then it might be displayed incorrectly for a short time.

Below you can see where you should maintain data consistency explicitly when creating a CODESYS visualization for use on a multicore system.

Note

Always see the general information regarding multicore operation in the CODESYS help.

Reading IEC data in one visualization cycle

If the display of a visualization element depends on multiple variables, then the assignment of these variables is not cycle-consistent. For example, if an element is moved in the x and y- direction by means of two IEC variables, then this can have the effect that the visualization element moves only in the x-direction in one cycle and then the moves in the y-direction in the next cycle.

The same applies to data that is used by multiple visualization elements.

Example: Element 1 reads the state variable invisible and updates its state. Another task than VISU_TASK modifies the respective IEC variable. Element 2 reads the state variable invisible and updates its state. Result: The elements have a different state for a short time. This behavior can occur for all animation variables.

Generic input actions

Visualization change

Note the problems described above when using string data types.

Execute Command

Note the problems described above when using string data types.

Toggle frame visualization

Note the problems described above when using string data types.

Write Variable

Like reading, no atomic assignments are possible for writing to STRING/WSTRING variables.

Execute ST Code

When creating the ST code, make sure that data consistency is not at risk.

Interface variables of a visualization

If a structure is transferred via VAR_INPUT, then data consistency is not guaranteed. Use structured data via VAR_IN_OUT, or use an interface via VAR_INPUT.

User management of the visualization

If the user management is called via the public interfaces (VisuUserMgmt.library), then this must always originate from the VISU_TASK.

Visualization element 'Polygon'

The Polygon visualization element has the Dynamic points property. Here you can configure an array of points. Note that the reading of the entire array is not atomic.

Variables of data type STRING

There is no atomic assignment for all properties configured with variables of the data type STRING. Example: The control variable for the URL for the Web Browser visualization element.

User libraries

VisuUtils.library

FbOpenDialogExtended.CallOpenDialog uses SysMemCpy. Do not reconfigure the instance while xBusy == TRUE.

IECStringUtils.library

Do not use the function block VisuFbAnalyzeDateTimeFormatString with the same buffer from multiple tasks.

StringUtils.library

Caution: Structure access occurs when using DateFormatter.Format.

IECStringUtils.library

Caution: String access occurs when using VisuFbAnalyzeDateTimeFormatString.GetMonth.

Dialogs

Passing parameters for dialogs should be considered in the same way as for complex data types. When a dialog is opened, a copy of all passed parameters is created.

Exception: VAR_IN_OUT parameters that have {attribute 'VAR_IN_OUT_AS_POINTER'}. If this attribute is assigned, then no copy is created and the dialog works on the original object.

See also