package com.its.op.xnetudp.protocol;

import com.its.utils.SysUtils;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

public class CENTER_VMS_REQ_LUMINANCE extends CENTER_VMS_REQ_COMMON {

	byte brghMode;
	byte brghCurrStep;
	byte brghWeekStep;
	byte brghNghtStep;

	public CENTER_VMS_REQ_LUMINANCE(Long id, String userId, byte brghMode, byte brghCurrStep, byte brghWeekStep, byte brghNghtStep) {
		super(CENTER_COMM_DEFINE.INT_OP_VMS_LUMINANCE_CTL, 0x30, 0, id, userId, null);
		this.brghMode = brghMode;
		this.brghCurrStep = brghCurrStep;
		this.brghWeekStep = brghWeekStep;
		this.brghNghtStep = brghNghtStep;
	}

	@Override
	public ByteBuffer getBuffer() {
		int pktSize = CENTER_COMM_DEFINE.INT_VMS_MAX_DATETIME + CENTER_COMM_DEFINE.INT_VMS_MAX_OPER_ID + 4 + 1 + 1 + 1 + 1;

		setLength(pktSize);
		ByteBuffer byteBuffer = ByteBuffer.allocate(CENTER_HEADER_SIZE + getLength());
		byteBuffer.order(ByteOrder.LITTLE_ENDIAN);

		byteBuffer.put(getSendId());
		byteBuffer.put(getRecvId());
		byteBuffer.put(getTotalFrame());
		byteBuffer.put(getCurrentFrame());
		byteBuffer.put(getMsgSeq());
		byteBuffer.put(getOpCode());
		byteBuffer.putShort(getLength());
		byte[] cmdTimeArr = new byte[CENTER_COMM_DEFINE.INT_VMS_MAX_DATETIME];
		SysUtils.copyStringToByteArray(cmdTimeArr, cmdTimeArr.length, getCmdTime());
		byteBuffer.put(cmdTimeArr);

		byte[] operIdArr = new byte[CENTER_COMM_DEFINE.INT_VMS_MAX_OPER_ID];
		SysUtils.copyStringToByteArray(operIdArr, operIdArr.length, getOperId());
		byteBuffer.put(operIdArr);

		//byte[] vmsIdArr = new byte[CENTER_COMM_DEFINE.INT_VMS_MAX_ID];
		//SysUtils.copyStringToByteArray(vmsIdArr, vmsIdArr.length, String.valueOf(this.vmsCtlrNmbr));
		byteBuffer.putInt(getVmsCtlrNmbr().intValue());

		byteBuffer.put(this.brghMode);
		byteBuffer.put(this.brghCurrStep);
		byteBuffer.put(this.brghWeekStep);
		byteBuffer.put(this.brghNghtStep);
		return byteBuffer;
	}
}