123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Aitex.Core.Common;
- using Aitex.Core.RT.DataCenter;
- using Aitex.Core.RT.Event;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using Aitex.Sorter.Common;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.Schedulers;
- using MECF.Framework.Common.SubstrateTrackings;
- using MECF.Framework.RT.ModuleLibrary.SystemModules;
- using EfemDualSchedulerLib.Schedulers;
- using Aitex.Core.Util;
- namespace EfemDualSchedulerLib
- {
- public class TMCycle : SchedulerModuleFactory, IRoutine
- {
- Dictionary<ModuleName, int> _checkPosition = new Dictionary<ModuleName, int>()
- {
- {ModuleName.TMRobot, SC.IsDoubleFork ? 4:2 },
- {ModuleName.PMA, 2},
- {ModuleName.PMB, 2},
- };
- Queue<Action> tmRobotActions = new Queue<Action>() { };
- private List<SchedulerPM> _lstPms = new List<SchedulerPM>();
- private List<SchedulerLoadLock> _lstLls = new List<SchedulerLoadLock>();
- public bool PMAIsInstalled
- {
- get
- {
- return SC.GetValueOrDefault<bool>("System.SetUp.PMA.IsInstalled");
- }
- }
- public bool PMBIsInstalled
- {
- get
- {
- return SC.GetValueOrDefault<bool>("System.SetUp.PMB.IsInstalled");
- }
- }
- public TMCycle(EquipmentManager equipment) : base()
- {
- DATA.Subscribe("TMCylce.RemainedCycleCount", () =>
- {
- return cycleCount - 1;
- });
- //有优先级,先处理pmb后pma
- if (PMBIsInstalled)
- _lstPms.Add(_pm2);
- if (PMAIsInstalled)
- _lstPms.Add(_pm1);
- _lstLls.Add(_loadlockA);
- _lstLls.Add(_loadlockB);
- tmRobotActions.Enqueue(MonitorTmRobotLoadLockPickTask);
- tmRobotActions.Enqueue(MonitorTMRobotPMPlaceTask);
- tmRobotActions.Enqueue(MonitorTMRobotPMPickTask);
- tmRobotActions.Enqueue(MonitorTmRobotLoadLockPlaceTask);
- }
- List<string> tmCycleRoutine = new List<string>() { "LLA", "PMA", "PMB", "LLB" };
- int cycleCount = 1;
- public Result Start(params object[] objs)
- {
- if (objs.Length == 2)
- {
- tmCycleRoutine = ((string[])objs[0]).ToList();
- cycleCount = (int)objs[1];
- }
- //if (!PMAIsInstalled && !PMBIsInstalled)
- //{
- // EV.PostWarningLog("System", $"TM Cycle, PMA & PMB Both UnInstalled.");
- // return Result.FAIL;
- //}
- if (!PMAIsInstalled && tmCycleRoutine.Contains("PMA"))
- {
- EV.PostWarningLog("System", $"TM Cycle, PMA is UnInstalled.");
- return Result.FAIL;
- }
- if (!PMBIsInstalled && tmCycleRoutine.Contains("PMB"))
- {
- EV.PostWarningLog("System", $"TM Cycle, PMB is UnInstalled.");
- return Result.FAIL;
- }
- foreach (var positions in _checkPosition)
- {
- for (int i = 0; i < positions.Value; i++)
- {
- WaferInfo wafer = WaferManager.Instance.GetWafer(positions.Key, i);
- if (!wafer.IsEmpty)
- {
- EV.PostWarningLog("System", $"TM Cycle, {positions.Key}.{i + 1} can not has wafer.");
- return Result.FAIL;
- }
- }
- }
- WaferInfo[] OriginWafers = WaferManager.Instance.GetWafers(ModuleHelper.Converter(tmCycleRoutine.First()));
- WaferInfo[] DestinationWafers = WaferManager.Instance.GetWafers(ModuleHelper.Converter(tmCycleRoutine.Last()));
- for (int i = 0; i < OriginWafers.Length; i++)
- {
- if (!OriginWafers[i].IsEmpty)
- {
- OriginWafers[i].OriginStation = (int)ModuleHelper.Converter(tmCycleRoutine.First());
- OriginWafers[i].OriginSlot = i;
- OriginWafers[i].ProcessState = EnumWaferProcessStatus.InProcess;
- OriginWafers[i].NextSequenceStep = 0;
- if (tmCycleRoutine.First() != tmCycleRoutine.Last() && !DestinationWafers[i].IsEmpty)
- {
- EV.PostWarningLog("System", $"TM Cycle, {tmCycleRoutine.Last()}.{i + 1} already has wafer.");
- return Result.FAIL;
- }
- }
- }
- if (tmCycleRoutine.First() != tmCycleRoutine.Last())
- {
- tmCycleRoutine.Add(tmCycleRoutine.First());
- }
- return Result.RUN;
- }
- public Result Monitor()
- {
- MonitorModuleTasks();
- if (MonitorTaskDone())
- {
- return Result.DONE;
- }
- return Result.RUN;
- }
- public void Clear()
- {
- }
- public void Abort()
- {
- _tmRobot?.ResetTask();
- foreach (var pm in _lstPms)
- {
- pm.ResetTask();
- }
- }
- public Result MonitorModuleTasks()
- {
- MonitorPMTask();
- MonitorTMRobotTask();
- return Result.RUN;
- }
- private void MonitorTMRobotTask()
- {
- if (!_tmRobot.IsAvailable)
- return;
- //_tmRobot is idle, release all the target
- foreach (var ll in _lstLls)
- {
- if (ll.IsWaitTransfer(ModuleName.TMRobot))
- ll.StopWaitTransfer(ModuleName.TMRobot);
- }
- foreach (var pm in _lstPms)
- {
- if (pm.IsWaitTransfer(ModuleName.TMRobot))
- pm.StopWaitTransfer(ModuleName.TMRobot);
- }
- if (!_tmRobot.IsAvailable)
- return;
- var act = tmRobotActions.Peek();
- act.Invoke();
- if (!_tmRobot.IsAvailable)
- return;
- tmRobotActions.Enqueue(tmRobotActions.Dequeue());
- //MonitorTMRobotPMTask();
- //if (!_tmRobot.IsAvailable)
- // return;
- //MonitorTMRobotLoadLockTask();
- }
- private void MonitorTmRobotLoadLockPlaceTask()
- {
- if (!_tmRobot.IsAvailable)
- return;
- //place to ll
- bool blade0HasWaferAndProcessed = _tmRobot.Blade1Enable && Converter.MapBladeToSlots(Hand.Blade1).Any(p=>WaferManager.Instance.CheckHasWafer(ModuleName.TMRobot, p));
- bool blade1HasWaferAndProcessed = _tmRobot.Blade2Enable && Converter.MapBladeToSlots(Hand.Blade2).Any(p=>WaferManager.Instance.CheckHasWafer(ModuleName.TMRobot, p));
- if (blade0HasWaferAndProcessed || blade1HasWaferAndProcessed)
- {
- Hand placeBlade = blade0HasWaferAndProcessed ? Hand.Blade1 : Hand.Blade2;
- var wafers = WaferManager.Instance.GetWafers(ModuleName.TMRobot);
- foreach (var ll in _lstLls)
- {
- if (!ll.IsAvailable)
- continue;
- var sourceSlot = new int[] { (int)placeBlade, ((int)placeBlade) + 2 };
- var targetSlot = new List<int>();
- for(int i=0;i< sourceSlot.Length;i++)
- {
- var wafer = WaferManager.Instance.GetWafer(ModuleName.TMRobot, sourceSlot[i]);
- if (wafer == null || wafer.IsEmpty) continue;
- var slot = wafer.OriginSlot;
- if (!CheckWaferNextStep(ModuleName.TMRobot, sourceSlot[i], ll.Module))
- continue;
- targetSlot.Add(slot);
- }
- if (targetSlot.Count > 0 && targetSlot.All(p => ll.IsReadyForPlace(ModuleName.TMRobot, placeBlade, p)))
- {
- if (_tmRobot.Place(ll.Module, targetSlot.ToArray(), placeBlade, Converter.GetPanAndSlotFromPlace(placeBlade).Item1, 0, 0, false))
- {
- Array.ForEach(wafers, p=> {
- if (p.NextSequenceStep >= tmCycleRoutine.Count - 1)
- p.ProcessState = EnumWaferProcessStatus.Completed;
- });
- ll.WaitTransfer(ModuleName.TMRobot);
- return;
- }
- }
- }
- }
- }
- private void MonitorTmRobotLoadLockPickTask()
- {
- if (!_tmRobot.IsAvailable)
- return;
- //pick from ll
- bool blade1EmptyAndEnable = _tmRobot.Blade1Enable && Converter.MapBladeToSlots(Hand.Blade1).All(p => WaferManager.Instance.CheckNoWafer(ModuleName.TMRobot, p));
- bool blade2EmptyAndEnable = _tmRobot.Blade2Enable && Converter.MapBladeToSlots(Hand.Blade2).All(p => WaferManager.Instance.CheckNoWafer(ModuleName.TMRobot, p));
- if (blade1EmptyAndEnable || blade2EmptyAndEnable)
- {
- Hand pickBlade = blade1EmptyAndEnable ? Hand.Blade1 : Hand.Blade2;
- //if (_tmRobot.Blade1Enable && WaferManager.Instance.CheckNoWafer(ModuleName.TMRobot, 0))
- //{
- // pickBlade = Hand.Blade1;
- //}
- //else if (_tmRobot.Blade2Enable && WaferManager.Instance.CheckNoWafer(ModuleName.TMRobot, 1))
- //{
- // pickBlade = Hand.Blade2;
- //}
- //else
- //{
- // return;
- //}
- foreach (var ll in _lstLls)
- {
- if (!ll.IsAvailable)
- continue;
- var wafers = WaferManager.Instance.GetWafers(ll.Module);
- List<int> slots = new List<int>();
- for (int pickSlot = 0; pickSlot < wafers.Length; pickSlot++)
- {
- if (wafers[pickSlot].NextSequenceStep == 0)
- {
- ModuleName nextModule = ModuleHelper.Converter(tmCycleRoutine[1]);
- if (SC.IsDoubleFork && WaferManager.Instance.GetWafers(nextModule).Any(x => !x.IsEmpty))
- return;
- if (WaferManager.Instance.GetWafers(nextModule).All(x => !x.IsEmpty))
- return;
- }
- if (wafers[pickSlot].ProcessState != EnumWaferProcessStatus.InProcess)
- continue;
- slots.Add(pickSlot);
- if (SC.IsDoubleFork)
- {
- var nextSlot = (pickSlot % 2 > 0) ? pickSlot - 1 : pickSlot + 1;
- if (wafers[nextSlot].ProcessState == EnumWaferProcessStatus.InProcess) slots.Add(nextSlot);
- }
- break;
- }
- if (slots.Count > 0 && slots.All(p=> ll.IsReadyForPick(ModuleName.TMRobot, pickBlade, p)))
- {
- if (_tmRobot.Pick(ll.Module, slots.ToArray(), pickBlade, Converter.GetPanAndSlotFromPick(pickBlade, slots.ToArray()).Item1, 0, 0, false))
- {
- slots.ForEach(p=> wafers[p].NextSequenceStep++);
- ll.WaitTransfer(ModuleName.TMRobot);
- slots.Clear();
- return;
- }
- }
- }
- }
- }
- private void MonitorTMRobotLoadLockTask()
- {
- if (!_tmRobot.IsAvailable)
- return;
- //place to llb
- {
- bool blade1HasWafer = _tmRobot.Blade1Enable && WaferManager.Instance.CheckHasWafer(ModuleName.TMRobot, 0) && WaferManager.Instance.GetWafer(ModuleName.TMRobot, 0).NextStation == (int)ModuleName.LLB;
- bool blade2HasWafer = _tmRobot.Blade2Enable && WaferManager.Instance.CheckHasWafer(ModuleName.TMRobot, 1) && WaferManager.Instance.GetWafer(ModuleName.TMRobot, 1).NextStation == (int)ModuleName.LLB;
- if (blade1HasWafer || blade2HasWafer)
- {
- Hand placeBlade = blade1HasWafer ? Hand.Blade1 : Hand.Blade2;
- var wafer = WaferManager.Instance.GetWafer(ModuleName.TMRobot, (int)placeBlade);
- {
- if (!_loadlockB.IsAvailable)
- return;
- var slot = wafer.OriginSlot;
- if (_loadlockB.IsReadyForPlace(ModuleName.TMRobot, placeBlade, (int)slot))
- {
- if (_tmRobot.Place(_loadlockB.Module, new int[] { (int)slot }, placeBlade, Converter.GetPanAndSlotFromPlace(placeBlade).Item1, 0, 0, false))
- {
- _loadlockB.WaitTransfer(ModuleName.TMRobot);
- return;
- }
- }
- }
- }
- }
- if (!_tmRobot.IsAvailable)
- return;
- //pick from lla
- if (PMAIsInstalled && PMBIsInstalled && WaferManager.Instance.CheckHasWafer(ModuleName.PMA, 0) && WaferManager.Instance.CheckHasWafer(ModuleName.PMA, 1))
- return;
- bool blade1EmptyAndEnable = _tmRobot.Blade1Enable && Converter.MapBladeToSlots(Hand.Blade1).All(p => WaferManager.Instance.CheckNoWafer(ModuleName.TMRobot, p));
- bool blade2EmptyAndEnable = _tmRobot.Blade2Enable && Converter.MapBladeToSlots(Hand.Blade2).All(p => WaferManager.Instance.CheckNoWafer(ModuleName.TMRobot, p));
- if (blade1EmptyAndEnable || blade2EmptyAndEnable)
- {
- Hand pickBlade = blade2EmptyAndEnable? Hand.Blade2: Hand.Blade1;
- //if (_tmRobot.Blade2Enable && WaferManager.Instance.CheckNoWafer(ModuleName.TMRobot, 1))
- //{
- // pickBlade = Hand.Blade2;
- //}
- //else if (_tmRobot.Blade1Enable && WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, 0))
- //{
- // pickBlade = Hand.Blade1;
- //}
- //else
- //{
- // return;
- //}
- {
- if (!_loadlockA.IsAvailable)
- return;
- var wafers = WaferManager.Instance.GetWafers(_loadlockA.Module);
- for (int pickSlot = 0; pickSlot < wafers.Length; pickSlot++)
- {
- if (_loadlockA.IsReadyForPick(ModuleName.TMRobot, pickBlade, pickSlot))
- {
- if (_tmRobot.Pick(_loadlockA.Module, new int[] { pickSlot }, pickBlade, Converter.GetPanAndSlotFromPick(pickBlade, new int[] { pickSlot }).Item1, 0, 0, false))
- {
- _loadlockA.WaitTransfer(ModuleName.TMRobot);
- return;
- }
- }
- }
- }
- }
- }
- private void MonitorTMRobotPMPlaceTask()
- {
- if (!_tmRobot.IsAvailable)
- return;
- //place to pm
- bool blade0HasWafer = _tmRobot.Blade1Enable && Converter.MapBladeToSlots(Hand.Blade1).Any(p=>WaferManager.Instance.CheckHasWafer(ModuleName.TMRobot, p));
- bool blade1HasWafer = _tmRobot.Blade2Enable && Converter.MapBladeToSlots(Hand.Blade2).Any(p=>WaferManager.Instance.CheckHasWafer(ModuleName.TMRobot, p));
- if (blade0HasWafer || blade1HasWafer)
- {
- Hand placeBlade = blade0HasWafer ? Hand.Blade1 : Hand.Blade2;
- var wafer = WaferManager.Instance.GetWafer(ModuleName.TMRobot, (int)placeBlade);
- foreach (var schedulerPm in _lstPms)
- {
- if (!schedulerPm.IsAvailable)
- continue;
- if (!CheckWaferNextStep(ModuleName.TMRobot, (int)placeBlade, schedulerPm.Module))
- continue;
- var pmWafer0 = WaferManager.Instance.GetWafer(schedulerPm.Module, 0);
- var pmWafer1 = WaferManager.Instance.GetWafer(schedulerPm.Module, 1);
- //如果腔体中两片都满了,则不允许放入
- if (!pmWafer0.IsEmpty && !pmWafer1.IsEmpty)
- continue;
- if(WaferManager.Instance.CheckNoWafer(schedulerPm.Module, 0) &&
- WaferManager.Instance.CheckNoWafer(schedulerPm.Module, 1) &&
- SC.IsDoubleFork)
- {
- List<int> targetSlots = new List<int>();
- int[] tmSlots = new int[] { (int)placeBlade, ((int)placeBlade) + 2 };
- for(var i=0;i< tmSlots.Length; i++)
- {
- var tmWafer = WaferManager.Instance.GetWafer(ModuleName.TMRobot, tmSlots[i]);
- if (tmWafer != null && !tmWafer.IsEmpty) targetSlots.Add(i);
- }
- if (_tmRobot.Place(schedulerPm.Module, targetSlots.ToArray(), placeBlade, Converter.GetPanAndSlotFromPlace(placeBlade).Item1, 0, 0, false))
- {
- schedulerPm.WaitTransfer(ModuleName.TMRobot);
- return;
- }
- }
- if (SC.IsDoubleFork) return;
- if (WaferManager.Instance.CheckNoWafer(schedulerPm.Module, 0))
- {
- if (_tmRobot.Place(schedulerPm.Module, new int[] { 0 }, placeBlade, Converter.GetPanAndSlotFromPlace(placeBlade).Item1, 0, 0, false))
- {
- schedulerPm.WaitTransfer(ModuleName.TMRobot);
- return;
- }
- }
- if (WaferManager.Instance.CheckNoWafer(schedulerPm.Module, 1))
- {
- if (_tmRobot.Place(schedulerPm.Module, new int[] { 1 }, placeBlade, Converter.GetPanAndSlotFromPlace(placeBlade).Item1, 0, 0, false))
- {
- schedulerPm.WaitTransfer(ModuleName.TMRobot);
- return;
- }
- }
- }
- }
- }
- private void MonitorTMRobotPMPickTask()
- {
- //pick from pm
- {
- bool blade1Empty = _tmRobot.Blade1Enable && Converter.MapBladeToSlots(Hand.Blade1).All(p => WaferManager.Instance.CheckNoWafer(ModuleName.TMRobot, p));
- bool blade2Empty = _tmRobot.Blade2Enable && Converter.MapBladeToSlots(Hand.Blade2).All(p => WaferManager.Instance.CheckNoWafer(ModuleName.TMRobot, p));
- if (blade1Empty || blade2Empty)
- {
- Hand pickBlade = blade1Empty ? Hand.Blade1 : Hand.Blade2;
- foreach (var pm in _lstPms)
- {
- if (!pm.IsAvailable)
- continue;
- var wafers = WaferManager.Instance.GetWafers(pm.Module);
- List<int> slots = new List<int>();
- for (int slot = 0; slot < wafers.Length; slot++)
- {
- if (pm.IsReadyForPick(ModuleName.TMRobot, pickBlade, slot))
- {
- slots.Add(slot);
- if (!SC.IsDoubleFork || slots.Count > 1) break;
- }
- }
- if (slots != null && slots.Count > 0)
- {
- if (_tmRobot.Pick(pm.Module, slots.ToArray(), pickBlade, Converter.GetPanAndSlotFromPick(pickBlade, slots.ToArray()).Item1, 0, 0, false))
- {
- slots.ForEach(p => wafers[p].NextSequenceStep++);
- pm.WaitTransfer(ModuleName.TMRobot);
- return;
- }
- }
- }
- }
- }
- }
- private void MonitorTMRobotPMTask()
- {
- if (!_tmRobot.IsAvailable)
- return;
- //place to pm
- bool blade0HasWafer = _tmRobot.Blade1Enable && Converter.MapBladeToSlots(Hand.Blade1).Any(p => WaferManager.Instance.CheckHasWafer(ModuleName.TMRobot, p));
- bool blade1HasWafer = _tmRobot.Blade2Enable && Converter.MapBladeToSlots(Hand.Blade2).Any(p => WaferManager.Instance.CheckHasWafer(ModuleName.TMRobot, p));
- if (blade0HasWafer || blade1HasWafer)
- {
- Hand placeBlade = blade0HasWafer ? Hand.Blade1 : Hand.Blade2;
- var wafer = WaferManager.Instance.GetWafer(ModuleName.TMRobot, (int)placeBlade);
- foreach (var schedulerPm in _lstPms)
- {
- if (!schedulerPm.IsAvailable)
- continue;
- if (wafer.NextStation != (int)schedulerPm.Module)
- continue;
- var pmWafer0 = WaferManager.Instance.GetWafer(schedulerPm.Module, 0);
- var pmWafer1 = WaferManager.Instance.GetWafer(schedulerPm.Module, 1);
- //如果腔体中两片都满了,则不允许放入
- if (!pmWafer0.IsEmpty && !pmWafer1.IsEmpty)
- continue;
- if (WaferManager.Instance.CheckNoWafer(schedulerPm.Module, 0))
- {
- if (_tmRobot.Place(schedulerPm.Module, new int[] { 0 }, placeBlade, Converter.GetPanAndSlotFromPlace(placeBlade).Item1, 0, 0, false))
- {
- schedulerPm.WaitTransfer(ModuleName.TMRobot);
- return;
- }
- }
- if (WaferManager.Instance.CheckNoWafer(schedulerPm.Module, 1))
- {
- if (_tmRobot.Place(schedulerPm.Module, new int[] { 1 }, placeBlade, Converter.GetPanAndSlotFromPlace(placeBlade).Item1,0, 0, false))
- {
- schedulerPm.WaitTransfer(ModuleName.TMRobot);
- return;
- }
- }
- }
- }
- if (!_tmRobot.IsAvailable)
- return;
- //pick from pm
- {
- bool blade1Empty = _tmRobot.Blade1Enable && Converter.MapBladeToSlots(Hand.Blade1).All(p => WaferManager.Instance.CheckNoWafer(ModuleName.TMRobot, p));//WaferManager.Instance.CheckNoWafer(ModuleName.TMRobot, 0);
- bool blade2Empty = _tmRobot.Blade2Enable && Converter.MapBladeToSlots(Hand.Blade2).All(p => WaferManager.Instance.CheckNoWafer(ModuleName.TMRobot, p));//WaferManager.Instance.CheckNoWafer(ModuleName.TMRobot, 1);
- if (blade1Empty || blade2Empty)
- {
- Hand pickBlade = blade1Empty ? Hand.Blade1 : Hand.Blade2;
- foreach (var pm in _lstPms)
- {
- if (!pm.IsAvailable)
- continue;
- var wafers = WaferManager.Instance.GetWafers(pm.Module);
- for (int slot = 0; slot < wafers.Length; slot++)
- {
- if (pm.IsReadyForPick(ModuleName.TMRobot, pickBlade, slot))
- {
- if (_tmRobot.Pick(pm.Module, new int[] { slot }, pickBlade, Converter.GetPanAndSlotFromPick(pickBlade, new int[] { slot }).Item1, 0, 0, false))
- {
- wafers[slot].NextSequenceStep++;
- pm.WaitTransfer(ModuleName.TMRobot);
- return;
- }
- }
- }
- }
- }
- }
- }
- private bool MonitorTaskDone()
- {
- foreach (var positions in _checkPosition)
- {
- for (int i = 0; i < positions.Value; i++)
- {
- WaferInfo wafer = WaferManager.Instance.GetWafer(positions.Key, i);
- if (!wafer.IsEmpty)
- {
- return false;
- }
- }
- }
- foreach (var ll in _lstLls)
- {
- var llWafers = WaferManager.Instance.GetWafers(ll.Module);
- for (int i = 0; i < llWafers.Length; i++)
- {
- if (!llWafers[i].IsEmpty && llWafers[i].ProcessState != EnumWaferProcessStatus.Completed)
- return false;
- }
- }
- if (!_tmRobot.IsAvailable)
- return false;
- WaferInfo[] originWafers = WaferManager.Instance.GetWafers(ModuleHelper.Converter(tmCycleRoutine.First()));
- if (cycleCount > 1 && originWafers.All(x => x.IsEmpty || x.ProcessState == EnumWaferProcessStatus.Completed))
- {
- cycleCount--;
- foreach (WaferInfo wafer in originWafers)
- {
- if(!wafer.IsEmpty)
- {
- wafer.NextSequenceStep = 0;
- wafer.ProcessState = EnumWaferProcessStatus.InProcess;
- }
- }
- return false;
- }
- return true;
- }
- private void MonitorPMTask()
- {
- foreach (var pm in _lstPms)
- {
- if (!pm.IsAvailable)
- continue;
- if (pm.Module == ModuleName.PMA && !PMAIsInstalled)
- continue;
- if (pm.Module == ModuleName.PMB && !PMBIsInstalled)
- continue;
- var wafers = WaferManager.Instance.GetWafers(pm.Module);
- int[] slots = new int[] { 0, 1 };
- if(wafers.Any(p=>!p.IsEmpty) && slots.Any(p=> !pm.IsReadyForPick(ModuleName.TMRobot, Hand.Blade1, p)))
- {
- var targetSlots = slots.Where(p=> WaferManager.Instance.CheckHasWafer(pm.Module,p)).ToArray();
- pm.PrepareTransfer(ModuleName.TMRobot, EnumTransferType.Pick, targetSlots);
- return;
- }
- if (wafers.Any(p => p.IsEmpty) && slots.Any(p=> !pm.IsReadyForPlace(ModuleName.TMRobot, Hand.Blade1, p)))
- {
- var targetSlots = slots.Where(p => WaferManager.Instance.CheckNoWafer(pm.Module, p)).ToArray();
- pm.PrepareTransfer(ModuleName.TMRobot, EnumTransferType.Place, targetSlots);
- return;
- }
- }
- }
- private bool CheckWaferNextStep(ModuleName module, int slot, ModuleName nextModule)
- {
- if (!WaferManager.Instance.CheckHasWafer(module, slot))
- return false;
- WaferInfo wafer = WaferManager.Instance.GetWafer(module, slot);
- if (wafer.NextSequenceStep >= tmCycleRoutine.Count)
- return false;
- if (tmCycleRoutine[wafer.NextSequenceStep] != nextModule.ToString())
- return false;
- return true;
- }
- }
- }
|