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
package safeluck.drive.evaluation.platformMessage;
 
import android.text.TextUtils;
 
import com.anyun.im_lib.util.ByteUtil;
 
/**
 * 上报结束考试
 */
public class StopExamMessage extends DriveExamProtocol {
    private static final short BODY_LENGTH = 30;
 
    private int currPos = 0;
 
    private String ID;//身份证
    private String BCDStr;//时间BCD[6] YYMMDDhhmmss
    private int exam_id;// DWORD  4字节 唯一考试ID标志
    private short score;//扣分分数 一字节
    private short reasonType;
 
    /**
     * 构造函数
     *
     * @param msg_id 消息ID
     */
    public StopExamMessage(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[] score_bytes = ByteUtil.shortGetByte(score);
        byte[] reason_bytes = ByteUtil.shortGetByte(reasonType);
 
 
 
        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(score_bytes,0,messageBody,currPos,1);
        currPos += 1;
 
        System.arraycopy(reason_bytes,0,messageBody,currPos,1);
 
        return messageBody;
    }
 
    @Override
    protected short msgBodyLength() {
        return BODY_LENGTH;
    }
}