package com.ard.tianyu.netty.command.control;
|
|
import com.ard.tianyu.model.dto.control.AbsAngleControlDTO;
|
import com.ard.tianyu.netty.command.BaseCmd;
|
import io.netty.buffer.ByteBuf;
|
import lombok.Data;
|
|
/**
|
* 云台绝对值控制(基于角度)命令
|
*
|
* @author 刘苏义
|
* @date 2024/10/22 16:36
|
*/
|
|
@Data
|
public class AbsAngleControlCmd extends BaseCmd {
|
private final byte encryptFlag = 0x00; // 加密标志
|
private final byte actionCode = 0x09; // 动作编号
|
private final float pitch; // 俯仰
|
private final float yaw; // 平移
|
private final float roll; // 横滚
|
|
public AbsAngleControlCmd(AbsAngleControlDTO absAngleControlDto) {
|
setDataHeader((short) 0x7479);
|
setDataLength((short) 30);
|
setBoxSn(absAngleControlDto.getBoxSn().getBytes());
|
setCmdCode((byte) 0xD1);
|
this.pitch = absAngleControlDto.getPitch();
|
this.yaw = absAngleControlDto.getYaw();
|
this.roll = absAngleControlDto.getRoll();
|
|
}
|
|
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.writeFloat(pitch); // 写入转动角度
|
out.writeFloat(yaw); // 写入转动角度
|
out.writeFloat(roll); // 写入转动角度
|
}
|
}
|