PlaceTask.cs 9.0 KB

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