ResistivityProbeItemManager.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using Aitex.Core.Util;
  2. using MECF.Framework.Common.Equipment;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Xml;
  9. namespace MECF.Framework.Common.ToolLayout
  10. {
  11. public class ResistivityProbeItemManager : Singleton<ResistivityProbeItemManager>
  12. {
  13. #region 常量
  14. /// <summary>
  15. /// 前缀
  16. /// </summary>
  17. private const string PREFIX = "RP";
  18. #endregion
  19. #region 内部变量
  20. /// <summary>
  21. /// 字典
  22. /// </summary>
  23. private Dictionary<string, ResistivityProbeItem> _moduleItemDictionary = new Dictionary<string, ResistivityProbeItem>();
  24. #endregion
  25. #region 属性
  26. /// <summary>
  27. /// 已经安装模块
  28. /// </summary>
  29. public List<string> InstalledModules { get; private set; } = new List<string>();
  30. #endregion
  31. /// <summary>
  32. /// 初始化
  33. /// </summary>
  34. /// <param name="xmlElement"></param>
  35. public void InitializeItem(XmlElement xmlElement)
  36. {
  37. ResistivityProbeItem rpItem = new ResistivityProbeItem();
  38. rpItem.Installed = bool.Parse(xmlElement.SelectSingleNode("Installed").InnerText);
  39. rpItem.ResistivityProbeID = int.Parse(xmlElement.SelectSingleNode("ResistivityProbeID").InnerText);
  40. rpItem.SubType = xmlElement.SelectSingleNode("SubType").InnerText;
  41. rpItem.Count = int.Parse(xmlElement.SelectSingleNode("Count").InnerText);
  42. string key = $"{PREFIX}{rpItem.ResistivityProbeID}";
  43. if (rpItem.Installed && !InstalledModules.Contains(key))
  44. {
  45. InstalledModules.Add(key);
  46. }
  47. _moduleItemDictionary[key] = rpItem;
  48. }
  49. /// <summary>
  50. /// 获取ResistivityProbe项
  51. /// </summary>
  52. /// <returns></returns>
  53. public ResistivityProbeItem GetResistivityProbeItem(string moduleName)
  54. {
  55. return _moduleItemDictionary.ContainsKey(moduleName) ? _moduleItemDictionary[moduleName]:null;
  56. }
  57. }
  58. }