lxw
2023-02-10 f978d4ecdf83cbf7c8b778f1362b86be5aa510bd
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
package com.whyc.mcp;
 
import com.whyc.util.ComBase;
 
import java.nio.ByteBuffer;
import java.util.Arrays;
 
public class MVolData {
    public static final int BYTE_LEN = 1000;
 
    public static final int MONOMER_COUNT_MAX = 500;
    public float vol[];//单体电压 偏移20000 分辨率0.001V
    public MVolData(int count) {
        vol = new float[count];
    }
    public boolean puByteBuffer(ByteBuffer bf) {
        bf.position(0);
        if (bf.remaining() < vol.length * 2) {
            return false;
        }
        for (int i = 0; i < vol.length; i++) {
            //System.out.println(ComBase.changeShortToFloat(bf.getShort()));
            vol[i] = ComBase.changeShortToFloat(bf.getShort()) * 0.001f;//单体电压 偏移20000 分辨率0.001V
        }
        bf.compact();
        //System.out.println(this);
        return true;
    }
    public String toString() {
        return "MVolData [vol=" + Arrays.toString(vol) + "]";
    }
}