PlaceExtendRoutine.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. using Aitex.Core.Common;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Core.RT.Device.Unit;
  4. using Aitex.Core.RT.Event;
  5. using Aitex.Core.RT.Routine;
  6. using Aitex.Core.RT.SCCore;
  7. using Aitex.Sorter.Common;
  8. using EFEM.RT.Tasks;
  9. using MECF.Framework.Common.Equipment;
  10. using MECF.Framework.Common.SubstrateTrackings;
  11. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
  12. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots;
  13. using System;
  14. namespace EFEM.RT.Routines
  15. {
  16. public class PlaceExtendRoutine : CommonRoutine, IRoutine, IEfemPlaceRoutine
  17. {
  18. private enum PlaceEx
  19. {
  20. CheckBeforePlace,
  21. PlaceReady,
  22. WaitPlaceReady,
  23. PlaceWafer,
  24. WaitPlace,
  25. PlaceRetract,
  26. WaitPlaceRetract,
  27. CheckAfterPlace,
  28. RobotBladeUnGrip,
  29. CheckWaferPrecenseBeforePlace,
  30. CheckWaferPrecenseAfterPlace,
  31. QuerySignalStatusBeforePlace,
  32. QuerySignalStatusAfterPlace,
  33. CheckTriggerSignalOn,
  34. }
  35. protected bool MultiWaferSize = DeviceDefineManager.Instance.GetValue<bool>("MultiWaferSize") ?? false;
  36. private SCConfigItem _scPlaceTimeout = null;
  37. private int _timeout = 0;
  38. private int _axisTimeout = 0;
  39. private int _axisSpeed = 0;
  40. public PlaceExtendRoutine(string module, string name)
  41. {
  42. }
  43. public bool Initalize()
  44. {
  45. _scPlaceTimeout = SC.GetConfigItem(SorterCommon.ScPathName.Robot_TimeLimitForPlaceWafer);
  46. if (HaveMotionAxis)
  47. {
  48. _axisTimeout = SC.GetValue<int>("MotionAxis.MoveTimeout");
  49. _axisSpeed = SC.GetValue<int>("MotionAxis.AutoSpeed");
  50. }
  51. return true;
  52. }
  53. public ModuleName Station { get; set; }
  54. public int Slot { get; set; }
  55. public Hand Blade { get; set; }
  56. public MpntTaskEnum TaskEnum { get; set; }
  57. public LoadPort _lpDevice;
  58. public Result Start(params object[] objs)
  59. {
  60. Name = "Place";
  61. Reset();
  62. _timeout = _scPlaceTimeout.IntValue;
  63. EV.PostMessage(ModuleName.System.ToString(), EventEnum.PuttingWaferToChamberBegins, string.Format("{0}{1:D2} by {2}", Station.ToString(), Slot + 1, Blade.ToString()));
  64. if (!ModuleHelper.IsLoadLock(Station) || TaskEnum == MpntTaskEnum.ParamNg)
  65. return Result.FAIL;
  66. return Result.RUN;
  67. }
  68. public Result Monitor()
  69. {
  70. try
  71. {
  72. switch (TaskEnum)
  73. {
  74. case MpntTaskEnum.P1:
  75. CheckBeforePlace((int)PlaceEx.CheckBeforePlace, "Check wafer before place", Station, Slot, Blade, Notify, Stop);
  76. RobotGoto((int)PlaceEx.PlaceWafer, "Extend to unLoadingPosition", Station, Slot, Blade, RobotPostionEnum.PlaceExtend, Notify, Stop);
  77. //PlaceReady((int)PlaceEx.PlaceReady, "Place wafer", Station, Slot, Blade, Notify, Stop);
  78. this.WaitRobotMotion((int)PlaceEx.WaitPlaceReady, robot, "Wait wafer placed", _timeout, Notify, Stop);
  79. break;
  80. case MpntTaskEnum.PB:
  81. //RobotSignalStatus((int)Pick.QuerySignalStatusBeforePlace, robot, _timeout);
  82. CheckBladeWaferIsExist((int)PlaceEx.CheckWaferPrecenseBeforePlace, robot, Blade, _timeout);
  83. //CheckTriggerSignalOn((int)PlaceEx.CheckTriggerSignalOn, "Check Trigger Signal On", Station, _timeout);
  84. CheckBeforePlace((int)PlaceEx.CheckBeforePlace, "Check wafer before place", Station, Slot, Blade, Notify, Stop);
  85. RobotGoto((int)PlaceEx.PlaceWafer, "Extend to unLoadingPosition", Station, Slot, Blade, RobotPostionEnum.PlaceExtend, Notify, Stop);
  86. this.WaitRobotMotion((int)PlaceEx.WaitPlaceReady, robot, "Wait wafer placed", _timeout, Notify, Stop);
  87. if (IsVacuumMode && NeedRobotGripAndUngrip)
  88. UnGripRobotBlade((int)PlaceEx.RobotBladeUnGrip, Blade, robot, _timeout);
  89. break;
  90. case MpntTaskEnum.P4:
  91. if (!IsVacuumMode && NeedRobotGripAndUngrip)
  92. UnGripRobotBlade((int)PlaceEx.RobotBladeUnGrip, Blade, robot, _timeout);
  93. RobotGoto((int)PlaceEx.PlaceRetract, "Retract from unLoadingPosition", Station, Slot, Blade, RobotPostionEnum.PlaceRetract, Notify, Stop);
  94. this.WaitRobotMotion((int)PlaceEx.WaitPlaceRetract, robot, "Wait wafer placed", _timeout, Notify, Stop);
  95. CheckBladeWaferIsExist((int)PlaceEx.CheckWaferPrecenseAfterPlace, robot, Blade, _timeout);
  96. //RobotSignalStatus((int)Pick.QuerySignalStatusAfterPlace, robot, _timeout);
  97. CheckAfterPlace((int)PlaceEx.CheckAfterPlace, "Check wafer information after wafer placed", Station, Slot, Blade, Notify, Stop);
  98. break;
  99. case MpntTaskEnum.ParamNg:
  100. break;
  101. }
  102. }
  103. catch (RoutineBreakException)
  104. {
  105. return Result.RUN;
  106. }
  107. catch (RoutineFaildException)
  108. {
  109. return Result.FAIL;
  110. }
  111. EV.PostMessage(ModuleName.System.ToString(), EventEnum.PuttingWaferToChamberEnds, string.Format("{0}{1:D2} by {2}", Station.ToString(), Slot + 1, Blade.ToString()));
  112. return Result.DONE;
  113. }
  114. protected override void Notify(string message)
  115. {
  116. EV.PostMessage(Module, EventEnum.GeneralInfo, String.Format("Place sequence:{0}", message));
  117. }
  118. /// <summary>
  119. /// prepare process failed
  120. /// </summary>
  121. /// <param name="failReason"></param>
  122. /// <param name="reactor"></param>
  123. protected override void Stop(string failReason)
  124. {
  125. string reason = String.Empty;
  126. EV.PostMessage(ModuleName.System.ToString(), EventEnum.PlaceWaferFailed, Station.ToString(), Slot + 1, Blade.ToString(), failReason);
  127. }
  128. public void PlaceReady(int id, string name, ModuleName chamber, int slot, Hand blade, Action<string> notify, Action<string> error)
  129. {
  130. Tuple<bool, Result> ret = Execute(id, () =>
  131. {
  132. notify(String.Format("Place wafer to {0}", chamber.ToString()));
  133. string reason = string.Empty;
  134. return robot.GoTo((RobotArmEnum)blade, chamber.ToString(), slot, RobotPostionEnum.PlaceReady);
  135. });
  136. if (ret.Item1)
  137. {
  138. if (ret.Item2 == Result.FAIL)
  139. {
  140. throw (new RoutineFaildException());
  141. }
  142. }
  143. }
  144. public void PlaceExtend(int id, string name, ModuleName chamber, int slot, Hand blade, Action<string> notify, Action<string> error)
  145. {
  146. Tuple<bool, Result> ret = Execute(id, () =>
  147. {
  148. notify(String.Format("Place wafer to {0}", chamber.ToString()));
  149. string reason = string.Empty;
  150. return robot.GoTo((RobotArmEnum)blade, chamber.ToString(), slot, RobotPostionEnum.PlaceExtendAtWafer);
  151. });
  152. if (ret.Item1)
  153. {
  154. if (ret.Item2 == Result.FAIL)
  155. {
  156. throw (new RoutineFaildException());
  157. }
  158. }
  159. }
  160. public void PlaceRetract(int id, string name, ModuleName chamber, int slot, Hand blade, Action<string> notify, Action<string> error)
  161. {
  162. Tuple<bool, Result> ret = Execute(id, () =>
  163. {
  164. notify(String.Format("Place wafer to {0}", chamber.ToString()));
  165. string reason = string.Empty;
  166. return robot.GoTo((RobotArmEnum)blade, chamber.ToString(), slot, RobotPostionEnum.PlaceRetract);
  167. });
  168. if (ret.Item1)
  169. {
  170. if (ret.Item2 == Result.FAIL)
  171. {
  172. throw (new RoutineFaildException());
  173. }
  174. }
  175. }
  176. public void CheckBeforePlace(int id, string name, ModuleName chamber, int slot, Hand blade, Action<string> notify, Action<string> error)
  177. {
  178. Tuple<bool, Result> ret = Execute(id, () =>
  179. {
  180. notify(String.Format("Check {0}{1:D2} wafer information before place wafer", chamber.ToString(), slot));
  181. string reason = string.Empty;
  182. if (!CheckRobotMotionInterlock(chamber, slot, out reason))
  183. {
  184. EV.PostMessage(ModuleName.System.ToString(), EventEnum.TransferPrepareFailed, String.Format("Target {0}{1:D2},{2}", chamber.ToString(), slot + 1, reason));
  185. return false;
  186. }
  187. if (blade == Hand.Blade1)
  188. {
  189. bool bNoWafer = WaferManager.Instance.CheckWafer(chamber, slot, WaferStatus.Empty);
  190. if (!bNoWafer)
  191. {
  192. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferPresentWithRecord, String.Format("Target {0}{1:D2}", chamber.ToString(), slot + 1));
  193. return false;
  194. }
  195. bool bHasWafer = WaferManager.Instance.CheckWafer(ModuleName.Robot, (int)blade, WaferStatus.Normal);
  196. if (!bHasWafer)
  197. {
  198. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferNotDetectedBeforeSend);
  199. return false;
  200. }
  201. bHasWafer = CheckSeneorHasWafer(ModuleName.Robot, (int)blade); //check sensor
  202. if (!bHasWafer)
  203. {
  204. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferNotDetectedBeforeSend);
  205. return false;
  206. }
  207. }
  208. else if (blade == Hand.Blade2)
  209. {
  210. bool bHasWafer = true;
  211. for (int i = 0; i < robot.Blade2Slots; i++)
  212. {
  213. bool bNoWafer = WaferManager.Instance.CheckWafer(chamber, slot + i, WaferStatus.Empty);
  214. if (!bNoWafer)
  215. {
  216. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferPresentWithRecord, String.Format("Target {0}{1:D2}", chamber.ToString(), slot + i + 1));
  217. return false;
  218. }
  219. bHasWafer &= WaferManager.Instance.CheckWafer(ModuleName.Robot, (int)blade + i, WaferStatus.Normal);
  220. bool bSensorWafer = CheckSeneorHasWafer(ModuleName.Robot, (int)blade + i); //check sensor
  221. if (!bSensorWafer)
  222. {
  223. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferNotDetectedBeforeSend);
  224. return false;
  225. }
  226. }
  227. if (!bHasWafer)
  228. {
  229. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferNotDetectedBeforeSend);
  230. return false;
  231. }
  232. }
  233. else
  234. {
  235. bool bHasWafer = true;
  236. for (int i = 0; i < robot.Blade2Slots + 1; i++)
  237. {
  238. bool bNoWafer = WaferManager.Instance.CheckWafer(chamber, slot + i, WaferStatus.Empty);
  239. if (!bNoWafer)
  240. {
  241. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferPresentWithRecord, String.Format("Target {0}{1:D2}", chamber.ToString(), slot + i + 1));
  242. return false;
  243. }
  244. bHasWafer &= WaferManager.Instance.CheckWafer(ModuleName.Robot, (int)Hand.Blade1 + i, WaferStatus.Normal);
  245. bool bSensorWafer = CheckSeneorHasWafer(ModuleName.Robot, (int)Hand.Blade1 + i); //check sensor
  246. if (!bSensorWafer)
  247. {
  248. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferNotDetectedBeforeSend);
  249. return false;
  250. }
  251. }
  252. if (!bHasWafer)
  253. {
  254. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferNotDetectedBeforeSend);
  255. return false;
  256. }
  257. }
  258. if (ModuleHelper.IsCoolingBuffer(chamber))
  259. {
  260. IoCoolingBuffer buffer = DEVICE.GetDevice<IoCoolingBuffer>(chamber.ToString());
  261. if (!buffer.CheckPinUp())
  262. {
  263. EV.PostWarningLog(chamber.ToString(), "Can not place wafer to buffer, buffer isn't pick position.");
  264. return false;
  265. }
  266. }
  267. else if (ModuleHelper.IsLoadPort(chamber) && MultiWaferSize)
  268. {
  269. //因为此手臂只有一个手抓
  270. WaferSize size = WaferManager.Instance.GetWaferSize(ModuleName.Robot, 0);
  271. OpenStageWithWaferSizeLoadPort lp = DEVICE.GetDevice<OpenStageWithWaferSizeLoadPort>(chamber.ToString());
  272. if (size != lp.Size)
  273. {
  274. EV.PostWarningLog(chamber.ToString(), "Can not place wafer to loadport, size is unmatch.");
  275. return false;
  276. }
  277. }
  278. return true;
  279. });
  280. if (ret.Item1)
  281. {
  282. if (ret.Item2 == Result.FAIL)
  283. {
  284. error(String.Format("Check wafer information failed, can not place."));
  285. throw (new RoutineFaildException());
  286. }
  287. }
  288. }
  289. public void CheckAfterPlace(int id, string name, ModuleName chamber, int slot, Hand blade, Action<string> notify, Action<string> error)
  290. {
  291. Tuple<bool, Result> ret = Execute(id, () =>
  292. {
  293. notify(name);
  294. //if (ModuleHelper.IsLoadLock(chamber) && Singleton<EfemEntity>.Instance.IsOnlineMode)
  295. //{
  296. // //online mode, DeleteWafer in LoadLock
  297. // WaferManager.Instance.DeleteWafer(chamber, slot);
  298. //}
  299. if (blade == Hand.Blade1)
  300. {
  301. bool bNoWafer = CheckSensorNoWafer(ModuleName.Robot, (int)blade);
  302. if (!bNoWafer)
  303. {
  304. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferDetectedAfterSend);
  305. return false;
  306. }
  307. }
  308. else if (blade == Hand.Blade2)
  309. {
  310. for (int i = 0; i < robot.Blade2Slots; i++)
  311. {
  312. bool bNoWafer = CheckSensorNoWafer(ModuleName.Robot, (int)blade + i);
  313. if (!bNoWafer)
  314. {
  315. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferDetectedAfterSend);
  316. return false;
  317. }
  318. }
  319. }
  320. else
  321. {
  322. for (int i = 0; i < robot.Blade2Slots + 1; i++)
  323. {
  324. bool bNoWafer = CheckSensorNoWafer(ModuleName.Robot, (int)Hand.Blade1 + i);
  325. if (!bNoWafer)
  326. {
  327. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferDetectedAfterSend);
  328. return false;
  329. }
  330. }
  331. }
  332. return true;
  333. });
  334. if (ret.Item1)
  335. {
  336. if (ret.Item2 == Result.FAIL)
  337. {
  338. error(String.Format("Failed to check wafer information"));
  339. throw (new RoutineFaildException());
  340. }
  341. }
  342. }
  343. }
  344. }