PufPlaceVacuumCheckRoutine.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Routine;
  3. using Aitex.Core.RT.SCCore;
  4. using MECF.Framework.Common.Routine;
  5. using CyberX8_Core;
  6. using CyberX8_RT.Devices.AXIS;
  7. using CyberX8_RT.Devices.PUF;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using MECF.Framework.Common.Utilities;
  14. namespace CyberX8_RT.Modules.PUF
  15. {
  16. public class PufPlaceVacuumCheckRoutine : RoutineBase, IRoutine
  17. {
  18. private enum PlaceVacuumStep
  19. {
  20. ChuckOut,
  21. CheckChuckOut,
  22. VacuumOff,
  23. VacuumDelay,
  24. ChuckIn,
  25. CheckChuckIn,
  26. VacuumOn,
  27. Delay,
  28. VacuumCheck,
  29. End
  30. }
  31. #region 常量
  32. private const string SideA = "SideA";
  33. private const string SideB = "SideB";
  34. private const string WAFER_ABSENT = "WaferAbsent";
  35. #endregion
  36. #region 内部变量
  37. private PufVacuum _vacuum;
  38. private PufChuckRoutine _chuckRoutine;
  39. private string _side = "SideA";
  40. /// <summary>
  41. /// 是否显示Routine错误
  42. /// </summary>
  43. private bool _showError = true;
  44. /// <summary>
  45. /// 第几次
  46. /// </summary>
  47. private int _times=1;
  48. /// <summary>
  49. /// 延迟时间
  50. /// </summary>
  51. private int _chuckValveSwitchingTimeDelayInMilliSeconds = 100;
  52. /// <summary>
  53. /// 是否处于模拟器
  54. /// </summary>
  55. private bool _isSimulator = false;
  56. #endregion
  57. /// <summary>
  58. /// 构造函数
  59. /// </summary>
  60. /// <param name="module"></param>
  61. public PufPlaceVacuumCheckRoutine(string module) : base(module)
  62. {
  63. _isSimulator = SC.GetValue<bool>("System.IsSimulatorMode");
  64. _chuckRoutine = new PufChuckRoutine(module);
  65. }
  66. /// <summary>
  67. /// 中止
  68. /// </summary>
  69. public void Abort()
  70. {
  71. Runner.Stop("Manual abort");
  72. }
  73. /// <summary>
  74. /// 监控
  75. /// </summary>
  76. /// <returns></returns>
  77. public RState Monitor()
  78. {
  79. Runner.Run(PlaceVacuumStep.ChuckOut, () => { return _chuckRoutine.Start(true) == RState.Running; }, NullFun, 100)
  80. .WaitWithStopCondition(PlaceVacuumStep.CheckChuckOut, () => CommonFunction.CheckRoutineEndState(_chuckRoutine), () => CommonFunction.CheckRoutineStopState(_chuckRoutine))
  81. .Run(PlaceVacuumStep.VacuumOff, VacuumOff, _delay_1ms)
  82. .Delay(PlaceVacuumStep.VacuumDelay,500)
  83. .Run(PlaceVacuumStep.ChuckIn, () => { return _chuckRoutine.Start(false) == RState.Running; }, NullFun, 100)
  84. .WaitWithStopCondition(PlaceVacuumStep.CheckChuckIn, () => CommonFunction.CheckRoutineEndState(_chuckRoutine), () => CommonFunction.CheckRoutineStopState(_chuckRoutine))
  85. .Run(PlaceVacuumStep.VacuumOn, VacuumOn, _delay_1ms)
  86. .Delay(PlaceVacuumStep.Delay, _chuckValveSwitchingTimeDelayInMilliSeconds)
  87. .Run(PlaceVacuumStep.VacuumCheck, CheckWaferPresent,NullFun, _delay_1ms,_showError)
  88. .End(PlaceVacuumStep.End, NullFun, _delay_1ms);
  89. return Runner.Status;
  90. }
  91. /// <summary>
  92. /// 关闭Vacuum
  93. /// </summary>
  94. /// <returns></returns>
  95. private bool VacuumOff()
  96. {
  97. if (_side == SideA)
  98. {
  99. return _vacuum.VacuumAOff();
  100. }
  101. else if (_side == SideB)
  102. {
  103. return _vacuum.VacuumBOff();
  104. }
  105. return false;
  106. }
  107. /// <summary>
  108. /// 打开Vacuum
  109. /// </summary>
  110. /// <returns></returns>
  111. private bool VacuumOn()
  112. {
  113. if (_side == SideA)
  114. {
  115. return _vacuum.VacuumAOn();
  116. }
  117. else if (_side == SideB)
  118. {
  119. return _vacuum.VacuumBOn();
  120. }
  121. return false;
  122. }
  123. /// <summary>
  124. /// 检验存在Wafer
  125. /// </summary>
  126. /// <returns></returns>
  127. private bool CheckWaferPresent()
  128. {
  129. if(_isSimulator)
  130. {
  131. return true;
  132. }
  133. if (_side == SideA)
  134. {
  135. return _vacuum.ChuckAVacuumStatus == WAFER_ABSENT;
  136. }
  137. else if (_side == SideB)
  138. {
  139. return _vacuum.ChuckBVacuumStatus == WAFER_ABSENT;
  140. }
  141. else
  142. {
  143. return false;
  144. }
  145. }
  146. /// <summary>
  147. /// 启动
  148. /// </summary>
  149. /// <param name="objs"></param>
  150. /// <returns></returns>
  151. public RState Start(params object[] objs)
  152. {
  153. _side = objs[0].ToString();
  154. _showError = objs.Length > 1 ? (bool)objs[1] : true;
  155. _times = objs.Length > 2 ? (int)objs[2] : 1;
  156. _vacuum = DEVICE.GetDevice<PufVacuum>($"{Module}.Vacuum");
  157. _chuckValveSwitchingTimeDelayInMilliSeconds = SC.GetValue<int>($"{Module}.ChuckValveSwitchingTimeDelayInMilliSeconds");
  158. return Runner.Start(Module, $"Start {_times} Place Vacuum Check");
  159. }
  160. }
  161. }