断点重连的次数和间隔开放到配置文件里,并且支持无限次重连;添加盘点拍照延时

chengdu-mxbc-qsl
QuShuailong 3 years ago
parent c2845fe6c7
commit a880b5148b

@ -59,6 +59,7 @@ public class ConfigProperties {
private Long C3DelayCaptureTime; private Long C3DelayCaptureTime;
private Long C4DelayCaptureTime; private Long C4DelayCaptureTime;
private Long C4OutDelayCaptureTime; private Long C4OutDelayCaptureTime;
private Long EDelayCaptureTime;
private Long B2DelayTime; private Long B2DelayTime;
private Long B2OutDelayTime; private Long B2OutDelayTime;
@ -82,6 +83,8 @@ public class ConfigProperties {
public static class KSEC{ public static class KSEC{
private String ip; private String ip;
private Integer port; private Integer port;
private Integer reconnectNum;
private Long reconnectInterval;
} }
@Data @Data

@ -571,6 +571,7 @@ public class PlcService {
log.info("camera ptz"+c); log.info("camera ptz"+c);
gyrateCameraByCode(cameraIdTop, c); gyrateCameraByCode(cameraIdTop, c);
}else { }else {
log.info("camera ptz"+cmdCode);
gyrateCameraByCode(cameraIdTop, cmdCode); gyrateCameraByCode(cameraIdTop, cmdCode);
try { try {
Thread.sleep(configProperties.getCameraConfig().getDelayCaptureTime()); Thread.sleep(configProperties.getCameraConfig().getDelayCaptureTime());
@ -583,7 +584,7 @@ public class PlcService {
String path = PathUtil.createFileNameByRowColumn("jpg",cameraId,plcCmdInfo.getRow1(),plcCmdInfo.getColumn1()); String path = PathUtil.createFileNameByRowColumn("jpg",cameraId,plcCmdInfo.getRow1(),plcCmdInfo.getColumn1());
//拍照暂停1s再拍 //拍照暂停1s再拍
try { try {
Thread.sleep(1000l); Thread.sleep(configProperties.getCameraConfig().getEDelayCaptureTime());
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -593,7 +594,7 @@ public class PlcService {
log.info("camera ptz"+e2); log.info("camera ptz"+e2);
gyrateCameraByCode(cameraId, e2); gyrateCameraByCode(cameraId, e2);
try { try {
Thread.sleep(1500l); Thread.sleep(configProperties.getCameraConfig().getEDelayCaptureTime());
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }

@ -25,11 +25,6 @@ public class KsecNettyClient {
@Resource @Resource
private ConfigProperties configProperties; private ConfigProperties configProperties;
/**
*
*/
private static int RECONNECT_NUM = 10;
private static Channel channel; private static Channel channel;
public void createClient(ConfigProperties.KSEC ksec) throws InterruptedException { public void createClient(ConfigProperties.KSEC ksec) throws InterruptedException {
@ -67,13 +62,21 @@ public class KsecNettyClient {
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
while (num < RECONNECT_NUM && !isConnected) { while (ksec.getReconnectNum() == -1 && num < ksec.getReconnectNum() && !isConnected) {
try { try {
createClient(ksec); createClient(ksec);
} catch (Exception e) { }
//没连上 继续 //没连上 继续
catch (Exception e) {
//关闭当前链接
channel.close();
log.error("reconnect error num:{}", num); log.error("reconnect error num:{}", num);
num++; num++;
try{
Thread.sleep(ksec.getReconnectInterval());
}catch (Exception ex){
throw new RuntimeException(ex);
}
continue; continue;
} }
isConnected = true; isConnected = true;

@ -45,6 +45,8 @@ cameraConfig:
C3DelayCaptureTime: 1500 C3DelayCaptureTime: 1500
C4DelayCaptureTime: 1500 C4DelayCaptureTime: 1500
C4OutDelayCaptureTime: 1500 C4OutDelayCaptureTime: 1500
# 盘点延时多久拍照
EDelayCaptureTime: 2500
# 发了B2之后多久转原点位 # 发了B2之后多久转原点位
B2DelayTime: 2000 B2DelayTime: 2000
# 外侧货架发了B2多久转原点位 # 外侧货架发了B2多久转原点位
@ -63,6 +65,10 @@ serverMode: 1
ksec: ksec:
ip: 192.168.168.11 ip: 192.168.168.11
port: 8001 port: 8001
#断点重连的次数:-1->不断重连
reconnectNum: -1
#断点重连的时间间隔(单位ms)
reconnectInterval: 10000
# ------------ 实时视频流 全部页面的格式 行列数量 # ------------ 实时视频流 全部页面的格式 行列数量
videoStyleConfig: videoStyleConfig:
videoStyleRow: 4 videoStyleRow: 4

Loading…
Cancel
Save