Hi,
I haven’t implemented such a functionality so far, so I can’t provide a example.
But I think you need to identify, if your code is running inside a INIT program, and if the INIT reason is a cold- or warmstart (but not a program transfer).
As a function block is not running itself in the cyclic context but is always called by a task, the call of the function block also has to be done in the INIT program of a task (because the init reason can’t deliver any time context when the last action happened).
Both information, if running in a INIT program and if the INIT reason was a restart, can be gathered by two function blocks in the BRSystem library:
- RTinit() to determine if the call was done inside a INIT program
- RTInfo() to determine the last init reason (FB output .init_reason)
So, combining those both informations inside a function block, and calling this function block inside the INIT of a task could be worth a try.
Best regards!