Infosys在阅读器中打开 / AI 翻译

PLC · 0 次阅读

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 Examples of call sequence).

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 Examples of call sequence).

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:

  • FB_Sub EXTENDS FB_Base
  • FB_SubSub EXTENDS FB_Sub

Situation:

  • All three function blocks have their own FB_init, FB_reinit and FB_exit methods.
  • The function block FB_SubSub is instantiated. An additional variable is added to the function block via Online Change.

Assumption - case 1:

  • No reinitialization of the basic implementation is required. This means that the call SUPER^.FB_reinit() does not exist in the method FB_SubSub.FB_reinit.

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:

  • A reinitialization of the basic implementation is required. This means that the methods FB_SubSub.FB_reinit and FB_Sub.FB_reinit contain the call SUPER^.FB_reinit().

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