lxw
2023-05-16 cbbf67dd9e9b1339a7251035b90c6032a9f5de54
文件解析放电、充电、告警数据
20个文件已添加
1个文件已修改
2665 ■■■■■ 已修改文件
src/main/java/com/whyc/alarm/Fbs5100Alarm.java 131 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/alarm/Fbs5100AlarmData.java 120 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/alarm/Fbs5100AlarmParam.java 129 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/charge/Fbs5100BattParam.java 195 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/charge/Fbs5100CapState.java 159 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/charge/Fbs5100ChargeData.java 126 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/charge/Fbs5100ChargeParam.java 176 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/charge/Fbs5100ChargeState.java 205 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/charge/Fbs5100DisChargeData.java 128 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/charge/Fbs5100FbsData.java 278 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/charge/Fbs5100TestParam.java 196 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/charge/Fbs5100TestTime.java 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/AnalysisController.java 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/TestController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/dto/ComFn.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/dto/Fbs5100ComBase.java 464 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/dto/Fbs5100Crc16.java 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/dto/Fbs5100DateTime.java 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/Fbs5100AlarmDataService.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/Fbs5100ChargeDataService.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/Fbs5100DisChargeDataService.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/alarm/Fbs5100Alarm.java
New file
@@ -0,0 +1,131 @@
package com.whyc.alarm;
import com.whyc.dto.Fbs5100ComBase;
import com.whyc.dto.Fbs5100DateTime;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
public class Fbs5100Alarm {
    public static final int ALMITEM_CAP1             = 0;      //组1容量告警
    public static final int ALMITEM_CAP2             = 1;    //组2容量告警
    public static final int ALMITEM_CAP3             = 2;    //组3容量告警
    public static final int ALMITEM_CAP4             = 3;    //组4容量告警
    public static final int ALMITEM_INPUTVOL         = 4;      //输入电压告警
    public static final int ALMITEM_AC_DOWM         = 5;       //交流失电
    public static final int ALMITEM_GROUPVOL1         = 6;      //组1电压告警
    public static final int ALMITEM_GROUPVOL2         = 7;    //组2电压告警
    public static final int ALMITEM_GROUPVOL3         = 8;    //组3电压告警
    public static final int ALMITEM_GROUPVOL4         = 9;    //组4电压告警
    public static final int ALMITEM_BOOST_FAULT     = 10;      //升压模块故障
    public static final int ALMITEM_BUCK_FAULT         = 11;      //降压模块故障
    public static final int ALMITEM_NBCOMM_FAULT     = 12;     //逆变通信故障
    public static final int ALMITEM_ACDC_FAULT         = 13;      //电源故障
    public static final int ALMITEM_COOLER_TEMP     = 14;      //散热器温度
    public static final int ALMITEM_INNER_TEMP         = 15;   //内部温度
    public static final int BYTE_LEN = 16;
    public int    SYNCode[] = new int[2]; //AA AA
    public int   AlarmItem;                    //告警类型
    public int    AlarmType;                     //1-超出上限 或 产生告警   2-超出下限
    public float  AlarmValue;                //告警值
    public Fbs5100DateTime StartTime;        //告警开始时间
    public Fbs5100DateTime    EndTime;          //暂未启用,不要显示
    public Fbs5100Alarm() {
        StartTime  = new Fbs5100DateTime();
        EndTime  = new Fbs5100DateTime();
    }
    public boolean putByteBuffer(final byte[] buf)
    {
        ByteBuffer bf = ByteBuffer.allocate(buf.length);
        bf.order(ByteOrder.LITTLE_ENDIAN);
        bf.put(buf);
        if(bf.limit() != BYTE_LEN){
            return false;
        }
        ByteBuffer tmpbuf = bf;
        tmpbuf.position(0);
        AlarmItem = Fbs5100ComBase.changeByteToInt(tmpbuf.get());                        //告警类型
        AlarmType = Fbs5100ComBase.changeByteToInt(tmpbuf.get());                         //1-超出上限 或 产生告警   2-超出下限
        AlarmValue = (float)Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort())/10;    //告警值
        StartTime.putByteBuffer(tmpbuf);                                                //告警开始时间
        EndTime.putByteBuffer(tmpbuf);                                                  //暂未启用,不要显示
        tmpbuf.compact();
        tmpbuf.flip();
        return true;
    }
    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<2; n++)
                {
                    if(1 != fis.read(tag, 0, 1))
                    {
                        file_end = true;
                        break;
                    }
                    if((0xAA != (tag[0]&0xFF)))
                    {
                        break;
                    }
                }
                if(n >= 2)
                {
                    type_tag = tag[0];
                    break;
                }
                if(true == file_end)
                {
                    type_tag = 1;
                    break;
                }
            }
        } catch (IOException e) {
            //e.printStackTrace();
        }
        setType(type_tag&0xFF);
        return (type_tag&0xFF);
    }
    private void setType(int synCode) {
        for(int i  = 0 ; i < SYNCode.length ; i++) {
            SYNCode[i] = synCode;
        }
    }
    @Override
    public String toString() {
        return "Fbs5100Alarm [SYNCode=" + Arrays.toString(SYNCode) + ", AlarmItem=" + AlarmItem + ", AlarmType="
                + AlarmType + ", AlarmValue=" + AlarmValue + ", StartTime=" + StartTime + ", EndTime=" + EndTime + "]";
    }
}
src/main/java/com/whyc/alarm/Fbs5100AlarmData.java
New file
@@ -0,0 +1,120 @@
package com.whyc.alarm;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.List;
import com.whyc.charge.Fbs5100BattParam;
import com.whyc.dto.ComFn;
import com.whyc.dto.Fbs5100ComBase;
import org.springframework.stereotype.Component;
@Component
public class Fbs5100AlarmData {
    public Fbs5100AlarmParam alarmParam;        //告警参数
    public List<Fbs5100Alarm> alarms;
    public int parse_result = Fbs5100ComBase.PARSE_RESULT_NULL;
    public Fbs5100AlarmData() {
        alarmParam = new Fbs5100AlarmParam();
        alarms = new ArrayList<Fbs5100Alarm>();
    }
    public void parseFileData(String filePath)
    {
        FileInputStream fis = null;
        try {
            File f = new File(filePath);
            //既不是核容放电也不是监测放电
            if(!filePath.endsWith(".ALM")) {
                parse_result = Fbs5100ComBase.PARSE_RESULT_FILETYPEERR;
                return;
            }
            if(!f.exists()) {
                parse_result = Fbs5100ComBase.PARSE_RESULT_NOTFOUNDFILE;
                return;
                //System.out.println("文件不存在..........");
            }
            fis = new FileInputStream(f);
            byte[] buf = new byte[1024];
            if(fis.read(buf, 0, buf.length) == 1024)
            {
                if(this.readDataHead(buf)) {
                    parse_result = Fbs5100ComBase.PARSE_RESULT_SUCCESS;
                }else {
                    parse_result = Fbs5100ComBase.PARSE_RESULT_FILEERROR;
                }
                while(true)
                {
                    Fbs5100Alarm alm = new Fbs5100Alarm();
                    int tag = alm.checkDataHead(fis);
                    if((0xAA == tag))
                    {
                        byte[] databuf = new byte[Fbs5100Alarm.BYTE_LEN];
                        if(fis.read(databuf) == databuf.length)
                        {
                            //System.out.println(ComFn.bytesToHexString(databuf, databuf.length));
                            if(alm.putByteBuffer(databuf)){
                                alarms.add(alm);
                            }
                        }
                    }
                    if(tag == 1)
                        break;
                }
            }else {
                parse_result = Fbs5100ComBase.PARSE_RESULT_FILEERROR;
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if(null != fis)
            {
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    //解析数据头
    public boolean readDataHead(byte[] buf) {
        //System.out.println(ComFn.bytesToHexString(buf, buf.length));
        boolean flag = false;
        if(buf.length < (Fbs5100BattParam.BYTE_LEN)) {
            //System.out.println("头部数据长度异常");
            return flag;
        }
        ByteBuffer bf = ByteBuffer.allocate(buf.length);
        bf.order(ByteOrder.LITTLE_ENDIAN);
        bf.put(buf);
        bf.position(0);
        flag = this.alarmParam.putByteBuffer(bf);
        //System.out.println("alarmParam:"+flag);
        return flag;
    }
    @Override
    public String toString() {
        return "Fbs5100AlarmData [alarmParam=" + alarmParam + ", alarms=" + alarms + ", parse_result=" + parse_result
                + "]";
    }
}
src/main/java/com/whyc/alarm/Fbs5100AlarmParam.java
New file
@@ -0,0 +1,129 @@
package com.whyc.alarm;
import com.whyc.dto.Fbs5100ComBase;
import com.whyc.dto.Fbs5100Crc16;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public class Fbs5100AlarmParam {
    private final int BYTE_LEN = 32;
    public float Batt_CAP = 0;
    public float GroupVol_H = 0;
    public float GroupVol_L = 0;
    public float AC_VOL_H = 0;
    public float AC_VOL_L = 0;
    public float bakeup1 = 0;
    public float bakeup2 = 0;
    public float bakeup3 = 0;
    public float bakeup4 = 0;
    public float bakeup5 = 0;
    public float bakeup6 = 0;
    public float bakeup7 = 0;
    public float bakeup8 = 0;
    public float bakeup9 = 0;
    public float bakeup10 = 0;
    public int CRC = 0;
    public Fbs5100AlarmParam clone()
    {
        Fbs5100AlarmParam obj = null;
        try
        {
            obj = (Fbs5100AlarmParam)super.clone();
        }
        catch(CloneNotSupportedException e)
        {
            e.printStackTrace();
        }
        return obj;
    }
    public void clear()
    {
        GroupVol_H = 0;
        GroupVol_L = 0;
        AC_VOL_H = 0;
        AC_VOL_L = 0;
        Batt_CAP = 0;
    }
    public boolean putByteBuffer(final ByteBuffer bf)
    {
        if(bf.limit() < BYTE_LEN) {
            return false;
        }
        ByteBuffer tmpbuf = bf;
        int crc0 = tmpbuf.getShort(BYTE_LEN-2) & 0xFFFF;
        int crc1 = Fbs5100Crc16.CalCRC16(tmpbuf, BYTE_LEN-2);
        if(crc0 != crc1) {
            System.err.println("Fbs5100AlarmParam:"+crc0+"=="+crc1);
            return false;
        }
        tmpbuf.position(0);
        Batt_CAP = Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort());
        GroupVol_H = Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort())/10;
        GroupVol_L = Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort())/10;
        AC_VOL_H = Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort())/10;
        AC_VOL_L = Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort())/10;
        bakeup1 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup2 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup3 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup4 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup5 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup6 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup7 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup8 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup9 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup10 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        CRC = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        tmpbuf.compact();
        tmpbuf.flip();
        return true;
    }
    public ByteBuffer getByteBuffer()
    {
        ByteBuffer bytebuffer = ByteBuffer.allocate(BYTE_LEN);
        bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(Batt_CAP));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(GroupVol_H*10));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(GroupVol_L*10));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(AC_VOL_H*10));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(AC_VOL_L*10));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup1));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup2));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup3));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup4));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup5));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup6));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup7));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup8));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup9));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup10));
        CRC = Fbs5100Crc16.CalCRC16(bytebuffer, bytebuffer.position());
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(CRC));
        bytebuffer.flip();
        return bytebuffer;
    }
    @Override
    public String toString() {
        return "Fbs5100AlarmParam [BYTE_LEN=" + BYTE_LEN + ", Batt_CAP=" + Batt_CAP + ", GroupVol_H=" + GroupVol_H
                + ", GroupVol_L=" + GroupVol_L + ", AC_VOL_H=" + AC_VOL_H + ", AC_VOL_L=" + AC_VOL_L + "]";
    }
}
src/main/java/com/whyc/charge/Fbs5100BattParam.java
New file
@@ -0,0 +1,195 @@
package com.whyc.charge;
import com.whyc.dto.Fbs5100ComBase;
import com.whyc.dto.Fbs5100Crc16;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public class Fbs5100BattParam {
    public static final int BYTE_LEN = 44;                //常规BTS长度
    public int op_cmd = 0;
    public float STD_CAP;
    public float STD_RES;
    public int BattGroupCount;                        //电池组数(1~4)
    public int EachGroupBattCount;                    //每组节数(1~15)
    public float MonomerVol;
    public float GroupVol;
    public float BattTemp;
    public float FloatChargeVol;                    //浮充电压 (0.1V,  1.8~28.8)
    public float FloatChargeCurr;                    //浮充电流阈值(0.1A  0.5~20.0)
    public float OnlineVolLow;                        //在线电压低阈值(0.1V 30.0~56.0)
    public int GroupConnType;
    public float JunChargeVol;                        //均充电压(0.1V, 30.0~56.0)
    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 = 0;
    /**
     * 复制一个当前对象(引用不同);
     */
    public Fbs5100BattParam clone()
    {
        Fbs5100BattParam obj = null;
        try
        {
            obj = (Fbs5100BattParam)super.clone();
        }
        catch(CloneNotSupportedException e)
        {
            e.printStackTrace();
        }
        return obj;
    }
    /**
     * 清空当前对象
     */
    public void clear()
    {
        STD_CAP = 0.0f;
        STD_RES = 0.0f;
        BattGroupCount = 0;
        EachGroupBattCount = 0;
        MonomerVol = 0.0f;
        GroupVol = 0.0f;
        BattTemp = 0.0f;
        FloatChargeVol = 0.0f;
        FloatChargeCurr = 0.0f;
        OnlineVolLow = 0.0f;
        GroupConnType = 0;
        JunChargeVol = 0f;
        bakeup2 = 0;
        bakeup3 = 0;
        bakeup4 = 0;
        bakeup5 = 0;
        bakeup6 = 0;
        bakeup7 = 0;
        bakeup8 = 0;
        bakeup9 = 0;
        bakeup10 = 0;
        CRC = 0;
    }
    /**
     * 将bytebuffer中的数据取出放入该对象的属性中,并返回是否取出成功
     *
     * @param bf
     * @return
     */
    public boolean putByteBuffer(final ByteBuffer bf)
    {
        if(bf.limit() < BYTE_LEN) {
            //System.out.println("长度错误");
            return false;
        }
        ByteBuffer tmpbuf = bf;
        int crc0 = tmpbuf.getShort(BYTE_LEN-2) & 0xFFFF;
        int crc1 = Fbs5100Crc16.CalCRC16(tmpbuf, BYTE_LEN-2);
        if(crc0 != crc1) {
            System.out.println("Fbs5100BattParam" + crc0 + "==" + crc1);
            return false;
        }
        tmpbuf.position(0);
        STD_CAP = Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort());
        STD_RES = Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort())*10;//uΩ
        BattGroupCount = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        EachGroupBattCount = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        MonomerVol = Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort())/10;
        GroupVol = Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort());
        BattTemp = Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort())/10;
        FloatChargeVol = Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort())/10;
        FloatChargeCurr = Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort())/10;
        OnlineVolLow = Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort())/10;
        GroupConnType = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        JunChargeVol = Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort())/10;
        bakeup2 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup3 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup4 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup5 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup6 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup7 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup8 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup9 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup10 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        CRC = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        tmpbuf.compact();
        tmpbuf.flip();
        //System.out.println(this);
        return true;
    }
    /**
     * 将数据放入bytebuffer中并返回
     * @return
     */
    public ByteBuffer getByteBuffer()
    {
        ByteBuffer bytebuffer = ByteBuffer.allocate(BYTE_LEN);
        bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
        bytebuffer.putShort(Fbs5100ComBase.changeFloatToShort(STD_CAP));
        bytebuffer.putShort(Fbs5100ComBase.changeFloatToShort(STD_RES/10));//uΩ
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(BattGroupCount));
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(EachGroupBattCount));
        bytebuffer.putShort(Fbs5100ComBase.changeFloatToShort(MonomerVol*10));
        bytebuffer.putShort(Fbs5100ComBase.changeFloatToShort(GroupVol));
        bytebuffer.putShort(Fbs5100ComBase.changeFloatToShort(BattTemp*10));
        bytebuffer.putShort(Fbs5100ComBase.changeFloatToShort(FloatChargeVol*10));
        bytebuffer.putShort(Fbs5100ComBase.changeFloatToShort(FloatChargeCurr*10));
        bytebuffer.putShort(Fbs5100ComBase.changeFloatToShort(OnlineVolLow*10));
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(GroupConnType));
        bytebuffer.putShort(Fbs5100ComBase.changeFloatToShort(JunChargeVol*10));
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(bakeup2));
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(bakeup3));
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(bakeup4));
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(bakeup5));
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(bakeup6));
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(bakeup7));
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(bakeup8));
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(bakeup9));
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(bakeup10));
        CRC = Fbs5100Crc16.CalCRC16(bytebuffer, bytebuffer.position());
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(CRC));
        bytebuffer.flip();
        return bytebuffer;
    }
    @Override
    public String toString() {
        return "Fbs5100BattParam [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
                + ", JunChargeVol=" + JunChargeVol + "]";
    }
}
src/main/java/com/whyc/charge/Fbs5100CapState.java
New file
@@ -0,0 +1,159 @@
package com.whyc.charge;
import java.nio.ByteBuffer;
import java.util.Arrays;
import com.whyc.dto.Fbs5100ComBase;
import com.whyc.dto.Fbs5100Crc16;
import com.whyc.dto.Fbs5100DateTime;
public class Fbs5100CapState {
    public static final int BYTE_LEN = 214;                //常规BTS长度
    public Fbs5100DateTime StartDT;                                                //启动放电的日期时间
    public Fbs5100DateTime StopDT;                                                    //终止放电的日期时间
    public Fbs5100TestTime Test_Time;                                                //已测试时间(HMS)
    public  int TestState;                                                            //测试状态(停止/暂停/放电)
    public  int TestType;                                                            //测试类型(放电/充电)
    public  int TestGroupNum;                                                        //被测试电池组编号(1~4)
    public  int SaveDataEN;                                                            //保存数据标识
    public  int NT_DCDC_State;                                                        //备用,DCDC模块工作状态
    public  int MonomerLowCount[] = new int[Fbs5100ComBase.BattGroupCountMax];        //每组已到单体下限数量
    public  float TestCur[] = new float[Fbs5100ComBase.BattGroupCountMax];
    public  float GroupVol[] = new float[Fbs5100ComBase.BattGroupCountMax];
    public  float OnlineVol[] = new float[Fbs5100ComBase.BattGroupCountMax];
    public  int TestCapInt[] = new int[Fbs5100ComBase.BattGroupCountMax];
    public  int GroupCapInt[] = new int[Fbs5100ComBase.BattGroupCountMax];
    public  int GroupRestCapInt[] = new int[Fbs5100ComBase.BattGroupCountMax];
    public  int MonMaxNum[] = new int[Fbs5100ComBase.BattGroupCountMax];
    public  int MonMinNum[] = new int[Fbs5100ComBase.BattGroupCountMax];
    public  float MonMaxValue[] = new float[Fbs5100ComBase.BattGroupCountMax];
    public  float MonMinValue[] = new float[Fbs5100ComBase.BattGroupCountMax];
    public  int RestTest_Time[] = new int[Fbs5100ComBase.BattGroupCountMax];        //剩余容量可放电时间(HMS)
    public double TestCap[] = new double[Fbs5100ComBase.BattGroupCountMax];            //每组已测试容量
    public double GroupCap[] = new double[Fbs5100ComBase.BattGroupCountMax];            //每组实际容量
    public double GroupRestCap[] = new double[Fbs5100ComBase.BattGroupCountMax];        //每组剩余容量
    public int CRC;
    public Fbs5100CapState() {
        StartDT = new Fbs5100DateTime();
        StopDT = new Fbs5100DateTime();
        Test_Time = new Fbs5100TestTime();
    }
    public boolean putByteBuffer(final ByteBuffer bf)
    {
        if(bf.limit() < BYTE_LEN) {
            System.out.println("长度错误");
            return false;
        }
        //System.err.println(ComFn.bytesToHexString(bf.array(), bf.array().length));
        ByteBuffer tmpbuf = bf;
        int crc0 = tmpbuf.getShort(BYTE_LEN-2) & 0xFFFF;
        int crc1 = Fbs5100Crc16.CalCRC16(tmpbuf, BYTE_LEN-2);
        if(crc0 != crc1) {
            System.out.println("Fbs5100CapState" + crc0 + "Crc 错误" + crc1);
            //return false;
        }
        tmpbuf.position(0);
        StartDT.putByteBuffer(tmpbuf);                                                    //启动放电的日期时间
        StopDT.putByteBuffer(tmpbuf);                                                    //终止放电的日期时间
        Test_Time.putByteBuffer(tmpbuf);                                                //已测试时间(HMS)
        TestState = Fbs5100ComBase.changeByteToInt(tmpbuf.get());                        //测试状态(停止/暂停/放电)
        TestType = Fbs5100ComBase.changeByteToInt(tmpbuf.get());                        //测试类型(放电/充电)
        TestGroupNum = Fbs5100ComBase.changeByteToInt(tmpbuf.get());                    //被测试电池组编号(1~4)
        SaveDataEN = Fbs5100ComBase.changeByteToInt(tmpbuf.get());                        //保存数据标识
        NT_DCDC_State = Fbs5100ComBase.changeByteToInt(tmpbuf.get());                    //备用,DCDC模块工作状态
        for(int i =0;i<MonomerLowCount.length;i++) {
            MonomerLowCount[i] = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());            //每组已到单体下限数量
        }
        for(int i =0;i<TestCur.length;i++) {
            TestCur[i] = (float)Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort());
        }
        for(int i =0;i<OnlineVol.length;i++) {
            OnlineVol[i] = (float)Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort());
        }
        for(int i =0;i<TestCapInt.length;i++) {
            TestCapInt[i] = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        }
        for(int i =0;i<GroupCapInt.length;i++) {
            GroupCapInt[i] = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        }
        for(int i =0;i<GroupRestCapInt.length;i++) {
            GroupRestCapInt[i] = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        }
        for(int i =0;i<MonMaxNum.length;i++) {
            MonMaxNum[i] = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        }
        for(int i =0;i<MonMinNum.length;i++) {
            MonMinNum[i] = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        }
        for(int i =0;i<MonMaxValue.length;i++) {
            MonMaxValue[i] = Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort());
        }
        for(int i =0;i<MonMinValue.length;i++) {
            MonMinValue[i] = Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort());
        }
        for(int i =0;i<RestTest_Time.length;i++) {
            //RestTest_Time[i] = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());        //剩余容量可放电时间(HMS)
            RestTest_Time[i] = tmpbuf.getInt();            //剩余容量可放电时间(HMS)
        }
        for(int i =0;i<TestCap.length;i++) {
            //TestCap[i] = Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort());            //每组已测试容量
            TestCap[i] = tmpbuf.getDouble();            //每组已测试容量
        }
        for(int i =0;i<GroupCap.length;i++) {
            //GroupCap[i] = Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort());        //每组实际容量
            GroupCap[i] = tmpbuf.getDouble();            //每组实际容量
        }
        for(int i =0;i<GroupRestCap.length;i++) {
            //GroupRestCap[i] = Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort());    //每组剩余容量
            GroupRestCap[i] = tmpbuf.getDouble();        //每组剩余容量
        }
        CRC  = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        //System.out.println("position:"+tmpbuf.position()+"====" + CRC);
        tmpbuf.compact();
        tmpbuf.flip();
        return true;
    }
    @Override
    public String toString() {
        return "Fbs5100CapState [StartDT=" + StartDT + ", StopDT=" + StopDT + ", Test_Time=" + Test_Time
                + ", TestState=" + TestState + ", TestType=" + TestType + ", TestGroupNum=" + TestGroupNum
                + ", SaveDataEN=" + SaveDataEN + ", NT_DCDC_State=" + NT_DCDC_State + ", MonomerLowCount="
                + Arrays.toString(MonomerLowCount) + ", TestCur=" + Arrays.toString(TestCur) + ", GroupVol="
                + Arrays.toString(GroupVol) + ", OnlineVol=" + Arrays.toString(OnlineVol) + ", TestCapInt="
                + Arrays.toString(TestCapInt) + ", GroupCapInt=" + Arrays.toString(GroupCapInt) + ", GroupRestCapInt="
                + Arrays.toString(GroupRestCapInt) + ", MonMaxNum=" + Arrays.toString(MonMaxNum) + ", MonMinNum="
                + Arrays.toString(MonMinNum) + ", MonMaxValue=" + Arrays.toString(MonMaxValue) + ", MonMinValue="
                + Arrays.toString(MonMinValue) + ", RestTest_Time=" + Arrays.toString(RestTest_Time) + ", TestCap="
                + Arrays.toString(TestCap) + ", GroupCap=" + Arrays.toString(GroupCap) + ", GroupRestCap="
                + Arrays.toString(GroupRestCap) + "]";
    }
}
src/main/java/com/whyc/charge/Fbs5100ChargeData.java
New file
@@ -0,0 +1,126 @@
package com.whyc.charge;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.List;
import com.whyc.dto.ComFn;
import com.whyc.dto.Fbs5100ComBase;
import org.springframework.stereotype.Component;
/**
 *     配网电源
 * @author LiJun
 *    充电数据结构体
 */
@Component
public class Fbs5100ChargeData {
    public Fbs5100BattParam battParam;            //电池参数
    public Fbs5100ChargeParam chargeParam;        //测试参数
    public Fbs5100ChargeState chargeState;        //容量状态
    public List<Fbs5100FbsData> fbsDatas;
    public int parse_result = Fbs5100ComBase.PARSE_RESULT_NULL;
    public Fbs5100ChargeData() {
        battParam = new Fbs5100BattParam();
        chargeParam = new Fbs5100ChargeParam();
        chargeState = new Fbs5100ChargeState();
        fbsDatas = new ArrayList<Fbs5100FbsData>();
    }
    public void parseFileData(String filePath)
    {
        FileInputStream fis = null;
        try {
            File f = new File(filePath);
            //非充电文件
            if(!filePath.endsWith(".CHR")) {
                parse_result = Fbs5100ComBase.PARSE_RESULT_FILETYPEERR;
                return;
            }
            if(!f.exists()) {
                parse_result = Fbs5100ComBase.PARSE_RESULT_NOTFOUNDFILE;
                return;
                //System.out.println("文件不存在..........");
            }
            fis = new FileInputStream(f);
            byte[] buf = new byte[1024];
            if(fis.read(buf, 0, buf.length) == 1024)
            {
                if(this.readDataHead(buf)) {
                    parse_result = Fbs5100ComBase.PARSE_RESULT_SUCCESS;
                }else {
                    parse_result = Fbs5100ComBase.PARSE_RESULT_FILEERROR;
                }
                while(true)
                {
                    Fbs5100FbsData fbsData = new Fbs5100FbsData();
                    int tag = fbsData.checkDataHead(fis);
                    if((0xFD == tag) || (0xFC == tag) || (0xFB == tag))
                    {
                        byte[] databuf = new byte[Fbs5100FbsData.BYTE_LEN - 4];
                        if(fis.read(databuf) == databuf.length)
                        {
                            //System.out.println(ComFn.bytesToHexString(databuf, databuf.length));
                            if(fbsData.putByteBuffer(databuf)) {
                                fbsDatas.add(fbsData);
                            }
                        }
                    }
                    if(tag == 1)
                        break;
                }
            }else {
                parse_result = Fbs5100ComBase.PARSE_RESULT_FILEERROR;
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if(null != fis)
            {
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    //解析数据头
    public boolean readDataHead(byte[] buf) {
        //System.out.println(ComFn.bytesToHexString(buf, buf.length));
        boolean flag = false;
        if(buf.length < (Fbs5100BattParam.BYTE_LEN + Fbs5100ChargeParam.BYTE_LEN + Fbs5100ChargeState.BYTE_LEN)) {
            //System.out.println("头部数据长度异常");
            return flag;
        }
        ByteBuffer bf = ByteBuffer.allocate(buf.length);
        bf.order(ByteOrder.LITTLE_ENDIAN);
        bf.put(buf);
        bf.position(0);
        flag = this.battParam.putByteBuffer(bf);
        //System.out.println("battParam:"+flag);
        flag &= this.chargeParam.putByteBuffer(bf);
        //System.out.println("chargeParam:"+flag);
        flag &= this.chargeState.putByteBuffer(bf);
        //System.out.println("chargeState:"+flag);
        return flag;
    }
    @Override
    public String toString() {
        return "Fbs5100ChargeData [battParam=" + battParam + ", chargeParam=" + chargeParam + ", chargeState="
                + chargeState + ", fbsDatas=" + fbsDatas + ", parse_result=" + parse_result + "]";
    }
}
src/main/java/com/whyc/charge/Fbs5100ChargeParam.java
New file
@@ -0,0 +1,176 @@
package com.whyc.charge;
import com.whyc.dto.Fbs5100ComBase;
import com.whyc.dto.Fbs5100Crc16;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
/**
 *     充电参数
 * @author LiJun
 *
 */
public class Fbs5100ChargeParam {
    public static final int BYTE_LEN = 44;
    public int HourRate = 0;                    //小时率
    public double ChargeCurr = 0;                //充电电流
    public double ChargeCap = 0;                //充电容量
    public int ChargeTime = 0;                    //充电时间
    public double GroupVol_High = 0;            //组端电压上限
    public double MonomerVol_High = 0;            //单体电压上限
    public int MonomerHighCount = 0;            //单体电压上限数量
    public int BattGroupNum = 0;                //组号
    public int OnlineVolLowAction = 0;            //在线电压低处理
    public int StaticTime = 0;                    //静置时间
    public int ChargeTestCount = 0;                //充电测试次数
    public int bakeup1 = 0;
    public int bakeup2 = 0;
    public int bakeup3 = 0;
    public int bakeup4 = 0;
    public int bakeup5 = 0;
    public int bakeup6 = 0;
    public int bakeup7 = 0;
    public int bakeup8 = 0;
    public int bakeup9 = 0;
    public int bakeup10 = 0;
    public int CRC = 0;
    public Fbs5100ChargeParam clone()
    {
        Fbs5100ChargeParam obj = null;
        try
        {
            obj = (Fbs5100ChargeParam)super.clone();
        }
        catch(CloneNotSupportedException e)
        {
            e.printStackTrace();
        }
        return obj;
    }
    public void clear()
    {
        HourRate = 0;
        ChargeCurr = 0;
        ChargeCap = 0;
        ChargeTime = 0;
        GroupVol_High = 0;
        MonomerVol_High = 0;
        MonomerHighCount = 0;
        BattGroupNum = 0;
        OnlineVolLowAction = 0;
        StaticTime = 0;
        ChargeTestCount = 0;
        bakeup1 = 0;
        bakeup2 = 0;
        bakeup3 = 0;
        bakeup4 = 0;
        bakeup5 = 0;
        bakeup6 = 0;
        bakeup7 = 0;
        bakeup8 = 0;
        bakeup9 = 0;
        bakeup10 = 0;
        CRC = 0;
    }
    public boolean putByteBuffer(final ByteBuffer bf)
    {
        if(bf.limit() < BYTE_LEN)
            return false;
        ByteBuffer tmpbuf = bf;
        int crc0 = tmpbuf.getShort(BYTE_LEN-2) & 0xFFFF;
        int crc1 = Fbs5100Crc16.CalCRC16(tmpbuf, BYTE_LEN-2);
        if(crc0 != crc1)
            return false;
        tmpbuf.position(0);
        HourRate = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        ChargeCurr = Fbs5100ComBase.changeShortToDouble(tmpbuf.getShort());
        ChargeCap = Fbs5100ComBase.changeShortToDouble(tmpbuf.getShort());
        ChargeTime = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        GroupVol_High = Fbs5100ComBase.changeShortToDouble(tmpbuf.getShort())/10;
        MonomerVol_High = Fbs5100ComBase.changeShortToDouble(tmpbuf.getShort())/1000;
        MonomerHighCount = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        BattGroupNum = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        OnlineVolLowAction = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        StaticTime = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        ChargeTestCount = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup1 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup2 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup3 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup4 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup5 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup6 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup7 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup8 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup9 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup10 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        CRC = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        tmpbuf.compact();
        tmpbuf.flip();
        return true;
    }
    public ByteBuffer getByteBuffer()
    {
        ByteBuffer bytebuffer = ByteBuffer.allocate(BYTE_LEN);
        bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(HourRate));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(ChargeCurr));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(ChargeCap));
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(ChargeTime));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(GroupVol_High*10));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(MonomerVol_High*1000));
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(MonomerHighCount));
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(BattGroupNum));
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(OnlineVolLowAction));
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(StaticTime));
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(ChargeTestCount));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup1));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup2));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup3));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup4));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup5));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup6));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup7));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup8));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup9));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup10));
        CRC = Fbs5100Crc16.CalCRC16(bytebuffer, bytebuffer.position());
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(CRC));
        bytebuffer.flip();
        return bytebuffer;
    }
    @Override
    public String toString() {
        return "FBS9100_ParamCharge [BYTE_LEN=" + BYTE_LEN + ", HourRate=" + HourRate + ", ChargeCurr=" + ChargeCurr
                + ", ChargeCap=" + ChargeCap + ", ChargeTime=" + ChargeTime + ", GroupVol_High=" + GroupVol_High
                + ", MonomerVol_High=" + MonomerVol_High + ", MonomerHighCount=" + MonomerHighCount + ", BattGroupNum="
                + BattGroupNum + ", OnlineVolLowAction=" + OnlineVolLowAction + ", StaticTime=" + StaticTime
                + ", ChargeTestCount=" + ChargeTestCount + ", 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/charge/Fbs5100ChargeState.java
New file
@@ -0,0 +1,205 @@
package com.whyc.charge;
import com.whyc.dto.Fbs5100ComBase;
import com.whyc.dto.Fbs5100Crc16;
import com.whyc.dto.Fbs5100DateTime;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
public class Fbs5100ChargeState {
    public static final int BYTE_LEN = 120;
    private final int BATTGROUP_COUNT = Fbs5100ComBase.BattGroupCountMax;
    public Fbs5100DateTime StartDT = new Fbs5100DateTime();                //启动放电的日期时间
    public Fbs5100DateTime StopDT = new Fbs5100DateTime();                //终止放电的日期时间
    public Fbs5100TestTime Test_Time = new Fbs5100TestTime();                //已测试时间(HMS)
    public int TestState;                    //测试状态(停止/暂停/放电)
    public int TestType;                    //测试类型(放电/充电)
    public int TestGroupNum;                //被测试电池组编号(1~4)
    public int SaveDataEN;                    //保存数据标识
    public int ChargeEN;                    //开始充电标识
    public int ChargeOverTime;                //充电过流超时
    public int LastCapTestAlarmRes;            //上次容量放电测试结果
    public double TestCur[] = new double[Fbs5100ComBase.BattGroupCountMax];
    public double GroupVol[] = new double[Fbs5100ComBase.BattGroupCountMax];
    public double OnlineVol[] = new double[Fbs5100ComBase.BattGroupCountMax];
    public double TestCapInt[] = new double[Fbs5100ComBase.BattGroupCountMax];
    public int MonMaxNum[] = new int[Fbs5100ComBase.BattGroupCountMax];
    public int MonMinNum[] = new int[Fbs5100ComBase.BattGroupCountMax];
    public double MonMaxValue[] = new double[Fbs5100ComBase.BattGroupCountMax];
    public double MonMinValue[] = new double[Fbs5100ComBase.BattGroupCountMax];
    public double TestCap[] = new double[Fbs5100ComBase.BattGroupCountMax];    //每组已测试容量
    public int    CRC;
    public Fbs5100ChargeState clone()
    {
        Fbs5100ChargeState obj = null;
        try
        {
            obj = (Fbs5100ChargeState)super.clone();
        }
        catch(CloneNotSupportedException e)
        {
            e.printStackTrace();
        }
        return obj;
    }
    public boolean putByteBuffer(final ByteBuffer bf)
    {
        if(bf.limit() < BYTE_LEN)
            return false;
        ByteBuffer tmpbuf = bf;
        int crc0 = tmpbuf.getShort(BYTE_LEN-2) & 0xFFFF;
        int crc1 = Fbs5100Crc16.CalCRC16(tmpbuf, BYTE_LEN-2);
        if(crc0 != crc1) {
            System.err.println("Fbs5100ChargeState:"+crc0+"=="+crc1);
            //return false;
        }
        tmpbuf.position(0);
        StartDT.year = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        StartDT.month = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        StartDT.day = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        StartDT.hour = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        StartDT.minute = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        StartDT.second = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        StopDT.year     = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        StopDT.month = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        StopDT.day     = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        StopDT.hour  = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        StopDT.minute = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        StopDT.second = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        Test_Time.hour = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        Test_Time.minute = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        Test_Time.second = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        TestState = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        TestType = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        TestGroupNum = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        SaveDataEN = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        ChargeEN = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        ChargeOverTime = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        LastCapTestAlarmRes = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        for(int n=0; n<BATTGROUP_COUNT; n++)
            TestCur[n] = Fbs5100ComBase.changeShortToDouble(tmpbuf.getShort()) / 10;
        for(int n=0; n<BATTGROUP_COUNT; n++)
            GroupVol[n] = Fbs5100ComBase.changeShortToDouble(tmpbuf.getShort()) / 10;
        for(int n=0; n<BATTGROUP_COUNT; n++)
            OnlineVol[n] = Fbs5100ComBase.changeShortToDouble(tmpbuf.getShort()) / 10;
        for(int n=0; n<BATTGROUP_COUNT; n++)
            TestCapInt[n] = Fbs5100ComBase.changeShortToDouble(tmpbuf.getShort());
        for(int n=0; n<BATTGROUP_COUNT; n++)
            MonMaxNum[n] = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        for(int n=0; n<BATTGROUP_COUNT; n++)
            MonMinNum[n] = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        for(int n=0; n<BATTGROUP_COUNT; n++)
            MonMaxValue[n] = Fbs5100ComBase.changeShortToDouble(tmpbuf.getShort()) / 1000;
        for(int n=0; n<BATTGROUP_COUNT; n++)
            MonMinValue[n] = Fbs5100ComBase.changeShortToDouble(tmpbuf.getShort()) / 1000;
        for(int n=0; n<BATTGROUP_COUNT; n++) {
            TestCap[n] = tmpbuf.getDouble();
        }
        //System.out.println(this);
        tmpbuf.compact();
        tmpbuf.flip();
        return true;
    }
    public ByteBuffer getByteBuffer()
    {
        ByteBuffer bytebuffer = ByteBuffer.allocate(BYTE_LEN);
        bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
        bytebuffer.put(Fbs5100ComBase.changeIntToByte(StartDT.year));
        bytebuffer.put(Fbs5100ComBase.changeIntToByte(StartDT.month));
        bytebuffer.put(Fbs5100ComBase.changeIntToByte(StartDT.day));
        bytebuffer.put(Fbs5100ComBase.changeIntToByte(StartDT.hour));
        bytebuffer.put(Fbs5100ComBase.changeIntToByte(StartDT.minute));
        bytebuffer.put(Fbs5100ComBase.changeIntToByte(StartDT.second));
        bytebuffer.put(Fbs5100ComBase.changeIntToByte(StopDT.year));
        bytebuffer.put(Fbs5100ComBase.changeIntToByte(StopDT.month));
        bytebuffer.put(Fbs5100ComBase.changeIntToByte(StopDT.day));
        bytebuffer.put(Fbs5100ComBase.changeIntToByte(StopDT.hour));
        bytebuffer.put(Fbs5100ComBase.changeIntToByte(StopDT.minute));
        bytebuffer.put(Fbs5100ComBase.changeIntToByte(StopDT.second));
        bytebuffer.put(Fbs5100ComBase.changeIntToByte(Test_Time.hour));
        bytebuffer.put(Fbs5100ComBase.changeIntToByte(Test_Time.minute));
        bytebuffer.put(Fbs5100ComBase.changeIntToByte(Test_Time.second));
        bytebuffer.put(Fbs5100ComBase.changeIntToByte(TestState));
        bytebuffer.put(Fbs5100ComBase.changeIntToByte(TestType));
        bytebuffer.put(Fbs5100ComBase.changeIntToByte(TestGroupNum));
        bytebuffer.put(Fbs5100ComBase.changeIntToByte(SaveDataEN));
        bytebuffer.put(Fbs5100ComBase.changeIntToByte(ChargeEN));
        bytebuffer.put(Fbs5100ComBase.changeIntToByte(ChargeOverTime));
        bytebuffer.put(Fbs5100ComBase.changeIntToByte(LastCapTestAlarmRes));
        for(int n=0; n<BATTGROUP_COUNT; n++)
            bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(TestCur[n]*10));
        for(int n=0; n<BATTGROUP_COUNT; n++)
            bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(GroupVol[n]*10));
        for(int n=0; n<BATTGROUP_COUNT; n++)
            bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(OnlineVol[n]*10));
        for(int n=0; n<BATTGROUP_COUNT; n++)
            bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(TestCapInt[n]));
        for(int n=0; n<BATTGROUP_COUNT; n++)
            bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(MonMaxNum[n]));
        for(int n=0; n<BATTGROUP_COUNT; n++)
            bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(MonMinNum[n]));
        for(int n=0; n<BATTGROUP_COUNT; n++)
            bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(MonMaxValue[n]*1000));
        for(int n=0; n<BATTGROUP_COUNT; n++)
            bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(MonMinValue[n]*1000));
        CRC = Fbs5100Crc16.CalCRC16(bytebuffer, bytebuffer.capacity()-2);
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(CRC));
        bytebuffer.flip();
        System.out.println("bytebuffer  limit:"+bytebuffer.limit());
        return bytebuffer;
    }
    @Override
    public String toString() {
        return "Fbs5100ChargeState [StartDT=" + StartDT + ", StopDT=" + StopDT + ", Test_Time=" + Test_Time
                + ", TestState=" + TestState + ", TestType=" + TestType + ", TestGroupNum=" + TestGroupNum
                + ", SaveDataEN=" + SaveDataEN + ", ChargeEN=" + ChargeEN + ", ChargeOverTime=" + ChargeOverTime
                + ", LastCapTestAlarmRes=" + LastCapTestAlarmRes + ", TestCur=" + Arrays.toString(TestCur)
                + ", GroupVol=" + Arrays.toString(GroupVol) + ", OnlineVol=" + Arrays.toString(OnlineVol)
                + ", TestCapInt=" + Arrays.toString(TestCapInt) + ", MonMaxNum=" + Arrays.toString(MonMaxNum)
                + ", MonMinNum=" + Arrays.toString(MonMinNum) + ", MonMaxValue=" + Arrays.toString(MonMaxValue)
                + ", MonMinValue=" + Arrays.toString(MonMinValue) + ", TestCap=" + Arrays.toString(TestCap) + "]";
    }
}
src/main/java/com/whyc/charge/Fbs5100DisChargeData.java
New file
@@ -0,0 +1,128 @@
package com.whyc.charge;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.List;
import com.whyc.dto.ComFn;
import com.whyc.dto.Fbs5100ComBase;
import org.springframework.stereotype.Component;
/**
 *     配网电源
 * @author LiJun
 *
 */
@Component
public class Fbs5100DisChargeData {
    public Fbs5100BattParam battParam;        //电池参数
    public Fbs5100TestParam testParam;        //测试参数
    public Fbs5100CapState capState;        //容量状态
    public List<Fbs5100FbsData> fbsDatas;
    public int parse_result = Fbs5100ComBase.PARSE_RESULT_NULL;
    public Fbs5100DisChargeData() {
        battParam = new Fbs5100BattParam();
        testParam = new Fbs5100TestParam();
        capState = new Fbs5100CapState();
        fbsDatas = new ArrayList<Fbs5100FbsData>();
    }
    public void parseFileData(String filePath)
    {
        FileInputStream fis = null;
        try {
            File f = new File(filePath);
            //既不是核容放电也不是监测放电
            if(!filePath.endsWith(".BCP") && !filePath.endsWith(".MCP")) {
                parse_result = Fbs5100ComBase.PARSE_RESULT_FILETYPEERR;
                return;
            }
            if(!f.exists()) {
                parse_result = Fbs5100ComBase.PARSE_RESULT_NOTFOUNDFILE;
                return;
                //System.out.println("文件不存在..........");
            }
            fis = new FileInputStream(f);
            byte[] buf = new byte[1024];
            if(fis.read(buf, 0, buf.length) == 1024)
            {
                if(this.readDataHead(buf)) {
                    parse_result = Fbs5100ComBase.PARSE_RESULT_SUCCESS;
                }else {
                    parse_result = Fbs5100ComBase.PARSE_RESULT_FILEERROR;
                }
                while(true)
                {
                    Fbs5100FbsData fbsData = new Fbs5100FbsData();
                    int tag = fbsData.checkDataHead(fis);
                    if((0xFD == tag) || (0xFC == tag) || (0xFB == tag))
                    {
                        byte[] databuf = new byte[Fbs5100FbsData.BYTE_LEN - 4];
                        if(fis.read(databuf) == databuf.length)
                        {
                            //System.out.println(ComFn.bytesToHexString(databuf, databuf.length));
                            if(fbsData.putByteBuffer(databuf)) {
                                fbsDatas.add(fbsData);
                            }
                        }
                    }
                    if(tag == 1)
                        break;
                }
            }else {
                parse_result = Fbs5100ComBase.PARSE_RESULT_FILEERROR;
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if(null != fis)
            {
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    //解析数据头
    public boolean readDataHead(byte[] buf) {
        //System.out.println(ComFn.bytesToHexString(buf, buf.length));
        boolean flag = false;
        if(buf.length < (Fbs5100BattParam.BYTE_LEN + Fbs5100TestParam.BYTE_LEN + Fbs5100CapState.BYTE_LEN)) {
            //System.out.println("头部数据长度异常");
            return flag;
        }
        ByteBuffer bf = ByteBuffer.allocate(buf.length);
        bf.order(ByteOrder.LITTLE_ENDIAN);
        bf.put(buf);
        bf.position(0);
        flag = this.battParam.putByteBuffer(bf);
        //System.out.println("battParam:"+flag);
        flag &= this.testParam.putByteBuffer(bf);
        //System.out.println("testParam:"+flag);
        flag &= this.capState.putByteBuffer(bf);
        //System.out.println("capState:"+flag);
        return flag;
    }
    @Override
    public String toString() {
        return "Fbs5100DisChargeData [battParam=" + battParam + ", testParam=" + testParam + ", capState=" + capState
                + ", fbsDatas=" + fbsDatas + ", parse_result=" + parse_result + "]";
    }
}
src/main/java/com/whyc/charge/Fbs5100FbsData.java
New file
@@ -0,0 +1,278 @@
package com.whyc.charge;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
import com.whyc.dto.Fbs5100ComBase;
import com.whyc.dto.Fbs5100Crc16;
public class Fbs5100FbsData {
    public static final int BYTE_LEN = 10 + 20* Fbs5100ComBase.BattGroupCountMax;
    private final int BATTGROUP_COUNT = Fbs5100ComBase.BattGroupCountMax;
    private final int BASIC_LEN = 10 + 20*BATTGROUP_COUNT;
    //public FBS9100_SysState m_SysState = new FBS9100_SysState();
    public int dataType[] = {0xAA, 0xAA, 0xAA, 0xAA};
    public int CRC = 0;
    public Fbs5100TestTime testTime = new Fbs5100TestTime();
    public int battGroup = 1;
    public int battSum = 24;
    public int battGroupNum = 1;
    public float muxianvol_discharge;              //放电母线电压 24Vd+
    public float muxianvol_charge;                  //充电母线电压 24Vc+
    public float boostDCDC_OutVol;                  //升压DCDC输出电压 48Vd+
    public float muxianvol;                          //48V母线电压 48Vo+
    public int battXuHangTime = 0;
    public int stationPowerOffTLong = 0;
    public int stationPowerOffCNT = 0;
    public double conresist  = 0;                //组1接触器导通阻抗 (0.001mR)
    public double conresist1 = 0;                //组2接触器导通阻抗 (0.001mR)
    public double condvoldp  = 0;                //组1二极管压降(0.01V)
    public double condvoldp1 = 0;                //组2二极管压降(0.01V)
    public float onlinevol[] = new float[Fbs5100ComBase.BattGroupCountMax];        //在线电压
    public float groupvol[] = new float[Fbs5100ComBase.BattGroupCountMax];            //组端电压
    public int battstate[] = new int[Fbs5100ComBase.BattGroupCountMax];            //充放电状态     3   5   9
    public float battcurr[] = new float[Fbs5100ComBase.BattGroupCountMax];            //电池组电流
    public float battcap[] = new float[Fbs5100ComBase.BattGroupCountMax];            //电池组容量
    public float batttemp[] = new float[Fbs5100ComBase.BattGroupCountMax];          //电池组温度
    public int monMAX_num[] = new int[Fbs5100ComBase.BattGroupCountMax];            //最大单体编号
    public int monMIN_num[] = new int[Fbs5100ComBase.BattGroupCountMax];            //最低按单体编号
    public double monvolMAX[] = new double[Fbs5100ComBase.BattGroupCountMax];        //最大单体电压
    public double monvolMIN[] = new double[Fbs5100ComBase.BattGroupCountMax];        //最低单体电压
    public float vol[] = new float[Fbs5100ComBase.MonomerCountMax];                //单体电压
    public Fbs5100FbsData clone()
    {
        Fbs5100FbsData obj = new Fbs5100FbsData();
        //obj.m_SysState = (FBS9100_SysState) m_SysState.clone();
        obj.dataType = dataType.clone();
        obj.CRC = CRC;
        obj.testTime = testTime;
        obj.battGroup = battGroup;
        obj.battSum = battSum;
        obj.onlinevol = onlinevol.clone();
        obj.groupvol = groupvol.clone();
        obj.battstate = battstate.clone();
        obj.battcurr = battcurr.clone();
        obj.battcap = battcap.clone();
        obj.batttemp = batttemp.clone();
        obj.monMAX_num = monMAX_num.clone();
        obj.monMIN_num = monMIN_num.clone();
        obj.monvolMAX = monvolMAX.clone();
        obj.monvolMIN = monvolMIN.clone();
        obj.vol = vol.clone();
        return obj;
    }
    public void copy(Fbs5100FbsData source) {
        for(int i = 0 ; i < groupvol.length;i++) {
            this.groupvol[i] = source.groupvol[i];
        }
        for(int i = 0 ; i < battcurr.length;i++) {
            this.battcurr[i] = source.battcurr[i];
        }
        for(int i = 0 ; i < battstate.length;i++) {
            this.battstate[i] = source.battstate[i];
        }
        this.muxianvol_discharge = source.muxianvol_discharge;      //放电母线电压 24Vd+
        this.muxianvol_charge = source.muxianvol_charge;          //充电母线电压 24Vc+
        this.boostDCDC_OutVol = source.boostDCDC_OutVol;          //升压DCDC输出电压 48Vd+
        this.muxianvol = source.muxianvol;                          //48V母线电压 48Vo+
    }
    /**
     * 2021-05-11 911设备用于区分大功率假负载设备读取在线电压和组端电压数据修改
     * @return
     */
    public boolean putByteBuffer(byte[] data)
    {
        ByteBuffer bf = ByteBuffer.allocate(BASIC_LEN);
        bf.order(ByteOrder.LITTLE_ENDIAN);
        for(int i = 0 ;i<this.dataType.length;i++) {
            bf.put(Fbs5100ComBase.changeIntToByte(this.dataType[i]));
        }
        bf.put(data);
        bf.flip();
        //System.out.println(ComFn.bytesToHexString(bf.array(), bf.array().length));
        if(bf.limit() < BASIC_LEN) {
            System.out.println(bf.limit() + "==" + BASIC_LEN);
            return false;
        }
        int battcount = bf.getShort(10);
        if(battcount > Fbs5100ComBase.MonomerCountMax) {
            //System.out.println("单体数目"+battcount);
            return false;
        }
        ByteBuffer tmpbuf = bf;
        int crc0 = tmpbuf.getShort(4) & 0xFFFF;
        tmpbuf.putShort(4, (short) 0);
        int crc1 = Fbs5100Crc16.CalCRC16(tmpbuf, BASIC_LEN + 2*battcount);
        if(crc0 != crc1) {
            System.out.println(crc0 + "===" + crc1);
            return false;
        }
        tmpbuf.position(0);
        for(int n=0; n<4; n++)
            dataType[n] = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        CRC = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        testTime.hour = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        testTime.minute = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        testTime.second = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        battGroup = Fbs5100ComBase.changeByteToInt(tmpbuf.get());
        battSum = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        muxianvol_discharge = (float)Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort())/10;                    //放电母线电压 24Vd+
        muxianvol_charge = (float)Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort())/10;                  //充电母线电压 24Vc+
        boostDCDC_OutVol = (float)Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort())/10;                  //升压DCDC输出电压 48Vd+
        muxianvol = (float)Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort())/10;                          //48V母线电压 48Vo+
        /***  2020-12-04 lijun 逆变版本的设备在线电压和组端电压不用/10  ****/
        for(int n=0; n<BATTGROUP_COUNT; n++) {
            //float o_v = Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort())/100;
            onlinevol[n] = muxianvol;
        }
        for(int n=0; n<BATTGROUP_COUNT; n++) {
            float g_v = Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort())/10;
            groupvol[n] = g_v;
        }
        for(int n=0; n<BATTGROUP_COUNT; n++) {
            battcurr[n] = Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort())/10;
        }
        for(int n=0; n<BATTGROUP_COUNT; n++) {
            battstate[n] = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
            if(Fbs5100ComBase.BattState_Discharge == battstate[n]) {
                battcurr[n] *= -1;
            }
        }
        for(int n=0; n<BATTGROUP_COUNT; n++) {
            float b_cap = Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort());
            if(Fbs5100ComBase.BattState_Discharge == battstate[n]) {
                b_cap *= -1;
            }
            battcap[n] = b_cap;
        }
        for(int n=0; n<(BATTGROUP_COUNT-1); n++)
            /**
             * 2021-10-27 @lijun 修复温度<10度时,温度显示bug
             */
            //batttemp[n] = Fbs5100ComBase.changeShortToDouble((short)(tmpbuf.getShort()-(short)100))/10;
            batttemp[n] = Fbs5100ComBase.changeShortToFloat((short)(tmpbuf.getShort()))/10 -10;
        for(int n=0; n<BATTGROUP_COUNT; n++) {
            monMAX_num[n] = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        }
        battXuHangTime = (monMAX_num[0]<<16) + monMAX_num[1];
        stationPowerOffTLong = (monMAX_num[2]<<16) + monMAX_num[3];
        for(int n=0; n<BATTGROUP_COUNT; n++) {
            monMIN_num[n] = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        }
        stationPowerOffCNT = monMIN_num[0];
        for(int n=0; n<BATTGROUP_COUNT; n++)
            monvolMAX[n] = ((double)Fbs5100ComBase.changeShortToDouble(tmpbuf.getShort()))/100;
        conresist = monvolMAX[0]/10;
        conresist1 = monvolMAX[1]/10;
        condvoldp = monvolMAX[2];
        condvoldp1 = monvolMAX[3];
        //System.out.println(conresist+"=="+conresist1+"=="+condvoldp+"=="+condvoldp1);
        for(int n=0; n<BATTGROUP_COUNT; n++)
            monvolMIN[n] = Fbs5100ComBase.changeShortToDouble(tmpbuf.getShort())/1000;
        for(int n=0; n<battSum; n++) {
            vol[n] = Fbs5100ComBase.changeShortToFloat(tmpbuf.getShort())/1000;
        }
        tmpbuf.compact();
        tmpbuf.flip();
        System.out.println(this);
        return true;
    }
    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) {
            //e.printStackTrace();
        }
        setType(type_tag&0xFF);
        return (type_tag&0xFF);
    }
    private void setType(int type) {
        for(int i = 0;i<dataType.length;i++) {
            dataType[i] = type;
        }
    }
    @Override
    public String toString() {
        return "Fbs5100FbsData [dataType=" + Arrays.toString(dataType) + ", testTime=" + testTime + ", battGroup="
                + battGroup + ", battSum=" + battSum + ", battGroupNum=" + battGroupNum + ", muxianvol_discharge="
                + muxianvol_discharge + ", muxianvol_charge=" + muxianvol_charge + ", boostDCDC_OutVol="
                + boostDCDC_OutVol + ", muxianvol=" + muxianvol + ", conresist=" + conresist + ", conresist1="
                + conresist1 + ", condvoldp=" + condvoldp + ", condvoldp1=" + condvoldp1 + ", onlinevol="
                + Arrays.toString(onlinevol) + ", groupvol=" + Arrays.toString(groupvol) + ", battstate="
                + Arrays.toString(battstate) + ", battcurr=" + Arrays.toString(battcurr) + ", battcap="
                + Arrays.toString(battcap) + ", batttemp=" + Arrays.toString(batttemp) + "]";
    }
}
src/main/java/com/whyc/charge/Fbs5100TestParam.java
New file
@@ -0,0 +1,196 @@
package com.whyc.charge;
import com.whyc.dto.Fbs5100ComBase;
import com.whyc.dto.Fbs5100Crc16;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public class Fbs5100TestParam {
    public static final int BYTE_LEN = 44;
    //private final int BYTE_LEN = 45;
    public int HourRate = 0;                    //小时率
    public float DisCurr = 0;                    //放电电流A(1~50)
    public float DisCap = 0;                    //放电容量AH(10~9999)
    public int DisTime = 0;                        //放电时长Min(1~9999)
    public float GroupVol_LOW = 0;                //组端下限(0.1V  18~28.8)
    public float MonomerVol_LOW = 0;            //单体电压下限
    public int MonomerLowCount = 0;                //单体下限数量
    public int BattGroupNum = 0;                //组号 [0-全组一起测试   1~4分别代表单组放电]
    public int OnlineVolLowAction = 0;            //在线电压低处理
    public int StaticTime = 0;                    //静置时间
    public int DisTestCount = 0;                //放电测试次数
    public float DCVolHighLimit = 0;            //升压上限(0.1V  48.0~54.0)
    public float ChargeCurrSet = 0;                //充电电流(1~50A)
    public int DisTestType = 0;                    //放电测试类型
    public float MonomerTmp_High = 0;            //单体温度上限
    public int bakeup5 = 0;
    public int bakeup6 = 0;
    public int bakeup7 = 0;
    public int bakeup8 = 0;
    public int bakeup9 = 0;
    public int bakeup10 = 0;
    public int CRC = 0;
    public Fbs5100TestParam clone()
    {
        Fbs5100TestParam obj = null;
        try
        {
            obj = (Fbs5100TestParam)super.clone();
        }
        catch(CloneNotSupportedException e)
        {
            e.printStackTrace();
        }
        return obj;
    }
    public void clear()
    {
        HourRate = 0;
        DisCurr = 0;
        DisCap = 0;
        DisTime = 0;
        GroupVol_LOW = 0;
        MonomerVol_LOW = 0;
        MonomerLowCount = 0;
        BattGroupNum = 0;
        OnlineVolLowAction = 0;
        StaticTime = 0;
        DisTestCount = 0;
        DCVolHighLimit = 0;
        ChargeCurrSet = 0;
        DisTestType = 0;
        MonomerTmp_High = 0;
        bakeup5 = 0;
        bakeup6 = 0;
        bakeup7 = 0;
        bakeup8 = 0;
        bakeup9 = 0;
        bakeup10 = 0;
        CRC = 0;
    }
    public boolean putByteBuffer(final ByteBuffer bf)
    {
        if(bf.limit() < BYTE_LEN){
            return false;
        }
        ByteBuffer tmpbuf = bf;
        int crc0 = tmpbuf.getShort(BYTE_LEN-2) & 0xFFFF;
        int crc1 = Fbs5100Crc16.CalCRC16(tmpbuf, BYTE_LEN-2);
        if(crc0 != crc1){
            System.out.println("Fbs5100TestParam:" + crc0 + "===" + crc1);
            return false;
        }
        tmpbuf.position(0);
        HourRate = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        DisCurr = (float)Fbs5100ComBase.changeShortToDouble(tmpbuf.getShort());
        DisCap = (float)Fbs5100ComBase.changeShortToDouble(tmpbuf.getShort());
        DisTime = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        GroupVol_LOW = (float)Fbs5100ComBase.changeShortToDouble(tmpbuf.getShort())/10;
        MonomerVol_LOW = (float)Fbs5100ComBase.changeShortToDouble(tmpbuf.getShort())/1000;
        MonomerLowCount = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        BattGroupNum = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        OnlineVolLowAction = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        StaticTime = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        DisTestCount = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        DCVolHighLimit = (float)Fbs5100ComBase.changeShortToDouble(tmpbuf.getShort())/10;
        ChargeCurrSet = (float)Fbs5100ComBase.changeShortToDouble(tmpbuf.getShort());
        DisTestType = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        MonomerTmp_High = (float)Fbs5100ComBase.changeShortToDouble(tmpbuf.getShort())/10;
        bakeup5 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup6 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup7 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup8 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup9 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        bakeup10 = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        CRC = Fbs5100ComBase.changeShortToInt(tmpbuf.getShort());
        tmpbuf.compact();
        tmpbuf.flip();
        //System.out.println(this);
        return true;
    }
    public ByteBuffer getByteBuffer()
    {
        System.out.println(this);
        ByteBuffer bytebuffer = ByteBuffer.allocate(BYTE_LEN);
        bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(HourRate));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(DisCurr));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(DisCap));
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(DisTime));
        //bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort((GroupVol_LOW+0.000001)*10));
        bytebuffer.putShort(Fbs5100ComBase.changeFloatToShort((GroupVol_LOW)*10));
        bytebuffer.putShort(Fbs5100ComBase.changeFloatToShort((MonomerVol_LOW)*1000));
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(MonomerLowCount));
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(BattGroupNum));
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(OnlineVolLowAction));
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(StaticTime));
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(DisTestCount));
        bytebuffer.putShort(Fbs5100ComBase.changeFloatToShort((DCVolHighLimit)*10));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(ChargeCurrSet));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(DisTestType));
        bytebuffer.putShort(Fbs5100ComBase.changeFloatToShort((MonomerTmp_High)*10));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup5));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup6));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup7));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup8));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup9));
        bytebuffer.putShort(Fbs5100ComBase.changeDoubleToShort(bakeup10));
        CRC = Fbs5100Crc16.CalCRC16(bytebuffer, bytebuffer.position());
        bytebuffer.putShort(Fbs5100ComBase.changeIntToShort(CRC));
        //System.out.println(this+"$$$$$$$$$$$$$$$$$$$$$$$$$");
        bytebuffer.flip();
        return bytebuffer;
    }
    @Override
    public String toString() {
        return "Fbs5100TestParam [HourRate=" + HourRate + ", DisCurr=" + DisCurr
                + ", DisCap=" + DisCap + ", DisTime=" + DisTime + ", GroupVol_LOW=" + GroupVol_LOW + ", MonomerVol_LOW="
                + MonomerVol_LOW + ", MonomerLowCount=" + MonomerLowCount + ", BattGroupNum=" + BattGroupNum
                + ", OnlineVolLowAction=" + OnlineVolLowAction + ", StaticTime=" + StaticTime + ", DisTestCount="
                + DisTestCount + ", DCVolHighLimit=" + DCVolHighLimit + ", ChargeCurrSet=" + ChargeCurrSet
                + ", DisTestType=" + DisTestType + ", MonomerTmp_High=" + MonomerTmp_High + "]";
    }
    public static void main(String[] args) {
        double d = 56.6;
        float f = (float)d;
        float ff = (56.6f)*10;
        System.err.println(f);
        double dd = 56.6;
        System.out.println("dd:"+dd);
        Fbs5100ComBase.changeDoubleToShort((dd)*10);
        System.out.println((int)ff);
    }
}
src/main/java/com/whyc/charge/Fbs5100TestTime.java
New file
@@ -0,0 +1,62 @@
package com.whyc.charge;
import com.whyc.dto.Fbs5100ComBase;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public class Fbs5100TestTime {
    public int hour = 0;
    public int minute = 0;
    public int second = 0;
    public void putByteBuffer(final ByteBuffer bf)
    {
        hour = Fbs5100ComBase.changeByteToInt(bf.get());
        minute = Fbs5100ComBase.changeByteToInt(bf.get());
        second = Fbs5100ComBase.changeByteToInt(bf.get());
    }
    public ByteBuffer getBytes()
    {
        ByteBuffer bytebuffer = ByteBuffer.allocate(6);
        bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
        bytebuffer.put(Fbs5100ComBase.changeIntToByte(hour));
        bytebuffer.put(Fbs5100ComBase.changeIntToByte(minute));
        bytebuffer.put(Fbs5100ComBase.changeIntToByte(second));
        bytebuffer.flip();
        return bytebuffer;
    }
    public int getSecondCount()
    {
        return (hour*3600 + minute*60 + second);
    }
    public static int getMinutesCount(String str)
    {
        int mcount = 0;
        try
        {
            // 先找到字符串中:的位置
            int position = str.indexOf(":");
            // 将每个:之间的字符串转换成整型
            mcount = Integer.parseInt(str.substring(0, position))*60;
            mcount += Integer.parseInt(str.substring(position + 1));
        }
        catch(Exception e)
        {
            mcount = 0;
        }
        return mcount;
    }
    @Override
    public String toString() {
        return "Fbs5100TestTime [hour=" + hour + ", minute=" + minute + ", second=" + second + "]";
    }
}
src/main/java/com/whyc/controller/AnalysisController.java
New file
@@ -0,0 +1,74 @@
package com.whyc.controller;
import com.whyc.alarm.Fbs5100AlarmData;
import com.whyc.charge.Fbs5100ChargeData;
import com.whyc.charge.Fbs5100DisChargeData;
import com.whyc.pojo.Response;
import com.whyc.service.Fbs5100AlarmDataService;
import com.whyc.service.Fbs5100ChargeDataService;
import com.whyc.service.Fbs5100DisChargeDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Locale;
@RestController
@Api(tags = "解析文件")
@RequestMapping("analysis")
public class AnalysisController {
    @Autowired
    private Fbs5100DisChargeDataService disChargeDataService;
    @Autowired
    private Fbs5100ChargeDataService chargeDataService;
    @Autowired
    private Fbs5100AlarmDataService alarmDataService;
    @GetMapping("/readFboFile")
    @ApiOperation(value = "根据文件后缀解析不同的文件")
    public Response readFboFile(@RequestParam String filePath){
        String suffix=filePath.substring(filePath.lastIndexOf(".")+1).toLowerCase(Locale.ROOT);
        Response response=new Response();
        switch (suffix){
            case "bcp"://放电数据
                Fbs5100DisChargeData disChargeData = disChargeDataService.readFboFile(filePath);
                response.set(1,disChargeData,filePath);
                break;
            case "chr"://充电数据
                Fbs5100ChargeData chargeData=chargeDataService.readFileData(filePath);
                response.set(1,chargeData,filePath);
                break;
            case "alm"://告警数据
                Fbs5100AlarmData alarmData=alarmDataService.readFileData(filePath);
                response.set(1,alarmData,filePath);
                break;
            default:response.set(1,false,filePath);
        }
        return response;
    }
    /*@PostMapping("/export")
    @ApiOperation(value = "文件导出")
    public void export(HttpServletRequest req, HttpServletResponse resp ){
        String filePath = req.getParameter("filePath");
        String suffix=filePath.substring(filePath.lastIndexOf(".")+1).toLowerCase(Locale.ROOT);
        switch (suffix){
            case "fbx":exportService.exportFbx(req,resp);
                break;
            case "bres":exportService.exportBres(req,resp);
                break;
            *//*case "alm":exportService.exportAlm(req,resp);
                break;*//*
            case "mcp":exportService.exportMcph(req,resp);
                break;
            case "mch":exportService.exportMcph(req,resp);
                break;
        }
    }*/
}
src/main/java/com/whyc/controller/TestController.java
@@ -11,7 +11,7 @@
import java.util.Locale;
@RestController
@Api(tags = "解析文件")
@Api(tags = "测试")
@RequestMapping("test")
public class TestController {
src/main/java/com/whyc/dto/ComFn.java
New file
@@ -0,0 +1,19 @@
package com.whyc.dto;
public class ComFn {
    public static String bytesToHexString(byte[] src, int len){
        StringBuilder stringBuilder = new StringBuilder("");
        if (src == null || len <= 0) {
            return null;
        }
        for (int i = 0; i < len; i++) {
            int v = src[i] & 0xFF;
            String hv = Integer.toHexString(v).toUpperCase();
            if (hv.length() < 2) {
                stringBuilder.append(0);
            }
            stringBuilder.append(hv + " ");
        }
        return stringBuilder.toString();
    }
}
src/main/java/com/whyc/dto/Fbs5100ComBase.java
New file
@@ -0,0 +1,464 @@
package com.whyc.dto;
public class Fbs5100ComBase
{
    //------------------------ 测试类型  ----------------------------------------------------
    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     BattGroupCountMax                =    4;
    public static final int     MonomerCountMax                    =    480;
    //----------------------------------------------------------------------------
    public static final int     BTS_DCDC_CountMax                =    8;
    public static final int     LIBTS_DCDC_CountMax                =     4;                    //锂电BTS的最大DCDC模块信息
    //----------------------------------------------------------------------------
    public static final int     CMD_NULL                        =    0x00;
    //----------------------------------------------------------------------------
    //------------ 重启FBS9100设备 ------------------------------------------------
    public static final int     CMD_ResetSystemAck                =     0x0F;
    public static final int     CMD_ResetSystem                    =     0x10;
    //------------ 升级FBS9100软件 ------------------------------------------------
    public static final int     CMD_SystemUpdate                =    0x11;
    public static final int     CMD_SystemUpdateAck                =    0x12;
    //----------------------------------------------------------------------------
    //------------ 读取设备版本号、实时任务列表等 ----------------------------------
    public static final int     CMD_GetDeviceInf                =    0x15;
    public static final int     CMD_GetDeviceTaskInfAck            =    0x16;
    public static final int     CMD_GetDeviceTaskInf            =    0x17;
    public static final int        CMD_GetSyslogFileLen            =    0x18;
    public static final int        CMD_GetSyslogFileStr            =    0x19;
    public static final int        CMD_ClearSyslogFile                =    0x1A;
    public static final int      CMD_Connect                     =    0x20;
    public static final int      CMD_GetState                     =    0x22;
    //public static final int     CMD_GETDEVID                  =   0x23;        //获取设备id
    //----------------------------------------------------------------------------
    //------------ 启动放电测试和读取设置参数,读取放电测试状态----------------------
    public static final int     CMD_StartDischarge                =    0x25;
    public static final int     CMD_StartDischargeAck            =    0x26;
    public static final int     CMD_SetDischargeParmAck            =    0x27;
    public static final int     CMD_SetDischargeParm            =    0x28;
    public static final int     CMD_GetDischargeParm            =    0x29;
    public static final int     CMD_GetDischargeParmAck            =    0x30;
    public static final int     CMD_GetDischargeState            =    0x31;
    //----------------------------------------------------------------------------
    //------------ 启动内阻测试和读取内阻测试状态-----------------------------------
    public static final int     CMD_StartResDischarge            =    0x32;
    public static final int        CMD_GetResTestState                =    0x34;
    //-----------------------------------------------------------------------------
    //------------ 读取和设置电池参数-----------------------------------------------
    public static final int        CMD_GetBattParam                =    0x36;
    public static final int        CMD_SetBattParam                =    0x37;
    public static final int        CMD_GetBattParamACK                =    0x38;
    public static final int        CMD_SetBattParamACK                =    0x39;
    //----------------------------------------------------------------------------
    //------------ 启动充电测试和读取设置参数,读取充电测试状态-----------------------
    public static final int     CMD_StartCharge                    =    0x40;
    public static final int      CMD_SetChargeParm                =    0x43;
    public static final int      CMD_GetChargeParm                =    0x44;
    public static final int     CMD_GetChargeState                =    0x46;
    public static final int     CMD_Set_BattOFFLine                =    0x4A;
    public static final int     CMD_Set_BattONLine                =    0x4B;
    //-----------------------------------------------------------------------------
    //------------ 停止任何的测试 --------------------------------------------------
    public static final int     CMD_Start                        =    0x51;
    public static final int     CMD_StartAck                    =    0x52;
    public static final int     CMD_Stop                        =    0x53;
    public static final int     CMD_StopAck                        =    0x54;
    //----------------------------------------------------------------------------
    //------------ 读取电压电流、充放电测试、内阻测试数据 ---------------------------
    public static final int     CMD_GetVIData                    =    0x60;
    public static final int      CMD_GetMonomerData                =    0x61;
    public static final int     CMD_GetMonomerRES                =    0x62;
    public static final int      CMD_GetMonomerCAP                =    0x63;
    public static final int      CMD_GetMonomerChargeCAP            =    0x64;
    public static final int      CMD_GetMonomerTMP                =    0x65;
    public static final int      CMD_GetMonomerJHcurr            =    0x66;
    public static final int     CMD_Get_DCDC_Data                =    0x67;        //铁塔版本获取DCDC命令
    public static final int     CMD_Get_K_D_TestData            =     0x68;
    public static final int     CMD_Result_Error                = - 0x01;        //操作失败
    public static final int     CMD_Result_Success                =    0x00;        //操作成功过
    public static final int     CMD_Result_Fail                    =    0x05;        //操作失败
    public static final int     CMD_Result_Work                    =    0x10;        //系统处于工作状态
    public static final int     CMD_Result_NotNull                =    0x11;        //句柄非空错误
    public static final int     CMD_Result_CreateErr            =    0x12;        //任务创建失败
    public static final int     CMD_Result_MemoryErr            =    0x13;        //内存申请错误
    public static final int     CMD_Result_OutErr                =    0x14;        //假负载失控
    public static final int     CMD_Result_OtherWork            =    0x15;        //其他设备在工作
    /**
     * 2021-08-31 @lijun  假负载版本新增均衡电流和漏液电压读取
     */
    public static final int     CMD_GetMonomerLYVolt            =    0x78;        //漏液电压
    public static final int     CMD_GetMonomerJHCUR                =    0x69;        //增加均衡电流
    public static final int     CMD_GetLiDCDCParam                =    0x8B;        //读取锂电DCDC参数
    public static final int     CMD_SetLiDCDCParam                =    0x8C;        //设置锂电DCDC参数
    public static final int     CMD_GetPbDCDCParam                =    0x8D;        //读取铅酸DCDC参数
    public static final int     CMD_SetPbDCDCParam                =    0x8E;        //设置铅酸DCDC参数
    public static final int     CMD_GetSXDCDCData                =    0x8F;        //读取双向DCDC内部数据
    public static final int     CMD_GetLiBMSData                =    0x95;        //读取锂电池BMS模拟量
    public static final int     CMD_GetLiBMSState                =    0x96;        //读取锂电池BMS告警量
    public static final int     CMD_ReStartDCDC                    =    0x9A;        //远程重启内部DCDC模块
    /**
     * 读取切换箱正负极开关状态
     */
    public static final int     CMD_ReadQHZZFZCDState            =    0xC3;        //读取切换箱正负极开关状态
    /**
     * 2022-01-06 edit by lijun 逆变设备新增机柜头数据
     *
     * 读取
     */
    public static final int     CMD_GetSimData                    =   0x99;        //读取逆变机柜头数据
    //------------ 平台锂电池命令 -----------------------------------------------------------------
    public static final int     CMD_GetLiDCDCParam_Ack            =     0x8D;        //读取锂电BTS参数成功
    public static final int      CMD_SetLiDCDCParam_Ack            =     0x8E;        //设置锂电BTS参数成功
    public static final int     CMD_GetSXDCDCData_Ack            =     0x92;        //读取双向DCDC内部数据成功
    public static final int     CMD_GetLiBMSData_Ack            =     0x93;        //读取锂电池BMS模拟量
    public static final int     CMD_GetLiBMSState_Ack            =     0x94;        //读取锂电池BMS告警量
    public static final int     CMD_ReStartDCDC_Ack                =    0x9B;        //远程重启内部DCDC模块成功
    //----------------------------------------------------------------------------------------
    //-----------------------------------------------------------------------------
    //------------ 在线电压校准 ----------------------------------------------------
    public static final int     CMD_GetOnlineVolAdjParam        =    0x6A;
    public static final int     CMD_SetOnlineVolAdjParam        =    0x6B;
    //------------ 组端电压校准 ----------------------------------------------------
    public static final int     CMD_GetBattGroupVolAdjParam        =    0x6C;
    public static final int     CMD_SetBattGroupVolAdjParam        =    0x6D;
    //------------ 放电电流校准 ----------------------------------------------------
    public static final int     CMD_GetDischargeCurrAdjParam    =    0x6E;
    public static final int     CMD_SetDischargeCurrAdjParam    =    0x6F;
    //------------ 充电电流校准 ----------------------------------------------------
    public static final int     CMD_GetChargeCurrAdjParam        =    0x70;
    public static final int     CMD_SetChargeCurrAdjParam        =    0x71;
    //------------ 单体内阻校准 ----------------------------------------------------
    public static final int     CMD_GetBattResAdjParam            =   0x72;
    public static final int     CMD_SetBattResAdjParam            =    0x73;
    //------------ 单体电压偏移/斜率校准 --------------------------------------------
    public static final int     CMD_GetMonVolAdjParam            =    0x74;
    public static final int     CMD_SetMonVolAdjOffset            =    0x75;
    public static final int     CMD_SetMonVolAdjSlope            =    0x76;
    public static final int     CMD_ResetMonVolAdjParam            =    0x77;
    //-----------------------------------------------------------------------------
    //------------ 设置日期时间 ----------------------------------------------------
    public static final int     CMD_SetDateTime                    =   0x7A;
    //------------ 读取设置系统参数和告警参数 ---------------------------------------
    public static final int     CMD_GetSYSSetParamAck            =    0x7E;
    public static final int     CMD_SetSYSSetParamAck            =    0x7F;
    public static final int     CMD_GetSYSSetParam                =    0x80;
    public static final int     CMD_SetSYSSetParam                =    0x81;
    public static final int     CMD_GetAlarmParam                =    0x82;
    public static final int     CMD_SetAlarmParam                =    0x83;
    public static final int     CMD_GetAlarmParamAck            =    0x84;
    public static final int     CMD_SetAlarmParamAck            =    0x85;
    public static final int     CMD_GetJuHengParam                =   0xC1;                    //读取均衡参数
    public static final int     CMD_GetJuHengParamAck            =   0xC2;                    //读取均衡参数成功
    public static final int     CMD_SetJuHengParam                =   0xC3;                    //设置均衡参数
    public static final int     CMD_SetJuHengParamAck            =   0xC4;                    //设置均衡参数成功
    //-------------- 清除告警     --------------------------------------------------
    public static final int        CMD_ClearSysAlarm               =   0xB8;                    //清除告警
    public static final int        CMD_ClearSysAlarm_ACK           =   0xB9;                    //清除告警成功
    //------------------------------------------------------------------------------
    //------------ DFU 命令 ---------------------------------------------------------
    public static final int     CMD_FBS9100_WriteDFU            =     0x86;
    public static final int     CMD_FBS9100_ReadDFU             =     0x87;
    //------------------------------------------------------------------------------
    //读取cmcc的电压电流
    public static final int     CMD_ReadCMCCVolCurr             =   0x8A;
    //读取GPRS模块的信号质量
    public static final int     CMD_ReadGPRSCSQ                 =   0x91;
    public static final int     CMD_ReadGPRSCSQAck                 =   0x92;
    //读取干节点数据
    public static final int     CMD_ReadStemNode                =   0xC2;
    //清除告警
    public static final int     CMD_ClearAlarm                    =   0x90;
    /**
     * 2023-04-25 @lijun 新增逆变器信息读取以及告警数据读取
     */
    public static final int     CMD_Get_DCAC_Data                =    0x90;                 //获取逆变器模块的数据
    public static final int     CMD_Get_AlarmData                =    0x96;                 //获取告警数据
    public static final int     CMD_Get_MOSSTATE                =    0x97;                 //获取MOS管状态
    /**
     *     @lijun 2021-11-13
     *     假负载BTS新增连接条阻抗信息以及温湿度信息读取
     */
    public static final int     CMD_ReadConnRes                    =   0x97;                    //读取连接条阻抗信息
    public static final int     CMD_ReadTmpHum                    =   0x98;                    //读取温湿度传感器信息
    public static final int     CMD_ReadBusCoupleState            =   0x9D;                    //读取智能母联状态
    public static final int     CMD_GetJunHengState                =   0xA8;                    //读取均衡供电模块信息
    public static final int     CMD_ReadJunHengParam            =   0xB0;                    //读取均衡参数信息
    public static final int     CMD_WriteJunHengParam            =   0xB1;                    //设置均衡参数信息
    //------------ 测试类型 ---------------------------------------------------------
    public static final int        TestType_NULL                    =    0x00;
    public static final int        TestType_VOL                    =    0xF9;
    public static final int        TestType_MDISCHARGE                =    0xFA;
    public static final int        TestType_MCHARGE                =    0xFB;
    public static final int        TestType_Charge                    =    0xFC;
    public static final int        TestType_CAP                    =    0xFD;                    //正常核容放电测试类型
    public static final int        TestType_RES                    =    0xFE;
    public static final int        TestType_Charge_HELUQI            =    0xBC;
    public static final int        TestType_CAP_HELUQI                =    0xBD;                    //升压续航放电测试类型
    public static final int        TestType_SwitchDiode            =     0xD1;                    //KD测试
    //------------------------------------------------------------------------------
    //------------ 电池状态 ---------------------------------------------------------
    public static final int        BattState_Float                    =    0x00;
    public static final int        BattState_Discharge                =    0x01;
    public static final int        BattState_Charge                =    0x02;
    //------------------------------------------------------------------------------
    //------------ 数据类型 ---------------------------------------------------------
    public static final int        DataType_Null                    =    0x00;
    public static final int        DataType_MonVol                    =    0x01;
    public static final int        DataType_MonCap                    =    0x02;
    public static final int        DataType_MonRes                    =    0x03;
    public static final int        DataType_Temp                    =    0x04;
    public static final int        DataType_GrpVol                    =    0x05;
    public static final int        DataType_Curr                    =    0x06;
    public static final int        DataType_MonTmp                    =    0x07;
    public static final int        DataType_MonJHcurr                =    0x08;                    //均衡电流
    public static final int     DataType_MonLYvol                =    0x09;                    //漏液电压
    public static final int     DataType_MonConnRes                =    0x10;                    //连接条阻抗
    //------------------------------------------------------------------------------
    //------------------------------------------------------------------------------
    public static final int     BTSE_DevType_TieTa                =    0x08;                    //铁塔版本的bt
    public static final int     BTSE_DevType_NiBian                =   0x06;                    //逆变版本的bts
    public static final int     BTSE_DevType_LIBTS                =   0x05;                    //锂电池版本的bts
    //------------------------------------------------------------------------------
    public static final int     SYS_STATE_STOPPED                =    0x00;
    public static final int     SYS_STATE_DISCHARGING            =    0x01;
    public static final int     SYS_STATE_CHARGING                =    0x02;
    public static final int     SYS_STATE_HELUQI_DISCHARGING    =    0x03;
    //------------------------------------------------------------------------------
    //-------------------------------------------------------------------------------------------
    public static final int     ALARM_NULL                         =    0;        //无
    public static final int     ALARM_PAUSED                    =    1;        //暂停
    public static final int     ALARM_DISCHARGING                =    2;        //正在放电测试
    public static final int     ALARM_DISCHARGEWAIT                =    3;        //正在等待放电
    public static final int     ALARM_LimitCHARGING                =    4;        //正在限流充电
    public static final int     ALARM_LargeCHARGING                =    5;        //正在直连充电
    public static final int     ALARM_CHARGEWAIT                   =    6;        //正在等待充电
    public static final int     ALARM_TIMESTOP                     =    7;        //放电时间到停止
    public static final int     ALARM_CAPSTOP                     =    8;        //放电容量到停止
    public static final int     ALARM_MVLLSTOP                     =    9;        //单体电压下限到停止
    public static final int     ALARM_SVLLSTOP                     =    10;        //组端电压下限到停止
    public static final int     ALARM_POWERBREAKSTOP             =    11;        //市电中断停止
    public static final int     ALARM_FLASHUPSTOP                 =    12;        //存储数据满停止
    public static final int     ALARM_TEMPHIGHSTOP               =    13;        //机内温度异常停止
    public static final int     ALARM_CURRSTOP                    =    14;        //放电电流过流停止
    public static final int     ALARM_PCCOMMBREAKSTOP             =    15;        //后台通信中断停止
    public static final int     ALARM_LoaderCOMMBREAKSTOP         =    16;        //负载模块通信中断停止
    public static final int     ALARM_Sel2TO1COMMBREAKSTOP         =    17;        //选择模块通信中断停止
    public static final int     ALARM_LoaderPowerError             =    18;        //负载模块放电过功率停止
    public static final int     ALARM_Malloc_ERROR                 =    19;        //内部程序异常停止
    public static final int     ALARM_POWERRESUMESTOP_HELUQI     =    20;        //合路器放电功能,市电恢复停止升压放电
    public static final int     ALARM_POWERBREAKSTOP_HELUQI     =    21;        //合路器放电功能,充电过程中市电中断
    public static final int     ALARM_SVLLSTOP_HELUQI             =    22;        //合路器放电功能组端电压下限
    public static final int     ALARM_MOMTEMP_HL_STOP             =    23;        //单体温度上限到停止
    public static final int     ALARM_ONLINEVOL_HL_STOP         =    24;        //在线电压异常高停止
    public static final int     ALARM_XIEZHUANG_COMM_ERR_STOP    =    25;        //协转通信异常停止
    public static final int     ALARM_MONOMER_COMM_ERR_STOP        =    26;        //单体通信异常停止
    public static final int     ALARM_UNKOWN                     =    27;        //未知
    //-------------------------------------------------------------------------------------------
    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;
        //System.out.println("tmp:"+tmp);
        return (short)(tmp & 0xFFFF);
    }
    public static short changeFloatToShort(float 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(int stdah, int current)
    {
        int index = 0;
        int value[]={514, 306, 250, 200, 166, 146, 131, 118, 108, 100, 55};
        int res;
        res = (current*100)/(stdah/10);
        if(res>=514) return 1;
        else if(res<=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;
    }
    //-------------------------------------------------------------------------------
    /*
    //-------------------------------------------------------------------------------
    double GetMonomerCap(double STDAH, int HourRate, double SumAH, double MaxMonomerVol,
                        double MonomerVol, double MonomerVolType, int CapType)
    {
        if(MaxMonomerVol - MonomerVolType*0.9 == 0)
            return 0;
        if(SumAH < 0)
            SumAH *= (-1);
        double tmp_cap;
        tmp_cap = MonomerVol - MonomerVolType * 0.9;
        tmp_cap *= (STDAH - SumAH * N_TO_10H(HourRate));
        tmp_cap = tmp_cap/(MaxMonomerVol - MonomerVolType*0.9);
        if(tmp_cap < 0)
            tmp_cap = 0;
        if(CapType == CapType_Rest)
            return tmp_cap;
        else if(CapType == CapType_Sum)
            return (tmp_cap + SumAH * N_TO_10H(HourRate));
        else
            return ((tmp_cap + SumAH * N_TO_10H(HourRate))*100 / STDAH);
    }
    //----------------------------------------------------------------------------------
    */
}
/***************************************************************************************
******************************* end of file (FBS_ComBase)*******************************
***************************************************************************************/
src/main/java/com/whyc/dto/Fbs5100Crc16.java
New file
@@ -0,0 +1,65 @@
package com.whyc.dto;
import java.nio.ByteBuffer;
public class Fbs5100Crc16
{
    private final static int CRC16Table[] =
    {
        0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
        0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
        0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6,
        0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE,
        0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485,
        0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D,
        0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4,
        0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC,
        0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823,
        0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B,
        0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12,
        0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A,
        0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41,
        0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49,
        0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70,
        0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78,
        0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F,
        0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
        0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E,
        0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256,
        0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D,
        0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
        0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C,
        0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634,
        0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB,
        0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3,
        0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A,
        0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92,
        0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9,
        0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1,
        0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8,
        0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
    };
    public static int CalCRC16(final ByteBuffer buf, int count)
    {
        ByteBuffer tmpbuf = buf;
        tmpbuf.position(0);
        int crc = 0xFFFF;    //�ؼ��Եij�ֵ...
        int tmp;
        for (int i=0; i<count; i++)
        {
                if(!buf.hasRemaining())
                    break;
                tmp = crc;
                crc = CRC16Table[(int)((((tmp&0xFFFF) >> 8) ^ (tmpbuf.get())) & 0xFF)];
                crc = crc ^ ((tmp&0xFFFF) << 8);
        }
        return (crc & 0xFFFF);
    }
}
/***************************************************************************************
****************************** end of file (FBS_Crc16) *********************************
***************************************************************************************/
src/main/java/com/whyc/dto/Fbs5100DateTime.java
New file
@@ -0,0 +1,82 @@
package com.whyc.dto;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Calendar;
import java.util.Date;
public class Fbs5100DateTime
    {
        public int year = 0;
        public int month = 1;
        public int day = 1;
        public int hour = 0;
        public int minute = 0;
        public int second = 0;
        public Date time = new Date(0);
        public Fbs5100DateTime clone()
        {
            Fbs5100DateTime obj = new Fbs5100DateTime();
            obj.year = year;
            obj.month = month;
            obj.day = day;
            obj.hour = hour;
            obj.minute = minute;
            obj.second = second;
            return obj;
        }
        public void putByteBuffer(final ByteBuffer bf)
        {
            year = Fbs5100ComBase.changeByteToInt(bf.get());
            month = Fbs5100ComBase.changeByteToInt(bf.get());
            day = Fbs5100ComBase.changeByteToInt(bf.get());
            hour = Fbs5100ComBase.changeByteToInt(bf.get());
            minute = Fbs5100ComBase.changeByteToInt(bf.get());
            second = Fbs5100ComBase.changeByteToInt(bf.get());
            time.setTime(getTimeInMillis());
        }
        public ByteBuffer getPCDateTimeBytes()
        {
            ByteBuffer bytebuffer = ByteBuffer.allocate(12);
            bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
            Calendar cad = Calendar.getInstance();
            //cad.set(23, 5, 10);
            bytebuffer.put(Fbs5100ComBase.changeIntToByte(cad.get(Calendar.YEAR)%100));
            bytebuffer.put(Fbs5100ComBase.changeIntToByte(cad.get(Calendar.MONTH)+1));
            bytebuffer.put(Fbs5100ComBase.changeIntToByte(cad.get(Calendar.DAY_OF_MONTH)));
            bytebuffer.put(Fbs5100ComBase.changeIntToByte(cad.get(Calendar.HOUR_OF_DAY)));
            bytebuffer.put(Fbs5100ComBase.changeIntToByte(cad.get(Calendar.MINUTE)));
            bytebuffer.put(Fbs5100ComBase.changeIntToByte(cad.get(Calendar.SECOND)));
            bytebuffer.flip();
            //System.out.println("设置时间:"+cad.get(Calendar.YEAR)+"-"+(cad.get(Calendar.MONTH)+1)+"-"+cad.get(Calendar.DAY_OF_MONTH)+" "+cad.get(Calendar.HOUR_OF_DAY)+":"+cad.get(Calendar.MINUTE)+":"+cad.get(Calendar.SECOND));
            return bytebuffer;
        }
        public long getTimeInMillis() {
            Calendar ca = Calendar.getInstance();
            int month_t = month;
            if(month_t > 0) {
                month_t -= 1;
            }
            ca.set(year+2000, month_t, day, hour, minute, second);
            return ca.getTimeInMillis();
        }
        @Override
        public String toString() {
            return "Fbs5100DateTime [year=" + year + ", month=" + month + ", day=" + day + ", hour=" + hour
                    + ", minute=" + minute + ", second=" + second + ", time=" + time + "]";
        }
}
src/main/java/com/whyc/service/Fbs5100AlarmDataService.java
New file
@@ -0,0 +1,17 @@
package com.whyc.service;
import com.whyc.alarm.Fbs5100AlarmData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class Fbs5100AlarmDataService {
    @Autowired(required = false)
    private Fbs5100AlarmData data;
    //告警数据
    public Fbs5100AlarmData readFileData(String filePath) {
        data.parseFileData(filePath);
        return data;
    }
}
src/main/java/com/whyc/service/Fbs5100ChargeDataService.java
New file
@@ -0,0 +1,17 @@
package com.whyc.service;
import com.whyc.charge.Fbs5100ChargeData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class Fbs5100ChargeDataService {
    @Autowired(required = false)
    private Fbs5100ChargeData data;
    //充电数据
    public Fbs5100ChargeData readFileData(String filePath) {
        data.parseFileData(filePath);
        return data;
    }
}
src/main/java/com/whyc/service/Fbs5100DisChargeDataService.java
New file
@@ -0,0 +1,20 @@
package com.whyc.service;
import com.whyc.charge.Fbs5100DisChargeData;
import com.whyc.charge.Fbs5100FbsData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class Fbs5100DisChargeDataService {
     @Autowired(required = false)
     private Fbs5100DisChargeData data;
    //放电数据
    public Fbs5100DisChargeData readFboFile(String filePath) {
        data.parseFileData(filePath);
        return data;
    }
}