SequenceInfo.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  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 VenusGetInfo(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. //}
  358. //if (attr.Name == "WTWClean")
  359. //{
  360. // info.WTWCleanRecipe = attr.Value;
  361. //}
  362. //if (attr.Name == "PreClean")
  363. //{
  364. // info.PreWaferCleanRecipe = attr.Value;
  365. //}
  366. //if (attr.Name == "PostClean")
  367. //{
  368. // info.PostWaferCleanRecipe = attr.Value;
  369. //}
  370. }
  371. info.Steps.Add(stepInfo);
  372. }
  373. // Loadlock Single In Single Out property check
  374. var llSteps = info.Steps.FindAll(item => item.StepModules.Contains(ModuleName.LLA) || item.StepModules.Contains(ModuleName.LLB));
  375. if (llSteps.Count == 2)
  376. {
  377. if (llSteps[0].StepModules.Count == 1 && llSteps[1].StepModules.Count == 1)
  378. {
  379. if (llSteps[0].StepModules[0] != llSteps[1].StepModules[0])
  380. {
  381. info.LLInOutPath = llSteps[0].StepModules[0] == ModuleName.LLA ? SequenceLLInOutPath.AInBOut : SequenceLLInOutPath.BInAOut;
  382. }
  383. else
  384. {
  385. info.LLInOutPath = llSteps[0].StepModules[0] == ModuleName.LLA ? SequenceLLInOutPath.AInAOut : SequenceLLInOutPath.BInBOut;
  386. }
  387. }
  388. if (llSteps[1].StepParameter.ContainsKey("LLDelayTime"))
  389. {
  390. if (int.TryParse((string)llSteps[1].StepParameter["LLDelayTime"], out int delay))
  391. {
  392. info.LLDelayTime = delay;
  393. }
  394. }
  395. }
  396. }
  397. catch (Exception ex)
  398. {
  399. LOG.WriteExeption(ex);
  400. return null;
  401. }
  402. return info;
  403. }
  404. else
  405. {
  406. return null;
  407. }
  408. }
  409. public static SequenceInfo KeplerGetInfo(string seqFile)
  410. {
  411. SequenceInfo info = new SequenceInfo(seqFile);
  412. info.PMs = new List<ModuleName>();
  413. string content = RecipeFileManager.Instance.GetSequenceAndTryAppendLL(seqFile, false);
  414. if (!string.IsNullOrEmpty(content))
  415. {
  416. try
  417. {
  418. XmlDocument dom = new XmlDocument();
  419. dom.LoadXml(content);
  420. XmlNodeList lstStepNode = dom.SelectNodes("Aitex/TableSequenceData/Step");
  421. if (lstStepNode == null)
  422. {
  423. //LOG.Error($"{seqFile} has no step");
  424. return null;
  425. }
  426. var nodeData = dom.SelectSingleNode("Aitex/TableSequenceData");
  427. if (nodeData != null)
  428. {
  429. var node = nodeData as XmlElement;
  430. info.ThicknessType = node.GetAttribute("ThicknessType");
  431. }
  432. foreach (var nodeModelChild in lstStepNode)
  433. {
  434. XmlElement nodeStep = nodeModelChild as XmlElement;
  435. SequenceStepInfo stepInfo = new SequenceStepInfo();
  436. foreach (XmlAttribute attr in nodeStep.Attributes)
  437. {
  438. if (attr.Name == "PMARecipe" || attr.Name == "PMBRecipe" || attr.Name == "PMCRecipe" || attr.Name == "PMDRecipe")
  439. {
  440. string module = attr.Name.Substring(0, 3);
  441. var dictionarys = SerializeHelper.Instance.StringToDictionary(attr.Value);
  442. foreach (var dictionary in dictionarys)
  443. {
  444. string key;
  445. if (dictionary.Key == "Process")
  446. {
  447. key = $"{module}Recipe";
  448. }
  449. else
  450. {
  451. key = $"{module}{dictionary.Key}";
  452. }
  453. stepInfo.StepParameter[key] = dictionary.Value;
  454. }
  455. }
  456. else
  457. {
  458. stepInfo.StepParameter[attr.Name] = attr.Value;
  459. }
  460. if (attr.Name == "Position" || attr.Name == "LLSelection" || attr.Name == "PMSelection")
  461. {
  462. if (attr.Value == "LL" || attr.Value == "PM")
  463. continue;
  464. string[] pos = attr.Value.Split(',');
  465. if (pos.Length < 1)
  466. {
  467. LOG.Write(eEvent.WARN_SEQUENCE, ModuleName.System, $"{seqFile} Position {attr.Value} can not be empty");
  468. return null;
  469. }
  470. foreach (var po in pos)
  471. {
  472. if (po.IsEmpty())
  473. continue;
  474. if (attr.Name == "PMSelection")
  475. {
  476. info.PMs.Add(ModuleHelper.Converter(po));
  477. }
  478. if (po == "Cooling")
  479. {
  480. stepInfo.StepModules.AddIfNotContains(ModuleName.Cooling1);
  481. stepInfo.StepModules.AddIfNotContains(ModuleName.Cooling2);
  482. continue;
  483. }
  484. if (po == "Aligner")
  485. {
  486. stepInfo.StepModules.AddIfNotContains(ModuleName.Aligner1);
  487. stepInfo.StepModules.AddIfNotContains(ModuleName.Aligner2);
  488. continue;
  489. }
  490. ModuleName module = ModuleHelper.Converter(po);
  491. if (module == ModuleName.System)
  492. {
  493. //LOG.Error($"{seqFile} Position {po} not valid");
  494. return null;
  495. }
  496. stepInfo.StepModules.Add(module);
  497. }
  498. continue;
  499. }
  500. //if (attr.Name == "PMARecipe")
  501. //{
  502. //}
  503. //if (attr.Name == "WTWClean")
  504. //{
  505. // info.WTWCleanRecipe = attr.Value;
  506. //}
  507. //if (attr.Name == "PreClean")
  508. //{
  509. // info.PreWaferCleanRecipe = attr.Value;
  510. //}
  511. //if (attr.Name == "PostClean")
  512. //{
  513. // info.PostWaferCleanRecipe = attr.Value;
  514. //}
  515. }
  516. info.Steps.Add(stepInfo);
  517. }
  518. // Loadlock Single In Single Out property check
  519. var llSteps = info.Steps.FindAll(item => item.StepModules.Contains(ModuleName.LLA) || item.StepModules.Contains(ModuleName.LLB));
  520. if (llSteps.Count == 2)
  521. {
  522. if (llSteps[0].StepModules.Count == 1 && llSteps[1].StepModules.Count == 1)
  523. {
  524. if (llSteps[0].StepModules[0] != llSteps[1].StepModules[0])
  525. {
  526. info.LLInOutPath = llSteps[0].StepModules[0] == ModuleName.LLA ? SequenceLLInOutPath.AInBOut : SequenceLLInOutPath.BInAOut;
  527. }
  528. else
  529. {
  530. info.LLInOutPath = llSteps[0].StepModules[0] == ModuleName.LLA ? SequenceLLInOutPath.AInAOut : SequenceLLInOutPath.BInBOut;
  531. }
  532. }
  533. if (llSteps[1].StepParameter.ContainsKey("LLDelayTime"))
  534. {
  535. if (int.TryParse((string)llSteps[1].StepParameter["LLDelayTime"], out int delay))
  536. {
  537. info.LLDelayTime = delay;
  538. }
  539. }
  540. }
  541. }
  542. catch (Exception ex)
  543. {
  544. LOG.WriteExeption(ex);
  545. return null;
  546. }
  547. return info;
  548. }
  549. else
  550. {
  551. return null;
  552. }
  553. }
  554. }
  555. }