whyclxw
2025-05-28 e16302f9d475c7cc4dd18c5abf1a23cb5502e362
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
96
97
98
99
100
101
102
103
104
105
106
107
108
package com.whyc.abe;
 
import com.whyc.constant.ComBase;
import com.whyc.constant.Crc16;
 
import java.nio.ByteBuffer;
 
/**
 *     充电数据头结构体
 * @author LiJun
 *
 */
public class ABEChrDataHeadStart  implements ABEDataHeadStart{
    public static final int BYTE_LEN = 44;
    
    public int hourRate;               //小时率 固定为10
    public float chargeCurr;        //充电电流参数 x/10 A
    public int  chargeCap;          //测试容量    x AH
    public int  chargeTime;            //测试时间
    public float  groupVol_High;      //充电上限    x/1000 V
    public float  monomerVol_High;    //充电上限    x/1000 V
    public int  monomerHighCount;    //上限个数 固定为1
    public int  battGroupNum;        //电池组数 固定为1
    public int  onlineVolLowAction;    //无用
    public int  staticTime;            //无用
    public int  chargeTestCount;       //无用
    
    public int  battNum;            //电池编号
    public int  battVolStyle;        //无用
    public int  std_CAP;            //标称容量 x AH
    
    public int  testcap;            //已测容量 x AH 同 ChargeCap
    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);
        
        hourRate = ComBase.changeShortToInt(bf.getShort());               //小时率 固定为10
        chargeCurr = ComBase.changeShortToFloat(bf.getShort())/10;        //充电电流参数 x/10 A
        chargeCap = ComBase.changeShortToInt(bf.getShort());          //测试容量    x AH
        chargeTime = ComBase.changeShortToInt(bf.getShort());            //测试时间
        groupVol_High = ComBase.changeShortToFloat(bf.getShort())/1000;      //充电上限    x/1000 V
        monomerVol_High = ComBase.changeShortToFloat(bf.getShort())/1000;    //充电上限    x/1000 V
        monomerHighCount = ComBase.changeShortToInt(bf.getShort());            //上限个数 固定为1
        battGroupNum = ComBase.changeShortToInt(bf.getShort());                //电池组数 固定为1
        onlineVolLowAction = ComBase.changeShortToInt(bf.getShort());        //无用
        staticTime = ComBase.changeShortToInt(bf.getShort());                //无用
        chargeTestCount = ComBase.changeShortToInt(bf.getShort());           //无用
        
        battNum = ComBase.changeShortToInt(bf.getShort());                    //电池编号
        battVolStyle = ComBase.changeShortToInt(bf.getShort());                //无用
        std_CAP = ComBase.changeShortToInt(bf.getShort());                    //标称容量 x AH
        
        testcap = ComBase.changeShortToInt(bf.getShort());                    //已测容量 x AH 同 ChargeCap
        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 this.battGroupNum;
    }
 
    @Override
    public String toString() {
        return "ABEChrDataHeadStart [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 + ", battNum=" + battNum + ", battVolStyle=" + battVolStyle + ", std_CAP=" + std_CAP
                + ", testcap=" + testcap + ", bakeup5=" + bakeup5 + ", bakeup6=" + bakeup6 + ", bakeup7=" + bakeup7
                + ", bakeup8=" + bakeup8 + ", bakeup9=" + bakeup9 + ", bakeup10=" + bakeup10 + ", crc=" + crc + "]";
    }
    
    
}