Skip to main content

Object: Action

Symbol: _cds_icon_obj_action.png

You can add actions to a function block or a program. Every action has a name.

The action object implements additional code, which may be programmed in a different language than the base implementation of the superordinate POU. Actions are often implemented in SFC. An action does not have its own variable declaration. It works with the data of its superordinate base implementation and uses its variables (VAR, VAR_INPUT, VAR_OUTPUT, VAR_IN_OUT).

In object-oriented programming, it is possible to inherit a function block together with its subordinate actions.

For more information, see: Input support when generating inheriting POUs

Insert Action

Add an Action to a function block or a program with the ProjectAdd ObjectAction command and define the properties of the new action in the dialog which opens.

Table 61. Add Action

Name

Name of the action

Implementation language

Selected from the list box with the available implementation languages



Call

Syntax:

<program name> . <action name> ( <parameter passing> )

or

<name of function block instance> . <action name> ( <parameter passing> )

<program name> .

Optional

Instance path with the name of the program

When an action is called in the corresponding base implementation of the program, it is sufficient to specify the action name.

<name of function block instance> .

Optional

Instance path with name of the function block instance

When an action is called in the corresponding basic implementation of the function block, it is sufficient to specify the action name.

<action name>

Required

Name of the action

( <parameter passing> )

Optional

When parameters are passed, arguments can be passed to the input and output variables in the same way as for the respective function block.

See Function block

The variables available in the action are declared in the superordinate POU. All the same, parameters can be passed when an action is called. The variables (VAR, VAR_INPUT, VAR_OUTPUT, VAR_IN_OUT) of the superordinate program or the function block instance can be accessed (in contrast to the method call).

When an action is called in a graphical editor, all I/Os of the base POU are therefore displayed.

Example 524. Example

Calling the Reset action (Counter function block) from another POU.

Instantiation of the function block

PROGRAM PLC_PRG
VAR
    Inst : Counter;
END_VAR

Calling the Reset action in IL

CAL Inst.Reset(In := FALSE)
LD Inst.Out
ST ERG

Calling the Reset action in ST

Inst.Reset(In := FALSE);
Erg := Inst.out;

Calling the Reset action in FBD

_cds_img_action_fbd.png


Example 525. Example

Declaration of the function block FB_Test

FUNCTION_BLOCK FB_Test
VAR_INPUT
    i_xTest : BOOL;
    i_lrTest : LREAL;
END_VAR
VAR_OUTPUT
    q_xTest : BOOL;
    q_lrTest : LREAL;
END_VAR
VAR
    xSet : BOOL;
    xReset : BOOL;
    SR_0 : SR;
    R_TRIG_0 : R_TRIG;
END_VAR

Implementation of the Act_Text action (in FBD) with access to the I/Os of the respective function block

_cds_object_action_example_textact.png


Tip

Actions are often used in the SFC implementation language.