123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Aitex.Core.Common;
- using Aitex.Core.RT.Event;
- using Aitex.Core.RT.Routine;
- using Aitex.Sorter.Common;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.SubstrateTrackings;
- namespace VirgoRT.Modules
- {
- public class ReturnAllWafer : TransferModule
- {
- private Queue<IRoutine> _moveTaskQueue = new Queue<IRoutine>();
- private IRoutine _activeTask;
- private bool _cooling;
- private int _coolingTime;
- public Result Start(object[] objs)
- {
- _moveTaskQueue.Clear();
- _activeTask = null;
- _cooling = objs.Length > 0 && (bool) objs[0];
- _coolingTime = (int) objs[1];
- return Result.RUN;
- }
- public Result Monitor(object[] objs)
- {
- if (_activeTask == null )
- {
- return StartNewReturnTask();
- }
- Result ret = _activeTask.Monitor();
- if (ret == Result.FAIL)
- return ret;
- if (ret == Result.DONE)
- {
- if (_moveTaskQueue.Count > 0)
- {
- _activeTask = _moveTaskQueue.Dequeue();
- return _activeTask.Start();
- }
- else
- {
- _activeTask = null;
- }
- }
- return Result.RUN;
- }
- public void Clear()
- {
- _moveTaskQueue.Clear();
- _activeTask = null;
- }
- private Result StartNewReturnTask()
- {
- ModuleName[] modules = new[]
- {ModuleName.EfemRobot, ModuleName.Aligner1, ModuleName.Aligner2, ModuleName.Cooling1, ModuleName.Cooling2, ModuleName.PMA, ModuleName.PMB};
- ModuleName source = ModuleName.System;
- WaferInfo wafer = null;
- Hand hand = Hand.Blade1;
- int sourceSlot = 0;
- foreach (var moduleName in modules)
- {
- if (WaferManager.Instance.CheckHasWafer(moduleName, 0))
- {
- source = moduleName;
- wafer = WaferManager.Instance.GetWafer(source, 0);
- break;
- }
- }
- if (wafer == null)
- {
- if (WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, 1))
- {
- source = ModuleName.EfemRobot;
- wafer = WaferManager.Instance.GetWafer(source, 1);
- hand = Hand.Blade2;
- sourceSlot = 1;
- }
- }
- if (source == ModuleName.System || wafer==null || wafer.IsEmpty)
- {
- EV.PostInfoLog("Scheduler", "All wafers returned.");
- return Result.DONE;
- }
- if (_cooling && !ModuleHelper.IsCooling(source) && !ModuleHelper.IsAligner(source))
- {
- if (WaferManager.Instance.CheckHasWafer(ModuleName.Cooling1, 0) && WaferManager.Instance.CheckHasWafer(ModuleName.Cooling2, 0))
- {
- EV.PostWarningLog("System", "Can not transfer, cooling has wafer, can not auto cooling");
- return Result.FAIL;
- }
- ModuleName cooling = WaferManager.Instance.CheckHasWafer(ModuleName.Cooling1, 0)
- ? ModuleName.Cooling2
- : ModuleName.Cooling1;
- _moveTaskQueue.Enqueue(new EfemRobotMover(new MoveItemEx(source, sourceSlot, cooling, 0, _coolingTime, hand)));
- _moveTaskQueue.Enqueue(new EfemRobotMover(new MoveItemEx(cooling, 0, (ModuleName)wafer.OriginStation, wafer.OriginSlot, 0, hand)));
- }
- else
- {
- _moveTaskQueue.Enqueue(new EfemRobotMover(new MoveItemEx(source, sourceSlot, (ModuleName)wafer.OriginStation, wafer.OriginSlot, 0, hand)));
- }
- _activeTask = _moveTaskQueue.Dequeue();
- return _activeTask.Start() ;
-
- }
- }
- }
|