该属性标记了从命名约定分析中排除的代码行。在停用代码分析的第一行代码之前,会为 pragma 属性分配一个off 。在最后一行之后会分配一个on 。分配omit 时,只忽略下一行代码。
插入位置 :停用:在 POU 和 DUT 的声明部分,受影响线路的上方。激活:受影响线路下方。
语法 :
{attribute 'naming' := '<switch state>'}
<switch state> : on | off | omit
on : naming is switched on
off : naming is switched off
omit : only next code line is switched off
示例
定义命名约定:1) INT 变量名必须以 "int "作为标识符前缀,例如 "intVar1"。2) 程序名称必须以 "prog "开头。
对于下面的代码,静态分析只对以下变量发出信息:cccVar,aVariable, 和bVariable 。
VAR
{attribute 'naming' := 'off'}
iVarA : INT;
iVarB : INT;
{attribute 'naming' := 'on'}
iVarC : INT;
END_VAR
VAR
...
{attribute 'naming' := 'omit'}
iVarC : INT;
...
END_VAR
{attribute 'naming' := 'omit'}
PROGRAM PLC_PRG
VAR
...
END_VAR
{attribute 'naming' := 'off'}
PROGRAM DoSomethingA
VAR
{attribute 'naming' := 'on'}
iVarA : INT;
iVarB : INT;
…
VAR_END