FIMSLoadRoutine.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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.LoadFailAlarm.Set($"The wafer on {Module} has shifted");
  63. return Result.FAIL;
  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. CheckLoadFinish((int)RoutineStep.CheckLoadFinish, _timeout);
  85. }
  86. catch (RoutineBreakException)
  87. {
  88. return Result.RUN;
  89. }
  90. catch (RoutineFaildException)
  91. {
  92. _fimsModule.Stop();
  93. return Result.FAIL;
  94. }
  95. _pmModule?.SetN2PurgeProcess(false);
  96. _fimsModule.FIMSDevice.IsLoadCompleted = true;
  97. _fimsModule.Stop();
  98. Notify($"{_fimsModule.Name} {Name} finished");
  99. return Result.DONE;
  100. }
  101. public void Abort()
  102. {
  103. _fimsModule.Stop();
  104. }
  105. private void Load(int id, int timeout)
  106. {
  107. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  108. {
  109. Notify($"{Module} load");
  110. if (!_fimsModule.FIMSDevice.Load(out string reason))
  111. {
  112. Stop(reason);
  113. return false;
  114. }
  115. return true;
  116. }, () =>
  117. {
  118. return true;
  119. }, timeout * 1000);
  120. if (ret.Item1)
  121. {
  122. if (ret.Item2 == Result.FAIL)
  123. {
  124. throw (new RoutineFaildException());
  125. }
  126. else if (ret.Item2 == Result.TIMEOUT) //timeout
  127. {
  128. _fimsModule.LoadTimeoutAlarm.Set($"can not complete in {timeout} seconds");
  129. throw (new RoutineFaildException());
  130. }
  131. else
  132. throw (new RoutineBreakException());
  133. }
  134. }
  135. private void CheckLoadFinish(int id, int timeout)
  136. {
  137. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  138. {
  139. Notify($"Check {Module} load finish");
  140. return true;
  141. }, () =>
  142. {
  143. return _fimsModule.FIMSDevice.IsPLCLoadCompleted && !_fimsModule.FIMSDevice.IsRunning;
  144. }, timeout * 1000);
  145. if (ret.Item1)
  146. {
  147. if (ret.Item2 == Result.FAIL)
  148. {
  149. throw (new RoutineFaildException());
  150. }
  151. else if (ret.Item2 == Result.TIMEOUT) //timeout
  152. {
  153. _fimsModule.LoadTimeoutAlarm.Set($"can not complete in {timeout} seconds");
  154. throw (new RoutineFaildException());
  155. }
  156. else
  157. throw (new RoutineBreakException());
  158. }
  159. }
  160. }
  161. }