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
package org.yzh.protocol.t808.T8900Lock;
 
import io.github.yezhihao.protostar.annotation.Field;
import lombok.Data;
 
@Data
public class T8900ReadAllInformation {
    @Field(index = 0, length = 2, desc = "锁ID")
    private byte[] lockId;
    @Field(index = 1, length = 1, desc = "命令类型")
    private byte commandType = 0x0B;
    @Field(index = 2, length = 1, desc = "年")
    private byte Year;
    @Field(index = 3, length = 1, desc = "月")
    private byte Month;
    @Field(index = 4, length = 1, desc = "日")
    private byte Day;
    @Field(index = 5, length = 1, desc = "时")
    private byte Hour;
    @Field(index = 6, length = 1, desc = "分")
    private byte Minute;
    @Field(index = 7, length = 1, desc = "秒")
    private byte Second;
    @Field(index = 8, length = 1, desc = "校验码")
    private byte checksum;
 
    /**
     * 计算校验和:(aa + aa + 02 + cc) & 0xFF
     */
    public byte calculateChecksum() {
        int sum = lockId[0] & 0xFF;
        sum += lockId[1] & 0xFF;
        sum += commandType & 0xFF;
        sum += Year & 0xFF;
        sum += Month & 0xFF;
        sum += Day & 0xFF;
        sum += Hour & 0xFF;
        sum += Minute & 0xFF;
        sum += Second & 0xFF;
        this.checksum = (byte) (sum & 0xFF);
        return this.checksum;// (byte) (sum & 0xFF); // 取低8位
    }
}