Command Implement interfaces

Function: The command updates the implemented interfaces for a function block by adding the interface elements that the function block does not currently contain.

Call: Context menu when the function block is selected in the PLC project tree.

Requirement: The function block implements an interface that you have changed. For example, you have added another method to the interface.

Applications

When this command is executed, the automatically created methods or properties are assigned a pragma attribute, which provokes compilation errors or warnings. This provides supports in the sense that automatically created elements do not remain empty unintentionally. Whether an error or warning attribute is used depends on the application.

Case 1:

Situation: The function block for which the command Implement interfaces is executed is not derived from another function block.

Consequence: When the command is executed, the interface elements are created in the function block without implementation ("stubs") and assigned a warning attribute (in the first line of the method/property declaration). The warnings generated during compilation alert you to the fact that these elements have been generated automatically and that you need to add the required implementation code.

{warning 'add method/property implementation'}

Procedure: Add the desired implementation code to the corresponding interface element (method or property). Then remove the warning attribute from the method or property declaration.

Case 2:

Situation: The function block for which the command Implement interfaces is executed is derived from another function block. The element (method or property) created when the command is executed in the derived function block is not provided by inheritance from the base function block (that is, the element does not exist under the base function block or a higher parent class).

Consequence/procedure: see case 1.

Case 3:

Situation: The function block for which the command Implement interfaces is executed is derived from another function block. The element (method or property) created when the command is executed in the derived function block is already provided by inheritance from the base function block (that is, the element exists under the base function block or a higher parent class).

Consequence: When the command is executed, the interface element is created in the derived function block without implementation ("stub") and assigned an error attribute (in the first line of the method/property declaration). The error generated during compilation alerts you to the fact that this interface element was generated automatically and that this method or property overwrites the corresponding element of the basic function block.

{error 'add method/property implementation or delete method/property to use base implementation'}

Procedure: If you want to overwrite or enhance the method or property of the basic function block, add the required implementation code to the element below the derived function block. Then remove the error attribute from the method or property declaration. However, if you do not want to overwrite the method or property of the basic function block, delete the method or property below the derived function block. In this case the method or property implementation of the basic function block is used.