PickTask.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. using Aitex.Core.Common;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Core.RT.Event;
  4. using Aitex.Core.RT.Log;
  5. using Aitex.Core.RT.SCCore;
  6. using Aitex.Core.Util;
  7. using EFEM.RT.Modules;
  8. using Aitex.Sorter.Common;
  9. using System.Linq;
  10. using Efem;
  11. using MECF.Framework.Common.Equipment;
  12. using MECF.Framework.Common.SubstrateTrackings;
  13. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
  14. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
  15. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase;
  16. namespace EFEM.RT.Tasks
  17. {
  18. public class PickTask : RobotImp, ITask
  19. {
  20. public PickTask()
  21. {
  22. }
  23. public bool Execute(out string result, params string[] args)
  24. {
  25. string device = DeviceName.Robot;
  26. IServerModule entity = GetEntity(device);
  27. ModuleName target = ModuleName.System;
  28. int slot = 1;
  29. if (!ParseMoveTarget(args[0], out target, out slot))
  30. {
  31. result = PARAM_NG;
  32. return false;
  33. }
  34. Hand arm = Hand.Blade2;
  35. if (!ParseMoveArm(args[1], out arm))
  36. {
  37. EV.PostWarningLog("Server", $"{args[1]} not valid arm parameter");
  38. result = PARAM_NG;
  39. return false;
  40. }
  41. if (ModuleHelper.IsLoadLock(target) && !SC.GetValue<bool>("System.IsLoadLockEnableZMotion"))
  42. {
  43. EV.PostWarningLog("Server", $"not support LL z motion, can not LOAD {target}");
  44. result = PARAM_NG;
  45. return false;
  46. }
  47. if (MultiWaferSize)
  48. {
  49. if (args.Length < 2)
  50. {
  51. result = PARAM_NG;
  52. return false;
  53. }
  54. if (!CheckWaferSize(args[2], target, slot - 1))
  55. {
  56. result = PARAM_NG;
  57. return false;
  58. }
  59. //if (ModuleHelper.IsLoadPort(target))
  60. //{
  61. //OpenStageWithWaferSizeLoadPort lp = DEVICE.GetDevice<OpenStageWithWaferSizeLoadPort>(target.ToString());
  62. //var
  63. //if (slot == 1 && lp.WaferSize == WaferSize.WS3)
  64. //{
  65. // EV.PostWarningLog("EFEM", $"{target} is 3', slot 1 is disabled");
  66. // result = PARAM_NG;
  67. // return false;
  68. //}
  69. // }
  70. }
  71. if (!Check<NoReadyPolicy>(device, out result))
  72. {
  73. return false;
  74. }
  75. if (!Check<NoInitCompletedPolicy>(device, out result))
  76. {
  77. return false;
  78. }
  79. if (!Check<NoOriginCompletedPolicy>(device, out result))
  80. {
  81. return false;
  82. }
  83. if (!Check<VacPolicy>(device, out result))
  84. {
  85. return false;
  86. }
  87. if (!Check<EMSPolicy>(device, out result))
  88. {
  89. return false;
  90. }
  91. if (!Check<ErrorPolicy>(device, out result))
  92. {
  93. return false;
  94. }
  95. if (!Check<DisablePolicy>(device, out result))
  96. {
  97. // LOG.Write($"PickTask {device} Busy");
  98. return false;
  99. }
  100. if (!Check<BusyPolicy>(device, out result))
  101. {
  102. LOG.Write($"PickTask {device} Busy");
  103. return false;
  104. }
  105. if (!Check<DisablePolicy>(target.ToString(), out result))
  106. {
  107. // LOG.Write($"PickTask {device} Busy");
  108. return false;
  109. }
  110. if (!Check<ClosePolicy>(device, out result))
  111. {
  112. return false;
  113. }
  114. if (!Check<NoWaferMappingCompletedPolicy>(device, out result))
  115. {
  116. return false;
  117. }
  118. if (!Check<NoWaferMappingCompletedPolicy>(target.ToString(), out result))
  119. {
  120. return false;
  121. }
  122. if (!Check<NoPodPolicy>(device, out result))
  123. {
  124. return false;
  125. }
  126. //do not check loadlock
  127. if (!ModuleHelper.IsBuffer(target))
  128. {
  129. if (!ModuleHelper.IsLoadLock(target)&& !Singleton<WaferManager>.Instance.CheckHasWafer(target, slot - 1))
  130. {
  131. result = "NONWAF";
  132. return false;
  133. }
  134. }
  135. if (ModuleHelper.IsLoadPort(target))
  136. {
  137. if (!Check<ErrorPolicy>(target.ToString(), out result))
  138. {
  139. return false;
  140. }
  141. }
  142. if (arm == Hand.Blade1)
  143. {
  144. if (!Singleton<WaferManager>.Instance.CheckNoWafer(ModuleName.Robot,0))
  145. {
  146. result = "WAFER";
  147. return false;
  148. }
  149. }
  150. else if (arm == Hand.Blade2)
  151. {
  152. if (!Singleton<WaferManager>.Instance.CheckNoWafer(ModuleName.Robot,1))
  153. {
  154. result = "WAFER";
  155. return false;
  156. }
  157. }
  158. else
  159. {
  160. if (!Singleton<WaferManager>.Instance.CheckNoWafer(ModuleName.Robot,0))
  161. {
  162. result = "WAFER";
  163. return false;
  164. }
  165. if (!Singleton<WaferManager>.Instance.CheckNoWafer(ModuleName.Robot,1))
  166. {
  167. result = "WAFER";
  168. return false;
  169. }
  170. }
  171. if (!Check<HoldPolicy>(device, out result))
  172. {
  173. return false;
  174. }
  175. if (!Check<RemovePolicy>(device, out result))
  176. {
  177. return false;
  178. }
  179. if (!Check<MaintenancePolicy>(device, out result))
  180. {
  181. return false;
  182. }
  183. if (!Check<LinkPolicy>(device, out result))
  184. {
  185. return false;
  186. }
  187. if (!Check<PowerDownPolicy>(device, out result))
  188. {
  189. return false;
  190. }
  191. if (!Singleton<RouteManager>.Instance.IsIdle)
  192. {
  193. LOG.Write($"PickTask RouteManager is Busy");
  194. result = "BUSY";
  195. return false;
  196. }
  197. _token = Singleton<RouteManager>.Instance.Invoke("Pick", target.ToString(), slot - 1, arm);
  198. return true;
  199. }
  200. public bool? Monitor(out string result, params string[] args)
  201. {
  202. result = string.Empty;
  203. RobotBaseDevice _device = DEVICE.GetDevice<RobotBaseDevice>(DeviceName.Robot);
  204. if (_device.IsError|| Singleton<RouteManager>.Instance.IsError)
  205. {
  206. flag1 = ErrorCheckList1.VAC | ErrorCheckList1.AIR | ErrorCheckList1.STALL
  207. | ErrorCheckList1.LIMIT | ErrorCheckList1.SENSOR | ErrorCheckList1.POSITION | ErrorCheckList1.EMS
  208. | ErrorCheckList1.COMM | ErrorCheckList1.COMM2 | ErrorCheckList1.VACON | ErrorCheckList1.VACOFF
  209. | ErrorCheckList1.CLAMPON | ErrorCheckList1.CLAMPOF;
  210. flag2 = ErrorCheckList2.RRTWAF | ErrorCheckList2.CRSWAF | ErrorCheckList2.THICKWAF | ErrorCheckList2.THINWAF
  211. | ErrorCheckList2.DBLWAF | ErrorCheckList2.BAOWAF | ErrorCheckList2.COMMAND | ErrorCheckList2.PODNG
  212. | ErrorCheckList2.PODMISMATCH | ErrorCheckList2.VAC_S | ErrorCheckList2.CLAMP_S | ErrorCheckList2.SAFTY
  213. | ErrorCheckList2.LOCKNG | ErrorCheckList2.UNLOCKNG | ErrorCheckList2.L_KEY_LK | ErrorCheckList2.L_KEY_UL;
  214. flag3 = ErrorCheckList3.MAP_S | ErrorCheckList3.MAP_S1 | ErrorCheckList3.MAP_S2 | ErrorCheckList3.WAFLOST
  215. | ErrorCheckList3.ALIGNNG
  216. | ErrorCheckList3.DRIVER | ErrorCheckList3.DRPOWERDOWN | ErrorCheckList3.HARDWARE
  217. | ErrorCheckList3.INTERNAL | ErrorCheckList3.E84_TIMEOUTx | ErrorCheckList3.E84_CS_VALID | ErrorCheckList3.READFAIL;
  218. var ret= CheckError(DeviceName.Robot, out result);
  219. if (!ret)
  220. {
  221. result = "";
  222. if (Singleton<EfemEntity>.Instance.EventError != null)
  223. {
  224. var items = Singleton<EfemEntity>.Instance.EventError.ToList().Where(m => m.Source == "System" || m.Source == "Robot").Reverse().ToList();
  225. for(int i=0;i<items.Count;i++)
  226. {
  227. if(i<3)
  228. result += items[i].Description +"|";
  229. }
  230. }
  231. }
  232. return ret;
  233. }
  234. if (Singleton<RouteManager>.Instance.IsIdle&& _device.IsReady()&& Singleton<RouteManager>.Instance.CheckAcked(_token))
  235. return true;
  236. return null;
  237. }
  238. }
  239. }