VpwCellItemManager.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. string key = $"{PREFIX}{vpwCellItem.VpwCellID}";
  45. vpwCellItem.ModuleName = key;
  46. vpwCellItem.ModuleType = ModuleType.Metal.ToString();
  47. CellItemManager.Instance.InitialLayoutCellItem(vpwCellItem);
  48. if(vpwCellItem.Installed && !InstalledModules.Contains(key))
  49. {
  50. InstalledModules.Add(key);
  51. }
  52. return vpwCellItem;
  53. }
  54. /// <summary>
  55. /// 增加
  56. /// </summary>
  57. /// <param name="metalItem"></param>
  58. public void AddCellItem(VpwCellItem vpwCellItem)
  59. {
  60. _vpwCellItemDictionary[$"{PREFIX}{vpwCellItem.VpwCellID}"] = vpwCellItem;
  61. }
  62. /// <summary>
  63. /// 获取MetalItem对象
  64. /// </summary>
  65. /// <param name="moduleName"></param>
  66. /// <returns></returns>
  67. public VpwCellItem GetVpwItem(string moduleName)
  68. {
  69. return _vpwCellItemDictionary.ContainsKey(moduleName) ? _vpwCellItemDictionary[moduleName] : null;
  70. }
  71. }
  72. }