Attribute call_after_init
Use the pragma {attribute call_after_init}
to define a method that is called implicitly after the initialization of a function block instance. For performance reasons, attach the attribute both to the function block itself and to the instance method to be called. The method has to be called after FB_Init and after having applied the variable values of an initialization expression in the instance declaration.
With the following definition:
{attribute 'call_after_init'}
FUNCTION_BLOCK FB
... <functionblock definition>
{attribute 'call_after_init'}
METHOD FB_AfterInit
... <method definition>
... declaration like the following:
inst : FB := (in1 := 99);
... will result in the following order of code processing:
inst.FB_Init();
inst.in1 := 99;
inst.FB_AfterInit();
So, in FB_Afterinit
, you can react on the user-defined initialization.