MFHomeRoutine.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. using Aitex.Core.RT.Routine;
  2. using Aitex.Core.RT.SCCore;
  3. using Venus_RT.Devices;
  4. using MECF.Framework.Common.Routine;
  5. using MECF.Framework.Common.Equipment;
  6. using Venus_Core;
  7. using Aitex.Core.RT.Log;
  8. using Venus_RT.Modules.PMs;
  9. namespace Venus_RT.Modules.TM
  10. {
  11. class MFHomeRoutine : ModuleRoutineBase, IRoutine
  12. {
  13. private enum HomeStep
  14. {
  15. kHoming,
  16. kRobot,
  17. kSlitDoor,
  18. kPump,
  19. kATMSwitch,
  20. kEnd,
  21. }
  22. private int _robotHomingTimeout = 120*1000;
  23. private int _slitDoorHomingTimeout = 20 * 1000;
  24. private int _pumpHomingTimeout = 120 * 1000;
  25. private int _pumpDownHomingTimeout = 600 * 1000;
  26. private readonly JetTM _JetTM;
  27. private readonly ITransferRobot _robot;
  28. private readonly MFPumpRoutine _pumpDownRoutine;
  29. public int currentStepNo;
  30. public MFHomeRoutine(JetTM jetTM, ITransferRobot robot, MFPumpRoutine pumpDownRoutine) : base(ModuleName.TM)
  31. {
  32. _JetTM = jetTM;
  33. _robot = robot;
  34. _pumpDownRoutine= pumpDownRoutine;
  35. Name = "TM Home";
  36. }
  37. public RState Start(params object[] objs)
  38. {
  39. currentStepNo = 0;
  40. if (!_JetTM.CheckLidClosed(Module))
  41. {
  42. Stop($"TM Lid Not Closed");
  43. return RState.Failed;
  44. }
  45. Reset();
  46. _robotHomingTimeout = SC.GetValue<int>($"{Module}.HomeTimeout") * 1000;
  47. return Runner.Start(Module, Name);
  48. }
  49. public RState Monitor()
  50. {
  51. Runner.Run((int)HomeStep.kRobot, HomeRobot, CheckRobotReady, _robotHomingTimeout)
  52. .Run((int)HomeStep.kSlitDoor, HomeSlitDoor, CheckSlitDoorReady, _slitDoorHomingTimeout)
  53. .Run((int)HomeStep.kPump, HomePump, CheckPumpReady, _pumpHomingTimeout)
  54. .Run((int)HomeStep.kATMSwitch, HomePumpDown, CheckATMSwitchReady, _pumpDownHomingTimeout)
  55. .End((int)HomeStep.kEnd, NullFun, _delay_50ms);
  56. return Runner.Status;
  57. }
  58. private bool HomeRobot()
  59. {
  60. currentStepNo = 1;
  61. if (_robot.Status == RState.End)
  62. {
  63. return true;
  64. }
  65. return _robot.Home();
  66. }
  67. private bool CheckRobotReady()
  68. {
  69. return _robot.Status == RState.End;
  70. }
  71. private bool HomeSlitDoor()
  72. {
  73. currentStepNo = 2;
  74. return _JetTM.CloseAllSlitDoor();
  75. }
  76. private bool CheckSlitDoorReady()
  77. {
  78. if (_JetTM.AllPMSlitDoorClosed && _JetTM.IsLLASlitDoorClosed && _JetTM.IsLLBSlitDoorClosed)
  79. {
  80. return true;
  81. }
  82. else
  83. {
  84. return false;
  85. }
  86. }
  87. private bool HomePump()
  88. {
  89. currentStepNo = 3;
  90. if ((bool)_JetTM.TMPumpIsRunning)
  91. {
  92. return true;
  93. }
  94. return _JetTM.TurnTMPump(true);
  95. }
  96. private bool CheckPumpReady()
  97. {
  98. if ((bool)_JetTM.TMPumpIsRunning)
  99. {
  100. return true;
  101. }
  102. else
  103. {
  104. return false;
  105. }
  106. }
  107. private bool HomePumpDown()
  108. {
  109. currentStepNo = 4;
  110. return _pumpDownRoutine.Start() == RState.Running;
  111. }
  112. private bool CheckATMSwitchReady()
  113. {
  114. if (_JetTM.IsTMVac)
  115. {
  116. _JetTM.TurnSoftPumpValve(ModuleName.TM, false);
  117. _JetTM.TurnFastPumpValve(ModuleName.TM, false);
  118. return true;
  119. }
  120. else
  121. {
  122. _pumpDownRoutine.Monitor();
  123. return false;
  124. }
  125. }
  126. public void Abort()
  127. {
  128. }
  129. }
  130. }