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 2b62bd20c..a609a2d78 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 @@ -19,10 +19,12 @@ public class DeviceOpcProtocolRunable implements Runnable { OpcServerManageDto OpcServer; int error_num; String message; + private Server server; public DeviceOpcProtocolRunable() { this.error_num = 0; this.message = null; + this.server = null; } public List getProtocols() { @@ -60,7 +62,7 @@ public class DeviceOpcProtocolRunable implements Runnable { public void run() { while (true) { try { - Server server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain()); + this.server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain()); // Group group = server.addGroup(this.OpcServer.getOpc_host()); Group group = server.addGroup(this.OpcServer.getOpc_code()); if(ObjectUtil.isEmpty(group)){ @@ -191,6 +193,15 @@ public class DeviceOpcProtocolRunable implements Runnable { } } } catch (Exception var30) { + if (this.server != null) { + try { + this.server.disconnect(); + } catch (Exception var25) { + } + } + + this.server = null; + String error_message = "设备信息同步异常,"+var30; if (!StrUtil.equals(this.message, error_message)) { log.warn("", var30);