lizhanwei
2020-02-17 ee16db5e1cbc1c27bdbc1984567b5e61a3d005dd
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
package safeluck.drive.evaluation.platformMessage;
 
import android.text.TextUtils;
 
import com.anyun.im_lib.util.ByteUtil;
 
/**
 * 上报开始考试
 */
public class StartExam2Server extends DriveExamProtocol {
    private static final short BODY_LENGTH = 29;
 
    private String ID;//身份证
    private String BCDStr;//时间BCD[6] YYMMDDhhmmss
    private int exam_id;// DWORD  4字节 唯一考试ID标志
    private short examaCourse = 0;
    private int currPos = 0;
 
    /**
     * 构造函数
     *
     * @param msg_id 消息ID
     */
    public StartExam2Server(short msg_id) {
        super(msg_id);
    }
 
    @Override
    protected byte[] createMessageBody() {
        byte [] messageBody = new byte[BODY_LENGTH];
        byte[] idBytes = !TextUtils.isEmpty(ID)?ID.getBytes():"".getBytes();
        byte[] timeStampBCD = ByteUtil.str2Bcd(BCDStr);
        byte[] examIdBytes = ByteUtil.intGetBytes(exam_id);
        byte[] examBytes = ByteUtil.shortGetByte(examaCourse);
 
        System.arraycopy(idBytes,0,messageBody,currPos,idBytes.length);
        currPos += 18;
 
        System.arraycopy(timeStampBCD,0,messageBody,currPos,timeStampBCD.length);
        currPos += timeStampBCD.length;
 
        System.arraycopy(examIdBytes,0,messageBody,currPos,examIdBytes.length);
        currPos += 4;
 
        System.arraycopy(examBytes,0,messageBody,currPos,examBytes.length);
        return messageBody;
    }
 
    @Override
    protected short msgBodyLength() {
        return BODY_LENGTH;
    }
 
    public String getID() {
        return ID;
    }
 
    public void setID(String ID) {
        this.ID = ID;
    }
 
    public String getBCDStr() {
        return BCDStr;
    }
 
    public void setBCDStr(String BCDStr) {
        this.BCDStr = BCDStr;
    }
 
    public int getExam_id() {
        return exam_id;
    }
 
    public void setExam_id(int exam_id) {
        this.exam_id = exam_id;
    }
 
    public short getExamaCourse() {
        return examaCourse;
    }
 
    public void setExamaCourse(short examaCourse) {
        this.examaCourse = examaCourse;
    }
}