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

namespace PlcSiemens.Protocol.DateTime
{
    public class HandleResponse<TResponseHeader> : IBuildResponse where TResponseHeader : HeaderPacket, new()
    {
        public TResponseHeader Header { get; set; }
        public ParamsResponse Params { get; set; }
        public byte[] Data { get; set; }

        public HandleResponse()
        {
            Header = new TResponseHeader();
            Params = new ParamsResponse();
        }

        public void Build(ByteBuffer buffer)
        {
            Header.Build(buffer);
            Params.Build(buffer);
            Data = buffer.PopBytes(Header.DataLen);
        }
    }
}
