SC.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. using System;
  2. using System.Collections.Generic;
  3. using Aitex.Core.Common;
  4. using Aitex.Core.RT.ConfigCenter;
  5. using Aitex.Core.RT.IOCore;
  6. using MECF.Framework.Common.SCCore;
  7. namespace Aitex.Core.RT.SCCore
  8. {
  9. public static class SC
  10. {
  11. public const string VaribleType = "V";
  12. public static ISCManager Manager { set; private get; }
  13. public static Dictionary<string, ISCManager> ModularManager { private set; get; } = new Dictionary<string, ISCManager>();
  14. public static bool IsEnable => Manager != null;
  15. public static void SetItemValue(string name, object value)
  16. {
  17. if (Manager != null)
  18. Manager.SetItemValue(name, value);
  19. }
  20. public static void SetItemValueStringFormat(string name, string value)
  21. {
  22. if (Manager != null)
  23. Manager.SetItemValueStringFormat(name, value);
  24. }
  25. public static void SetItemValue(string name, bool value)
  26. {
  27. if (Manager != null)
  28. Manager.SetItemValue(name, value);
  29. }
  30. public static void SetItemValue(string name, int value)
  31. {
  32. if (Manager != null)
  33. Manager.SetItemValue(name, value);
  34. }
  35. public static void SetItemValue(string name, double value)
  36. {
  37. if (Manager != null)
  38. Manager.SetItemValue(name, value);
  39. }
  40. public static void SetItemValue(string name, string value)
  41. {
  42. if (Manager != null)
  43. Manager.SetItemValue(name, value);
  44. }
  45. public static void SetItemValueFromString(string name, string value)
  46. {
  47. if (Manager != null)
  48. Manager.SetItemValueFromString(name, value);
  49. }
  50. public static SCConfigItem GetConfigItem(string name)
  51. {
  52. if (Manager != null)
  53. return Manager.GetConfigItem(name);
  54. return null;
  55. }
  56. public static bool ContainsItem(string name)
  57. {
  58. if (Manager != null)
  59. return Manager.ContainsItem(name);
  60. return false;
  61. }
  62. public static SCConfigItem GetConfigItem(string path, string name)
  63. {
  64. return GetConfigItem(path+"."+name);
  65. }
  66. public static T GetValue<T>(string name) where T : struct
  67. {
  68. if (Manager != null)
  69. return Manager.GetValue<T>(name);
  70. return default(T);
  71. }
  72. public static string GetStringValue(string name)
  73. {
  74. if (Manager != null)
  75. return Manager.GetStringValue(name);
  76. return null;
  77. }
  78. /// <summary>
  79. /// 如果找不到对应的SC,用默认值代替
  80. /// </summary>
  81. /// <typeparam name="T"></typeparam>
  82. /// <param name="name"></param>
  83. /// <param name="defaultValue"></param>
  84. /// <returns></returns>
  85. public static T SafeGetValue<T>(string name, T defaultValue) where T : struct
  86. {
  87. if (Manager != null)
  88. return Manager.SafeGetValue<T>(name, defaultValue);
  89. return default(T);
  90. }
  91. /// <summary>
  92. /// 如果找不到对应的SC,用默认值代替
  93. /// </summary>
  94. /// <param name="name"></param>
  95. /// <param name="defaultValue"></param>
  96. /// <returns></returns>
  97. public static string SafeGetStringValue(string name, string defaultValue)
  98. {
  99. if (Manager != null)
  100. return Manager.SafeGetStringValue(name, defaultValue);
  101. return null;
  102. }
  103. public static List<SCConfigItem> GetItemList()
  104. {
  105. if (Manager != null)
  106. return Manager.GetItemList();
  107. return null;
  108. }
  109. public static List<WaferTypeInfo> GetWaferTypes()
  110. {
  111. if (Manager != null)
  112. return Manager.GetWaferTypes();
  113. return null;
  114. }
  115. public static Dictionary<string, Dictionary<string, string>> GetAllWaferTypeColor()
  116. {
  117. if (Manager != null)
  118. return Manager.GetAllWaferTypeColor();
  119. return null;
  120. }
  121. public static string GetConfigFileContent( )
  122. {
  123. if (Manager != null)
  124. return Manager.GetFileContent();
  125. return "";
  126. }
  127. public static string GetConfigFileContent(string module)
  128. {
  129. if (Manager != null && ModularManager!=null && ModularManager.ContainsKey(module) && ModularManager[module]!=null)
  130. return ModularManager[module].GetFileContent();
  131. return GetConfigFileContent();
  132. }
  133. }
  134. }