123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- 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<ReservoirItemManager>
- {
- #region 常量
- /// <summary>
- /// 前缀
- /// </summary>
- private const string PREFIX = "Reservoir";
- #endregion
- #region 内部变量
- /// <summary>
- /// 字典
- /// </summary>
- private Dictionary<string,ReservoirItem> _reservoirItemDictionary=new Dictionary<string, ReservoirItem>();
- /// <summary>
- /// 化学液PlatingCell集合字典
- /// </summary>
- private Dictionary<string, List<PlatingCellItem>> _chemistryPlatingCellItemDictionary = new Dictionary<string, List<PlatingCellItem>>();
- /// <summary>
- /// PlatingCell-Reservoir字典
- /// </summary>
- private Dictionary<string, string> _platingCellReservoirDictionary = new Dictionary<string, string>();
- /// <summary>
- /// TC-Reservoir字典
- /// </summary>
- private Dictionary<string, string> _tcReservoirDictionary=new Dictionary<string, string>();
- /// <summary>
- /// Reservoir-PlatingCells字典(key-reservoir名称,value-PlatingCells集合)
- /// </summary>
- private SerializableDictionary<string, List<string>> _reseroirPlatingCellsDictionary = new SerializableDictionary<string, List<string>>();
- #endregion
- #region 属性
- /// <summary>
- /// 已经安装模块
- /// </summary>
- public List<string> InstalledModules { get; private set; } = new List<string>();
- /// <summary>
- /// Reservoir-PlatingCells字典
- /// </summary>
- public SerializableDictionary<string,List<string>> ReservoirPlatingCellsDictionary { get { return _reseroirPlatingCellsDictionary; }}
- #endregion
- /// <summary>
- /// 初始化Reservoir
- /// </summary>
- /// <param name="rinservoirElement"></param>
- 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<PlatingCellItem>();
- XmlNodeList itemsNode = reservoirElement.SelectNodes("PlatingCells/Item");
- List<string> platingCells = new List<string>();
- 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<PlatingCellItem> lst = new List<PlatingCellItem>();
- 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;
- }
- /// <summary>
- /// 获取Reservoir对象
- /// </summary>
- /// <param name="moduleName"></param>
- /// <returns></returns>
- public ReservoirItem GetReservoirItem(string moduleName)
- {
- return _reservoirItemDictionary.ContainsKey(moduleName) ? _reservoirItemDictionary[moduleName] : null;
- }
- /// <summary>
- /// 根据化学液获取所有PlatingCell集合
- /// </summary>
- /// <param name="chemistry"></param>
- /// <returns></returns>
- public List<PlatingCellItem> GetAllPlatingCellItemsByChemistry(string chemistry)
- {
- return _chemistryPlatingCellItemDictionary.ContainsKey(chemistry)?_chemistryPlatingCellItemDictionary[chemistry]: null;
- }
- /// <summary>
- /// 根据PlatingCell获取Reservoir
- /// </summary>
- /// <param name="platingCellName"></param>
- /// <returns></returns>
- public string GetReservoirByPlatingCell(string platingCellName)
- {
- return _platingCellReservoirDictionary.ContainsKey(platingCellName) ? _platingCellReservoirDictionary[platingCellName] : "";
- }
- /// <summary>
- /// 根据TC获取Reservoir
- /// </summary>
- /// <param name="tcName"></param>
- /// <returns></returns>
- public string GetReservoirByTC(string tcName)
- {
- return _tcReservoirDictionary.ContainsKey(tcName) ? _tcReservoirDictionary[tcName] : "";
- }
- /// <summary>
- /// 获取Reservoir下面PlatingCells
- /// </summary>
- /// <param name="reservoirName"></param>
- /// <returns></returns>
- public List<string> GetPlatingCellsByReservoir(string reservoirName)
- {
- return _reseroirPlatingCellsDictionary.ContainsKey(reservoirName)?_reseroirPlatingCellsDictionary[reservoirName] : null;
- }
- }
- }
|