using Aitex.Common.Util; using Aitex.Core.RT.DataCenter; using Aitex.Core.RT.Log; using Aitex.Core.RT.OperationCenter; using Aitex.Core.RT.SCCore; using Aitex.Core.Util; using Aitex.Core.WCF; using MECF.Framework.Common.Account; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.Event; using MECF.Framework.Common.FAServices; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.ServiceModel; using System.Xml; namespace Aitex.Core.RT.Event { public class DisplayManager : Singleton { public Dictionary DisplayDict { get; set; } = new Dictionary(); public Dictionary ProcessDetailDisplayDict { get; set; } = new Dictionary(); private string _displayReplaceFile = PathManager.GetCfgDir() + "DisplayReplace.xml"; private object _displayDicLocker = new object(); public Dictionary> ProcessDetailInfoDict { get; set; } = new Dictionary>(); public DisplayManager() { } public void Initialize() { Initialize(_displayReplaceFile); DATA.Subscribe($"System.Display", () => DisplayDict); DATA.Subscribe($"System.ProcessDetailDisplay", () => ProcessDetailDisplayDict); DATA.Subscribe($"System.ProcessDetailInfoDict", () => ProcessDetailInfoDict); } public void Initialize(string ListXmlFile) { try { if (!string.IsNullOrEmpty(ListXmlFile)) { lock (_displayDicLocker) { BuildItems(ListXmlFile); } } } catch (Exception ex) { throw new ApplicationException("DisplayReplace," + ListXmlFile + ",\r\n" + ex.Message); } } private string GetGaslineHeaterIndex(string keyStr) { if (string.IsNullOrEmpty(keyStr)) { return ""; } var item = keyStr.Split('.').Where(a => !string.IsNullOrEmpty(a) && a.Contains(ModuleName.GaslineHeater.ToString())).FirstOrDefault(); if (item == null) return ""; return item.Replace(ModuleName.GaslineHeater.ToString(), ""); } private void BuildItems(string xmlFile) { Dictionary values = new Dictionary(); try { if (File.Exists(xmlFile)) { XmlDocument xml = new XmlDocument(); xml.Load(xmlFile); XmlNodeList node = xml.SelectNodes("Displays/HistoryGroup"); foreach (XmlElement AlarmTable in node) { XmlNodeList nodeList = AlarmTable.SelectNodes("Display"); foreach (XmlElement nodeCategory in nodeList) { string key = nodeCategory.GetAttribute("Name"); string value = nodeCategory.GetAttribute("DisplayName"); if (ModuleHelper.IsHeaterBand(value)) { var auxIndex = GetGaslineHeaterIndex(key); if (!SC.ContainsItem($"PM1.RecipeEditParameter.AUX.{auxIndex}.Display")) continue; var scAuxName = SCCore.SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{auxIndex}.Display"); var valueArray = value.Split('.').ToList(); value = $"{valueArray[0]}.{scAuxName}.{valueArray[1]}"; } if (DisplayDict.ContainsKey(key)) { DisplayDict[key] = value; } else { DisplayDict.Add(key, value); } } } node = xml.SelectNodes("Displays/DetailGroup"); foreach (XmlElement AlarmTable in node) { XmlNodeList nodeList = AlarmTable.SelectNodes("Display"); foreach (XmlElement nodeCategory in nodeList) { string key = nodeCategory.GetAttribute("Name"); string value = nodeCategory.GetAttribute("DisplayName"); if (ModuleHelper.IsHeaterBand(value)) { var auxIndex = GetGaslineHeaterIndex(key); if (!SC.ContainsItem($"PM1.RecipeEditParameter.AUX.{auxIndex}.Display")) continue; var scAuxName = SCCore.SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{auxIndex}.Display"); var valueArray = value.Split('.').ToList(); value = $"{valueArray[0]}.{scAuxName}.{valueArray[1]}"; } #region 存储各个节点信息 Dictionary attributesDict = new Dictionary(); foreach (XmlAttribute attr in nodeCategory.Attributes) { if (ModuleHelper.IsHeaterBand(value) && attr.Name == "ColName" && string.IsNullOrEmpty(attr.Value)) { attributesDict[attr.Name] = value; } else { attributesDict[attr.Name] = attr.Value; } } if (ProcessDetailInfoDict.ContainsKey(key)) { ProcessDetailInfoDict[key] = attributesDict; } else { ProcessDetailInfoDict.Add(key, attributesDict); } #endregion if (ProcessDetailDisplayDict.ContainsKey(key)) { ProcessDetailDisplayDict[key] = value; } else { ProcessDetailDisplayDict.Add(key, value); } } } } } catch (Exception ex) { LOG.Write(ex); } } } }