using Aitex.Common.Util; using Aitex.Core.RT.Log; using Aitex.Core.Util; using MECF.Framework.Common.Persistent.Prewet; using MECF.Framework.Common.Persistent.Reservoirs; using MECF.Framework.Common.Persistent.Rinse; using MECF.Framework.Common.Persistent.SRD; using MECF.Framework.Common.ToolLayout; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MECF.Framework.Common.Persistent.Dryer { public class DryerPersistentManager: Singleton { #region 内部变量 private Dictionary _persistentValueDic = new Dictionary(); private Dictionary _persistentValuePathDic = new Dictionary(); #endregion /// /// 初始化 /// public void Initialize() { try { List lst = DryerItemManager.Instance.InstalledModules; foreach (string item in lst) { string foldStr = PathManager.GetCfgDir() + $"Persistent\\Dryer"; if (!Directory.Exists(foldStr)) { Directory.CreateDirectory(foldStr); } string path = PathManager.GetCfgDir() + $"Persistent\\Dryer\\{item}Persistent.xml"; _persistentValuePathDic[item] = path; if (File.Exists(path)) { DryerPersistentValue reservoirs1PersistentValue = CustomXmlSerializer.Deserialize(new FileInfo(path)); if (reservoirs1PersistentValue != null) { _persistentValueDic[item] = reservoirs1PersistentValue; } } else { DryerPersistentValue persistentValue = new DryerPersistentValue(); persistentValue.Name = item; persistentValue.OperatingMode = "Manual"; persistentValue.RecipeOperatingMode = "Engineering"; _persistentValueDic[item] = persistentValue; UpdatePersistentValue(item); } } } catch (Exception ex) { LOG.WriteLog(eEvent.ERR_DRYER, "System", "Load DryerPersistent xml exception"); } } /// /// 获取Dryer Persistent数值 /// /// public DryerPersistentValue GetDryerPersistentValue(string module) { DryerPersistentValue value = new DryerPersistentValue(); if (_persistentValueDic.ContainsKey(module)==false) { return null; } else { value = _persistentValueDic[module]; } return value; } /// /// 更新PersistentValue /// /// public void UpdatePersistentValue(string module) { if (_persistentValueDic.ContainsKey(module)) { try { CustomXmlSerializer.Serialize(_persistentValueDic[module], _persistentValuePathDic[module]); } catch (Exception ex) { LOG.WriteLog(eEvent.ERR_METAL, module, "Update DryersPersistent xml file excepetion"); } } else { LOG.WriteLog(eEvent.ERR_METAL, module, "Update DyersPersistent xml file excepetion"); } } } }