using Aitex.Common.Util; using Aitex.Core.Common; using Aitex.Core.RT.Log; using Aitex.Core.Util; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.Utilities; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MECF.Framework.Common.ToolLayout { public class CellItemRecipeTimeManager : Singleton { #region 内部变量 /// /// Recipe时间字典(key-recipe ppid,value-时间总和) /// private Dictionary _recipeTimeDictionary = new Dictionary(); #endregion /// /// 初始化 /// public void Initialize() { _recipeTimeDictionary = BinarySerializer>.FromStream("RecipeTimeManager"); } /// /// 是否包含 /// /// /// public bool ContainRecipe(string ppid) { return _recipeTimeDictionary.ContainsKey(ppid); } /// /// 获取recipe时间总和 /// /// /// public int GetRecipeTotalTime(string ppid) { return _recipeTimeDictionary.ContainsKey(ppid) ? _recipeTimeDictionary[ppid] : int.MaxValue; } /// /// 更新Recipe时长 /// /// /// public void UpdateRecipeTime(string ppid,int time) { _recipeTimeDictionary[ppid] = time; Serialize(); } /// /// 序列化 /// private async void Serialize() { await Task.Run(() => { try { BinarySerializer>.ToStream(_recipeTimeDictionary, "RecipeTimeManager"); } catch (Exception ex) { LOG.WriteExeption(ex); } }); } } }