IMPLEMENTS¶
IMPLEMENTS declares that a function block type provides every method of
one or more interfaces. The type promises to supply an
implementation for each method signature the interface declares, which lets
instances of unrelated types be used through a common interface. This is
part of the object-oriented programming introduced in IEC 61131-3 Edition 3.
Note
IMPLEMENTS is a keyword only when the --allow-fb-inheritance flag is enabled. When the flag
is not set, IMPLEMENTS is an ordinary identifier and may be used as a
variable or type name, exactly as in standard IEC 61131-3. Pass --allow-fb-inheritance to
enable the object-oriented syntax, or select a dialect that includes it.
See Enabling Dialects and Features for the dialects and
flags reference.
IEC 61131-3 |
Edition 3 (object-oriented programming) |
Support |
Parsed and analyzed: the function block must provide the
interface’s members (P4067,
P4068), and an instance
can be used where an interface it implements is required. Enable with
|
Syntax¶
IMPLEMENTS names one or more interfaces, separated by commas. It may
follow an EXTENDS clause on the same declaration:
FUNCTION_BLOCK fb_name [EXTENDS base_name]
IMPLEMENTS interface_name {, interface_name}
variable_declarations
statement_list
END_FUNCTION_BLOCK
Example¶
INTERFACE I_Drivable
END_INTERFACE
FUNCTION_BLOCK FB_Motor IMPLEMENTS I_Drivable
VAR
running : BOOL;
END_VAR
END_FUNCTION_BLOCK
The function block must provide every method and property of the
interface, and of the interfaces it extends, with the same signature; see
P4067 and
P4068 for what must match. A
member inherited from a base type through EXTENDS counts, and a type that
extends a function block implements the interfaces the base implements.
A type may implement several interfaces at once:
FUNCTION_BLOCK FB_Actuator IMPLEMENTS I_Hydraulics, I_Brake
END_FUNCTION_BLOCK
See Also¶
INTERFACE — declare an interface
METHOD — declare a method on a function block type
EXTENDS — derive from a base type
ABSTRACT — mark a type as not directly instantiable
Object Oriented Programming — inheritance, interfaces, and abstract types explained
FUNCTION_BLOCK — the
FUNCTION_BLOCKunit