|
|
|
@ -14,6 +14,7 @@ import io.netty.handler.timeout.IdleStateEvent;
|
|
|
|
|
import io.netty.util.ReferenceCountUtil; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springframework.context.ApplicationContext; |
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.List; |
|
|
|
@ -37,7 +38,8 @@ public class EchoServerHandler extends ChannelInboundHandlerAdapter {
|
|
|
|
|
private int size = 0; |
|
|
|
|
private String IP; |
|
|
|
|
private String port; |
|
|
|
|
private String receiveStr=""; |
|
|
|
|
private String receiveStr = ""; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 客户端连接会触发 |
|
|
|
|
*/ |
|
|
|
@ -57,7 +59,7 @@ public class EchoServerHandler extends ChannelInboundHandlerAdapter {
|
|
|
|
|
IdleStateEvent event = (IdleStateEvent) obj; |
|
|
|
|
if (IdleState.READER_IDLE.equals(event.state())) { //如果读通道处于空闲状态,说明没有接收到心跳命令
|
|
|
|
|
log.info("第{}已经10秒没有接收到客户端的信息了", idleCount); |
|
|
|
|
receiveStr =""; |
|
|
|
|
receiveStr = ""; |
|
|
|
|
num = num + 1; |
|
|
|
|
if (num > size - 1) { |
|
|
|
|
num = 0; |
|
|
|
@ -67,7 +69,7 @@ public class EchoServerHandler extends ChannelInboundHandlerAdapter {
|
|
|
|
|
// SendOrderUtils.sendAllOrder(deviceCodeParamList.get(num),ctx,num,size);
|
|
|
|
|
} else { |
|
|
|
|
// 继续发送下一个采集指令
|
|
|
|
|
SendOrderUtils.sendAllOrder(deviceCodeParamList.get(num),ctx,num,size); |
|
|
|
|
SendOrderUtils.sendAllOrder(deviceCodeParamList.get(num), ctx, num, size); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
@ -104,29 +106,23 @@ public class EchoServerHandler extends ChannelInboundHandlerAdapter {
|
|
|
|
|
|
|
|
|
|
// 当前批量读取中的最后一条消息
|
|
|
|
|
@Override |
|
|
|
|
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception{ |
|
|
|
|
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { |
|
|
|
|
//心跳包报文: 24 00 60 95
|
|
|
|
|
receiveStr= receiveStr.toUpperCase();//返回值全部变成大写
|
|
|
|
|
//截取去掉FE
|
|
|
|
|
if (receiveStr.length()>8){ |
|
|
|
|
String str1=receiveStr.substring(0,8); |
|
|
|
|
String str2=receiveStr.substring(8); |
|
|
|
|
receiveStr=str1.replace("FE", "")+str2; |
|
|
|
|
}else{ |
|
|
|
|
receiveStr = receiveStr.replace("FE", ""); |
|
|
|
|
} |
|
|
|
|
log.info("channelReadComplete接收到的数据长度: ===> {}", receiveStr.length()); |
|
|
|
|
receiveStr = receiveStr.toUpperCase();//返回值全部变成大写
|
|
|
|
|
log.info("channelReadComplete接收到的数据{}, 长度: ===> {}", receiveStr, receiveStr.length()); |
|
|
|
|
//心跳包处理
|
|
|
|
|
if ((receiveStr.length() == 8) && receiveStr.startsWith("24")) { |
|
|
|
|
// if ((receiveStr.length() == 8) && receiveStr.startsWith("24")) {
|
|
|
|
|
if ((receiveStr.length() == 8) && receiveStr.startsWith("C0A801FE")) { |
|
|
|
|
log.info("接收到心跳包 ===> {}", receiveStr); |
|
|
|
|
idleCount = 1; |
|
|
|
|
port=receiveStr.substring(4,8);//心跳包包含网关端口(自己定义返回心跳包)
|
|
|
|
|
port = receiveStr.substring(4, 8);//心跳包包含网关端口(自己定义返回心跳包)
|
|
|
|
|
port = "6001"; |
|
|
|
|
// 清空receiveStr
|
|
|
|
|
receiveStr = ""; |
|
|
|
|
// 更新对应的网关在线情况
|
|
|
|
|
gatewayManageService.updateGatewayManage2(port); |
|
|
|
|
//根据端口或者IP或者心跳包查询网关对应的项目名称
|
|
|
|
|
String projectName=gatewayManageService.selectProjectName(port); |
|
|
|
|
String projectName = gatewayManageService.selectProjectName(port); |
|
|
|
|
log.info("---------------------{}项目网关上线---------------------", projectName); |
|
|
|
|
// 生成采集指令
|
|
|
|
|
deviceCodeParamList = deviceCodeParamService.queryCodeParam(port); //心跳包包含网关端口(自己定义返回心跳包)
|
|
|
|
@ -134,172 +130,111 @@ public class EchoServerHandler extends ChannelInboundHandlerAdapter {
|
|
|
|
|
log.info("deviceCodeParam size ===> {}", size); |
|
|
|
|
num = 0; |
|
|
|
|
// 发送采集报文
|
|
|
|
|
if (size>0) { |
|
|
|
|
if (idleCount<2){ |
|
|
|
|
if (size > 0) { |
|
|
|
|
if (idleCount < 2) { |
|
|
|
|
Thread.sleep(200); |
|
|
|
|
SendOrderUtils.sendAllOrder(deviceCodeParamList.get(num),ctx,num,size); |
|
|
|
|
SendOrderUtils.sendAllOrder(deviceCodeParamList.get(num), ctx, num, size); |
|
|
|
|
idleCount++; |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
ctx.channel().close(); |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
log.info("gateway not find deviceCodeParam!" ); |
|
|
|
|
} else { |
|
|
|
|
log.info("gateway not find deviceCodeParam!"); |
|
|
|
|
} |
|
|
|
|
} else if (receiveStr.length() == 36 || receiveStr.length() == 40 || receiveStr.length() == 44 || receiveStr.length() == 50) { |
|
|
|
|
} else if (receiveStr.length() == 34 || receiveStr.length() == 36 || receiveStr.length() == 40 || receiveStr.length() == 44 || receiveStr.length() == 50) { |
|
|
|
|
//电表返回数据解析
|
|
|
|
|
idleCount=1; |
|
|
|
|
idleCount = 1; |
|
|
|
|
log.info("电表接收===> {},长度:{}", receiveStr, receiveStr.length()); |
|
|
|
|
//解析采集的报文,并保存到数据库
|
|
|
|
|
AnalysisReceiveOrder485 analysisReceiveOrder485 = new AnalysisReceiveOrder485(); |
|
|
|
|
analysisReceiveOrder485.analysisMeterOrder485(receiveStr,deviceCodeParamList.get(num)); |
|
|
|
|
//清空receiveStr
|
|
|
|
|
receiveStr = ""; |
|
|
|
|
//判断发送的下标,如果不等于指令数组大小
|
|
|
|
|
num = num + 1; |
|
|
|
|
if (num > size - 1) { |
|
|
|
|
num = 0; |
|
|
|
|
Thread.sleep(200); |
|
|
|
|
// 继续发送下一个采集指令
|
|
|
|
|
SendOrderUtils.sendAllOrder(deviceCodeParamList.get(num),ctx,num,size); |
|
|
|
|
log.info("------一轮采集完成,继续下一轮--------"); |
|
|
|
|
} else { |
|
|
|
|
// 添加一个状态值,判断是否继续发送指令 update by ljf on 2020-08-07
|
|
|
|
|
if (Constant.WEB_FLAG) { |
|
|
|
|
num = 0; |
|
|
|
|
// 关闭连接
|
|
|
|
|
receiveStr = null; |
|
|
|
|
ctx.close(); |
|
|
|
|
} else { |
|
|
|
|
Thread.sleep(200); |
|
|
|
|
// 继续发送下一个采集指令
|
|
|
|
|
SendOrderUtils.sendAllOrder(deviceCodeParamList.get(num),ctx,num,size); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
nextSendOrder(ctx); |
|
|
|
|
} else if (receiveStr.length() == 18) { |
|
|
|
|
//冷量计返回数据解析
|
|
|
|
|
idleCount=1; |
|
|
|
|
idleCount = 1; |
|
|
|
|
log.info("冷量计接收==>{},长度:{}", receiveStr, receiveStr.length()); |
|
|
|
|
// 解析采集的报文,并保存到数据库
|
|
|
|
|
AnalysisReceiveOrder485 analysisReceiveOrder485 = new AnalysisReceiveOrder485(); |
|
|
|
|
analysisReceiveOrder485.analysisCloudOrder485(receiveStr,deviceCodeParamList.get(num) ); |
|
|
|
|
// 清空receiveStr
|
|
|
|
|
receiveStr = ""; |
|
|
|
|
// 判断发送的下标,如果不等于指令数组大小
|
|
|
|
|
num = num + 1; |
|
|
|
|
if (num > size - 1) { |
|
|
|
|
num = 0; |
|
|
|
|
Thread.sleep(200); |
|
|
|
|
// 继续发送下一个采集指令
|
|
|
|
|
SendOrderUtils.sendAllOrder(deviceCodeParamList.get(num),ctx,num,size); |
|
|
|
|
log.info("------一轮采集完成,继续下一轮--------"); |
|
|
|
|
} else { |
|
|
|
|
// 添加一个状态值,判断是否继续发送指令 update by ljf on 2020-08-07
|
|
|
|
|
if (Constant.WEB_FLAG) { |
|
|
|
|
num = 0; |
|
|
|
|
// 关闭连接
|
|
|
|
|
receiveStr = null; |
|
|
|
|
ctx.close(); |
|
|
|
|
} else { |
|
|
|
|
Thread.sleep(200); |
|
|
|
|
// 继续发送下一个采集指令
|
|
|
|
|
SendOrderUtils.sendAllOrder(deviceCodeParamList.get(num),ctx,num,size); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}else if (receiveStr.length() == 12 || receiveStr.length() == 14) { |
|
|
|
|
nextSendOrder(ctx); |
|
|
|
|
} else if (receiveStr.length() == 12 || receiveStr.length() == 14) { |
|
|
|
|
//冷水机返回数据解析
|
|
|
|
|
idleCount=1; |
|
|
|
|
idleCount = 1; |
|
|
|
|
log.info("冷水机接收===>{},长度:{}", receiveStr, receiveStr.length()); |
|
|
|
|
// 解析采集的报文,并保存到数据库
|
|
|
|
|
AnalysisReceiveOrder485 analysisReceiveOrder485 = new AnalysisReceiveOrder485(); |
|
|
|
|
analysisReceiveOrder485.analysisChillerOrder485(receiveStr,deviceCodeParamList.get(num)); |
|
|
|
|
// 清空receiveStr
|
|
|
|
|
receiveStr = ""; |
|
|
|
|
// 判断发送的下标,如果不等于指令数组大小
|
|
|
|
|
num = num + 1; |
|
|
|
|
if (num > size - 1) { |
|
|
|
|
num = 0; |
|
|
|
|
Thread.sleep(200); |
|
|
|
|
// 继续发送下一个采集指令
|
|
|
|
|
SendOrderUtils.sendAllOrder(deviceCodeParamList.get(num),ctx,num,size); |
|
|
|
|
log.info("------一轮采集完成,继续下一轮--------"); |
|
|
|
|
} else { |
|
|
|
|
// 添加一个状态值,判断是否继续发送指令 update by ljf on 2020-08-07
|
|
|
|
|
if (Constant.WEB_FLAG) { |
|
|
|
|
num = 0; |
|
|
|
|
// 关闭连接
|
|
|
|
|
receiveStr = null; |
|
|
|
|
ctx.close(); |
|
|
|
|
} else { |
|
|
|
|
Thread.sleep(200); |
|
|
|
|
// 继续发送下一个采集指令
|
|
|
|
|
SendOrderUtils.sendAllOrder(deviceCodeParamList.get(num),ctx,num,size); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
nextSendOrder(ctx); |
|
|
|
|
} else if (receiveStr.length() > 50 && receiveStr.length() < 100) { |
|
|
|
|
idleCount=1; |
|
|
|
|
idleCount = 1; |
|
|
|
|
// 清空receiveStr
|
|
|
|
|
receiveStr = null; |
|
|
|
|
// 判断发送的下标,如果不等于指令数组大小
|
|
|
|
|
num = num + 1; |
|
|
|
|
if (num > size - 1) { |
|
|
|
|
num = 0; |
|
|
|
|
Thread.sleep(200); |
|
|
|
|
// 继续发送下一个采集指令
|
|
|
|
|
SendOrderUtils.sendAllOrder(deviceCodeParamList.get(num),ctx,num,size); |
|
|
|
|
log.info("------一轮采集完成,继续下一轮--------"); |
|
|
|
|
} else { |
|
|
|
|
// 添加一个状态值,判断是否继续发送指令 update by ljf on 2020-08-07
|
|
|
|
|
if (Constant.WEB_FLAG) { |
|
|
|
|
num = 0; |
|
|
|
|
// 关闭连接
|
|
|
|
|
receiveStr = null; |
|
|
|
|
ctx.close(); |
|
|
|
|
} else { |
|
|
|
|
Thread.sleep(200); |
|
|
|
|
// 继续发送下一个采集指令
|
|
|
|
|
SendOrderUtils.sendAllOrder(deviceCodeParamList.get(num),ctx,num,size); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
nextSendOrder(ctx); |
|
|
|
|
} |
|
|
|
|
// else if (receiveStr.length() >= 100 ){
|
|
|
|
|
// whiteGateway(ctx);
|
|
|
|
|
// }
|
|
|
|
|
else { |
|
|
|
|
receiveStr = null; |
|
|
|
|
} |
|
|
|
|
// else {
|
|
|
|
|
// receiveStr = null;
|
|
|
|
|
// }
|
|
|
|
|
ctx.flush(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void nextSendOrder(ChannelHandlerContext ctx) throws InterruptedException { |
|
|
|
|
// 解析采集的报文,并保存到数据库
|
|
|
|
|
analysisReceiveData(receiveStr, deviceCodeParamList.get(num)); |
|
|
|
|
// 清空receiveStr
|
|
|
|
|
receiveStr = ""; |
|
|
|
|
// 判断发送的下标,如果不等于指令数组大小
|
|
|
|
|
num = num + 1; |
|
|
|
|
if (num > size - 1) { |
|
|
|
|
num = 0; |
|
|
|
|
Thread.sleep(200); |
|
|
|
|
// 继续发送下一个采集指令
|
|
|
|
|
SendOrderUtils.sendAllOrder(deviceCodeParamList.get(num), ctx, num, size); |
|
|
|
|
log.info("------一轮采集完成,继续下一轮--------"); |
|
|
|
|
} else { |
|
|
|
|
// 添加一个状态值,判断是否继续发送指令 update by ljf on 2020-08-07
|
|
|
|
|
if (Constant.WEB_FLAG) { |
|
|
|
|
num = 0; |
|
|
|
|
// 关闭连接
|
|
|
|
|
receiveStr = null; |
|
|
|
|
ctx.close(); |
|
|
|
|
} else { |
|
|
|
|
Thread.sleep(200); |
|
|
|
|
// 继续发送下一个采集指令
|
|
|
|
|
SendOrderUtils.sendAllOrder(deviceCodeParamList.get(num), ctx, num, size); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void analysisReceiveData(String receiveStr, DeviceCodeParamEntity deviceCodeParamEntity) { |
|
|
|
|
// 解析采集的报文,并保存到数据库
|
|
|
|
|
AnalysisReceiveOrder485 analysisReceiveOrder485 = new AnalysisReceiveOrder485(); |
|
|
|
|
analysisReceiveOrder485.analysisReceiveOrder485(receiveStr, deviceCodeParamEntity); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void whiteGateway(ChannelHandlerContext ctx) throws InterruptedException { |
|
|
|
|
if (receiveStr.substring(0,2).equalsIgnoreCase("2b") && receiveStr.substring(6,8).equalsIgnoreCase("7b")){ |
|
|
|
|
receiveStr=receiveStr.substring(6); |
|
|
|
|
if (receiveStr.substring(0, 2).equalsIgnoreCase("2b") && receiveStr.substring(6, 8).equalsIgnoreCase("7b")) { |
|
|
|
|
receiveStr = receiveStr.substring(6); |
|
|
|
|
} |
|
|
|
|
receiveStr=ExchangeStringUtil.hexStringToString(receiveStr) ; |
|
|
|
|
receiveStr = ExchangeStringUtil.hexStringToString(receiveStr); |
|
|
|
|
log.info("白色网关接收===> " + receiveStr); |
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(receiveStr); |
|
|
|
|
receiveStr=""; |
|
|
|
|
port=jsonObject.getString("snr"); //网关ID,从心跳包中获得
|
|
|
|
|
IP=jsonObject.getString("ip"); //ip
|
|
|
|
|
String cmd=jsonObject.getString("cmd"); //指令模式dHeartbeat(心跳包),data(主动采集返回),reword
|
|
|
|
|
String name=jsonObject.getString("name"); |
|
|
|
|
receiveStr = ""; |
|
|
|
|
port = jsonObject.getString("snr"); //网关ID,从心跳包中获得
|
|
|
|
|
IP = jsonObject.getString("ip"); //ip
|
|
|
|
|
String cmd = jsonObject.getString("cmd"); //指令模式dHeartbeat(心跳包),data(主动采集返回),reword
|
|
|
|
|
String name = jsonObject.getString("name"); |
|
|
|
|
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
Date date = new Date(); |
|
|
|
|
String time = sdf1.format(date); |
|
|
|
|
if(cmd.equals("dHeartbeat")){ |
|
|
|
|
JSONObject jsonHeart=new JSONObject(); |
|
|
|
|
jsonHeart.put("snr",port); |
|
|
|
|
jsonHeart.put("cmd","uHeartbeat"); |
|
|
|
|
jsonHeart.put("recordCheckTime","30"); |
|
|
|
|
jsonHeart.put("keepAliveTime","50"); //通讯保持在线间隔,秒80
|
|
|
|
|
jsonHeart.put("resetTime","23:59:59"); |
|
|
|
|
jsonHeart.put("ip",IP); |
|
|
|
|
jsonHeart.put("time",time); |
|
|
|
|
jsonHeart.put("name",name); |
|
|
|
|
jsonHeart.put("heartInterval","20");//网关发起心跳包的时间间隔,秒70
|
|
|
|
|
jsonHeart.put("recordMode","cover"); |
|
|
|
|
String sendStr=jsonHeart.toString(); |
|
|
|
|
if (cmd.equals("dHeartbeat")) { |
|
|
|
|
JSONObject jsonHeart = new JSONObject(); |
|
|
|
|
jsonHeart.put("snr", port); |
|
|
|
|
jsonHeart.put("cmd", "uHeartbeat"); |
|
|
|
|
jsonHeart.put("recordCheckTime", "30"); |
|
|
|
|
jsonHeart.put("keepAliveTime", "50"); //通讯保持在线间隔,秒80
|
|
|
|
|
jsonHeart.put("resetTime", "23:59:59"); |
|
|
|
|
jsonHeart.put("ip", IP); |
|
|
|
|
jsonHeart.put("time", time); |
|
|
|
|
jsonHeart.put("name", name); |
|
|
|
|
jsonHeart.put("heartInterval", "20");//网关发起心跳包的时间间隔,秒70
|
|
|
|
|
jsonHeart.put("recordMode", "cover"); |
|
|
|
|
String sendStr = jsonHeart.toString(); |
|
|
|
|
log.info("白色网关回复收到心跳包===>" + sendStr); |
|
|
|
|
sendStr=ExchangeStringUtil.strTo16(sendStr); |
|
|
|
|
sendStr = ExchangeStringUtil.strTo16(sendStr); |
|
|
|
|
ByteBuf buffer = ExchangeStringUtil.getByteBuf(ctx, sendStr); |
|
|
|
|
Thread.sleep(200); |
|
|
|
|
ctx.channel().writeAndFlush(buffer); //发送数据
|
|
|
|
@ -311,38 +246,38 @@ public class EchoServerHandler extends ChannelInboundHandlerAdapter {
|
|
|
|
|
log.info("白色网关接收长度===> " + size); |
|
|
|
|
num = 0; |
|
|
|
|
// 发送采集报文
|
|
|
|
|
if (size>0) { |
|
|
|
|
if (idleCount<2){ |
|
|
|
|
if (size > 0) { |
|
|
|
|
if (idleCount < 2) { |
|
|
|
|
Thread.sleep(200); |
|
|
|
|
SendOrderUtils.sendAllOrder2(deviceCodeParamList.get(num), ctx,port,IP,num,size); |
|
|
|
|
SendOrderUtils.sendAllOrder2(deviceCodeParamList.get(num), ctx, port, IP, num, size); |
|
|
|
|
idleCount++; |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
log.info("close this channel!"); |
|
|
|
|
ctx.channel().close(); |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
log.info("white gateway not find deviceCodeParam!" ); |
|
|
|
|
} else { |
|
|
|
|
log.info("white gateway not find deviceCodeParam!"); |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
idleCount=1; |
|
|
|
|
String data=jsonObject.getString("data"); |
|
|
|
|
String strHex=ExchangeStringUtil.base64ToHex(data); |
|
|
|
|
} else { |
|
|
|
|
idleCount = 1; |
|
|
|
|
String data = jsonObject.getString("data"); |
|
|
|
|
String strHex = ExchangeStringUtil.base64ToHex(data); |
|
|
|
|
//返回值全部变成大写
|
|
|
|
|
strHex= strHex.toUpperCase(); |
|
|
|
|
strHex = strHex.toUpperCase(); |
|
|
|
|
//截取去掉FE
|
|
|
|
|
String dataStr; |
|
|
|
|
if (strHex.length()>8){ |
|
|
|
|
String str1=strHex.substring(0,8); |
|
|
|
|
String str2=strHex.substring(8); |
|
|
|
|
dataStr=str1.replace("FE", "")+str2; |
|
|
|
|
}else{ |
|
|
|
|
if (strHex.length() > 8) { |
|
|
|
|
String str1 = strHex.substring(0, 8); |
|
|
|
|
String str2 = strHex.substring(8); |
|
|
|
|
dataStr = str1.replace("FE", "") + str2; |
|
|
|
|
} else { |
|
|
|
|
dataStr = strHex.replace("FE", ""); |
|
|
|
|
} |
|
|
|
|
if (dataStr.length() == 36 || dataStr.length() == 40 || dataStr.length() == 44 || dataStr.length() == 50){ |
|
|
|
|
if (dataStr.length() == 36 || dataStr.length() == 40 || dataStr.length() == 44 || dataStr.length() == 50) { |
|
|
|
|
log.info("白色网关电表接收===>" + dataStr); |
|
|
|
|
// 解析采集的报文,并保存到数据库
|
|
|
|
|
AnalysisReceiveOrder485 analysisReceiveOrder485 = new AnalysisReceiveOrder485(); |
|
|
|
|
analysisReceiveOrder485.analysisMeterOrder485(dataStr,deviceCodeParamList.get(num)); //电表报文解析
|
|
|
|
|
analysisReceiveOrder485.analysisMeterOrder485(dataStr, deviceCodeParamList.get(num)); //电表报文解析
|
|
|
|
|
// 清空dataStr
|
|
|
|
|
// 判断发送的下标,如果不等于指令数组大小
|
|
|
|
|
num = num + 1; |
|
|
|
@ -350,7 +285,7 @@ public class EchoServerHandler extends ChannelInboundHandlerAdapter {
|
|
|
|
|
num = 0; |
|
|
|
|
Thread.sleep(200); |
|
|
|
|
// 继续发送下一个采集指令
|
|
|
|
|
SendOrderUtils.sendAllOrder2(deviceCodeParamList.get(num), ctx,port,IP,num,size); |
|
|
|
|
SendOrderUtils.sendAllOrder2(deviceCodeParamList.get(num), ctx, port, IP, num, size); |
|
|
|
|
log.info("------一轮采集完成,继续下一轮--------"); |
|
|
|
|
} else { |
|
|
|
|
// 添加一个状态值,判断是否继续发送指令 update by ljf on 2020-08-07
|
|
|
|
@ -362,14 +297,14 @@ public class EchoServerHandler extends ChannelInboundHandlerAdapter {
|
|
|
|
|
} else { |
|
|
|
|
Thread.sleep(200); |
|
|
|
|
// 继续发送下一个采集指令
|
|
|
|
|
SendOrderUtils.sendAllOrder2(deviceCodeParamList.get(num), ctx,port,IP,num,size); |
|
|
|
|
SendOrderUtils.sendAllOrder2(deviceCodeParamList.get(num), ctx, port, IP, num, size); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}else if(dataStr.length() == 12 || dataStr.length() == 14){ |
|
|
|
|
} else if (dataStr.length() == 12 || dataStr.length() == 14) { |
|
|
|
|
log.info("白色网关冷水机接收===>" + dataStr); |
|
|
|
|
// 解析采集的报文,并保存到数据库
|
|
|
|
|
AnalysisReceiveOrder485 analysisReceiveOrder485 = new AnalysisReceiveOrder485(); |
|
|
|
|
analysisReceiveOrder485.analysisChillerOrder485(dataStr,deviceCodeParamList.get(0)); |
|
|
|
|
analysisReceiveOrder485.analysisChillerOrder485(dataStr, deviceCodeParamList.get(0)); |
|
|
|
|
// 清空dataStr
|
|
|
|
|
dataStr = ""; |
|
|
|
|
// 判断发送的下标,如果不等于指令数组大小
|
|
|
|
@ -378,7 +313,7 @@ public class EchoServerHandler extends ChannelInboundHandlerAdapter {
|
|
|
|
|
num = 0; |
|
|
|
|
Thread.sleep(200); |
|
|
|
|
// 继续发送下一个采集指令
|
|
|
|
|
SendOrderUtils.sendAllOrder2(deviceCodeParamList.get(num), ctx,port,IP,num,size); |
|
|
|
|
SendOrderUtils.sendAllOrder2(deviceCodeParamList.get(num), ctx, port, IP, num, size); |
|
|
|
|
log.info("------一轮采集完成,继续下一轮--------"); |
|
|
|
|
} else { |
|
|
|
|
// 添加一个状态值,判断是否继续发送指令 update by ljf on 2020-08-07
|
|
|
|
@ -391,15 +326,15 @@ public class EchoServerHandler extends ChannelInboundHandlerAdapter {
|
|
|
|
|
} else { |
|
|
|
|
Thread.sleep(200); |
|
|
|
|
// 继续发送下一个采集指令
|
|
|
|
|
SendOrderUtils.sendAllOrder2(deviceCodeParamList.get(num), ctx,port,IP,num,size); |
|
|
|
|
SendOrderUtils.sendAllOrder2(deviceCodeParamList.get(num), ctx, port, IP, num, size); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}else if(dataStr.length() == 18){ |
|
|
|
|
} else if (dataStr.length() == 18) { |
|
|
|
|
// log.info("white gateway cloud receive message ===> " + dataStr);
|
|
|
|
|
log.info("白色网关冷量计接收===> " + dataStr); |
|
|
|
|
// 解析采集的报文,并保存到数据库
|
|
|
|
|
AnalysisReceiveOrder485 analysisReceiveOrder485 = new AnalysisReceiveOrder485(); //冷量机报文解析
|
|
|
|
|
analysisReceiveOrder485.analysisCloudOrder485(dataStr,deviceCodeParamList.get(num) ); |
|
|
|
|
analysisReceiveOrder485.analysisCloudOrder485(dataStr, deviceCodeParamList.get(num)); |
|
|
|
|
// 清空dataStr
|
|
|
|
|
dataStr = ""; |
|
|
|
|
// 判断发送的下标,如果不等于指令数组大小
|
|
|
|
@ -408,7 +343,7 @@ public class EchoServerHandler extends ChannelInboundHandlerAdapter {
|
|
|
|
|
num = 0; |
|
|
|
|
Thread.sleep(200); |
|
|
|
|
// 继续发送下一个采集指令
|
|
|
|
|
SendOrderUtils.sendAllOrder2(deviceCodeParamList.get(num), ctx,port,IP,num,size); |
|
|
|
|
SendOrderUtils.sendAllOrder2(deviceCodeParamList.get(num), ctx, port, IP, num, size); |
|
|
|
|
log.info("------一轮采集完成,继续下一轮--------"); |
|
|
|
|
} else { |
|
|
|
|
// 添加一个状态值,判断是否继续发送指令 update by ljf on 2020-08-07
|
|
|
|
@ -421,10 +356,10 @@ public class EchoServerHandler extends ChannelInboundHandlerAdapter {
|
|
|
|
|
} else { |
|
|
|
|
Thread.sleep(200); |
|
|
|
|
// 继续发送下一个采集指令
|
|
|
|
|
SendOrderUtils.sendAllOrder2(deviceCodeParamList.get(num), ctx,port,IP,num,size); |
|
|
|
|
SendOrderUtils.sendAllOrder2(deviceCodeParamList.get(num), ctx, port, IP, num, size); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}else { //if(dataStr.length() > 50)
|
|
|
|
|
} else { //if(dataStr.length() > 50)
|
|
|
|
|
// 清空dataStr
|
|
|
|
|
dataStr = null; |
|
|
|
|
// 判断发送的下标,如果不等于指令数组大小
|
|
|
|
@ -433,7 +368,7 @@ public class EchoServerHandler extends ChannelInboundHandlerAdapter {
|
|
|
|
|
num = 0; |
|
|
|
|
Thread.sleep(200); |
|
|
|
|
// 继续发送下一个采集指令
|
|
|
|
|
SendOrderUtils.sendAllOrder2(deviceCodeParamList.get(num), ctx,port,IP,num,size); |
|
|
|
|
SendOrderUtils.sendAllOrder2(deviceCodeParamList.get(num), ctx, port, IP, num, size); |
|
|
|
|
log.info("------一轮采集完成,继续下一轮--------"); |
|
|
|
|
} else { |
|
|
|
|
// 添加一个状态值,判断是否继续发送指令 update by ljf on 2020-08-07
|
|
|
|
@ -445,7 +380,7 @@ public class EchoServerHandler extends ChannelInboundHandlerAdapter {
|
|
|
|
|
} else { |
|
|
|
|
Thread.sleep(200); |
|
|
|
|
// 继续发送下一个采集指令
|
|
|
|
|
SendOrderUtils.sendAllOrder2(deviceCodeParamList.get(num), ctx,port,IP,num,size); |
|
|
|
|
SendOrderUtils.sendAllOrder2(deviceCodeParamList.get(num), ctx, port, IP, num, size); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|