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;
|
}
|
}
|