SchedulerVPW.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 && _vpwEntity.IsIdle)
  83. {
  84. _state = RState.End;
  85. _isStartRunRecipe = false;
  86. }
  87. return true;
  88. }
  89. /// <summary>
  90. /// 检验前置条件
  91. /// </summary>
  92. /// <param name="sequenceIndex"></param>
  93. /// <param name="parameter"></param>
  94. /// <returns></returns>
  95. public override bool CheckPrecondition(List<SchedulerSequence> schedulerSequences, int sequenceIndex, object parameter, string materialId,ref string reason)
  96. {
  97. if (_state == RState.Running)
  98. {
  99. reason = "scheduler module is already running";
  100. return false;
  101. }
  102. if (_vpwEntity.IsBusy)
  103. {
  104. reason = $"{_vpwEntity.Module} is busy";
  105. return false;
  106. }
  107. if(WaferManager.Instance.CheckNoWafer(Module,0))
  108. {
  109. reason = $"{_vpwEntity.Module} has no wafer";
  110. return false;
  111. }
  112. return true;
  113. }
  114. }
  115. }