GlobalDataManager.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. using Aitex.Core.Common;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.RT.SCCore;
  4. using Aitex.Core.Util;
  5. using MECF.Framework.Common.DataCenter;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Media;
  12. using System.Xml;
  13. namespace FurnaceUI.DataModule
  14. {
  15. public class GlobalDataManager : Singleton<GlobalDataManager>
  16. {
  17. private int _lpCount = 0;
  18. public int LPCount
  19. {
  20. get
  21. {
  22. if (_lpCount == 0)
  23. {
  24. string key = "LoadPort.LPCount";
  25. if (QueryDataClient.Instance.Service.GetConfig(key) == null)
  26. {
  27. LOG.Error($"GlobalDataManager.LPCount QueryDataClient.Instance.Service.GetConfig({key}=null)");
  28. _lpCount = 4;
  29. }
  30. else
  31. {
  32. int t = (int)QueryDataClient.Instance.Service.GetConfig(key);
  33. if (t > 0 && t <= 10) _lpCount = t;
  34. else
  35. {
  36. LOG.Error($"GlobalDataManager.LPCount QueryDataClient.Instance.Service.GetConfig({key})={t} out of [1,10]");
  37. _lpCount = 4;
  38. }
  39. }
  40. }
  41. return _lpCount;
  42. }
  43. }
  44. private int _stockerCount = 0;
  45. public int StockerCount
  46. {
  47. get
  48. {
  49. if (_stockerCount == 0)
  50. {
  51. string key = "System.Stocker.StockerCount";
  52. if (QueryDataClient.Instance.Service.GetConfig(key) == null)
  53. {
  54. LOG.Error($"GlobalDataManager.LPCount QueryDataClient.Instance.Service.GetConfig({key}=null)");
  55. _stockerCount = 18;
  56. }
  57. else
  58. {
  59. int t = (int)QueryDataClient.Instance.Service.GetConfig(key);
  60. if (t > 0 && t <= 22) _stockerCount = t;
  61. else
  62. {
  63. LOG.Error($"GlobalDataManager.LPCount QueryDataClient.Instance.Service.GetConfig({key})={t} out of [1,22]");
  64. _stockerCount = 18;
  65. }
  66. }
  67. }
  68. return _stockerCount;
  69. }
  70. }
  71. private int _stockerCountByLayer = 0;
  72. public int StockerCountByLayer
  73. {
  74. get
  75. {
  76. if (_stockerCountByLayer == 0)
  77. {
  78. string key = "System.Stocker.StockerCountByLayer";
  79. if (QueryDataClient.Instance.Service.GetConfig(key) == null)
  80. {
  81. LOG.Error($"GlobalDataManager.LPCount QueryDataClient.Instance.Service.GetConfig({key}=null)");
  82. _stockerCountByLayer = 4;
  83. }
  84. else
  85. {
  86. int t = (int)QueryDataClient.Instance.Service.GetConfig(key);
  87. if (t > 0 && t < 6) _stockerCountByLayer = t;
  88. else
  89. {
  90. LOG.Error($"GlobalDataManager.LPCount QueryDataClient.Instance.Service.GetConfig({key})={t}");
  91. _stockerCountByLayer = 4;
  92. }
  93. }
  94. }
  95. return _stockerCountByLayer;
  96. }
  97. }
  98. private int _stockerLayers = 0;
  99. public int StockerLayers
  100. {
  101. get
  102. {
  103. if (_stockerLayers == 0)
  104. {
  105. string key = "System.Stocker.StockerLayers";
  106. if (QueryDataClient.Instance.Service.GetConfig(key) == null)
  107. {
  108. LOG.Error($"GlobalDataManager.LPCount QueryDataClient.Instance.Service.GetConfig({key}=null)");
  109. _stockerLayers = 4;
  110. }
  111. else
  112. {
  113. int t = (int)QueryDataClient.Instance.Service.GetConfig(key);
  114. if (t > 0 && t < 5) _stockerLayers = t;
  115. else
  116. {
  117. LOG.Error($"GlobalDataManager.LPCount QueryDataClient.Instance.Service.GetConfig({key})={t}");
  118. _stockerLayers = 4;
  119. }
  120. }
  121. }
  122. return _stockerLayers;
  123. }
  124. }
  125. private int _stockerFoupCount;
  126. /// <summary>
  127. ///正常情况应该是StockerCountByLayer*StockerLayers
  128. ///需考虑排除特殊情况
  129. /// </summary>
  130. public int StockerFoupCount
  131. {
  132. get
  133. {
  134. if (_stockerFoupCount == 0)
  135. {
  136. string key = "System.Stocker.FoupStockerCount";
  137. if (QueryDataClient.Instance.Service.GetConfig(key) == null)
  138. {
  139. LOG.Error($"GlobalDataManager.LPCount QueryDataClient.Instance.Service.GetConfig({key}=null)");
  140. _stockerFoupCount = 16;
  141. }
  142. else
  143. {
  144. int t = (int)QueryDataClient.Instance.Service.GetConfig(key);
  145. if (t > 0 && t < 22)
  146. {
  147. _stockerFoupCount = t;
  148. }
  149. else
  150. {
  151. LOG.Error($"GlobalDataManager.LPCount QueryDataClient.Instance.Service.GetConfig({key})={t}");
  152. _stockerFoupCount = 16;
  153. }
  154. }
  155. }
  156. return _stockerFoupCount;
  157. }
  158. }
  159. private Dictionary<string, WaferTypeInfo> _waferTypes;
  160. public Dictionary<string, WaferTypeInfo> WaferTypes
  161. {
  162. get
  163. {
  164. if (_waferTypes == null || _waferTypes.Count == 0)
  165. {
  166. List<WaferTypeInfo> types = QueryDataClient.Instance.Service.GetConfigWaferTypes();
  167. _waferTypes = new Dictionary<string, WaferTypeInfo>();
  168. if (types == null || types.Count == 0)
  169. {
  170. LOG.Error("GlobalDataManager.WaferTypes: QueryDataClient.Instance.Service.GetWaferTypes not find avalible");
  171. }
  172. else
  173. {
  174. foreach (var type in types)
  175. {
  176. _waferTypes[type.Name] = type;
  177. }
  178. }
  179. //_waferTypes = new Dictionary<string, WaferTypeInfo>();
  180. //var config = QueryDataClient.Instance.Service.GetConfigFileContent();
  181. //string key = "System.WaferType";
  182. //var t = GetWaferInfo(key, config);
  183. //if (t == null || t.Count == 0)
  184. //{
  185. // LOG.Error($"GlobalDataManager.WaferTypes: QueryDataClient.Instance.Service.GetConfigFileContent not find avalible [{key}]");
  186. //}
  187. //else
  188. //{
  189. // foreach (var type in t)
  190. // {
  191. // _waferTypes[type.Name] = type;
  192. // }
  193. //}
  194. }
  195. return _waferTypes;
  196. }
  197. }
  198. private List<WaferTypeInfo> GetWaferInfo(string key, string content)
  199. {
  200. XmlDocument xml = new XmlDocument();
  201. xml.LoadXml(content);
  202. XmlElement root = xml.DocumentElement;
  203. XmlNodeList xmlNodeList = xml.SelectNodes("root/configs");
  204. string[] keys = key.Split('.');
  205. foreach (XmlElement item in xmlNodeList)
  206. {
  207. if (item.GetAttribute("name") == keys[0])
  208. {
  209. foreach (XmlElement element in item.ChildNodes)
  210. {
  211. if (element.GetAttribute("name") == keys[1])
  212. {
  213. foreach (XmlElement ele in element.ChildNodes)
  214. {
  215. BuildPathConfigs(ele.GetAttribute("name"), ele);
  216. }
  217. break;
  218. }
  219. }
  220. break;
  221. }
  222. }
  223. List<WaferTypeInfo> wafers = new List<WaferTypeInfo>();
  224. BrushConverter converter = new BrushConverter();
  225. foreach (var item in dic)
  226. {
  227. if (string.IsNullOrWhiteSpace(item.Key) || item.Key == "None" || item.Key == "V" || wafers.Find(r => r.Name == item.Key) != null) continue;
  228. WaferTypeInfo typeInfo = new WaferTypeInfo() { Name = item.Key };
  229. foreach (var r in item.Value)
  230. {
  231. switch (r.Name)
  232. {
  233. case "FullName":
  234. typeInfo.FullName = string.IsNullOrWhiteSpace(r.Default) ? string.Empty : r.Default.Trim();
  235. break;
  236. case "AccFilmThick":
  237. typeInfo.AccFilmThick = bool.Parse(r.Default);
  238. break;
  239. case "AlternativeWaferType":
  240. typeInfo.AlternativeWaferType = string.IsNullOrWhiteSpace(r.Default) ? string.Empty : r.Default.Trim();
  241. break;
  242. case "IsReturnWafer":
  243. typeInfo.IsReturnWafer = bool.Parse(r.Default);
  244. break;
  245. case "ReturnWaferType":
  246. typeInfo.ReturnWaferType = string.IsNullOrWhiteSpace(r.Default) ? string.Empty : r.Default.Trim();
  247. break;
  248. case "READY":
  249. {
  250. if (string.IsNullOrWhiteSpace(r.Default) || converter.IsValid(r.Default)) typeInfo.ShowColor = r.Default ?? "".Trim();
  251. else typeInfo.ShowColor = "LightGray";//保证颜色有效
  252. }
  253. break;
  254. case "CanProcessContinuously":
  255. typeInfo.CanProcessContinuously = bool.Parse(r.Default);
  256. break;
  257. case "IsDummy":
  258. typeInfo.IsDummy = bool.Parse(r.Default);
  259. break;
  260. }
  261. }
  262. wafers.Add(typeInfo);
  263. }
  264. return wafers;
  265. }
  266. private Dictionary<string, List<SCConfigItem>> dic = new Dictionary<string, List<SCConfigItem>>();
  267. private void BuildPathConfigs(string parentPath, XmlElement configElement)
  268. {
  269. //先处理config节点
  270. XmlNodeList nodeConfigs = configElement.SelectNodes("config");
  271. List<SCConfigItem> items = new List<SCConfigItem>();
  272. foreach (XmlElement nodeConfig in nodeConfigs)
  273. {
  274. SCConfigItem item = new SCConfigItem()
  275. {
  276. Default = nodeConfig.GetAttribute("default"),
  277. Name = nodeConfig.GetAttribute("name"),
  278. Description = nodeConfig.GetAttribute("description"),
  279. Max = nodeConfig.GetAttribute("max"),
  280. Min = nodeConfig.GetAttribute("min"),
  281. Parameter = nodeConfig.GetAttribute("paramter"),
  282. Path = parentPath,
  283. Tag = nodeConfig.GetAttribute("tag"),
  284. Type = nodeConfig.GetAttribute("type"),
  285. Unit = nodeConfig.GetAttribute("unit"),
  286. };
  287. items.Add(item);
  288. }
  289. if (!dic.ContainsKey(parentPath)) dic[parentPath] = items;
  290. //再处理configs
  291. XmlNodeList nodeConfigsList = configElement.SelectNodes("configs");
  292. foreach (XmlElement nodeConfig in nodeConfigsList)
  293. {
  294. BuildPathConfigs(nodeConfig.GetAttribute("name"), nodeConfig);
  295. }
  296. }
  297. /// <summary>
  298. /// 是否需要pick、place过程主界面动画
  299. /// 应用:手动拖动时,不需要此动画
  300. /// </summary>
  301. public bool IsNeedAnimationDisplay { get; set; } = true;
  302. #region 未找到合理的界面更改配置后如何更新此配置的方式,暂时不用
  303. private Dictionary<string, string> _stockersType;
  304. /// <summary>
  305. /// 存放每个Stocker的配置的WaferType
  306. /// </summary>
  307. public Dictionary<string, string> StockersConfigType
  308. {
  309. get
  310. {
  311. if (_stockersType == null)
  312. {
  313. _stockersType = new Dictionary<string, string>();
  314. for (Int32 i = 1; i <= StockerCount; i++)
  315. {
  316. string key = $"System.Stocker.Stocker{i}WaferType";
  317. if (QueryDataClient.Instance.Service.GetConfig(key) == null)
  318. {
  319. LOG.Error($"GlobalDataManager.StockersConfigType QueryDataClient.Instance.Service.GetConfig({key}=null)");
  320. _stockersType[$"Stocker{i}"] = "";
  321. }
  322. else
  323. {
  324. _stockersType[$"Stocker{i}"] = ((string)QueryDataClient.Instance.Service.GetConfig(key)).Trim();
  325. }
  326. }
  327. }
  328. return _stockersType;
  329. }
  330. set
  331. {
  332. _stockersType = value;
  333. }
  334. }
  335. #endregion
  336. }
  337. }