|
|
|
|
@ -59,16 +59,16 @@ public class AnalysisReceiveOrder485 {
|
|
|
|
|
try { |
|
|
|
|
if (registerAddr.equals("32") || registerAddr.equals("33") || registerAddr.equals("35") || registerAddr.equals("36")) { |
|
|
|
|
data = decimalFormat.format(Math.abs(ExchangeStringUtil.hexToSingle(data)));//十六进制字符串转IEEE754浮点型
|
|
|
|
|
log.info("冷量计==>{},寄存器地址==>{},读数==>{}", cloudId, registerAddr, data); |
|
|
|
|
// log.info("冷量计==>{},寄存器地址==>{},读数==>{}", cloudId, registerAddr, data);
|
|
|
|
|
} else if (registerAddr.equals("31") || registerAddr.equals("34")) { |
|
|
|
|
long lData = Long.parseLong(ExchangeStringUtil.hexToDec(data)); |
|
|
|
|
log.info("冷量计==>{},寄存器地址==>{},累计读数==>{}", cloudId, registerAddr, lData); |
|
|
|
|
// log.info("冷量计==>{},寄存器地址==>{},累计读数==>{}", cloudId, registerAddr, lData);
|
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("保存冷量计数据失败!", e); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
log.info("冷量计校验失败===>{}", dataStr); |
|
|
|
|
// log.info("冷量计校验失败===>{}", dataStr);
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -113,7 +113,7 @@ public class AnalysisReceiveOrder485 {
|
|
|
|
|
try { |
|
|
|
|
if (dataType == 3) { |
|
|
|
|
data = decimalFormat.format(Math.abs(ExchangeStringUtil.hexToSingle(data)));//十六进制字符串转IEEE754浮点型
|
|
|
|
|
log.info("水表==>{},寄存器地址==>{},读数==>{}", cloudId, deviceCodeParam.getRegisterAddr(), data); |
|
|
|
|
// log.info("水表==>{},寄存器地址==>{},读数==>{}", cloudId, deviceCodeParam.getRegisterAddr(), data);
|
|
|
|
|
} else if (dataType == 2) { |
|
|
|
|
data = dataStr.substring(dataStr.length() - 12, dataStr.length() - 10) |
|
|
|
|
+ dataStr.substring(dataStr.length() - 10, dataStr.length() - 8) |
|
|
|
|
@ -123,7 +123,7 @@ public class AnalysisReceiveOrder485 {
|
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(data); |
|
|
|
|
bigDecimal = bigDecimal.divide(new BigDecimal((int) Math.pow(10, deviceCodeParam.getDigits()))).setScale(2, RoundingMode.HALF_UP); // 除以1000并保留整数
|
|
|
|
|
data = bigDecimal.toString(); |
|
|
|
|
log.info("水表==>{},寄存器地址==>{},累计读数==>{}", cloudId, deviceCodeParam.getRegisterAddr(), data); |
|
|
|
|
// log.info("水表==>{},寄存器地址==>{},累计读数==>{}", cloudId, deviceCodeParam.getRegisterAddr(), data);
|
|
|
|
|
} |
|
|
|
|
// 判断data大于99999999,就返回空
|
|
|
|
|
if (new BigDecimal(data).intValue() > 99999999) { |
|
|
|
|
@ -134,7 +134,7 @@ public class AnalysisReceiveOrder485 {
|
|
|
|
|
log.error("保存水表数据失败!", e); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
log.info("水表===>{}", dataStr); |
|
|
|
|
// log.info("水表===>{}", dataStr);
|
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
return ""; |
|
|
|
|
@ -165,7 +165,7 @@ public class AnalysisReceiveOrder485 {
|
|
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("0.00"); |
|
|
|
|
// 表号
|
|
|
|
|
String cloudId = ExchangeStringUtil.hexToDec(dataStr.substring(0, 2)); |
|
|
|
|
// 读数
|
|
|
|
|
// 读数 02 04 04 00 04 4D 1F FD DD
|
|
|
|
|
String data = ""; |
|
|
|
|
data = dataStr.substring(dataStr.length() - 8, dataStr.length() - 6) |
|
|
|
|
+ dataStr.substring(dataStr.length() - 6, dataStr.length() - 4) |
|
|
|
|
@ -183,10 +183,20 @@ public class AnalysisReceiveOrder485 {
|
|
|
|
|
try { |
|
|
|
|
if (dataType == 3) { |
|
|
|
|
data = decimalFormat.format(Math.abs(ExchangeStringUtil.hexToSingle(data)));//十六进制字符串转IEEE754浮点型
|
|
|
|
|
log.info("电表==>{},寄存器地址==>{},读数==>{}", cloudId, deviceCodeParam.getRegisterAddr(), data); |
|
|
|
|
// log.info("电表==>{},寄存器地址==>{},读数==>{}", cloudId, deviceCodeParam.getRegisterAddr(), data);
|
|
|
|
|
} else if (dataType == 2) { |
|
|
|
|
data = ExchangeStringUtil.hexToDec(data); |
|
|
|
|
log.info("电表==>{},寄存器地址==>{},累计读数==>{}", cloudId, deviceCodeParam.getRegisterAddr(), data); |
|
|
|
|
// log.info("电表==>{},寄存器地址==>{},累计读数==>{}", cloudId, deviceCodeParam.getRegisterAddr(), data);
|
|
|
|
|
} else if (dataType == 4) { |
|
|
|
|
data = dataStr.substring(dataStr.length() - 12, dataStr.length() - 10) |
|
|
|
|
+ dataStr.substring(dataStr.length() - 10, dataStr.length() - 8) |
|
|
|
|
+ dataStr.substring(dataStr.length() - 8, dataStr.length() - 6) |
|
|
|
|
+ dataStr.substring(dataStr.length() - 6, dataStr.length() - 4); |
|
|
|
|
data = ExchangeStringUtil.hexToDec(data); |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(data); |
|
|
|
|
bigDecimal = bigDecimal.divide(new BigDecimal((int) Math.pow(10, deviceCodeParam.getDigits()))).setScale(2, RoundingMode.HALF_UP); // 除以1000并保留整数
|
|
|
|
|
data = bigDecimal.toString(); |
|
|
|
|
// log.info("电表==>{},寄存器地址==>{},累计读数==>{}", cloudId, deviceCodeParam.getRegisterAddr(), data);
|
|
|
|
|
} |
|
|
|
|
// 判断data大于99999999,就返回空
|
|
|
|
|
if (new BigDecimal(data).intValue() > 99999999) { |
|
|
|
|
@ -197,7 +207,7 @@ public class AnalysisReceiveOrder485 {
|
|
|
|
|
log.error("保存电表数据失败!", e); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
log.info("电表===>{}", dataStr); |
|
|
|
|
// log.info("电表===>{}", dataStr);
|
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
return ""; |
|
|
|
|
@ -270,13 +280,13 @@ public class AnalysisReceiveOrder485 {
|
|
|
|
|
)) { |
|
|
|
|
data = ExchangeStringUtil.hexToDec(data); |
|
|
|
|
} |
|
|
|
|
log.info("热泵==>{},寄存器地址==>{},读数==>{}", cloudId, deviceCodeParam.getRegisterAddr(), data); |
|
|
|
|
// log.info("热泵==>{},寄存器地址==>{},读数==>{}", cloudId, deviceCodeParam.getRegisterAddr(), data);
|
|
|
|
|
return data; |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("保存热泵数据失败!", e); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
log.info("热泵===>{}", dataStr); |
|
|
|
|
// log.info("热泵===>{}", dataStr);
|
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
return ""; |
|
|
|
|
@ -317,7 +327,7 @@ public class AnalysisReceiveOrder485 {
|
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(data); |
|
|
|
|
bigDecimal = bigDecimal.divide(new BigDecimal((int) Math.pow(10, deviceCodeParam.getDigits()))).setScale(3, RoundingMode.HALF_UP); // 除以1000并保留整数
|
|
|
|
|
data = bigDecimal.toString(); |
|
|
|
|
log.info("液位==>{},寄存器地址==>{},实时读数==>{}", cloudId, deviceCodeParam.getRegisterAddr(), data); |
|
|
|
|
// log.info("液位==>{},寄存器地址==>{},实时读数==>{}", cloudId, deviceCodeParam.getRegisterAddr(), data);
|
|
|
|
|
} |
|
|
|
|
// 判断data大于99999999,就返回空
|
|
|
|
|
if (new BigDecimal(data).intValue() > 100) { |
|
|
|
|
@ -328,7 +338,7 @@ public class AnalysisReceiveOrder485 {
|
|
|
|
|
log.error("保存液位数据失败!", e); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
log.info("液位===>{}", dataStr); |
|
|
|
|
// log.info("液位===>{}", dataStr);
|
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
return ""; |
|
|
|
|
|