Implementing interfaces, L-force | plc designer – Lenze PLC Designer PLC Designer (R3-1) User Manual
Page 78

L-force | PLC Designer
Concepts and Base Components
76
DMS 4.1 EN 03/2011 TD29
Extension by EXTENDS means:
• fbB does contain all data and methods which are defined by fbA. An instance of fbB
can now be used in any context were a function block of type fbA is expected.
• fbB is allowed to override the methods defined in fbA. That means: fbB can declare
a method with the same name and the same inputs and output as declared by A.
• fbB is not allowed to use function block variables with the same name as used in
fbA. In this case the compiler will prompt an error.
• fbA variables and methods can be accessed directly within a fbB-Scope by using the
keyword "SUPER" (SUPER^.
Note: Multiple inheritance is not allowed.
Implementing interfaces
In order to support object oriented programming a function block can implement
several interfaces which provide the possibility to use methods:
Syntax:
FUNCTION_BLOCK
A function block that implements an interface must contain all methods of this
interface. That is name, inputs and the output of the particular method must be
exactly the same. For this purpose - when creating a new function block implementing
an interface - automatically all methods defined in this interface will be inserted below
the new function block in the object tree. Currently however any modifications in the
interface definition will not be updated automatically in the concerned function
blocks. This must be done explicitly by command 'Implement interfaces...'.
Example:
INTERFACE I1 includes Method GetName:
METHOD GetName : STRING
Function blocks A and B each implement interface I1:
FUNCTION_BLOCK A IMPLEMENTS I1
FUNCTION_BLOCK B IMPLEMENTS I1
Thus in both function blocks the method "GetName" must be available and will be
inserted automatically below each when the function blocks get inserted in the object
tree.