zhaowenyu
2025-10-15 a9780c49f8cf587af26cc83d439320ad02b8668f
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
package com.ard.work.component.netty.command.control;
 
import com.ard.work.domain.dto.control.AngleControlDTO;
import com.ard.work.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);       // 写入转动角度
    }
}