INTERFACE

INTERFACE declares an interface: a named set of method signatures with no implementation. A function block type that implements the interface promises to supply a body for each of those methods, which lets instances of unrelated types be used through the same interface. An interface declaration is terminated by END_INTERFACE. Interfaces are part of the object-oriented programming introduced in IEC 61131-3 Edition 3.

Note

INTERFACE is a keyword only when the --allow-fb-inheritance flag is enabled. When the flag is not set, INTERFACE 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.

Note

END_INTERFACE is the closing keyword of an interface declaration and is gated by the same flag. Like INTERFACE, it is an ordinary identifier when the flag is not enabled.

IEC 61131-3

Edition 3 (object-oriented programming)

Support

Parsed only — not yet analyzed or executed (P9999). Enable with --allow-fb-inheritance; see Enabling Dialects and Features.

Syntax

INTERFACE interface_name [EXTENDS base_interface {, base_interface}]
    method_prototypes
END_INTERFACE

An interface may extend one or more base interfaces, inheriting their method signatures.

Example

INTERFACE I_Drivable
END_INTERFACE

INTERFACE I_PoweredDrivable EXTENDS I_Drivable
END_INTERFACE

FUNCTION_BLOCK FB_Motor IMPLEMENTS I_Drivable
    VAR
        running : BOOL;
    END_VAR
END_FUNCTION_BLOCK

Note

Method declarations (METHODEND_METHOD) inside an interface are not yet parsed, so interface bodies are currently empty. The interface name and any EXTENDS clause are recognized.

See Also

  • IMPLEMENTS — provide the methods declared by an interface

  • EXTENDS — derive an interface or function block from a base

  • ABSTRACT — mark a function block type as not directly instantiable

  • Object Oriented Programming — inheritance, interfaces, and abstract types explained