lxw
2023-03-02 2ebf5324ac4e7dd23f4857e7080d25d40065b86c
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
package com.whyc.abe;
 
import com.whyc.abe.ABEVolCurrData.ABEMonData;
import com.whyc.constant.ComBase;
 
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
 
/**
 *    每一笔单体数据
 * @author LiJun
 *
 */
public class ABEFBSData {
    
    
    
    public ABEDataType m_DataType;       //标志位 0xFD放电 0xFC充电
    public int crc16;
    public ABETestTime m_TestTime;       //测试时间
    public int battGroup = 1;              //电池组数 固定为1
    public int battSum = 1;                //单体数   固定为1
    public ABEVolCurrData vcData;        //组端数据
    public ABEMonData mVol;                //单体数据
    
    public int testTimeLong;            //测试时长
    
    public ABEFBSData() {
        m_DataType = new ABEDataType();
        m_TestTime = new ABETestTime();
    }
 
    
    public void setData(byte[] databuf) {
        ByteBuffer bf = ByteBuffer.allocate(databuf.length);
        bf.order(ByteOrder.LITTLE_ENDIAN);
        bf.put(databuf);
        bf.position(0);
        
        crc16 = ComBase.changeShortToInt(bf.getShort());
        m_TestTime.hour = ComBase.changeByteToInt(bf.get());
        m_TestTime.minute = ComBase.changeByteToInt(bf.get());
        m_TestTime.second = ComBase.changeByteToInt(bf.get());
        
        //System.out.println(m_TestTime.hour + ":" + m_TestTime.minute + ":" + m_TestTime.second);
        
        battGroup = ComBase.changeByteToInt(bf.get());
        battSum = ComBase.changeShortToInt(bf.getShort());
        
        testTimeLong = m_TestTime.calTestTimeLong();
        
        bf.compact();
        bf.flip();
        
        vcData = new ABEVolCurrData(battGroup);
        mVol = vcData.new ABEMonData(battSum);
        
        
        vcData.putByteBuffer(bf);
        
        mVol.putByteBuffer(bf);
        
        //System.out.println(this);
    }
 
 
    @Override
    public String toString() {
        return "ABEFBSData [m_DataType=" + m_DataType + ", crc16=" + crc16 + ", m_TestTime=" + m_TestTime
                + ", battGroup=" + battGroup + ", battSum=" + battSum + ", vcData=" + vcData + ", mVol=" + mVol
                + ", testTimeLong=" + testTimeLong + "]";
    }
    
    
}