RecipeParserPack.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using Aitex.Core.Common;
  7. using Aitex.Core.RT.DataCenter;
  8. using Aitex.Core.RT.Device;
  9. using Aitex.Core.RT.Log;
  10. using Aitex.Core.RT.SCCore;
  11. using Aitex.Sorter.Common;
  12. using MECF.Framework.Common.Equipment;
  13. using MECF.Framework.Common.SubstrateTrackings;
  14. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
  15. namespace Aitex.Sorter.RT.Module.Recipe
  16. {
  17. /// <summary>
  18. ///
  19. /// 把同一个Foup内分散的wafer集中起来;可选align或者read wafer id
  20. ///
  21. /// </summary>
  22. class RecipeParserPack : IRecipeParser
  23. {
  24. public SorterRecipeXml XmlRecipe { get; set; }
  25. public bool Init(SorterRecipeXml xmlRecipe, out string reason)
  26. {
  27. reason = string.Empty;
  28. if (xmlRecipe.RecipeType != SorterRecipeType.Pack)
  29. {
  30. LOG.Write("xml recipe type not valid, " + xmlRecipe.RecipeType);
  31. reason = "Recipe xml file not valid";
  32. return false;
  33. }
  34. XmlRecipe = xmlRecipe;
  35. return true;
  36. }
  37. public List<TransferInfo> Parse(out string reason)
  38. {
  39. List<TransferInfo> result = new List<TransferInfo>();
  40. reason = string.Empty;
  41. //string paramName = string.Empty;
  42. //switch (XmlRecipe.Source[0])
  43. //{
  44. // case ModuleName.LP1:
  45. // paramName = ParamName.WaferInfoFoupA;
  46. // break;
  47. // case ModuleName.LP2:
  48. // paramName = ParamName.WaferInfoFoupB;
  49. // break;
  50. // case ModuleName.LP3:
  51. // paramName = ParamName.WaferInfoFoupC;
  52. // break;
  53. // case ModuleName.LP4:
  54. // paramName = ParamName.WaferInfoFoupD;
  55. // break;
  56. // default:
  57. // reason = string.Format("recipe source {0} not valid", XmlRecipe.Source);
  58. // return result;
  59. //}
  60. //WaferInfo[] foupInfos = (WaferInfo[])DATA.Poll(ChamberSetString.System, paramName);
  61. //Array.Reverse(foupInfos);
  62. List<WaferInfo[]> wafersInSourceList = new List<WaferInfo[]>();
  63. List<ModuleName> SourceModules = new List<ModuleName>();
  64. bool isLoad = false;
  65. for (int i = 0; i < XmlRecipe.Source.Count; i++)
  66. {
  67. LoadPort lp = DEVICE.GetDevice<LoadPort>(XmlRecipe.Source[i].ToString());
  68. if (lp.IsEnableTransferWafer(out reason))
  69. {
  70. isLoad = true;
  71. WaferInfo[] wafersInSource = WaferManager.Instance.GetWafers(XmlRecipe.Source[i]);
  72. wafersInSourceList.Add(wafersInSource);
  73. SourceModules.Add(XmlRecipe.Source[i]);
  74. }
  75. }
  76. if (!isLoad)
  77. {
  78. reason = "Source is not valid for transfer.";
  79. return result;
  80. }
  81. if (wafersInSourceList.Count == 0)
  82. {
  83. reason = "Please choose Sources";
  84. return result;
  85. }
  86. switch (XmlRecipe.PlaceModePack)
  87. {
  88. case SorterRecipePlaceModePack.FromBottomInsert:
  89. FromBottomInsert(wafersInSourceList, SourceModules, ref result, out reason);
  90. break;
  91. case SorterRecipePlaceModePack.FromBottomShift:
  92. FromBottomShift(wafersInSourceList, SourceModules, ref result, out reason);
  93. break;
  94. case SorterRecipePlaceModePack.FromTopInsert:
  95. FromTopInsert(wafersInSourceList, SourceModules, ref result, out reason);
  96. break;
  97. case SorterRecipePlaceModePack.FromTopShift:
  98. FromTopShift(wafersInSourceList, SourceModules, ref result, out reason);
  99. break;
  100. default:
  101. reason = string.Format("recipe PlaceModePack {0} not valid", XmlRecipe.PlaceModePack);
  102. return result;
  103. }
  104. //if (result.Count == 0)
  105. // reason = "Recipe has no vaild transfer task.";
  106. return result;
  107. }
  108. /// <summary>
  109. /// 从最上面开始取wafer,从最下面开始找空
  110. /// </summary>
  111. /// <param name="lst"></param>
  112. /// <param name="reason"></param>
  113. /// <returns></returns>
  114. bool FromBottomInsert(List<WaferInfo[]> sourceList, List<ModuleName> sourceModules, ref List<TransferInfo> lst, out string reason)
  115. {
  116. reason = string.Empty;
  117. for (int s = 0; s < sourceList.Count; s++)
  118. {
  119. WaferInfo[] foupInfos = WaferManager.Instance.GetWafers(XmlRecipe.Source[s]);
  120. int to = -1;
  121. for (int i = foupInfos.Length - 1; i >= 0; i--)
  122. {
  123. if (foupInfos[i].IsEmpty)
  124. continue;
  125. bool findEmpty = false;
  126. for (int j = to + 1; j < i; j++)
  127. {
  128. if (foupInfos[j].IsEmpty)
  129. {
  130. to = j;
  131. findEmpty = true;
  132. break;
  133. }
  134. }
  135. if (!findEmpty)
  136. break;
  137. lst.Add(new TransferInfo()
  138. {
  139. Source = sourceModules[s],
  140. Angle = XmlRecipe.AlignAngle,
  141. Option = (XmlRecipe.IsAlign ? MoveOption.Align : MoveOption.None)
  142. | (XmlRecipe.IsReadLaserMarker ? MoveOption.ReadID : MoveOption.None)
  143. | (XmlRecipe.IsReadT7Code ? MoveOption.ReadID2 : MoveOption.None) | (XmlRecipe.WaferReaderIndex == 1 ? MoveOption.Reader1 : MoveOption.None)
  144. | (XmlRecipe.WaferReaderIndex == 2 ? MoveOption.Reader2 : MoveOption.None)
  145. | (XmlRecipe.IsTurnOver ? MoveOption.Turnover : MoveOption.None),
  146. Slot = to,
  147. Station = sourceModules[s],
  148. WaferID = foupInfos[i].WaferID,
  149. });
  150. }
  151. }
  152. return true;
  153. }
  154. /// <summary>
  155. /// 从最下面开始找空,顺序朝上找wafer
  156. /// </summary>
  157. /// <param name="lst"></param>
  158. /// <param name="reason"></param>
  159. /// <returns></returns>
  160. bool FromBottomShift(List<WaferInfo[]> sourceList, List<ModuleName> sourceModules, ref List<TransferInfo> lst, out string reason)
  161. {
  162. reason = string.Empty;
  163. for (int s = 0; s < sourceList.Count; s++)
  164. {
  165. WaferInfo[] foupInfos = WaferManager.Instance.GetWafers(XmlRecipe.Source[s]);
  166. int to = -1;
  167. for (int i = 0; i < foupInfos.Length; i++)
  168. {
  169. if (foupInfos[i].IsEmpty)
  170. continue;
  171. to++;
  172. if (i == to)
  173. continue;
  174. lst.Add(new TransferInfo()
  175. {
  176. Angle = XmlRecipe.AlignAngle,
  177. Option = (XmlRecipe.IsAlign ? MoveOption.Align : MoveOption.None)
  178. | (XmlRecipe.IsReadLaserMarker ? MoveOption.ReadID : MoveOption.None)
  179. | (XmlRecipe.IsReadT7Code ? MoveOption.ReadID2 : MoveOption.None) | (XmlRecipe.WaferReaderIndex == 1 ? MoveOption.Reader1 : MoveOption.None)
  180. | (XmlRecipe.WaferReaderIndex == 2 ? MoveOption.Reader2 : MoveOption.None)
  181. | (XmlRecipe.IsTurnOver ? MoveOption.Turnover : MoveOption.None),
  182. Slot = to,
  183. Source = sourceModules[s],
  184. Station = sourceModules[s],
  185. WaferID = foupInfos[i].WaferID,
  186. });
  187. }
  188. }
  189. return true;
  190. }
  191. /// <summary>
  192. /// 从最下面开始找wafer,从最上面找空
  193. /// </summary>
  194. /// <param name="lst"></param>
  195. /// <param name="reason"></param>
  196. /// <returns></returns>
  197. bool FromTopInsert(List<WaferInfo[]> sourceList, List<ModuleName> sourceModules, ref List<TransferInfo> lst, out string reason)
  198. {
  199. reason = string.Empty;
  200. for (int s = 0; s < sourceList.Count; s++)
  201. {
  202. WaferInfo[] foupInfos = sourceList[s];
  203. int to = foupInfos.Length;
  204. for (int i = 0; i < foupInfos.Length; i++)
  205. {
  206. if (foupInfos[i].IsEmpty)
  207. continue;
  208. bool findEmpty = false;
  209. for (int j = to - 1; j > i; j--)
  210. {
  211. if (foupInfos[j].IsEmpty)
  212. {
  213. to = j;
  214. findEmpty = true;
  215. break;
  216. }
  217. }
  218. if (!findEmpty)
  219. break;
  220. lst.Add(new TransferInfo()
  221. {
  222. Angle = XmlRecipe.AlignAngle,
  223. Option = (XmlRecipe.IsAlign ? MoveOption.Align : MoveOption.None)
  224. | (XmlRecipe.IsReadLaserMarker ? MoveOption.ReadID : MoveOption.None)
  225. | (XmlRecipe.IsReadT7Code ? MoveOption.ReadID2 : MoveOption.None) | (XmlRecipe.WaferReaderIndex == 1 ? MoveOption.Reader1 : MoveOption.None)
  226. | (XmlRecipe.WaferReaderIndex == 2 ? MoveOption.Reader2 : MoveOption.None)
  227. | (XmlRecipe.IsTurnOver ? MoveOption.Turnover : MoveOption.None),
  228. Slot = to,
  229. Source = sourceModules[s],
  230. Station = sourceModules[s],
  231. WaferID = foupInfos[i].WaferID,
  232. });
  233. }
  234. }
  235. return true;
  236. }
  237. /// <summary>
  238. /// 集中,平移到最上面
  239. /// </summary>
  240. /// <param name="lst"></param>
  241. /// <param name="reason"></param>
  242. /// <returns></returns>
  243. bool FromTopShift(List<WaferInfo[]> sourceList, List<ModuleName> sourceModules, ref List<TransferInfo> lst, out string reason)
  244. {
  245. reason = string.Empty;
  246. for (int s = 0; s < sourceList.Count; s++)
  247. {
  248. WaferInfo[] foupInfos = WaferManager.Instance.GetWafers(XmlRecipe.Source[s]);
  249. int to = foupInfos.Length;
  250. for (int i = foupInfos.Length - 1; i >= 0; i--)
  251. {
  252. if (foupInfos[i].IsEmpty)
  253. continue;
  254. to--;
  255. if (to == i)
  256. continue;
  257. lst.Add(new TransferInfo()
  258. {
  259. Angle = XmlRecipe.AlignAngle,
  260. Option = (XmlRecipe.IsAlign ? MoveOption.Align : MoveOption.None)
  261. | (XmlRecipe.IsReadLaserMarker ? MoveOption.ReadID : MoveOption.None)
  262. | (XmlRecipe.IsReadT7Code ? MoveOption.ReadID2 : MoveOption.None) | (XmlRecipe.WaferReaderIndex == 1 ? MoveOption.Reader1 : MoveOption.None)
  263. | (XmlRecipe.WaferReaderIndex == 2 ? MoveOption.Reader2 : MoveOption.None)
  264. | (XmlRecipe.IsTurnOver ? MoveOption.Turnover : MoveOption.None),
  265. Slot = to,
  266. Source = sourceModules[s],
  267. Station = sourceModules[s],
  268. WaferID = foupInfos[i].WaferID,
  269. });
  270. }
  271. }
  272. return true;
  273. }
  274. }
  275. }