rev 还原自动线程
This commit is contained in:
@@ -22,7 +22,7 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
|||||||
int error_num;
|
int error_num;
|
||||||
String message;
|
String message;
|
||||||
private Server server;
|
private Server server;
|
||||||
boolean flag =false;
|
//boolean flag =false;
|
||||||
|
|
||||||
|
|
||||||
public DeviceOpcProtocolRunable() {
|
public DeviceOpcProtocolRunable() {
|
||||||
@@ -176,30 +176,30 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
|||||||
value = OpcUtl.getValue(item, itemState);
|
value = OpcUtl.getValue(item, itemState);
|
||||||
his = accessor_value.getValue(item.getId());
|
his = accessor_value.getValue(item.getId());
|
||||||
if (!ObjectUtl.isEquals(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) {
|
if (!ObjectUtl.isEquals(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) {
|
||||||
flag = true;
|
//flag = true;
|
||||||
log.warn("opc 值不健康 item: {}, 状态: {},当前读取值:{}, 系统内存值{} ", item.getId(), itemState.getQuality(), value, his);
|
log.warn("opc 值不健康 item: {}, 状态: {},当前读取值:{}, 系统内存值{} ", item.getId(), itemState.getQuality(), value, his);
|
||||||
}
|
}
|
||||||
if(flag){
|
// if(flag){
|
||||||
if (this.server != null) {
|
// if (this.server != null) {
|
||||||
try {
|
// try {
|
||||||
this.server.disconnect();
|
// this.server.disconnect();
|
||||||
} catch (Exception var25) {
|
// } catch (Exception var25) {
|
||||||
log.warn("{} : server disconnect", var25);
|
// log.warn("{} : server disconnect", var25);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
DeviceOpcProtocolRunable runable = new DeviceOpcProtocolRunable();
|
// DeviceOpcProtocolRunable runable = new DeviceOpcProtocolRunable();
|
||||||
runable.setProtocols(protocols);
|
// runable.setProtocols(protocols);
|
||||||
runable.setOpcServer(OpcServer);
|
// runable.setOpcServer(OpcServer);
|
||||||
ExecutorService executorService = Executors.newCachedThreadPool();
|
// ExecutorService executorService = Executors.newCachedThreadPool();
|
||||||
executorService.submit(runable);
|
// executorService.submit(runable);
|
||||||
log.warn("opc 值不健康 item: {}, 重新创建连接,当前线程名:{}", item.getId(),tag);
|
// log.warn("opc 值不健康 item: {}, 重新创建连接,当前线程名:{}", item.getId(),tag);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
} while (ObjectUtil.equal(value, his));//如果两次的值相等,不走下面的代码
|
} while (ObjectUtil.equal(value, his));//如果两次的值相等,不走下面的代码
|
||||||
|
|
||||||
if(flag){
|
// if(flag){
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
OpcItemDto itemDto = this.getItem(item.getId());
|
OpcItemDto itemDto = this.getItem(item.getId());
|
||||||
//默认记录日志
|
//默认记录日志
|
||||||
if (true) {
|
if (true) {
|
||||||
@@ -221,13 +221,13 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
|||||||
// accessor_value.getHistoryUnifiedData(item.getId());
|
// accessor_value.getHistoryUnifiedData(item.getId());
|
||||||
//设置值
|
//设置值
|
||||||
accessor_value.setValue(item.getId(), value);
|
accessor_value.setValue(item.getId(), value);
|
||||||
if(flag){
|
// if(flag){
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
|
||||||
if(flag){
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
// if(flag){
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
} catch (Exception var30) {
|
} catch (Exception var30) {
|
||||||
if (this.server != null) {
|
if (this.server != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user