lxw
2023-02-10 f978d4ecdf83cbf7c8b778f1362b86be5aa510bd
充放电数据解析和内阻数据解析
3个文件已修改
12个文件已添加
874 ■■■■■ 已修改文件
src/main/java/com/whyc/controller/TestController.java 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mcp/BattParam.java 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mcp/DateTime.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mcp/FBSData.java 71 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mcp/MVolData.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mcp/MonitorDataInfo.java 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mcp/SYSMonitorParam.java 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mcp/SYSMonitorState.java 77 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mcp/TestDataInfo.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mcp/TestTime.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mcp/VolCurrData.java 72 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/res/RESDataInfo.java 90 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/RESDataInfoService.java 76 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/TestDataInfoService.java 75 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/util/StaticInf.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/TestController.java
@@ -4,9 +4,13 @@
import com.whyc.fbo.FboDataHeadStart;
import com.whyc.fbo.FboDataHeadStop;
import com.whyc.fbo.FboDataInf;
import com.whyc.mcp.TestDataInfo;
import com.whyc.pojo.Response;
import com.whyc.res.RESDataInfo;
import com.whyc.service.ExcelExportService;
import com.whyc.service.FboDataInfService;
import com.whyc.service.RESDataInfoService;
import com.whyc.service.TestDataInfoService;
import com.whyc.util.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -37,6 +41,12 @@
    @Autowired
    private ExcelExportService exportService;
    @Autowired
    private RESDataInfoService resService;
    @Autowired
    private TestDataInfoService testDataInfoService;
    @GetMapping("/hello")
    public Response hello(){
        return new Response().set(1,"hello");
@@ -48,17 +58,23 @@
        String suffix=filePath.substring(filePath.lastIndexOf(".")+1).toLowerCase(Locale.ROOT);
        Response response=new Response();
        switch (suffix){
            case "fbx":FboDataInf fboDataInf = fboService.readFboFile(filePath);
            case "fbx":
                       FboDataInf fboDataInf = fboService.readFboFile(filePath);
                       response.set(1,fboDataInf,filePath);
                       break;
            case "bres":response.set(1,filePath);
            case "bres":
                       RESDataInfo resDataInfo =resService.readFileData(filePath);
                       response.set(1,resDataInfo,filePath);
                       break;
            case "alm":response.set(1,filePath);
                       break;
            case "mcp":response.set(1,filePath);
            case "mcp":
                       TestDataInfo testDataInfoMcp=testDataInfoService.readFileData(filePath);
                       response.set(1,testDataInfoMcp,filePath);
                       break;
            case "mch":response.set(1,filePath);
                      break;
            case "mch":TestDataInfo testDataInfoMch=testDataInfoService.readFileData(filePath);
                       response.set(1,testDataInfoMch,filePath);
                       break;
            default:response.set(1,false,filePath);
        }
src/main/java/com/whyc/mcp/BattParam.java
New file
@@ -0,0 +1,83 @@
package com.whyc.mcp;
import com.whyc.util.ComBase;
import java.nio.ByteBuffer;
public class BattParam {
    public static final int BYTE_LEN = 44;
    public int STD_CAP;                    //标称容量 分辨率 1AH
    public float STD_RES;                //标称内阻 分辨率0.001mΩ
    public int battGroupCount;            //组数
    public int eachGroupBattCount;        //每组单体个数
    public float monomerVol;            //单体标称电压 分辨率0.1V
    public float groupVol;                //未使用
    public float battTemp;                ////未使用
    public float floatChargeVol;        //未使用
    public float floatChargeCurr;        //未使用
    public float onlineVolLow;            //未使用
    public int groupConnType;            //未使用
    public int bakeup1;
    public int bakeup2;
    public int bakeup3;
    public int bakeup4;
    public int bakeup5;
    public int bakeup6;
    public int bakeup7;
    public int bakeup8;
    public int bakeup9;
    public int bakeup10;
    public int CRC;                        //未使用
    public boolean putByteBuffer(ByteBuffer bf) {
        if(bf.remaining() < BYTE_LEN) {
            return false;
        }
        bf.position(0);
        STD_CAP = ComBase.changeShortToInt(bf.getShort());                    //标称容量 分辨率 1AH
        STD_RES = ComBase.changeShortToFloat(bf.getShort()) * 0.001f;        //标称内阻 分辨率0.001mΩ
        battGroupCount = ComBase.changeShortToInt(bf.getShort());            //组数
        eachGroupBattCount = ComBase.changeShortToInt(bf.getShort());        //每组单体个数
        monomerVol = ComBase.changeShortToFloat(bf.getShort())*0.1f;        //单体标称电压 分辨率0.1V
        groupVol = ComBase.changeShortToFloat(bf.getShort());                //未使用
        battTemp = ComBase.changeShortToFloat(bf.getShort());                ////未使用
        floatChargeVol = ComBase.changeShortToFloat(bf.getShort());            //未使用
        floatChargeCurr = ComBase.changeShortToFloat(bf.getShort());        //未使用
        onlineVolLow = ComBase.changeShortToFloat(bf.getShort());            //未使用
        groupConnType = ComBase.changeShortToInt(bf.getShort());            //未使用
        bakeup1 = ComBase.changeShortToInt(bf.getShort());
        bakeup2 = ComBase.changeShortToInt(bf.getShort());
        bakeup3 = ComBase.changeShortToInt(bf.getShort());
        bakeup4 = ComBase.changeShortToInt(bf.getShort());
        bakeup5 = ComBase.changeShortToInt(bf.getShort());
        bakeup6 = ComBase.changeShortToInt(bf.getShort());
        bakeup7 = ComBase.changeShortToInt(bf.getShort());
        bakeup8 = ComBase.changeShortToInt(bf.getShort());
        bakeup9 = ComBase.changeShortToInt(bf.getShort());
        bakeup10 = ComBase.changeShortToInt(bf.getShort());
        CRC = ComBase.changeShortToInt(bf.getShort());
        //System.out.println(this);
        //System.out.println("bf.limit()"+bf.limit());
        bf.compact();
        //System.out.println("bf.limit()"+bf.limit());
        return true;
    }
    @Override
    public String toString() {
        return "BattParam [STD_CAP=" + STD_CAP + ", STD_RES=" + STD_RES + ", battGroupCount=" + battGroupCount
                + ", eachGroupBattCount=" + eachGroupBattCount + ", monomerVol=" + monomerVol + ", groupVol="
                + groupVol + ", battTemp=" + battTemp + ", floatChargeVol=" + floatChargeVol + ", floatChargeCurr="
                + floatChargeCurr + ", onlineVolLow=" + onlineVolLow + ", groupConnType=" + groupConnType
                + ", bakeup1=" + bakeup1 + ", bakeup2=" + bakeup2 + ", bakeup3=" + bakeup3 + ", bakeup4=" + bakeup4
                + ", bakeup5=" + bakeup5 + ", bakeup6=" + bakeup6 + ", bakeup7=" + bakeup7 + ", bakeup8=" + bakeup8
                + ", bakeup9=" + bakeup9 + ", bakeup10=" + bakeup10 + ", CRC=" + CRC + "]";
    }
}
src/main/java/com/whyc/mcp/DateTime.java
New file
@@ -0,0 +1,42 @@
package com.whyc.mcp;
import com.whyc.util.ComBase;
import java.nio.ByteBuffer;
import java.util.Calendar;
import java.util.Date;
public class DateTime {
    private static final int BYTE_LEN = 6;
    public int year;
    public int month;
    public int day;
    public int hour;
    public int minute;
    public int second;
    public Date time;
    public DateTime() {
    }
    public void setDateTime(ByteBuffer bf) {
        if(bf.remaining()< BYTE_LEN) {
            return;
        }
        this.year = ComBase.changeByteToInt(bf.get());
        this.month = ComBase.changeByteToInt(bf.get());
        this.day = ComBase.changeByteToInt(bf.get());
        this.hour = ComBase.changeByteToInt(bf.get());
        this.minute = ComBase.changeByteToInt(bf.get());
        this.second = ComBase.changeByteToInt(bf.get());
        time = getFBODateTime();
    }
    public Date getFBODateTime() {
        Calendar c = Calendar.getInstance();
        c.set(2000+year, month, day, hour, minute, second);
        return c.getTime();
    }
}
src/main/java/com/whyc/mcp/FBSData.java
New file
@@ -0,0 +1,71 @@
package com.whyc.mcp;
import com.whyc.res.RES_Crc16;
import com.whyc.util.ComBase;
import lombok.Data;
import lombok.ToString;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@ToString
@Data
public class FBSData {
    public static final int BYTE_LEN = 5 + TestTime.BYTE_LEN+VolCurrData.BYTE_LEN + MVolData.BYTE_LEN;
    public int dataType[] = new int[4];        //数据类型 见表1
    public int CRC16;
    public TestTime testTime;                //已测试时间(HMS)
    public int battGroup;                    //组数
    public int battSum;                        //单体个数
    public VolCurrData vcData;
    public MVolData mVol;
    public FBSData(int dataType) {
        testTime = new TestTime();
        vcData = new VolCurrData();
        for(int i=0;i<this.dataType.length;i++) {
            this.dataType[i] = dataType;
        }
    }
    public boolean setData(byte[] databuf) {
        boolean flag = true;
        //System.out.println(databuf.length + "===" + BYTE_LEN);
        //System.out.println(ComFn.bytesToHexString(databuf, databuf.length));
        ByteBuffer bf = ByteBuffer.allocate(databuf.length + dataType.length);
        bf.order(ByteOrder.LITTLE_ENDIAN);
        bf.position(0);
        if(databuf.length < (BYTE_LEN-MVolData.BYTE_LEN)) {
            return flag;
        }
        for(int i = 0;i<dataType.length;i++) {
            bf.put(ComBase.changeIntToByte(this.dataType[i]));
        }
        bf.put(databuf);
        //System.out.println(ComFn.bytesToHexString(bf.array(), bf.array().length));
        bf.flip();
        CRC16 = ComBase.changeShortToInt(bf.getShort(4));
        bf.putShort(4, ComBase.changeIntToShort(0));
        int crc1 = RES_Crc16.CalCRC16(bf, bf.limit());
        if(CRC16 != crc1) {
            System.err.println(CRC16 +"!="+ crc1);
            return false;
        }
        bf.position(6);
        testTime.setTestTime(bf);                            //已测试时间(HMS)
        battGroup = ComBase.changeByteToInt(bf.get());        //组数
        battSum = ComBase.changeShortToInt(bf.getShort());    //单体个数
        mVol = new MVolData(battGroup*battSum);
        bf.compact();
        flag &= vcData.puByteBuffer(bf);
        flag &= mVol.puByteBuffer(bf);
        return flag;
    }
}
src/main/java/com/whyc/mcp/MVolData.java
New file
@@ -0,0 +1,32 @@
package com.whyc.mcp;
import com.whyc.util.ComBase;
import java.nio.ByteBuffer;
import java.util.Arrays;
public class MVolData {
    public static final int BYTE_LEN = 1000;
    public static final int MONOMER_COUNT_MAX = 500;
    public float vol[];//单体电压 偏移20000 分辨率0.001V
    public MVolData(int count) {
        vol = new float[count];
    }
    public boolean puByteBuffer(ByteBuffer bf) {
        bf.position(0);
        if (bf.remaining() < vol.length * 2) {
            return false;
        }
        for (int i = 0; i < vol.length; i++) {
            //System.out.println(ComBase.changeShortToFloat(bf.getShort()));
            vol[i] = ComBase.changeShortToFloat(bf.getShort()) * 0.001f;//单体电压 偏移20000 分辨率0.001V
        }
        bf.compact();
        //System.out.println(this);
        return true;
    }
    public String toString() {
        return "MVolData [vol=" + Arrays.toString(vol) + "]";
    }
}
src/main/java/com/whyc/mcp/MonitorDataInfo.java
New file
@@ -0,0 +1,80 @@
package com.whyc.mcp;
import com.whyc.util.StaticInf;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public class MonitorDataInfo {
    public static final int BYTE_LEN = BattParam.BYTE_LEN + SYSMonitorParam.BYTE_LEN + SYSMonitorState.BYTE_LEN;
    public BattParam battparam;                                //电池参数
    public SYSMonitorParam monitorparam;                    //未使用
    public SYSMonitorState monitorstate;
    public MonitorDataInfo() {
        battparam = new BattParam();
        monitorparam = new SYSMonitorParam();
        monitorstate = new SYSMonitorState();
    }
    public boolean checkDataHead(FileInputStream fis)
    {
        boolean check_ok = false;
        boolean file_end = false;
        byte[] tag = new byte[1];
        try {
            while(true)
            {
                int n = 0;
                for(n=0; n<4; n++)
                {
                    if(1 != fis.read(tag, 0, 1))
                    {
                        file_end = true;
                        break;
                    }
                    if((0xFA != (tag[0]&0xFF)) && (0xFB != (tag[0]&0xFF)))
                    {
                        break;
                    }
                }
                if(n >= 4)
                {
                    check_ok = true;
                    break;
                }
                if(true == file_end)
                {
                    break;
                }
            }
        } catch (IOException e) {
            //e.printStackTrace();
        }
        return check_ok;
    }
    public boolean setHeadData(byte[] buf) {
        boolean flag = false;
        if(buf.length < BYTE_LEN) {
            return flag;
        }
        ByteBuffer bf = ByteBuffer.allocate(buf.length);
        bf.order(ByteOrder.LITTLE_ENDIAN);
        bf.position(0);
        bf.put(buf);
        bf.flip();
        flag = battparam.putByteBuffer(bf);
        bf.position(0);
        flag &= monitorparam.putByteBuffer(bf);
        bf.position(0);
        flag &= monitorstate.putByteBuffer(bf);
        return flag;
    }
}
src/main/java/com/whyc/mcp/SYSMonitorParam.java
New file
@@ -0,0 +1,83 @@
package com.whyc.mcp;
import com.whyc.util.ComBase;
import java.nio.ByteBuffer;
public class SYSMonitorParam {
    public static final int BYTE_LEN = 46;
    public int monitorEN;
    public float disCurr;
    public float disCap;
    public int disTime;
    public float groupVol_LOW;
    public float monomerVol_LOW;
    public int monomerLowCount;
    public int battGroupCount;
    public int onlineVolLowAction;
    public float chrCurr;
    public float chrCap;
    public int chrTime;
    public int bakeup1;
    public int bakeup2;
    public int bakeup3;
    public int bakeup4;
    public int bakeup5;
    public int bakeup6;
    public int bakeup7;
    public int bakeup8;
    public int bakeup9;
    public int bakeup10;
    public int CRC;
    public boolean putByteBuffer(ByteBuffer bf) {
        if(bf.remaining() < BYTE_LEN) {
            return false;
        }
        bf.position(0);
        monitorEN = ComBase.changeShortToInt(bf.getShort());
        disCurr = ComBase.changeShortToFloat(bf.getShort());
        disCap = ComBase.changeShortToFloat(bf.getShort());
        disTime = ComBase.changeShortToInt(bf.getShort());
        groupVol_LOW = ComBase.changeShortToFloat(bf.getShort());
        monomerVol_LOW = ComBase.changeShortToFloat(bf.getShort());
        monomerLowCount = ComBase.changeShortToInt(bf.getShort());
        battGroupCount = ComBase.changeShortToInt(bf.getShort());
        onlineVolLowAction = ComBase.changeShortToInt(bf.getShort());
        chrCurr = ComBase.changeShortToFloat(bf.getShort());
        chrCap = ComBase.changeShortToInt(bf.getShort());
        chrTime = ComBase.changeShortToInt(bf.getShort());
        bakeup1 = ComBase.changeShortToInt(bf.getShort());
        bakeup2 = ComBase.changeShortToInt(bf.getShort());
        bakeup3 = ComBase.changeShortToInt(bf.getShort());
        bakeup4 = ComBase.changeShortToInt(bf.getShort());
        bakeup5 = ComBase.changeShortToInt(bf.getShort());
        bakeup6 = ComBase.changeShortToInt(bf.getShort());
        bakeup7 = ComBase.changeShortToInt(bf.getShort());
        bakeup8 = ComBase.changeShortToInt(bf.getShort());
        bakeup9 = ComBase.changeShortToInt(bf.getShort());
        bakeup10 = ComBase.changeShortToInt(bf.getShort());
        CRC = ComBase.changeShortToInt(bf.getShort());
        //System.out.println(this);
        bf.compact();
        return true;
    }
    @Override
    public String toString() {
        return "SYSMonitorParam [monitorEN=" + monitorEN + ", disCurr=" + disCurr + ", disCap=" + disCap
                + ", disTime=" + disTime + ", groupVol_LOW=" + groupVol_LOW + ", monomerVol_LOW=" + monomerVol_LOW
                + ", monomerLowCount=" + monomerLowCount + ", battGroupCount=" + battGroupCount
                + ", onlineVolLowAction=" + onlineVolLowAction + ", chrCurr=" + chrCurr + ", chrCap=" + chrCap
                + ", chrTime=" + chrTime + ", bakeup1=" + bakeup1 + ", bakeup2=" + bakeup2 + ", bakeup3=" + bakeup3
                + ", bakeup4=" + bakeup4 + ", bakeup5=" + bakeup5 + ", bakeup6=" + bakeup6 + ", bakeup7=" + bakeup7
                + ", bakeup8=" + bakeup8 + ", bakeup9=" + bakeup9 + ", bakeup10=" + bakeup10 + ", CRC=" + CRC + "]";
    }
}
src/main/java/com/whyc/mcp/SYSMonitorState.java
New file
@@ -0,0 +1,77 @@
package com.whyc.mcp;
import com.whyc.util.ComBase;
import java.nio.ByteBuffer;
import java.util.Arrays;
public class SYSMonitorState {
    public static final int BYTE_LEN = 46;
    public DateTime startDT;                        //启动放电的日期时间
    public DateTime stopDT;                            //终止放电的日期时间
    public TestTime     test_Time;                        //已测试时间(HMS)
    public int testState;                              //监测状态(MONITOR_STATE_)    //0:停止监测 1:放电监测 2:充电监测
    public int testType;                            //测试类型 0xFA:放电  0xFB:充电
    public int testGroupCount;                      //unused
    public int saveDataEN;                          //保存数据标识
    public int backUp;                              //reserved
    public int restTest_Time[] = new int[4];           //剩余容量可放电时间(HMS)
    public double testCap[] = new double[4];        //每组已测试容量 单位AH 显示一位小数
    public double groupCap[] = new double[4];        //每组实际容量 单位AH 显示一位小数
    public double groupRestCap[] = new double[4];    //每组剩余容量 单位AH 显示一位小数
    public int CRC;                                    //未使用
    public SYSMonitorState() {
        startDT = new DateTime();                        //启动放电的日期时间
        stopDT = new DateTime();                            //终止放电的日期时间
        test_Time = new TestTime();                        //已测试时间(HMS)
    }
    public boolean putByteBuffer(ByteBuffer bf) {
        //System.err.println("bf.remaining():"+bf.remaining());
        if(bf.remaining() < BYTE_LEN) {
            return false;
        }
        bf.position(0);
        startDT.setDateTime(bf);                            //启动放电的日期时间
        stopDT.setDateTime(bf);                                //终止放电的日期时间
        test_Time.setTestTime(bf);                            //已测试时间(HMS)
        testState = ComBase.changeByteToInt(bf.get());         //监测状态(MONITOR_STATE_)    //0:停止监测 1:放电监测 2:充电监测
        testType = ComBase.changeByteToInt(bf.get());       //测试类型 0xFA:放电  0xFB:充电
        testGroupCount = ComBase.changeByteToInt(bf.get()); //unused
        saveDataEN = ComBase.changeByteToInt(bf.get());        //保存数据标识
        backUp = ComBase.changeByteToInt(bf.get());                              //reserved
        for(int i=0;i<restTest_Time.length;i++) {
            restTest_Time[i] = bf.getInt();                    //剩余容量可放电时间(HMS)
        }
        for(int i=0;i<testCap.length;i++) {
            testCap[i] = bf.getDouble();                    //每组已测试容量 单位AH 显示一位小数
        }
        for(int i=0;i<groupCap.length;i++) {
            groupCap[i] = bf.getDouble();                    //每组实际容量 单位AH 显示一位小数
        }
        for(int i=0;i<groupRestCap.length;i++) {
            groupRestCap[i] = bf.getDouble();                //每组剩余容量 单位AH 显示一位小数
        }
        CRC = ComBase.changeShortToInt(bf.getShort());
        //System.out.println(this);
        return true;
    }
    @Override
    public String toString() {
        return "SYSMonitorState [startDT=" + startDT + ", stopDT=" + stopDT + ", test_Time=" + test_Time
                + ", testState=" + testState + ", testType=" + testType + ", testGroupCount=" + testGroupCount
                + ", saveDataEN=" + saveDataEN + ", backUp=" + backUp + ", restTest_Time="
                + Arrays.toString(restTest_Time) + ", testCap=" + Arrays.toString(testCap) + ", groupCap="
                + Arrays.toString(groupCap) + ", groupRestCap=" + Arrays.toString(groupRestCap) + ", CRC=" + CRC
                + "]";
    }
}
src/main/java/com/whyc/mcp/TestDataInfo.java
New file
@@ -0,0 +1,30 @@
package com.whyc.mcp;
import java.util.ArrayList;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
 *     FBS充放电数据解析
 * @author LiJun
 *
 */
@Data
@AllArgsConstructor
public class TestDataInfo {
    public int parse_result;            //文件解析结果
    public int file_type ;                //文件类型
    public MonitorDataInfo monitorDataInfo;
    public List<FBSData> FBSDatas;
    public TestDataInfo() {
        monitorDataInfo = new MonitorDataInfo();
        FBSDatas = new ArrayList<FBSData>();
    }
}
src/main/java/com/whyc/mcp/TestTime.java
New file
@@ -0,0 +1,22 @@
package com.whyc.mcp;
import com.whyc.util.ComBase;
import java.nio.ByteBuffer;
public class TestTime {
    public static final int BYTE_LEN = 3;
    public int hour;            //时
    public int minute;            //分
    public int second;            //秒
    public void setTestTime(ByteBuffer bf) {
        if(bf.limit() < BYTE_LEN) {
            return;
        }
        this.hour = ComBase.changeByteToInt(bf.get());
        this.minute = ComBase.changeByteToInt(bf.get());
        this.second = ComBase.changeByteToInt(bf.get());
    }
}
src/main/java/com/whyc/mcp/VolCurrData.java
New file
@@ -0,0 +1,72 @@
package com.whyc.mcp;
import com.whyc.util.ComBase;
import java.nio.ByteBuffer;
import java.util.Arrays;
public class VolCurrData {
    public static final int BYTE_LEN = 80;
    public static final int GROUP_COUNT_MAX = 4;
    public float onlinevol[]  = new float[GROUP_COUNT_MAX];//在线电压    分辨率0.1V
    public float groupvol[]   = new float[GROUP_COUNT_MAX];//组端电压 分辨率0.1V
    public int battstate[]    = new int[GROUP_COUNT_MAX];//电池状态,见表2
    public float  battcurr[]  = new float[GROUP_COUNT_MAX];//电流 分辨率0.1A
    public int battcap[]      = new int[GROUP_COUNT_MAX];//已测容量 AH
    public float  batttemp[]  = new float[GROUP_COUNT_MAX];//温度,预留,没使用
    public int monMAX_num[]   = new int[GROUP_COUNT_MAX];//最高单体索引号
    public int monMIN_num[]   = new int[GROUP_COUNT_MAX];//最低单体索引号
    public float  monvolMAX[] = new float[GROUP_COUNT_MAX];//最高单体电压 0.001V
    public float  monvolMIN[] = new float[GROUP_COUNT_MAX];//最低单体电压 0.001V
    public boolean puByteBuffer(ByteBuffer bf) {
        //System.err.println(ComFn.bytesToHexString(bf.array(), bf.array().length));
        bf.position(0);
        if(bf.remaining() < BYTE_LEN) {
            return false;
        }
        for(int i=0;i<onlinevol.length;i++) {
            onlinevol[i]  = ComBase.changeShortToFloat(bf.getShort())*0.1f;    //在线电压    分辨率0.1V
        }
        for(int i=0;i<groupvol.length;i++) {
            groupvol[i]   = ComBase.changeShortToFloat(bf.getShort())*0.1f;    //组端电压 分辨率0.1V
        }
        for(int i =0;i<battstate.length;i++) {
            battstate[i] = ComBase.changeShortToInt(bf.getShort());            //电池状态,见表2
        }
        for(int i = 0;i<battcurr.length;i++) {
            battcurr[i]  = ComBase.changeShortToFloat(bf.getShort())*0.1f;    //电流 分辨率0.1A
        }
        for(int i=0;i<battcap.length;i++) {
            battcap[i] = ComBase.changeShortToInt(bf.getShort());            //已测容量 AH
        }
        for(int i=0;i<batttemp.length;i++) {
            batttemp[i]  = ComBase.changeShortToFloat(bf.getShort());        //温度,预留,没使用
        }
        for(int i=0;i<monMAX_num.length;i++) {
            monMAX_num[i]   = ComBase.changeShortToInt(bf.getShort());        //最高单体索引号
        }
        for(int i=0;i<monMIN_num.length;i++) {
            monMIN_num[i]   = ComBase.changeShortToInt(bf.getShort());//最低单体索引号
        }
        for(int i=0;i<monvolMAX.length;i++) {
            monvolMAX[i] = ComBase.changeShortToFloat(bf.getShort())*0.001f;//最高单体电压 0.001V
        }
        for(int i=0;i<monvolMIN.length;i++) {
            monvolMIN[i] = ComBase.changeShortToFloat(bf.getShort())*0.001f;//最低单体电压 0.001V
        }
        bf.compact();
        //System.out.println(this);
        return true;
    }
    @Override
    public String toString() {
        return "VolCurrData [onlinevol=" + Arrays.toString(onlinevol) + ", groupvol=" + Arrays.toString(groupvol)
                + ", battstate=" + Arrays.toString(battstate) + ", battcurr=" + Arrays.toString(battcurr)
                + ", battcap=" + Arrays.toString(battcap) + ", batttemp=" + Arrays.toString(batttemp)
                + ", monMAX_num=" + Arrays.toString(monMAX_num) + ", monMIN_num=" + Arrays.toString(monMIN_num)
                + ", monvolMAX=" + Arrays.toString(monvolMAX) + ", monvolMIN=" + Arrays.toString(monvolMIN) + "]";
    }
}
src/main/java/com/whyc/res/RESDataInfo.java
@@ -1,5 +1,9 @@
package com.whyc.res;
import com.whyc.util.StaticInf;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -8,91 +12,27 @@
//FBS9600 内阻数据集
@Data
@AllArgsConstructor
public class RESDataInfo {
    
    public RESDataHead resDataHead;            //内阻数据头
    public List<RESData> resDatas;            //内阻数据集
    public int parse_result = PARSE_RESULT_NULL;
    public static final int PARSE_RESULT_NULL = 0;            //未知
    public static final int PARSE_RESULT_SUCCESS = 1;        //解析成功
    public static final int PARSE_RESULT_NOTFOUNDFILE = 2;    //文件未找到
    public static final int PARSE_RESULT_FILETYPEERR = 3;    //文件格式错误
    public static final int PARSE_RESULT_FILEERROR = 4;        //文件异常
    public RESDataHead resDataHead;                    //内阻数据头
    public List<RESData> resDatas;                    //内阻数据集
    public  int parse_result;
    public int file_type = StaticInf.FILE_TYPE_RES;        //文件类型
    
    public RESDataInfo() {
        resDataHead = new RESDataHead();            //内阻数据头
        resDatas = new ArrayList<>();            //内阻数据集
        resDatas = new ArrayList<>();                //内阻数据集
    }
    
    public void readResFile(String filePath)
    {
        FileInputStream fis = null;
        try {
            File f = new File(filePath);
            if(!filePath.endsWith(".BRES") && !filePath.endsWith(".bres")) {
                System.out.println("文件格式错误");
                parse_result = PARSE_RESULT_FILETYPEERR;
                return;
            }
            if(!f.exists()) {
                parse_result = PARSE_RESULT_NOTFOUNDFILE;
                System.out.println("文件不存在..........");
                return;
            }
            fis = new FileInputStream(f);
            byte[] buf = new byte[4];
            if(fis.read(buf, 0, buf.length) == RESDataHead.BYTE_LEN)
            {
                if(this.resDataHead.setHeadData(buf)) {
                    parse_result = PARSE_RESULT_SUCCESS;
                }else {
                    parse_result = PARSE_RESULT_FILEERROR;
                }
                while(true)
                {
                    if(resDataHead.checkDataHead(fis))
                    {
                        byte[] databuf = new byte[RESData.DATABYTE_LEN];
                        if(fis.read(databuf) == databuf.length)
                        {
                            RESData resData = new RESData();
                            if(resData.setData(databuf)) {
                                //System.out.println(resData);
                                resDatas.add(resData);
                            }
                        }
                    }
                    if(fis.available() <1) {
                        //System.out.println("解析完成");
                        break;
                    }
                }
            }else {
                parse_result = PARSE_RESULT_FILEERROR;
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if(null != fis)
            {
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    
    
    public static void main(String[] args) {
        RESDataInfo info = new RESDataInfo();
        info.readResFile("D:\\桌面文件备份\\公司各种设备资料\\FBS存储文件解析/resdata.bres");
        //info.readFileData("D:\\桌面文件备份\\公司各种设备资料\\FBS存储文件解析/resdata.bres");
    }
}
src/main/java/com/whyc/service/RESDataInfoService.java
New file
@@ -0,0 +1,76 @@
package com.whyc.service;
import com.whyc.res.RESData;
import com.whyc.res.RESDataHead;
import com.whyc.res.RESDataInfo;
import com.whyc.util.StaticInf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@Service
public class RESDataInfoService {
    //解析res内阻数据
    public RESDataInfo readFileData(String filePath)
    {
        RESDataInfo resDataInfo=new RESDataInfo();
        int parse_result = StaticInf.PARSE_RESULT_NULL;
        FileInputStream fis = null;
        try {
            File f = new File(filePath);
            if(!filePath.endsWith(".BRES") && !filePath.endsWith(".bres")) {
                parse_result = StaticInf.PARSE_RESULT_FILETYPEERR;
            }
            if(!f.exists()) {
                parse_result = StaticInf.PARSE_RESULT_NOTFOUNDFILE;
            }
            fis = new FileInputStream(f);
            byte[] buf = new byte[4];
            if(fis.read(buf, 0, buf.length) == RESDataHead.BYTE_LEN)
            {
                if(resDataInfo.resDataHead.setHeadData(buf)) {
                    parse_result = StaticInf.PARSE_RESULT_SUCCESS;
                }else {
                    parse_result = StaticInf.PARSE_RESULT_FILEERROR;
                }
                while(true)
                {
                    if(resDataInfo.resDataHead.checkDataHead(fis))
                    {
                        byte[] databuf = new byte[RESData.DATABYTE_LEN];
                        if(fis.read(databuf) == databuf.length)
                        {
                            RESData resData = new RESData();
                            if(resData.setData(databuf)) {
                                resDataInfo.resDatas.add(resData);
                            }
                        }
                    }
                    if(fis.available() <1) {
                        break;
                    }
                }
            }else {
                parse_result = StaticInf.PARSE_RESULT_FILEERROR;
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if(null != fis)
            {
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        resDataInfo.setParse_result(parse_result);
        return resDataInfo;
    }
}
src/main/java/com/whyc/service/TestDataInfoService.java
New file
@@ -0,0 +1,75 @@
package com.whyc.service;
import com.whyc.mcp.*;
import com.whyc.util.StaticInf;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@Service
public class TestDataInfoService {
    //mch/mcp解析
    public TestDataInfo readFileData(String filePath) {
        TestDataInfo testDataInfo=new TestDataInfo();
        int parse_result = StaticInf.PARSE_RESULT_NULL;;
        FileInputStream fis = null;
        try {
            File f = new File(filePath);
            if((!filePath.endsWith(".MCP") && !filePath.endsWith(".mcp")) && (!filePath.endsWith(".MCH") && !filePath.endsWith(".mch"))) {
                parse_result = StaticInf.PARSE_RESULT_FILETYPEERR;
            }
            if(!f.exists()) {
                parse_result =StaticInf. PARSE_RESULT_NOTFOUNDFILE;
            }
            fis = new FileInputStream(f);
            byte[] buf = new byte[MonitorDataInfo.BYTE_LEN];
            if(fis.read(buf, 0, buf.length) == MonitorDataInfo.BYTE_LEN)
            {
                if(testDataInfo.monitorDataInfo.setHeadData(buf)) {
                    parse_result = StaticInf.PARSE_RESULT_SUCCESS;
                }else {
                    parse_result = StaticInf.PARSE_RESULT_FILEERROR;
                }
                while(true)
                {
                    if(testDataInfo.monitorDataInfo.checkDataHead(fis))
                    {
                        int bufLength=FBSData.BYTE_LEN - MVolData.BYTE_LEN +(testDataInfo.monitorDataInfo.battparam.eachGroupBattCount*testDataInfo.monitorDataInfo.battparam.battGroupCount)*2;
                        byte[] databuf = new byte[bufLength];
                        if(fis.read(databuf) == databuf.length)
                        {
                            FBSData fbsData = new FBSData(testDataInfo.monitorDataInfo.monitorstate.testType);
                            if(fbsData.setData(databuf)) {
                                testDataInfo.FBSDatas.add(fbsData);
                            }
                        }
                    }
                    if(fis.available() <1) {
                        break;
                    }
                }
            }else {
                parse_result = StaticInf.PARSE_RESULT_FILEERROR;
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if(null != fis)
            {
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        testDataInfo.setFile_type(testDataInfo.monitorDataInfo.monitorstate.testType);
        testDataInfo.setParse_result(parse_result);
        return testDataInfo;
    }
}
src/main/java/com/whyc/util/StaticInf.java
@@ -4,4 +4,19 @@
    public static final int DataType_Dis     = 0xFD;            //放电
    public static final int DataType_Char     = 0xFC;            //充电
    public static final int DataType_Peac     = 0xFB;            //常规
    public static final int PARSE_RESULT_NULL = 0;            //未知
    public static final int PARSE_RESULT_SUCCESS = 1;        //解析成功
    public static final int PARSE_RESULT_NOTFOUNDFILE = 2;    //文件未找到
    public static final int PARSE_RESULT_FILETYPEERR = 3;    //文件格式错误
    public static final int PARSE_RESULT_FILEERROR = 4;        //文件异常
    public static final int FILE_TYPE_NULL     = 0;            //未知
    public static final int FILE_TYPE_FBO     = 1;            //FBO文件数据
    public static final int FILE_TYPE_RES     = 2;            //内阻数据
    public static final int FILE_TYPE_ALM     = 3;            //告警数据
    public static final int FILE_TYPE_MCP     = 4;            //放电监测数据
    public static final int FILE_TYPE_MCH     = 5;            //充电监测数据
}