Behavior with derived function blocks

When using the methods FB_init, FB_reinit and FB_exit in the context of derived function blocks, please note the following.

FB_init with derived function blocks

If a function block is derived from another function block, then the FB_init method of the basic function block is automatically executed for this function block. If the FB_init method of the derived function block is explicitly added, it is executed following the FB_init method of the basic function block (see Behavior with derived function blocks).

If the FB_init method of the derived function block is to be present in explicit form, it must define the same parameters as the FB_init method of the basic function block. Further parameters can be added, in order to set up a special initialization for the derived instance.

FB_reinit with derived function blocks

To reinitialize the basic implementation of the function block, FB_reinit must be called explicitly for the basic function block (via SUPER^.FB_reinit()). The return value can be evaluated.

FB_exit with derived function blocks

If a function block is derived from another function block, then the FB_exit method of the basic function block is automatically executed for this function block. If the FB_exit method of the derived function block is explicitly added, this is executed first and then the FB_exit method of the basic function block (see Behavior with derived function blocks).

Sample of the calling order in the case of derived function blocks

The function blocks FB_Base, FB_Sub and FB_SubSub are derived from each other. The following applies:

Situation:

Assumption - case 1:

Call sequence:

The call sequence for the methods FB_exit, FB_init and FB_reinit for the function block instance fbSubSub is then as follows:

  1. Impliziter Aufruf von FB_SubSub.FB_exit(TRUE) für fbSubSub
  2. Impliziter Aufruf von FB_Sub.FB_exit(TRUE) für fbSubSub
  3. Impliziter Aufruf von FB_Base.FB_exit(TRUE) für fbSubSub
  4. Impliziter Aufruf von FB_Base.FB_init(FALSE, TRUE) für fbSubSub
  5. Impliziter Aufruf von FB_Sub.FB_init(FALSE, TRUE) für fbSubSub
  6. Impliziter Aufruf von FB_SubSub.FB_init(FALSE, TRUE) für fbSubSub
  7. Impliziter Aufruf von FB_SubSub.FB_reinit() für fbSubSub

Assumption – case 2:

Call sequence:

The call sequence for the methods FB_exit, FB_init and FB_reinit for the function block instance fbSubSub is then as follows:

  1. Impliziter Aufruf von FB_SubSub.FB_exit(TRUE) für fbSubSub
  2. Impliziter Aufruf von FB_Sub.FB_exit(TRUE) für fbSubSub
  3. Impliziter Aufruf von FB_Base.FB_exit(TRUE) für fbSubSub
  4. Impliziter Aufruf von FB_Base.FB_init(FALSE, TRUE) für fbSubSub
  5. Impliziter Aufruf von FB_Sub.FB_init(FALSE, TRUE) für fbSubSub
  6. Impliziter Aufruf von FB_SubSub.FB_init(FALSE, TRUE) für fbSubSub
  7. Impliziter Aufruf von FB_SubSub.FB_reinit() für fbSubSub
  8. Expliziter Aufruf von FB_Sub.FB_reinit() für fbSubSub
  9. Expliziter Aufruf von FB_Base.FB_reinit() für fbSubSub