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