测试 用electron + springboot 构建桌面应用
whyczh
2022-03-17 c7b38e7a35021d16bec63fc920ccefbc3727e088
添加readFboFile接口
1个文件已修改
5个文件已添加
774 ■■■■■ 已修改文件
src/main/java/testElectronJ/ComBase.java 178 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/testElectronJ/FboData.java 208 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/testElectronJ/FboDataHeadStart.java 224 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/testElectronJ/FboDataHeadStop.java 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/testElectronJ/FboDataInf.java 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/testElectronJ/TestController.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/testElectronJ/ComBase.java
New file
@@ -0,0 +1,178 @@
package testElectronJ;
public class ComBase
{
    public static final byte CapType_Rest = 0;
    public static final byte CapType_Real = 1;
    //------------------------------------------------------------------------------
    //------------------------------------------------------------------------------
    public static byte changeIntToByte(int data)
    {
        return (byte)(data & 0xFF);
    }
    //------------------------------------------------------------------------------
    public static short changeIntToShort(int data)
    {
        return (short)(data & 0xFFFF);
    }
    //------------------------------------------------------------------------------
    public static byte changeShortToByte(short data)
    {
        return (byte)(data & 0xFF);
    }
    //------------------------------------------------------------------------------
    public static int changeByteToInt(byte data)
    {
        int tmp = data;
        return (tmp & 0xFF);
    }
    //------------------------------------------------------------------------------
    public static int changeShortToInt(short data)
    {
        int tmp = data;
        return (tmp & 0xFFFF);
    }
    //------------------------------------------------------------------------------
    public static double changeShortToDouble(short data)
    {
        int tmp = data & 0xFFFF;
        return (double)(tmp);
    }
    public static float changeShortToFloat(short data)
    {
        int tmp = data & 0xFFFF;
        return (float)(tmp);
    }
    //------------------------------------------------------------------------------
    public static short changeDoubleToShort(double data)
    {
        int tmp = (int)data;
        return (short)(tmp & 0xFFFF);
    }
    //------------------------------------------------------------------------------
    //------------------------------------------------------------------------------
    public static double GetFDCurrent(double stdcap, int hourrate)
    {
        double res = 0.055;
        switch(hourrate)
        {
            case 1: res = 0.514; break;
            case 2: res = 0.306; break;
            case 3: res = 0.250; break;
            case 4: res = 0.200; break;
            case 5: res = 0.166; break;
            case 6: res = 0.146; break;
            case 7: res = 0.131; break;
            case 8: res = 0.118; break;
            case 9: res = 0.108; break;
            case 10: res = 0.100; break;
            case 20: res = 0.055; break;
            default: res = 0.055; break;
        }
        return (stdcap * res);
    }
    //------------------------------------------------------------------------------
    //------------------------------------------------------------------------------
    public static int GetHourRate(double stdah, double current)
    {
        int index = 0;
        double value[]={5.14, 3.06, 2.50, 2.00, 1.66, 1.46, 1.31, 1.18, 1.08, 1.00, 0.55};
        double res;
        if(stdah < 1)
            stdah = 1;
        res = current/(stdah/10);
        if(res >= 5.14) return 1;
        else if(res <= 0.55) return 20;
        else
        {
            for(index=0; index<10; index++)
            {
                if((res<=value[index]) && (res>value[index+1]))    break;
                else continue;
            }
            if((value[index]-res) < (res-value[index+1]))
            {
                return (index+1);
            }
            else
            {
                if(index+2 > 10) return (20);
                else return (index+2);
            }
        }
    }
    //------------------------------------------------------------------------------
    //------------------------------------------------------------------------------
    public static double N_TO_10H(int n_H)
    {
        switch(n_H)
        {
            case  1 : return(1/0.55);
            case  2 : return(1/0.61);
            case  3 : return(1/0.75);
            case  4 : return(1/0.79);
            case  5 : return(1/0.833);
            case  6 : return(1/0.876);
            case  7 : return(1/0.917);
            case  8 : return(1/0.944);
            case  9 : return(1/0.974);
            case  10: return(1/1);
            case  20: return(1/1.1);
        }
        return 1.0;
    }
    //-------------------------------------------------------------------------------
    //-------------------------------------------------------------------------------
    public static double GetMonomerCap(double STDAH, int HourRate, double SumAH, double MaxMonomerVol,
                                        double MonomerVol, double MonomerVolType, byte CapType)
    {
        if(MaxMonomerVol - MonomerVolType*0.9 <= 0)
            return 0;
        if(STDAH < 1)
            STDAH = 1;
        if(SumAH < 0)
            SumAH *= (-1);
        double tmp_cap;
        tmp_cap = MonomerVol - MonomerVolType * 0.9;
        tmp_cap *= (STDAH - SumAH * N_TO_10H(HourRate));
        double dt_vol = MaxMonomerVol - MonomerVolType*0.9;
        if(dt_vol < 0.01)
            dt_vol = 0.01;
        tmp_cap = tmp_cap/dt_vol;
        if(tmp_cap < 0)
            tmp_cap = 0;
        if(CapType == CapType_Rest)
            return tmp_cap;
        else if(CapType == CapType_Real)
            return (tmp_cap + SumAH * N_TO_10H(HourRate));
        else
            return ((tmp_cap + SumAH * N_TO_10H(HourRate))*100 / STDAH);
    }
    //----------------------------------------------------------------------------------
    //----------------------------------------------------------------------------------
    public static int GetRestTimeSecond(double restcap, double curr)
    {
        double tmp_curr = Math.abs(curr);
        if(tmp_curr < 0.1)
            tmp_curr = 0.1;
        int rest_time = (int)((restcap / tmp_curr) * 3600);
        if(rest_time > (99*3600))
            rest_time = (99*3600);
        return rest_time;
    }
    //----------------------------------------------------------------------------------
}
/***************************************************************************************
******************************* end of file (FBS_ComBase)*******************************
***************************************************************************************/
src/main/java/testElectronJ/FboData.java
New file
@@ -0,0 +1,208 @@
package testElectronJ;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
/**
 * FBO测试数据[每个对象为一笔数据]
 * @author LiJun
 *
 */
public class FboData {
    public static final int MAX_GROUPMODULE_NUM = 5;
    public DataType m_DataType;                        //数据类型
    public int CRC16;
    public TestTime m_TestTime;                        //数据时间
    public int  BattGroup;                            //组数 未使用            2
    public int BattSum;                                //单体数 未使用            2
    public float OnlineVol;                            //未使用            4
    public float SumVoltage;                        //总电压                4
    public float SumCurrent;                        //总电流                2
    public float testCap;                            //测试容量
    public float actualCap;                            //实际容量 预估数据
    public float residualCap;                        //剩余容量
    public int residualTime;                        //剩余时间
    public float Temp_Envi;                           //环境温度
    public float Humi_Envi;                           //环境湿度
    public FboDataHeadStart.DateTime InsDate;                        //绝缘测试日期
    public float PosInsRes;                           //正极绝缘电阻
    public float NegInsRes;                           //负极绝缘电阻
    public float SingleVol[];                        //0.001        //单体电压
    public float SubCurrent[];                        //未使用        //单体电流
    public float testSubCap[];                        //未使用        //单体测试容量
    public float actualSubCap[];                    //未使用        //实际容量
    public float residualSubCap[];                    //未使用        //剩余容量
    public int residualSubTime[];                    //未使用        //剩余时间
    public FboData() {
        // TODO Auto-generated constructor stub
    }
    public FboData(int  BattGroup) {
        this.m_DataType = new DataType();
        this.m_TestTime = new TestTime();
        this.InsDate = new FboDataHeadStart().new DateTime();
        this.SingleVol = new float[BattGroup];                        //0.001        //单体电压
        this.SubCurrent = new float[BattGroup];                        //未使用        //单体电流
        this.testSubCap = new float[BattGroup];                        //未使用        //单体测试容量
        this.actualSubCap = new float[BattGroup];                    //未使用        //实际容量
        this.residualSubCap = new float[BattGroup];                    //未使用        //剩余容量
        this.residualSubTime = new int[BattGroup];                    //未使用        //剩余时间
    }
    /**
     *     数据类型
     * @author LiJun
     *
     */
    public class DataType{
        public int typeTag0;
        public int typeTag1;
        public int typeTag2;
        public int typeTag3;
        public int checkDataHead(FileInputStream fis)
        {
            boolean file_end = false;
            byte type_tag = 0;
            byte[] tag = new byte[1];
            try {
                while(true)
                {
                    type_tag = 0;
                    int n = 0;
                    for(n=0; n<4; n++)
                    {
                        if(1 != fis.read(tag, 0, 1))
                        {
                            file_end = true;
                            break;
                        }
                        if((0xFD != (tag[0]&0xFF)) && (0xFC != (tag[0]&0xFF)) && (0xFB != (tag[0]&0xFF)))
                        {
                            break;
                        }
                    }
                    if(n >= 4)
                    {
                        type_tag = tag[0];
                        break;
                    }
                    if(true == file_end)
                    {
                        type_tag = 1;
                        break;
                    }
                }
            } catch (IOException e) {
                // TODO Auto-generated catch block
                //e.printStackTrace();
            }
            setType(type_tag&0xFF);
            return (typeTag0);
        }
        public void setType(int type)
        {
            typeTag0 = type;
            typeTag1 = type;
            typeTag2 = type;
            typeTag3 = type;
        }
    }
    public class TestTime{
        public int hour;
        public int minute;
        public int second;
        @Override
        public String toString() {
            return "TestTime [hour=" + hour + ", minute=" + minute + ", second=" + second + "]";
        }
    }
    public void setData(byte[] databuf) {
        ByteBuffer bf = ByteBuffer.allocate(databuf.length);
        bf.order(ByteOrder.LITTLE_ENDIAN);
        bf.put(databuf);
        bf.position(0);
        this.CRC16 = ComBase.changeShortToInt(bf.getShort());
        this.m_TestTime.hour = ComBase.changeByteToInt(bf.get());            //数据时间
        this.m_TestTime.minute = ComBase.changeByteToInt(bf.get());            //数据时间
        this.m_TestTime.second = ComBase.changeByteToInt(bf.get());            //数据时间
        this.BattGroup = ComBase.changeByteToInt(bf.get());                    //组数 未使用            2
        this.BattSum = ComBase.changeShortToInt(bf.getShort());                //单体数 未使用            2
           this.OnlineVol = (float)bf.getInt()/1000;                            //未使用            4
        this.SumVoltage = (float)bf.getInt()/1000;                            //总电压                4
        this.SumCurrent = ComBase.changeShortToFloat(bf.getShort())/10;        //总电流                2
        this.testCap = ComBase.changeShortToFloat(bf.getShort());            //测试容量
        this.actualCap = ComBase.changeShortToFloat(bf.getShort());            //实际容量 预估数据
        this.residualCap = ComBase.changeShortToFloat(bf.getShort());        //剩余容量
        this.residualTime = ComBase.changeShortToInt(bf.getShort());        //剩余时间
        this.Temp_Envi = ComBase.changeShortToFloat(bf.getShort());         //环境温度
        this.Humi_Envi = ComBase.changeShortToFloat(bf.getShort());         //环境湿度
        this.InsDate.year = ComBase.changeByteToInt(bf.get());                //年
        this.InsDate.month = ComBase.changeByteToInt(bf.get());                //月
        this.InsDate.day = ComBase.changeByteToInt(bf.get());                //日
        this.InsDate.hour = ComBase.changeByteToInt(bf.get());                //时
        this.InsDate.minute = ComBase.changeByteToInt(bf.get());            //分
        this.InsDate.second = ComBase.changeByteToInt(bf.get());            //秒
        this.PosInsRes = ComBase.changeShortToFloat(bf.getShort());         //正极绝缘电阻
        this.NegInsRes = ComBase.changeShortToFloat(bf.getShort());         //负极绝缘电阻
        for(int i=0;i<SingleVol.length;i++) {
            SingleVol[i] = (float)bf.getInt()/1000;                            //0.001        //单体电压
        }
        for(int i=0;i<SubCurrent.length;i++) {
            SubCurrent[i] = ComBase.changeShortToFloat(bf.getShort());        //未使用        //单体电流
        }
        for(int i=0;i<testSubCap.length;i++) {
            testSubCap[i] = ComBase.changeShortToFloat(bf.getShort());        //未使用        //单体测试容量
        }
        for(int i=0;i<actualSubCap.length;i++) {
            actualSubCap[i] = ComBase.changeShortToFloat(bf.getShort());
        }
        for(int i=0;i<residualSubCap.length;i++) {
            residualSubCap[i] = ComBase.changeShortToFloat(bf.getShort());     //未使用        //剩余容量
        }
        for(int i=0;i<residualSubTime.length;i++) {
            residualSubTime[i] = ComBase.changeShortToInt(bf.getShort()); //未使用        //剩余时间
        }
        System.out.println(this);
    }
    @Override
    public String toString() {
        return "FboData [m_DataType=" + m_DataType + ", CRC16=" + CRC16 + ", m_TestTime=" + m_TestTime + ", BattGroup="
                + BattGroup + ", BattSum=" + BattSum + ", OnlineVol=" + OnlineVol + ", SumVoltage=" + SumVoltage
                + ", SumCurrent=" + SumCurrent + ", testCap=" + testCap + ", actualCap=" + actualCap + ", residualCap="
                + residualCap + ", residualTime=" + residualTime + ", Temp_Envi=" + Temp_Envi + ", Humi_Envi="
                + Humi_Envi + ", PosInsRes=" + PosInsRes + ", NegInsRes=" + NegInsRes + ", SingleVol="
                + Arrays.toString(SingleVol) + ", SubCurrent=" + Arrays.toString(SubCurrent) + ", testSubCap="
                + Arrays.toString(testSubCap) + ", actualSubCap=" + Arrays.toString(actualSubCap) + ", residualSubCap="
                + Arrays.toString(residualSubCap) + ", residualSubTime=" + Arrays.toString(residualSubTime) + "]";
    }
}
src/main/java/testElectronJ/FboDataHeadStart.java
New file
@@ -0,0 +1,224 @@
package testElectronJ;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
/**
 * FBO数据头数据
 * @author LiJun
 *
 */
public class FboDataHeadStart {
    public static final int BYTE_LEN = 179;
    public int battname_len;                    //电池组名称长度                        1
    public byte[] battname = new byte[60];      //电池名称 最大20个中文                    60
    public String battNameStr;                    //电池组名称
    public int batt_brand_len;                    //电池组品牌长度                        1
    public byte[] batt_brand = new byte[18];    //电池品牌 最大6个中文                    18
    public String battBrandStr;
    public int batt_date_len;                    //日期长度                                1
    public byte[] batt_date = new byte[10];        //安装日期 2000-01-01                    10
    public String batt_date_str;
    public float batt_std_cap;                   //标称容量                                2
    public float batt_std_res;                   //标称内阻                                2
    public float batt_std_cte;                   //标称电导                                2
    public int batt_mon_num;                       //单体数量                                1
    public float batt_mon_vol;                   //单体电压 0.1                            2        =100
    public DateTime TestStartTime;                //放电开始的时间                        6
    public int Device;                             //仪表类型 未使用                        1
    public int DataVersion;                        //数据版本                                1
    public int DataType;                        //数据类型;0xFD表示放电,0xFC表示充电            1
    public int HourRate;                        //小时率 未使用                            1
    public int SaveInterval;                    //采集间隔 未使用                        1
    public float TestCur;                        //测试电流 未使用                        2
    public int BattGroup;                          //电池组数[模块个数] 未使用                2
    public int MVLLimitCount;                      //单体下限个数 未使用                    2
    public int module_mon_num[] = new int[10];  //每个组压模块单体节数 目前只用5个        20
    public float GrpVol_H_Limit;                 //组压模块电压平均值上限(0.1)            2
    public float GrpVol_L_Limit;                 //组压模块电压平均值下限(0.1)            2
    public float Module_Vol_H_Limit;             //组压模块电压平均值上限(0.1)            2
    public float Module_Vol_L_Limit;             //组压模块电压平均值下限(0.1)            2
    public float ENV_Temp_H_Limit;                //环境温度上限(0.1-20)                    2
    public float ENV_Temp_L_Limit;                //环境温度下限(0.1)                        2
    public float ENV_Humi_H_Limit;                //环境湿度上限(0.1)                        2
    public float ENV_Humi_L_Limit;                //环境湿度下限(0.1)                        2
    public float ChargeCurr_H_Limit;             //充电电流上限(0.1)                        2
    public float DischCurr_H_Limit;              //放电电流上限(0.1)                        2
    public float Cap_L_Limit;                    //容量下限                                2
    public int[] StandBy = new int[10];            //保留备用                                20        179
    public FboDataHeadStart(){
        TestStartTime = new DateTime();
    }
    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 void setDateTime(ByteBuffer bf) {
            if(bf.limit() < 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());
            System.out.println(year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second);
        }
        public Date getFBODateTime() {
            Calendar c = Calendar.getInstance();
            c.set(2000+year, month, day, hour, minute, second);
            return c.getTime();
            //return Com.get_DT_FromStr(year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second, Com.DTF_YMDhms);
        }
    }
    public void setDataInf(byte[] buf,FboDataHeadStop fboHeadStop) {
        if(buf.length < BYTE_LEN) {
            System.out.println("头部数据长度异常");
            return;
        }
        ByteBuffer bf = ByteBuffer.allocate(buf.length);
        bf.order(ByteOrder.LITTLE_ENDIAN);
        bf.put(buf);
        bf.position(0);
        battname_len = ComBase.changeByteToInt(bf.get());                    //电池组名称长度                        1
        bf.get(battname);                                                     //电池名称 最大20个中文                    60
        checkBattName();                                                    //电池组名称
        this.batt_brand_len = ComBase.changeByteToInt(bf.get());            //电池组品牌长度                        1
        bf.get(batt_brand);                                                   //电池品牌 最大6个中文                    18
        checkBattBrand();
        batt_date_len = ComBase.changeByteToInt(bf.get());                    //日期长度                                1
        bf.get(batt_date);                                                    //安装日期 2000-01-01                    10
        checkBattDate();
        batt_std_cap = ComBase.changeShortToInt(bf.getShort());                //标称容量                                2
        batt_std_res = ComBase.changeShortToInt(bf.getShort())/10;          //标称内阻                                2
        batt_std_cte = ComBase.changeShortToInt(bf.getShort())/10;          //标称电导                                2
        batt_mon_num = ComBase.changeShortToInt(bf.getShort());             //单体数量                                1
        batt_mon_vol = ComBase.changeShortToInt(bf.getShort())/10;           //单体电压 0.1                            2        =100
        TestStartTime.setDateTime(bf);;                                        //放电开始的时间                        6
        Device = ComBase.changeShortToInt(bf.getShort());                   //仪表类型 未使用                        1
        System.out.println("仪表类型:"+getDeviceType(Device));
        DataVersion = ComBase.changeShortToInt(bf.getShort());              //数据版本                                1
        DataType = ComBase.changeByteToInt(bf.get());                        //数据类型;0xFD表示放电,0xFC表示充电            1
        HourRate = ComBase.changeByteToInt(bf.get());                        //小时率 未使用                            1
        SaveInterval = ComBase.changeByteToInt(bf.get());                    //采集间隔 未使用                        1
        TestCur = ComBase.changeShortToFloat(bf.getShort());                //测试电流 未使用                        2
        BattGroup = ComBase.changeShortToInt(bf.getShort());                //电池组数 未使用                        2
        MVLLimitCount = ComBase.changeShortToInt(bf.getShort());            //单体下限个数 未使用                    2
        for(int i=0;i<module_mon_num.length;i++) {
            module_mon_num[i] = ComBase.changeShortToInt(bf.getShort());    //每个组压模块单体节数 目前只用5个        20
            System.out.println((i+1)+":单体数目:"+module_mon_num[i]);
        }
        GrpVol_H_Limit = ComBase.changeShortToFloat(bf.getShort())/10;        //组端电压上限                            2
        GrpVol_L_Limit = ComBase.changeShortToFloat(bf.getShort())/10;        //组端电压下限                            2
        Module_Vol_H_Limit = ComBase.changeShortToFloat(bf.getShort())/1000;  //单体电压上限                            2
        Module_Vol_L_Limit = ComBase.changeShortToFloat(bf.getShort())/1000;  //单体电压下限                            2
        ENV_Temp_H_Limit = ComBase.changeShortToFloat(bf.getShort())/10;      //单体温度上限                            2
        ENV_Temp_L_Limit = ComBase.changeShortToFloat(bf.getShort())/10;      //单体温度下限                            2
        ENV_Humi_H_Limit = ComBase.changeShortToFloat(bf.getShort())/10;      //单体湿度上限                            2
        ENV_Humi_L_Limit = ComBase.changeShortToFloat(bf.getShort())/10;      //单体湿度下限                            2
        ChargeCurr_H_Limit = ComBase.changeShortToFloat(bf.getShort())/10;    //充电电流上限                            2
        DischCurr_H_Limit = ComBase.changeShortToFloat(bf.getShort())/10;     //放电电流上限                            2
        Cap_L_Limit = ComBase.changeShortToFloat(bf.getShort());              //容量下限                                2
        for(int i =0;i<StandBy.length;i++) {
            StandBy[i] =  ComBase.changeShortToInt(bf.getShort());              //保留备用                                20        179
        }
        System.out.println(this);
        fboHeadStop.setFboStopData(bf);
        //System.out.println("avg_curr:"+avg_curr);
        //realcap = BattCapFactory.GetMonomerCap(STDCap,HourRate, TestCap, SMaxVol[0], MonomerVol, SMinVol[0], BattCapFactory.CapType_Real);
    }
    private void checkBattBrand() {
        byte[] batt_brand_tmp = new byte[batt_brand_len];
        System.arraycopy(this.batt_brand, 0, batt_brand_tmp, 0, batt_brand_tmp.length);
        this.battBrandStr = new String(batt_brand_tmp);
        //System.out.println(this.battBrandStr);
    }
    public void checkBattName() {
        byte[] batt = new byte[battname_len];
        System.arraycopy(this.battname, 0, batt, 0, batt.length);
        this.battNameStr = new String(batt);
        //System.out.println(this.battNameStr);
    }
    public void checkBattDate() {
        byte[] date = new byte[batt_date_len];
        System.arraycopy(this.batt_date, 0, date, 0, date.length);
        this.batt_date_str = new String(date);
        //System.out.println(this.batt_date_str);
    }
    public String getDeviceType(int device) {
        String deviceType = "未知";
        switch(device) {
            case 0xFB : deviceType = "FBO4815-CT";break;
            case 0xDC : deviceType = "IDCE4815-CT";break;
            case 0x2F : deviceType = "FBO2205-CT";break;
            case 0x2E : deviceType = "IDCE2205-CT";break;
            case 0x26 : deviceType = "FBO2206-CT";break;
            case 0x25 : deviceType = "IDCE2206-CT";break;
            case 0x3F : deviceType = "FBO4830-CT";break;
            case 0x3E : deviceType = "IDCE4830-CT";break;
            case 0x6F : deviceType = "FBO6003-CT";break;
            case 0x6E : deviceType = "IDCE6003-CT";break;
            case 0x66 : deviceType = "FBO6006-CT";break;
            case 0x67 : deviceType = "IDCE6006-CT";break;
            case 0x1F : deviceType = "FBO1110-CT";break;
            case 0x1E : deviceType = "IDCE1110-CT";break;
            case 0xF3 : deviceType = "FBI-3048CT";break;
            case 0xF1 : deviceType = "FBI-3015CT";break;
            case 0xF4 : deviceType = "FBI-10480CT";break;
            case 0xF5 : deviceType = "FBI-05480CT";break;
            case 0x22 : deviceType = "FBO2210-CT";break;
            case 0x21 : deviceType = "IDCE2210-CT";break;
            case 0x15 : deviceType = "FBO2415-CT";break;
            case 0x16 : deviceType = "IDCE2415-CT";break;
        }
        return deviceType;
    }
    @Override
    public String toString() {
        return "FboDataHeadStart [battname_len=" + battname_len + ", battname=" + Arrays.toString(battname)
                + ", battNameStr=" + battNameStr + ", batt_brand_len=" + batt_brand_len + ", batt_brand="
                + Arrays.toString(batt_brand) + ", battBrandStr=" + battBrandStr + ", batt_date_len=" + batt_date_len
                + ", batt_date=" + Arrays.toString(batt_date) + ", batt_date_str=" + batt_date_str + ", batt_std_cap="
                + batt_std_cap + ", batt_std_res=" + batt_std_res + ", batt_std_cte=" + batt_std_cte + ", batt_mon_num="
                + batt_mon_num + ", batt_mon_vol=" + batt_mon_vol + ", TestStartTime=" + TestStartTime + ", Device="
                + Device + ", DataVersion=" + DataVersion + ", DataType=" + DataType + ", HourRate=" + HourRate
                + ", SaveInterval=" + SaveInterval + ", TestCur=" + TestCur + ", BattGroup=" + BattGroup
                + ", MVLLimitCount=" + MVLLimitCount + ", module_mon_num=" + Arrays.toString(module_mon_num)
                + ", GrpVol_H_Limit=" + GrpVol_H_Limit + ", GrpVol_L_Limit=" + GrpVol_L_Limit + ", Module_Vol_H_Limit="
                + Module_Vol_H_Limit + ", Module_Vol_L_Limit=" + Module_Vol_L_Limit + ", ENV_Temp_H_Limit="
                + ENV_Temp_H_Limit + ", ENV_Temp_L_Limit=" + ENV_Temp_L_Limit + ", ENV_Humi_H_Limit=" + ENV_Humi_H_Limit
                + ", ENV_Humi_L_Limit=" + ENV_Humi_L_Limit + ", ChargeCurr_H_Limit=" + ChargeCurr_H_Limit
                + ", DischCurr_H_Limit=" + DischCurr_H_Limit + ", Cap_L_Limit=" + Cap_L_Limit + ", StandBy="
                + Arrays.toString(StandBy) + "]";
    }
}
src/main/java/testElectronJ/FboDataHeadStop.java
New file
@@ -0,0 +1,70 @@
package testElectronJ;
import java.nio.ByteBuffer;
import java.util.Arrays;
/**
 *     结束数据
 * @author LiJun
 *
 */
public class FboDataHeadStop {
    private static final int BYTE_LEN = 40;
    public FboData.TestTime TestTimeLong;   //测试时长                    3
    public int StopType;            //结束方式 未使用                1
    public int BlockSum;            //保存数据的总块数 未使用        1
    public int StandBy;             //保留备用                    1
    public int[] SMaxIndex;         //最高单体索引 未使用            8
    public int[] SMinIndex;         //最低单体索引 未使用            8
    public float[] SMaxVol;         //最高单体 未使用                8
    public float[] SMinVol;         //最低单体 未使用                8
    public float TestCap;           //测试容量 未使用                2
    public FboDataHeadStop() {
        SMaxIndex = new int[4];
        SMinIndex = new int[4];
        SMaxVol = new float[4];
        SMinVol = new float[4];
    }
    public void setFboStopData(ByteBuffer bf) {
        if(bf.remaining() < BYTE_LEN) {
            return;
        }
        System.out.println("索引位置:"+bf.position());
        this.TestTimeLong = new FboData().new TestTime();
        this.TestTimeLong.hour = ComBase.changeByteToInt(bf.get());
        this.TestTimeLong.minute = ComBase.changeByteToInt(bf.get());
        this.TestTimeLong.second = ComBase.changeByteToInt(bf.get());
        this.StopType = ComBase.changeByteToInt(bf.get());            //结束方式 未使用                1
        this.BlockSum = ComBase.changeByteToInt(bf.get());            //保存数据的总块数 未使用        1
        this.StandBy = ComBase.changeByteToInt(bf.get());             //保留备用                    1
        for(int i = 0;i<SMaxIndex.length;i++) {
            this.SMaxIndex[i] = ComBase.changeShortToInt(bf.getShort()); //最高单体索引 未使用            8
        }
        for(int i=0;i<SMinIndex.length;i++) {
            this.SMinIndex[i] = ComBase.changeShortToInt(bf.getShort());//最低单体索引 未使用            8
        }
        for(int i=0;i<SMaxVol.length;i++) {
            this.SMaxVol[i] = ComBase.changeShortToFloat(bf.getShort());//最高单体 未使用                8
        }
        for(int i=0;i<SMinVol.length;i++) {
            this.SMinVol[i] = ComBase.changeShortToFloat(bf.getShort()); //最低单体 未使用                8
        }
        this.TestCap = ComBase.changeShortToFloat(bf.getShort());           //测试容量 未使用                2
        System.out.println(this);
    }
    @Override
    public String toString() {
        return "FboDataHeadStop [TestTimeLong=" + TestTimeLong + ", StopType=" + StopType + ", BlockSum=" + BlockSum
                + ", StandBy=" + StandBy + ", SMaxIndex=" + Arrays.toString(SMaxIndex) + ", SMinIndex="
                + Arrays.toString(SMinIndex) + ", SMaxVol=" + Arrays.toString(SMaxVol) + ", SMinVol="
                + Arrays.toString(SMinVol) + ", TestCap=" + TestCap + "]";
    }
}
src/main/java/testElectronJ/FboDataInf.java
New file
@@ -0,0 +1,83 @@
package testElectronJ;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class FboDataInf {
    public static final int DataType_Dis     = 0xFD;            //放电
    public static final int DataType_Char     = 0xFC;            //充电
    public static final int DataType_Peac     = 0xFB;            //常规
    public List<FboData> fboData;
    public FboDataHeadStart fboDataStart;
    public FboDataHeadStop fboDataStop;
    public FboDataInf() {
        fboData = new ArrayList<FboData>();
        fboDataStart = new FboDataHeadStart();
        fboDataStop = new FboDataHeadStop();
    }
    public void readFboFile(String filePath)
    {
        FileInputStream fis = null;
        try {
            File f = new File(filePath);
            if(!f.exists()) {
                System.out.println("文件不存在..........");
            }
            fis = new FileInputStream(f);
            byte[] buf = new byte[256];
            if(fis.read(buf, 0, buf.length) == 256)
            {
                this.fboDataStart.setDataInf(buf,this.fboDataStop);
                FboData.DataType mType = new FboData().new DataType();
                while(true)
                {
                    int tag = mType.checkDataHead(fis);
                    if((0xFD == tag) || (0xFC == tag) || (0xFB == tag))
                    {
                        byte[] databuf = new byte[this.fboDataStart.BattGroup*14 + 40];
                        if(fis.read(databuf) == databuf.length)
                        {
                            FboData m_FboData = new FboData(this.fboDataStart.BattGroup);
                            m_FboData.m_DataType = mType;
                            m_FboData.setData(databuf);
                            fboData.add(m_FboData);
                        }
                    }
                    if(tag == 1)
                        break;
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if(null != fis)
            {
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    public static void main(String[] args) {
        FboDataInf fbo = new FboDataInf();
        //fbo.readFboFile("D:/test/F2022-03-09 11.26.12.FBX");
        //fbo.readFboFile("D:/test/F2022-03-09 16.22.37.FBX");
        //fbo.readFboFile("D:/test/F2022-03-10 11.12.30.FBX");
        fbo.readFboFile("D:/test/F2022-03-14 15.32.19.FBX");
    }
}
src/main/java/testElectronJ/TestController.java
@@ -2,16 +2,27 @@
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController
@RequestMapping("test")
public class TestController {
    @Resource
    private FboDataInf fboDataInf;
    @GetMapping("/hello")
    public Response hello(){
        return new Response().set(1,"hello");
    }
    @GetMapping("/readFboFile")
    public Response readFboFile(@RequestParam String filePath){
        fboDataInf.readFboFile(filePath);
        return new Response().set(1,filePath);
    }
}