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()
        {
            CFXMessage eve = null;
            try
            {
                eve = new RecipeActivated()
                {
                    RecipeName = "配方A",
                    Revision = "1.0",
                    Lane = 1,
                    ExpectedCycleTime = 1200000,
                    ExpectedUnitsPerWorkTransaction = 6,
                    ExpectedWorkTime = 1200000,
                    NumberOfComponentsPerUnit = 6,
                    WorkOrderIdentifier = new WorkOrderIdentifier()
                    {
                        WorkOrderId = "WO-1000-1000",
                        Batch = "WO-1000-1000-B1",
                    },
                    TargetQuantity = 500,
                    RelevantSurface = Surface.Unspecified,
                    RecipeStagesInformation = new List<RecipeStageInformation>()
                    {
                        new RecipeStageInformation()
                        {
                            Stage = new Stage()
                            {
                                StageSequence = 1,
                                StageName = "工段1",
                                StageType = StageType.Work
                            },
                            ExpectedCycleTime = 5000,
                            NumberOfComponentsPerUnit = 6,
                        },
                    }
                };
            }
            catch (Exception e)
            {
                SerilogHelper.Instance.Error("终端节点连接事件数据封装异常", e);
            }
            return eve;
        }
    }
}
