| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using Aitex.Sorter.Common;
- using Aitex.Core.RT.Log;
- using Aitex.Core.Util;
- using Aitex.Core.RT.DataCenter;
- using Aitex.Core.RT.Fsm;
- using MECF.Framework.Common.Jobs;
- using MECF.Framework.Common.Routine;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.SubstrateTrackings;
- using MECF.Framework.Common.Schedulers;
- using Venus_Core;
- using Venus_RT.Modules.Schedulers;
- using Venus_RT.Scheduler;
- namespace Venus_RT.Modules
- {
- enum ModulePriority
- {
- High,
- Middle,
- Low,
- Stop,
- }
- enum MovingStatus
- {
- Staying,
- Waiting,
- Moving,
- }
- class ModuleFlag
- {
- public ModulePriority Priority { get; set; }
- public MovingStatus MovingStatus { get; set; }
- public ModuleFlag(ModulePriority _priority)
- {
- Priority = _priority;
- MovingStatus = MovingStatus.Staying;
- }
- }
- class AutoCycle : IRoutine
- {
- private List<ControlJobInfo> _lstControlJobs = new List<ControlJobInfo>();
- private List<ProcessJobInfo> _lstProcessJobs = new List<ProcessJobInfo>();
- private RState _cycleState = RState.Init;
- Dictionary<ModuleName, SchedulerModule> _atmSchedulers = new Dictionary<ModuleName, SchedulerModule>();
- Dictionary<ModuleName, ModuleFlag> _atmModules = new Dictionary<ModuleName, ModuleFlag>();
- Dictionary<ModuleName, SchedulerModule> _vacSchedulers = new Dictionary<ModuleName, SchedulerModule>();
- Dictionary<ModuleName, ModuleFlag> _vacModules = new Dictionary<ModuleName, ModuleFlag>();
- SchedulerTMRobot _tmRobot = new SchedulerTMRobot();
- SchedulerEfemRobot _efemRobot = new SchedulerEfemRobot();
- List<SlotItem> _vacReadyOutSlots = new List<SlotItem>();
- List<SlotItem> _vacReadyInSlots = new List<SlotItem>();
- List<SlotItem> _atmReadyOutSlots = new List<SlotItem>();
- List<SlotItem> _atmReadyInSlots = new List<SlotItem>();
- List<int> _LLAInSlot = new List<int> { 0, 1, 2, 3 };
- List<int> _LLAOutSlot = new List<int> { 0, 1, 2, 3 };
- List<int> _LLBInSlot = new List<int> { 0, 1, 2, 3 };
- List<int> _LLBOutSlot = new List<int> { 0, 1, 2, 3 };
- List<MoveItem> _movingItems = new List<MoveItem>();
- List<MoveItem> _efemMovingItems = new List<MoveItem>();
- Dictionary<SlotItem, Guid> _vacWaferTargets = new Dictionary<SlotItem, Guid>();
- Dictionary<SlotItem, Guid> _atmWaferTargets = new Dictionary<SlotItem, Guid>();
- private bool _isCycleMode;
- private int _cycleSetPoint = 0;
- private int _cycledCount = 0;
- private int _cycledWafer = 0;
- #region public interface
- public AutoCycle()
- {
- InitModules();
- DATA.Subscribe("Scheduler.CycledCount", () => _cycledCount);
- DATA.Subscribe("Scheduler.CycledWafer", () => _cycledWafer);
- DATA.Subscribe("Scheduler.CycleSetPoint", () => _cycleSetPoint);
- DATA.Subscribe("Scheduler.PjIdList", () => Array.ConvertAll(_lstProcessJobs.ToArray(), x => x.InnerId.ToString()).ToList());
- }
- public RState Start(params object[] objs)
- {
- _isCycleMode = SC.GetValue<bool>("System.IsCycleMode");
- _cycleSetPoint = _isCycleMode ? SC.GetValue<int>("System.CycleCount") : 0;
- _cycledWafer = 0;
- _cycledCount = 0;
- return RState.Running;
- }
- public RState Monitor()
- {
- prelude();
- driveAtmSystem();
- driveVacSystem();
- epilogue();
- return _cycleState;
- }
- public void Abort()
- {
- }
- public bool CheckAllJobDone()
- {
- foreach (var cj in _lstControlJobs)
- {
- if (cj.State == EnumControlJobState.Executing || cj.State == EnumControlJobState.Paused)
- return false;
- }
- return true;
- }
- public bool CheckJobJustDone(out string sJobName)
- {
- foreach (var cj in _lstControlJobs)
- {
- if (cj.State == EnumControlJobState.Completed && !cj.BeenPosted)
- {
- //LP;WaferSize;Lot;Number;Start;End;
- sJobName = $"{cj.Module};{cj.JobWaferSize};{cj.LotName};{cj.LotWafers.Count};{cj.StartTime:T};{cj.EndTime:T}";
- cj.BeenPosted = true;
- return true;
- }
- }
- sJobName = "NULL";
- return false;
- }
- #endregion
- private void InitModules()
- {
- foreach(var module in new ModuleName[]{ ModuleName.LP1, ModuleName.LP2, ModuleName.LP3,
- ModuleName.Aligner1, ModuleName.Aligner2, ModuleName.Cooling1, ModuleName.Cooling2})
- {
- if(ModuleHelper.IsInstalled(module))
- {
- if(ModuleHelper.IsLoadPort(module))
- {
- _atmSchedulers[module] = new SchedulerLoadPort(module);
- _atmModules[module] = new ModuleFlag(ModulePriority.Middle);
- }
- else if(ModuleHelper.IsAligner(module) || ModuleHelper.IsCooling(module))
- {
- _atmSchedulers[module] = new SchedulerAligner(module);
- _atmModules[module] = new ModuleFlag(ModulePriority.Middle);
- }
- }
- }
- foreach (var module in new ModuleName[] { ModuleName.PMA, ModuleName.PMB, ModuleName.PMC,
- ModuleName.PMD, ModuleName.PME, ModuleName.PMF})
- {
- if (ModuleHelper.IsInstalled(module))
- {
- _vacSchedulers[module] = new SchedulerPM(module);
- _vacModules[module] = new ModuleFlag(ModulePriority.Middle);
- }
- }
- foreach (var module in new ModuleName[] { ModuleName.LLA, ModuleName.LLB })
- {
- if (ModuleHelper.IsInstalled(module))
- {
- var llScheduler = new SchedulerLoadLock(module);
- _vacSchedulers[module] = llScheduler;
- _vacModules[module] = new ModuleFlag(ModulePriority.Middle);
- _atmSchedulers[module] = llScheduler;
- _atmModules[module] = new ModuleFlag(ModulePriority.Middle);
- }
- }
- }
- private void prelude()
- {
- }
- private void epilogue()
- {
- foreach(var mod in _vacSchedulers)
- {
- if(mod.Value.IsAvailable)
- {
- var tars = _vacWaferTargets.Where(item => item.Key.Module == mod.Key).ToArray();
- foreach(var tar in tars)
- {
- var wafer = WaferManager.Instance.GetWafer(tar.Key.Module, tar.Key.Slot);
- if (wafer.IsEmpty)
- continue;
- if(wafer.InnerId == tar.Value)
- {
- // wafer arrive
- _vacWaferTargets.Remove(tar.Key);
- wafer.NextSequenceStep++;
- }
- }
- }
- }
- foreach(var mod in _atmSchedulers)
- {
- if (mod.Value.IsAvailable)
- {
- var tars = _atmWaferTargets.Where(item => item.Key.Module == mod.Key).ToArray();
- foreach (var tar in tars)
- {
- var wafer = WaferManager.Instance.GetWafer(tar.Key.Module, tar.Key.Slot);
- if (wafer.IsEmpty)
- continue;
- if (wafer.InnerId == tar.Value)
- {
- // wafer arrive
- _atmWaferTargets.Remove(tar.Key);
- if (!ModuleHelper.IsLoadPort(tar.Key.Module))
- wafer.NextSequenceStep++;
- }
- }
- }
- }
- }
- private void driveVacSystem()
- {
- PumpingTMRobotTask();
- ProcessTMRobotTask();
- RuningTMRobotTask();
- }
- #region Vacuum System
- private void PumpingTMRobotTask()
- {
- foreach(var mod in _vacSchedulers)
- {
- if (mod.Value.IsAvailable && _vacModules[mod.Key].MovingStatus == MovingStatus.Staying)
- {
- if(ModuleHelper.IsLoadLock(mod.Key))
- {
- var inSlots = mod.Key == ModuleName.LLA ? _LLAInSlot : _LLBInSlot;
- foreach(var slot in inSlots)
- {
- if(WaferManager.Instance.CheckHasWafer(mod.Key, slot) && IsVacWaferReadyOut(mod.Key, slot))
- {
- _vacReadyOutSlots.Add(new SlotItem(mod.Key, slot));
- _vacModules[mod.Key].MovingStatus = MovingStatus.Waiting;
- }
- }
- var outSlots = mod.Key == ModuleName.LLA ? _LLAOutSlot : _LLBOutSlot;
- foreach(var slot in outSlots)
- {
- if(WaferManager.Instance.CheckNoWafer(mod.Key, slot))
- {
- _vacReadyInSlots.Add(new SlotItem(mod.Key, slot));
- _vacModules[mod.Key].MovingStatus = MovingStatus.Waiting;
- }
- }
- }
- else
- {
- if(WaferManager.Instance.CheckHasWafer(mod.Key, 0) && IsVacWaferReadyOut(mod.Key, 0)) // processed?
- {
- _vacReadyOutSlots.Add(new SlotItem(mod.Key, 0));
- _vacModules[mod.Key].MovingStatus = MovingStatus.Waiting;
- }
- else
- {
- _vacReadyInSlots.Add(new SlotItem(mod.Key, 0));
- _vacModules[mod.Key].MovingStatus = MovingStatus.Waiting;
- }
- }
- }
- }
- }
- bool SearchWaferDestination(SlotItem outSlot, out SlotItem destSlot)
- {
- destSlot = new SlotItem(ModuleName.System, -1);
- var wafer = WaferManager.Instance.GetWafer(outSlot.Module, outSlot.Slot);
- foreach (var next_module in wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules)
- {
- var validSlots = GetModuleValidSlots(next_module);
- foreach (var nSlot in validSlots)
- {
- if (_movingItems.Exists(mItem => mItem.DestinationModule == next_module && mItem.DestinationSlot == nSlot))
- continue;
- var ready_in = _vacReadyInSlots.Find(item => item.Module == next_module && item.Slot == nSlot);
- if (ready_in != null)
- {
- destSlot.Module = ready_in.Module;
- destSlot.Slot = nSlot;
- return true;
- }
- }
- }
- return false;
- }
- List<int> GetModuleValidSlots(ModuleName mod)
- {
- var validSlot = new List<int>();
- if(ModuleHelper.IsLoadLock(mod))
- {
- var inSlots = mod == ModuleName.LLA ? _LLAInSlot : _LLBInSlot;
- foreach (var slot in inSlots)
- {
- if (WaferManager.Instance.CheckNoWafer(mod, slot) && !_movingItems.Exists(item => item.DestinationModule == mod && item.DestinationSlot == slot))
- validSlot.Add(slot);
- if (WaferManager.Instance.CheckHasWafer(mod, slot) && _movingItems.Exists(item => item.SourceModule == mod && item.SourceSlot == slot))
- validSlot.Add(slot);
- }
- }
- else if(ModuleHelper.IsPm(mod))
- {
- if (WaferManager.Instance.CheckNoWafer(mod, 0) && !_movingItems.Exists(item => item.DestinationModule == mod))
- validSlot.Add(0);
- if (WaferManager.Instance.CheckHasWafer(mod, 0) && _movingItems.Exists(item => item.SourceModule == mod))
- validSlot.Add(0);
- }
-
- return validSlot.Distinct().ToList();
- }
- List<MoveItem> SearchWaitInSlots(ModuleName inModule)
- {
- List<MoveItem> inSlots = new List<MoveItem>();
- var validSlots = GetModuleValidSlots(inModule);
- foreach(var slot in _vacReadyOutSlots)
- {
- if (slot.Module == inModule)
- continue;
- var wafer = WaferManager.Instance.GetWafer(slot.Module, slot.Slot);
- foreach (var next_module in wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules)
- {
- if(next_module == inModule && validSlots.Count > 0)
- {
- inSlots.Add(new MoveItem(slot.Module, slot.Slot, inModule, validSlots.First(), Hand.None) );
- validSlots.RemoveAt(0);
- }
- }
- }
- return inSlots;
- }
- private void ProcessTMRobotTask()
- {
- if(_tmRobot.IsAvailable)
- {
- if(WaferManager.Instance.CheckHasWafer(ModuleName.TMRobot, 0) || WaferManager.Instance.CheckHasWafer(ModuleName.TMRobot, 1))
- {
- return;
- }
- foreach(var slot in _vacReadyOutSlots)
- {
- if(ModuleHelper.IsLoadLock(slot.Module))
- {
- if(SearchWaferDestination(slot, out SlotItem destSlot))
- {
- _movingItems.Add(new MoveItem(slot.Module, slot.Slot, destSlot.Module, destSlot.Slot, Hand.None));
- // check whether match double pick pattern
- var out_slot_2 = _vacReadyOutSlots.Find(item => item.Module == slot.Module && item.Slot != slot.Slot);
- if (out_slot_2 != null)
- {
- if(SearchWaferDestination(out_slot_2, out SlotItem destSlot_2))
- {
- _movingItems.Add(new MoveItem(out_slot_2.Module, out_slot_2.Slot, destSlot_2.Module, destSlot_2.Slot, Hand.None));
- }
- }
- // check whether match swap pattern
- var in_slots = SearchWaitInSlots(slot.Module);
- foreach(var in_slot in in_slots)
- {
- _movingItems.Add(in_slot);
- }
- return;
- }
- }
- else // PM
- {
- if(SearchWaferDestination(slot, out SlotItem destSlot))
- {
- _movingItems.Add(new MoveItem(slot.Module, slot.Slot, destSlot.Module, destSlot.Slot, Hand.None));
- // check whether match swap pattern
- var in_slots = SearchWaitInSlots(slot.Module);
- if(in_slots.Count >= 1)
- {
- _movingItems.Add(in_slots.First());
- }
- else
- {
- // check whether match double move pattern
- var same_dest = SearchWaitInSlots(destSlot.Module);
- foreach (var item in same_dest)
- {
- _movingItems.Add(item);
- }
- }
- return;
- }
- }
- }
- }
- }
- private void RuningTMRobotTask()
- {
- if(_tmRobot.IsAvailable)
- {
- if(_tmRobot.PostMoveItems(_movingItems.ToArray()))
- {
-
- foreach(var item in _movingItems)
- {
- var wafer = WaferManager.Instance.GetWafer(item.SourceModule, item.SourceSlot);
- if (wafer.IsEmpty)
- {
- // post alarm
- LOG.Write(eEvent.ERR_ROUTER, ModuleName.System, $"Cannot run TM moving task as Get {item.SourceModule}{item.SourceModule} Wafer Info failed");
- return;
- }
- var slot = new SlotItem(item.DestinationModule, item.DestinationSlot);
- _vacWaferTargets[slot] = wafer.InnerId;
- }
- _movingItems.Clear();
- }
- }
- }
- private Hand GetTMRobotFreeHand()
- {
- var blade1HasWafer = WaferManager.Instance.CheckHasWafer(ModuleName.TMRobot, 0);
- var blade2HasWafer = WaferManager.Instance.CheckHasWafer(ModuleName.TMRobot, 1);
- if (blade1HasWafer && blade2HasWafer)
- return Hand.None;
- else if (!blade1HasWafer && !blade2HasWafer)
- return Hand.Both;
- else if (blade1HasWafer)
- return Hand.Blade2;
- else
- return Hand.Blade1;
- }
- private bool IsVacWaferReadyOut(ModuleName mod, int slot)
- {
- var wafer = WaferManager.Instance.GetWafer(mod, slot);
- if (wafer.IsEmpty)
- return false;
- if (wafer.ProcessJob == null || wafer.ProcessJob.Sequence == null)
- return false;
- if (wafer.NextSequenceStep >= wafer.ProcessJob.Sequence.Steps.Count)
- {
- // should not go here
- LOG.Write(eEvent.ERR_ROUTER, ModuleName.System, $"Wafer:{wafer.WaferOrigin} NextSequenceStep {wafer.NextSequenceStep} exceeds {wafer.ProcessJob.Sequence.Name} max steps number");
- return false;
- }
- if (wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules.Contains(mod))
- return false;
- foreach(var module in wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules)
- {
- if (ModuleHelper.IsLoadLock(module) || ModuleHelper.IsPm(module))
- return true;
- }
- return false;
- }
- #endregion Vacuum System
- #region Atm System
- private void driveAtmSystem()
- {
- PumpingEFEMRobotTask();
- RuningEFEMRobotTask();
- }
- private void PumpingEFEMRobotTask()
- {
- if (!_efemRobot.IsAvailable)
- return;
- foreach(var scheduler in _atmSchedulers)
- {
- if (!scheduler.Value.IsAvailable)
- continue;
- if(ModuleHelper.IsLoadLock(scheduler.Key))
- {
- if (ProcessLLEFEMRobotTask(scheduler.Key))
- return;
- }
- else if(ModuleHelper.IsLoadPort(scheduler.Key))
- {
- if (ProcessLPEFEMRobotTask(scheduler.Key))
- return;
- }
- else if(ModuleHelper.IsAligner(scheduler.Key))
- {
- if (ProcessAlignerEFEMRobotTask(scheduler.Key))
- return;
- }
- else if(ModuleHelper.IsCooling(scheduler.Key))
- {
- if (ProcessCoolingEFEMRobotTask(scheduler.Key))
- return;
- }
- else
- {
- // should not go here
- LOG.Write(eEvent.ERR_ROUTER, $"Wrong Module: {scheduler.Key} in ATM System");
- }
- }
- }
- List<int> GetEfemRobotWaferReadyInHands(ModuleName mod)
- {
- var slots = new List<int>();
- for(int i = 0; i < 2; i++)
- {
- var wafer = WaferManager.Instance.GetWafer(ModuleName.EfemRobot, i);
- if (wafer.IsEmpty)
- continue;
- if (wafer.ProcessJob == null || wafer.ProcessJob.Sequence == null)
- continue;
- if (wafer.NextSequenceStep >= wafer.ProcessJob.Sequence.Steps.Count)
- {
- // should not go here
- LOG.Write(eEvent.ERR_ROUTER, ModuleName.System, $"Wafer:{wafer.WaferOrigin} NextSequenceStep {wafer.NextSequenceStep} exceeds {wafer.ProcessJob.Sequence.Name} max steps number");
- continue;
- }
- if (wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules.Contains(mod))
- {
- slots.Add(i);
- }
- }
- return slots;
- }
- bool IsAtmWaferReadyOut(ModuleName mod, int slot)
- {
- var wafer = WaferManager.Instance.GetWafer(mod, slot);
- if (wafer.IsEmpty)
- return false;
- if (wafer.ProcessJob == null || wafer.ProcessJob.Sequence == null)
- return false;
- if (wafer.NextSequenceStep >= wafer.ProcessJob.Sequence.Steps.Count)
- {
- // should not go here
- LOG.Write(eEvent.ERR_ROUTER, ModuleName.System, $"Wafer:{wafer.WaferOrigin} NextSequenceStep {wafer.NextSequenceStep} exceeds {wafer.ProcessJob.Sequence.Name} max steps number");
- return false;
- }
- if (wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules.Contains(mod))
- return false;
- if(ModuleHelper.IsLoadLock(mod))
- {
- foreach (var module in wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules)
- {
- if (ModuleHelper.IsPm(module))
- return false;
- }
- }
- return true;
- }
- private bool ProcessLLEFEMRobotTask(ModuleName ll)
- {
- var robotSlots = GetEfemRobotWaferReadyInHands(ll);
- var inSlots = ll == ModuleName.LLA ? _LLAInSlot : _LLBInSlot;
- foreach(var slot in inSlots)
- {
- if(robotSlots.Count >= 1)
- {
- if(WaferManager.Instance.CheckNoWafer(ll, slot))
- {
- _efemMovingItems.Add(new MoveItem(ModuleName.EfemRobot, robotSlots.First(), ll, slot, (Hand)robotSlots.First()));
- robotSlots.RemoveAt(0);
- }
- }
- }
- var outSlots = ll == ModuleName.LLA ? _LLAOutSlot : _LLBOutSlot;
- foreach(var slot in outSlots)
- {
- if(IsAtmWaferReadyOut(ll, slot))
- {
- var robotHand = GetEFEMRobotFreeHand();
- if(robotHand != Hand.None)
- {
- _efemMovingItems.Add(new MoveItem(ll, slot, ModuleName.EfemRobot, (int)robotHand, robotHand));
- }
- }
- }
- return _efemMovingItems.Count > 0;
- }
- private bool ProcessLPEFEMRobotTask(ModuleName lp)
- {
- // check return
- for(int i = 0; i < 2; i++)
- {
- if(WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, i))
- {
- var returnWafer = WaferManager.Instance.GetWafer(ModuleName.EfemRobot, i);
- if (returnWafer.IsEmpty)
- continue;
- if (returnWafer.ProcessJob == null || returnWafer.ProcessJob.Sequence == null)
- continue;
- if (returnWafer.NextSequenceStep >= returnWafer.ProcessJob.Sequence.Steps.Count && lp == (ModuleName)returnWafer.OriginStation) // need return
- {
- _efemMovingItems.Add(new MoveItem(ModuleName.EfemRobot, i, lp, returnWafer.OriginSlot, (Hand)i));
- }
- }
- }
- if (_efemMovingItems.Count > 0)
- return true;
- var outSlots = GetNextWaferInJobQueue(lp);
- foreach(var slot in outSlots)
- {
- var hand = GetEFEMRobotFreeHand();
- if(hand != Hand.None)
- {
- _efemMovingItems.Add(new MoveItem(lp, slot, ModuleName.EfemRobot, (int)hand, hand));
- }
- }
- return _efemMovingItems.Count > 0;
- }
- private List<int> GetNextWaferInJobQueue(ModuleName lp)
- {
- var inSlots = new List<int>();
- return inSlots;
- //if (GetSystemInnerWaferCount() >= SystemInternalWaferCount || GetBufferWaferCount() > _maxBufferWaferCount)
- // return new SlotItem(ModuleName.System, -1);
- //foreach (var cj in _lstControlJobs)
- //{
- // if (lpModule != ModuleName.System && (cj.Module != lpModule.ToString()))
- // continue;
- // if (cj.State == EnumControlJobState.Executing)
- // {
- // foreach (var pj in _lstProcessJobs)
- // {
- // if (pj.ControlJobName == cj.Name && pj.State == EnumProcessJobState.Processing)
- // {
- // foreach (var pjSlotWafer in pj.SlotWafers)
- // {
- // if (CheckWaferNeedProcessAndPMAvailable(pjSlotWafer.Item1, pjSlotWafer.Item2))
- // {
- // return new SlotItem(pjSlotWafer.Item1, pjSlotWafer.Item2);
- // }
- // }
- // }
- // }
- // }
- //}
- //return new SlotItem(ModuleName.System, -1);
- }
- private bool ProcessAlignerEFEMRobotTask(ModuleName aligner)
- {
- if(WaferManager.Instance.CheckHasWafer(aligner, 0) && IsAtmWaferReadyOut(aligner, 0))
- {
- var hand = GetEFEMRobotFreeHand();
- if(hand != Hand.None)
- {
- _efemMovingItems.Add(new MoveItem(aligner, 0, ModuleName.EfemRobot, (int)hand, hand));
- }
- }
- else
- {
- var robotSlots = GetEfemRobotWaferReadyInHands(aligner);
- if(robotSlots.Count > 0)
- {
- _efemMovingItems.Add(new MoveItem(aligner, 0, ModuleName.EfemRobot, robotSlots.First(), (Hand)robotSlots.First()));
- }
- }
- return _efemMovingItems.Count > 0;
- }
- private bool ProcessCoolingEFEMRobotTask(ModuleName cooling)
- {
- if (WaferManager.Instance.CheckHasWafer(cooling, 0) && IsAtmWaferReadyOut(cooling, 0))
- {
- var hand = GetEFEMRobotFreeHand();
- if (hand != Hand.None)
- {
- _efemMovingItems.Add(new MoveItem(cooling, 0, ModuleName.EfemRobot, (int)hand, hand));
- }
- }
- else
- {
- var robotSlots = GetEfemRobotWaferReadyInHands(cooling);
- if (robotSlots.Count > 0)
- {
- _efemMovingItems.Add(new MoveItem(cooling, 0, ModuleName.EfemRobot, robotSlots.First(), (Hand)robotSlots.First()));
- }
- }
- return _efemMovingItems.Count > 0;
- }
- private void RuningEFEMRobotTask()
- {
- if (_efemRobot.IsAvailable)
- {
- if (_efemRobot.PostMoveItems(_efemMovingItems.ToArray()))
- {
- foreach (var item in _efemMovingItems)
- {
- var wafer = WaferManager.Instance.GetWafer(item.SourceModule, item.SourceSlot);
- if (wafer.IsEmpty)
- {
- // post alarm
- LOG.Write(eEvent.ERR_ROUTER, ModuleName.System, $"Cannot run EFEM moving task as Get {item.SourceModule}{item.SourceModule} Wafer Info failed");
- return;
- }
- var slot = new SlotItem(item.DestinationModule, item.DestinationSlot);
- _atmWaferTargets[slot] = wafer.InnerId;
- }
- _efemMovingItems.Clear();
- }
- }
- }
- private Hand GetEFEMRobotFreeHand()
- {
- for(int i = 0; i < 2; i++)
- {
- if ((WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, i) && !_efemMovingItems.Exists(item => item.DestinationModule == ModuleName.EfemRobot && item.DestinationSlot == i)) ||
- (WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, i) && _efemMovingItems.Exists(item => item.SourceModule == ModuleName.EfemRobot && item.SourceSlot == i)))
- return (Hand)i;
- }
- return Hand.None;
- }
- #endregion Atm System
- }
- }
|