SchedulerDryer.cs 4.3 KB

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