CheckImp.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. using Aitex.Core.Common;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Core.Util;
  4. using Aitex.Sorter.Common;
  5. using athosRT.Devices.EFEM.ABS;
  6. using MECF.Framework.Common.Equipment;
  7. using MECF.Framework.Common.SubstrateTrackings;
  8. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using EV = athosRT.tool.EV;
  15. namespace athosRT.Devices.EFEM.Task
  16. {
  17. public class CheckImp
  18. {
  19. protected ErrorCheckList1 flag1 = 0;
  20. protected ErrorCheckList2 flag2 = 0;
  21. protected ErrorCheckList3 flag3 = 0;
  22. protected int LoadPortQuantity = Singleton<DeviceDefineManager>.Instance.GetValue<int>(nameof(LoadPortQuantity)).GetValueOrDefault();
  23. protected int LoadLockQuantity = Singleton<DeviceDefineManager>.Instance.GetValue<int>(nameof(LoadLockQuantity)).GetValueOrDefault();
  24. protected bool AlignerInstalled = Singleton<DeviceDefineManager>.Instance.GetValue<bool>(nameof(AlignerInstalled)).GetValueOrDefault();
  25. protected bool CoolingBufferInstalled = Singleton<DeviceDefineManager>.Instance.GetValue<bool>(nameof(CoolingBufferInstalled)).GetValueOrDefault();
  26. protected bool RobotIsSingleArm = Singleton<DeviceDefineManager>.Instance.GetValue<bool>(nameof(RobotIsSingleArm)).GetValueOrDefault();
  27. protected bool MultiWaferSize = Singleton<DeviceDefineManager>.Instance.GetValue<bool>(nameof(MultiWaferSize)).GetValueOrDefault();
  28. public const string PARAM_NG = "PARAM_NG";
  29. protected int _token;
  30. public bool HasInfoMessage { get; set; }
  31. public CheckImp() => HasInfoMessage = true;
  32. public bool CheckError(string device, out string reason)
  33. {
  34. //44个policy 额滴神啊
  35. //44个policy 只有3个包含真正的判断的check 其他都是空的 3个分别是EMSPolicy、VacPolicy、AirPolicy
  36. //剩余一些信号可能要加 所以要将IO信号、task等搞清楚 方便修改、添加条件
  37. //if ( flag1.HasFlag(ErrorCheckList1.VAC) && !Check<VacPolicy>(device, out reason)
  38. // || flag1.HasFlag(ErrorCheckList1.AIR) && !Check<AirPolicy>(device, out reason)
  39. // || flag1.HasFlag(ErrorCheckList1.STALL) && !Check<StallPolicy>(device, out reason)
  40. // || flag1.HasFlag(ErrorCheckList1.LIMIT) && !Check<LIMITPolicy>(device, out reason)
  41. // || flag1.HasFlag(ErrorCheckList1.SENSOR) && !Check<SENSORPolicy>(device, out reason)
  42. // || flag1.HasFlag(ErrorCheckList1.POSITION) && !Check<POSITIONPolicy>(device, out reason)
  43. // || flag1.HasFlag(ErrorCheckList1.EMS) && !Check<EMSPolicy>(device, out reason)
  44. // || flag1.HasFlag(ErrorCheckList1.COMM) && !Check<COMMPolicy>(device, out reason)
  45. // || flag1.HasFlag(ErrorCheckList1.COMM2) && !Check<COMM2Policy>(device, out reason)
  46. // || flag1.HasFlag(ErrorCheckList1.VACON) && !Check<VACONPolicy>(device, out reason)
  47. // || flag1.HasFlag(ErrorCheckList1.VACOFF) && !Check<VACOFPolicy>(device, out reason)
  48. // || flag1.HasFlag(ErrorCheckList1.CLAMPON) && !Check<CLAMPONPolicy>(device, out reason)
  49. // || flag1.HasFlag(ErrorCheckList1.CLAMPOF) && !Check<CLAMPOFPolicy>(device, out reason)
  50. // || flag2.HasFlag(ErrorCheckList2.RRTWAF) && !Check<PRTWAFPolicy>(device, out reason)
  51. // || flag2.HasFlag(ErrorCheckList2.CRSWAF) && !Check<CRSWAFPolicy>(device, out reason)
  52. // || flag2.HasFlag(ErrorCheckList2.THICKWAF) && !Check<THICKWAFPolicy>(device, out reason)
  53. // || flag2.HasFlag(ErrorCheckList2.THINWAF) && !Check<THINWAFPolicy>(device, out reason)
  54. // || flag2.HasFlag(ErrorCheckList2.DBLWAF) && !Check<DBLWAFPolicy>(device, out reason)
  55. // || flag2.HasFlag(ErrorCheckList2.BAOWAF) && !Check<BOWWAFPolicy>(device, out reason)
  56. // || flag2.HasFlag(ErrorCheckList2.COMMAND) && !Check<COMMANDPolicy>(device, out reason)
  57. // || flag2.HasFlag(ErrorCheckList2.PODNG) && !Check<PODNGPolicy>(device, out reason)
  58. // || flag2.HasFlag(ErrorCheckList2.PODMISMATCH) && !Check<PODMISMATCHPolicy>(device, out reason)
  59. // || flag2.HasFlag(ErrorCheckList2.VAC_S) && !Check<VAC_SPolicy>(device, out reason)
  60. // || flag2.HasFlag(ErrorCheckList2.CLAMP_S) && !Check<CLAMP_SPolicy>(device, out reason)
  61. // || flag2.HasFlag(ErrorCheckList2.SAFTY) && !Check<SAFTYPolicy>(device, out reason)
  62. // || flag2.HasFlag(ErrorCheckList2.LOCKNG) && !Check<LOCKNGPolicy>(device, out reason)
  63. // || flag2.HasFlag(ErrorCheckList2.UNLOCKNG) && !Check<UNLOCKNGPolicy>(device, out reason)
  64. // || flag2.HasFlag(ErrorCheckList2.L_KEY_LK) && !Check<L_KEY_LKPolicy>(device, out reason)
  65. // || flag2.HasFlag(ErrorCheckList2.L_KEY_UL) && !Check<L_KEY_ULPolicy>(device, out reason)
  66. // || flag3.HasFlag(ErrorCheckList3.MAP_S) && !Check<MAP_SPolicy>(device, out reason)
  67. // || flag3.HasFlag(ErrorCheckList3.MAP_S1) && !Check<MAP_S1Policy>(device, out reason)
  68. // || flag3.HasFlag(ErrorCheckList3.MAP_S2) && !Check<MAP_S2Policy>(device, out reason)
  69. // || flag3.HasFlag(ErrorCheckList3.WAFLOST) && !Check<WAFLOSTPolicy>(device, out reason)
  70. // || flag3.HasFlag(ErrorCheckList3.ALIGNNG) && !Check<ALIGNNGPolicy>(device, out reason)
  71. // || flag3.HasFlag(ErrorCheckList3.PODNG) && !Check<PODNGPolicy>(device, out reason)
  72. // || flag3.HasFlag(ErrorCheckList3.PODMISMATCH) && !Check<PODMISMATCHPolicy>(device, out reason)
  73. // || flag3.HasFlag(ErrorCheckList3.VAC_S) && !Check<VAC_SPolicy>(device, out reason)
  74. // || flag3.HasFlag(ErrorCheckList3.CLAMP_S) && !Check<CLAMP_SPolicy>(device, out reason)
  75. // || flag3.HasFlag(ErrorCheckList3.DRIVER) && !Check<DRIVERPolicy>(device, out reason)
  76. // || flag3.HasFlag(ErrorCheckList3.DRPOWERDOWN) && !Check<DRPOWERDOWNPolicy>(device, out reason)
  77. // || flag3.HasFlag(ErrorCheckList3.HARDWARE) && !Check<HARDWAREPolicy>(device, out reason)
  78. // || flag3.HasFlag(ErrorCheckList3.INTERNAL) && !Check<INTERNALPolicy>(device, out reason)
  79. // || flag3.HasFlag(ErrorCheckList3.E84_TIMEOUTx) && !Check<E84_TIMEOUTxPolicy>(device, out reason)
  80. // || flag3.HasFlag(ErrorCheckList3.E84_CS_VALID) && !Check<E84_CS_VALIDPolicy>(device, out reason)
  81. // || flag3.HasFlag(ErrorCheckList3.READFAIL) && !Check<READFAILPolicy>(device, out reason))
  82. if (flag1.HasFlag(ErrorCheckList1.VAC) && !Check<VacPolicy>(device, out reason)
  83. || flag1.HasFlag(ErrorCheckList1.AIR) && !Check<AirPolicy>(device, out reason)
  84. || flag1.HasFlag(ErrorCheckList1.EMS) && !Check<EMSPolicy>(device, out reason)
  85. )
  86. return false;
  87. reason = "UNDEFINITION";
  88. return true;
  89. }
  90. public bool Check<T>(string device, out string reason) where T : class, IPolicy, new()
  91. {
  92. reason = string.Empty;
  93. return Singleton<T>.Instance.Check(device, out reason);
  94. }
  95. //用来判断传入的字符串 符合开头/结尾/包含中间参数的情况
  96. protected string Args2Unit(string args)
  97. {
  98. string str = string.Empty;
  99. if (string.IsNullOrEmpty(args) || args.StartsWith("ALL") || args.StartsWith("SYSTEM"))
  100. str = "System";
  101. else if (args.StartsWith("ROB"))
  102. str = "Robot";
  103. else if (args.StartsWith("ALIGN"))
  104. {
  105. if (AlignerInstalled)
  106. str = "Aligner";
  107. else if (CoolingBufferInstalled)
  108. {
  109. if (args.EndsWith("ALIGN1") || args.EndsWith("ALIGN"))
  110. str = "CoolingBuffer1";
  111. else if (args.EndsWith("ALIGN2"))
  112. str = "CoolingBuffer2";
  113. else if (args.EndsWith("ALIGN3"))
  114. str = "Aligner1";
  115. else if (args.EndsWith("ALIGN4"))
  116. str = "Aligner2";
  117. }
  118. }
  119. else if (args.Equals("P1") && LoadPortQuantity > 0)
  120. str = "LP1";
  121. else if (args.Equals("P2") && LoadPortQuantity > 1)
  122. str = "LP2";
  123. else if (args.Equals("P3") && LoadPortQuantity > 2)
  124. str = "LP3";
  125. else if (args.Equals("P4") && LoadPortQuantity > 3)
  126. str = "LP4";
  127. else if (args.Equals("P5") && LoadPortQuantity > 4)
  128. str = "LP5";
  129. else if (args.Equals("P6") && LoadPortQuantity > 5)
  130. str = "LP6";
  131. else if (args.Equals("P7") && LoadPortQuantity > 6)
  132. str = "LP7";
  133. else if (args.Equals("P8") && LoadPortQuantity > 7)
  134. str = "LP8";
  135. else if (args.Equals("P9") && LoadPortQuantity > 8)
  136. str = "LP9";
  137. else if (args.Equals("P10") && LoadPortQuantity > 9)
  138. str = "LP10";
  139. else if ((args.Equals("LLA") || args.StartsWith("LLLA")) && LoadLockQuantity > 0)
  140. str = "LoadlockA";
  141. else if ((args.Equals("LLB") || args.StartsWith("LLLB")) && LoadLockQuantity > 1)
  142. str = "LoadlockB";
  143. else if (args.Equals("LLC") && LoadLockQuantity > 2)
  144. str = "LoadlockC";
  145. else if (args.Equals("LLD") && LoadLockQuantity > 3)
  146. str = "LoadlockD";
  147. else if (args.Equals("STOWER"))
  148. str = "SignalTower";
  149. return str;
  150. }
  151. //与上差不多 但会将modulename通过外部变量target传回去
  152. protected bool ParseMoveTarget(string args, out ModuleName target, out int slot)
  153. {
  154. target = ModuleName.System;
  155. slot = 1;
  156. if (args.StartsWith("ALIGN"))
  157. {
  158. if (AlignerInstalled)
  159. {
  160. target = ModuleName.Aligner;
  161. slot = 1;
  162. }
  163. else if (CoolingBufferInstalled)
  164. {
  165. if (args.EndsWith("ALIGN1") || args.EndsWith("ALIGN"))
  166. {
  167. target = ModuleName.CoolingBuffer1;
  168. slot = 1;
  169. }
  170. else if (args.EndsWith("ALIGN2"))
  171. {
  172. target = ModuleName.CoolingBuffer2;
  173. slot = 1;
  174. }
  175. else if (args.EndsWith("ALIGN3"))
  176. {
  177. target = ModuleName.Aligner1;
  178. slot = 1;
  179. }
  180. else if (args.EndsWith("ALIGN4"))
  181. {
  182. target = ModuleName.Aligner2;
  183. slot = 1;
  184. }
  185. }
  186. return true;
  187. }
  188. if (args.StartsWith("P1") && LoadPortQuantity > 0)
  189. {
  190. target = ModuleName.LP1;
  191. if (int.TryParse(args.Replace("P1", ""), out slot))
  192. return true;
  193. }
  194. else if (args.StartsWith("P2") && LoadPortQuantity > 1)
  195. {
  196. target = ModuleName.LP2;
  197. if (int.TryParse(args.Replace("P2", ""), out slot))
  198. return true;
  199. }
  200. else if (args.StartsWith("P3") && LoadPortQuantity > 2)
  201. {
  202. target = ModuleName.LP3;
  203. if (int.TryParse(args.Replace("P3", ""), out slot))
  204. return true;
  205. }
  206. else if (args.StartsWith("P4") && LoadPortQuantity > 3)
  207. {
  208. target = ModuleName.LP4;
  209. if (int.TryParse(args.Replace("P4", ""), out slot))
  210. return true;
  211. }
  212. if (args.StartsWith("BUFFER"))
  213. {
  214. target = ModuleName.Buffer;
  215. if (int.TryParse(args.Replace("BUFFER", ""), out slot))
  216. return true;
  217. }
  218. else if (args.StartsWith("LLLA") || args.StartsWith("LLA"))
  219. {
  220. target = ModuleName.LL1;
  221. string s = args.Replace("LLLA", "").Replace("LLA", "");
  222. if (string.IsNullOrEmpty(s))
  223. {
  224. slot = 1;
  225. return true;
  226. }
  227. if (int.TryParse(s, out slot))
  228. return true;
  229. }
  230. else if (args.StartsWith("LLLB") || args.StartsWith("LLB"))
  231. {
  232. target = ModuleName.LL2;
  233. string s = args.Replace("LLLB", "").Replace("LLB", "");
  234. if (string.IsNullOrEmpty(s))
  235. {
  236. slot = 1;
  237. return true;
  238. }
  239. if (int.TryParse(s, out slot))
  240. return true;
  241. }
  242. return false;
  243. }
  244. //与上是差不多 但目标是输出Robot的arm
  245. protected bool ParseMoveArm(string args, out Hand arm)
  246. {
  247. arm = Hand.Blade2;
  248. string str = args;
  249. if (!(str == "ARM1"))
  250. {
  251. if (!(str == "ARM2"))
  252. {
  253. if (!(str == "ARM3"))
  254. return false;
  255. arm = Hand.Both;
  256. }
  257. else
  258. arm = Hand.Blade1;
  259. }
  260. else
  261. arm = Hand.Blade2;
  262. return !RobotIsSingleArm || arm == 0;
  263. }
  264. protected bool CheckWaferSize(string waferSize, ModuleName target, int slot)
  265. {
  266. WaferSize result;
  267. if (!Enum.TryParse<WaferSize>(waferSize, out result))
  268. {
  269. EV.PostWarningLog("EFEM", waferSize + " is not a valid size type");
  270. return false;
  271. }
  272. if (ModuleHelper.IsLoadPort(target))
  273. {
  274. OpenStageWithWaferSizeLoadPort device = DEVICE.GetDevice<OpenStageWithWaferSizeLoadPort>(target.ToString());
  275. if (device.CassetteState == LoadportCassetteState.Normal && device.WaferSize != result)
  276. {
  277. EV.PostWarningLog("EFEM", string.Format("{0} is not match target {1}", (object)device.WaferSize, (object)result));
  278. return false;
  279. }
  280. }
  281. else if (Singleton<WaferManager>.Instance.CheckHasWafer(target, slot) && Singleton<WaferManager>.Instance.GetWaferSize(target, slot) != result)
  282. {
  283. EV.PostWarningLog("EFEM", string.Format("{0} is not match target {1}", (object)Singleton<WaferManager>.Instance.GetWaferSize(target, slot), (object)result));
  284. return false;
  285. }
  286. return true;
  287. }
  288. protected bool CheckIsPort(string device) => device == "LP1" || device == "LP2" || device == "LP3" || device == "LP4";
  289. protected bool CheckIsTower(string device) => device == "SignalTower";
  290. //获取实例化的Entity
  291. protected IServerModule GetEntity(string name)
  292. {
  293. IServerModule entity = Singleton<EntityFactory>.Instance.GetEntity(name);
  294. return entity.Name == "Aligner" && !AlignerInstalled ? null : entity;
  295. }
  296. }
  297. }