SequenceInfo.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  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 GetLongIdleCleanRecipe(ModuleName pm, out int idletime)
  75. {
  76. idletime = -1;
  77. if (!ModuleHelper.IsPm(pm))
  78. return string.Empty;
  79. string attr = $"{pm}IdleClean";
  80. string timeattr = $"{pm}IdleTime";
  81. foreach (var step in Steps)
  82. {
  83. if (step.StepModules.Contains(pm) && step.StepParameter.ContainsKey(timeattr))
  84. {
  85. idletime = Convert.ToInt32(step.StepParameter[timeattr]);
  86. }
  87. }
  88. foreach (var step in Steps)
  89. {
  90. if (step.StepModules.Contains(pm) && step.StepParameter.ContainsKey(attr))
  91. {
  92. return (string)step.StepParameter[attr];
  93. }
  94. }
  95. return string.Empty;
  96. }
  97. public string GetPreCleanRecipe(ModuleName pm)
  98. {
  99. if (!ModuleHelper.IsPm(pm))
  100. return string.Empty;
  101. string attr = $"{pm}PreLotClean";
  102. foreach (var step in Steps)
  103. {
  104. if (step.StepModules.Contains(pm) && step.StepParameter.ContainsKey(attr))
  105. {
  106. return (string)step.StepParameter[attr];
  107. }
  108. }
  109. return string.Empty;
  110. }
  111. public string GetWTWCleanRecipe(ModuleName pm)
  112. {
  113. if (!ModuleHelper.IsPm(pm))
  114. return string.Empty;
  115. string attr = $"{pm}WTWClean";
  116. foreach (var step in Steps)
  117. {
  118. if (step.StepModules.Contains(pm) && step.StepParameter.ContainsKey(attr))
  119. {
  120. return (string)step.StepParameter[attr];
  121. }
  122. }
  123. return string.Empty;
  124. }
  125. public int GetWTWCleanInterval(ModuleName pm)
  126. {
  127. if (!ModuleHelper.IsPm(pm))
  128. return -1;
  129. string attr = $"{pm}WTWInterval";
  130. foreach (var step in Steps)
  131. {
  132. if (step.StepModules.Contains(pm) && step.StepParameter.ContainsKey(attr))
  133. {
  134. return Convert.ToInt32(step.StepParameter[attr]);
  135. }
  136. }
  137. return -1;
  138. }
  139. public string GetPostCleanRecipe(ModuleName pm)
  140. {
  141. if (!ModuleHelper.IsPm(pm))
  142. return string.Empty;
  143. string attr = $"{pm}PostLotClean";
  144. foreach (var step in Steps)
  145. {
  146. if (step.StepModules.Contains(pm) && step.StepParameter.ContainsKey(attr))
  147. {
  148. return (string)step.StepParameter[attr];
  149. }
  150. }
  151. return string.Empty;
  152. }
  153. // public string GetRecipe(ModuleName pm, JobRecipeType jobRecipeType)
  154. // {
  155. // if (!ModuleHelper.IsPm(pm))
  156. // return string.Empty;
  157. // string attr = $"{pm}Recipe";
  158. // foreach (var step in Steps)
  159. // {
  160. // if (step.StepModules.Contains(pm))
  161. // {
  162. // string recipeInfoString = (string)step.StepParameter[attr];
  163. // var recipeInfoDictionary= SerializeHelper.Instance.StringToDictionary(recipeInfoString);
  164. // if (recipeInfoDictionary.Keys.Contains(jobRecipeType.ToString()))
  165. // {
  166. // return recipeInfoDictionary[jobRecipeType.ToString()];
  167. // }
  168. // }
  169. // }
  170. // return string.Empty;
  171. // }
  172. //}
  173. }
  174. public class SequenceInfoHelper
  175. {
  176. public static SequenceInfo GetInfo(string seqFile)
  177. {
  178. SequenceInfo info = new SequenceInfo(seqFile);
  179. info.PMs = new List<ModuleName>();
  180. string content = RecipeFileManager.Instance.GetSequenceAndTryAppendLL(seqFile, false);
  181. if (!string.IsNullOrEmpty(content))
  182. {
  183. try
  184. {
  185. XmlDocument dom = new XmlDocument();
  186. dom.LoadXml(content);
  187. XmlNodeList lstStepNode = dom.SelectNodes("Aitex/TableSequenceData/Step");
  188. if (lstStepNode == null)
  189. {
  190. //LOG.Error($"{seqFile} has no step");
  191. return null;
  192. }
  193. var nodeData = dom.SelectSingleNode("Aitex/TableSequenceData");
  194. if (nodeData != null)
  195. {
  196. var node = nodeData as XmlElement;
  197. info.ThicknessType = node.GetAttribute("ThicknessType");
  198. }
  199. foreach (var nodeModelChild in lstStepNode)
  200. {
  201. XmlElement nodeStep = nodeModelChild as XmlElement;
  202. SequenceStepInfo stepInfo = new SequenceStepInfo();
  203. foreach (XmlAttribute attr in nodeStep.Attributes)
  204. {
  205. stepInfo.StepParameter[attr.Name] = attr.Value;
  206. if (attr.Name == "Position" || attr.Name == "LLSelection" || attr.Name == "PMSelection")
  207. {
  208. if (attr.Value == "LL" || attr.Value == "PM")
  209. continue;
  210. string[] pos = attr.Value.Split(',');
  211. if (pos.Length < 1)
  212. {
  213. LOG.Write(eEvent.WARN_SEQUENCE, ModuleName.System, $"{seqFile} Position {attr.Value} can not be empty");
  214. return null;
  215. }
  216. foreach (var po in pos)
  217. {
  218. if (po.IsEmpty())
  219. continue;
  220. if (attr.Name == "PMSelection")
  221. {
  222. info.PMs.Add(ModuleHelper.Converter(po));
  223. }
  224. if (po == "Cooling")
  225. {
  226. stepInfo.StepModules.AddIfNotContains(ModuleName.Cooling1);
  227. stepInfo.StepModules.AddIfNotContains(ModuleName.Cooling2);
  228. continue;
  229. }
  230. if (po == "Aligner")
  231. {
  232. stepInfo.StepModules.AddIfNotContains(ModuleName.Aligner1);
  233. stepInfo.StepModules.AddIfNotContains(ModuleName.Aligner2);
  234. continue;
  235. }
  236. ModuleName module = ModuleHelper.Converter(po);
  237. if (module == ModuleName.System)
  238. {
  239. //LOG.Error($"{seqFile} Position {po} not valid");
  240. return null;
  241. }
  242. stepInfo.StepModules.Add(module);
  243. }
  244. continue;
  245. }
  246. if (attr.Name == "PMARecipe")
  247. {
  248. }
  249. if (attr.Name == "WTWClean")
  250. {
  251. info.WTWCleanRecipe = attr.Value;
  252. }
  253. //if (attr.Name == "PreClean")
  254. //{
  255. // info.PreWaferCleanRecipe = attr.Value;
  256. //}
  257. //if (attr.Name == "PostClean")
  258. //{
  259. // info.PostWaferCleanRecipe = attr.Value;
  260. //}
  261. }
  262. info.Steps.Add(stepInfo);
  263. }
  264. // Loadlock Single In Single Out property check
  265. var llSteps = info.Steps.FindAll(item => item.StepModules.Contains(ModuleName.LLA) || item.StepModules.Contains(ModuleName.LLB));
  266. if (llSteps.Count == 2)
  267. {
  268. if (llSteps[0].StepModules.Count == 1 && llSteps[1].StepModules.Count == 1)
  269. {
  270. if (llSteps[0].StepModules[0] != llSteps[1].StepModules[0])
  271. {
  272. info.LLInOutPath = llSteps[0].StepModules[0] == ModuleName.LLA ? SequenceLLInOutPath.AInBOut : SequenceLLInOutPath.BInAOut;
  273. }
  274. else
  275. {
  276. info.LLInOutPath = llSteps[0].StepModules[0] == ModuleName.LLA ? SequenceLLInOutPath.AInAOut : SequenceLLInOutPath.BInBOut;
  277. }
  278. }
  279. if (llSteps[1].StepParameter.ContainsKey("LLDelayTime"))
  280. {
  281. if (int.TryParse((string)llSteps[1].StepParameter["LLDelayTime"], out int delay))
  282. {
  283. info.LLDelayTime = delay;
  284. }
  285. }
  286. }
  287. }
  288. catch (Exception ex)
  289. {
  290. LOG.WriteExeption(ex);
  291. return null;
  292. }
  293. return info;
  294. }
  295. else
  296. {
  297. return null;
  298. }
  299. }
  300. public static SequenceInfo VenusGetInfo(string seqFile)
  301. {
  302. SequenceInfo info = new SequenceInfo(seqFile);
  303. info.PMs = new List<ModuleName>();
  304. string content = RecipeFileManager.Instance.GetSequenceAndTryAppendLL(seqFile, false);
  305. if (!string.IsNullOrEmpty(content))
  306. {
  307. try
  308. {
  309. XmlDocument dom = new XmlDocument();
  310. dom.LoadXml(content);
  311. XmlNodeList lstStepNode = dom.SelectNodes("Aitex/TableSequenceData/Step");
  312. if (lstStepNode == null)
  313. {
  314. //LOG.Error($"{seqFile} has no step");
  315. return null;
  316. }
  317. var nodeData = dom.SelectSingleNode("Aitex/TableSequenceData");
  318. if (nodeData != null)
  319. {
  320. var node = nodeData as XmlElement;
  321. info.ThicknessType = node.GetAttribute("ThicknessType");
  322. }
  323. foreach (var nodeModelChild in lstStepNode)
  324. {
  325. XmlElement nodeStep = nodeModelChild as XmlElement;
  326. SequenceStepInfo stepInfo = new SequenceStepInfo();
  327. foreach (XmlAttribute attr in nodeStep.Attributes)
  328. {
  329. if (attr.Name == "PMARecipe" || attr.Name == "PMBRecipe" || attr.Name == "PMCRecipe" || attr.Name == "PMDRecipe")
  330. {
  331. string module = attr.Name.Substring(0, 3);
  332. var dictionarys = SerializeHelper.Instance.StringToDictionary(attr.Value);
  333. foreach (var dictionary in dictionarys)
  334. {
  335. string key;
  336. if (dictionary.Key == "Process")
  337. {
  338. key = $"{module}Recipe";
  339. }
  340. else
  341. {
  342. key = $"{module}{dictionary.Key}";
  343. }
  344. stepInfo.StepParameter[key] = dictionary.Value;
  345. }
  346. }
  347. else
  348. {
  349. stepInfo.StepParameter[attr.Name] = attr.Value;
  350. }
  351. if (attr.Name == "Position" || attr.Name == "LLSelection" || attr.Name == "PMSelection")
  352. {
  353. if (attr.Value == "LL" || attr.Value == "PM")
  354. continue;
  355. string[] pos = attr.Value.Split(',');
  356. if (pos.Length < 1)
  357. {
  358. LOG.Write(eEvent.WARN_SEQUENCE, ModuleName.System, $"{seqFile} Position {attr.Value} can not be empty");
  359. return null;
  360. }
  361. foreach (var po in pos)
  362. {
  363. if (po.IsEmpty())
  364. continue;
  365. if (attr.Name == "PMSelection")
  366. {
  367. info.PMs.Add(ModuleHelper.Converter(po));
  368. }
  369. if (po == "Cooling")
  370. {
  371. stepInfo.StepModules.AddIfNotContains(ModuleName.Cooling1);
  372. stepInfo.StepModules.AddIfNotContains(ModuleName.Cooling2);
  373. continue;
  374. }
  375. if (po == "Aligner")
  376. {
  377. stepInfo.StepModules.AddIfNotContains(ModuleName.Aligner1);
  378. stepInfo.StepModules.AddIfNotContains(ModuleName.Aligner2);
  379. continue;
  380. }
  381. ModuleName module = ModuleHelper.Converter(po);
  382. if (module == ModuleName.System)
  383. {
  384. //LOG.Error($"{seqFile} Position {po} not valid");
  385. return null;
  386. }
  387. stepInfo.StepModules.Add(module);
  388. }
  389. continue;
  390. }
  391. //if (attr.Name == "PMARecipe")
  392. //{
  393. //
  394. //}
  395. //if (attr.Name == "WTWClean")
  396. //{
  397. // info.WTWCleanRecipe = attr.Value;
  398. //}
  399. //if (attr.Name == "PreClean")
  400. //{
  401. // info.PreWaferCleanRecipe = attr.Value;
  402. //}
  403. //if (attr.Name == "PostClean")
  404. //{
  405. // info.PostWaferCleanRecipe = attr.Value;
  406. //}
  407. }
  408. info.Steps.Add(stepInfo);
  409. }
  410. // Loadlock Single In Single Out property check
  411. var llSteps = info.Steps.FindAll(item => item.StepModules.Contains(ModuleName.LLA) || item.StepModules.Contains(ModuleName.LLB));
  412. if (llSteps.Count == 2)
  413. {
  414. if (llSteps[0].StepModules.Count == 1 && llSteps[1].StepModules.Count == 1)
  415. {
  416. if (llSteps[0].StepModules[0] != llSteps[1].StepModules[0])
  417. {
  418. info.LLInOutPath = llSteps[0].StepModules[0] == ModuleName.LLA ? SequenceLLInOutPath.AInBOut : SequenceLLInOutPath.BInAOut;
  419. }
  420. else
  421. {
  422. info.LLInOutPath = llSteps[0].StepModules[0] == ModuleName.LLA ? SequenceLLInOutPath.AInAOut : SequenceLLInOutPath.BInBOut;
  423. }
  424. }
  425. if (llSteps[1].StepParameter.ContainsKey("LLDelayTime"))
  426. {
  427. if (int.TryParse((string)llSteps[1].StepParameter["LLDelayTime"], out int delay))
  428. {
  429. info.LLDelayTime = delay;
  430. }
  431. }
  432. }
  433. }
  434. catch (Exception ex)
  435. {
  436. LOG.WriteExeption(ex);
  437. return null;
  438. }
  439. return info;
  440. }
  441. else
  442. {
  443. return null;
  444. }
  445. }
  446. public static SequenceInfo KeplerGetInfo(string seqFile)
  447. {
  448. SequenceInfo info = new SequenceInfo(seqFile);
  449. info.PMs = new List<ModuleName>();
  450. string content = RecipeFileManager.Instance.GetSequenceAndTryAppendLL(seqFile, false);
  451. if (!string.IsNullOrEmpty(content))
  452. {
  453. try
  454. {
  455. XmlDocument dom = new XmlDocument();
  456. dom.LoadXml(content);
  457. XmlNodeList lstStepNode = dom.SelectNodes("Aitex/TableSequenceData/Step");
  458. if (lstStepNode == null)
  459. {
  460. //LOG.Error($"{seqFile} has no step");
  461. return null;
  462. }
  463. var nodeData = dom.SelectSingleNode("Aitex/TableSequenceData");
  464. if (nodeData != null)
  465. {
  466. var node = nodeData as XmlElement;
  467. info.ThicknessType = node.GetAttribute("ThicknessType");
  468. }
  469. foreach (var nodeModelChild in lstStepNode)
  470. {
  471. XmlElement nodeStep = nodeModelChild as XmlElement;
  472. SequenceStepInfo stepInfo = new SequenceStepInfo();
  473. foreach (XmlAttribute attr in nodeStep.Attributes)
  474. {
  475. if (attr.Name == "PMARecipe" || attr.Name == "PMBRecipe" || attr.Name == "PMCRecipe" || attr.Name == "PMDRecipe")
  476. {
  477. string module = attr.Name.Substring(0, 3);
  478. var dictionarys = SerializeHelper.Instance.StringToDictionary(attr.Value);
  479. foreach (var dictionary in dictionarys)
  480. {
  481. string key;
  482. if (dictionary.Key == "Process")
  483. {
  484. key = $"{module}Recipe";
  485. }
  486. else
  487. {
  488. key = $"{module}{dictionary.Key}";
  489. }
  490. stepInfo.StepParameter[key] = dictionary.Value;
  491. }
  492. }
  493. else
  494. {
  495. stepInfo.StepParameter[attr.Name] = attr.Value;
  496. }
  497. if (attr.Name == "Position" || attr.Name == "LLSelection" || attr.Name == "PMSelection")
  498. {
  499. if (attr.Value == "LL" || attr.Value == "PM")
  500. continue;
  501. string[] pos = attr.Value.Split(',');
  502. if (pos.Length < 1)
  503. {
  504. LOG.Write(eEvent.WARN_SEQUENCE, ModuleName.System, $"{seqFile} Position {attr.Value} can not be empty");
  505. return null;
  506. }
  507. foreach (var po in pos)
  508. {
  509. if (po.IsEmpty())
  510. continue;
  511. if (attr.Name == "PMSelection")
  512. {
  513. info.PMs.Add(ModuleHelper.Converter(po));
  514. }
  515. if (po == "Cooling")
  516. {
  517. stepInfo.StepModules.AddIfNotContains(ModuleName.Cooling1);
  518. stepInfo.StepModules.AddIfNotContains(ModuleName.Cooling2);
  519. continue;
  520. }
  521. if (po == "Aligner")
  522. {
  523. stepInfo.StepModules.AddIfNotContains(ModuleName.Aligner1);
  524. stepInfo.StepModules.AddIfNotContains(ModuleName.Aligner2);
  525. continue;
  526. }
  527. ModuleName module = ModuleHelper.Converter(po);
  528. if (module == ModuleName.System)
  529. {
  530. //LOG.Error($"{seqFile} Position {po} not valid");
  531. return null;
  532. }
  533. stepInfo.StepModules.Add(module);
  534. }
  535. continue;
  536. }
  537. //if (attr.Name == "PMARecipe")
  538. //{
  539. //}
  540. //if (attr.Name == "WTWClean")
  541. //{
  542. // info.WTWCleanRecipe = attr.Value;
  543. //}
  544. //if (attr.Name == "PreClean")
  545. //{
  546. // info.PreWaferCleanRecipe = attr.Value;
  547. //}
  548. //if (attr.Name == "PostClean")
  549. //{
  550. // info.PostWaferCleanRecipe = attr.Value;
  551. //}
  552. }
  553. info.Steps.Add(stepInfo);
  554. }
  555. // Loadlock Single In Single Out property check
  556. var llSteps = info.Steps.FindAll(item => item.StepModules.Contains(ModuleName.LLA) || item.StepModules.Contains(ModuleName.LLB));
  557. if (llSteps.Count == 2)
  558. {
  559. if (llSteps[0].StepModules.Count == 1 && llSteps[1].StepModules.Count == 1)
  560. {
  561. if (llSteps[0].StepModules[0] != llSteps[1].StepModules[0])
  562. {
  563. info.LLInOutPath = llSteps[0].StepModules[0] == ModuleName.LLA ? SequenceLLInOutPath.AInBOut : SequenceLLInOutPath.BInAOut;
  564. }
  565. else
  566. {
  567. info.LLInOutPath = llSteps[0].StepModules[0] == ModuleName.LLA ? SequenceLLInOutPath.AInAOut : SequenceLLInOutPath.BInBOut;
  568. }
  569. }
  570. if (llSteps[1].StepParameter.ContainsKey("LLDelayTime"))
  571. {
  572. if (int.TryParse((string)llSteps[1].StepParameter["LLDelayTime"], out int delay))
  573. {
  574. info.LLDelayTime = delay;
  575. }
  576. }
  577. }
  578. }
  579. catch (Exception ex)
  580. {
  581. LOG.WriteExeption(ex);
  582. return null;
  583. }
  584. return info;
  585. }
  586. else
  587. {
  588. return null;
  589. }
  590. }
  591. }
  592. }