using Aitex.Core.RT.DataCenter; using Aitex.Core.Util; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml; namespace MECF.Framework.Common.ToolLayout { public class ReservoirItemManager : Singleton { #region 常量 /// /// 前缀 /// private const string PREFIX = "Reservoir"; #endregion #region 内部变量 /// /// 字典 /// private Dictionary _reservoirItemDictionary=new Dictionary(); /// /// 化学液PlatingCell集合字典 /// private Dictionary> _chemistryPlatingCellItemDictionary = new Dictionary>(); /// /// PlatingCell-Reservoir字典 /// private Dictionary _platingCellReservoirDictionary = new Dictionary(); /// /// TC-Reservoir字典 /// private Dictionary _tcReservoirDictionary=new Dictionary(); /// /// Reservoir-PlatingCells字典(key-reservoir名称,value-PlatingCells集合) /// private SerializableDictionary> _reseroirPlatingCellsDictionary = new SerializableDictionary>(); #endregion #region 属性 /// /// 已经安装模块 /// public List InstalledModules { get; private set; } = new List(); /// /// Reservoir-PlatingCells字典 /// public SerializableDictionary> ReservoirPlatingCellsDictionary { get { return _reseroirPlatingCellsDictionary; }} #endregion /// /// 初始化Reservoir /// /// public void InitializeReservoirItem(XmlElement reservoirElement) { ReservoirItem reservoirItem = new ReservoirItem(); reservoirItem.Installed = bool.Parse(reservoirElement.SelectSingleNode("Installed").InnerText); reservoirItem.ReservoirID = int.Parse(reservoirElement.SelectSingleNode("ReservoirID").InnerText); reservoirItem.SubType = reservoirElement.SelectSingleNode("SubType").InnerText; reservoirItem.TCID = reservoirElement.SelectSingleNode("TCID").InnerText; reservoirItem.PHProbeChannelNumber = int.Parse(reservoirElement.SelectSingleNode("PHProbeChannelNumber").InnerText); reservoirItem.PlannedInitialChemistry = reservoirElement.SelectSingleNode("PlannedInitialChemistry").InnerText; string key = $"{PREFIX}{reservoirItem.ReservoirID}"; _tcReservoirDictionary[reservoirItem.TCID] = key; reservoirItem.PlatingCells = new List(); XmlNodeList itemsNode = reservoirElement.SelectNodes("PlatingCells/Item"); List platingCells = new List(); foreach (var item in itemsNode) { XmlElement element = item as XmlElement; PlatingCellItem platingCellItem = PlatingCellItemManager.Instance.InitializePlatingCellItem(element); PlatingCellItemManager.Instance.AddPlatingCellItem(platingCellItem); reservoirItem.PlatingCells.Add(platingCellItem); if(reservoirItem.Installed&&platingCellItem.Installed) { List lst = new List(); if(_chemistryPlatingCellItemDictionary.ContainsKey(reservoirItem.PlannedInitialChemistry)) { lst = _chemistryPlatingCellItemDictionary[reservoirItem.PlannedInitialChemistry]; } else { _chemistryPlatingCellItemDictionary[reservoirItem.PlannedInitialChemistry] = lst; } if(lst.FindIndex(O=>O.PlatingCellID==platingCellItem.PlatingCellID)==-1) { lst.Add(platingCellItem); } _platingCellReservoirDictionary[platingCellItem.ModuleName] = key; if (!platingCells.Contains(platingCellItem.ModuleName)) { platingCells.Add(platingCellItem.ModuleName); } } } if (reservoirItem.Installed) { _reseroirPlatingCellsDictionary[key] = platingCells; } reservoirItem.CellPosition = int.Parse(reservoirElement.SelectSingleNode("CellPosition").InnerText); reservoirItem.PositionInMilliMeters = int.Parse(reservoirElement.SelectSingleNode("PositionInMilliMeters").InnerText); reservoirItem.LengthInMilliMeters = int.Parse(reservoirElement.SelectSingleNode("LengthInMilliMeters").InnerText); reservoirItem.ChemicalReplenishmentEnable = bool.Parse(reservoirElement.SelectSingleNode("ChemicalReplenishmentEnable").InnerText); reservoirItem.DIReplenType = reservoirElement.SelectSingleNode("DIReplenType").InnerText; reservoirItem.ANDIReplenType = reservoirElement.SelectSingleNode("ANDIReplenType").InnerText; reservoirItem.PHProbeType = reservoirElement.SelectSingleNode("PHProbeType").InnerText; reservoirItem.CrossDoseType = reservoirElement.SelectSingleNode("CrossDoseType").InnerText; reservoirItem.ChemReplenType = reservoirElement.SelectSingleNode("ChemReplenType").InnerText; reservoirItem.ChemReplenPumps = int.Parse(reservoirElement.SelectSingleNode("ChemReplenPumps").InnerText); reservoirItem.AutoDrainsInstalled = bool.Parse(reservoirElement.SelectSingleNode("AutoDrainsInstalled").InnerText); reservoirItem.SlipstreamType = reservoirElement.SelectSingleNode("SlipstreamType").InnerText; reservoirItem.CMMType = reservoirElement.SelectSingleNode("CMMType").InnerText; reservoirItem.CMMSupplyID = reservoirElement.SelectSingleNode("CMMSupplyID").InnerText; reservoirItem.EvaporatorType = reservoirElement.SelectSingleNode("EvaporatorType").InnerText; DATA.Subscribe($"{key}.CMMPowerSupplier", () => { return reservoirItem.CMMSupplyID; }, SubscriptionAttribute.FLAG.IgnoreSaveDB); if (reservoirItem.Installed && !InstalledModules.Contains(key)) { InstalledModules.Add(key); } _reservoirItemDictionary[key] = reservoirItem; } /// /// 获取Reservoir对象 /// /// /// public ReservoirItem GetReservoirItem(string moduleName) { return _reservoirItemDictionary.ContainsKey(moduleName) ? _reservoirItemDictionary[moduleName] : null; } /// /// 根据化学液获取所有PlatingCell集合 /// /// /// public List GetAllPlatingCellItemsByChemistry(string chemistry) { return _chemistryPlatingCellItemDictionary.ContainsKey(chemistry)?_chemistryPlatingCellItemDictionary[chemistry]: null; } /// /// 根据PlatingCell获取Reservoir /// /// /// public string GetReservoirByPlatingCell(string platingCellName) { return _platingCellReservoirDictionary.ContainsKey(platingCellName) ? _platingCellReservoirDictionary[platingCellName] : ""; } /// /// 根据TC获取Reservoir /// /// /// public string GetReservoirByTC(string tcName) { return _tcReservoirDictionary.ContainsKey(tcName) ? _tcReservoirDictionary[tcName] : ""; } /// /// 获取Reservoir下面PlatingCells /// /// /// public List GetPlatingCellsByReservoir(string reservoirName) { return _reseroirPlatingCellsDictionary.ContainsKey(reservoirName)?_reseroirPlatingCellsDictionary[reservoirName] : null; } } }