using System.Linq;
using System.Text;
using MECF.Framework.Common.Communications;

namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Aligners.HiWinAligner.Handlers
{
    public abstract class HwAlignerGuideHandler : HandlerBase
    {
        public HwAlignerGuide Device { get; }

        protected HwAlignerGuideHandler(HwAlignerGuide device, string command)
            : base(BuildMessage(command))
        {
            Device = device;
        }

        private static byte[] BuildMessage(string command)
        {
            var liCmd = Encoding.ASCII.GetBytes(command).ToList<byte>();
            liCmd.Add(0x0d); //CR
            liCmd.Add(0x0a); //LF 不可颠倒          

            return liCmd.ToArray();
        }

        public override bool HandleMessage(MessageBase msg, out bool handled)
        {
            var result = msg as HwAlignerGuideMessage;

            ResponseMessage = msg;
            handled = true;
            return true;
        }
    }
}
