SchedulerPlatingCell.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. _isStartRunRecipe = false;
  60. bool result = false;
  61. if (recipe is DepRecipe)
  62. {
  63. DepRecipe depRecipe = (DepRecipe)recipe;
  64. result = _entity.CheckToPostMessage<PlatingCellState, PlatingCellMsg>(eEvent.INFO_PLATINGCELL, Module.ToString(), (int)PlatingCellMsg.RunRecipe, depRecipe,false, 1);
  65. }
  66. else
  67. {
  68. DqdrRecipe dqdrRecipe = (DqdrRecipe)recipe;
  69. result = _entity.CheckToPostMessage<PlatingCellState, PlatingCellMsg>(eEvent.INFO_PLATINGCELL, Module.ToString(), (int)PlatingCellMsg.RunRecipe,dqdrRecipe,true, 1);
  70. }
  71. if (result)
  72. {
  73. _state = RState.Running;
  74. }
  75. return result;
  76. }
  77. /// <summary>
  78. /// 监控执行
  79. /// </summary>
  80. /// <returns></returns>
  81. public override bool MonitorProcess(SchedulerSequence schedulerSequence,bool hasMatchWafer)
  82. {
  83. if (!_isStartRunRecipe)
  84. {
  85. _isStartRunRecipe = _entity.State == (int)PlatingCellState.RunReciping;
  86. }
  87. if (_isStartRunRecipe && _entity.IsIdle)
  88. {
  89. _state = RState.End;
  90. _isStartRunRecipe = false;
  91. }
  92. return true;
  93. }
  94. /// <summary>
  95. /// 检验前置条件
  96. /// </summary>
  97. /// <param name="sequenceIndex"></param>
  98. /// <param name="parameter"></param>
  99. /// <returns></returns>
  100. public override bool CheckPrecondition(List<SchedulerSequence> schedulerSequences, int sequenceIndex, object parameter, string materialId,ref string reason)
  101. {
  102. if (_state == RState.Running)
  103. {
  104. reason = "scheduler module is already running";
  105. return false;
  106. }
  107. if (_entity.IsBusy)
  108. {
  109. reason = $"{_entity.Module} is busy";
  110. return false;
  111. }
  112. if(WaferManager.Instance.CheckNoWafer(Module,0))
  113. {
  114. reason = $"{_entity.Module} has no wafer";
  115. return false;
  116. }
  117. string matcher = ModuleMatcherManager.Instance.GetMatcherByModule(Module.ToString());
  118. if (string.IsNullOrEmpty(matcher))
  119. {
  120. reason = $"{Module} has no matcher";
  121. return false;
  122. }
  123. PlatingCellEntity matcherEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellEntity>(matcher);
  124. if (matcherEntity == null)
  125. {
  126. reason = $"{matcher} has no matcher";
  127. return false;
  128. }
  129. if (!matcherEntity.IsAuto)
  130. {
  131. return true;
  132. }
  133. if (WaferManager.Instance.CheckNoWafer(matcher, 0))
  134. {
  135. reason = $"{matcher} has no wafer";
  136. return false;
  137. }
  138. return true;
  139. }
  140. }
  141. }