FIMSLoadRoutine.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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 (_isNeedN2Purge)
  69. _pmModule?.SetN2PurgeParameters();
  70. _pmModule?.SetN2PurgeFIMS1O2CheckEnable(ModuleHelper.Converter(Module), _isNeedN2Purge);
  71. return Result.RUN;
  72. }
  73. public override Result Monitor()
  74. {
  75. try
  76. {
  77. PauseRountine(_fimsModule.FIMSDevice.IsPause);
  78. if (_fimsModule.FIMSDevice.IsPause)
  79. return Result.RUN;
  80. Load((int)RoutineStep.Load, _timeout);
  81. Delay((int)RoutineStep.Delay, 3);
  82. CheckLoadFinish((int)RoutineStep.CheckLoadFinish, _timeout);
  83. }
  84. catch (RoutineBreakException)
  85. {
  86. return Result.RUN;
  87. }
  88. catch (RoutineFaildException)
  89. {
  90. _pmModule?.SetN2PurgeFIMS1O2CheckEnable(ModuleHelper.Converter(Module), false);
  91. _fimsModule.Stop();
  92. return Result.FAIL;
  93. }
  94. _pmModule?.SetN2PurgeFIMS1O2CheckEnable(ModuleHelper.Converter(Module), 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. return _fimsModule.FIMSDevice.IsPLCLoadCompleted && !_fimsModule.FIMSDevice.IsRunning;
  143. }, timeout * 1000);
  144. if (ret.Item1)
  145. {
  146. if (ret.Item2 == Result.FAIL)
  147. {
  148. throw (new RoutineFaildException());
  149. }
  150. else if (ret.Item2 == Result.TIMEOUT) //timeout
  151. {
  152. _fimsModule.LoadTimeoutAlarm.Set($"can not complete in {timeout} seconds");
  153. throw (new RoutineFaildException());
  154. }
  155. else
  156. throw (new RoutineBreakException());
  157. }
  158. }
  159. }
  160. }