From 4cf57b750ba4e43e6b354fb5b2eabe5fb0b951d6 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期三, 30 三月 2022 10:42:03 +0800
Subject: [PATCH] 充电桩
---
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/frame/inner/report/A5LightHeartbeatReportInnerFrame.java | 128 ++++++++++++++++++++++++++++++------------
1 files changed, 90 insertions(+), 38 deletions(-)
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/frame/inner/report/A5LightHeartbeatReportInnerFrame.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/frame/inner/report/A5LightHeartbeatReportInnerFrame.java
index 9b28ccd..477780a 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/frame/inner/report/A5LightHeartbeatReportInnerFrame.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/frame/inner/report/A5LightHeartbeatReportInnerFrame.java
@@ -1,5 +1,7 @@
package com.sandu.ximon.admin.manager.iot.frame.inner.report;
+import cn.hutool.core.util.HexUtil;
+import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.sandu.ximon.admin.manager.iot.frame.inner.BaseResponseInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.IResponseInnerFrame;
@@ -54,41 +56,43 @@
@Data
public static class HeartBeatDataPackage implements IResponseInnerFrame<HeartBeatDataPackage> {
// 骞碦TC 1
- private String year;
+ private Integer year;
// 鏈圧TC 1
- private String month;
+ private Integer month;
// 鏃TC 1
- private String day;
+ private Integer day;
// 鏃禦TC 1
- private String hour;
+ private Integer hour;
// 鍒哛TC 1
- private String min;
+ private Integer min;
// 绉扲TC 1
- private String sec;
+ private Integer sec;
// 璁惧娓╁害 2 1瀛楄妭鏁存暟1瀛楄妭灏忔暟
- private String deviceTemperature;
- // 浜害鐧惧垎姣� 1
- private String lightPercent;
+ private Double deviceTemperature;
+ // 鐏�1浜害鐧惧垎姣� 1
+ private Integer lightPercent;
// 鐢电綉鐢靛帇 2 1瀛楄妭鏁存暟1瀛楄妭灏忔暟
- private String gridVol;
+ private Double voltage;
// 鐢电綉鐢垫祦 2 1瀛楄妭鏁存暟1瀛楄妭灏忔暟
- private String gridCur;
+ private Double electricCurrent;
// 璧吂 2 1瀛楄妭鏁存暟1瀛楄妭灏忔暟
- private String hertz;
+ private Double hertz;
// 鍔熺巼鍥犵礌 2 1瀛楄妭鏁存暟1瀛楄妭灏忔暟
- private String powerFactor;
+ private Double powerFactor;
// 鏈夊姛鍔熺巼 2 1瀛楄妭鏁存暟1瀛楄妭灏忔暟
- private String activePower;
+ private Double activePower;
// 鏃犲姛鍔熺巼 2 1瀛楄妭鏁存暟1瀛楄妭灏忔暟
- private String reactivePower;
+ private Double reactivePower;
// 鏈�杩戜竴娆′寒鐏椂闂� 4 绉�
- private String recentlyLightSec;
+ private Long recentlyLightSec;
// 绱浜伅鏃堕棿 4
- private String totalLightTime;
+ private Long totalLightSec;
// 鏈�杩戜竴娆$敤鐢电數閲� 4
- private String recentlyUsingPower;
+ private Double recentlyUsingPower;
// 绱鐢ㄧ數鐢甸噺 4
- private String totalUsingPower;
+ private Double totalUsingPower;
+ // 鐏�2浜害鐧惧垎姣� 1
+ private Integer light2Percent;
// 淇濈暀 11
private String retain;
// 鍘熷抚
@@ -97,27 +101,75 @@
@Override
public HeartBeatDataPackage transformFrame(String hex) {
this.originFrame = hex;
- this.year = hex.substring(0, 2);
- this.month = hex.substring(2, 4);
- this.day = hex.substring(4, 6);
- this.hour = hex.substring(6, 8);
- this.min = hex.substring(8, 10);
- this.sec = hex.substring(10, 12);
+ this.year = HexUtil.hexToInt(hex.substring(0, 2));
+ this.month = HexUtil.hexToInt(hex.substring(2, 4));
+ this.day = HexUtil.hexToInt(hex.substring(4, 6));
+ this.hour = HexUtil.hexToInt(hex.substring(6, 8));
+ this.min = HexUtil.hexToInt(hex.substring(8, 10));
+ this.sec = HexUtil.hexToInt(hex.substring(10, 12));
- this.deviceTemperature = hex.substring(12, 16);
- this.lightPercent = hex.substring(16, 18);
- this.gridVol = hex.substring(18, 22);
- this.gridCur = hex.substring(22, 26);
- this.hertz = hex.substring(26, 30);
- this.powerFactor = hex.substring(30, 34);
- this.activePower = hex.substring(34, 38);
- this.reactivePower = hex.substring(38, 42);
- this.recentlyLightSec = hex.substring(42, 50);
- this.totalLightTime = hex.substring(50, 58);
- this.recentlyUsingPower = hex.substring(58, 66);
- this.totalUsingPower = hex.substring(66, 74);
- this.retain = hex.substring(74, 96);
+// //闇�瑕佹妸鍗佸叚杩涘埗杞簩杩涘埗
+// this.deviceTemperature = NumberUtil.round(HexUtil.hexToInt(hex.substring(12, 16)) * 0.01, 2).doubleValue();
+ this.deviceTemperature = NumberUtil.round(temperatureTransition(hex.substring(12, 16)), 2).doubleValue();
+ this.lightPercent = HexUtil.hexToInt(hex.substring(16, 18));
+ this.voltage = NumberUtil.round(HexUtil.hexToInt(hex.substring(18, 22)) * 0.1, 1).doubleValue();
+ this.electricCurrent = NumberUtil.round(HexUtil.hexToInt(hex.substring(22, 26)) * 0.001, 3).doubleValue();
+ this.hertz = NumberUtil.round(HexUtil.hexToInt(hex.substring(26, 30)) * 0.01, 2).doubleValue();
+ this.powerFactor = NumberUtil.round(HexUtil.hexToInt(hex.substring(30, 34)) * 0.001, 3).doubleValue();
+ this.activePower = NumberUtil.round(HexUtil.hexToInt(hex.substring(34, 38)) * 0.01, 2).doubleValue();
+ this.reactivePower = NumberUtil.round(HexUtil.hexToInt(hex.substring(38, 42)) * 0.01, 2).doubleValue();
+ this.recentlyLightSec = HexUtil.hexToLong(hex.substring(42, 50));
+ this.totalLightSec = HexUtil.hexToLong(hex.substring(50, 58));
+ this.recentlyUsingPower = NumberUtil.round(HexUtil.hexToInt(hex.substring(58, 66)) * (double) 0.001, 3).doubleValue();
+ this.totalUsingPower = NumberUtil.round(HexUtil.hexToInt(hex.substring(66, 74)) * (double) 0.001, 3).doubleValue();
+ this.light2Percent = HexUtil.hexToInt(hex.substring(74, 76));
+ this.retain = hex.substring(76, 96);
return this;
}
+
+ /**
+ * 灏�16杩涘埗杞垚2杩涘埗锛岃繘琛岃ˉ鐮侊紙鍙嶇爜鍩虹涓�+1锛夛紝寰楀埌姝g‘鏁板��
+ * 浼犲叆16杩涘埗鐨勬俯搴︼紝绫诲瀷涓篠tring
+ * 濡侳500
+ */
+ public static Double temperatureTransition(String temperature) {
+
+ //灏嗕紶杩涙潵鐨�16杩涘埗鐨勮浆涓�2杩涘埗
+ String twoBinStr = hexStr2BinStr(temperature);
+
+ if ("1".equals(twoBinStr.substring(0, 1))) {
+ //鏈�楂樹綅鏄�1锛屼负璐熸暟,灏�16杩涘埗鐨勮繘琛岃ˉ鐮侊紝杩斿洖
+ int max = 0b1111111111111111;
+ double result = (max-HexUtil.hexToInt(temperature))*(-0.01);
+ return result;
+
+ } else if ("0".equals(twoBinStr.substring(0, 1))) {
+ //鏈�楂樹綅鏄�0锛屾鏁帮紝鐩存帴杩斿洖
+ double result = (HexUtil.hexToInt(temperature))*(0.01);
+ return result;
+
+ }
+ //
+ return 0.00;
+ }
+ /**
+ * 16杩涘埗瀛楃涓茶浆涓轰簩杩涘埗
+ * */
+ public static String hexStr2BinStr(String hexStr)
+ {
+ if (hexStr == null || hexStr.length() % 2 != 0)
+ {
+ return null;
+ }
+ String bString = "", tmp;
+ for (int i = 0; i < hexStr.length(); i++)
+ {
+ tmp = "0000" + Integer.toBinaryString(Integer.parseInt(hexStr.substring(i, i + 1), 16));
+ bString += tmp.substring(tmp.length() - 4);
+ }
+ return bString;
+ }
+
}
+
}
--
Gitblit v1.9.3