SchedulerSrd.cs 3.8 KB

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