VpwCycleManualProcessRecipeRoutine.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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 Aitex.Core.Util;
  6. using MECF.Framework.Common.CommonData;
  7. using MECF.Framework.Common.CommonData.Prewet;
  8. using MECF.Framework.Common.CommonData.Vpw;
  9. using MECF.Framework.Common.RecipeCenter;
  10. using MECF.Framework.Common.Routine;
  11. using PunkHPX8_Core;
  12. using PunkHPX8_RT.Devices.LinMot;
  13. using PunkHPX8_RT.Devices.VpwCell;
  14. using PunkHPX8_RT.Modules.VpwMain;
  15. using System;
  16. using System.Collections.Generic;
  17. using System.Linq;
  18. using System.Text;
  19. using System.Threading.Tasks;
  20. namespace PunkHPX8_RT.Modules.VpwCell
  21. {
  22. public class VpwCycleManualProcessRecipeRoutine : RoutineBase, IRoutine
  23. {
  24. private const int LOTTRACK_TIME = 1000;
  25. private enum CycleManualRunRecipeStep
  26. {
  27. LoopStart,
  28. LoopRunProcess,
  29. LoopWaitRunProcess,
  30. LoopDelay,
  31. LoopEnd,
  32. End
  33. }
  34. #region 内部变量
  35. private VpwManualRecipeRoutine _processRecipeRoutine;
  36. private int _cycle = 0;
  37. private int _achievedCycle;
  38. private object[] param;
  39. /// <summary>
  40. /// Vpw recipe
  41. /// </summary>
  42. private VpwRecipe _recipe;
  43. /// <summary>
  44. /// lock track time
  45. /// </summary>
  46. private DateTime _lotTackTime = DateTime.Now;
  47. /// <summary>
  48. /// LotTrack数据
  49. /// </summary>
  50. private List<VpwLotTrackData> _datas = new List<VpwLotTrackData>();
  51. /// <summary>
  52. /// LotTrack文件头数据
  53. /// </summary>
  54. private LotTrackFileHeaderCommonData _header = new LotTrackFileHeaderCommonData();
  55. /// <summary>
  56. /// 设备对象
  57. /// </summary>
  58. private VpwCellDevice _vpwCellDevice;
  59. #endregion
  60. #region 属性
  61. /// <summary>
  62. /// 当前执行到循环哪一步
  63. /// </summary>
  64. public string CurrentStatus
  65. {
  66. get { return Runner.CurrentStep.ToString(); }
  67. }
  68. /// <summary>
  69. /// 当前执行到循环哪一步内的哪个动作
  70. /// </summary>
  71. public string CurrentStateMachine
  72. {
  73. get { return _processRecipeRoutine.CurrentStep; }
  74. }
  75. /// <summary>
  76. /// LotTrack数据
  77. /// </summary>
  78. public List<VpwLotTrackData> VpwLotTrackDatas { get { return _datas; } }
  79. /// <summary>
  80. /// LotTrack文件头数据
  81. /// </summary>
  82. public LotTrackFileHeaderCommonData VpwLotTrackHeaderDatas { get { return _header; } }
  83. #endregion
  84. /// <summary>
  85. /// 构造函数
  86. /// </summary>
  87. /// <param name="module"></param>
  88. public VpwCycleManualProcessRecipeRoutine(string module) : base(module)
  89. {
  90. _processRecipeRoutine = new VpwManualRecipeRoutine(module);
  91. }
  92. /// <summary>
  93. /// Abort
  94. /// </summary>
  95. public void Abort()
  96. {
  97. _processRecipeRoutine.Abort();
  98. Runner.Stop("Vpw Cycle ManualRunRecipe Abort");
  99. }
  100. public RState Start(params object[] objs)
  101. {
  102. _cycle = (int)objs[1];
  103. _achievedCycle = 0;
  104. param = objs;
  105. _vpwCellDevice = DEVICE.GetDevice<VpwCellDevice>(Module);
  106. _datas.Clear();
  107. _recipe = objs[0] as VpwRecipe;
  108. if (_recipe == null)
  109. {
  110. LOG.WriteLog(eEvent.ERR_VPW, Module, "recipe is null");
  111. return RState.Failed;
  112. }
  113. if (SC.ContainsItem("System.ToolID")) _header.ToolID = SC.GetStringValue("System.ToolID");
  114. _header.SoftWareVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
  115. _header.Recipe = $"{_recipe.Ppid}.vpw.rcp";
  116. //lotTract记录SequenceRecipe
  117. //VpwCellEntity vpwCellEntity = Singleton<RouteManager>.Instance.GetModule<VpwCellEntity>(Module);
  118. //if (vpwCellEntity.WaferHolderInfo != null && vpwCellEntity.WaferHolderInfo.SequenceRecipe != null && !string.IsNullOrEmpty(vpwCellEntity.WaferHolderInfo.SequenceRecipe.Ppid.ToString()))
  119. //{
  120. // _header.SequenceRecipe = vpwCellEntity.WaferHolderInfo.SequenceRecipe.Ppid.ToString();
  121. // _header.ProcessTransferList = new List<string>();
  122. // _header.ProcessTransferList.AddRange(vpwCellEntity.WaferHolderInfo.SchedulerModules);
  123. // vpwCellEntity.WaferHolderInfo.SchedulerModules.Clear();
  124. //}
  125. _lotTackTime = DateTime.Now;
  126. return Runner.Start(Module, "Start Vpw Cycle ManualRunRecipe");
  127. }
  128. public RState Monitor()
  129. {
  130. LottrackRecord();
  131. Runner.LoopStart(CycleManualRunRecipeStep.LoopStart, "Loop Start ManualRunRecipe", _cycle, NullFun, _delay_1ms)
  132. .LoopRun(CycleManualRunRecipeStep.LoopRunProcess, () => _processRecipeRoutine.Start(param) == RState.Running, _delay_1ms)
  133. .LoopRunWithStopStatus(CycleManualRunRecipeStep.LoopWaitRunProcess, () => CheckRoutineEndStatus(_processRecipeRoutine), () => CheckRoutineStopStatus(_processRecipeRoutine))
  134. .LoopDelay(CycleManualRunRecipeStep.LoopDelay, _delay_1s)
  135. .LoopEnd(CycleManualRunRecipeStep.LoopEnd, AchievedCycleCount, _delay_1ms)
  136. .End(CycleManualRunRecipeStep.End, NullFun, _delay_1ms);
  137. return Runner.Status;
  138. }
  139. private bool CheckRoutineEndStatus(IRoutine routine)
  140. {
  141. bool result = routine.Monitor() == RState.End;
  142. return result;
  143. }
  144. private bool CheckRoutineStopStatus(IRoutine routine)
  145. {
  146. RState state = routine.Monitor();
  147. if (state == RState.Failed || state == RState.Timeout)
  148. {
  149. AddLotTrackData();
  150. return true;
  151. }
  152. return false;
  153. }
  154. /// <summary>
  155. /// 统计完成的Cycle次数
  156. /// </summary>
  157. /// <returns></returns>
  158. private bool AchievedCycleCount()
  159. {
  160. _achievedCycle += 1;
  161. return true;
  162. }
  163. /// <summary>
  164. /// 获取已经完成的Cycle次数
  165. /// </summary>
  166. /// <returns></returns>
  167. public int GetAchievedCycle()
  168. {
  169. return _achievedCycle;
  170. }
  171. /// <summary>
  172. /// 记录Lottrack
  173. /// </summary>
  174. private void LottrackRecord()
  175. {
  176. //记录Lottrack
  177. if (DateTime.Now.Subtract(_lotTackTime).TotalMilliseconds >= LOTTRACK_TIME)
  178. {
  179. AddLotTrackData();
  180. _lotTackTime = DateTime.Now;
  181. }
  182. }
  183. /// <summary>
  184. /// 获取Lot Track数据
  185. /// </summary>
  186. /// <returns></returns>
  187. private void AddLotTrackData()
  188. {
  189. VpwLotTrackData data = new VpwLotTrackData();
  190. data.TimeStamp = DateTime.Now;
  191. data.StateMachine = CurrentStateMachine;
  192. data.VacuumPressure = _vpwCellDevice.CommonData.VacuumPressure;
  193. data.CellFlow = _vpwCellDevice.CommonData.DiwFlow;
  194. data.DiwLoopDo = _vpwCellDevice.LoopDOValue;
  195. data.WaterPressure = _vpwCellDevice.MainCommonData.DiwPressure;
  196. data.DripValve = _vpwCellDevice.CommonData.FlowDrip;
  197. data.SmallValve = _vpwCellDevice.CommonData.FlowSmall;
  198. data.LargeValve = _vpwCellDevice.CommonData.FlowLarge;
  199. data.ChamberClosed = _vpwCellDevice.MainCommonData.ChamberClosed;
  200. _datas.Add(data);
  201. }
  202. }
  203. }