CstidTask.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.SCCore;
  3. using Aitex.Core.Util;
  4. using Efem;
  5. using EFEM.RT.Devices;
  6. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.CarrierIdReaders;
  7. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.CarrierIdReaders.CarrierIDReaderBase;
  8. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.CarrierIdReaders.OmronRFID;
  9. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase;
  10. namespace EFEM.RT.Tasks
  11. {
  12. public class CstidTask : CheckImp, ITask
  13. {
  14. private string _param1;
  15. public CstidTask()
  16. {
  17. }
  18. public bool Execute(out string result, params string[] args)
  19. {
  20. string device = Args2Unit(args.Length > 0 ?args[0]:string.Empty);
  21. IServerModule entity = GetEntity(device);
  22. if (entity == null || !(entity is LoadPortServerModule))
  23. {
  24. result = PARAM_NG;
  25. return false;
  26. }
  27. _param1 = args[0];
  28. if (!Check<NoReadyPolicy>(device, out result))
  29. {
  30. return false;
  31. }
  32. if (!Check<NoInitCompletedPolicy>(device, out result))
  33. {
  34. return false;
  35. }
  36. if (!Check<EMSPolicy>(device, out result))
  37. {
  38. return false;
  39. }
  40. if (!Check<ErrorPolicy>(device, out result))
  41. {
  42. return false;
  43. }
  44. if (!Check<BusyPolicy>(device, out result))
  45. {
  46. return false;
  47. }
  48. if (!Check<NoPodPolicy>(device, out result))
  49. {
  50. return false;
  51. }
  52. if (!Check<HoldPolicy>(device, out result))
  53. {
  54. return false;
  55. }
  56. if (!Check<RemovePolicy>(device, out result))
  57. {
  58. return false;
  59. }
  60. if (!Check<MaintenancePolicy>(device, out result))
  61. {
  62. return false;
  63. }
  64. if (!Check<LinkPolicy>(device, out result))
  65. {
  66. return false;
  67. }
  68. if (!Check<NoFuncPolicy>(device, out result))
  69. {
  70. return false;
  71. }
  72. //CarrierIdReader _device = Singleton<DeviceManager>.Instance.GetRfidReader(device);
  73. //if (_device == null)
  74. //{
  75. // result = PARAM_NG;
  76. // return false;
  77. //}
  78. //_device.Read(out result);
  79. LoadPortServerModule lpEntity = (LoadPortServerModule)GetEntity(device);
  80. if (lpEntity == null)
  81. {
  82. result = PARAM_NG;
  83. return false;
  84. }
  85. //if (!lpEntity.QueryWaferMap(out result))
  86. if (SC.GetValue<int>($"LoadPort.{device}.CstType") == 0 &&SC.GetValue<bool>($"LoadPort.{device}.ExternalSmartTagReader"))
  87. {
  88. if (!lpEntity.Read())
  89. {
  90. return false;
  91. }
  92. }
  93. else
  94. {
  95. if (args.Length == 1)
  96. {
  97. if (!lpEntity.Read(out result))
  98. {
  99. return false;
  100. }
  101. }
  102. if (args.Length == 2)
  103. {
  104. if (!lpEntity.Read(args[1].ToString(), out result))
  105. {
  106. return false;
  107. }
  108. }
  109. }
  110. return true;
  111. }
  112. public bool? Monitor(out string result, params string[] args)
  113. {
  114. result = string.Empty;
  115. string device = Args2Unit(args.Length > 0 ?args[0]:string.Empty);
  116. //OmronRfidReader _device = Singleton<DeviceManager>.Instance.GetRfidReader(device);
  117. LoadPortBaseDevice _device = DEVICE.GetDevice<LoadPortBaseDevice>(device);
  118. if (_device.IsError)
  119. {
  120. flag1 = ErrorCheckList1.VAC | ErrorCheckList1.AIR | ErrorCheckList1.STALL
  121. | ErrorCheckList1.LIMIT | ErrorCheckList1.SENSOR | ErrorCheckList1.POSITION | ErrorCheckList1.EMS
  122. | ErrorCheckList1.COMM | ErrorCheckList1.COMM2 | ErrorCheckList1.VACON | ErrorCheckList1.VACOFF
  123. | ErrorCheckList1.CLAMPON | ErrorCheckList1.CLAMPOF;
  124. flag2 = ErrorCheckList2.RRTWAF | ErrorCheckList2.CRSWAF | ErrorCheckList2.THICKWAF | ErrorCheckList2.THINWAF
  125. | ErrorCheckList2.DBLWAF | ErrorCheckList2.BAOWAF | ErrorCheckList2.COMMAND | ErrorCheckList2.PODNG
  126. | ErrorCheckList2.PODMISMATCH | ErrorCheckList2.VAC_S | ErrorCheckList2.CLAMP_S | ErrorCheckList2.SAFTY
  127. | ErrorCheckList2.LOCKNG | ErrorCheckList2.UNLOCKNG | ErrorCheckList2.L_KEY_LK | ErrorCheckList2.L_KEY_UL;
  128. flag3 = ErrorCheckList3.MAP_S | ErrorCheckList3.MAP_S1 | ErrorCheckList3.MAP_S2 | ErrorCheckList3.WAFLOST
  129. | ErrorCheckList3.ALIGNNG
  130. | ErrorCheckList3.DRIVER | ErrorCheckList3.DRPOWERDOWN | ErrorCheckList3.HARDWARE
  131. | ErrorCheckList3.INTERNAL | ErrorCheckList3.E84_TIMEOUTx | ErrorCheckList3.E84_CS_VALID | ErrorCheckList3.READFAIL;
  132. return CheckError(device, out result);
  133. }
  134. if (!_device.IsBusy)
  135. {
  136. if (SC.GetValue<int>($"LoadPort.{device}.CstType")==0)
  137. {
  138. if (!SC.GetValue<bool>($"LoadPort.{device}.ExternalSmartTagReader"))
  139. {
  140. if (string.IsNullOrWhiteSpace(_device.LPLotID))
  141. result = "NOREAD";
  142. else
  143. result = $"{_device.LPLotID}";// CarrierId}";
  144. }
  145. else
  146. {
  147. CIDReaderBaseDevice _device1 = Singleton<DeviceManager>.Instance.GetGeneralBarcodeReader(device);
  148. if (_device1.IsBusy) return null;
  149. if (_device1.DeviceState != CIDReaderStateEnum.Idle) return null;
  150. {
  151. if (string.IsNullOrWhiteSpace(_device.CarrierId))
  152. result = "NOREAD";
  153. else
  154. result = $"{_device.CarrierId}";// CarrierId}";
  155. }
  156. }
  157. }
  158. else
  159. {
  160. CIDReaderBaseDevice _device1 = Singleton<DeviceManager>.Instance.GetGeneralBarcodeReader(device);
  161. if (_device1.IsBusy) return null;
  162. if (_device1.DeviceState != CIDReaderStateEnum.Idle) return null;
  163. {
  164. if (string.IsNullOrWhiteSpace(_device.CarrierId))
  165. result = "NOREAD";
  166. else
  167. result = $"{_device.CarrierId}";// CarrierId}";
  168. }
  169. }
  170. return true;
  171. }
  172. return null;
  173. }
  174. }
  175. public class SetCstidTask : CheckImp, ITask
  176. {
  177. private string _param1;
  178. public SetCstidTask()
  179. {
  180. }
  181. public bool Execute(out string result, params string[] args)
  182. {
  183. string device = Args2Unit(args.Length > 0 ? args[0] : string.Empty);
  184. IServerModule entity = GetEntity(device);
  185. if (entity == null || !(entity is LoadPortServerModule))
  186. {
  187. result = PARAM_NG;
  188. return false;
  189. }
  190. _param1 = args[0];
  191. if (!Check<NoReadyPolicy>(device, out result))
  192. {
  193. return false;
  194. }
  195. if (!Check<NoInitCompletedPolicy>(device, out result))
  196. {
  197. return false;
  198. }
  199. if (!Check<EMSPolicy>(device, out result))
  200. {
  201. return false;
  202. }
  203. if (!Check<ErrorPolicy>(device, out result))
  204. {
  205. return false;
  206. }
  207. if (!Check<BusyPolicy>(device, out result))
  208. {
  209. return false;
  210. }
  211. if (!Check<NoPodPolicy>(device, out result))
  212. {
  213. return false;
  214. }
  215. if (!Check<HoldPolicy>(device, out result))
  216. {
  217. return false;
  218. }
  219. if (!Check<RemovePolicy>(device, out result))
  220. {
  221. return false;
  222. }
  223. if (!Check<MaintenancePolicy>(device, out result))
  224. {
  225. return false;
  226. }
  227. if (!Check<LinkPolicy>(device, out result))
  228. {
  229. return false;
  230. }
  231. if (!Check<NoFuncPolicy>(device, out result))
  232. {
  233. return false;
  234. }
  235. //CarrierIdReader _device = Singleton<DeviceManager>.Instance.GetRfidReader(device);
  236. //if (_device == null)
  237. //{
  238. // result = PARAM_NG;
  239. // return false;
  240. //}
  241. //_device.Read(out result);
  242. LoadPortServerModule lpEntity = (LoadPortServerModule)GetEntity(device);
  243. if (lpEntity == null)
  244. {
  245. result = PARAM_NG;
  246. return false;
  247. }
  248. //if (!lpEntity.QueryWaferMap(out result))
  249. if (SC.GetValue<int>($"LoadPort.{device}.CstType") == 0 && SC.GetValue<bool>($"LoadPort.{device}.ExternalSmartTagReader"))
  250. {
  251. lpEntity.Write(args[1].ToString());
  252. }else
  253. lpEntity.Write(args[1].ToString(), out _);
  254. return true;
  255. }
  256. public bool? Monitor(out string result, params string[] args)
  257. {
  258. result = string.Empty;
  259. string device = Args2Unit(args.Length > 0 ? args[0] : string.Empty);
  260. //OmronRfidReader _device = Singleton<DeviceManager>.Instance.GetRfidReader(device);
  261. LoadPortBaseDevice _device = DEVICE.GetDevice<LoadPortBaseDevice>(device);
  262. if (_device.IsError)
  263. {
  264. flag1 = ErrorCheckList1.VAC | ErrorCheckList1.AIR | ErrorCheckList1.STALL
  265. | ErrorCheckList1.LIMIT | ErrorCheckList1.SENSOR | ErrorCheckList1.POSITION | ErrorCheckList1.EMS
  266. | ErrorCheckList1.COMM | ErrorCheckList1.COMM2 | ErrorCheckList1.VACON | ErrorCheckList1.VACOFF
  267. | ErrorCheckList1.CLAMPON | ErrorCheckList1.CLAMPOF;
  268. flag2 = ErrorCheckList2.RRTWAF | ErrorCheckList2.CRSWAF | ErrorCheckList2.THICKWAF | ErrorCheckList2.THINWAF
  269. | ErrorCheckList2.DBLWAF | ErrorCheckList2.BAOWAF | ErrorCheckList2.COMMAND | ErrorCheckList2.PODNG
  270. | ErrorCheckList2.PODMISMATCH | ErrorCheckList2.VAC_S | ErrorCheckList2.CLAMP_S | ErrorCheckList2.SAFTY
  271. | ErrorCheckList2.LOCKNG | ErrorCheckList2.UNLOCKNG | ErrorCheckList2.L_KEY_LK | ErrorCheckList2.L_KEY_UL;
  272. flag3 = ErrorCheckList3.MAP_S | ErrorCheckList3.MAP_S1 | ErrorCheckList3.MAP_S2 | ErrorCheckList3.WAFLOST
  273. | ErrorCheckList3.ALIGNNG
  274. | ErrorCheckList3.DRIVER | ErrorCheckList3.DRPOWERDOWN | ErrorCheckList3.HARDWARE
  275. | ErrorCheckList3.INTERNAL | ErrorCheckList3.E84_TIMEOUTx | ErrorCheckList3.E84_CS_VALID | ErrorCheckList3.READFAIL;
  276. //result = "Write Smartag Timeout";
  277. return CheckError(device, out result);
  278. }
  279. if (!_device.IsBusy)
  280. {
  281. result = null;
  282. // result = $"{_device.CarrierId}";
  283. return true;
  284. }
  285. return null;
  286. }
  287. }
  288. }