自动化立体仓库 - WCS系统
#
luxiaotao1123
2020-08-04 6abc20e29568c129f4ca71eccec9310534a8c779
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
package com.zy.common.HslCommunication.Core.IMessage;
 
public class S7Message implements INetMessage {
 
    // 头字节
    private byte[] HeadBytes = null;
 
    // 消息内容字节
    private byte[] ContentBytes = null;
 
    // 发送的消息
    private byte[] SendBytes = null;
 
    /**
     * 消息头的指令长度
     */
    public int ProtocolHeadBytesLength(){
        return 4;
    }
 
    /**
     * 从当前的头子节文件中提取出接下来需要接收的数据长度
     * @return 返回接下来的数据内容长度
     */
    public int GetContentLengthByHeadBytes(){
        if(HeadBytes == null) return 0;
        return (HeadBytes[2] & 0xff) * 256 + (HeadBytes[3] & 0xff) - 4;
    }
 
    /**
     * 检查头子节的合法性
     * @param token 特殊的令牌,有些特殊消息的验证
     * @return 是否合法的验证
     */
    public boolean CheckHeadBytesLegal(byte[] token) {
        if(HeadBytes == null) return false;
        return HeadBytes[0] == 0x03 && HeadBytes[1] == 0x00;
    }
 
    /**
     * 获取头子节里的消息标识
     */
    public int GetHeadBytesIdentity(){
        return 0;
    }
 
    @Override
    public byte[] getHeadBytes() {
        return HeadBytes;
    }
 
    @Override
    public byte[] getContentBytes() {
        return ContentBytes;
    }
 
    @Override
    public byte[] getSendBytes() {
        return SendBytes;
    }
 
    public void setHeadBytes(byte[] headBytes){
        HeadBytes = headBytes;
    }
 
    public void setContentBytes(byte[] contentBytes){
        ContentBytes = contentBytes;
    }
 
    public void setSendBytes(byte[] sendBytes){
        SendBytes = sendBytes;
    }
 
}