FIMSLoadRoutine.cs 6.1 KB

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