package com.ard.tianyu.component.netty.command.control;
|
|
import com.ard.tianyu.domain.dto.control.AngleControlDTO;
|
import com.ard.tianyu.component.netty.command.BaseCmd;
|
import io.netty.buffer.ByteBuf;
|
import lombok.Data;
|
|
/**
|
* 云台转动(基于角度)命令
|
*
|
* @author 刘苏义
|
* @date 2024/10/22 16:36
|
*/
|
|
@Data
|
public class AngleControlCmd extends BaseCmd {
|
private final byte encryptFlag = 0x00; // 加密标志
|
private final byte actionCode; // 动作编号
|
private final byte rotationAngle; // 转动角度
|
|
public AngleControlCmd(AngleControlDTO angleControlDto) {
|
setDataHeader((short) 0x7479);
|
setDataLength((short) 19);
|
setBoxSn(angleControlDto.getBoxSn().getBytes());
|
setCmdCode((byte) 0xD1);
|
this.actionCode = angleControlDto.getActionCode();
|
this.rotationAngle = angleControlDto.getRotationAngle();
|
}
|
|
public void encode(ByteBuf out) {
|
out.writeShort(getDataHeader()); // 写入数据头
|
out.writeShort(getDataLength()); // 写入数据长度
|
out.writeBytes(getBoxSn()); // 写入盒子SN
|
out.writeByte(getCmdCode()); // 写入命令码
|
out.writeByte(encryptFlag); // 写入加密标志
|
out.writeByte(actionCode); // 写入动作编号
|
out.writeByte(rotationAngle); // 写入转动角度
|
}
|
}
|