SchedulerSrd.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using Aitex.Common.Util;
  2. using Aitex.Core.Common;
  3. using Aitex.Core.RT.Log;
  4. using Aitex.Core.Util;
  5. using CyberX8_Core;
  6. using CyberX8_RT.Modules;
  7. using CyberX8_RT.Modules.Rinse;
  8. using CyberX8_RT.Modules.SRD;
  9. using MECF.Framework.Common.Equipment;
  10. using MECF.Framework.Common.RecipeCenter;
  11. using MECF.Framework.Common.SubstrateTrackings;
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Linq;
  15. using System.Text;
  16. using System.Threading.Tasks;
  17. namespace CyberX8_RT.Schedulers.Srd
  18. {
  19. public class SchedulerSrd : SchedulerModule
  20. {
  21. #region 内部变量
  22. private SRDEntity _srdEntity;
  23. private bool _isStartRunRecipe = false;
  24. #endregion
  25. #region 属性
  26. /// <summary>
  27. /// 是否空闲
  28. /// </summary>
  29. public override bool IsIdle
  30. {
  31. get { return _state == RState.End; }
  32. }
  33. /// <summary>
  34. /// 是否错误
  35. /// </summary>
  36. public override bool IsError
  37. {
  38. get { return _state == RState.Failed || _state == RState.Timeout; }
  39. }
  40. #endregion
  41. /// <summary>
  42. /// 构造函数
  43. /// </summary>
  44. /// <param name="moduleName"></param>
  45. public SchedulerSrd(ModuleName moduleName) : base(moduleName.ToString())
  46. {
  47. _srdEntity = Singleton<RouteManager>.Instance.GetModule<SRDEntity>(moduleName.ToString());
  48. }
  49. /// <summary>
  50. /// 执行
  51. /// </summary>
  52. /// <param name="parameter"></param>
  53. /// <returns></returns>
  54. public override bool RunProcess(object recipe, object parameter, List<SchedulerSyncModuleMessage> syncModuleMessages)
  55. {
  56. if (!(recipe is SrdRecipe))
  57. {
  58. _state = RState.Failed;
  59. LOG.WriteLog(eEvent.ERR_SRD, Module.ToString(), "recipe is invalid");
  60. return false;
  61. }
  62. _isStartRunRecipe = false;
  63. SrdRecipe srdRecipe = (SrdRecipe)recipe;
  64. bool result = _srdEntity.CheckToPostMessage<SRDState, SRDMSG>(eEvent.WARN_SRD, Module.ToString(), (int)SRDMSG.ProcessRecipe, srdRecipe, 1);
  65. if (result)
  66. {
  67. _state = RState.Running;
  68. }
  69. return result;
  70. }
  71. /// <summary>
  72. /// 监控执行
  73. /// </summary>
  74. /// <returns></returns>
  75. public override bool MonitorProcess(SchedulerSequence schedulerSequence,bool hasMatchWafer)
  76. {
  77. if (!_isStartRunRecipe)
  78. {
  79. _isStartRunRecipe = _srdEntity.State == (int)SRDState.ProcessReciping;
  80. }
  81. if (_isStartRunRecipe && _srdEntity.IsIdle)
  82. {
  83. _state = RState.End;
  84. _isStartRunRecipe = false;
  85. }
  86. return true;
  87. }
  88. /// <summary>
  89. /// 检验前置条件
  90. /// </summary>
  91. /// <param name="sequenceIndex"></param>
  92. /// <param name="parameter"></param>
  93. /// <returns></returns>
  94. public override bool CheckPrecondition(List<SchedulerSequence> schedulerSequences, int sequenceIndex, object parameter, string materialId,ref string reason)
  95. {
  96. if (_state == RState.Running)
  97. {
  98. reason = "scheduler module is already running";
  99. return false;
  100. }
  101. if (_srdEntity.IsBusy)
  102. {
  103. reason = $"{_srdEntity.Module} is busy";
  104. return false;
  105. }
  106. if(WaferManager.Instance.CheckNoWafer(Module,0))
  107. {
  108. reason = $"{_srdEntity.Module} has no wafer";
  109. return false;
  110. }
  111. return true;
  112. }
  113. }
  114. }