RecipeParserTransfer1To1.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. using System.Collections.Generic;
  2. using Aitex.Core.Common;
  3. using Aitex.Core.RT.DataCenter;
  4. using Aitex.Core.RT.Device;
  5. using Aitex.Core.RT.Log;
  6. using Aitex.Core.RT.SCCore;
  7. using Aitex.Sorter.Common;
  8. using MECF.Framework.Common.Equipment;
  9. using MECF.Framework.Common.SubstrateTrackings;
  10. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
  11. namespace Aitex.Sorter.RT.Module.Recipe
  12. {
  13. /// <summary>
  14. /// 从一个FOUP到另外一个FOUP,可选Align,Read Wafer ID
  15. /// </summary>
  16. class RecipeParserTransfer1To1 : IRecipeParser
  17. {
  18. public SorterRecipeXml XmlRecipe { get; set; }
  19. public bool Init(SorterRecipeXml xmlRecipe, out string reason)
  20. {
  21. reason = string.Empty;
  22. if (xmlRecipe.RecipeType != SorterRecipeType.Transfer1To1)
  23. {
  24. LOG.Write("xml recipe type not valid, " + xmlRecipe.RecipeType);
  25. reason = "Recipe xml file not valid";
  26. return false;
  27. }
  28. XmlRecipe = xmlRecipe;
  29. return true;
  30. }
  31. public List<TransferInfo> Parse(out string reason)
  32. {
  33. List<TransferInfo> result = new List<TransferInfo>();
  34. reason = string.Empty;
  35. List<WaferInfo[]> wafersInSourceList = new List<WaferInfo[]>();
  36. List<WaferInfo[]> wafersInDestinationList = new List<WaferInfo[]>();
  37. List<ModuleName> destinationModules = new List<ModuleName>();
  38. bool isLoad = false;
  39. for (int i = 0; i < XmlRecipe.Source.Count; i++)
  40. {
  41. LoadPort lp = DEVICE.GetDevice<LoadPort>(XmlRecipe.Source[i].ToString());
  42. if (lp.IsEnableTransferWafer(out reason))
  43. {
  44. isLoad = true;
  45. WaferInfo[] wafersInSource = WaferManager.Instance.GetWafers(XmlRecipe.Source[i]);
  46. wafersInSourceList.Add(wafersInSource);
  47. }
  48. }
  49. if (!isLoad)
  50. {
  51. reason = "Source is not valid for transfer..";
  52. return result;
  53. }
  54. isLoad = false;
  55. for (int i = 0; i < XmlRecipe.Destination.Count; i++)
  56. {
  57. LoadPort lp = DEVICE.GetDevice<LoadPort>(XmlRecipe.Destination[i].ToString());
  58. if (lp.IsEnableTransferWafer(out reason))
  59. {
  60. isLoad = true;
  61. if (!lp.IsEnableTransferWafer())
  62. continue;
  63. destinationModules.Add(XmlRecipe.Destination[i]);
  64. WaferInfo[] wafersInDestination = WaferManager.Instance.GetWafers(XmlRecipe.Destination[i]);
  65. wafersInDestinationList.Add(wafersInDestination);
  66. }
  67. }
  68. if (!isLoad)
  69. {
  70. reason = "Destination is not valid for transfer..";
  71. return result;
  72. }
  73. if (wafersInSourceList.Count == 0 || wafersInDestinationList.Count == 0)
  74. {
  75. reason = "Recipe has no vaild transfer task.";
  76. return result;
  77. }
  78. switch (XmlRecipe.PlaceModeTransfer1To1)
  79. {
  80. case SorterRecipePlaceModeTransfer1To1.FromBottom:
  81. FromBottom(wafersInSourceList, wafersInDestinationList, destinationModules, ref result, out reason);
  82. break;
  83. case SorterRecipePlaceModeTransfer1To1.FromTop:
  84. FromTop(wafersInSourceList, wafersInDestinationList, destinationModules, ref result, out reason);
  85. break;
  86. case SorterRecipePlaceModeTransfer1To1.SameSlot:
  87. SameSlot(wafersInSourceList, wafersInDestinationList, destinationModules, ref result, out reason);
  88. break;
  89. default:
  90. reason = string.Format("recipe PlaceModeTransfer1To1 {0} not valid", XmlRecipe.PlaceModeTransfer1To1);
  91. return result;
  92. }
  93. //if (result.Count == 0)
  94. // reason = "Recipe has no vaild transfer task.";
  95. return result;
  96. }
  97. /// <summary>
  98. /// 从source最下面开始取wafer,顺序放在destination的最下面
  99. /// </summary>
  100. /// <param name="lst"></param>
  101. /// <param name="reason"></param>
  102. /// <returns></returns>
  103. bool FromBottom(List<WaferInfo[]> sourceList, List<WaferInfo[]> destinationList, List<ModuleName> destinationModules, ref List<TransferInfo> lst, out string reason)
  104. {
  105. reason = string.Empty;
  106. SCConfigItem _scLP2Pitch = SC.GetConfigItem("LoadPort.LoadPort2Pitch");
  107. if (_scLP2Pitch == null || _scLP2Pitch.IntValue == 10)
  108. {
  109. int destinationIndex = -1;
  110. for (int i = 0; i < sourceList.Count * sourceList[0].Length; i++)
  111. {
  112. WaferInfo[] source = sourceList[i / sourceList[0].Length];
  113. if (source[i % sourceList[0].Length].IsEmpty)
  114. continue;
  115. int to = destinationIndex;
  116. for (int j = destinationIndex + 1; j < destinationList.Count * destinationList[0].Length; j++)
  117. {
  118. WaferInfo[] destination = destinationList[j / destinationList[0].Length];
  119. if (destination[j % destinationList[0].Length].IsEmpty)
  120. {
  121. to = j;
  122. break;
  123. }
  124. }
  125. if (to == destinationIndex)
  126. break;
  127. destinationIndex = to;
  128. lst.Add(new TransferInfo()
  129. {
  130. Angle = XmlRecipe.AlignAngle,
  131. Option = (XmlRecipe.IsAlign ? MoveOption.Align : MoveOption.None)
  132. | (XmlRecipe.IsReadLaserMarker ? MoveOption.ReadID : MoveOption.None)
  133. | (XmlRecipe.IsReadT7Code ? MoveOption.ReadID2 : MoveOption.None)
  134. | (XmlRecipe.WaferReaderIndex == 1 ? MoveOption.Reader1 : MoveOption.None)
  135. | (XmlRecipe.WaferReaderIndex == 2 ? MoveOption.Reader2 : MoveOption.None)
  136. | (XmlRecipe.IsTurnOver ? MoveOption.Turnover : MoveOption.None),
  137. Slot = to % destinationList[0].Length,
  138. Station = destinationModules[to / destinationList[0].Length],
  139. WaferID = source[i % sourceList[0].Length].WaferID,
  140. });
  141. }
  142. }
  143. else
  144. {
  145. if (sourceList.Count > 1 || destinationList.Count > 1)
  146. {
  147. reason = "Multiple Sources and Destinations are not supported in SameSlot mode";
  148. return false;
  149. }
  150. int destinationIndex = -1;
  151. SCConfigItem _scEnable = SC.GetConfigItem("LoadPort.EnableSlot1OnLP2");
  152. bool isContinue = false;
  153. for (int i = 0; i < sourceList[0].Length; i++)
  154. {
  155. WaferInfo[] source = sourceList[0];
  156. if (isContinue && source[i].IsEmpty)
  157. isContinue = false;
  158. if (source[i].IsEmpty)
  159. {
  160. continue;
  161. }
  162. if (!_scEnable.BoolValue && i == 0)
  163. {
  164. isContinue = true;
  165. continue;
  166. }
  167. if (isContinue)
  168. continue;
  169. int to = destinationIndex;
  170. for (int j = destinationIndex + 1; j < destinationList.Count * destinationList[0].Length; j++)
  171. {
  172. WaferInfo[] destination = destinationList[j / destinationList[0].Length];
  173. if (destination[j % destinationList[0].Length].IsEmpty)
  174. {
  175. to = j;
  176. break;
  177. }
  178. }
  179. if (to == destinationIndex)
  180. break;
  181. destinationIndex = to;
  182. lst.Add(new TransferInfo()
  183. {
  184. Angle = XmlRecipe.AlignAngle,
  185. Option = (XmlRecipe.IsAlign ? MoveOption.Align : MoveOption.None)
  186. | (XmlRecipe.IsReadLaserMarker ? MoveOption.ReadID : MoveOption.None)
  187. | (XmlRecipe.IsReadT7Code ? MoveOption.ReadID2 : MoveOption.None)
  188. | (XmlRecipe.WaferReaderIndex == 1 ? MoveOption.Reader1 : MoveOption.None)
  189. | (XmlRecipe.WaferReaderIndex == 2 ? MoveOption.Reader2 : MoveOption.None)
  190. | (XmlRecipe.IsTurnOver ? MoveOption.Turnover : MoveOption.None),
  191. Slot = to % destinationList[0].Length,
  192. Station = destinationModules[to / destinationList[0].Length],
  193. WaferID = source[i % sourceList[0].Length].WaferID,
  194. });
  195. }
  196. }
  197. return true;
  198. }
  199. /// <summary>
  200. /// 放在同一位置,如果有冲突,直接忽略
  201. /// </summary>
  202. /// <param name="lst"></param>
  203. /// <param name="reason"></param>
  204. /// <returns></returns>
  205. bool SameSlot(List<WaferInfo[]> sourceList, List<WaferInfo[]> destinationList, List<ModuleName> destinationModules, ref List<TransferInfo> lst, out string reason)
  206. {
  207. reason = string.Empty;
  208. if (sourceList.Count > 1 || destinationList.Count > 1)
  209. {
  210. reason = "Multiple Sources and Destinations are not supported in SameSlot mode";
  211. return false;
  212. }
  213. WaferInfo[] source = sourceList[0];
  214. WaferInfo[] destination = destinationList[0];
  215. //int destinationIndex = -1;
  216. SCConfigItem _scLP2Pitch = SC.GetConfigItem("LoadPort.LoadPort2Pitch");
  217. if (_scLP2Pitch == null || _scLP2Pitch.IntValue == 10)
  218. {
  219. for (int i = 0; i < source.Length && i < destination.Length; i++)
  220. {
  221. if (source[i].IsEmpty || !destination[i].IsEmpty)
  222. continue;
  223. lst.Add(new TransferInfo()
  224. {
  225. Angle = XmlRecipe.AlignAngle,
  226. Option = (XmlRecipe.IsAlign ? MoveOption.Align : MoveOption.None)
  227. | (XmlRecipe.IsReadLaserMarker ? MoveOption.ReadID : MoveOption.None)
  228. | (XmlRecipe.IsReadT7Code ? MoveOption.ReadID2 : MoveOption.None)
  229. | (XmlRecipe.WaferReaderIndex == 1 ? MoveOption.Reader1 : MoveOption.None)
  230. | (XmlRecipe.WaferReaderIndex == 2 ? MoveOption.Reader2 : MoveOption.None)
  231. | (XmlRecipe.IsTurnOver ? MoveOption.Turnover : MoveOption.None),
  232. Slot = i,
  233. Station = destinationModules[0],
  234. WaferID = source[i].WaferID,
  235. });
  236. }
  237. }
  238. else if (_scLP2Pitch.IntValue == 7 && XmlRecipe.Destination[0] == ModuleName.LP2)
  239. {
  240. SCConfigItem _scEnable = SC.GetConfigItem("LoadPort.EnableSlot1OnLP2");
  241. for (int i = source.Length - 1; i >= 0; i--)
  242. {
  243. if (source[i].IsEmpty || !destination[i].IsEmpty || (!_scEnable.BoolValue && i == 0) || (i > 0 && !destination[i - 1].IsEmpty))
  244. continue;
  245. lst.Add(new TransferInfo()
  246. {
  247. Angle = XmlRecipe.AlignAngle,
  248. Option = (XmlRecipe.IsAlign ? MoveOption.Align : MoveOption.None)
  249. | (XmlRecipe.IsReadLaserMarker ? MoveOption.ReadID : MoveOption.None)
  250. | (XmlRecipe.IsReadT7Code ? MoveOption.ReadID2 : MoveOption.None)
  251. | (XmlRecipe.WaferReaderIndex == 1 ? MoveOption.Reader1 : MoveOption.None)
  252. | (XmlRecipe.WaferReaderIndex == 2 ? MoveOption.Reader2 : MoveOption.None)
  253. | (XmlRecipe.IsTurnOver ? MoveOption.Turnover : MoveOption.None),
  254. Slot = i,
  255. Station = destinationModules[0],
  256. WaferID = source[i].WaferID,
  257. });
  258. }
  259. }
  260. else if ((_scLP2Pitch.IntValue == 7 && XmlRecipe.Source[0] == ModuleName.LP2))
  261. {
  262. SCConfigItem _scEnable = SC.GetConfigItem("LoadPort.EnableSlot1OnLP2");
  263. bool isContinue = false;
  264. for (int i = 0; i < source.Length && i < destination.Length; i++)
  265. {
  266. if (isContinue && source[i].IsEmpty)
  267. isContinue = false;
  268. if (source[i].IsEmpty || !destination[i].IsEmpty)
  269. continue;
  270. if (!_scEnable.BoolValue && i == 0 || (i > 0 && !destination[i - 1].IsEmpty))
  271. {
  272. isContinue = true;
  273. continue;
  274. }
  275. if (isContinue)
  276. continue;
  277. lst.Add(new TransferInfo()
  278. {
  279. Angle = XmlRecipe.AlignAngle,
  280. Option = (XmlRecipe.IsAlign ? MoveOption.Align : MoveOption.None)
  281. | (XmlRecipe.IsReadLaserMarker ? MoveOption.ReadID : MoveOption.None)
  282. | (XmlRecipe.IsReadT7Code ? MoveOption.ReadID2 : MoveOption.None)
  283. | (XmlRecipe.WaferReaderIndex == 1 ? MoveOption.Reader1 : MoveOption.None)
  284. | (XmlRecipe.WaferReaderIndex == 2 ? MoveOption.Reader2 : MoveOption.None)
  285. | (XmlRecipe.IsTurnOver ? MoveOption.Turnover : MoveOption.None),
  286. Slot = i,
  287. Station = destinationModules[0],
  288. WaferID = source[i].WaferID,
  289. });
  290. }
  291. }
  292. return true;
  293. }
  294. /// <summary>
  295. /// 从source最上面开始取wafer,顺序放在destination的最上面
  296. /// </summary>
  297. /// <param name="lst"></param>
  298. /// <param name="reason"></param>
  299. /// <returns></returns>
  300. bool FromTop(List<WaferInfo[]> sourceList, List<WaferInfo[]> destinationList, List<ModuleName> destinationModules, ref List<TransferInfo> lst, out string reason)
  301. {
  302. reason = string.Empty;
  303. SCConfigItem _scLP2Pitch = SC.GetConfigItem("LoadPort.LoadPort2Pitch");
  304. if (_scLP2Pitch == null || _scLP2Pitch.IntValue == 10)
  305. {
  306. int destinationIndex = destinationList.Count * destinationList[0].Length;
  307. for (int i = sourceList.Count * sourceList[0].Length - 1; i >= 0; i--)
  308. {
  309. WaferInfo[] source = sourceList[sourceList.Count - i / sourceList[0].Length - 1];
  310. if (source[i % sourceList[0].Length].IsEmpty)
  311. continue;
  312. int to = destinationIndex;
  313. for (int j = destinationIndex - 1; j >= 0; j--)
  314. {
  315. WaferInfo[] destination = destinationList[destinationList.Count - j / destinationList[0].Length - 1];
  316. if (destination[j % destinationList[0].Length].IsEmpty)
  317. {
  318. to = j;
  319. break;
  320. }
  321. }
  322. if (to == destinationIndex)
  323. break;
  324. destinationIndex = to;
  325. lst.Add(new TransferInfo()
  326. {
  327. Angle = XmlRecipe.AlignAngle,
  328. Option = (XmlRecipe.IsAlign ? MoveOption.Align : MoveOption.None)
  329. | (XmlRecipe.IsReadLaserMarker ? MoveOption.ReadID : MoveOption.None)
  330. | (XmlRecipe.IsReadT7Code ? MoveOption.ReadID2 : MoveOption.None)
  331. | (XmlRecipe.WaferReaderIndex == 1 ? MoveOption.Reader1 : MoveOption.None)
  332. | (XmlRecipe.WaferReaderIndex == 2 ? MoveOption.Reader2 : MoveOption.None)
  333. | (XmlRecipe.IsTurnOver ? MoveOption.Turnover : MoveOption.None),
  334. Slot = to % destinationList[0].Length,
  335. Station = destinationModules[destinationList.Count - to / destinationList[0].Length - 1],
  336. WaferID = source[i % sourceList[0].Length].WaferID,
  337. });
  338. }
  339. }
  340. else
  341. {
  342. if (sourceList.Count > 1 || destinationList.Count > 1)
  343. {
  344. reason = "Multiple Sources and Destinations are not supported in SameSlot mode";
  345. return false;
  346. }
  347. SCConfigItem _scEnable = SC.GetConfigItem("LoadPort.EnableSlot1OnLP2");
  348. if (XmlRecipe.Source[0] == ModuleName.LP2) //Source为LP2
  349. {
  350. bool isContinue = false;
  351. int destinationIndex = destinationList[0].Length;
  352. for (int i = 0; i < sourceList[0].Length; i++)
  353. {
  354. WaferInfo[] source = sourceList[0];
  355. if (isContinue && source[i].IsEmpty)
  356. isContinue = false;
  357. if (source[i].IsEmpty)
  358. continue;
  359. if (!_scEnable.BoolValue && i == 0)
  360. {
  361. isContinue = true;
  362. continue;
  363. }
  364. if (isContinue)
  365. continue;
  366. int to = destinationIndex;
  367. for (int j = destinationIndex - 1; j >= 0; j--)
  368. {
  369. WaferInfo[] destination = destinationList[0];
  370. if (destination[j].IsEmpty)
  371. {
  372. to = j;
  373. break;
  374. }
  375. }
  376. if (to == destinationIndex)
  377. break;
  378. destinationIndex = to;
  379. lst.Add(new TransferInfo()
  380. {
  381. Angle = XmlRecipe.AlignAngle,
  382. Option = (XmlRecipe.IsAlign ? MoveOption.Align : MoveOption.None)
  383. | (XmlRecipe.IsReadLaserMarker ? MoveOption.ReadID : MoveOption.None)
  384. | (XmlRecipe.IsReadT7Code ? MoveOption.ReadID2 : MoveOption.None)
  385. | (XmlRecipe.WaferReaderIndex == 1 ? MoveOption.Reader1 : MoveOption.None)
  386. | (XmlRecipe.WaferReaderIndex == 2 ? MoveOption.Reader2 : MoveOption.None)
  387. | (XmlRecipe.IsTurnOver ? MoveOption.Turnover : MoveOption.None),
  388. Slot = to,
  389. Station = destinationModules[0],
  390. WaferID = source[i].WaferID,
  391. });
  392. }
  393. }
  394. else //Station为LP2
  395. {
  396. int destinationIndex = destinationList[0].Length;
  397. for (int i = sourceList[0].Length - 1; i >= 0; i--)
  398. {
  399. WaferInfo[] source = sourceList[0];
  400. if (source[i].IsEmpty)
  401. continue;
  402. int to = destinationIndex;
  403. for (int j = destinationIndex - 1; j >= 0; j--)
  404. {
  405. WaferInfo[] destination = destinationList[0];
  406. if (j == 0)
  407. {
  408. if (_scEnable.BoolValue)
  409. {
  410. if (destination[j].IsEmpty)
  411. {
  412. to = j;
  413. break;
  414. }
  415. }
  416. }
  417. else
  418. {
  419. if (destination[j - 1].IsEmpty && destination[j].IsEmpty)
  420. {
  421. to = j;
  422. break;
  423. }
  424. }
  425. }
  426. if (to == destinationIndex)
  427. break;
  428. destinationIndex = to;
  429. lst.Add(new TransferInfo()
  430. {
  431. Angle = XmlRecipe.AlignAngle,
  432. Option = (XmlRecipe.IsAlign ? MoveOption.Align : MoveOption.None)
  433. | (XmlRecipe.IsReadLaserMarker ? MoveOption.ReadID : MoveOption.None)
  434. | (XmlRecipe.IsReadT7Code ? MoveOption.ReadID2 : MoveOption.None)
  435. | (XmlRecipe.WaferReaderIndex == 1 ? MoveOption.Reader1 : MoveOption.None)
  436. | (XmlRecipe.WaferReaderIndex == 2 ? MoveOption.Reader2 : MoveOption.None)
  437. | (XmlRecipe.IsTurnOver ? MoveOption.Turnover : MoveOption.None),
  438. Slot = to,
  439. Station = destinationModules[0],
  440. WaferID = source[i].WaferID,
  441. });
  442. }
  443. }
  444. }
  445. return true;
  446. }
  447. }
  448. }