WafshTask.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. using System;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Core.Util;
  4. using EFEM.RT.Modules;
  5. using Aitex.Sorter.Common;
  6. using Efem.Protocol;
  7. using MECF.Framework.Common.Equipment;
  8. using MECF.Framework.Common.SubstrateTrackings;
  9. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
  10. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
  11. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase;
  12. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase;
  13. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.BufferStations;
  14. namespace EFEM.RT.Tasks
  15. {
  16. public class WafshTask : CheckImp, ITask
  17. {
  18. public WafshTask()
  19. {
  20. }
  21. public bool Execute(out string result, params string[] args)
  22. {
  23. string device = Args2Unit(args.Length > 0 ? args[0] : string.Empty);
  24. SystemServerModule entity = (SystemServerModule)GetEntity(DeviceName.System);
  25. if (entity == null)
  26. {
  27. result = PARAM_NG;
  28. return false;
  29. }
  30. if (!Check<NoReadyPolicy>(device, out result))
  31. {
  32. return false;
  33. }
  34. if (!Check<NoInitCompletedPolicy>(device, out result))
  35. {
  36. return false;
  37. }
  38. if (!Check<NoOriginCompletedPolicy>(device, out result))
  39. {
  40. return false;
  41. }
  42. if (!Check<VacPolicy>(device, out result))
  43. {
  44. return false;
  45. }
  46. if (!Check<AirPolicy>(device, out result))
  47. {
  48. return false;
  49. }
  50. if (!Check<EMSPolicy>(device, out result))
  51. {
  52. return false;
  53. }
  54. if (DeviceDefineManager.Instance.GetValue<bool>("WAFSHEnable") == false)
  55. {
  56. if (!Check<ErrorPolicy>(DeviceName.Robot, out result))
  57. {
  58. return false;
  59. }
  60. }
  61. else
  62. {
  63. if (!Check<ErrorPolicy>(device, out result))
  64. {
  65. return false;
  66. }
  67. }
  68. if (!Check<BusyPolicy>(device, out result))
  69. {
  70. return false;
  71. }
  72. if (DeviceDefineManager.Instance.GetValue<bool>("WAFSHEnable") == false && !Check<BusyPolicy>(DeviceName.Robot, out result))
  73. {
  74. return false;
  75. }
  76. if (!Check<HoldPolicy>(device, out result))
  77. {
  78. return false;
  79. }
  80. if (!Check<RemovePolicy>(device, out result))
  81. {
  82. return false;
  83. }
  84. if (!Check<MaintenancePolicy>(device, out result))
  85. {
  86. return false;
  87. }
  88. if (!Check<LinkPolicy>(device, out result))
  89. {
  90. return false;
  91. }
  92. if (DeviceDefineManager.Instance.GetValue<bool>("WAFSHEnable") == false && !Check<ArmExtendPolicy>(device, out result))
  93. {
  94. return false;
  95. }
  96. if (!Check<PowerDownPolicy>(device, out result))
  97. {
  98. return false;
  99. }
  100. if (!Check<NoPosPolicy>(device, out result))
  101. {
  102. return false;
  103. }
  104. if (!Check<NoPodPolicy>(device, out result))
  105. {
  106. return false;
  107. }
  108. //if (!Check<ClosePolicy>(device, out result))
  109. //{
  110. // return false;
  111. //}
  112. //if (DeviceDefineManager.Instance.GetValue<bool>("WAFSHEnable")==false)
  113. //{
  114. // result = "This device doesn't support mapping.";
  115. // return false;
  116. //}
  117. if (ModuleHelper.IsLoadPort(ModuleHelper.Converter(device)))
  118. {
  119. if (!DEVICE.GetDevice<LoadPortBaseDevice>(device).IsMapWaferByLoadPort&&DeviceDefineManager.Instance.GetValue<bool>("WAFSHEnable") == false)
  120. {
  121. if (!entity.MapWafer(device, out result))
  122. {
  123. return false;
  124. }
  125. }
  126. else
  127. {
  128. LoadPortServerModule lpEntity = (LoadPortServerModule)GetEntity(device);
  129. if (lpEntity == null)
  130. {
  131. result = PARAM_NG;
  132. return false;
  133. }
  134. if (lpEntity.DockState == FoupDockState.Docked)
  135. {
  136. if (!lpEntity.QueryWaferMap(out result))
  137. {
  138. return false;
  139. }
  140. }
  141. else
  142. {
  143. if (!lpEntity.Open(out result))
  144. {
  145. return false;
  146. }
  147. }
  148. }
  149. }
  150. else if (ModuleHelper.IsBuffer(ModuleHelper.Converter(device)))
  151. {
  152. if (!entity.MapWafer(device, out result))
  153. {
  154. return false;
  155. }
  156. }
  157. return true;
  158. }
  159. public bool? Monitor(out string result, params string[] args)
  160. {
  161. result = string.Empty;
  162. string device = Args2Unit(args.Length > 0 ? args[0] : string.Empty);
  163. if (ModuleHelper.IsLoadPort(ModuleHelper.Converter(device)))
  164. {
  165. LoadPortBaseDevice _loadport = DEVICE.GetDevice<LoadPortBaseDevice>(device);
  166. RobotBaseDevice _robot = DEVICE.GetDevice<RobotBaseDevice>(DeviceName.Robot);
  167. if (_loadport.IsError || _robot.IsError)
  168. {
  169. flag1 = ErrorCheckList1.VAC | ErrorCheckList1.AIR | ErrorCheckList1.STALL
  170. | ErrorCheckList1.LIMIT | ErrorCheckList1.SENSOR | ErrorCheckList1.POSITION | ErrorCheckList1.EMS
  171. | ErrorCheckList1.COMM | ErrorCheckList1.COMM2 | ErrorCheckList1.VACON | ErrorCheckList1.VACOFF
  172. | ErrorCheckList1.CLAMPON | ErrorCheckList1.CLAMPOF;
  173. flag2 = ErrorCheckList2.RRTWAF | ErrorCheckList2.CRSWAF | ErrorCheckList2.THICKWAF | ErrorCheckList2.THINWAF
  174. | ErrorCheckList2.DBLWAF | ErrorCheckList2.BAOWAF | ErrorCheckList2.COMMAND | ErrorCheckList2.PODNG
  175. | ErrorCheckList2.PODMISMATCH | ErrorCheckList2.VAC_S | ErrorCheckList2.CLAMP_S | ErrorCheckList2.SAFTY
  176. | ErrorCheckList2.LOCKNG | ErrorCheckList2.UNLOCKNG | ErrorCheckList2.L_KEY_LK | ErrorCheckList2.L_KEY_UL;
  177. flag3 = ErrorCheckList3.MAP_S | ErrorCheckList3.MAP_S1 | ErrorCheckList3.MAP_S2 | ErrorCheckList3.WAFLOST
  178. | ErrorCheckList3.ALIGNNG
  179. | ErrorCheckList3.DRIVER | ErrorCheckList3.DRPOWERDOWN | ErrorCheckList3.HARDWARE
  180. | ErrorCheckList3.INTERNAL | ErrorCheckList3.E84_TIMEOUTx | ErrorCheckList3.E84_CS_VALID | ErrorCheckList3.READFAIL;
  181. return CheckError(device, out result);
  182. }
  183. SystemServerModule entity = (SystemServerModule)GetEntity(DeviceName.System);
  184. if (_robot.IsReady() && _loadport.IsReady() && _loadport.IsMapped)
  185. {
  186. if (Singleton<RouteManager>.Instance.CheckAcked((int)RouteManager.MSG.MapWafer) &&
  187. Singleton<RouteManager>.Instance.IsIdle)
  188. {
  189. Singleton<EfemEntity>.Instance.SendMapEvent(_loadport);
  190. return true;
  191. }
  192. }
  193. }
  194. else if (ModuleHelper.IsBuffer(ModuleHelper.Converter(device)))
  195. {
  196. BufferStation _buffer = DEVICE.GetDevice<BufferStation>(device);
  197. RobotBaseDevice _robot = DEVICE.GetDevice<RobotBaseDevice>(DeviceName.Robot);
  198. if (_robot.IsError)
  199. {
  200. flag1 = ErrorCheckList1.VAC | ErrorCheckList1.AIR | ErrorCheckList1.STALL
  201. | ErrorCheckList1.LIMIT | ErrorCheckList1.SENSOR | ErrorCheckList1.POSITION | ErrorCheckList1.EMS
  202. | ErrorCheckList1.COMM | ErrorCheckList1.COMM2 | ErrorCheckList1.VACON | ErrorCheckList1.VACOFF
  203. | ErrorCheckList1.CLAMPON | ErrorCheckList1.CLAMPOF;
  204. flag2 = ErrorCheckList2.RRTWAF | ErrorCheckList2.CRSWAF | ErrorCheckList2.THICKWAF | ErrorCheckList2.THINWAF
  205. | ErrorCheckList2.DBLWAF | ErrorCheckList2.BAOWAF | ErrorCheckList2.COMMAND | ErrorCheckList2.PODNG
  206. | ErrorCheckList2.PODMISMATCH | ErrorCheckList2.VAC_S | ErrorCheckList2.CLAMP_S | ErrorCheckList2.SAFTY
  207. | ErrorCheckList2.LOCKNG | ErrorCheckList2.UNLOCKNG | ErrorCheckList2.L_KEY_LK | ErrorCheckList2.L_KEY_UL;
  208. flag3 = ErrorCheckList3.MAP_S | ErrorCheckList3.MAP_S1 | ErrorCheckList3.MAP_S2 | ErrorCheckList3.WAFLOST
  209. | ErrorCheckList3.ALIGNNG
  210. | ErrorCheckList3.DRIVER | ErrorCheckList3.DRPOWERDOWN | ErrorCheckList3.HARDWARE
  211. | ErrorCheckList3.INTERNAL | ErrorCheckList3.E84_TIMEOUTx | ErrorCheckList3.E84_CS_VALID | ErrorCheckList3.READFAIL;
  212. return CheckError(device, out result);
  213. }
  214. SystemServerModule entity = (SystemServerModule)GetEntity(DeviceName.System);
  215. if (_robot.IsReady() && _buffer.IsMapped)
  216. {
  217. if (Singleton<RouteManager>.Instance.CheckAcked((int)RouteManager.MSG.MapWafer) &&
  218. Singleton<RouteManager>.Instance.IsIdle)
  219. {
  220. Singleton<EfemEntity>.Instance.SendMapEvent(_buffer);
  221. return true;
  222. }
  223. }
  224. }
  225. return null;
  226. }
  227. public bool Ack(EfemCommandType type, EfemCommand cmd, params string[] args)
  228. {
  229. return cmd == EfemCommand.WAFSH;
  230. }
  231. }
  232. }