using PlcSiemens.O;
using PlcSiemens.Protocol.Common;
using PlcSiemens.Protocol.Header;

namespace PlcSiemens.Protocol.Negotiate
{
    public class NegotiateRequest : IBuildRequest
    {
        public HeaderPacket Header { get; set; }
        public NegotiateRequestParams Params { get; set; }

        public ushort PduRequestLength { get; set; }

        public void Build()
        {
            Header = new HeaderPacket();
            Params = new NegotiateRequestParams();

            Header.Build(PduType.Request, Params.PacketLength, 0x00);
            Params.Build(PduRequestLength);
        }

        public ByteBuffer GetBuffer()
        {
            ByteBuffer buffer = ByteBuffer.Allocate();
            Header.GetByteBuffer(buffer);
            Params.GetByteBuffer(buffer);
            return buffer;
        }
    }
}
