通过FB_Init
方法检测功能块对全局变量的访问。该变量的值取决于初始化的顺序。
理由根据 POU 实例的声明位置,如果违反规则,可能会访问未初始化的变量。
重要性:高
示例
VAR_GLOBAL g_xTest1 : BOOL; g_iTest3 : INT; END_VAR METHOD PUBLIC 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 g_xTest1 := NOT g_xTest1; // SA0015 g_iTest3 := g_iTest3 + INT#1; // SA0015 --> SA0015: FB_Init method of function block 'POU' accesses global data