Attribute 'no_virtual_actions'

The pragma is applied to function blocks derived from a function block implemented in SFC and using the basic SFC sequence of this base class. The resulting actions show the same virtual behavior as methods. This means that the implementations of the actions in the base class from the derived class can be replaced by specific custom implementations.

If you apply the pragma to the base class, your actions are protected against overloading.

Syntax: {attribute 'no_virtual_actions'}

Insertion location: Top line in the declaration part of the function block

Sample:

The function block FB_Sample is the base class for the derived function block FB_SampleExt.

The derived class FB_SampleExt uses the special variable SUPER to call the base class process, which is written in SFC.

Attribute 'no_virtual_actions' 1:

The sample implementation of this process is limited to the initial step followed by a single step with associated step action ACT1. This step with associated step action deals with assignment of the output variable.

nAN := nAn + 1; // Counting the action calls 
sTestAct:='father_action'; 
METH1();  // Call of the method METH1 in order to set the string variable sTestMeth

In the case of the derived class FB_SampleExt, the step action is replaced by a special implementation of ACT1. ACT1 differs from the original only by assigning the string 'child_action' instead of 'father_action' to the variable sTestAct.

In addition, the method METH1, which in the base class assigns the string' father_method' to the variable sTestMeth, is overwritten so that sTestMeth is now assigned the value sTestMeth. The MAIN program calls an instance of the function block FB_SampleExt called "fbSampleExt". As expected, the value of the strings reflects the call of action and method of the derived class:

Attribute 'no_virtual_actions' 2:

Now, however, you precede the base with the pragma {attribute' no_virtual_actions'}:

{attribute 'no_virtual_actions'} 
FUNCTION_BLOCK FB_Sample... 

This changes the behavior: While the implementation of the derived class continues to be used for method METH1, calling the step action now results in a call of the action ACT1 of the base class. Therefore, sTestAct is now assigned the value 'father_action':

Attribute 'no_virtual_actions' 3: