12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Xml;
- using Aitex.Core.Common;
- using Aitex.Core.RT.DataCenter;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Event;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.RecipeCenter;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using Aitex.Sorter.Common;
- using MECF.Framework.Common.DBCore;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.Jobs;
- using MECF.Framework.Common.Schedulers;
- using MECF.Framework.Common.SubstrateTrackings;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.PMs;
- using Virgo_DRT.Modules.Schedulers;
- using Virgo_DRT.Scheduler;
- namespace Virgo_DRT.Modules
- {
- public class AutoTransfer : TransferModule
- {
- private List<ControlJobInfo> _lstControlJobs = new List<ControlJobInfo>();
- private List<ProcessJobInfo> _lstProcessJobs = new List<ProcessJobInfo>();
- //private Object _locker = new Object();
- private List<SchedulerPM> _lstPms = new List<SchedulerPM>();
- private List<SchedulerAligner> _lstBuffers = new List<SchedulerAligner>();
- private List<SchedulerLoadPort> _lstLps = new List<SchedulerLoadPort>();
-
- private const string LogSource = "Scheduler";
- private bool _isCycleMode;
- private int _cycleSetPoint = 0;
- private int _cycledCount = 0;
- private int _cycledWafer = 0;
- private bool _isInParallelMode;
- private Dictionary<ModuleName, ModuleName> _mapLpPm = new Dictionary<ModuleName, ModuleName>();
- private Dictionary<ModuleName, ModuleName> _mapLpAligner = new Dictionary<ModuleName, ModuleName>();
- private List<ModuleName> _mapTarget = new List<ModuleName>();
- public bool HasJobRunning
- {
- get { return _lstControlJobs.Count > 0; }
- }
- public AutoTransfer()
- {
- if (SC.GetValue<bool>("System.PMAIsInstalled"))
- _lstPms.Add(_pma);
- if (SC.GetValue<bool>("System.PMBIsInstalled"))
- _lstPms.Add(_pmb);
- _lstBuffers.AddRange(new[] { _buffer1, _buffer2 });
- _lstLps.AddRange(new[] { _lp1, _lp2 });
- 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());
- DATA.Subscribe("LP1.LocalJobName", () =>
- {
- if (_lstControlJobs.Exists(x => x.Name == "CJ_Local_LP1"))
- return "CJ_Local_LP1";
- return "";
- });
- DATA.Subscribe("LP1.LocalJobStatus", () =>
- {
- var jb = _lstControlJobs.Find(x => x.Name == "CJ_Local_LP1");
- if (jb != null)
- return jb.State.ToString();
- return "";
- });
- DATA.Subscribe("LP2.LocalJobName", () =>
- {
- if (_lstControlJobs.Exists(x => x.Name == "CJ_Local_LP2"))
- return "CJ_Local_LP2";
- return "";
- });
- DATA.Subscribe("LP2.LocalJobStatus", () =>
- {
- var jb = _lstControlJobs.Find(x => x.Name == "CJ_Local_LP2");
- if (jb != null)
- return jb.State.ToString();
- return "";
- });
- }
- public void Clear()
- {
- _efemRobot.ResetTask();
- foreach (var pm in _lstPms)
- {
- pm.ResetTask();
- }
- foreach (var buffer in _lstBuffers)
- {
- buffer.ResetTask();
- }
- foreach (var lp in _lstLps)
- {
- lp.ResetTask();
- }
-
- _lstControlJobs.Clear();
- _lstProcessJobs.Clear();
- _mapLpAligner.Clear();
- _mapLpPm.Clear();
- _isInParallelMode = false;
- _mapTarget.Clear();
- }
- #region Job Management
- public void CreateJob(Dictionary<string, object> param)
- {
- string[] slotSequence = (string[])param["SlotSequence"];
- string jobId = (string)param["JobId"];
- string module = (string)param["Module"];
- bool autoStart = (bool)param["AutoStart"];
- if (slotSequence.Length != 25)
- {
- EV.PostWarningLog(LogSource, $"slot sequence parameter not valid, length is {slotSequence.Length}, should be 25");
- return;
- }
- if (!ModuleHelper.IsLoadPort(ModuleHelper.Converter(module)))
- {
- EV.PostWarningLog(LogSource, $"{module} should be LoadPort");
- return;
- }
- if (string.IsNullOrEmpty(jobId))
- {
- jobId = "CJ_Local_" + module;
- }
- if (_lstControlJobs.Exists(x => x.Name == jobId))
- {
- EV.PostWarningLog(LogSource, $"{jobId} already created");
- return;
- }
- SchedulerLoadPort lp = GetModule(module) as SchedulerLoadPort;
- if (!lp.CheckReadyRunJob())
- {
- EV.PostWarningLog(LogSource, $"{module} not ready");
- return;
- }
- ControlJobInfo cj = new ControlJobInfo();
- cj.Name = jobId;
- cj.Module = module;
- cj.SetState(EnumControlJobState.WaitingForStart);
- Dictionary<string, bool[]> seqSlot = new Dictionary<string, bool[]>();
- Dictionary<string, List<Tuple<ModuleName, int>>> seqSlotWafers = new Dictionary<string, List<Tuple<ModuleName, int>>>();
- Dictionary<string, string> indexSequence = new Dictionary<string, string>();
- bool enableGroupBySequence = SC.GetValue<bool>("Scheduler.GroupWaferBySequence");
- for (int i = 0; i < 25; i++)
- {
- if (string.IsNullOrEmpty(slotSequence[i]) || string.IsNullOrEmpty(slotSequence[i].Trim()))
- continue;
- string groupName = enableGroupBySequence ? slotSequence[i].Trim() : i.ToString();
- indexSequence[groupName] = slotSequence[i];
- if (!seqSlot.ContainsKey(groupName))
- {
- seqSlot[groupName] = new bool[25];
- }
- if (!seqSlotWafers.ContainsKey(groupName))
- {
- seqSlotWafers[groupName] = new List<Tuple<ModuleName, int>>();
- }
- seqSlot[groupName][i] = true;
- if (!WaferManager.Instance.CheckHasWafer(module, i))
- {
- EV.PostWarningLog(LogSource, $"job wafer: {module} slot {i + 1} not in the carrier");
- return;
- }
- if (!WaferManager.Instance.CheckWafer(ModuleHelper.Converter(module), i, WaferStatus.Normal))
- {
- EV.PostWarningLog(LogSource, $"job wafer: {module} slot {i + 1} status is {WaferManager.Instance.GetWafer(ModuleHelper.Converter(module), i).Status}");
- return;
- }
- if (WaferManager.Instance.GetWafer(ModuleHelper.Converter(module), i).ProcessState != EnumWaferProcessStatus.Idle)
- {
- EV.PostWarningLog(LogSource, $"job wafer: {module} slot {i + 1} process status is {WaferManager.Instance.GetWafer(ModuleHelper.Converter(module), i).ProcessState}");
- return;
- }
- //特殊场景,3寸片第一片不能取放
- if (i ==0 && (WaferManager.Instance.GetWafer(ModuleHelper.Converter(module), i).Size==WaferSize.WS3))
- {
- EV.PostWarningLog(LogSource, $"job wafer: {module} 3 inch slot {i + 1} is not supported.");
- return;
- }
- seqSlotWafers[groupName].Add(Tuple.Create(ModuleHelper.Converter(module), i));
- }
- if (seqSlotWafers.Count == 0)
- {
- EV.PostWarningLog(LogSource, $"job has not assign wafer");
- return;
- }
- List<ProcessJobInfo> pjs = new List<ProcessJobInfo>();
- string[] seqs = seqSlot.Keys.ToArray();
- for (int i = 0; i < seqs.Length; i++)
- {
- ProcessJobInfo pj = new ProcessJobInfo();
- pj.Name = jobId + "_" + (i + 1);
- pj.Sequence = SequenceInfoHelper.GetInfo(indexSequence[seqs[i]]);
- pj.ControlJobName = cj.Name;
- pj.SlotWafers = seqSlotWafers[seqs[i]];
- pj.SetState(EnumProcessJobState.Queued);
- if (!CheckSequencePmReady(pj.Sequence, out string reason))
- {
- EV.PostWarningLog(LogSource, $"no valid chamber for the {reason}");
- return;
- }
- if (!SC.GetValue<bool>("System.IsATMMode") && !CheckSequenceRecipeFileValid(pj.Sequence, out reason))
- {
- EV.PostWarningLog(LogSource, $"recipe file not valid in the sequence, {reason}");
- return;
- }
- if (!SetSequenceTemperatureInfo(pj.Sequence, out reason))
- {
- EV.PostWarningLog(LogSource, $"sequence recipe temperature not valid, {reason}");
- return;
- }
-
- pjs.Add(pj);
- }
- foreach (var pj in pjs)
- {
- cj.ProcessJobNameList.Add(pj.Name);
- _lstProcessJobs.Add(pj);
- }
- _lstControlJobs.Add(cj);
- UpdateParallelMode();
- }
-
- internal void StopJob(string jobName)
- {
- ControlJobInfo cj = _lstControlJobs.Find(x => x.Name == jobName);
- if (cj == null)
- {
- EV.PostWarningLog(LogSource, $"stop job rejected, not found job with id {jobName}");
- return;
- }
- foreach (var pj in _lstProcessJobs)
- {
- if (pj.ControlJobName == cj.Name)
- {
- pj.SetState(EnumProcessJobState.Stopping);
- }
- }
- }
- internal void AbortJob(string jobName)
- {
- ControlJobInfo cj = _lstControlJobs.Find(x => x.Name == jobName);
- if (cj == null)
- {
- EV.PostWarningLog(LogSource, $"abort job rejected, not found job with id {jobName}");
- return;
- }
- List<ProcessJobInfo> pjAbortList = new List<ProcessJobInfo>();
- foreach (var pj in _lstProcessJobs)
- {
- if (pj.ControlJobName == cj.Name)
- {
- pj.SetState(EnumProcessJobState.Aborting);
- pjAbortList.Add(pj);
- int unprocessed = 0;
- int aborted = 0;
- WaferInfo[] wafers = WaferManager.Instance.GetWaferByProcessJob(pj.Name);
- foreach (var waferInfo in wafers)
- {
- waferInfo.ProcessJob = null;
- waferInfo.NextSequenceStep = 0;
- if (waferInfo.ProcessState != EnumWaferProcessStatus.Completed)
- unprocessed++;
- }
- JobDataRecorder.EndPJ(pj.InnerId.ToString(), aborted, unprocessed);
- }
- }
- foreach (var pj in pjAbortList)
- {
- _lstProcessJobs.Remove(pj);
- }
- _lstControlJobs.Remove(cj);
- }
- public void ResumeJob(string jobName)
- {
- ControlJobInfo cj = _lstControlJobs.Find(x => x.Name == jobName);
- if (cj == null)
- {
- EV.PostWarningLog(LogSource, $"resume job rejected, not found job with id {jobName}");
- return;
- }
- if (cj.State == EnumControlJobState.Paused)
- {
- cj.SetState(EnumControlJobState.Executing);
- }
- }
- internal void StartJob(string jobName)
- {
- ControlJobInfo cj = _lstControlJobs.Find(x => x.Name == jobName);
- if (cj == null)
- {
- EV.PostWarningLog(LogSource, $"start job rejected, not found job with id {jobName}");
- return;
- }
- if (cj.State == EnumControlJobState.WaitingForStart)
- {
- cj.SetState(EnumControlJobState.Executing);
- }
- }
- internal void PauseJob(string jobName)
- {
- ControlJobInfo cj = _lstControlJobs.Find(x => x.Name == jobName);
- if (cj == null)
- {
- EV.PostWarningLog(LogSource, $"pause job rejected, not found job with id {jobName}");
- return;
- }
- if (cj.State == EnumControlJobState.Executing)
- {
- cj.SetState(EnumControlJobState.Paused);
- }
- }
- internal void Map(string moduleName)
- {
- ModuleName target = ModuleHelper.Converter(moduleName);
- if (!ModuleHelper.IsLoadPort(target))
- {
- EV.PostWarningLog(LogSource, $"Invalid map target {target}");
- return;
- }
- if (!_mapTarget.Contains(target))
- {
- _mapTarget.Add(target);
- }
- }
- #endregion Job Management
- public Result Start(params object[] objs)
- {
- _isCycleMode = SC.GetValue<bool>("System.IsCycleMode");
- _cycleSetPoint = _isCycleMode ? SC.GetValue<int>("System.CycleCount") : 0;
- _cycledWafer = 0;
- _cycledCount = 0;
- bool hasPmOnline = false;
- foreach (var schedulerPm in _lstPms)
- {
- if (schedulerPm.IsAvailable)
- {
- schedulerPm.SetPMAuto();
- hasPmOnline = true;
- continue;
- }
- }
- if (!hasPmOnline)
- {
- EV.PostWarningLog("Scheduler", "can not change to auto mode, at least one process chamber be online");
- return Result.FAIL;
- }
- return Result.RUN;
- }
- public Result Monitor()
- {
- ControlJobInfo cjActive = _lstControlJobs.Find(x => x.State == EnumControlJobState.Executing);
- if (cjActive != null)
- {
- MonitorModuleTasks();
- }
- MonitorJobTasks();
- return Result.RUN;
- }
- #region Job task
- public Result MonitorJobTasks()
- {
- UpdateParallelMode();
- UpdateProcessJobStatus();
- UpdateControlJobStatus();
- StartNewJob();
- return Result.RUN;
- }
- private void UpdateParallelMode()
- {
- bool isParallel = SC.GetValue<bool>("Scheduler.IsRunInParallelMode");
- bool bothLpHasJob = true;
- Dictionary<ModuleName, Dictionary<ModuleName, float>> lpNeededPmTemperature = new Dictionary<ModuleName, Dictionary<ModuleName, float>>();
- foreach (var lp in _lstLps)
- {
- var cj = _lstControlJobs.Find(x => x.Module == lp.Module.ToString());
- bothLpHasJob = bothLpHasJob && (cj != null);
- if (cj != null)
- {
- lpNeededPmTemperature[lp.Module] = new Dictionary<ModuleName, float>();
- var pj = _lstProcessJobs.FirstOrDefault(x => x.ControlJobName == cj.Name);
- if (pj != null)
- {
- var seq = pj.Sequence;
- for (int i = 0; i < seq.Steps.Count; i++)
- {
- SequenceStepInfo stepInfo = seq.Steps[i];
- foreach (var module in stepInfo.StepModules)
- {
- if (ModuleHelper.IsPm(module) && !lpNeededPmTemperature[lp.Module].ContainsKey(module))
- {
- lpNeededPmTemperature[lp.Module][module] = (float) seq.Steps[i]
- .StepParameter[module == ModuleName.PMA ? "PMATemp" : "PMBTemp"];
- }
- }
- }
- }
- }
- }
- bool needSamePm = false;
- ModuleName pmSource = ModuleName.System;
- foreach (var pmNeeded in lpNeededPmTemperature)
- {
- if (pmNeeded.Value.Count == 1)
- {
- var source = pmNeeded.Value.Keys.First();
- if (source != pmSource)
- {
- pmSource = source;
- }
- else
- {
- needSamePm = true;
- break;
- }
- }
- }
-
- var needParallel = isParallel && bothLpHasJob && !needSamePm;
- if (needParallel != _isInParallelMode)
- {
- _isInParallelMode = needParallel;
- if (needParallel)
- {
- //aligner固定不做逻辑
- _mapLpAligner[ModuleName.LP1] = ModuleName.Aligner1;
- _mapLpAligner[ModuleName.LP2] = ModuleName.Aligner2;
- bool assigned =false;
- foreach (var pmNeeded in lpNeededPmTemperature)
- {
- if (pmNeeded.Value.Count == 1)
- {
- _mapLpPm[pmNeeded.Key] = pmNeeded.Value.Keys.First();
- var anotherLp = pmNeeded.Key == ModuleName.LP1 ? ModuleName.LP2 : ModuleName.LP1;
- var anotherPm = _mapLpPm[pmNeeded.Key]== ModuleName.PMA ? ModuleName.PMB : ModuleName.PMA;
- _mapLpPm[anotherLp] = anotherPm;
- assigned = true;
- break;
- }
- }
- if (!assigned)
- {
- _mapLpPm[ModuleName.LP1] = ModuleName.PMA;
- _mapLpPm[ModuleName.LP2] = ModuleName.PMB;
- float pmaTemp = ((SchedulerPM) GetModule(ModuleName.PMA.ToString())).Temperature;
- float pmbTemp = ((SchedulerPM)GetModule(ModuleName.PMB.ToString())).Temperature;
- float tempCurrent = Math.Abs(lpNeededPmTemperature[ModuleName.LP1][ModuleName.PMA] - pmaTemp)
- + Math.Abs(lpNeededPmTemperature[ModuleName.LP2][ModuleName.PMB] - pmbTemp);
- float tempAnother = Math.Abs(lpNeededPmTemperature[ModuleName.LP1][ModuleName.PMB] - pmbTemp)
- + Math.Abs(lpNeededPmTemperature[ModuleName.LP2][ModuleName.PMA] - pmaTemp);
- if (tempAnother < tempCurrent)
- {
- _mapLpPm[ModuleName.LP1] = ModuleName.PMB;
- _mapLpPm[ModuleName.LP2] = ModuleName.PMA;
- }
- }
- }
- }
- }
- private void UpdateProcessJobStatus()
- {
- foreach (var pj in _lstProcessJobs)
- {
- if (pj.State == EnumProcessJobState.Processing)
- {
- if (CheckAllWaferReturned(pj, true) )
- {
- pj.SetState(EnumProcessJobState.ProcessingComplete);
- JobDataRecorder.EndPJ(pj.InnerId.ToString(), 0, 0);
- }
- }
- else if (pj.State == EnumProcessJobState.Stopping)
- {
- if (CheckAllWaferReturned(pj, false) )
- {
- pj.SetState(EnumProcessJobState.ProcessingComplete);
- JobDataRecorder.EndPJ(pj.InnerId.ToString(), 0, 0);
- }
- }
- }
- }
- private void UpdateControlJobStatus()
- {
- if (_lstControlJobs.Count == 0)
- return;
- bool allControlJobComplete = true;
- List<ControlJobInfo> cjRemoveList = new List<ControlJobInfo>();
- foreach (var cj in _lstControlJobs)
- {
- if (cj.State == EnumControlJobState.Executing)
- {
- bool allPjCompleted = true;
- foreach (var pjName in cj.ProcessJobNameList)
- {
- var pj = _lstProcessJobs.Find(x => x.Name == pjName);
- if (pj == null)
- {
- LOG.Error($"Not find pj named {pjName} in {cj.Name}");
- continue;
- }
- if (pj.State != EnumProcessJobState.Complete && pj.State != EnumProcessJobState.ProcessingComplete)
- {
- allPjCompleted = false;
- break;
- }
- }
- if (allPjCompleted)
- {
- cj.SetState(EnumControlJobState.Completed);
- }
- }
-
- LoadportCassetteState state = (LoadportCassetteState)DATA.Poll($"{cj.Module}.CassetteState");
- if (cj.State == EnumControlJobState.Completed && state != LoadportCassetteState.Normal)
- {
- cjRemoveList.Add(cj);
- }
- allControlJobComplete = allControlJobComplete && cj.State == EnumControlJobState.Completed;
- }
- if (_isCycleMode && _cycledCount < _cycleSetPoint)
- {
- int countPerCycle = 0;
- int countProcessed = 0;
- foreach (var pj in _lstProcessJobs)
- {
- foreach (var pjSlotWafer in pj.SlotWafers)
- {
- countPerCycle++;
- WaferInfo wafer = WaferManager.Instance.GetWafer(pjSlotWafer.Item1, pjSlotWafer.Item2);
- if (!wafer.IsEmpty && !CheckWaferNeedProcess(pjSlotWafer.Item1, pjSlotWafer.Item2))
- countProcessed++;
- }
- }
- _cycledWafer = _cycledCount * countPerCycle + countProcessed;
- if (allControlJobComplete)
- {
- _cycledCount++;
- if (_cycledCount < _cycleSetPoint)
- {
- foreach (var cj in _lstControlJobs)
- {
- cj.SetState(EnumControlJobState.Executing);
- }
- foreach (var pj in _lstProcessJobs)
- {
- pj.SetState(EnumProcessJobState.Queued);
- pj.InnerId = Guid.NewGuid();
- foreach (var pjSlotWafer in pj.SlotWafers)
- {
- WaferInfo wafer = WaferManager.Instance.GetWafer(pjSlotWafer.Item1, pjSlotWafer.Item2);
- wafer.ProcessJob = null;
- wafer.NextSequenceStep = 0;
- wafer.ProcessState = EnumWaferProcessStatus.Idle;
- }
- }
- }
- }
- }
- foreach (var cj in cjRemoveList)
- {
- List<ProcessJobInfo> pjRemoveList = new List<ProcessJobInfo>();
- foreach (var pj in _lstProcessJobs)
- {
- if (pj.ControlJobName == cj.Name)
- pjRemoveList.Add(pj);
- }
- foreach (var pj in pjRemoveList)
- {
- _lstProcessJobs.Remove(pj);
- }
- _lstControlJobs.Remove(cj);
- }
- if (cjRemoveList.Count > 0)
- {
- UpdateParallelMode();
- }
- }
- private void StartNewJob()
- {
- ControlJobInfo cjActived = null;
- foreach (var cj in _lstControlJobs)
- {
- if (cj.State == EnumControlJobState.Executing)
- {
- cjActived = cj;
- foreach (var pjName in cjActived.ProcessJobNameList)
- {
- var pj = _lstProcessJobs.Find(x => x.Name == pjName);
- if (pj == null)
- {
- LOG.Error($"Not find pj named {pjName} in {cjActived.Name}");
- continue;
- }
- if (pj.State == EnumProcessJobState.Queued)
- {
- ActiveProcessJob(pj);
- break;
- }
- }
- if (!_isInParallelMode)
- break;
- }
- }
- }
- private bool ActiveProcessJob(ProcessJobInfo pj)
- {
- //pm is ok
- if (!CheckSequencePmReady( pj.Sequence, out string reason))
- {
- EV.PostWarningLog(LogSource, $"can not active {pj.Name}, {reason}");
- return false;
- }
-
- foreach (var pjSlotWafer in pj.SlotWafers)
- {
- WaferInfo wafer = WaferManager.Instance.GetWafer(pjSlotWafer.Item1, pjSlotWafer.Item2);
- wafer.ProcessJob = pj;
- wafer.NextSequenceStep = 0;
- WaferDataRecorder.SetPjInfo(wafer.InnerId.ToString(), pj.InnerId.ToString());
- }
- ControlJobInfo cj = _lstControlJobs.Find(x => x.Name == pj.ControlJobName);
- CarrierInfo carrier = CarrierManager.Instance.GetCarrier(cj.Module);
- JobDataRecorder.StartPJ(pj.InnerId.ToString(), carrier.InnerId.ToString(), cj.InnerId.ToString(), pj.Name, cj.Module, cj.Module, pj.SlotWafers.Count);
- pj.SetState(EnumProcessJobState.Processing);
- return true;
- }
- #endregion Job task
- #region Module task
- public Result MonitorModuleTasks()
- {
- MonitorPMTask();
- MonitorEfemRobotTask();
-
- MonitorBufferTask();
- return Result.RUN;
- }
-
- private void MonitorBufferTask()
- {
- foreach (var schedulerBuffer in _lstBuffers)
- {
- if (!schedulerBuffer.IsAvailable
- || WaferManager.Instance.CheckNoWafer(schedulerBuffer.Module, 0)
- )
- continue;
- if (CheckWaferNextStepIsAlign(schedulerBuffer.Module, 0))
- {
- WaferInfo wafer = WaferManager.Instance.GetWafers(schedulerBuffer.Module)[0];
- var job = wafer.ProcessJob;
- GetWaferSequenceAlignTime(schedulerBuffer.Module, 0, out float time);
- if (schedulerBuffer.Align(time))
- {
- wafer.NextSequenceStep++;
- }
- }
- }
- }
- private void MonitorEfemRobotTask()
- {
- if (!_efemRobot.IsAvailable)
- return;
- //efem robot is idle, release all the target
- foreach (var pm in _lstPms)
- {
- if (pm.IsWaitTransfer(ModuleName.EfemRobot))
- {
- pm.PostTransfer(ModuleName.EfemRobot);
- }
- }
- foreach (var buffer in _lstBuffers)
- {
- if (buffer.IsWaitTransfer(ModuleName.EfemRobot))
- {
- buffer.PostTransfer(ModuleName.EfemRobot);
- }
- }
- foreach (var lp in _lstLps)
- {
- if (lp.IsWaitTransfer(ModuleName.EfemRobot))
- {
- lp.PostTransfer(ModuleName.EfemRobot);
- }
- }
- MonitorEfemRobotMapTask();
- if (!_efemRobot.IsAvailable)
- return;
- MonitorEfemRobotPMTask();
- if (!_efemRobot.IsAvailable)
- return;
- MonitorEfemRobotBufferTask();
- if (!_efemRobot.IsAvailable)
- return;
- MonitorEfemRobotLoadPortTask();
- }
- private void MonitorEfemRobotMapTask()
- {
- if (!_efemRobot.IsAvailable)
- return;
- if (_mapTarget.Count > 0)
- {
- ModuleName first = _mapTarget[0];
- SchedulerLoadPort lp = GetModule(first.ToString()) as SchedulerLoadPort;
- if (lp != null && lp.IsAvailable)
- {
- _efemRobot.Map(first);
- _mapTarget.Remove(first);
- }
- }
- }
- private void MonitorEfemRobotPMTask()
- {
- if (!_efemRobot.IsAvailable)
- return;
- //place to pm
- if (WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, 0) &&
- CheckWaferNeedProcess(ModuleName.EfemRobot, 0) && !CheckWaferNeedAlign(ModuleName.EfemRobot,0))
- {
- foreach (var pm in _lstPms)
- {
- if (!pm.IsAvailable || !WaferManager.Instance.CheckNoWafer(pm.Module, 0) )
- continue;
- if (_isInParallelMode && GetWaferCountOutofLP(ModuleName.LP1) <= 1 && GetWaferCountOutofLP(ModuleName.LP2) <= 1)
- {
- int origin = WaferManager.Instance.GetWafer(ModuleName.EfemRobot, 0).OriginStation;
- if (origin == (int)ModuleName.LP1 && _mapLpPm[ModuleName.LP1] != pm.Module)
- continue;
- if (origin == (int)ModuleName.LP2 && _mapLpPm[ModuleName.LP2] != pm.Module)
- continue;
- }
- if ( !pm.IsReadyForPlace(ModuleName.EfemRobot, 0))
- continue;
- if (_efemRobot.Place(pm.Module, 0, Hand.Blade1))
- {
- pm.WaitTransfer(ModuleName.EfemRobot, EnumTransferType.Place, 0);
- return;
- }
- }
- }
- if (!_efemRobot.IsAvailable)
- return;
- //pick from pm
- if (WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, 0) )
- {
- ModuleName pickPm = ModuleName.System;
- int waferOriginSlot = int.MaxValue;
- foreach (var schedulerPm in _lstPms)
- {
- if (!schedulerPm.IsAvailable
- || WaferManager.Instance.CheckNoWafer(schedulerPm.Module, 0)
- || CheckWaferNeedProcess(schedulerPm.Module, 0, schedulerPm.Module) )
- continue;
- WaferInfo wafer = WaferManager.Instance.GetWafer(schedulerPm.Module, 0);
- bool pickAllowed = CheckVacuumWaferHasAvailableTarget(schedulerPm.Module, 0);
- if (pickAllowed)
- {
- int slot = wafer.OriginSlot;
- if (slot < waferOriginSlot)
- {
- waferOriginSlot = slot;
- pickPm = schedulerPm.Module;
- }
- }
- }
- if (pickPm != ModuleName.System)
- {
- SchedulerModule pm = GetModule(pickPm.ToString());
- if (pm.IsReadyForPick(ModuleName.EfemRobot, 0))
- {
- if (_efemRobot.Pick(pm.Module, 0, Hand.Blade1))
- {
- pm.WaitTransfer(ModuleName.EfemRobot, EnumTransferType.Pick, 0);
- return;
- }
- }
- }
- }
- }
- private void MonitorEfemRobotLoadPortTask()
- {
- if (!_efemRobot.IsAvailable)
- return;
- //pick
- if (_isInParallelMode)
- {
- int outWaferLp1 = GetWaferCountOutofLP(ModuleName.LP1);
- int outWaferLp2 = GetWaferCountOutofLP(ModuleName.LP2);
- if (outWaferLp1 <= GetMaxOutWafer() && outWaferLp2 <= GetMaxOutWafer())
- {
- foreach (var lp in _lstLps)
- {
- if (GetWaferCountOutofLP(lp.Module) >= GetMaxOutWafer())
- continue;
- if (GetWaferCountInJobQueue(lp.Module) > 0 && WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, 0))
- {
- SlotItem position = GetNextWaferInJobQueue(lp.Module);
- if (position != null && CheckWaferPmTemperatureIsOk(position.Module, position.Slot))
- {
- if (lp.IsReadyForPick(ModuleName.EfemRobot, position.Slot))
- {
- if (_efemRobot.Pick(position.Module, position.Slot, Hand.Blade1))
- {
- lp.WaitTransfer(ModuleName.EfemRobot, EnumTransferType.Pick, position.Slot);
- return;
- }
- }
- }
- }
- }
- }
- }
- else
- {
- if (GetWaferCountOutofLP(ModuleName.System) < GetMaxOutWafer() && GetWaferCountInJobQueue(ModuleName.System) > 0 &&
- WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, 0))
- {
- SlotItem position = GetNextWaferInJobQueue(ModuleName.System);
- if (position != null && CheckWaferPmTemperatureIsOk(position.Module, position.Slot))
- {
- SchedulerLoadPort lp = (SchedulerLoadPort)GetModule(position.Module.ToString());
- if (lp.IsReadyForPick(ModuleName.EfemRobot, position.Slot))
- {
- if (_efemRobot.Pick(position.Module, position.Slot, Hand.Blade1))
- {
- lp.WaitTransfer(ModuleName.EfemRobot, EnumTransferType.Pick, position.Slot);
- return;
- }
- }
- }
- }
- }
- if (!_efemRobot.IsAvailable)
- return;
- //place
- if (WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, 0) &&
- !CheckWaferNeedProcess(ModuleName.EfemRobot, 0))
- {
- SlotItem destination = GetWaferReturnLoadPort(_efemRobot.Module, 0);
- if (destination != null)
- {
- SchedulerLoadPort lp = (SchedulerLoadPort)GetModule(destination.Module.ToString());
- if (lp.IsReadyForPlace(ModuleName.EfemRobot, destination.Slot))
- {
- if (_efemRobot.Place(destination.Module, destination.Slot, Hand.Blade1))
- {
- lp.WaitTransfer(ModuleName.EfemRobot, EnumTransferType.Place, destination.Slot);
- return;
- }
- }
- }
- }
- }
- private void MonitorEfemRobotBufferTask()
- {
- if (!_efemRobot.IsAvailable)
- return;
-
- //place to buffer
- if (WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, 0) &&
- CheckWaferNeedAlign(ModuleName.EfemRobot, 0))
- {
- foreach (var buffer in _lstBuffers)
- {
- if (!buffer.IsAvailable || !WaferManager.Instance.CheckNoWafer(buffer.Module, 0))
- continue;
- if (_isInParallelMode && GetWaferCountOutofLP(ModuleName.LP1)<=1 && GetWaferCountOutofLP(ModuleName.LP2) <= 1)
- {
- int origin = WaferManager.Instance.GetWafer(ModuleName.EfemRobot, 0).OriginStation;
- if (origin == (int)ModuleName.LP1 && _mapLpAligner[ModuleName.LP1] != buffer.Module)
- continue;
- if (origin == (int)ModuleName.LP2 && _mapLpAligner[ModuleName.LP2] != buffer.Module)
- continue;
- }
- if (!buffer.IsReadyForPlace(ModuleName.EfemRobot, 0))
- continue;
- if (_efemRobot.Place(buffer.Module, 0, Hand.Blade1))
- {
- buffer.WaitTransfer(ModuleName.EfemRobot, EnumTransferType.Place, 0);
- return;
- }
- }
- }
- if (!_efemRobot.IsAvailable)
- return;
- //pick from buffer
- if (WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, 0))
- {
- ModuleName pickBuffer = ModuleName.System;
- int waferOriginSlot = int.MaxValue;
- foreach (var schedulerBuffer in _lstBuffers)
- {
- if (!schedulerBuffer.IsAvailable
- || WaferManager.Instance.CheckNoWafer(schedulerBuffer.Module, 0)
- || CheckWaferNeedAlign(schedulerBuffer.Module, 0 ))
- continue;
- WaferInfo wafer = WaferManager.Instance.GetWafer(schedulerBuffer.Module, 0);
- bool pickAllowed = CheckBufferWaferHasAvailableTarget(schedulerBuffer.Module, 0);
- if (pickAllowed)
- {
- int slot = wafer.OriginSlot;
- if (slot < waferOriginSlot)
- {
- waferOriginSlot = slot;
- pickBuffer = schedulerBuffer.Module;
- }
- }
- }
- if (pickBuffer != ModuleName.System)
- {
- SchedulerModule buffer = GetModule(pickBuffer.ToString());
- if (buffer.IsReadyForPick(ModuleName.EfemRobot, 0))
- {
- if (_efemRobot.Pick(buffer.Module, 0, Hand.Blade1))
- {
- buffer.WaitTransfer(ModuleName.EfemRobot, EnumTransferType.Pick, 0);
- return;
- }
- }
- }
- }
- }
- private void MonitorPMTask()
- {
- bool robotWaferAssigned = false;
- bool aligner1WaferAssigned = false;
- bool aligner2WaferAssigned = false;
- foreach (var pm in _lstPms)
- {
- if (!pm.IsAvailable)
- continue;
- if (WaferManager.Instance.CheckHasWafer(pm.Module, 0))
- {
- if (CheckWaferNeedProcess(pm.Module, 0, pm.Module))
- {
- WaferInfo wafer = WaferManager.Instance.GetWafer(pm.Module, 0);
- var recipeName = pm.Module == ModuleName.PMA
- ? wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepParameter["PMARecipe"]
- : wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepParameter["PMBRecipe"];
- if (pm.Process((string)recipeName, false, true))
- {
- WaferManager.Instance.GetWafer(pm.Module, 0).NextSequenceStep++;
- continue;
- }
- }
- else
- {
- if (!pm.IsReadyForPick(ModuleName.EfemRobot, 0))
- {
- pm.PrepareTransfer(ModuleName.EfemRobot, EnumTransferType.Pick, 0);
- }
- }
- }
- else //no wafer
- {
- if (WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, 0) && WaferManager.Instance.CheckNoWafer(ModuleName.Aligner1, 0)
- && WaferManager.Instance.CheckNoWafer(ModuleName.Aligner2, 0) )
- {
- ModuleName source = ModuleName.System;
- if (_isInParallelMode)
- {
- foreach (var moduleName in _mapLpPm)
- {
- if (moduleName.Value == pm.Module)
- source = moduleName.Key;
- }
- }
- SlotItem item = GetNextWaferInJobQueue(source);
- if (item != null && CheckWaferNeedProcess(item.Module, item.Slot, pm.Module))
- {
- if (GetWaferTemperatureSetInRecipe(item.Module, item.Slot, pm.Module, out float temp) && !pm.IsTemperatureReady(temp))
- {
- pm.Preheating(temp);
- continue;
- }
- }
- }
- if (!pm.IsAvailable)
- continue;
- if (!robotWaferAssigned && CheckWaferNeedProcess(ModuleName.EfemRobot, 0, pm.Module) && CheckWaferNextProcessIn(ModuleName.EfemRobot, 0, pm.Module))
- {
- robotWaferAssigned = true;
- GetWaferTemperatureSetInRecipe(ModuleName.EfemRobot, 0, pm.Module, out float temp);
- if (!pm.IsReadyForPlace(ModuleName.EfemRobot, 0) || !pm.IsTemperatureReady(temp))
- {
- pm.PrepareTransfer(ModuleName.EfemRobot, EnumTransferType.Place, 0, temp);
- }
- }
- if (!pm.IsAvailable)
- continue;
- if (!aligner1WaferAssigned && CheckWaferNeedProcess(ModuleName.Aligner1, 0, pm.Module))
- {
- aligner1WaferAssigned = true;
- GetWaferTemperatureSetInRecipe(ModuleName.Aligner1, 0, pm.Module, out float temp);
- if (!pm.IsReadyForPlace(ModuleName.EfemRobot, 0) || !pm.IsTemperatureReady(temp))
- {
- pm.PrepareTransfer(ModuleName.EfemRobot, EnumTransferType.Place, 0, temp);
- }
- }
- if (!pm.IsAvailable)
- continue;
- if (!aligner2WaferAssigned && CheckWaferNeedProcess(ModuleName.Aligner2, 0, pm.Module))
- {
- aligner2WaferAssigned = true;
- GetWaferTemperatureSetInRecipe(ModuleName.Aligner2, 0, pm.Module, out float temp);
- if (!pm.IsReadyForPlace(ModuleName.EfemRobot, 0) || !pm.IsTemperatureReady(temp))
- {
- pm.PrepareTransfer(ModuleName.EfemRobot, EnumTransferType.Place, 0, temp);
- }
- }
- if (!pm.IsAvailable)
- continue;
- }
- }
- }
- #endregion Module task
- #region Logic Check
- private bool CheckSequencePmReady(SequenceInfo seq, out string reason)
- {
- for (int i = 0; i < seq.Steps.Count; i++)
- {
- SequenceStepInfo stepInfo = seq.Steps[i];
- bool hasPm = false;
- foreach (var module in stepInfo.StepModules)
- {
- if (ModuleHelper.IsPm(module))
- {
- PM pm = DEVICE.GetDevice<PM>(module.ToString());
- if (pm.IsInstalled)
- {
- hasPm = true;
- break;
- }
- }
- else
- {
- hasPm = true; // other modules default ok
- }
- }
- if (!hasPm)
- {
- reason = $"Step {i + 1} no valid PM, " + string.Join("|", stepInfo.StepModules);
- return false;
- }
- }
- reason = "";
- return true;
- }
- protected int GetUnprocessedWaferCount()
- {
- int count = 0;
- foreach (ProcessJobInfo pj in _lstProcessJobs)
- {
- if (pj.State == EnumProcessJobState.Processing || pj.State == EnumProcessJobState.Paused)
- count += GetUnprocessedWaferCount(pj);
- }
- return count;
- }
- protected int GetUnprocessedWaferCount(ProcessJobInfo pj)
- {
- int count = 0;
- for (int i = 0; i < pj.SlotWafers.Count; ++i)
- {
- WaferInfo wafer = WaferManager.Instance.GetWafer(pj.SlotWafers[i].Item1, pj.SlotWafers[i].Item2);
- if (wafer.IsEmpty)
- continue;
- if (CheckWaferNeedProcess(pj.SlotWafers[i].Item1, pj.SlotWafers[i].Item2))
- count++;
- }
- return count;
- }
- protected bool CheckAllWaferReturned(ProcessJobInfo pj, bool checkAllProcessed)
- {
- for (int i = 0; i < pj.SlotWafers.Count; ++i)
- {
- WaferInfo wafer = WaferManager.Instance.GetWafer(pj.SlotWafers[i].Item1, pj.SlotWafers[i].Item2);
- if (wafer.IsEmpty)
- return false;
- if (checkAllProcessed && CheckWaferNeedProcess(pj.SlotWafers[i].Item1, pj.SlotWafers[i].Item2))
- return false;
- }
- return true;
- }
- private bool CheckWaferNextStepIsAlign(ModuleName module, int slot)
- {
- if (!WaferManager.Instance.CheckHasWafer(module, slot))
- return false;
- WaferInfo wafer = WaferManager.Instance.GetWafer(module, slot);
- if (wafer.ProcessJob == null || wafer.ProcessJob.Sequence == null)
- return false;
- if (wafer.NextSequenceStep >= wafer.ProcessJob.Sequence.Steps.Count)
- return false;
- if (wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules.Contains(ModuleName.Aligner1)
- || wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules.Contains(ModuleName.Aligner2))
- return true;
- return false;
- }
- private bool GetWaferTemperatureSetInRecipe(ModuleName waferModule, int waferSlot, ModuleName pmModule, out float temp)
- {
- WaferInfo wafer = WaferManager.Instance.GetWafer(waferModule, waferSlot);
-
- var seq = wafer.ProcessJob.Sequence;
- for (int i = 0; i < seq.Steps.Count; i++)
- {
- SequenceStepInfo stepInfo = seq.Steps[i];
- foreach (var module in stepInfo.StepModules)
- {
- if ( module == pmModule)
- {
- temp = (float)seq.Steps[i].StepParameter[module == ModuleName.PMA ? "PMATemp" : "PMBTemp"] ;
- return true;
- }
- }
- }
- temp = 0;
- LOG.Error($"Can not find wafer {waferModule} {waferSlot+1} temperature set in recipe");
- return false;
- }
- private bool CheckWaferPmTemperatureIsOk(ModuleName waferModule, int waferSlot)
- {
- WaferInfo wafer = WaferManager.Instance.GetWafer(waferModule, waferSlot);
- if (wafer.IsEmpty || wafer.ProcessJob == null || wafer.ProcessJob.Sequence == null)
- return false;
- var seq = wafer.ProcessJob.Sequence;
- for (int i = 0; i < seq.Steps.Count; i++)
- {
- SequenceStepInfo stepInfo = seq.Steps[i];
- bool stepOk = false;
- foreach (var module in stepInfo.StepModules)
- {
- if (ModuleHelper.IsPm(module))
- {
- float tempNeeded = (float)seq.Steps[i].StepParameter[module == ModuleName.PMA ? "PMATemp" : "PMBTemp"];
- if ((GetModule(module.ToString()) as SchedulerPM).IsTemperatureReady(tempNeeded))
- {
- stepOk = true;
- break;
- }
- }
- else
- {
- stepOk = true;
- }
- }
- if (!stepOk)
- return false;
- }
- return true;
- }
- private bool CheckWaferNeedAlign(ModuleName waferModule, int waferSlot)
- {
- WaferInfo wafer = WaferManager.Instance.GetWafer(waferModule, waferSlot);
- if (wafer.IsEmpty)
- return false;
- if (wafer.ProcessJob == null || wafer.ProcessJob.Sequence == null)
- return false;
- if (wafer.NextSequenceStep >= wafer.ProcessJob.Sequence.Steps.Count)
- return false;
- if (!wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules
- .Contains(ModuleName.Aligner1) && !wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules
- .Contains(ModuleName.Aligner2))
- return false;
- return true;
- }
- private bool CheckWaferNextProcessIn(ModuleName waferModule, int waferSlot, ModuleName chamber)
- {
- WaferInfo wafer = WaferManager.Instance.GetWafer(waferModule, waferSlot);
- if (wafer.IsEmpty ||
- wafer.ProcessJob == null ||
- wafer.ProcessJob.Sequence == null ||
- wafer.ProcessJob.Sequence.Steps == null ||
- wafer.ProcessJob.Sequence.Steps.Count <= wafer.NextSequenceStep ||
- wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep] == null ||
- wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules == null)
- {
- return false;
- }
- if (_isInParallelMode && _mapLpPm[(ModuleName)wafer.OriginStation] != chamber)
- return false;
- return wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules.Contains(chamber);
- }
- public bool CheckWaferNeedProcess(ModuleName waferModule, int waferSlot, ModuleName processIn = ModuleName.System)
- {
- WaferInfo wafer = WaferManager.Instance.GetWafer(waferModule, waferSlot);
- if (wafer.IsEmpty)
- return false;
- if (wafer.ProcessJob == null || wafer.ProcessJob.Sequence == null)
- return false;
- if (wafer.NextSequenceStep >= wafer.ProcessJob.Sequence.Steps.Count)
- return false;
- for (int i = wafer.NextSequenceStep; i < wafer.ProcessJob.Sequence.Steps.Count; i++)
- {
- if (wafer.ProcessJob.Sequence.Steps[i].StepModules
- .Contains(ModuleName.PMA) || wafer.ProcessJob.Sequence.Steps[i].StepModules
- .Contains(ModuleName.PMB))
- {
- if (processIn == ModuleName.System)
- return true;
- if (_isInParallelMode && _mapLpPm[(ModuleName) wafer.OriginStation] != processIn)
- return false;
- if (wafer.ProcessJob.Sequence.Steps[i].StepModules
- .Contains(processIn))
- return true;
- }
- }
- return false;
- }
- private bool CheckVacuumWaferHasAvailableTarget(ModuleName waferModule, int waferSlot)
- {
- WaferInfo wafer = WaferManager.Instance.GetWafer(waferModule, waferSlot);
- //System.Diagnostics.Trace.Assert(!wafer.IsEmpty);
- //if (CheckWaferNeedProcess(waferModule, waferSlot))
- //{
- // // Check for an empty PM
- // foreach (var pm in _lstPms)
- // {
- // if (WaferManager.Instance.CheckNoWafer(pm.Module, 0))
- // {
- // if (pm.IsAvailable == false)
- // continue;
- // if (!CheckWaferNextProcessIn(waferModule, waferSlot, pm.Module))
- // continue;
- // return true;
- // }
- // }
- //}
- //else
- {
- // No more processing needed, check for a outbound BUFFER slot
- foreach (var buffer in _lstBuffers)
- {
- if (!buffer.IsAvailable)
- continue;
- if (WaferManager.Instance.CheckNoWafer(buffer.Module, 0))
- {
- return true;
- }
- }
- }
- return false;
- }
- private bool CheckBufferWaferHasAvailableTarget(ModuleName waferModule, int waferSlot)
- {
- WaferInfo wafer = WaferManager.Instance.GetWafer(waferModule, waferSlot);
- //System.Diagnostics.Trace.Assert(!wafer.IsEmpty);
- if (!CheckWaferNeedProcess(waferModule, waferSlot))
- return true;
-
- // Check for an empty PM
- foreach (var pm in _lstPms)
- {
- if (WaferManager.Instance.CheckNoWafer(pm.Module, 0))
- {
- if (pm.IsAvailable == false)
- continue;
- if (!CheckWaferNextProcessIn(waferModule, waferSlot, pm.Module))
- continue;
- return true;
- }
- }
-
- return false;
- }
- private bool SetSequenceTemperatureInfo(SequenceInfo seq, out string reason)
- {
- for (int i = 0; i < seq.Steps.Count; i++)
- {
- SequenceStepInfo stepInfo = seq.Steps[i];
- foreach (var module in stepInfo.StepModules)
- {
- if (ModuleHelper.IsPm(module))
- {
- string attr = module == ModuleName.PMA ? "PMARecipe" : "PMBRecipe";
- if (stepInfo.StepParameter.ContainsKey(attr)
- && !string.IsNullOrEmpty((string)stepInfo.StepParameter[attr]))
- {
- var recipeName = (string)stepInfo.StepParameter[attr];
- if (!string.IsNullOrEmpty(recipeName))
- {
- var recipeContent =
- RecipeFileManager.Instance.LoadRecipe($"", recipeName, false);
- if (string.IsNullOrEmpty(recipeContent))
- {
- reason = $"Can not find recipe file{recipeName}";
- return false;
- }
- try
- {
- XmlDocument xml = new XmlDocument();
- xml.LoadXml(recipeContent);
- var substrateTemp = xml.DocumentElement.HasAttribute("SubstrateTemp") ? xml.DocumentElement.Attributes["SubstrateTemp"].Value : "";
- if (!float.TryParse(substrateTemp, out float temp))
- {
- reason = $"Invalid substrate temperature in recipe head {recipeName}";
- return false;
- }
- seq.Steps[i].StepParameter[module == ModuleName.PMA ? "PMATemp" : "PMBTemp"] = temp;
- }
- catch (Exception ex)
- {
- LOG.Write(ex);
- reason = $"recipe not valid, {recipeName}";
- return false;
- }
- }
- }
- }
- }
- }
- reason = "";
- return true;
- }
- private bool CheckSequenceRecipeFileValid(SequenceInfo seq, out string reason)
- {
- for (int i = 0; i < seq.Steps.Count; i++)
- {
- SequenceStepInfo stepInfo = seq.Steps[i];
- foreach (var module in stepInfo.StepModules)
- {
- if (ModuleHelper.IsPm(module))
- {
- string attr = module==ModuleName.PMA ? "PMARecipe" : "PMBRecipe";
- if (stepInfo.StepParameter.ContainsKey(attr)
- && !string.IsNullOrEmpty((string)stepInfo.StepParameter[attr]))
- {
- var recipeName = (string)stepInfo.StepParameter[attr];
- if (!string.IsNullOrEmpty(recipeName))
- {
- var recipeContent =
- RecipeFileManager.Instance.LoadRecipe($"", recipeName, false);
- if (string.IsNullOrEmpty(recipeContent))
- {
- reason = $"Can not find recipe file{recipeName}";
- return false;
- }
- }
- }
- }
- }
- }
- reason = "";
- return true;
- }
-
- private bool GetWaferSequenceAlignTime(ModuleName module, int slot, out float time)
- {
- time = 0;
- if (!WaferManager.Instance.CheckHasWafer(module, slot))
- return false;
- WaferInfo wafer = WaferManager.Instance.GetWafer(module, slot);
- if (wafer.ProcessJob == null || wafer.ProcessJob.Sequence == null)
- return false;
- if (wafer.NextSequenceStep >= wafer.ProcessJob.Sequence.Steps.Count)
- return false;
- if (!wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules.Contains(ModuleName.Aligner1)
- && !wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules.Contains(ModuleName.Aligner2))
- return false;
- if (!wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepParameter.ContainsKey("CoolingTime"))
- return false;
- if (!float.TryParse((string)wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepParameter["CoolingTime"],
- out time))
- return false;
-
- return true;
- }
- private int GetWaferCountOutofLP(ModuleName lp)
- {
- int count = 0;
- var lstPosition = new List<ModuleName>()
- {
- ModuleName.EfemRobot, ModuleName.Aligner1, ModuleName.Aligner2, ModuleName.PMA, ModuleName.PMB,
- };
- foreach (var moduleName in lstPosition)
- {
- if (WaferManager.Instance.CheckHasWafer(moduleName, 0))
- {
- if (lp == ModuleName.System ||
- WaferManager.Instance.GetWafer(moduleName, 0).OriginStation == (int) lp)
- count++;
- }
- }
- return count;
- }
- private SlotItem GetWaferReturnLoadPort(ModuleName module, int slot)
- {
- WaferInfo wafer = WaferManager.Instance.GetWafer(module, slot);
- if (!wafer.IsEmpty)
- {
- return new SlotItem((ModuleName)wafer.OriginStation, wafer.OriginSlot);
- }
- return null;
- }
- private int GetWaferCountInJobQueue(ModuleName sourceLp)
- {
- int count = 0;
- foreach (var lp in _lstLps)
- {
- for (int i = 0; i < 25; i++)
- {
- if (CheckWaferNeedProcess(lp.Module, i) && (sourceLp==ModuleName.System || sourceLp==lp.Module))
- count++;
- }
- }
- return count;
- }
- private SlotItem GetNextWaferInJobQueue(ModuleName sourceLp)
- {
- foreach (var cj in _lstControlJobs)
- {
- if (sourceLp!=ModuleName.System && (cj.Module !=sourceLp.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 (CheckWaferNeedProcess(pjSlotWafer.Item1, pjSlotWafer.Item2))
- return new SlotItem(pjSlotWafer.Item1, pjSlotWafer.Item2);
- }
- }
- }
- }
- }
- return null;
- }
- private int GetMaxOutWafer()
- {
- return _isInParallelMode ? 1 : 2;
- }
-
- #endregion Logic Check
- }
- }
|