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 and analyzed: a variable declared with the type of an ABSTRACT function block reports P4045, while a concrete type that extends it instantiates normally. The check covers a direct declaration; it does not yet reject an ABSTRACT type used as the element type of an array. IronPLC does not yet execute an ABSTRACT function block, so declaring one also reports P9999. Enable with --allow-fb-inheritance; see Enabling Dialects and Features.

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

PROGRAM main
    VAR
        axis : FB_LinearAxis;
    END_VAR
END_PROGRAM

FB_BaseAxis cannot be instantiated on its own; FB_LinearAxis extends it and can be, so axis is a valid declaration.

Naming the abstract type in the declaration instead reports P4045:

FUNCTION_BLOCK ABSTRACT FB_BaseAxis
END_FUNCTION_BLOCK

PROGRAM main
    VAR
        axis : FB_BaseAxis;    (* P4045: FB_BaseAxis is ABSTRACT *)
    END_VAR
END_PROGRAM

See Also