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

namespace Sln.Iot.CFX.Event
{
    /// <summary>
    /// 工段完成事件
    /// </summary>
    public class WorkStageCompletedEvent
    {
        /// <summary>
        /// 数据封装处理
        /// </summary>
        /// <returns></returns>
        public CFXMessage Handle(Guid tid, string stageName, int stageSequence)
        {
            CFXMessage eve = null;
            try
            {
                eve = new WorkStageCompleted()
                {
                    TransactionID = tid,
                    Stage = new Stage()
                    {
                        StageSequence = stageSequence,
                        StageName = stageName,
                        StageType = StageType.Work
                    },
                    Result = WorkResult.Completed,
                    //PerformanceImpacts = new List<PerformanceImpact>()
                    //{
                    //    new PerformanceImpact()
                    //    {
                    //        Cause = PerformanceImpactCause.LowFeederSpeed,
                    //    }
                    //}
                };
            }
            catch (Exception e)
            {
                SerilogHelper.Instance.Error("终端节点连接事件数据封装异常", e);
            }
            return eve;
        }
    }
}
