SA0004: Multiple write access on output
Function | Determines outputs that are written at more than one position. |
Reason | The maintainability suffers if an output is written in various places in the code. It is then unclear which write access is actually affecting the process. It is good practice to perform the calculation of the output variables in auxiliary variables and to assign the calculated value to a point at the end of the cycle. |
Exception | No error is issued if an output variable is written in different branches of IF or CASE statements. |
Importance | High |
PLCopen rule | CP12 |
![]() | This rule cannot be disabled via a pragma or attribute! |
Sample:
Global variable list:
VAR_GLOBAL
bVar AT%QX0.0 : BOOL;
nSample AT%QW5 : INT;
END_VARMAIN program:
PROGRAM MAIN
VAR
nCondition : INT;
END_VARIF nCondition < INT#0 THEN
bVar := TRUE; // => SA0004
nSample := INT#12; // => SA0004
END_IF
CASE nCondition OF
INT#1:
bVar := FALSE; // => SA0004
INT#2:
nSample := INT#11; // => SA0004
ELSE
bVar := TRUE; // => SA0004
nSample := INT#9; // => SA0004
END_CASE