18045010223
2025-07-07 0d3a683a0c97154b1f2e6657398664537e4e3e82
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
package org.yzh.protocol.t808.T8900Lock;
 
import io.github.yezhihao.protostar.annotation.Field;
import io.github.yezhihao.protostar.annotation.Message;
import org.yzh.commons.util.BytesUtils;
import org.yzh.protocol.basics.JTMessage;
import org.yzh.protocol.commons.JT808;
 
/**
 * 消息透传 - 蝶阀锁查询命令
 */
public class T8900State {
 
    @Field(index = 0, length = 2, desc = "锁ID")
    private byte[] lockId;
 
    @Field(index = 1, length = 1, desc = "命令类型")
    private byte commandType = 0x01;
 
    @Field(index = 2, length = 1, desc = "校验码")
    private byte checksum;
 
    public T8900State() {
    }
 
    public T8900State(String lockIdHex) {
        this.lockId = BytesUtils.hex2bytes(lockIdHex);
        this.checksum = calculateChecksum();
    }
 
    /**
     * 计算校验和:(aa + aa + 02 + cc) & 0xFF
     */
    public byte calculateChecksum() {
        int sum = lockId[0] & 0xFF;
        sum += lockId[1] & 0xFF;
        sum += commandType & 0xFF;
        //sum += status & 0xFF;
        this.checksum = (byte) (sum & 0xFF);
        return this.checksum;// (byte) (sum & 0xFF); // 取低8位
    }
 
    // Getters and Setters
    public byte[] getLockId() {
        return lockId;
    }
 
    public void setLockId(byte[] lockId) {
        this.lockId = lockId;
        this.checksum = calculateChecksum();
    }
 
    public byte getCommandType() {
        return commandType;
    }
 
    public void setCommandType(byte commandType) {
        this.commandType = commandType;
        this.checksum = calculateChecksum();
    }
 
    public byte getChecksum() {
        return checksum;
    }
}