充放电一体机FGCD通信程序【二期初版】
Administrator
2022-03-04 6478c04ab6f39fe8db87ba9f97c8e3d88cfef702
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
package com.dev.fgcd.data;
 
import java.nio.ByteBuffer;
import java.util.Arrays;
 
/**
 *     ÔÚÏßÄ£¿éÐÅÏ¢
 * @author LiJun
 *
 */
public class FGCD_OnlineInfo {
    private final int BYTE_LEN = 24;
    
    public double batt1_vol;            //µç³Ø×é1µçѹ
    public double batt2_vol;            //µç³Ø×é2µçѹ
    public int currBattNum;                //µ±Ç°Ñ¡ÔñµÄµç³Ø×é;0:δѡÔñµç³Ø×é
    public int endoscopeState;            //ÄÚ¿ú¾µ×´Ì¬->0Í£Ö¹ÏÔʾ;1:¿ªÊ¼ÏÔʾ
    public int backup[] = new int[14];
    
    public boolean putByteBuffer(ByteBuffer bf) {
        if(bf.limit()<BYTE_LEN) {
            return false;
        }
        ByteBuffer tmpbuf = bf;
        tmpbuf.position(0);
 
        batt1_vol = bf.getFloat();                                    //µç³Ø×é1µçѹ
        batt2_vol = bf.getFloat();                                    //µç³Ø×é2µçѹ
        //Ïû³ýÎÞ2×éµç³ØÇé¿öÏÂÓÐ×é¶ËµçѹµÄÇé¿ö
        if(batt1_vol < 1.7) {
            batt1_vol = 0;
        }
        if(batt2_vol <1.7) {
            batt2_vol = 0;
        }
        currBattNum = FGCD_ComBase.changeByteToInt(bf.get());
        endoscopeState = FGCD_ComBase.changeByteToInt(bf.get());
        for(int i = 0 ; i < backup.length ; i++) {
            backup[i] = FGCD_ComBase.changeByteToInt(bf.get());
        }
        return true;
    }
 
    /**
     * »ñÈ¡µ±Ç°Ñ¡ÖÐµç³Ø×éµÄ×é¶Ëµçѹ
     * @return
     */
    public double getGroupVol() {
        double tmp_groupvol = 0;
        if(this.currBattNum > 0) {
            switch(this.currBattNum) {
                case 0:tmp_groupvol = 0;break;
                case 1:tmp_groupvol = batt1_vol;break;
                case 2:tmp_groupvol = batt2_vol;break;
            }
        }        
        return tmp_groupvol;
    }
    
    
    @Override
    public String toString() {
        return "FGCD_OnlineInfo [BYTE_LEN=" + BYTE_LEN + ", batt1_vol=" + batt1_vol + ", batt2_vol=" + batt2_vol
                + ", currBattNum=" + currBattNum + ", endoscopeState=" + endoscopeState + ", backup="
                + Arrays.toString(backup) + "]";
    }
    
}