| | |
| | | import com.ld.igds.protocol.beibo.grainv1.util.BeiboGrainServerUtils; |
| | | import com.ld.igds.util.BytesUtil; |
| | | import com.ld.igds.util.ContextUtil; |
| | | import com.ld.igds.util.NumberUtil; |
| | | import com.ld.igds.warn.WarnUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | |
| | | } |
| | | |
| | | //封装数据 |
| | | ReMessage reMessage = ReMessageBuilder.getInstance().buildMessage(hexStr); |
| | | ReMessage reMessage = ReMessageBuilder.getInstance().buildMessage(result); |
| | | reMessage.setIp(ip); |
| | | reMessage.setPort(port); |
| | | log.info("分机------->>平台:粮情完整报文信息={}", reMessage); |
| | | |
| | | result = ""; |
| | | if (!BeiboGrainServerUtils.MSG_START.startsWith(reMessage.getStartStr())) { |
| | | log.error("分机------->>平台,解析粮情失败:报文起始符={}错误,不解析", reMessage.getStartStr()); |
| | | return; |
| | |
| | | } |
| | | |
| | | // 一分几多仓情况,考虑单仓采集和多仓采集 |
| | | // 单仓采集时候数据从0返回 |
| | | if (StringUtils.isEmpty(exeRequest.getDepotIds())) { |
| | | |
| | | depotConf.setCableEnd(depotConf.getCableEnd() - depotConf.getCableStart() + 1); |
| | | depotConf.setCableStart(ser.getCableStart()); |
| | | |
| | | if (DepotType.TYPE_02.getCode().equals(depotConf.getDepotType())) { |
| | | analysisStep2(depotConf, ser, exeRequest, reMessage, sysConf); |
| | | } else if (DepotType.TYPE_04.getCode().equals(depotConf.getDepotType())) { |
| | | analysisStep2(depotConf, ser, exeRequest, reMessage, sysConf); |
| | | } else { |
| | | analysisStep1(depotConf, ser, exeRequest, reMessage, sysConf); |
| | | } |
| | | |
| | | return; |
| | | |
| | | } |
| | | |
| | | // 批量采集所有关联一起采集,遍历执行 |
| | | for (DepotConf depotConfTemp : depotConfs) { |
| | |
| | | int curRoot = 1;//所在根 |
| | | int curCir = 1;//所在圈 |
| | | int cirLay = 1;//当前圈的层 |
| | | int symbol = 0; //符号位 |
| | | for (int i = 0; i < strPoints.length() / 4; i++) { |
| | | temp = strPoints.substring(i * 4, i * 4 + 4); |
| | | if (temp == null) { |
| | | temp = "0000"; |
| | | } |
| | | tempValue = BytesUtil.hexToInt(BytesUtil.tran_LH(temp)) / 10.0; |
| | | //高低位转换后转为16位二进制字符串 |
| | | temp = BytesUtil.toBinary8StringSame(BytesUtil.hexToInt(BytesUtil.tran_LH(temp)), 16); |
| | | //符号位 |
| | | symbol = Integer.valueOf(temp.substring(0, 1)); |
| | | //获取温度值 |
| | | tempValue = BytesUtil.hexToInt(BytesUtil.binToHex(temp.substring(6))) * 0.0625; |
| | | if(symbol == 1){ |
| | | tempValue = (1- BytesUtil.hexToInt(BytesUtil.binToHex(temp.substring(6))))*0.0625; |
| | | } |
| | | tempValue = NumberUtil.keepPrecision(tempValue, 1); |
| | | |
| | | //非正常值 |
| | | if (tempValue > ERROR_CHECK_TAG2) { |
| | |
| | | List<Double> temps = new ArrayList<>(); |
| | | double tempValue; |
| | | String temp; |
| | | int symbol = 0; |
| | | for (int i = 0; i < strPoints.length() / 4; i++) { |
| | | temp = strPoints.substring(i * 4, i * 4 + 4); |
| | | if (temp == null) { |
| | | temp = "0000"; |
| | | } |
| | | tempValue = BytesUtil.hexToInt(BytesUtil.tran_LH(temp)) / 10.0; |
| | | |
| | | //高低位转换后转为16位二进制字符串 |
| | | temp = BytesUtil.toBinary8StringSame(BytesUtil.hexToInt(BytesUtil.tran_LH(temp)), 16); |
| | | //符号位 |
| | | symbol = Integer.valueOf(temp.substring(0, 1)); |
| | | //获取温度值 |
| | | tempValue = BytesUtil.hexToInt(BytesUtil.binToHex(temp.substring(6))) * 0.0625; |
| | | if(symbol == 1){ |
| | | tempValue = (1- BytesUtil.hexToInt(BytesUtil.binToHex(temp.substring(6))))*0.0625; |
| | | } |
| | | tempValue = NumberUtil.keepPrecision(tempValue, 1); |
| | | // 说明解析的数据有问题 |
| | | if (tempValue == ERROR_CHECK_TAG || tempValue == ERROR_CHECK_TAG2) { |
| | | tempValue = Constant.ERROR_TEMP; |