PickTask.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.Util;
  4. using Aitex.Sorter.Common;
  5. using Aitex.Sorter.RT.EFEMs.Servers;
  6. using MECF.Framework.Common.Equipment;
  7. using MECF.Framework.Common.SubstrateTrackings;
  8. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
  9. namespace Aitex.Sorter.RT.EFEMs.Tasks
  10. {
  11. public class PickTask : RobotImp, ITask
  12. {
  13. Hand _arm = Hand.Blade2;
  14. public PickTask()
  15. {
  16. }
  17. public bool Execute(out string result, params string[] args)
  18. {
  19. string device = DeviceName.Robot;
  20. IServerModule entity = GetEntity(device);
  21. ModuleName target = ModuleName.System;
  22. int slot = 1;
  23. if (!ParseMoveTarget(args[0], out target, out slot))
  24. {
  25. result = PARAM_NG;
  26. return false;
  27. }
  28. if (!ParseMoveArm(args[1], out _arm))
  29. {
  30. result = PARAM_NG;
  31. return false;
  32. }
  33. if (!Check<NoReadyPolicy>(device, out result))
  34. {
  35. return false;
  36. }
  37. if (!Check<NoInitCompletedPolicy>(device, out result))
  38. {
  39. return false;
  40. }
  41. if (!Check<NoOriginCompletedPolicy>(device, out result))
  42. {
  43. return false;
  44. }
  45. if (!Check<VacPolicy>(device, out result))
  46. {
  47. return false;
  48. }
  49. if (!Check<EMSPolicy>(device, out result))
  50. {
  51. return false;
  52. }
  53. if (!Check<ErrorPolicy>(device, out result))
  54. {
  55. return false;
  56. }
  57. if (!Check<BusyPolicy>(device, out result))
  58. {
  59. LOG.Write($"PickTask {device} Busy");
  60. return false;
  61. }
  62. if (!Check<ClosePolicy>(device, out result))
  63. {
  64. return false;
  65. }
  66. if (!Check<NoWaferMappingCompletedPolicy>(device, out result))
  67. {
  68. return false;
  69. }
  70. if (!Check<NoPodPolicy>(device, out result))
  71. {
  72. return false;
  73. }
  74. //do not check loadlock
  75. if (!ModuleHelper.IsLoadLock(target) && !Singleton<WaferManager>.Instance.CheckHasWafer(target,slot-1))
  76. {
  77. result = "NONWAF";
  78. return false;
  79. }
  80. if (_arm == Hand.Blade1)
  81. {
  82. if (Singleton<WaferManager>.Instance.CheckHasWafer(ModuleName.Robot,0))
  83. {
  84. result = "WAFER";
  85. return false;
  86. }
  87. }
  88. else if (_arm == Hand.Blade2)
  89. {
  90. if (Singleton<WaferManager>.Instance.CheckHasWafer(ModuleName.Robot,1))
  91. {
  92. result = "WAFER";
  93. return false;
  94. }
  95. }
  96. else
  97. {
  98. if (Singleton<WaferManager>.Instance.CheckHasWafer(ModuleName.Robot,0))
  99. {
  100. result = "WAFER";
  101. return false;
  102. }
  103. if (Singleton<WaferManager>.Instance.CheckHasWafer(ModuleName.Robot,1))
  104. {
  105. result = "WAFER";
  106. return false;
  107. }
  108. }
  109. if (!Check<HoldPolicy>(device, out result))
  110. {
  111. return false;
  112. }
  113. if (!Check<RemovePolicy>(device, out result))
  114. {
  115. return false;
  116. }
  117. if (!Check<MaintenancePolicy>(device, out result))
  118. {
  119. return false;
  120. }
  121. if (!Check<LinkPolicy>(device, out result))
  122. {
  123. return false;
  124. }
  125. if (!Check<PowerDownPolicy>(device, out result))
  126. {
  127. return false;
  128. }
  129. if (Singleton<EfemEntity>.Instance.EfemDevice.IsError)
  130. {
  131. result = "ERROR";
  132. return false;
  133. }
  134. if (!Singleton<EfemEntity>.Instance.EfemDevice.IsIdle)
  135. {
  136. LOG.Write($"PickTask RouteManager is Busy");
  137. result = "BUSY";
  138. return false;
  139. }
  140. _token = Singleton<EfemEntity>.Instance.EfemDevice.Invoke("Pick", target.ToString(), slot - 1, _arm);
  141. return true;
  142. }
  143. public bool? Monitor(out string result, params string[] args)
  144. {
  145. result = string.Empty;
  146. if (Singleton<EfemEntity>.Instance.EfemDevice.CheckIsError(ModuleName.Robot))
  147. {
  148. string param1 = "";
  149. if (_arm == Hand.Blade1)
  150. {
  151. if (Singleton<WaferManager>.Instance.CheckHasWafer(ModuleName.Robot, 0))
  152. {
  153. param1 = "WAFER";
  154. }
  155. else
  156. {
  157. param1 = "NONWAF";
  158. }
  159. }
  160. else if (_arm == Hand.Blade2)
  161. {
  162. if (Singleton<WaferManager>.Instance.CheckHasWafer(ModuleName.Robot, 1))
  163. {
  164. param1 = "WAFER";
  165. }
  166. else
  167. {
  168. param1 = "NONWAF";
  169. }
  170. }
  171. result = $"ERROR|{param1}";
  172. return false;
  173. }
  174. if (Singleton<EfemEntity>.Instance.EfemDevice.CheckIsIdle(ModuleName.Robot)
  175. && Singleton<EfemEntity>.Instance.EfemDevice.CheckIsIdle(ModuleName.System)
  176. && Singleton<EfemEntity>.Instance.EfemDevice.CheckAcked(_token))
  177. return true;
  178. return null;
  179. }
  180. }
  181. }