更新opc线程
This commit is contained in:
@@ -12,6 +12,8 @@ import org.openscada.opc.lib.da.ItemState;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
@Slf4j
|
||||
public class DeviceOpcProtocolRunable implements Runnable {
|
||||
@@ -19,6 +21,7 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
OpcServerManageDto OpcServer;
|
||||
int error_num;
|
||||
String message;
|
||||
int maxResartNum;
|
||||
private Server server;
|
||||
|
||||
public DeviceOpcProtocolRunable() {
|
||||
@@ -172,8 +175,24 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
value = OpcUtl.getValue(item, itemState);
|
||||
his = accessor_value.getValue(item.getId());
|
||||
if (!ObjectUtl.isEquals(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) {
|
||||
maxResartNum ++;
|
||||
log.warn("opc 值不健康 item: {}, 状态: {},当前读取值:{}, 系统内存值{} ", item.getId(), itemState.getQuality(), value, his);
|
||||
}
|
||||
if(maxResartNum>1000){
|
||||
if (this.server != null) {
|
||||
try {
|
||||
this.server.disconnect();
|
||||
} catch (Exception var25) {
|
||||
log.warn("{} : server disconnect", var25);
|
||||
}
|
||||
}
|
||||
DeviceOpcProtocolRunable runable = new DeviceOpcProtocolRunable();
|
||||
runable.setProtocols(protocols);
|
||||
runable.setOpcServer(OpcServer);
|
||||
ExecutorService executorService = Executors.newCachedThreadPool();
|
||||
executorService.submit(runable);
|
||||
log.warn("opc 值不健康 item: {}, 重新创建连接", item.getId());
|
||||
}
|
||||
} while (ObjectUtil.equal(value, his));//如果两次的值相等,不走下面的代码
|
||||
|
||||
OpcItemDto itemDto = this.getItem(item.getId());
|
||||
|
||||
Reference in New Issue
Block a user