SA0015:通过 FB_Init 访问全局数据
通过方法检测功能块对全局变量的访问 FB_Init.此变量的值取决于初始化的顺序。
理由:根据 POU 实例的声明位置,如果违反规则,可能会访问未初始化的变量。
重要性:高
例 28. 例子
VAR_GLOBAL
g_xTest1 : BOOL;
g_iTest3 : INT;
END_VARMETHOD PUBLIC 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;
END_VAR
g_xTest1 := NOT g_xTest1; // SA0015 g_iTest3 := g_iTest3 + INT#1; // SA0015
输出在 留言 看法:
SA0015:功能块“POU”的 FB_Init 方法访问全局数据