Object ‘Property’¶
Symbol:
A property is an extension of the IEC 61131-3 standard and is a tool for object-oriented programming. It consists of the accessor methods Get and Set. CODESYS calls these methods automatically when a read or write access occurs to the function block that implements the property.
You add the object below a program or a function block in the device tree by clicking
.Name | Name of the property |
Return type | Input or selection of the return type via the input assistant. |
Access specifier | Combo box
|
A property can contain additional local variables. However, a property cannot contain any extra inputs or, unlike a function or a method, any extra outputs.
Attention
If you copy or shift a property from a POU to an interface, then CODESYS deletes the contained implementations automatically.
Note
When you do object-oriented programming and want to use inheritance for blocks, you have the following support: When you insert a method, action, etc. below an inherited block, the Add Object dialog box includes a combo box with a list of methods, actions, etc. used in the base block. In this way, you can easily accept a method definition of the base and adapt it accordingly for the inherited method of the block. Methods and attributes with the PRIVATE access modifier are not available in this selection because they should not be inherited. When accepted into the inherited block, methods and attributes with the PUBLIC access modifier automatically have a blank access modifier field. (Functionally, this means the same thing.)
See also
Get and set accessors
CODESYS adds the accessor methods Get and Set automatically to the device tree below the property object. You can add an object explicitly by means of the command “Add object”.
CODESYS calls the Set accessor when the property is accessed for writing. This means that you use the name of the property as the input parameter.
CODESYS calls the Get accessor when the property is accessed for reading. This means that you use the name of the property as the output parameter.
If you wish to use the property only for reading access or only for writing access, you can delete the unused accessor.
Note
You can add access specifiers to accessor methods at the following positions:
- In the declaration part of the accessor (manually)
- In the dialog box Add Get accessor or Add Set accessor if you explicitly insert the accessor with the command Add object. The selection corresponds to inserting a property. Refer to the Add property table above.
The objects accessor methods that are identified as PRIVATE or PROTECTED are identified by the corresponding symbol for PRIVATE( ) or for PROTECTED (
).
See also