FIMSLoadRoutine.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. CheckLoadFinish,
  19. }
  20. private int _timeout;
  21. private FIMSModule _fimsModule;
  22. private PMModule _pmModule;
  23. private bool _isNeedN2Purge;
  24. public FIMSLoadRoutine(FIMSModule fimsModule)
  25. {
  26. Module = fimsModule.Module.ToString();
  27. _fimsModule = fimsModule;
  28. Name = "Load";
  29. _pmModule = Singleton<EquipmentManager>.Instance.Modules[ModuleName.PM1] as PMModule;
  30. }
  31. public Result Init(bool isNeedN2Purge)
  32. {
  33. _isNeedN2Purge = isNeedN2Purge;
  34. return Result.DONE;
  35. }
  36. public Result Start(params object[] objs)
  37. {
  38. Reset();
  39. _timeout = SC.GetValue<int>($"FIMS.{Module}.MotionTimeout");
  40. if (!Singleton<EquipmentManager>.Instance.IsAutoMode && !Singleton<EquipmentManager>.Instance.IsReturnWafer)
  41. {
  42. if (!_fimsModule.SensorWaferRobotEX1AxisHomePosition.Value)
  43. {
  44. _fimsModule.LoadFailAlarm.Set($"wafer robot EX1 axis not at home position");
  45. return Result.FAIL;
  46. }
  47. if (!_fimsModule.SensorWaferRobotEX2AxisHomePosition.Value)
  48. {
  49. _fimsModule.LoadFailAlarm.Set($"wafer robot EX2 axis not at home position");
  50. return Result.FAIL;
  51. }
  52. }
  53. if (_fimsModule.FIMSDevice.IsLoadCompleted)
  54. {
  55. EV.PostInfoLog(Module, $"{Module} already at load position");
  56. _fimsModule.FIMSDevice.IsLoadCompleted = true;
  57. _fimsModule.FIMSDevice.IsUnloadCompleted = false;
  58. return Result.DONE;
  59. }
  60. if (SC.ContainsItem("PM1.N2Purge.FOUPOpenerStableWaitTime"))
  61. {
  62. _timeout = (int)SC.GetValue<double>("PM1.N2Purge.FOUPOpenerStableWaitTime");
  63. }
  64. Notify($"{_fimsModule.Name} {Name} start");
  65. _fimsModule.FIMSDevice.IsLoadCompleted = false;
  66. _fimsModule.FIMSDevice.IsUnloadCompleted = false;
  67. if (_isNeedN2Purge)
  68. {
  69. _pmModule?.SetN2PurgeParameters();
  70. }
  71. _pmModule?.SetN2PurgeProcess(_isNeedN2Purge);
  72. return Result.RUN;
  73. }
  74. public override Result Monitor()
  75. {
  76. try
  77. {
  78. PauseRountine(_fimsModule.FIMSDevice.IsPause);
  79. if (_fimsModule.FIMSDevice.IsPause)
  80. return Result.RUN;
  81. Load((int)RoutineStep.Load, _timeout);
  82. Delay((int)RoutineStep.Delay, 3);
  83. CheckLoadFinish((int)RoutineStep.CheckLoadFinish, _timeout);
  84. }
  85. catch (RoutineBreakException)
  86. {
  87. return Result.RUN;
  88. }
  89. catch (RoutineFaildException)
  90. {
  91. _fimsModule.Stop();
  92. return Result.FAIL;
  93. }
  94. _pmModule?.SetN2PurgeProcess(false);
  95. _fimsModule.FIMSDevice.IsLoadCompleted = true;
  96. _fimsModule.Stop();
  97. Notify($"{_fimsModule.Name} {Name} finished");
  98. return Result.DONE;
  99. }
  100. public void Abort()
  101. {
  102. _fimsModule.Stop();
  103. }
  104. private void Load(int id, int timeout)
  105. {
  106. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  107. {
  108. Notify($"{Module} load");
  109. if (!_fimsModule.FIMSDevice.Load(out string reason))
  110. {
  111. Stop(reason);
  112. return false;
  113. }
  114. return true;
  115. }, () =>
  116. {
  117. return true;
  118. }, timeout * 1000);
  119. if (ret.Item1)
  120. {
  121. if (ret.Item2 == Result.FAIL)
  122. {
  123. throw (new RoutineFaildException());
  124. }
  125. else if (ret.Item2 == Result.TIMEOUT) //timeout
  126. {
  127. _fimsModule.LoadTimeoutAlarm.Set($"can not complete in {timeout} seconds");
  128. throw (new RoutineFaildException());
  129. }
  130. else
  131. throw (new RoutineBreakException());
  132. }
  133. }
  134. private void CheckLoadFinish(int id, int timeout)
  135. {
  136. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  137. {
  138. Notify($"Check {Module} load finish");
  139. return true;
  140. }, () =>
  141. {
  142. if (_fimsModule.FIMSDevice.IsPLCLoadCompleted && !_fimsModule.FIMSDevice.IsRunning)
  143. {
  144. if (_fimsModule.IsWaferOnRobot)
  145. {
  146. _fimsModule.LoadFailAlarm.Set($"The wafer on {Module} has shifted");
  147. _pmModule?.SetN2PurgeProcess(false);
  148. return false;
  149. }
  150. return true;
  151. }
  152. return false;
  153. }, timeout * 1000);
  154. if (ret.Item1)
  155. {
  156. if (ret.Item2 == Result.FAIL)
  157. {
  158. throw (new RoutineFaildException());
  159. }
  160. else if (ret.Item2 == Result.TIMEOUT) //timeout
  161. {
  162. _fimsModule.LoadTimeoutAlarm.Set($"can not complete in {timeout} seconds");
  163. throw (new RoutineFaildException());
  164. }
  165. else
  166. throw (new RoutineBreakException());
  167. }
  168. }
  169. }
  170. }