SchedulerVPW.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. return true;
  88. }
  89. if (vpwMainEntity.IsChamberClosed)
  90. {
  91. vpwMainEntity.CheckToPostMessage<VPWCellState, VPWCellMsg>(eEvent.INFO_VPW, Module.ToString(), (int)VPWMainMsg.ChamberDown);
  92. }
  93. else
  94. {
  95. if (vpwMainEntity.IsIdle)
  96. {
  97. _state = RState.End;
  98. _isStartRunRecipe = false;
  99. }
  100. }
  101. }
  102. return true;
  103. }
  104. /// <summary>
  105. /// 检验前置条件
  106. /// </summary>
  107. /// <param name="sequenceIndex"></param>
  108. /// <param name="parameter"></param>
  109. /// <returns></returns>
  110. public override bool CheckPrecondition(List<SchedulerSequence> schedulerSequences, int sequenceIndex, object parameter, string materialId,ref string reason)
  111. {
  112. if (_state == RState.Running)
  113. {
  114. reason = "scheduler module is already running";
  115. return false;
  116. }
  117. if (_vpwEntity.IsBusy)
  118. {
  119. reason = $"{_vpwEntity.Module} is busy";
  120. return false;
  121. }
  122. if(WaferManager.Instance.CheckNoWafer(Module,0))
  123. {
  124. reason = $"{_vpwEntity.Module} has no wafer";
  125. return false;
  126. }
  127. if (!SchedulerSequenceManager.Instance.CheckSystemHasTheSameSizeVpw())
  128. {
  129. return true;
  130. }
  131. VpwCellEntity vpwCellEntity1 = Singleton<RouteManager>.Instance.GetModule<VpwCellEntity>(ModuleName.VPW1.ToString());
  132. VpwCellEntity vpwCellEntity2 = Singleton<RouteManager>.Instance.GetModule<VpwCellEntity>(ModuleName.VPW2.ToString());
  133. if (vpwCellEntity1.State != (int)VPWCellState.WaitForRunRecipe && vpwCellEntity1.State != (int)VPWCellState.RunReciping)
  134. {
  135. return false;
  136. }
  137. if (WaferManager.Instance.CheckNoWafer(ModuleName.VPW1, 0))
  138. {
  139. reason = $"{ModuleName.VPW1} has no wafer";
  140. return false;
  141. }
  142. if (vpwCellEntity2.State != (int)VPWCellState.WaitForRunRecipe&&vpwCellEntity2.State!=(int)VPWCellState.RunReciping)
  143. {
  144. return false;
  145. }
  146. if (WaferManager.Instance.CheckNoWafer(ModuleName.VPW2, 0))
  147. {
  148. reason = $"{ModuleName.VPW2} has no wafer";
  149. return false;
  150. }
  151. return true;
  152. }
  153. }
  154. }