FIMSLoadRoutine.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. using Aitex.Core.RT.Event;
  2. using Aitex.Core.RT.Routine;
  3. using Aitex.Core.RT.SCCore;
  4. using Aitex.Core.Util;
  5. using FurnaceRT.Equipments.PMs;
  6. using FurnaceRT.Equipments.Systems;
  7. using MECF.Framework.Common.Equipment;
  8. using MECF.Framework.Common.SubstrateTrackings;
  9. using System;
  10. namespace FurnaceRT.Equipments.FIMSs
  11. {
  12. public class FIMSLoadRoutine : ModuleRoutine, IRoutine
  13. {
  14. enum RoutineStep
  15. {
  16. Load,
  17. Delay,
  18. CheckWaferShifted,
  19. CheckLoadFinish,
  20. }
  21. private int _timeout;
  22. private FIMSModule _fimsModule;
  23. private PMModule _pmModule;
  24. private bool _isNeedN2Purge;
  25. public FIMSLoadRoutine(FIMSModule fimsModule)
  26. {
  27. Module = fimsModule.Module.ToString();
  28. _fimsModule = fimsModule;
  29. Name = "Load";
  30. _pmModule = Singleton<EquipmentManager>.Instance.Modules[ModuleName.PM1] as PMModule;
  31. }
  32. public Result Init(bool isNeedN2Purge)
  33. {
  34. _isNeedN2Purge = isNeedN2Purge;
  35. return Result.DONE;
  36. }
  37. public Result Start(params object[] objs)
  38. {
  39. Reset();
  40. _timeout = SC.GetValue<int>($"FIMS.{Module}.MotionTimeout");
  41. if (!Singleton<EquipmentManager>.Instance.IsAutoMode && !Singleton<EquipmentManager>.Instance.IsReturnWafer)
  42. {
  43. if (!_fimsModule.SensorWaferRobotEX1AxisHomePosition.Value)
  44. {
  45. _fimsModule.LoadFailAlarm.Set($"wafer robot EX1 axis not at home position");
  46. return Result.FAIL;
  47. }
  48. if (!_fimsModule.SensorWaferRobotEX2AxisHomePosition.Value)
  49. {
  50. _fimsModule.LoadFailAlarm.Set($"wafer robot EX2 axis not at home position");
  51. return Result.FAIL;
  52. }
  53. }
  54. if (_fimsModule.FIMSDevice.IsLoadCompleted)
  55. {
  56. EV.PostInfoLog(Module, $"{Module} already at load position");
  57. _fimsModule.FIMSDevice.IsLoadCompleted = true;
  58. _fimsModule.FIMSDevice.IsUnloadCompleted = false;
  59. return Result.DONE;
  60. }
  61. if (SC.ContainsItem("PM1.N2Purge.FOUPOpenerStableWaitTime"))
  62. {
  63. _timeout = (int)SC.GetValue<double>("PM1.N2Purge.FOUPOpenerStableWaitTime");
  64. }
  65. Notify($"{_fimsModule.Name} {Name} start");
  66. _fimsModule.FIMSDevice.IsLoadCompleted = false;
  67. _fimsModule.FIMSDevice.IsUnloadCompleted = false;
  68. if (_isNeedN2Purge)
  69. {
  70. _pmModule?.SetN2PurgeParameters();
  71. _pmModule?.SetN2PurgeProcess(_isNeedN2Purge);
  72. }
  73. return Result.RUN;
  74. }
  75. public override Result Monitor()
  76. {
  77. try
  78. {
  79. PauseRountine(_fimsModule.FIMSDevice.IsPause);
  80. if (_fimsModule.FIMSDevice.IsPause)
  81. return Result.RUN;
  82. Load((int)RoutineStep.Load, _timeout);
  83. Delay((int)RoutineStep.Delay, 3);
  84. CheckWaferShifted((int)RoutineStep.CheckWaferShifted, _timeout);
  85. CheckLoadFinish((int)RoutineStep.CheckLoadFinish, _timeout);
  86. }
  87. catch (RoutineBreakException)
  88. {
  89. return Result.RUN;
  90. }
  91. catch (RoutineFaildException)
  92. {
  93. _fimsModule.Stop();
  94. return Result.FAIL;
  95. }
  96. _pmModule?.SetN2PurgeProcess(false);
  97. _fimsModule.FIMSDevice.IsLoadCompleted = true;
  98. _fimsModule.Stop();
  99. Notify($"{_fimsModule.Name} {Name} finished");
  100. return Result.DONE;
  101. }
  102. public void Abort()
  103. {
  104. _fimsModule.Stop();
  105. }
  106. private void Load(int id, int timeout)
  107. {
  108. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  109. {
  110. Notify($"{Module} load");
  111. if (!_fimsModule.FIMSDevice.Load(out string reason))
  112. {
  113. Stop(reason);
  114. return false;
  115. }
  116. return true;
  117. }, () =>
  118. {
  119. return true;
  120. }, timeout * 1000);
  121. if (ret.Item1)
  122. {
  123. if (ret.Item2 == Result.FAIL)
  124. {
  125. throw (new RoutineFaildException());
  126. }
  127. else if (ret.Item2 == Result.TIMEOUT) //timeout
  128. {
  129. _fimsModule.LoadTimeoutAlarm.Set($"can not complete in {timeout} seconds");
  130. throw (new RoutineFaildException());
  131. }
  132. else
  133. throw (new RoutineBreakException());
  134. }
  135. }
  136. private void CheckWaferShifted(int id, int timeout)
  137. {
  138. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  139. {
  140. Notify($"Check {Module} Wafer Shifted");
  141. return true;
  142. }, () =>
  143. {
  144. if (_fimsModule.FIMSDevice.IsPLCLoadCompleted && !_fimsModule.FIMSDevice.IsRunning && _fimsModule.IsWaferOnRobot)
  145. {
  146. _fimsModule.LoadFailAlarm.Set($"The wafer on {Module} has shifted");
  147. return false;
  148. }
  149. return true;
  150. }, timeout * 1000);
  151. if (ret.Item1)
  152. {
  153. if (ret.Item2 == Result.FAIL)
  154. {
  155. throw (new RoutineFaildException());
  156. }
  157. else if (ret.Item2 == Result.TIMEOUT) //timeout
  158. {
  159. _fimsModule.LoadTimeoutAlarm.Set($"can not complete in {timeout} seconds");
  160. throw (new RoutineFaildException());
  161. }
  162. else
  163. throw (new RoutineBreakException());
  164. }
  165. }
  166. private void CheckLoadFinish(int id, int timeout)
  167. {
  168. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  169. {
  170. Notify($"Check {Module} load finish");
  171. return true;
  172. }, () =>
  173. {
  174. return _fimsModule.FIMSDevice.IsPLCLoadCompleted && !_fimsModule.FIMSDevice.IsRunning;
  175. }, timeout * 1000);
  176. if (ret.Item1)
  177. {
  178. if (ret.Item2 == Result.FAIL)
  179. {
  180. throw (new RoutineFaildException());
  181. }
  182. else if (ret.Item2 == Result.TIMEOUT) //timeout
  183. {
  184. _fimsModule.LoadTimeoutAlarm.Set($"can not complete in {timeout} seconds");
  185. throw (new RoutineFaildException());
  186. }
  187. else
  188. throw (new RoutineBreakException());
  189. }
  190. }
  191. }
  192. }