diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java b/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java index a75d8c5..fa52be5 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java @@ -18,10 +18,12 @@ public class DeviceOpcProtocolRunable implements Runnable { List protocols; OpcServerManageDto OpcServer; int error_num; + int all_null; String message; public DeviceOpcProtocolRunable() { this.error_num = 0; + this.all_null = 0; this.message = null; } @@ -125,7 +127,7 @@ public class DeviceOpcProtocolRunable implements Runnable { } else { time_out = false; } - + boolean valueAllNotNull = false; Set items = itemStatus.keySet(); Iterator var18 = items.iterator(); @@ -145,12 +147,38 @@ public class DeviceOpcProtocolRunable implements Runnable { this.error_num = 0; this.message = null; } + if (!valueAllNotNull) { + int random = (new Random()).nextInt(10) + 1; + random *= 1000; + if (this.all_null < 3) { + log.warn("{} 所有内容都为空,暂定{}s", tag, 5000 + random); + ThreadUtl.sleep((long)(5000 + random)); + } else if (this.all_null < 6) { + log.warn("{} 所有内容都为空,暂定{}s", tag, 30000 + random); + ThreadUtl.sleep((long)(30000 + random)); + } else if (this.all_null < 12) { + log.warn("{} 所有内容都为空,暂定{}ms", tag, '\uea60' + random); + ThreadUtl.sleep((long)('\uea60' + random)); + } else { + log.warn("{} 所有内容都为空,暂定{}ms", tag, 120000 + random); + ThreadUtl.sleep((long)(120000 + random)); + } + + ++this.all_null; + } else { + this.all_null = 0; + } continue label97; } item = (Item) var18.next(); ItemState itemState = (ItemState) itemStatus.get(item); value = OpcUtl.getValue(item, itemState); + + if (value != null) { + valueAllNotNull = true; + } + his = accessor_value.getValue(item.getId()); if (!ObjectUtil.equal(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) { log.warn("opc 值不健康 item: {}, 状态: {}", item.getId(), itemState.getQuality()); @@ -178,6 +206,8 @@ public class DeviceOpcProtocolRunable implements Runnable { } } + System.out.println("opc线程停止。。。"); + return; } catch (Exception var30) { if (!DeviceOpcSynchronizeAutoRun.isRun) { System.out.println("opc线程停止2。。。"); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/opc/ThreadUtl.java b/acs/nladmin-system/src/main/java/org/nl/acs/opc/ThreadUtl.java new file mode 100644 index 0000000..be1e259 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/opc/ThreadUtl.java @@ -0,0 +1,20 @@ +package org.nl.acs.opc; + +/** + * @author ldjun + * @version 1.0 + * @date 2023年01月06日 11:23 + * @desc desc + */ +public class ThreadUtl { + private ThreadUtl() { + } + + public static void sleep(long times) throws RuntimeException { + try { + Thread.sleep(times); + } catch (InterruptedException var3) { + throw new RuntimeException(var3); + } + } +}