TransferResult.java
1.77 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package com.sunvote.cmd.upload;
import com.sunvote.cmd.BaseCmd;
import com.sunvote.cmd.ICmd;
/**
* Created by Elvis on 2017/8/9.
* Email:Eluis@psunsky.com
* Description:编号模式结果
* 模块应答表示收到:
字节 标识符 描述
1 REQUEST_CMD 0xF3
2 MSGID 相同的流水号 1-255
3 MSGTYPE 1
4 STATUS 1 收到
*/
public class TransferResult extends UploadBaseCmd {
public static final int CMD_LENGTH = 4 ;
/**
* 0xF3
*/
private byte cmd = RESPONSE_CMD;
/**
* 相同的流水号 1-255
*/
private byte msgId ;
/**
* 1
*/
private byte msgType = 0x01;
/**
* STATUS 1 收到
*/
private byte status = 0x01 ;
public byte getCmd() {
return cmd;
}
public void setCmd(byte cmd) {
this.cmd = cmd;
}
public byte getMsgId() {
return msgId;
}
public void setMsgId(byte msgId) {
this.msgId = msgId;
}
public byte getMsgType() {
return msgType;
}
public void setMsgType(byte msgType) {
this.msgType = msgType;
}
public byte getStatus() {
return status;
}
public void setStatus(byte status) {
this.status = status;
}
@Override
public byte[] toBytes() {
byte[] result = new byte[CMD_LENGTH];
result[0] = cmd;
result[1] = msgId;
result[2] = msgType ;
result[3] = status ;
return result;
}
@Override
public ICmd parseCmd(byte[] source, int start) {
if(source != null && source.length >= start + CMD_LENGTH) {
cmd = source[start];
msgId = source[start + 1];
msgType = source[start + 2];
status = source[start + 3];
}
return this;
}
}