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

namespace Sln.Iot.CFX.Event
{
    /// <summary>
    /// 配方激活事件
    /// </summary>
    public class RecipeActivatedEvent
    {
        /// <summary>
        /// 数据封装处理
        /// </summary>
        /// <returns></returns>
        public CFXMessage Handle(string recipeName, string stageName, int stageSequence)
        {
            CFXMessage eve = null;
            try
            {
                eve = new RecipeActivated()
                {
                    RecipeName = recipeName,
                    Lane = 1,
                    Revision = "2.0",
                    RecipeStagesInformation = new List<RecipeStageInformation>()
                    {
                        new RecipeStageInformation()
                        {
                            Stage = new Stage()
                            {
                                StageSequence = stageSequence,
                                StageName = stageName,
                                StageType = StageType.Work
                            },
                        },
                    }
                };
            }
            catch (Exception e)
            {
                SerilogHelper.Instance.Error("终端节点连接事件数据封装异常", e);
            }
            return eve;
        }
    }
}
