ABSTRACT¶
ABSTRACT marks a function block type that is meant to be extended rather
than instantiated directly. An abstract type provides a common base — shared
variables and method signatures — that derived types complete. An instance
of an abstract type cannot be created; only a concrete type that
extends it can be. This is part of the object-oriented
programming introduced in IEC 61131-3 Edition 3.
Note
ABSTRACT is a keyword only when the --allow-fb-inheritance flag is enabled. When the flag
is not set, ABSTRACT 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¶
ABSTRACT appears between FUNCTION_BLOCK and the type name. It may be
combined with EXTENDS and IMPLEMENTS:
FUNCTION_BLOCK ABSTRACT fb_name [EXTENDS base_name] [IMPLEMENTS interface_name {, interface_name}]
variable_declarations
statement_list
END_FUNCTION_BLOCK
Example¶
FUNCTION_BLOCK ABSTRACT FB_BaseAxis
VAR
enabled : BOOL;
END_VAR
END_FUNCTION_BLOCK
FUNCTION_BLOCK FB_LinearAxis EXTENDS FB_BaseAxis
VAR
position : REAL;
END_VAR
END_FUNCTION_BLOCK
FB_BaseAxis cannot be instantiated on its own; FB_LinearAxis extends
it and can be.
See Also¶
EXTENDS — derive from a base type
IMPLEMENTS — provide the methods declared by an interface
INTERFACE — declare an interface
Object Oriented Programming — inheritance, interfaces, and abstract types explained
FUNCTION_BLOCK — the
FUNCTION_BLOCKunit