PlaceExtendRoutine.cs 16 KB

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