FIMSLoadRoutine.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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. Notify($"{_fimsModule.Name} {Name} start");
  62. _fimsModule.FIMSDevice.IsLoadCompleted = false;
  63. _fimsModule.FIMSDevice.IsUnloadCompleted = false;
  64. if (_isNeedN2Purge)
  65. {
  66. _pmModule?.SetN2PurgeParameters();
  67. _pmModule?.SetN2PurgeProcess(_isNeedN2Purge);
  68. }
  69. return Result.RUN;
  70. }
  71. public override Result Monitor()
  72. {
  73. try
  74. {
  75. PauseRountine(_fimsModule.FIMSDevice.IsPause);
  76. if (_fimsModule.FIMSDevice.IsPause)
  77. return Result.RUN;
  78. Load((int)RoutineStep.Load, _timeout);
  79. Delay((int)RoutineStep.Delay, 3);
  80. CheckWaferShifted((int)RoutineStep.CheckWaferShifted, _timeout);
  81. CheckLoadFinish((int)RoutineStep.CheckLoadFinish, _timeout);
  82. }
  83. catch (RoutineBreakException)
  84. {
  85. return Result.RUN;
  86. }
  87. catch (RoutineFaildException)
  88. {
  89. _fimsModule.Stop();
  90. return Result.FAIL;
  91. }
  92. _pmModule?.SetN2PurgeProcess(false);
  93. _fimsModule.FIMSDevice.IsLoadCompleted = true;
  94. _fimsModule.Stop();
  95. Notify($"{_fimsModule.Name} {Name} finished");
  96. return Result.DONE;
  97. }
  98. public void Abort()
  99. {
  100. _fimsModule.Stop();
  101. }
  102. private void Load(int id, int timeout)
  103. {
  104. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  105. {
  106. Notify($"{Module} load");
  107. if (!_fimsModule.FIMSDevice.Load(out string reason))
  108. {
  109. Stop(reason);
  110. return false;
  111. }
  112. return true;
  113. }, () =>
  114. {
  115. return true;
  116. }, timeout * 1000);
  117. if (ret.Item1)
  118. {
  119. if (ret.Item2 == Result.FAIL)
  120. {
  121. throw (new RoutineFaildException());
  122. }
  123. else if (ret.Item2 == Result.TIMEOUT) //timeout
  124. {
  125. _fimsModule.LoadTimeoutAlarm.Set($"can not complete in {timeout} seconds");
  126. throw (new RoutineFaildException());
  127. }
  128. else
  129. throw (new RoutineBreakException());
  130. }
  131. }
  132. private void CheckWaferShifted(int id, int timeout)
  133. {
  134. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  135. {
  136. Notify($"Check {Module} Wafer Shifted");
  137. return true;
  138. }, () =>
  139. {
  140. if (_fimsModule.IsWaferOnRobot)
  141. {
  142. _fimsModule.LoadFailAlarm.Set($"The wafer on {Module} has shifted");
  143. return false;
  144. }
  145. return true;
  146. }, timeout * 1000);
  147. if (ret.Item1)
  148. {
  149. if (ret.Item2 == Result.FAIL)
  150. {
  151. throw (new RoutineFaildException());
  152. }
  153. else if (ret.Item2 == Result.TIMEOUT) //timeout
  154. {
  155. _fimsModule.LoadTimeoutAlarm.Set($"can not complete in {timeout} seconds");
  156. throw (new RoutineFaildException());
  157. }
  158. else
  159. throw (new RoutineBreakException());
  160. }
  161. }
  162. private void CheckLoadFinish(int id, int timeout)
  163. {
  164. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  165. {
  166. Notify($"Check {Module} load finish");
  167. return true;
  168. }, () =>
  169. {
  170. return _fimsModule.FIMSDevice.IsPLCLoadCompleted && !_fimsModule.FIMSDevice.IsRunning;
  171. }, timeout * 1000);
  172. if (ret.Item1)
  173. {
  174. if (ret.Item2 == Result.FAIL)
  175. {
  176. throw (new RoutineFaildException());
  177. }
  178. else if (ret.Item2 == Result.TIMEOUT) //timeout
  179. {
  180. _fimsModule.LoadTimeoutAlarm.Set($"can not complete in {timeout} seconds");
  181. throw (new RoutineFaildException());
  182. }
  183. else
  184. throw (new RoutineBreakException());
  185. }
  186. }
  187. }
  188. }