lxw
2023-08-15 160e150009b51a39fa95d9462c3798ba28d51a09
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package com.whyc.abe;
 
import com.whyc.constant.ComBase;
import com.whyc.constant.Crc16;
 
import java.nio.ByteBuffer;
 
/**
 *     活化数据头结构体
 * @author LiJun
 *
 */
public class ABECycleDataHeadStart implements ABEDataHeadStart{
    public static final int BYTE_LEN = 45;
    
    public int battNum;                //电池编号
    public int battVolStyle;        //电池电压 无用
    public int std_CAP;                //标称容量      x AH
    public int disTime;                //放电时间      x Min
    public float disCurr;            //放电电流      x/10 A
    public float monomerVol_LOW;    //放电电压下限   x/1000 V
    public int chargeTime;            //充电时间      x Min
    public float chargeCurr;        //充电电流      x/10 A
    public float monomerVol_High;    //充电电压上限   x/1000 V
    public int cycleTimes;            //充放次数
    public int waitTime;            //静置时间 无用
    public int workFrom;            //测试起点  0放电 1充电
 
    public int testcap1;               //初测容量  x AH 第一次放电容量
    public int testcap2;               //终测容量  x AH 最后一次放电容量
    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;
 
    @Override
    public boolean setDataInf(ByteBuffer bf) {
        System.out.println("头部数据长度异常"+bf.remaining());
        if(bf.limit() < BYTE_LEN) {
            return false;
        }
        int crc0 = bf.getShort(BYTE_LEN-2) & 0xFFFF;
        int crc1 = Crc16.CalCRC16(bf, BYTE_LEN-2);
        if(crc0 != crc1) {
            //校验CRC
            //System.out.println(crc0 + "==" + crc1);
            return false;
        }
        
        bf.position(0);
        
        battNum = ComBase.changeShortToInt(bf.getShort());                    //电池编号
        battVolStyle = ComBase.changeShortToInt(bf.getShort());                //电池电压 无用
        std_CAP = ComBase.changeShortToInt(bf.getShort());                    //标称容量      x AH
        disTime = ComBase.changeShortToInt(bf.getShort());                    //放电时间      x Min
        disCurr = ComBase.changeShortToFloat(bf.getShort())/10;                //放电电流      x/10 A
        monomerVol_LOW = ComBase.changeShortToFloat(bf.getShort())/1000;    //放电电压下限   x/1000 V
        chargeTime = ComBase.changeShortToInt(bf.getShort());                //充电时间      x Min
        chargeCurr = ComBase.changeShortToFloat(bf.getShort())/10;            //充电电流      x/10 A
        monomerVol_High = ComBase.changeShortToFloat(bf.getShort())/1000;    //充电电压上限   x/1000 V
        cycleTimes = ComBase.changeShortToInt(bf.getShort());                //充放次数
        waitTime = ComBase.changeShortToInt(bf.getShort());                    //静置时间 无用
        workFrom = ComBase.changeByteToInt(bf.get());                        //测试起点  0放电 1充电
 
        testcap1 = ComBase.changeShortToInt(bf.getShort());                   //初测容量  x AH 第一次放电容量
        testcap2 = ComBase.changeShortToInt(bf.getShort());                   //终测容量  x AH 最后一次放电容量
        bakeup3 = ComBase.changeShortToInt(bf.getShort());
        bakeup4 = ComBase.changeShortToInt(bf.getShort());
        bakeup5 = ComBase.changeShortToInt(bf.getShort());
        bakeup6 = ComBase.changeShortToInt(bf.getShort());
        bakeup7 = ComBase.changeShortToInt(bf.getShort());
        bakeup8 = ComBase.changeShortToInt(bf.getShort());
        bakeup9 = ComBase.changeShortToInt(bf.getShort());
        bakeup10 = ComBase.changeShortToInt(bf.getShort());
 
        CRC = ComBase.changeShortToInt(bf.getShort());
        
        //System.out.println(this);
        
        bf.compact();
        bf.flip();
        return true;
    }
 
    @Override
    public int getBattGroupNum() {
        return 1;
    }
}