123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- 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<DisplayManager>
- {
- public Dictionary<string, string> DisplayDict { get; set; } = new Dictionary<string, string>();
- public Dictionary<string, string> ProcessDetailDisplayDict { get; set; } = new Dictionary<string, string>();
- private string _displayReplaceFile = PathManager.GetCfgDir() + "DisplayReplace.xml";
- private object _displayDicLocker = new object();
- public Dictionary<string, Dictionary<string, string>> ProcessDetailInfoDict { get; set; } = new Dictionary<string, Dictionary<string, string>>();
- 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<string, string> values = new Dictionary<string, string>();
- 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<string, string> attributesDict = new Dictionary<string, string>();
- 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);
- }
- }
- }
- }
|