Skip to main content

FB_init

Short Summary

The constructor FB_init is needed to create an unique hash code. The hash code is a pseudo random number create with a xorshift_ algorithm. It can be overwritten on derivations, because it will be called implicit, SUPER^.FB_init() is not required. For more information check: Behavoir with derived function blocks_

.. _Behavoir with derived function blocks: https://infosys.beckhoff.com/content/1033/tc3_plc_intro/5482088715.html?id=6983869892358031022 .. _xorshift: https://en.wikipedia.org/wiki/Xorshift

parameters

  • Return type: BOOL

Parameters

NameTypeCommentKind
bInitRetainsBOOLif TRUE, the retain variables are initialized (warm start / cold start)input
bInCopyCodeBOOLif TRUE, the instance afterwards gets moved into the copy code (online change)input
modeHandlerCNM_OpModeHandlingInterfaces.IOpModeHandleroperation mode handler for the stationinput
customModeConditionsCNM_OpModeHandlingInterfaces.IModeConditionProvidercustom mode condition, if set to 0, default conditions will be usedinput

Code

Declaration

METHOD FB_init : BOOL
VAR_INPUT
(* if TRUE, the retain variables are initialized (warm start / cold start)*)
bInitRetains : BOOL;
(* if TRUE, the instance afterwards gets moved into the copy code (online change) *)
bInCopyCode : BOOL;
(* operation mode handler for the station *)
modeHandler :CNM_OpModeHandlingInterfaces.IOpModeHandler;
(* custom mode condition, if set to 0, default conditions will be used *)
customModeConditions :CNM_OpModeHandlingInterfaces.IModeConditionProvider;
END_VAR

Implementation

IF THIS^.isObjectValid(modeHandler) THEN
modeHandler.globalMessageService := THIS^.messageService;
END_IF
IF (customModeConditions <> 0) THEN
THIS^.conditionProvider := customModeConditions;
ELSE
THIS^.defaultConditions := __NEW(DefaultModeConditions);
IF (THIS^.defaultConditions <> 0) THEN
THIS^.conditionProvider := THIS^.defaultConditions^;
END_IF
END_IF