Attribute is_connected
The is_connected
attribute marks a Boolean variable of a function block to provide the information when the function block instance is called about whether the associated input of the POU has an assignment.
As a prerequisite, the reflection
attribute must be assigned to the respective function block.
In the function block FB
, a local variable is declared for each input variable (in1
and in2
). Each input variable is prefixed by the attribute is connected
and the name of the input variable. The function block is assigned the pragma attribute reflection
.
If an instance of the function block is called, the local variable is set to TRUE provided that the assigned input receives an assignment.
{attribute 'reflection'}
FUNCTION_BLOCK FB
VAR_INPUT
in1: INT;
in2: INT;
END_VAR
VAR
{attribute 'is_connected' := 'in1'}
in1_connection_info: BOOL;
{attribute 'is_connected' := 'in2'}
in2_connection_info: BOOL;
END_VAR
Assumption: When the function block instance is called, in1
receives an external assignment and in2
does not receive an assignment. This results in the following code:
in1_connection_info := TRUE;
in2_connection_info := FALSE;