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

namespace PlcSiemens.ProtocolHandle
{
    public class PlcStopHandle : IPacketHandle
    {
        public PlcStopRequest Request { get; set; }
        public ControlResponse Response { get; set; }
        public ResultCode ResultCode { get; set; }

        public void Handle(IIsoSender sender)
        {
            Response = sender.IsoSend<PlcStopRequest, ControlResponse>(Request);
            if (Response == null) return;

            ResultCode = Response.Header.Error;
            //Response.Params.Para=0x07�Ѿ�ֹͣ
            if (ResultCode != ResultCode.OK && Response.Params.Para == 0x07)
                ResultCode = ResultCode.OK;
        }

        public PlcStopHandle()
        {
            ResultCode = ResultCode.Unknown;
            Request = new PlcStopRequest();
        }
    }
}
