using CFX;
using CFX.Production;
using CFX.Structures;
using Sln.Iot.CFX.CFXBusiness;
using Sln.Iot.Serilog;

namespace Sln.Iot.CFX.Event
{
    /// <summary>
    /// 单元离站事件
    /// </summary>
    public class UnitsDepartedEvent
    {
        private CFXEventTools cFXEventTools = CFXEventTools.Instance;
        
        /// <summary>
        /// 数据封装处理
        /// </summary>
        /// <returns></returns>
        public CFXMessage Handle(string primaryIdentifier, string[] unitIdentifier)
        {
            CFXMessage eve = null;
            try
            {
                eve = new UnitsDeparted()
                {
                    Lane = 1,
                    PrimaryIdentifier = primaryIdentifier,
                    Units = cFXEventTools.UnitPositionTrans(unitIdentifier)
                };
            }
            catch (Exception e)
            {
                SerilogHelper.Instance.Error("终端节点连接事件数据封装异常", e);
            }
            return eve;
        }
    }
}
