SequenceInfo.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.Serialization;
  5. using System.Xml;
  6. using Aitex.Core.RT.Log;
  7. using Aitex.Core.RT.RecipeCenter;
  8. using MECF.Framework.Common.Equipment;
  9. using SciChart.Core.Extensions;
  10. using Venus_Unity;
  11. namespace MECF.Framework.Common.Jobs
  12. {
  13. public enum JobRecipeType
  14. {
  15. PreLotClean,
  16. Process,
  17. WTWClean,
  18. PostLotClean
  19. }
  20. public enum SequenceLLInOutPath
  21. {
  22. AInBOut,
  23. BInAOut,
  24. DInDOut,
  25. AInAOut,
  26. BInBOut,
  27. }
  28. [Serializable]
  29. [DataContract]
  30. public class SequenceInfo
  31. {
  32. [DataMember]
  33. public List<SequenceStepInfo> Steps { get; set; }
  34. [DataMember]
  35. public string Name { get; set; }
  36. //[DataMember]
  37. //public string PreWaferCleanRecipe { get; set; }
  38. //[DataMember]
  39. //public string PostWaferCleanRecipe { get; set; }
  40. [DataMember]
  41. public string WTWCleanRecipe { get; set; }
  42. [DataMember]
  43. public List<ModuleName> PMs { get; set; }
  44. [DataMember]
  45. public string ThicknessType { get; set; }
  46. [DataMember]
  47. public Guid InnerId { get; set; }
  48. [DataMember]
  49. public SequenceLLInOutPath LLInOutPath { get; set; }
  50. [DataMember]
  51. public int LLDelayTime { get; set; }
  52. public SequenceInfo(string name)
  53. {
  54. Name = name;
  55. InnerId = Guid.NewGuid();
  56. LLInOutPath = SequenceLLInOutPath.DInDOut;
  57. LLDelayTime = 0;
  58. Steps = new List<SequenceStepInfo>();
  59. }
  60. public string GetRecipe(ModuleName pm)
  61. {
  62. if (!ModuleHelper.IsPm(pm))
  63. return string.Empty;
  64. string attr = $"{pm}Recipe";
  65. foreach (var step in Steps)
  66. {
  67. if (step.StepModules.Contains(pm))
  68. {
  69. return (string)step.StepParameter[attr];
  70. }
  71. }
  72. return string.Empty;
  73. }
  74. public string GetPreCleanRecipe(ModuleName pm)
  75. {
  76. if (!ModuleHelper.IsPm(pm))
  77. return string.Empty;
  78. string attr = $"{pm}PreLotClean";
  79. foreach (var step in Steps)
  80. {
  81. if (step.StepModules.Contains(pm) && step.StepParameter.ContainsKey(attr))
  82. {
  83. return (string)step.StepParameter[attr];
  84. }
  85. }
  86. return string.Empty;
  87. }
  88. public string GetWTWCleanRecipe(ModuleName pm)
  89. {
  90. if (!ModuleHelper.IsPm(pm))
  91. return string.Empty;
  92. string attr = $"{pm}WTWClean";
  93. foreach (var step in Steps)
  94. {
  95. if (step.StepModules.Contains(pm) && step.StepParameter.ContainsKey(attr))
  96. {
  97. return (string)step.StepParameter[attr];
  98. }
  99. }
  100. return string.Empty;
  101. }
  102. public string GetPostCleanRecipe(ModuleName pm)
  103. {
  104. if (!ModuleHelper.IsPm(pm))
  105. return string.Empty;
  106. string attr = $"{pm}PostLotClean";
  107. foreach (var step in Steps)
  108. {
  109. if (step.StepModules.Contains(pm) && step.StepParameter.ContainsKey(attr))
  110. {
  111. return (string)step.StepParameter[attr];
  112. }
  113. }
  114. return string.Empty;
  115. }
  116. // public string GetRecipe(ModuleName pm, JobRecipeType jobRecipeType)
  117. // {
  118. // if (!ModuleHelper.IsPm(pm))
  119. // return string.Empty;
  120. // string attr = $"{pm}Recipe";
  121. // foreach (var step in Steps)
  122. // {
  123. // if (step.StepModules.Contains(pm))
  124. // {
  125. // string recipeInfoString = (string)step.StepParameter[attr];
  126. // var recipeInfoDictionary= SerializeHelper.Instance.StringToDictionary(recipeInfoString);
  127. // if (recipeInfoDictionary.Keys.Contains(jobRecipeType.ToString()))
  128. // {
  129. // return recipeInfoDictionary[jobRecipeType.ToString()];
  130. // }
  131. // }
  132. // }
  133. // return string.Empty;
  134. // }
  135. //}
  136. }
  137. public class SequenceInfoHelper
  138. {
  139. public static SequenceInfo GetInfo(string seqFile)
  140. {
  141. SequenceInfo info = new SequenceInfo(seqFile);
  142. info.PMs = new List<ModuleName>();
  143. string content = RecipeFileManager.Instance.GetSequenceAndTryAppendLL(seqFile, false);
  144. if (!string.IsNullOrEmpty(content))
  145. {
  146. try
  147. {
  148. XmlDocument dom = new XmlDocument();
  149. dom.LoadXml(content);
  150. XmlNodeList lstStepNode = dom.SelectNodes("Aitex/TableSequenceData/Step");
  151. if (lstStepNode == null)
  152. {
  153. //LOG.Error($"{seqFile} has no step");
  154. return null;
  155. }
  156. var nodeData = dom.SelectSingleNode("Aitex/TableSequenceData");
  157. if (nodeData != null)
  158. {
  159. var node = nodeData as XmlElement;
  160. info.ThicknessType = node.GetAttribute("ThicknessType");
  161. }
  162. foreach (var nodeModelChild in lstStepNode)
  163. {
  164. XmlElement nodeStep = nodeModelChild as XmlElement;
  165. SequenceStepInfo stepInfo = new SequenceStepInfo();
  166. foreach (XmlAttribute attr in nodeStep.Attributes)
  167. {
  168. stepInfo.StepParameter[attr.Name] = attr.Value;
  169. if (attr.Name == "Position" || attr.Name == "LLSelection" || attr.Name == "PMSelection")
  170. {
  171. if (attr.Value == "LL" || attr.Value == "PM")
  172. continue;
  173. string[] pos = attr.Value.Split(',');
  174. if (pos.Length < 1)
  175. {
  176. LOG.Write(eEvent.WARN_SEQUENCE, ModuleName.System, $"{seqFile} Position {attr.Value} can not be empty");
  177. return null;
  178. }
  179. foreach (var po in pos)
  180. {
  181. if (po.IsEmpty())
  182. continue;
  183. if (attr.Name == "PMSelection")
  184. {
  185. info.PMs.Add(ModuleHelper.Converter(po));
  186. }
  187. if (po == "Cooling")
  188. {
  189. stepInfo.StepModules.AddIfNotContains(ModuleName.Cooling1);
  190. stepInfo.StepModules.AddIfNotContains(ModuleName.Cooling2);
  191. continue;
  192. }
  193. if (po == "Aligner")
  194. {
  195. stepInfo.StepModules.AddIfNotContains(ModuleName.Aligner1);
  196. stepInfo.StepModules.AddIfNotContains(ModuleName.Aligner2);
  197. continue;
  198. }
  199. ModuleName module = ModuleHelper.Converter(po);
  200. if (module == ModuleName.System)
  201. {
  202. //LOG.Error($"{seqFile} Position {po} not valid");
  203. return null;
  204. }
  205. stepInfo.StepModules.Add(module);
  206. }
  207. continue;
  208. }
  209. if (attr.Name == "PMARecipe")
  210. {
  211. }
  212. if (attr.Name == "WTWClean")
  213. {
  214. info.WTWCleanRecipe = attr.Value;
  215. }
  216. //if (attr.Name == "PreClean")
  217. //{
  218. // info.PreWaferCleanRecipe = attr.Value;
  219. //}
  220. //if (attr.Name == "PostClean")
  221. //{
  222. // info.PostWaferCleanRecipe = attr.Value;
  223. //}
  224. }
  225. info.Steps.Add(stepInfo);
  226. }
  227. // Loadlock Single In Single Out property check
  228. var llSteps = info.Steps.FindAll(item => item.StepModules.Contains(ModuleName.LLA) || item.StepModules.Contains(ModuleName.LLB));
  229. if (llSteps.Count == 2)
  230. {
  231. if (llSteps[0].StepModules.Count == 1 && llSteps[1].StepModules.Count == 1)
  232. {
  233. if (llSteps[0].StepModules[0] != llSteps[1].StepModules[0])
  234. {
  235. info.LLInOutPath = llSteps[0].StepModules[0] == ModuleName.LLA ? SequenceLLInOutPath.AInBOut : SequenceLLInOutPath.BInAOut;
  236. }
  237. else
  238. {
  239. info.LLInOutPath = llSteps[0].StepModules[0] == ModuleName.LLA ? SequenceLLInOutPath.AInAOut : SequenceLLInOutPath.BInBOut;
  240. }
  241. }
  242. if (llSteps[1].StepParameter.ContainsKey("LLDelayTime"))
  243. {
  244. if (int.TryParse((string)llSteps[1].StepParameter["LLDelayTime"], out int delay))
  245. {
  246. info.LLDelayTime = delay;
  247. }
  248. }
  249. }
  250. }
  251. catch (Exception ex)
  252. {
  253. LOG.WriteExeption(ex);
  254. return null;
  255. }
  256. return info;
  257. }
  258. else
  259. {
  260. return null;
  261. }
  262. }
  263. public static SequenceInfo KeplerGetInfo(string seqFile)
  264. {
  265. SequenceInfo info = new SequenceInfo(seqFile);
  266. info.PMs = new List<ModuleName>();
  267. string content = RecipeFileManager.Instance.GetSequenceAndTryAppendLL(seqFile, false);
  268. if (!string.IsNullOrEmpty(content))
  269. {
  270. try
  271. {
  272. XmlDocument dom = new XmlDocument();
  273. dom.LoadXml(content);
  274. XmlNodeList lstStepNode = dom.SelectNodes("Aitex/TableSequenceData/Step");
  275. if (lstStepNode == null)
  276. {
  277. //LOG.Error($"{seqFile} has no step");
  278. return null;
  279. }
  280. var nodeData = dom.SelectSingleNode("Aitex/TableSequenceData");
  281. if (nodeData != null)
  282. {
  283. var node = nodeData as XmlElement;
  284. info.ThicknessType = node.GetAttribute("ThicknessType");
  285. }
  286. foreach (var nodeModelChild in lstStepNode)
  287. {
  288. XmlElement nodeStep = nodeModelChild as XmlElement;
  289. SequenceStepInfo stepInfo = new SequenceStepInfo();
  290. foreach (XmlAttribute attr in nodeStep.Attributes)
  291. {
  292. if (attr.Name == "PMARecipe" || attr.Name == "PMBRecipe" || attr.Name == "PMCRecipe" || attr.Name == "PMDRecipe")
  293. {
  294. string module = attr.Name.Substring(0, 3);
  295. var dictionarys = SerializeHelper.Instance.StringToDictionary(attr.Value);
  296. foreach (var dictionary in dictionarys)
  297. {
  298. string key;
  299. if (dictionary.Key == "Process")
  300. {
  301. key = $"{module}Recipe";
  302. }
  303. else
  304. {
  305. key = $"{module}{dictionary.Key}";
  306. }
  307. stepInfo.StepParameter[key] = dictionary.Value;
  308. }
  309. }
  310. else
  311. {
  312. stepInfo.StepParameter[attr.Name] = attr.Value;
  313. }
  314. if (attr.Name == "Position" || attr.Name == "LLSelection" || attr.Name == "PMSelection")
  315. {
  316. if (attr.Value == "LL" || attr.Value == "PM")
  317. continue;
  318. string[] pos = attr.Value.Split(',');
  319. if (pos.Length < 1)
  320. {
  321. LOG.Write(eEvent.WARN_SEQUENCE, ModuleName.System, $"{seqFile} Position {attr.Value} can not be empty");
  322. return null;
  323. }
  324. foreach (var po in pos)
  325. {
  326. if (po.IsEmpty())
  327. continue;
  328. if (attr.Name == "PMSelection")
  329. {
  330. info.PMs.Add(ModuleHelper.Converter(po));
  331. }
  332. if (po == "Cooling")
  333. {
  334. stepInfo.StepModules.AddIfNotContains(ModuleName.Cooling1);
  335. stepInfo.StepModules.AddIfNotContains(ModuleName.Cooling2);
  336. continue;
  337. }
  338. if (po == "Aligner")
  339. {
  340. stepInfo.StepModules.AddIfNotContains(ModuleName.Aligner1);
  341. stepInfo.StepModules.AddIfNotContains(ModuleName.Aligner2);
  342. continue;
  343. }
  344. ModuleName module = ModuleHelper.Converter(po);
  345. if (module == ModuleName.System)
  346. {
  347. //LOG.Error($"{seqFile} Position {po} not valid");
  348. return null;
  349. }
  350. stepInfo.StepModules.Add(module);
  351. }
  352. continue;
  353. }
  354. //if (attr.Name == "PMARecipe")
  355. //{
  356. //}
  357. //if (attr.Name == "WTWClean")
  358. //{
  359. // info.WTWCleanRecipe = attr.Value;
  360. //}
  361. //if (attr.Name == "PreClean")
  362. //{
  363. // info.PreWaferCleanRecipe = attr.Value;
  364. //}
  365. //if (attr.Name == "PostClean")
  366. //{
  367. // info.PostWaferCleanRecipe = attr.Value;
  368. //}
  369. }
  370. info.Steps.Add(stepInfo);
  371. }
  372. // Loadlock Single In Single Out property check
  373. var llSteps = info.Steps.FindAll(item => item.StepModules.Contains(ModuleName.LLA) || item.StepModules.Contains(ModuleName.LLB));
  374. if (llSteps.Count == 2)
  375. {
  376. if (llSteps[0].StepModules.Count == 1 && llSteps[1].StepModules.Count == 1)
  377. {
  378. if (llSteps[0].StepModules[0] != llSteps[1].StepModules[0])
  379. {
  380. info.LLInOutPath = llSteps[0].StepModules[0] == ModuleName.LLA ? SequenceLLInOutPath.AInBOut : SequenceLLInOutPath.BInAOut;
  381. }
  382. else
  383. {
  384. info.LLInOutPath = llSteps[0].StepModules[0] == ModuleName.LLA ? SequenceLLInOutPath.AInAOut : SequenceLLInOutPath.BInBOut;
  385. }
  386. }
  387. if (llSteps[1].StepParameter.ContainsKey("LLDelayTime"))
  388. {
  389. if (int.TryParse((string)llSteps[1].StepParameter["LLDelayTime"], out int delay))
  390. {
  391. info.LLDelayTime = delay;
  392. }
  393. }
  394. }
  395. }
  396. catch (Exception ex)
  397. {
  398. LOG.WriteExeption(ex);
  399. return null;
  400. }
  401. return info;
  402. }
  403. else
  404. {
  405. return null;
  406. }
  407. }
  408. }
  409. }