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

namespace PlcSiemens.ProtocolHandle
{
    public class GetDateTimeHandle : IPacketHandle
    {
        public GetDateTimeRequest Request { get; set; }
        public GetDateTimeResponse Response { get; set; }
        public ResultCode ResultCode { get; set; }

        public void Handle(IIsoSender sender)
        {
            Response = sender.IsoSend<GetDateTimeRequest, GetDateTimeResponse>(Request);

            if (Response == null) return;

            ResultCode = Response.Params.Err;
        }

        public GetDateTimeHandle()
        {
            ResultCode = ResultCode.Unknown;
            Request = new GetDateTimeRequest();
        }
    }
}
