Symbol:
Keyword: PROPERTY
Properties are an extension of the IEC 61131-3 standard and a tool for object-oriented programming.
Properties are used for data encapsulation because they allow for external access
to data and act as filters at the same time. For this purpose, a property provides
the accessor methods Get
and Set
which allows for read and write access to the data of the instance below the property.
You can add a property with accessor methods below a program, a function block, or a global variable list. Click “Project Add Object Property” to open the “Add Property” dialog.
You can add an interface property below an interface.
When you copy a property that is inserted below a POU and add it below an interface, or if you move the property there, the included implementations are removed automatically.
See also
Dialog 'Add Property'
Function: Creates a new property below the selected POU when the dialog is closed.
Call: Menu bar: “Project Add Object Property”; context menu
Requirement: A program (PRG
), a function block (FUNCTION_BLOCK
), or a global variable list (GVL
) is selected in the “POUs” view or the “Devices” view.
“Name” |
Name (identifier) of the property Example: |
“Return type” |
Default type or structured type of return value Example: |
“Implementation language” |
Example: “Structured Text (ST)” |
“Access specifier” |
Controls access to data |
“PUBLIC” or unspecified |
Access is not restricted. |
“PRIVATE” |
Access is restricted to the program, function block, or GVL. The object is marked as |
“PROTECTED” |
Access is restricted to the program, function block, or GVL with its derivations. The object is marked as |
“INTERNAL” |
Access is restricted to the namespace (library). The object is marked as |
“Abstract” |
|
“Add” |
Adds a new property be low the selected object and below that the accessor methods
Note: When you select a property, you can also add a previously removed accessor explicitly by clicking “Add Object”. |
Editor 'Property'
You can program the data access in the editor. The code can contain additional local variables. However, it must not contain any additional input variables or (as opposed to a function or method) output variables.
Example

Function block FB_A
FUNCTION_BLOCK FB_A VAR_INPUT END_VAR VAR_OUTPUT END_VAR VAR iA : INT; END_VAR iA := iA + 1;
Property prop_iA
PROPERTY PUBLIC prop_iA : INT
Accessor method FB_A.prop_iA.Get
prop_iA := iA;
Accessor method FB_A.prop_iA.Set
iA := prop_iA;
PROGRAM PLC_PRG VAR fbA : FB_A; iVar: INT; END_VAR fbA(); IF fbA.prop_iA > 500 THEN fbA.prop_iA := 0; END_IF iVar := fbA.prop_iA;
Get
and Set
accessors
The call of the Set
accessor is written to the property. Then it is used in the same way as an input
parameter. When the Get accessor is called, the property is read. It is used in the
same way as an output parameter. Access is restricted in each case by means of access
modifiers (qualifiers). As a result, the objects are identified accordingly.
When a property is accessed as read only or write only, you can delete the unneeded accessors.
You can add accessors explicitly by selecting a property and clicking “Add Object”. A dialog opens, either “Add Get accessor” or “Add Set accessor”. There you can set the implementation language and the access.
“Implementation language” |
Example: “Structured Text (ST)” |
“Access specifier” |
Qualifier for the declaration part |
|
Access is not restricted. |
|
Access is restricted to the program, function block, or GVL. The object is marked as |
|
Access to the property is restricted to the program, function block, or GVL and its derivations. The declaration contains the keyword. The object is marked as |
|
Access to the method is restricted to the namespace (the library). The object is marked as |
“Add” |
Adds the accessor methods |
Monitoring of properties in online mode
The following pragmas are provided for the monitoring of properties in online mode. You insert them at the top position of the property definition:
-
{attribute 'monitoring' := 'variable'}
Each time the property is accessed, CODESYS saves the actual value to a variable and displays the value of this variable. This value can become outdated if no more access to the property takes place in the code.
-
{attribute 'monitoring' := 'call'}
Each time the value is displayed, CODESYS calls the code of the
Get
accessor. If this code contains a side effect, then the monitoring executes the side effect.
You can monitor a property with the help of the following functions.
-
Inline monitoring
Requirement: The “Enable inline monitoring” option is selected in the “Text Editor” category of the “Options” dialog.
-
Watch List
See also
Input support when generating inheriting POUs
When you doing object-oriented programming and using the inheritance (keyword EXTENDS
) of POUs, you can get support as follows:
When you insert an action, a property, a method, or a transition below a POU derived from a base POU, the “Add …” dialog opens. Then the input field for the name extends to a list box. The list box contains a valid selection from the actions, properties, methods, or transitions available in the base POU. Now you can, for example, easily accept a method of the base POU and then adapt it to the derived function of the POU.
Methods and properties with the access modifier PRIVATE
are not listed here because they are also not inherited. Methods and properties with
the access modifier PUBLIC
automatically get a blank access modifier field when accepting into the derived POU,
which means the same thing functionally.
Example
