#
whycq
2024-08-15 e54492fb532366faac8aa5d46ad8905ea3ff38d5
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package com.example.agvcontroller.protocol;
 
 
import java.io.Serializable;
 
/**
 * 动作命令包
 * Created by vincent on 2023/3/21
 */
public class AGV_02_DOWN implements IMessageBody, Serializable {
 
    private static final long serialVersionUID = 1664188062202647371L;
 
    @Override
    public byte[] writeToBytes() {
        String serialNo = Utils.zeroFill(this.serialNo, 16);
        byte[] serialNoBytes = Utils.reverse(serialNo.getBytes());
        //byte cmdCodeByte = (byte) this.getCmdCode();
        byte cmdCodeByte = (byte) 1;
        //byte valByte = (byte) this.getVal();
        byte valByte = (byte) 1;
 
        byte[] cmdBodyBytes = commandBody.writeToBytes();
 
        return Utils.merge(serialNoBytes, cmdCodeByte, valByte, cmdBodyBytes);
    }
 
    @Override
    public void readFromBytes(byte[] messageBodyBytes) {
 
    }
 
    // 流水号 - 16
    private String serialNo;
 
    // 命令码
    private int cmdCode;
 
    // 属性值
    private int val;
 
    // 动作参数
    private ICommandBody commandBody;
 
    public String getSerialNo() {
        return serialNo;
    }
 
    public void setSerialNo(String serialNo) {
        this.serialNo = serialNo;
    }
 
    public int getCmdCode() {
        return cmdCode;
    }
 
    public void setCmdCode(int cmdCode) {
        this.cmdCode = cmdCode;
    }
 
    public int getVal() {
        return val;
    }
 
    public void setVal(int val) {
        this.val = val;
    }
 
    public ICommandBody getCommandBody() {
        return commandBody;
    }
 
    public void setCommandBody(ICommandBody commandBody) {
        this.commandBody = commandBody;
    }
}