Incomplete interface implementation
Any class or function block implementing an interface must implement all methods as defined in the interface. Generally speaking this error is raised when any of the following conditions are met:
- The method is not implemented in the class or function block at all
- The return type of the method is different from the return type defined in the interface
- The order of the parameters in the method is different from the order of the parameters in the interface
- The size of the parameter list does not match the size of the parameter list in the interface
- The parameter at any given position in the method is different from the parameter at the same position in the interface (name, data type, or variable block type i.e. INPUT, OUTPUT, IN_OUT)
Errouneus code example:
INTERFACE interfaceA
METHOD foo : INT
VAR_INPUT
a : INT;
b : DINT;
END_VAR
END_METHOD
END_INTERFACE
FUNCTION_BLOCK fb IMPLEMENTS interfaceA
METHOD foo : DINT // Incorrect return type, should have been `INT`
VAR_OUPUT // Incorrect variable block type, should have been `VAR_INPUT`
b : DINT; // Incorrect order, should have been `a : INT`; as a result also an incorrect data type
a : INT; // Incorrect order, should have been `b : DINT`; as a result also an incorrect data type
c : INT; // Incorrect parameter list length, 3 > 2
END_VAR
END_METHOD
END_FUNCTION_BLOCK
Note: The third bullet point can be confusing, however for implicit calls the order of the parameters is
important. For example if a interface defines the order of the parameters as a, b
and the function block
implements the method as b, a
a method call such as foo(1, 2)
should be interpreted as foo(a := 1, b := 2)
but instead will be interpreted as foo(a := 2, b := 1)
. As a result consistency between any POU implementing
an interface can no longer be guaranteed.