Attribute: implicit-parameter
The attribute causes the calling POU to automatically provide implicit context information without requiring explicit parameter transfer or a complex reflection function. This context information is used as the basis for a precise protocol which can be created even in production environments without much effort.
As a PLC application developer, you can use this attribute to generate log information which can precisely identify where production errors occur. Setting breakpoints or adapting individual call locations is not necessary.
As a library developer, you can use this attribute to provide validation functions which automatically detect the calling POU. This provides library users with clear and meaningful error messages without requiring additional programming effort.
Syntax:
{attribute 'implicit-parameter' := <value> }
| Returns the qualified name of the calling POU |
| Specifies the call position in a human-readable format |
| Returns the instance path of the calling POU |
Allowed insertion point:
The attribute may be used in the declaration area VAR_INPUT via an input variable of type STRING or WSTRING. POINTER TO STRING and POINTER TO WSTRING are also possible.
This attribute is allowed in POUs of the following type:
Program:
PROGRAMFunction:
FUNCTIONMethod:
METHOD, also interface method
The check functions provided for implicit monitoring support the attribute.
The attribute cannot be inherited.
The attribute is not supported for automatically generated POU calls (such as FB_Init, FB_Reinit, or FB_Exit).
Declaration
FUNCTION MyAwesomeLogger
VAR_INPUT
{attribute 'implicit-parameter':='pouname'}
pouName : STRING := '';
{attribute 'implicit-parameter':='position'}
position : POINTER TO STRING := 0; // Pass by reference is supported for performance reasons
{attribute 'implicit-parameter':='instance-path'}
instance_path : STRING := '';
END_VAR
Implementation details
FUNCTION_BLOCK FB
// Can be used like this, to pass all arguments automatically
MyAwesomeLogger(); // Values inside the function: pouName="FB", position=ADR("Line 15"), instance_path = "Device.Application.GVL.fbInstance"
// Or like this with explicit parameters
MyAwesomeLogger(pouName := 'OverwrittenName', position := ADR('OverwrittenPosition'));
END_PROGRAM