|
@@ -1,22 +1,16 @@
|
|
|
package com.tokheim.aifueling.communication;
|
|
|
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
-import com.google.gson.Gson;
|
|
|
+import com.tokheim.aifueling.communication.entitys.DecimalAnalysisAid;
|
|
|
import com.tokheim.aifueling.communication.entitys.BaseInfo;
|
|
|
import com.tokheim.aifueling.communication.entitys.NozzleDTO;
|
|
|
-import com.tokheim.aifueling.communication.toInternalInterface.InterfaceApi;
|
|
|
import com.tokheim.aifueling.communication.toInternalInterface.InterfaceUtils;
|
|
|
-import com.tokheim.aifueling.communication.toInternalInterface.entity.FuelResponse;
|
|
|
-import com.tokheim.aifueling.communication.toMachine.MachineWriter;
|
|
|
-import com.tokheim.aifueling.domain.Nozzle;
|
|
|
import com.tokheim.aifueling.repository.NozzleRepository;
|
|
|
import com.tokheim.aifueling.utils.BeanUtils;
|
|
|
import com.tokheim.aifueling.utils.ByteArrayUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
import java.util.List;
|
|
|
-import java.util.Optional;
|
|
|
|
|
|
@Slf4j
|
|
|
public abstract class BaseAnalyzer {
|
|
@@ -33,6 +27,23 @@ public abstract class BaseAnalyzer {
|
|
|
InterfaceUtils.sendDataToInternal(dataType,allInfo);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 解析小数
|
|
|
+ * @param currentIndex 当前下标
|
|
|
+ * @param data 数据
|
|
|
+ * @return 解析后的小数及下标应该移动到哪个位置
|
|
|
+ */
|
|
|
+ protected DecimalAnalysisAid getDecimal(int currentIndex, byte[] data){
|
|
|
+ DecimalAnalysisAid decimalAnalysisAid = new DecimalAnalysisAid();
|
|
|
+ int decimalLen = data[currentIndex+1];
|
|
|
+ int decimalIntLen = data[currentIndex+2] / 2;
|
|
|
+ String decimalIntPart = Convert.toHex(ByteArrayUtils.slipt(data,currentIndex+3,currentIndex+3+decimalIntLen));
|
|
|
+ String decimalDecimalsPart = Convert.toHex(ByteArrayUtils.slipt(data,currentIndex+3+decimalIntLen,currentIndex+2+decimalLen));
|
|
|
+ String decimal = decimalIntPart + "." + decimalDecimalsPart;
|
|
|
+ decimalAnalysisAid.setNextIndex(currentIndex + 2 + decimalLen);
|
|
|
+ decimalAnalysisAid.setDecimal(decimal);
|
|
|
+ return decimalAnalysisAid;
|
|
|
+ }
|
|
|
|
|
|
* 获取基础信息
|
|
|
* @param ip 油机 ip
|