DELL
2025-04-28 e6eb7fb0af366e370f125668d62e89eb0004f517
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.dev.bts.data;
 
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
 
public class FBS9100_JuHengParam {
    
    private final int BYTE_LEN = 44;
    
    public int GdUnitAutoRestartCycle;            //¹©µçÄ£¿é×Ô¶¯ÖØÆôÖÜÆÚ
    public int AutoOffLineTestCycle;            //×Ô¶¯ÀëÏßÑø»¤ÖÜÆÚ
    public float OnlineVolLow;                     //ÔÚÏßµçѹµÍ·§Öµ(0.01)
    public float jhSetVolt;                     //¾ùºâµçѹÉèÖÃ(0.001)//2021-8-13Ŀǰµ±×ö¿ª¹ØÊ¹ÓÃ
    public float jhVoltLimit;                     //¾ùºâµçѹֹͣÌõ¼þ(0.001)
    public float jhCurrLimit;                     //¾ùºâµçÁ÷Í£Ö¹Ìõ¼þ(0.001)
    public float StandyVolt;                    //ºó±¸µçѹ(0.1)(18~57.5)
    public int back[] = new int[14];            //±¸ÓÃ
    public int CRC;                             //CRC
    
    public FBS9100_JuHengParam clone() {
        FBS9100_JuHengParam tmp = new FBS9100_JuHengParam();
        tmp.GdUnitAutoRestartCycle = this.GdUnitAutoRestartCycle;            //¹©µçÄ£¿é×Ô¶¯ÖØÆôÖÜÆÚ
        tmp.AutoOffLineTestCycle = this.AutoOffLineTestCycle;                //×Ô¶¯ÀëÏßÑø»¤ÖÜÆÚ
        tmp.OnlineVolLow = this.OnlineVolLow;                                 //ÔÚÏßµçѹµÍ·§Öµ
        tmp.jhSetVolt = this.jhSetVolt;                                     //¾ùºâµçѹÉèÖÃ//2021-8-13Ŀǰµ±×ö¿ª¹ØÊ¹ÓÃ
        tmp.jhVoltLimit = this.jhVoltLimit;                                 //¾ùºâµçѹֹͣÌõ¼þ
        tmp.jhCurrLimit = this.jhCurrLimit;                                 //¾ùºâµçÁ÷Í£Ö¹Ìõ¼þ
        tmp.StandyVolt = this.StandyVolt;
        for(int i = 0; i<back.length;i++) {
            tmp.back[i] = this.back[i];
        }
        return tmp;
    }
    
    /**
     * ½«bytebufferÖеÄÊý¾ÝÈ¡³ö·ÅÈë¸Ã¶ÔÏóµÄÊôÐÔÖУ¬²¢·µ»ØÊÇ·ñÈ¡³ö³É¹¦
     * @param bf
     * @return
     */
    public boolean putByteBuffer(final ByteBuffer bf)
    {
        if(bf.limit() < BYTE_LEN)
            return false;
        
        ByteBuffer tmpbuf = bf;
        int crc0 = tmpbuf.getShort(BYTE_LEN-2) & 0xFFFF;
        int crc1 = FBS9100_Crc16.CalCRC16(tmpbuf, BYTE_LEN-2);
        if(crc0 != crc1) {
            System.out.println("FBS9100_JuHengParam.putByteBuffer():" + crc0 + "!=" + crc1);
            return false;
        }
        tmpbuf.position(0);
        
        GdUnitAutoRestartCycle = FBS9100_ComBase.changeShortToInt(tmpbuf.getShort());        //¹©µçÄ£¿é×Ô¶¯ÖØÆôÖÜÆÚ
        AutoOffLineTestCycle = FBS9100_ComBase.changeShortToInt(tmpbuf.getShort());            //×Ô¶¯ÀëÏßÑø»¤ÖÜÆÚ
        OnlineVolLow = FBS9100_ComBase.changeShortToFloat(tmpbuf.getShort())/100;          //ÔÚÏßµçѹµÍ·§Öµ
        jhSetVolt = FBS9100_ComBase.changeShortToFloat(tmpbuf.getShort())/1000;                 //¾ùºâµçѹÉèÖÃ//2021-8-13Ŀǰµ±×ö¿ª¹ØÊ¹ÓÃ
        jhVoltLimit = FBS9100_ComBase.changeShortToFloat(tmpbuf.getShort())/1000;             //¾ùºâµçѹֹͣÌõ¼þ
        jhCurrLimit = FBS9100_ComBase.changeShortToFloat(tmpbuf.getShort())/1000;             //¾ùºâµçÁ÷Í£Ö¹Ìõ¼þ
        
        StandyVolt = FBS9100_ComBase.changeShortToFloat(tmpbuf.getShort())/10;             //¾ùºâµçÁ÷Í£Ö¹Ìõ¼þ
        
        for(int i=0;i<back.length;i++) {
            back[i] = FBS9100_ComBase.changeShortToInt(tmpbuf.getShort());
        }
        
        System.err.println(this);
        
        tmpbuf.compact();
        tmpbuf.flip();        
        return true;
    }
 
    public ByteBuffer getByteBuffer() {
        ByteBuffer bytebuffer = ByteBuffer.allocate(BYTE_LEN);
        bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
        bytebuffer.position(0);
        bytebuffer.putShort(FBS9100_ComBase.changeIntToShort(GdUnitAutoRestartCycle));
        bytebuffer.putShort(FBS9100_ComBase.changeIntToShort(AutoOffLineTestCycle));
        bytebuffer.putShort(FBS9100_ComBase.changeFloatToShort(OnlineVolLow*100));
        bytebuffer.putShort(FBS9100_ComBase.changeFloatToShort(jhSetVolt*1000));
        bytebuffer.putShort(FBS9100_ComBase.changeFloatToShort(jhVoltLimit*1000));
        bytebuffer.putShort(FBS9100_ComBase.changeFloatToShort(jhCurrLimit*1000));
        
        bytebuffer.putShort(FBS9100_ComBase.changeFloatToShort(StandyVolt*10));
        
        for(int i=0;i<back.length;i++) {            
            bytebuffer.putShort(FBS9100_ComBase.changeIntToShort(back[i]));
        }
        
        CRC = FBS9100_Crc16.CalCRC16(bytebuffer, bytebuffer.position());
        bytebuffer.putShort(FBS9100_ComBase.changeIntToShort(CRC));
        
        bytebuffer.flip();
        return bytebuffer;
    }
 
 
    @Override
    public String toString() {
        return "FBS9100_JuHengParam [BYTE_LEN=" + BYTE_LEN + ", GdUnitAutoRestartCycle=" + GdUnitAutoRestartCycle
                + ", AutoOffLineTestCycle=" + AutoOffLineTestCycle + ", OnlineVolLow=" + OnlineVolLow + ", jhSetVolt="
                + jhSetVolt + ", jhVoltLimit=" + jhVoltLimit + ", jhCurrLimit=" + jhCurrLimit + ", back="
                + Arrays.toString(back) + ", CRC=" + CRC + "]";
    }
    
}