package com.its.vds.xnettcp.vds.protocol.impl;

import com.its.vds.dto.TbVdsCtlrDto;
import com.its.vds.xnettcp.vds.protocol.VdsFramePacket;
import com.its.vds.xnettcp.vds.protocol.VdsReqFramePacket;
import com.its.vds.xnettcp.vds.protocol.enums.eVdsOpCode;
import com.its.vds.xnettcp.vds.protocol.impl.andong.VdsAndongReqFramePacket;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.nio.ByteBuffer;

/**
 * VDS ACK 요청
 */
@Getter
@Slf4j
public class VdsReqAck extends VdsReqFramePacket {

    private final VdsFramePacket framePacket;

    TbVdsCtlrDto vdsObj;
    private byte[] body;
    public VdsReqAck(TbVdsCtlrDto vdsObj) {
        this.vdsObj = vdsObj;
        this.opCode = eVdsOpCode.OP_VDS_ACK;
        byte opCode = (byte)this.opCode.getValue();
        this.packetNmbr = vdsObj.getSeqNext();
        this.framePacket = new VdsAndongReqFramePacket(vdsObj.getGroupNo(), vdsObj.getVdsCtlrNmbr().intValue(), this.packetNmbr, opCode);
    }

    @Override
    public ByteBuffer getByteBuffer() {
        return this.framePacket.getByteBuffer();
    }

}
