Attribute: init_on_onlchange
No initialization code during a fast online change
Since compiler version >= 3.5.0.0, a "fast online change" is performed for minor changes. During a fast online change, only the modified POUs are compiled and downloaded. In particular, no initialization code is generated.
For variables with the init_on_onlchange
attribute, this also results in no initialization code being generated. In the usual scenarios, that has no impact because the attribute is usually used to initialize variables with addresses. However, during a fast online change, it cannot happen that a variable changes its address.
However, to make sure of the impact of the init_on_onlchange
attribute is applied in the entire application code, in general for the application you can use the no_fast_online_change
compiler define to disable the fast online change. To do this, select your application object in the device tree and click Properties in the context menu. Below the Build tab, add the no_fast_online_change
compiler define.
For more information, see: Build
The effect of this pragma is that the variable to which the pragma is applied is initialized with each online change.
Syntax:
{attribute 'init_on_onlchange' }
Insert location: The line above the line with the declaration of the variables.
VAR_GLOBAL {attribute 'init_on_onlchange'} g_fastOnlineChange : BOOL := FALSE; END_VAR
{attribute 'call_after_online_change_slot' := '4567'} FUNCTION FUNC_OnlineChangeDetection : BOOL VAR_INPUT END_VAR VAR END_VAR IF GVL_OnlineChangeDetection.g_fastOnlineChange THEN // here you know that you are inside a FastOnlineChange END_IF // reset for next detection GVL_OnlineChangeDetection.g_fastOnlineChange := TRUE;