|
|
@ -147,46 +147,50 @@ public class DeviceRunner implements CommandLineRunner { |
|
|
// - 大卷B分切信号:0x502 |
|
|
// - 大卷B分切信号:0x502 |
|
|
int cuta = 500; |
|
|
int cuta = 500; |
|
|
int cutb = 502; |
|
|
int cutb = 502; |
|
|
|
|
|
int cutab = 508; |
|
|
int bit1 = collectUtil.readHoldingRegister(ip, port, cuta); |
|
|
int bit1 = collectUtil.readHoldingRegister(ip, port, cuta); |
|
|
logger.info("卷A分切信号:{}", bit1); |
|
|
logger.info("卷A分切信号:{}", bit1); |
|
|
// 卷B分切信号 |
|
|
// 卷B分切信号 |
|
|
int bit2 = collectUtil.readHoldingRegister(ip, port, cutb); |
|
|
int bit2 = collectUtil.readHoldingRegister(ip, port, cutb); |
|
|
logger.info("卷B分切信号:{}", bit2); |
|
|
logger.info("卷B分切信号:{}", bit2); |
|
|
|
|
|
int bit3 = collectUtil.readHoldingRegister(ip, port, cutab); |
|
|
|
|
|
logger.info("大卷AB分切信号:{}", bit3); |
|
|
|
|
|
|
|
|
String nextRollNo = ""; |
|
|
String nextRollNo = ""; |
|
|
|
|
|
|
|
|
if (bit1 == 1) { |
|
|
|
|
|
// 获取寄存器信息 |
|
|
|
|
|
List<Integer> list = getConnectData(deviceInfo); |
|
|
|
|
|
// 获取卷A信息 |
|
|
|
|
|
Integer rollAddress1 = deviceInfo.getRollAddress1(); |
|
|
|
|
|
Integer rollQty1 = deviceInfo.getRollQty1(); |
|
|
|
|
|
List<Integer> roll1 = subAddressValue(rollAddress1, rollQty1 - 1, list); |
|
|
|
|
|
String rStr1 = convertHex(roll1).trim(); |
|
|
|
|
|
logger.info("卷A:{}", rStr1); |
|
|
|
|
|
nextRollNo = rStr1; |
|
|
|
|
|
// 回写清零 |
|
|
|
|
|
collectUtil.writeHoldingRegister(ip, port, cuta, 0); |
|
|
|
|
|
} |
|
|
|
|
|
if (bit2 == 1) { |
|
|
|
|
|
// 获取寄存器信息 |
|
|
|
|
|
List<Integer> list = getConnectData(deviceInfo); |
|
|
|
|
|
// 获取卷B信息 |
|
|
|
|
|
Integer rollAddress2 = deviceInfo.getRollAddress2(); |
|
|
|
|
|
Integer rollQty2 = deviceInfo.getRollQty2(); |
|
|
|
|
|
List<Integer> roll2 = subAddressValue(rollAddress2, rollQty2 - 1, list); |
|
|
|
|
|
String rStr2 = convertHex(roll2).trim(); |
|
|
|
|
|
logger.info("卷B:{}", rStr2); |
|
|
|
|
|
nextRollNo = rStr2; |
|
|
|
|
|
// 回写清零(注意:0x502 同时也可能作为小卷信号地址使用) |
|
|
|
|
|
collectUtil.writeHoldingRegister(ip, port, cutb, 0); |
|
|
|
|
|
} |
|
|
|
|
|
// 存在信号 |
|
|
|
|
|
if (bit1 == 1 || bit2 == 1) { |
|
|
|
|
|
// 获取Redis中卷号信息 |
|
|
|
|
|
String rollNo = (String) redisTemplate.opsForValue().get("device:" + ip); |
|
|
|
|
|
// 触发分切,执行方法扫描卷处理 |
|
|
|
|
|
deviceGatherService.scanRollNo(deviceInfo, rollNo, nextRollNo); |
|
|
|
|
|
|
|
|
if(bit3 == 1){ |
|
|
|
|
|
if (bit1 == 1) { |
|
|
|
|
|
// 获取寄存器信息 |
|
|
|
|
|
List<Integer> list = getConnectData(deviceInfo); |
|
|
|
|
|
// 获取卷A信息 |
|
|
|
|
|
Integer rollAddress1 = deviceInfo.getRollAddress1(); |
|
|
|
|
|
Integer rollQty1 = deviceInfo.getRollQty1(); |
|
|
|
|
|
List<Integer> roll1 = subAddressValue(rollAddress1, rollQty1 - 1, list); |
|
|
|
|
|
String rStr1 = convertHex(roll1).trim(); |
|
|
|
|
|
logger.info("卷A:{}", rStr1); |
|
|
|
|
|
nextRollNo = rStr1; |
|
|
|
|
|
// 回写清零 |
|
|
|
|
|
collectUtil.writeHoldingRegister(ip, port, cuta, 0); |
|
|
|
|
|
} |
|
|
|
|
|
if (bit2 == 1) { |
|
|
|
|
|
// 获取寄存器信息 |
|
|
|
|
|
List<Integer> list = getConnectData(deviceInfo); |
|
|
|
|
|
// 获取卷B信息 |
|
|
|
|
|
Integer rollAddress2 = deviceInfo.getRollAddress2(); |
|
|
|
|
|
Integer rollQty2 = deviceInfo.getRollQty2(); |
|
|
|
|
|
List<Integer> roll2 = subAddressValue(rollAddress2, rollQty2 - 1, list); |
|
|
|
|
|
String rStr2 = convertHex(roll2).trim(); |
|
|
|
|
|
logger.info("卷B:{}", rStr2); |
|
|
|
|
|
nextRollNo = rStr2; |
|
|
|
|
|
// 回写清零(注意:0x502 同时也可能作为小卷信号地址使用) |
|
|
|
|
|
collectUtil.writeHoldingRegister(ip, port, cutb, 0); |
|
|
|
|
|
} |
|
|
|
|
|
// 存在信号 |
|
|
|
|
|
if (bit1 == 1 || bit2 == 1) { |
|
|
|
|
|
// 获取Redis中卷号信息 |
|
|
|
|
|
String rollNo = (String) redisTemplate.opsForValue().get("device:" + ip); |
|
|
|
|
|
// 触发分切,执行方法扫描卷处理 |
|
|
|
|
|
deviceGatherService.scanRollNo(deviceInfo, rollNo, nextRollNo); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|