ErrorTask.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Sorter.Common;
  3. using Efem;
  4. using Efem.Protocol;
  5. using System;
  6. using Aitex.Core.Util;
  7. using EFEM.RT.Modules;
  8. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
  9. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase;
  10. using System.Threading;
  11. using Aitex.Core.RT.Event;
  12. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Aligners.AlignersBase;
  13. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase;
  14. namespace EFEM.RT.Tasks
  15. {
  16. public class ClearErrorTask : CheckImp, ITask
  17. {
  18. public ClearErrorTask()
  19. {
  20. HasInfoMessage = false;
  21. }
  22. public bool Execute(out string result, params string[] args)
  23. {
  24. string device = DeviceName.System;
  25. EfemEventType type;
  26. if (!String.Equals(args[0], "CLEAR"))
  27. {
  28. result = PARAM_NG;
  29. return false;
  30. }
  31. if (!Check<NoReadyPolicy>(device, out result))
  32. {
  33. return false;
  34. }
  35. if (!Check<MaintenancePolicy>(device, out result))
  36. {
  37. return false;
  38. }
  39. if (args.Length == 1)
  40. {
  41. SystemServerModule entity = (SystemServerModule)GetEntity(device);
  42. entity.ClearError();
  43. }
  44. else if (args.Length > 1)
  45. {
  46. device = Args2Unit(args.Length > 0 ? args[1] : string.Empty);
  47. IServerModule entity = GetEntity(device);
  48. if (entity == null || !(entity is SystemServerModule || entity is RobotServerModule || entity is LoadPortServerModule || entity is AlignerServerModule))
  49. {
  50. result = PARAM_NG;
  51. return false;
  52. }
  53. if (!entity.Reset(out result))
  54. {
  55. return false;
  56. }
  57. switch (device)
  58. {
  59. case "Robot":
  60. {
  61. var rbt = DEVICE.GetDevice<RobotBaseDevice>(DeviceName.Robot);
  62. DateTime dt = DateTime.Now;
  63. while (true)
  64. {
  65. Thread.Sleep(1000);
  66. if (DateTime.Now - dt > TimeSpan.FromSeconds(60))
  67. {
  68. EV.PostAlarmLog("System", "Clear error time out than 60s.");
  69. return false;
  70. }
  71. if (rbt.IsBusy)
  72. continue;
  73. break;
  74. }
  75. }
  76. break;
  77. //case "Aligner":
  78. // {
  79. // var alg = DEVICE.GetDevice<AlignerBaseDevice>(DeviceName.Aligner);
  80. // DateTime dt = DateTime.Now;
  81. // while (true)
  82. // {
  83. // Thread.Sleep(1000);
  84. // if (DateTime.Now - dt > TimeSpan.FromSeconds(60))
  85. // {
  86. // EV.PostAlarmLog("System", "Clear error time out than 60s.");
  87. // return false;
  88. // }
  89. // if (alg.IsBusy)
  90. // continue;
  91. // break;
  92. // }
  93. // }
  94. // break;
  95. case "LP1":
  96. case "LP2":
  97. case "LP3":
  98. {
  99. var lp1 = DEVICE.GetDevice<LoadPortBaseDevice>(device);
  100. DateTime dt = DateTime.Now;
  101. while (true)
  102. {
  103. Thread.Sleep(1000);
  104. if (DateTime.Now - dt > TimeSpan.FromSeconds(60))
  105. {
  106. EV.PostAlarmLog("System", "Clear error time out than 60s.");
  107. return false;
  108. }
  109. if (lp1.IsBusy)
  110. continue;
  111. break;
  112. }
  113. }
  114. break;
  115. }
  116. }
  117. return true;
  118. }
  119. public bool? Monitor(out string result, params string[] args)
  120. {
  121. result = string.Empty;
  122. SystemServerModule entity = (SystemServerModule)GetEntity(DeviceName.System);
  123. string device = DeviceName.System;
  124. LoadPortBaseDevice _device = DEVICE.GetDevice<LoadPortBaseDevice>(device);
  125. if (_device!= null && _device.IsError)
  126. {
  127. flag3 = ErrorCheckList3.HARDWARE
  128. | ErrorCheckList3.INTERNAL;
  129. return CheckError(device, out result);
  130. }
  131. if (_device==null || !_device.IsBusy)
  132. return true;
  133. return null;
  134. }
  135. }
  136. public class QueryErrorTask : CheckImp, ITask
  137. {
  138. public QueryErrorTask()
  139. {
  140. }
  141. public bool Execute(out string result, params string[] args)
  142. {
  143. string device = DeviceName.System;
  144. if (!Check<NoReadyPolicy>(device, out result))
  145. {
  146. return false;
  147. }
  148. return true;
  149. }
  150. public bool? Monitor(out string result, params string[] args)
  151. {
  152. result = string.Empty;
  153. SystemServerModule entity = (SystemServerModule)GetEntity(DeviceName.System);
  154. string device = DeviceName.System;
  155. if (Singleton<RouteManager>.Instance.IsError)
  156. {
  157. result = "INTERNAL/UNDEFINITION";
  158. }
  159. return true;
  160. }
  161. }
  162. }