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

namespace PlcSiemens.ProtocolHandle
{
    public class UploadStartHandle : IPacketHandle
    {
        public StartUploadRequest Request { get; set; }
        public StartUploadResponse Response { get; set; }
        public ResultCode ResultCode { get; set; }

        public ushort BlockNum { get; set; }
        public BlockType BlockType { get; set; }

        public UploadStartHandle()
        {
            Request = new StartUploadRequest();
        }

        public void Handle(IIsoSender sender)
        {
            Request.BlockType = BlockType;
            Request.BlockNum = BlockNum;

            Response = sender.IsoSend<StartUploadRequest, StartUploadResponse>(Request);

            ResultCode = Response.Header.Error;
        }
    }
}
