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 only — not yet analyzed or executed
(P9999). 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
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
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