StandardHotInitializeRoutine.cs 6.2 KB

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