Attribute ‘is_connected’ΒΆ

You use the pragma 'is_connected' to mark a Boolean function block variable which, when a function module instance is called, provides information about whether the associated input of the POU has an assignment.

The use of the pragma requires the use of the attribute 'reflection' on the affected function block.

Syntax:

{attribute 'is_connected' := '<input variable>'}

Example

In the function block FB, a local variable is declared for each input variable (in1 and in2) and the attribute 'is connected' is prepended to it each time with the name of the input variable. The func itself gets the pragma attribute 'reflection'.

When an instance of the function block is called, the local variable is TRUE in the case that the input assigned to it has received 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 in 2 does not receive an assignment. This results in the following code:

in1_connection_info := TRUE;
in2_connection_info := FALSE;

See also