whyclj
2019-10-16 3825e10fc9eba23411e8836b34ba70ed10abee7b
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
package com.mode;
 
import java.nio.ByteBuffer;
import java.util.Arrays;
import com.util.ComFn;
import com.util.*;
 
 
public class BattRTData {
    private final int BATTGROUP_COUNT = FBS_ComBase.BattGroupCountMax;        //电池组的组数
    private final int BYTE_HEAD_LEN = 32;                                    //头部长度为32个字节
 
    public int monsum;
 
    public double[] groupvol = new double[BATTGROUP_COUNT];                    //组端电压
    public double[] groupcur = new double[BATTGROUP_COUNT];                    //组端电流
    public int[]     battstate = new int[BATTGROUP_COUNT];                    //电池状态
    public double vol[] = new double[FBS_ComBase.MonomerCountMax];            //单体电压
 
    public boolean putByteBuffer(ByteBuffer bf,int BYTECOUNT) {
        monsum = (BYTECOUNT - 32)/2;
        if(monsum <= 0) {
            return false;
        }
        if(monsum > 480) {
            monsum = 480;
        }
 
        ByteBuffer tmpbuf = bf;
        tmpbuf.position(0);
        for(int i=0;i<BATTGROUP_COUNT;i++) {
            groupvol[i] = FBS_ComBase.changeShortToDouble(tmpbuf.getShort())/10;
        }
        for(int i=0;i<BATTGROUP_COUNT;i++) {
            groupcur[i] = FBS_ComBase.changeShortToDouble(tmpbuf.getShort())/10;
        }
        for(int i=0;i<BATTGROUP_COUNT;i++) {
            battstate[i] = FBS_ComBase.changeShortToInt(tmpbuf.getShort());
        }
 
        for(int i=0;i<monsum;i++) {
            vol[i] = FBS_ComBase.changeShortToDouble(tmpbuf.getShort())/1000;
        }
        System.out.println(this);
        return true;
    }
 
 
    public double[] getGroupvol() {
        return groupvol;
    }
 
    public double[] getGroupcur() {
        return groupcur;
    }
 
    public int[] getBattstate() {
        return battstate;
    }
 
    public double[] getVol() {
        return vol;
    }
 
 
    public void setGroupvol(double[] groupvol) {
        this.groupvol = groupvol;
    }
 
    public void setGroupcur(double[] groupcur) {
        this.groupcur = groupcur;
    }
 
    public void setBattstate(int[] battstate) {
        this.battstate = battstate;
    }
 
    public void setVol(double[] vol) {
        this.vol = vol;
    }
 
 
    public int getMonsum() {
        return monsum;
    }
 
 
    public void setMonsum(int monsum) {
        this.monsum = monsum;
    }
 
 
    @Override
    public String toString() {
        return "BattData [monsum=" + monsum + ", groupvol=" + Arrays.toString(groupvol) + ", groupcur="
                + Arrays.toString(groupcur) + ", battstate=" + Arrays.toString(battstate) + ", vol="
                + Arrays.toString(vol) + "]";
    }
}