L-force | plc designer – Lenze PLC Designer PLC Designer (R3-1) User Manual

Page 986

Advertising
background image

L-force | PLC Designer

Programming Reference

984

DMS 4.1 EN 03/2011 TD29

On the call sequence in case of inheritance please see: FB_exit, Execution order
Regard also the possibility of defining a function block instance method to be called
automatically after initialization via FB_init: attribute call_after_init

Interface of the init method:

METHOD fb_init : BOOL
VAR_INPUT
bInitRetains : BOOL; // if TRUE, the retain variables are initialized (warm start / cold
start)
bInCopyCode : BOOL; // if TRUE, the instance afterwards gets moved into the copy
code (online change)
END_VAR

The return value is not interpreted.

Note: Notice also the possible use of an "exit" method and the resulting execution
order: See FB_exit Method.


User defined input:
In an init method additional inputs can be declared. Those must be assigned at the
declaration of a function block instance.

Example for a init method for a function block "serialdevice"

METHOD fb_init : BOOL
VAR_INPUT
bInitRetains : BOOL; (* Initialization of retains *)
bInCopyCode : BOOL; (* Instance moved into copy code *)
nCOMnum : INT; (* additional input: number of the COM interface to listen at *)
END_VAR

Declaration of function block "serialdevice":

COM1 : serialdevice(nCOMnum:=1);
COM0 : serialdevice(nCOMnum:=0);


Advertising