VpwCellItemManager.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using Aitex.Core.RT.DataCenter;
  2. using Aitex.Core.Util;
  3. using MECF.Framework.Common.Device.LinMot;
  4. using MECF.Framework.Common.Device.PowerSupplier;
  5. using MECF.Framework.Common.Equipment;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Xml;
  12. namespace MECF.Framework.Common.ToolLayout
  13. {
  14. public class VpwCellItemManager : Singleton<VpwCellItemManager>
  15. {
  16. #region 常量
  17. /// <summary>
  18. /// 前缀
  19. /// </summary>
  20. private const string PREFIX = "VPW";
  21. #endregion
  22. #region 内部变量
  23. /// <summary>
  24. /// 字典
  25. /// </summary>
  26. private Dictionary<string,VpwCellItem> _vpwCellItemDictionary=new Dictionary<string, VpwCellItem>();
  27. #endregion
  28. #region 属性
  29. /// <summary>
  30. /// 已经安装模块
  31. /// </summary>
  32. public List<string> InstalledModules { get; private set; } = new List<string>();
  33. #endregion
  34. /// <summary>
  35. /// 初始化metal
  36. /// </summary>
  37. /// <param name="metalItemElement"></param>
  38. public VpwCellItem InitializeVpwCellItem(XmlElement element)
  39. {
  40. VpwCellItem vpwCellItem = new VpwCellItem();
  41. vpwCellItem.CellType = "Cell";
  42. LayoutCellItemManager.Instance.InitializeLayoutCellItem(vpwCellItem, element);
  43. vpwCellItem.VpwCellID = int.Parse(element.SelectSingleNode("VpwCellID").InnerText);
  44. vpwCellItem.ResistivityID = element.SelectSingleNode("ResistivityID").InnerText;
  45. string key = $"{PREFIX}{vpwCellItem.VpwCellID}";
  46. vpwCellItem.ModuleName = key;
  47. vpwCellItem.ModuleType = ModuleType.Metal.ToString();
  48. CellItemManager.Instance.InitialLayoutCellItem(vpwCellItem);
  49. if(vpwCellItem.Installed && !InstalledModules.Contains(key))
  50. {
  51. InstalledModules.Add(key);
  52. }
  53. return vpwCellItem;
  54. }
  55. /// <summary>
  56. /// 增加
  57. /// </summary>
  58. /// <param name="metalItem"></param>
  59. public void AddCellItem(VpwCellItem vpwCellItem)
  60. {
  61. _vpwCellItemDictionary[$"{PREFIX}{vpwCellItem.VpwCellID}"] = vpwCellItem;
  62. }
  63. /// <summary>
  64. /// 获取MetalItem对象
  65. /// </summary>
  66. /// <param name="moduleName"></param>
  67. /// <returns></returns>
  68. public VpwCellItem GetVpwItem(string moduleName)
  69. {
  70. return _vpwCellItemDictionary.ContainsKey(moduleName) ? _vpwCellItemDictionary[moduleName] : null;
  71. }
  72. }
  73. }