ReturnAllWafer.cs 3.6 KB

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