in EcoStruxure Machine Expert means that before a project can be downloaded to the target system without build errors, the source code is searched for deviations from certain coding directives. To this purpose, a set of rules to be respected can be configured in the project settings. An automatic verification, according to those defined rules, is performed at code generation.
{analysis ...} pragma or the {attribute 'analysis' := '...'} pragma.
The results of the analysis are displayed as errors in the view with the prefix .
|
Detect variables, which are declared, but not used within the compiled program code. |
|
|
Detect an allocation of two or more variables to the same memory location.
For example, this occurs if there are the following declarations: |
|
|
Detect variables which are written by more than 1 task. |
Example (SA0006):
FUNCTION_BLOCK ADD_FB
g_iTemp1 := g_iTemp1 + INT#1;
PROGRAM PLC_PRG //controlled by MainTask
g_iTemp1 := g_iTemp1 + INT#2;
g_xTemp2 := g_iTemp1 > INT#10;
PROGRAM PLC_PRG_1 //controlled by SubTask
g_iTemp1 := g_iTemp1 - INT#3;
g_xTemp2 := g_iTemp1 < INT#-10;
|
(SA0004): |
Detect outputs which are written at more than one position. |
VAR_GLOBAL
g_xVar AT %QX0.0 : BOOL ;
g_iTest AT %QW0 : INT ;
END_VAR
PROGRAM PLC_PRG
IF iCondition < INT#0 THEN
g_xVar := TRUE;
g_iTest := INT#12;
END_IF
CASE iCondition OF
INT#1:
g_xVar := FALSE;
INT#2:
g_iTest := INT#11;
ELSE
g_xVar := TRUE;
g_iTest := INT#9;
END_CASE
|
Detect multiple use of a name/identifier for a variable or object (POU) within the scope of a project. The following cases are detected:
|
Example (SA0027):
PROGRAM PLC_PRG
VAR
ton : INT; // error SA0027
END_VAR
The Standard.library is included in the project and provides the function block TON resulting in a multiple usage of a name.
|
The test detects function block instances that are declared as temporary variables. This applies to instances that are declared in a method, or in a function, or as VAR_TEMP, and that are therefore reinitialized in each processing cycle and for each POU call. |
Example (SA0167):
PROGRAM PLC_PRG
VAR
END_VAR
VAR_TEMP
yafb: AFB;
END_VAR
FUNCTION Fun : INT
VAR_INPUT
END_VAR
VAR
funafb: AFB;
END_VAR
METHOD METH : INT
VAR_INPUT
END_VAR
VAR
methafb: AFB;
END_VAR