ReturnAllWafer.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Aitex.Core.Common;
  7. using Aitex.Core.RT.Event;
  8. using Aitex.Core.RT.Routine;
  9. using Aitex.Sorter.Common;
  10. using MECF.Framework.Common.Equipment;
  11. using MECF.Framework.Common.SubstrateTrackings;
  12. namespace VirgoRT.Modules
  13. {
  14. public class ReturnAllWafer : TransferModule
  15. {
  16. private Queue<IRoutine> _moveTaskQueue = new Queue<IRoutine>();
  17. private IRoutine _activeTask;
  18. private bool _cooling;
  19. private int _coolingTime;
  20. public Result Start(object[] objs)
  21. {
  22. _moveTaskQueue.Clear();
  23. _activeTask = null;
  24. _cooling = objs.Length > 0 && (bool) objs[0];
  25. _coolingTime = (int) objs[1];
  26. return Result.RUN;
  27. }
  28. public Result Monitor(object[] objs)
  29. {
  30. if (_activeTask == null )
  31. {
  32. return StartNewReturnTask();
  33. }
  34. Result ret = _activeTask.Monitor();
  35. if (ret == Result.FAIL)
  36. return ret;
  37. if (ret == Result.DONE)
  38. {
  39. if (_moveTaskQueue.Count > 0)
  40. {
  41. _activeTask = _moveTaskQueue.Dequeue();
  42. return _activeTask.Start();
  43. }
  44. else
  45. {
  46. _activeTask = null;
  47. }
  48. }
  49. return Result.RUN;
  50. }
  51. public void Clear()
  52. {
  53. _moveTaskQueue.Clear();
  54. _activeTask = null;
  55. }
  56. private Result StartNewReturnTask()
  57. {
  58. ModuleName[] modules = new[]
  59. {ModuleName.EfemRobot, ModuleName.Aligner1, ModuleName.Aligner2, ModuleName.Cooling1, ModuleName.Cooling2, ModuleName.PMA, ModuleName.PMB};
  60. ModuleName source = ModuleName.System;
  61. WaferInfo wafer = null;
  62. Hand hand = Hand.Blade1;
  63. int sourceSlot = 0;
  64. foreach (var moduleName in modules)
  65. {
  66. if (WaferManager.Instance.CheckHasWafer(moduleName, 0))
  67. {
  68. source = moduleName;
  69. wafer = WaferManager.Instance.GetWafer(source, 0);
  70. break;
  71. }
  72. }
  73. if (wafer == null)
  74. {
  75. if (WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, 1))
  76. {
  77. source = ModuleName.EfemRobot;
  78. wafer = WaferManager.Instance.GetWafer(source, 1);
  79. hand = Hand.Blade2;
  80. sourceSlot = 1;
  81. }
  82. }
  83. if (source == ModuleName.System || wafer==null || wafer.IsEmpty)
  84. {
  85. EV.PostInfoLog("Scheduler", "All wafers returned.");
  86. return Result.DONE;
  87. }
  88. if (_cooling && !ModuleHelper.IsCooling(source) && !ModuleHelper.IsAligner(source))
  89. {
  90. if (WaferManager.Instance.CheckHasWafer(ModuleName.Cooling1, 0) && WaferManager.Instance.CheckHasWafer(ModuleName.Cooling2, 0))
  91. {
  92. EV.PostWarningLog("System", "Can not transfer, cooling has wafer, can not auto cooling");
  93. return Result.FAIL;
  94. }
  95. ModuleName cooling = WaferManager.Instance.CheckHasWafer(ModuleName.Cooling1, 0)
  96. ? ModuleName.Cooling2
  97. : ModuleName.Cooling1;
  98. _moveTaskQueue.Enqueue(new EfemRobotMover(new MoveItemEx(source, sourceSlot, cooling, 0, _coolingTime, hand)));
  99. _moveTaskQueue.Enqueue(new EfemRobotMover(new MoveItemEx(cooling, 0, (ModuleName)wafer.OriginStation, wafer.OriginSlot, 0, hand)));
  100. }
  101. else
  102. {
  103. _moveTaskQueue.Enqueue(new EfemRobotMover(new MoveItemEx(source, sourceSlot, (ModuleName)wafer.OriginStation, wafer.OriginSlot, 0, hand)));
  104. }
  105. _activeTask = _moveTaskQueue.Dequeue();
  106. return _activeTask.Start() ;
  107. }
  108. }
  109. }