This commit is contained in:
caixiang 2022-08-09 14:16:03 +08:00
parent 3b1c667915
commit e373cd8e01

View File

@ -283,11 +283,11 @@ public enum S7Client {
}
private void check_ping(){
while (true){
try {
ScheduledFuture<?> schedule = ping_fail_check.schedule(new Runnable() {
ping_fail_check.execute(new Runnable() {
@Override
public void run() {
while (true){
try {
if(connections.size()!=coreSize){
int c = coreSize-connections.size();
for(int z=0;z<c;z++){
@ -301,22 +301,22 @@ public enum S7Client {
}
}
}
}, 10000, TimeUnit.SECONDS);
Object o = schedule.get();
Thread.sleep(10000);
}catch (Exception e){
logger.info("( out catched ) host:"+host +" ;;(check_ping) "+"check connect.size 出现异常errMessage is : "+e.getMessage()+"现在进入下一次轮询");
logger.info(" ( outside check_ping catched ) host:"+host +" ;;(check_ping()) Thread.sleep 异常,异常原因:"+e.getMessage());
}
}
}
});
}
//todo 当网络断开之后下面这个ping() 循环不生效 可能是read = connector.read( 出来是null但还是继续通过了也可能是 当连接全部断开后 getConnector(); 应该是取不到数据的也就会报null这个明天再看看
private void ping(){
while (true){
try {
ScheduledFuture<?> schedule = executor.schedule(new Runnable() {
executor.execute(new Runnable() {
@Override
public void run() {
while (true){
try {
for(int i=0;i<coreSize;i++){
S7Connector connector = getConnector();
try {
@ -328,6 +328,7 @@ public enum S7Client {
heartBeat.getByteOffset(),
heartBeat.getBitOffset(),
heartBeat.getType().getTransportSize());
System.out.println("host:"+host +" ;; "+connector.hashCode()+" : ping");
Thread.sleep(100);
}catch (Exception e){
@ -357,12 +358,13 @@ public enum S7Client {
}
}
}
}
}, 30000, TimeUnit.SECONDS);
Object o = schedule.get();
Thread.sleep(30000);
}catch (Exception e){
logger.info("( out catched ) host:"+host +" ;;(ping) "+"ping的时候 整体 出现异常errMessage is : "+e.getMessage()+"现在进入下一次轮询");
e.printStackTrace();
logger.info(" ( outside ping catched ) host:"+host +" ;;(ping) "+e.getMessage());
}
}
}
});
}
}