MFHomeRoutine.cs 4.9 KB

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