SchedulerAligner.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using System.Diagnostics;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Aitex.Core.RT.Fsm;
  7. using Aitex.Core.Util;
  8. using Aitex.Core.RT.SCCore;
  9. using Aitex.Sorter.Common;
  10. using MECF.Framework.Common.Equipment;
  11. using MECF.Framework.Common.Schedulers;
  12. using MECF.Framework.Common.SubstrateTrackings;
  13. using CyberX8_RT.Modules;
  14. using MECF.Framework.Common.CommonData;
  15. using CyberX8_Core;
  16. using Aitex.Core.RT.Log;
  17. using Aitex.Core.Common;
  18. using MECF.Framework.Common.RecipeCenter;
  19. namespace CyberX8_RT.Schedulers.Aligner
  20. {
  21. public class SchedulerAligner : SchedulerModule
  22. {
  23. #region 内部变量
  24. private EfemEntity _efemEntity;
  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="module"></param>
  46. public SchedulerAligner(ModuleName module) : base(module.ToString())
  47. {
  48. _efemEntity = Singleton<RouteManager>.Instance.EFEM;
  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 (_efemEntity.IsBusy)
  58. {
  59. return false;
  60. }
  61. if (recipe == null)
  62. {
  63. return false;
  64. }
  65. if(!(recipe is SequenceRecipe))
  66. {
  67. return false;
  68. }
  69. SequenceRecipe sequenceRecipe=recipe as SequenceRecipe;
  70. int angle = int.Parse(sequenceRecipe.AlignmentAngle.ToString());
  71. int platType = sequenceRecipe.PlatType;
  72. return _efemEntity.CheckToPostMessage<EfemEntity.STATE, EfemEntity.MSG>(eEvent.ERR_EFEM_COMMON_FAILED,
  73. Module.ToString(), (int)EfemEntity.MSG.Align, ModuleName.Aligner1.ToString(), 0, angle,platType);
  74. }
  75. /// <summary>
  76. /// 监控执行
  77. /// </summary>
  78. /// <returns></returns>
  79. public override bool MonitorProcess(SchedulerSequence schedulerSequence,bool hasMatchWafer)
  80. {
  81. if (_efemEntity.IsBusy)
  82. {
  83. _state = RState.Running;
  84. }
  85. if (_efemEntity.IsIdle)
  86. {
  87. _state = RState.End;
  88. }
  89. return true;
  90. }
  91. /// <summary>
  92. /// 检验前置条件
  93. /// </summary>
  94. /// <param name="sequenceIndex"></param>
  95. /// <param name="parameter"></param>
  96. /// <returns></returns>
  97. public override bool CheckPrecondition(List<SchedulerSequence> schedulerSequences, int sequenceIndex, object parameter, string materialId, ref string reason)
  98. {
  99. if(_state == RState.Running)
  100. {
  101. reason = "scheduler module is already running";
  102. return false;
  103. }
  104. if (WaferManager.Instance.CheckHasWafer(Module, 0))
  105. {
  106. WaferInfo waferInfo = WaferManager.Instance.GetWafer(Module, 0);
  107. bool result= waferInfo.WaferID==materialId;
  108. if (!result)
  109. {
  110. reason = $"aligner wafer id {waferInfo.WaferID} is not matched with {materialId}";
  111. }
  112. return result;
  113. }
  114. else
  115. {
  116. reason = "aligner has no wafer";
  117. return false;
  118. }
  119. }
  120. }
  121. }