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位
|
}
|
}
|