@@ -6,23 +6,27 @@ import EnvironmentVariables
6
6
import IfEqual
7
7
import PlcMemory
8
8
import Sub
9
+ import org.slf4j.LoggerFactory
9
10
import java.util.concurrent.CancellationException
10
11
import toBooleanFromBinary
11
12
12
13
13
14
class SubOperation (private val configuration : Configuration ,private val memory : PlcMemory , environmentVariables : EnvironmentVariables
14
15
) : BaseOperation(environmentVariables, configuration) {
15
16
17
+ companion object {
18
+ val logger = LoggerFactory .getLogger(" SubOperation" )
19
+ }
16
20
fun subOperation (element : Sub ) {
17
- println (" Sub symbol ${element.symbol} value ${element.value} " )
21
+ logger.debug (" Sub symbol ${element.symbol} value ${element.value} " )
18
22
var value = processValue(element.value)
19
23
var variable = configuration.registers.getVarConfiguration(element.symbol)
20
24
if (variable == null ) {
21
- println ( " ERROR: Symbol ${element.symbol} not found during Set execution" )
25
+ logger.error( " Symbol ${element.symbol} not found during Set execution" )
22
26
throw CancellationException (" Error - Sub" )
23
27
} else {
24
28
if (variable.addressType == AddressType .COIL || variable.addressType == AddressType .DISCRETE_INPUT ) {
25
- println ( " ERROR: Symbol ${element.symbol} is of type COIL or DISCRETE_INPUT which is not support by Sub operation" )
29
+ logger.error( " Symbol ${element.symbol} is of type COIL or DISCRETE_INPUT which is not support by Sub operation" )
26
30
throw CancellationException (" Error - Sub" )
27
31
}
28
32
@@ -36,7 +40,7 @@ class SubOperation(private val configuration: Configuration,private val memory:
36
40
if (variable.datatype == " FLOAT32" ) {
37
41
var currentValue = memory.readHoldingRegister(variable.address.toInt(), 2 )
38
42
if (currentValue.isEmpty()) {
39
- println ( " ERROR: Add Operation - Unable to get value of ${element.symbol} address ${variable.address} " )
43
+ logger.error( " Add Operation - Unable to get value of ${element.symbol} address ${variable.address} " )
40
44
throw CancellationException (" Error - Add" )
41
45
}
42
46
val intValue = ((currentValue[1 ].toInt() shl 16 ) or (currentValue[0 ].toInt() and 0xFFFF ))
@@ -47,7 +51,7 @@ class SubOperation(private val configuration: Configuration,private val memory:
47
51
} else {
48
52
var currentValue = memory.readHoldingRegister(variable.address.toInt(), 1 )
49
53
if (currentValue.isEmpty()) {
50
- println ( " ERROR: Add Operation - Unable to get value of ${element.symbol} address ${variable.address} " )
54
+ logger.error( " Add Operation - Unable to get value of ${element.symbol} address ${variable.address} " )
51
55
throw CancellationException (" Error - Add" )
52
56
}
53
57
var intValue = value.toInt()
0 commit comments