using CFX;
using CFX.Production.Processing;
using CFX.Structures;
using CFX.Structures.CommonUseEquipment;
using Sln.Iot.Serilog;

namespace Sln.Iot.CFX.Event
{
    /// <summary>
    /// 单元加工完成事件
    /// </summary>
    public class UnitsProcessedEvent
    {
        /// <summary>
        /// 数据封装处理
        /// </summary>
        /// <returns></returns>
        public CFXMessage Handle(Guid tid, CommonProcessData processData)
        {
            CFXMessage eve = null;
            try
            {
                eve = new UnitsProcessed()
                {
                    TransactionId = tid,
                    OverallResult = ProcessingResult.Succeeded,
                    CommonProcessData = processData,
                    UnitProcessData = null
                };
            }
            catch (Exception e)
            {
                SerilogHelper.Instance.Error("终端节点连接事件数据封装异常", e);
            }
            return eve;
        }
    }
}
