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

namespace PlcSiemens.Protocol.Negotiate
{
    public class NegotiateRequestParams
    {
        public byte FunNegotiate { get; set; }
        public byte Unknown { get; set; }
        public ushort ParallelJobs1 { get; set; }
        public ushort ParallelJobs2 { get; set; }
        public ushort PduLength { get; set; }

        public ushort PacketLength = 0x08;

        public void GetByteBuffer(ByteBuffer buffer)
        {
            buffer.Push(FunNegotiate);
            buffer.Push(Unknown);
            buffer.Push(ParallelJobs1);
            buffer.Push(ParallelJobs2);
            buffer.Push(PduLength);
        }

        public void Build(ushort pduRequest)
        {
            FunNegotiate = (byte)PduFuncType.PduNegotiate;
            Unknown = 0x00;
            ParallelJobs1 = 0x0001;
            ParallelJobs2 = 0x0001;
            PduLength = pduRequest;
        }
    }
}
