SchedulerPlatingCell.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. using PunkHPX8_RT.Modules.PlatingCell;
  19. using static PunkHPX8_RT.Modules.PlatingCell.PlatingCellEntity;
  20. namespace PunkHPX8_RT.Schedulers.Srd
  21. {
  22. public class SchedulerPlatingCell : SchedulerModule
  23. {
  24. #region 内部变量
  25. private PlatingCellEntity _entity;
  26. private bool _isStartRunRecipe = false;
  27. #endregion
  28. #region 属性
  29. /// <summary>
  30. /// 是否空闲
  31. /// </summary>
  32. public override bool IsIdle
  33. {
  34. get { return _state == RState.End; }
  35. }
  36. /// <summary>
  37. /// 是否错误
  38. /// </summary>
  39. public override bool IsError
  40. {
  41. get { return _state == RState.Failed || _state == RState.Timeout; }
  42. }
  43. #endregion
  44. /// <summary>
  45. /// 构造函数
  46. /// </summary>
  47. /// <param name="moduleName"></param>
  48. public SchedulerPlatingCell(ModuleName moduleName) : base(moduleName.ToString())
  49. {
  50. _entity = Singleton<RouteManager>.Instance.GetModule<PlatingCellEntity>(moduleName.ToString());
  51. }
  52. /// <summary>
  53. /// 执行
  54. /// </summary>
  55. /// <param name="parameter"></param>
  56. /// <returns></returns>
  57. public override bool RunProcess(object recipe, object parameter, List<SchedulerSyncModuleMessage> syncModuleMessages)
  58. {
  59. if (!(recipe is DepRecipe))
  60. {
  61. _state = RState.Failed;
  62. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module.ToString(), "recipe is invalid");
  63. return false;
  64. }
  65. _isStartRunRecipe = false;
  66. DepRecipe depRecipe = (DepRecipe)recipe;
  67. bool result = _entity.CheckToPostMessage<PlatingCellState, PlatingCellMsg>(eEvent.INFO_PLATINGCELL, Module.ToString(), (int)PlatingCellMsg.RunRecipe, depRecipe, 1);
  68. if (result)
  69. {
  70. _state = RState.Running;
  71. }
  72. return result;
  73. }
  74. /// <summary>
  75. /// 监控执行
  76. /// </summary>
  77. /// <returns></returns>
  78. public override bool MonitorProcess(SchedulerSequence schedulerSequence,bool hasMatchWafer)
  79. {
  80. if (!_isStartRunRecipe)
  81. {
  82. _isStartRunRecipe = _entity.State == (int)PlatingCellState.RunReciping;
  83. }
  84. if (_isStartRunRecipe && _entity.IsIdle)
  85. {
  86. _state = RState.End;
  87. _isStartRunRecipe = false;
  88. }
  89. return true;
  90. }
  91. /// <summary>
  92. /// 检验前置条件
  93. /// </summary>
  94. /// <param name="sequenceIndex"></param>
  95. /// <param name="parameter"></param>
  96. /// <returns></returns>
  97. public override bool CheckPrecondition(List<SchedulerSequence> schedulerSequences, int sequenceIndex, object parameter, string materialId,ref string reason)
  98. {
  99. if (_state == RState.Running)
  100. {
  101. reason = "scheduler module is already running";
  102. return false;
  103. }
  104. if (_entity.IsBusy)
  105. {
  106. reason = $"{_entity.Module} is busy";
  107. return false;
  108. }
  109. if(WaferManager.Instance.CheckNoWafer(Module,0))
  110. {
  111. reason = $"{_entity.Module} has no wafer";
  112. return false;
  113. }
  114. string matcher = ModuleMatcherManager.Instance.GetMatcherByModule(Module.ToString());
  115. if (string.IsNullOrEmpty(matcher))
  116. {
  117. reason = $"{Module} has no matcher";
  118. return false;
  119. }
  120. PlatingCellEntity matcherEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellEntity>(matcher);
  121. if (matcherEntity == null)
  122. {
  123. reason = $"{matcher} has no matcher";
  124. return false;
  125. }
  126. if (WaferManager.Instance.CheckNoWafer(matcher, 0))
  127. {
  128. reason = $"{matcher} has no wafer";
  129. return false;
  130. }
  131. return true;
  132. }
  133. }
  134. }