CompactEmbranceInitializeRoutine.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.RT.Routine;
  4. using Aitex.Core.RT.SCCore;
  5. using CyberX8_Core;
  6. using CyberX8_RT.Devices.Metal;
  7. using CyberX8_RT.Devices.Reservoir;
  8. using MECF.Framework.Common.Persistent.Reservoirs;
  9. using MECF.Framework.Common.RecipeCenter;
  10. using MECF.Framework.Common.Routine;
  11. using MECF.Framework.Common.ToolLayout;
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Linq;
  15. using System.Text;
  16. using System.Threading.Tasks;
  17. namespace CyberX8_RT.Modules.Metal
  18. {
  19. public class CompactEmbranceInitializeRoutine : RoutineBase, IRoutine
  20. {
  21. private enum InitializeStep
  22. {
  23. CheckPowerSupplierConnected,
  24. LinmotReset,
  25. LinmotResetWait,
  26. WHUnclampOn,
  27. FlowValveOn,
  28. Delay,
  29. ManualFlowCheck,
  30. AutoFlowCheck,
  31. End
  32. }
  33. #region 内部变量
  34. /// <summary>
  35. /// 持久化对象
  36. /// </summary>
  37. private MetalPersistentValue _persistentValue;
  38. /// <summary>
  39. /// 设备对象
  40. /// </summary>
  41. private CompactMembranMetalDevice _metalDevice;
  42. /// <summary>
  43. /// Reservoir Recipe
  44. /// </summary>
  45. private ResRecipe _resRecipe;
  46. /// <summary>
  47. /// Cell Flow Delay Time
  48. /// </summary>
  49. private int _cellFlowFaultHoldOffTime = 5000;
  50. /// <summary>
  51. /// Cell Flow Start Low Limit
  52. /// </summary>
  53. private double _cellFlowStartLowLimit = 3.0;
  54. #endregion
  55. /// <summary>
  56. /// 构造函数
  57. /// </summary>
  58. /// <param name="module"></param>
  59. public CompactEmbranceInitializeRoutine(string module) : base(module)
  60. {
  61. }
  62. /// <summary>
  63. /// 中止
  64. /// </summary>
  65. public void Abort()
  66. {
  67. Runner.Stop("Manual Abort");
  68. }
  69. /// <summary>
  70. /// 监控
  71. /// </summary>
  72. /// <returns></returns>
  73. public RState Monitor()
  74. {
  75. Runner.Run(InitializeStep.CheckPowerSupplierConnected, CheckPowerSupplierStatus, _delay_1ms)
  76. .Run(InitializeStep.LinmotReset, _metalDevice.ResetLinmot, _delay_1ms)
  77. .WaitWithStopCondition(InitializeStep.LinmotResetWait, _metalDevice.CheckLinmotRoutineEnd, _metalDevice.CheckLinmotRoutineError)
  78. .Run(InitializeStep.WHUnclampOn, WaferHolderUnclampOn, _delay_1ms)
  79. .Run(InitializeStep.FlowValveOn, () => _metalDevice.CellFlowValveOn("", null), _delay_1ms)
  80. .Delay(InitializeStep.Delay, _cellFlowFaultHoldOffTime)
  81. .RunIf(InitializeStep.ManualFlowCheck, _metalDevice.IsManual, ManualFlowCheck, _delay_1ms)
  82. .RunIf(InitializeStep.AutoFlowCheck, _metalDevice.IsAuto, AutoFlowCheck, _delay_1ms)
  83. .End(InitializeStep.End, NullFun, _delay_1ms);
  84. return Runner.Status;
  85. }
  86. /// <summary>
  87. /// 检验Metal A/B 面PowerSupplier通讯状况
  88. /// </summary>
  89. /// <returns></returns>
  90. private bool CheckPowerSupplierStatus()
  91. {
  92. if (!_metalDevice.SideAPowerSupplier.IsConnected)
  93. {
  94. LOG.WriteLog(eEvent.ERR_METAL, Module, "side A power is not connected");
  95. return false;
  96. }
  97. if (!_metalDevice.SideBPowerSupplier.IsConnected)
  98. {
  99. LOG.WriteLog(eEvent.ERR_METAL, Module, "side B power is not connected");
  100. return false;
  101. }
  102. return true;
  103. }
  104. /// <summary>
  105. /// WaferHolder Unclamp on
  106. /// </summary>
  107. /// <returns></returns>
  108. private bool WaferHolderUnclampOn()
  109. {
  110. return _metalDevice.WaferHolderUnclampOn("", null);
  111. }
  112. /// <summary>
  113. /// 手动检验Flow
  114. /// </summary>
  115. /// <returns></returns>
  116. private bool ManualFlowCheck()
  117. {
  118. if (_metalDevice.MetalDeviceData.CellFlow < _cellFlowStartLowLimit)
  119. {
  120. LOG.WriteLog(eEvent.ERR_METAL, Module, $"Flow {_metalDevice.MetalDeviceData.CellFlow} is less than {_cellFlowStartLowLimit}");
  121. _metalDevice.CellFlowValveOff("", null);
  122. return false;
  123. }
  124. return true;
  125. }
  126. /// <summary>
  127. /// 自动检验Flow
  128. /// </summary>
  129. /// <returns></returns>
  130. private bool AutoFlowCheck()
  131. {
  132. if (_metalDevice.MetalDeviceData.CellFlow < _resRecipe.CAFlowRateErrorLow)
  133. {
  134. LOG.WriteLog(eEvent.ERR_METAL, Module, $"Flow {_metalDevice.MetalDeviceData.CellFlow} is less than {_resRecipe.CAFlowRateErrorLow}");
  135. return false;
  136. }
  137. return true;
  138. }
  139. /// <summary>
  140. /// 启动
  141. /// </summary>
  142. /// <param name="objs"></param>
  143. /// <returns></returns>
  144. public RState Start(params object[] objs)
  145. {
  146. _persistentValue = (MetalPersistentValue)objs[0];
  147. _metalDevice = DEVICE.GetDevice<CompactMembranMetalDevice>(Module);
  148. _cellFlowFaultHoldOffTime = SC.GetValue<int>("Metal.CellFlowFaultHoldOffTime");
  149. _cellFlowStartLowLimit = SC.GetValue<double>("Metal.CellFlowStartLowLimit");
  150. string reservoir = ReservoirItemManager.Instance.GetReservoirByMetal(Module.ToString());
  151. CompactMembranReservoirDevice reservoirDevice = DEVICE.GetDevice<CompactMembranReservoirDevice>(reservoir);
  152. if (reservoirDevice == null)
  153. {
  154. LOG.WriteLog(eEvent.ERR_METAL, Module, $"{reservoir} device is null");
  155. return RState.Failed;
  156. }
  157. if (reservoirDevice.Recipe == null)
  158. {
  159. LOG.WriteLog(eEvent.ERR_METAL, Module, $"{reservoir} current recipe is null");
  160. return RState.Failed;
  161. }
  162. _resRecipe = reservoirDevice.Recipe;
  163. return Runner.Start(Module, "Start C&M Initialize");
  164. }
  165. }
  166. }