|
@@ -18,7 +18,7 @@ public class GatherTask implements Runnable{
|
|
|
|
|
|
private Channel channel;
|
|
|
|
|
|
- private long cmdTimeout=35*1000; //指令等待回复超时时间 30s
|
|
|
+ private long cmdTimeout=25*1000; //指令等待回复超时时间 2次超时=50s 不能超过采集周期60s
|
|
|
|
|
|
private int timeoutCount=0; //超时发送指令次数
|
|
|
|
|
@@ -28,6 +28,9 @@ public class GatherTask implements Runnable{
|
|
|
|
|
|
@Override
|
|
|
public void run() {
|
|
|
+ //新的采集开始先复位 ATTR_KEY_PRE_TIME,timeoutCount
|
|
|
+ channel.attr(ChannelGroupMgr.ATTR_KEY_PRE_TIME).set(null);
|
|
|
+ timeoutCount=0;
|
|
|
|
|
|
ByteBufAllocator alloc=channel.alloc();
|
|
|
synchronized(channel) {
|
|
@@ -104,7 +107,10 @@ public class GatherTask implements Runnable{
|
|
|
ZLOpdProtCMDEnum.DIAGRAM_POWER_3
|
|
|
|
|
|
};
|
|
|
+
|
|
|
ByteBuf byteBuf=null;
|
|
|
+ timeoutCount=0 ; //多值采集开始前复位该值(因为单值与多值有5分钟间隔,该间隔不能算作超时)
|
|
|
+
|
|
|
for(ZLOpdProtCMDEnum cmd : cmds) {
|
|
|
|
|
|
if(needCloseChannel()) {
|
|
@@ -150,7 +156,7 @@ public class GatherTask implements Runnable{
|
|
|
}
|
|
|
boolean isTimeout= ((new Date()).getTime()-pre.longValue())>(cmdTimeout-1000);
|
|
|
|
|
|
- /**
|
|
|
+
|
|
|
if(!isTimeout) {
|
|
|
timeoutCount=0; //有一次不超时就清空超时次数
|
|
|
}
|
|
@@ -159,8 +165,8 @@ public class GatherTask implements Runnable{
|
|
|
}
|
|
|
|
|
|
return timeoutCount>1; //多次超时(2次及以上)需要关闭通道,等待重连
|
|
|
- **/
|
|
|
|
|
|
- return isTimeout;
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|