SchedulerVPW.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. using Aitex.Common.Util;
  2. using Aitex.Core.Common;
  3. using Aitex.Core.RT.Log;
  4. using Aitex.Core.Util;
  5. using PunkHPX8_Core;
  6. using PunkHPX8_RT.Modules;
  7. using PunkHPX8_RT.Modules.SRD;
  8. using MECF.Framework.Common.Equipment;
  9. using MECF.Framework.Common.RecipeCenter;
  10. using MECF.Framework.Common.SubstrateTrackings;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Linq;
  14. using System.Text;
  15. using System.Threading.Tasks;
  16. using PunkHPX8_RT.Modules.VpwMain;
  17. using PunkHPX8_RT.Modules.VpwCell;
  18. namespace PunkHPX8_RT.Schedulers.Srd
  19. {
  20. public class SchedulerVPW : SchedulerModule
  21. {
  22. #region 内部变量
  23. private VpwCellEntity _vpwEntity;
  24. private bool _isStartRunRecipe = false;
  25. #endregion
  26. #region 属性
  27. /// <summary>
  28. /// 是否空闲
  29. /// </summary>
  30. public override bool IsIdle
  31. {
  32. get { return _state == RState.End; }
  33. }
  34. /// <summary>
  35. /// 是否错误
  36. /// </summary>
  37. public override bool IsError
  38. {
  39. get { return _state == RState.Failed || _state == RState.Timeout; }
  40. }
  41. #endregion
  42. /// <summary>
  43. /// 构造函数
  44. /// </summary>
  45. /// <param name="moduleName"></param>
  46. public SchedulerVPW(ModuleName moduleName) : base(moduleName.ToString())
  47. {
  48. _vpwEntity = Singleton<RouteManager>.Instance.GetModule<VpwCellEntity>(moduleName.ToString());
  49. }
  50. /// <summary>
  51. /// 执行
  52. /// </summary>
  53. /// <param name="parameter"></param>
  54. /// <returns></returns>
  55. public override bool RunProcess(object recipe, object parameter, List<SchedulerSyncModuleMessage> syncModuleMessages)
  56. {
  57. if (!(recipe is VpwRecipe))
  58. {
  59. _state = RState.Failed;
  60. LOG.WriteLog(eEvent.ERR_SRD, Module.ToString(), "recipe is invalid");
  61. return false;
  62. }
  63. _isStartRunRecipe = false;
  64. VpwRecipe vpwRecipe = (VpwRecipe)recipe;
  65. bool result = _vpwEntity.CheckToPostMessage<VPWCellState, VPWCellMsg>(eEvent.INFO_VPW, Module.ToString(), (int)VPWCellMsg.RunRecipe, vpwRecipe, 1);
  66. if (result)
  67. {
  68. _state = RState.Running;
  69. }
  70. return result;
  71. }
  72. /// <summary>
  73. /// 监控执行
  74. /// </summary>
  75. /// <returns></returns>
  76. public override bool MonitorProcess(SchedulerSequence schedulerSequence,bool hasMatchWafer)
  77. {
  78. if (!_isStartRunRecipe)
  79. {
  80. _isStartRunRecipe = _vpwEntity.State == (int)VPWCellState.RunReciping;
  81. }
  82. if (_isStartRunRecipe)
  83. {
  84. VpwMainEntity vpwMainEntity = Singleton<RouteManager>.Instance.GetModule<VpwMainEntity>(ModuleName.VPWMain1.ToString());
  85. if (_vpwEntity.IsIdle)
  86. {
  87. if (vpwMainEntity.IsChamberClosed)
  88. {
  89. _vpwEntity.CheckToPostMessage<VPWCellState, VPWCellMsg>(eEvent.INFO_VPW, Module.ToString(), (int)VPWCellMsg.ChamberDown);
  90. }
  91. else
  92. {
  93. _state = RState.End;
  94. _isStartRunRecipe = false;
  95. }
  96. }
  97. }
  98. return true;
  99. }
  100. /// <summary>
  101. /// 检验前置条件
  102. /// </summary>
  103. /// <param name="sequenceIndex"></param>
  104. /// <param name="parameter"></param>
  105. /// <returns></returns>
  106. public override bool CheckPrecondition(List<SchedulerSequence> schedulerSequences, int sequenceIndex, object parameter, string materialId,ref string reason)
  107. {
  108. if (_state == RState.Running)
  109. {
  110. reason = "scheduler module is already running";
  111. return false;
  112. }
  113. if (_vpwEntity.IsBusy)
  114. {
  115. reason = $"{_vpwEntity.Module} is busy";
  116. return false;
  117. }
  118. if(WaferManager.Instance.CheckNoWafer(Module,0))
  119. {
  120. reason = $"{_vpwEntity.Module} has no wafer";
  121. return false;
  122. }
  123. if (!SchedulerSequenceManager.Instance.CheckSystemHasTheSameSizeVpw())
  124. {
  125. return true;
  126. }
  127. VpwCellEntity vpwCellEntity1 = Singleton<RouteManager>.Instance.GetModule<VpwCellEntity>(ModuleName.VPW1.ToString());
  128. VpwCellEntity vpwCellEntity2 = Singleton<RouteManager>.Instance.GetModule<VpwCellEntity>(ModuleName.VPW2.ToString());
  129. if (vpwCellEntity1.State != (int)VPWCellState.WaitForRunRecipe && vpwCellEntity1.State != (int)VPWCellState.RunReciping)
  130. {
  131. return false;
  132. }
  133. if (WaferManager.Instance.CheckNoWafer(ModuleName.VPW1, 0))
  134. {
  135. reason = $"{ModuleName.VPW1} has no wafer";
  136. return false;
  137. }
  138. if (vpwCellEntity2.State != (int)VPWCellState.WaitForRunRecipe&&vpwCellEntity2.State!=(int)VPWCellState.RunReciping)
  139. {
  140. return false;
  141. }
  142. if (WaferManager.Instance.CheckNoWafer(ModuleName.VPW2, 0))
  143. {
  144. reason = $"{ModuleName.VPW2} has no wafer";
  145. return false;
  146. }
  147. return true;
  148. }
  149. }
  150. }