1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354 |
- using MECF.Framework.Common.RecipeCenter;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.Schedulers;
- using Aitex.Core.Common;
- using MECF.Framework.Common.WaferHolder;
- using MECF.Framework.Common.CommonData;
- using System.Windows;
- using Aitex.Core.RT.IOCore;
- using Aitex.Core.RT.Log;
- using Aitex.Core.Util;
- using MECF.Framework.Common.Routine;
- using CyberX8_RT.Modules;
- using Aitex.Core.RT.Fsm;
- using CyberX8_RT.Modules.PUF;
- using CyberX8_RT.Modules.Dummy;
- using MECF.Framework.Common.SubstrateTrackings;
- using MECF.Framework.Common.ToolLayout;
- using CyberX8_RT.Modules.Metal;
- using CyberX8_RT.Modules.Rinse;
- using MECF.Framework.RT.Core.Equipments;
- using MECF.Framework.Common.ProcessCell;
- using SecsGem.Core.ItemModel;
- using CyberX8_RT.Modules.Transporter;
- using CyberX8_Core;
- using Aitex.Core.RT.SCCore;
- using CyberX8_RT.Modules.Dryer;
- using CyberX8_RT.Modules.Prewet;
- using CyberX8_RT.Modules.SRD;
- using CyberX8_RT.Modules.Reservoir;
- using CyberX8_RT.Schedulers.Puf;
- using CyberX8_RT.Modules.Loader;
- using CyberX8_RT.Schedulers.Transporter;
- using CyberX8_RT.Schedulers.Loader;
- using CyberX8_RT.Devices.EFEM;
- namespace CyberX8_RT.Schedulers
- {
- public class SchedulerSequenceManager : Singleton<SchedulerSequenceManager>
- {
- #region 常量
- private const string ENGINEERING = "Engineering";
- private const string PRODUCTION = "Production";
- private const string TRNPA = "TRNPA";
- private const string TRNPB = "TRNPB";
- #endregion
- #region 内部变量
- private int _sideAWaferSize = 0;
- private int _sideBWaferSize = 0;
- #endregion
- /// <summary>
- /// 初始化
- /// </summary>
- public void Initialize()
- {
- _sideAWaferSize = SC.GetValue<int>($"Loader1.SideAWaferSize");
- _sideBWaferSize = SC.GetValue<int>($"Loader1.SideBWaferSize");
- }
- /// <summary>
- /// 解析Wafer所有调度工序
- /// </summary>
- /// <param name="sequenceRecipe"></param>
- /// <returns></returns>
- public List<SchedulerSequence> AnalyWaferAllSchedulerSequence(WaferInfo waferInfo,ModuleName pufModule,string side,WaferHolderInfo waferHolderInfo,SequenceRecipe sequenceRecipe)
- {
- waferInfo.LoaderSide = side;
- List<SchedulerSequence> schedulerSequences = new List<SchedulerSequence>();
- int index = 0;
- MoveItem moveItem = new MoveItem((ModuleName)waferInfo.OriginStation, waferInfo.OriginSlot, ModuleName.Aligner1, 0, Aitex.Sorter.Common.Hand.Blade1);
- SchedulerSequence efemRobotSequence = CreateEfemRobotSequence(moveItem,null,sequenceRecipe.SubstrateSize,ref index);
- schedulerSequences.Add(efemRobotSequence);
- SchedulerSequence alignerSequence=CreateAlignerSequence(sequenceRecipe.AlignmentAngle,sequenceRecipe.SubstrateSize,ref index);
- schedulerSequences.Add(alignerSequence);
- //从Aligner至Puf B面
- MoveItem moveItem2 = new MoveItem(ModuleName.Aligner1, 0, pufModule, 1, Aitex.Sorter.Common.Hand.Blade1);
- SchedulerSequence secondEfemRobotSequence = CreateEfemRobotSequence(moveItem2,null,sequenceRecipe.SubstrateSize, ref index);
- schedulerSequences.Add(secondEfemRobotSequence);
- SchedulerSequence pufSequence=CreatePufSequence(pufModule,sequenceRecipe,side,true,ref index);
- schedulerSequences.Add(pufSequence);
- ////Loader
- //SchedulerSequence loaderSequence = CreateLoaderSequence(ref index);
- //schedulerSequences.Add(loaderSequence);
- ////wafer holder装载后的recipe工序
- //List<SchedulerSequence> waferHolderAfterLoadedAllSequences = WaferHolderAfterLoadedAllSchedulerSequences(waferHolderInfo, sequenceRecipe, ref index);
- //schedulerSequences.AddRange(waferHolderAfterLoadedAllSequences);
- ////buffer模块至Loader
- //ModuleName bufferModule = ConvertToBufferModule(waferHolderInfo.BufferId);
- //WaferHolderMoveItem bufferToLoaderItem = new WaferHolderMoveItem(bufferModule,ModuleType.Buffer , ModuleName.Loader1, ModuleType.Loader);
- //SchedulerSequence bufferToLoaderSequence = CreateLoaderTransporterSequence(bufferToLoaderItem, ref index);
- //schedulerSequences.Add(bufferToLoaderSequence);
- ////Loader
- //SchedulerSequence backLoaderSequence = CreateLoaderSequence(ref index);
- //schedulerSequences.Add(backLoaderSequence);
- //puf模块
- SchedulerSequence backPufSequence = CreatePufSequence(pufModule,sequenceRecipe,"",false, ref index);
- schedulerSequences.Add(backPufSequence);
- //若经过srd
- if(SequenceRecipeManager.Instance.IsContainedSrd(sequenceRecipe))
- {
- SrdRecipe srdRecipe=SequenceRecipeManager.Instance.GetSrdRecipeBySequenceRecipe(sequenceRecipe);
- if(srdRecipe!=null)
- {
- MoveItem pufToSrdItem = new MoveItem();
- pufToSrdItem.SourceModule = pufModule;
- //A面
- pufToSrdItem.SourceSlot = 0;
- pufToSrdItem.DestinationType = ModuleType.SRD;
- pufToSrdItem.SourceSlot = 0;
- pufToSrdItem.DestinationModule = ModuleName.Unknown;
- pufToSrdItem.RobotHand = Aitex.Sorter.Common.Hand.Blade1;
- SchedulerSequence backEfemRobotSequence = CreateEfemRobotSequence(pufToSrdItem,null,sequenceRecipe.SubstrateSize, ref index);
- schedulerSequences.Add(backEfemRobotSequence);
- SchedulerSequence srdSequence = CreateSRDSequence(srdRecipe, ref index);
- schedulerSequences.Add(srdSequence);
-
- MoveItem srdToLoadPortItem = new MoveItem();
- srdToLoadPortItem.SourceModule = ModuleName.Unknown;
- srdToLoadPortItem.SourceType = ModuleType.SRD;
- srdToLoadPortItem.SourceSlot = 0;
- srdToLoadPortItem.DestinationType = ModuleType.LoadPort;
- srdToLoadPortItem.DestinationModule = (ModuleName)waferInfo.OriginStation;
- srdToLoadPortItem.DestinationSlot = waferInfo.OriginSlot;
- srdToLoadPortItem.RobotHand = Aitex.Sorter.Common.Hand.Blade1;
- SchedulerSequence srdToLoadPortSequence = CreateEfemRobotSequence(srdToLoadPortItem,null,sequenceRecipe.SubstrateSize, ref index);
- schedulerSequences.Add(srdToLoadPortSequence);
- }
- else
- {
- LOG.WriteLog(eEvent.ERR_SEQUENCE, "System", $"{sequenceRecipe.Ppid} srd recipe is invalid");
- return new List<SchedulerSequence>();
- }
- }
- else
- {
- MoveItem pufToLoadPortItem=new MoveItem(pufModule,0,(ModuleName)waferInfo.OriginStation,
- waferInfo.OriginSlot,Aitex.Sorter.Common.Hand.Blade1);
- SchedulerSequence pufToLoaderSequence=CreateEfemRobotSequence(pufToLoadPortItem,null,sequenceRecipe.SubstrateSize, ref index);
- schedulerSequences.Add(pufToLoaderSequence);
- }
- return schedulerSequences;
- }
- /// <summary>
- /// 解析WaferHolder的所有工序
- /// </summary>
- /// <param name="waferHolderInfo"></param>
- /// <param name="sequenceRecipe"></param>
- /// <returns></returns>
- public List<SchedulerSequence> AnalyWaferHolderAllSchedulerSequence(WaferHolderInfo waferHolderInfo, SequenceRecipe sequenceRecipe,int productWaferCount,int dummyWaferCount)
- {
- int totalWaferCount = productWaferCount + dummyWaferCount;
- int index = 0;
- List<SchedulerSequence> schedulerSequences = new List<SchedulerSequence>();
- //Buffer To Loader
- ModuleName currentLocationModuleName = (ModuleName)Enum.Parse(typeof(ModuleName), waferHolderInfo.CurrentLocation);
- TransporterAction transporterAction = GenerateTransporterTransferAction(currentLocationModuleName, ModuleType.Buffer, ModuleName.Loader1, ModuleType.Loader);
- string strTRNP = AnalyseLoadTransporterSide(sequenceRecipe, productWaferCount,dummyWaferCount);
- List<SchedulerSyncModuleMessage> synModules = GenerateLoaderTransporterSyncModuleMessage(strTRNP);
- SchedulerSequence bufferToLoaderSequence = CreateLoaderTransporterSequence(transporterAction,synModules,waferHolderInfo.WaferSize, ref index);
- schedulerSequences.Add(bufferToLoaderSequence);
- //尺寸不一致
- bool needFlip = CheckLoaderWaferSizeNotEqual() && totalWaferCount == 2;
- //Loader
- LoaderParameter parameter = new LoaderParameter();
- parameter.WaferCount= needFlip?1: totalWaferCount;
- parameter.LoadCompleteToTransporterSide = strTRNP;
- parameter.NeedWaitFlip = needFlip;
- SchedulerSequence loaderSequence = CreateLoaderSequence(parameter,sequenceRecipe.SubstrateSize, ref index);
- schedulerSequences.Add(loaderSequence);
- if (needFlip)
- {
- string reverse = GetReverseTransporterLocation(strTRNP);
- TransporterAction flipAction = GenerateTransporterFlipAction(reverse);
- SchedulerSequence flipSequence=CreateLoaderTransporterSequence(flipAction,null,sequenceRecipe.SubstrateSize, ref index);
- schedulerSequences.Add(flipSequence);
- //Loader
- LoaderParameter reverseParameter = new LoaderParameter();
- reverseParameter.WaferCount = 1;
- reverseParameter.LoadCompleteToTransporterSide = reverse;
- reverseParameter.NeedWaitFlip = false;
- SchedulerSequence reverseLoadSequence = CreateLoaderSequence(reverseParameter,sequenceRecipe.SubstrateSize, ref index);
- schedulerSequences.Add(reverseLoadSequence);
- }
- //wafer holder装载后的recipe工序
- List<SchedulerSequence> waferHolderAfterLoadedAllSequences = WaferHolderAfterLoadedAllSchedulerSequences(waferHolderInfo, sequenceRecipe,ref index);
- schedulerSequences.AddRange(waferHolderAfterLoadedAllSequences);
- return schedulerSequences;
- }
- /// <summary>
- /// 解析LoaderTransporter放至Loader第一次确定TRNP的方向
- /// </summary>
- /// <param name="sequenceRecipe"></param>
- /// <param name="waferCount"></param>
- /// <returns></returns>
- private string AnalyseLoadTransporterSide(SequenceRecipe sequenceRecipe,int productWaferCount,int dummyWaferCount)
- {
- //单片,同时loader两边尺寸不一致
- if ((productWaferCount == 1||dummyWaferCount==1) && _sideAWaferSize != _sideBWaferSize)
- {
- //recipe使用B面工艺,但loader A面与recipe尺寸一致
- if (sequenceRecipe.LastSingleWaferToSideB && sequenceRecipe.SubstrateSize == _sideAWaferSize)
- {
- return "TRNPB";
- }
- //recipe使用A面工艺,但loader B面与recipe尺寸一致
- else if (!sequenceRecipe.LastSingleWaferToSideB && sequenceRecipe.SubstrateSize == _sideBWaferSize)
- {
- return "TRNPB";
- }
- }
- return "TRNPA";
- }
- private string GetReverseTransporterLocation(string strTrn)
- {
- return strTrn == TRNPA ? TRNPB : TRNPA;
- }
- /// <summary>
- /// 创建Transporter transfer指令
- /// </summary>
- /// <param name="source"></param>
- /// <param name="sourceType"></param>
- /// <param name="dest"></param>
- /// <param name="destType"></param>
- /// <returns></returns>
- private TransporterAction GenerateTransporterTransferAction(ModuleName source,ModuleType sourceType,ModuleName dest,ModuleType destType)
- {
- TransporterAction transporterAction = new TransporterAction();
- transporterAction.ActionMsg = TransporterMSG.Transfer;
- WaferHolderMoveItem waferHolderMoveItem = new WaferHolderMoveItem(source, sourceType, dest, destType);
- transporterAction.Parameter = waferHolderMoveItem;
- return transporterAction;
- }
- /// <summary>
- /// 创建Transporter pickup指令
- /// </summary>
- /// <param name="source"></param>
- /// <param name="sourceType"></param>
- /// <param name="dest"></param>
- /// <param name="destType"></param>
- /// <returns></returns>
- private TransporterAction GenerateTransporterFlipAction(string strTransporter)
- {
- TransporterAction transporterAction = new TransporterAction();
- transporterAction.ActionMsg = TransporterMSG.Flip;
- transporterAction.Parameter = strTransporter;
- return transporterAction;
- }
- /// <summary>
- /// 检验Loader两边waferSize不一致
- /// </summary>
- /// <returns></returns>
- private bool CheckLoaderWaferSizeNotEqual()
- {
- return _sideAWaferSize != _sideBWaferSize;
- }
- /// <summary>
- /// 创建LoaderTrasporter同步模块消息
- /// </summary>
- /// <param name="tranporter"></param>
- /// <returns></returns>
- private List<SchedulerSyncModuleMessage> GenerateLoaderTransporterSyncModuleMessage(string tranporter)
- {
- List<SchedulerSyncModuleMessage> synModules = new List<SchedulerSyncModuleMessage>();
- SchedulerSyncModuleMessage syncModuleMessage = new SchedulerSyncModuleMessage();
- syncModuleMessage.ModuleEntity = Singleton<RouteManager>.Instance.GetModule<IModuleEntity>(ModuleName.Loader1.ToString());
- syncModuleMessage.ModuleMsg = LoaderMSG.PrepareForPlace.ToString();
- syncModuleMessage.parameters = new object[] { tranporter };
- synModules.Add(syncModuleMessage);
- return synModules;
- }
- /// <summary>
- /// Dummy Wafer对应WaferHolder任务
- /// </summary>
- /// <param name="waferHolderInfo"></param>
- /// <returns></returns>
- public List<SchedulerSequence> AnalyseDummyWaferHolderAllSchedulerSequence(WaferHolderInfo waferHolderInfo,int productWaferCount,int dummyWaferCount)
- {
- int index = 0;
- List<SchedulerSequence> schedulerSequences = new List<SchedulerSequence>();
- string strTRNP = AnalyseLoadTransporterSide(waferHolderInfo.SequenceRecipe, productWaferCount,dummyWaferCount);
- //Buffer To Loader
- ModuleName currentLocationModuleName = (ModuleName)Enum.Parse(typeof(ModuleName), waferHolderInfo.CurrentLocation);
- ModuleName bufferModule = (ModuleName)Enum.Parse(typeof(ModuleName), waferHolderInfo.OriginalBuffer);
- List<SchedulerSyncModuleMessage> synModules = GenerateLoaderTransporterSyncModuleMessage(strTRNP);
- TransporterAction transporterAction = GenerateTransporterTransferAction(currentLocationModuleName, ModuleType.Buffer, ModuleName.Loader1, ModuleType.Loader);
- SchedulerSequence bufferToLoaderSequence = CreateLoaderTransporterSequence(transporterAction,synModules,waferHolderInfo.WaferSize, ref index);
- schedulerSequences.Add(bufferToLoaderSequence);
- //尺寸不一致
- bool needFlip = CheckLoaderWaferSizeNotEqual() && dummyWaferCount == 2;
- //Loader
- LoaderParameter parameter = new LoaderParameter();
- parameter.WaferCount = needFlip ? 1 : dummyWaferCount; ;
- parameter.LoadCompleteToTransporterSide = strTRNP;
- parameter.NeedWaitFlip = needFlip;
- SchedulerSequence loaderSequence = CreateLoaderSequence(parameter,waferHolderInfo.WaferSize,ref index);
- schedulerSequences.Add(loaderSequence);
- if (needFlip)
- {
- string reverse = GetReverseTransporterLocation(strTRNP);
- TransporterAction flipAction = GenerateTransporterFlipAction(reverse);
- SchedulerSequence flipSequence = CreateLoaderTransporterSequence(flipAction, null,waferHolderInfo.WaferSize, ref index);
- schedulerSequences.Add(flipSequence);
- //Loader
- LoaderParameter reverseParameter = new LoaderParameter();
- reverseParameter.WaferCount = 1;
- reverseParameter.LoadCompleteToTransporterSide = reverse;
- reverseParameter.NeedWaitFlip = false;
- SchedulerSequence reverseLoadSequence = CreateLoaderSequence(reverseParameter,waferHolderInfo.WaferSize, ref index);
- schedulerSequences.Add(reverseLoadSequence);
- }
- //Loader To Buffer
- TransporterAction loaderMoveToBufferAction=GenerateTransporterTransferAction (ModuleName.Loader1, ModuleType.Loader,
- bufferModule, ModuleType.Buffer);
- SchedulerSequence loaderToBufferSequence = CreateLoaderTransporterSequence(loaderMoveToBufferAction,null,waferHolderInfo.WaferSize, ref index);
- schedulerSequences.Add(loaderToBufferSequence);
- return schedulerSequences;
- }
- /// <summary>
- /// 解析Dummy Wafer所有调度工序
- /// </summary>
- /// <param name="sequenceRecipe"></param>
- /// <returns></returns>
- public List<SchedulerSequence> AnalyDummyWaferAllSchedulerSequence(SequenceRecipe sequenceRecipe,WaferInfo waferInfo, ModuleName pufModule,string side)
- {
- waferInfo.LoaderSide = side;
- List<SchedulerSequence> schedulerSequences = new List<SchedulerSequence>();
- int index = 0;
- //DummyCassete至Aligner
- MoveItem moveItem = new MoveItem((ModuleName)waferInfo.Station, waferInfo.Slot, ModuleName.Aligner1, 0, Aitex.Sorter.Common.Hand.Blade1);
- SchedulerSequence secondEfemRobotSequence = CreateEfemRobotSequence(moveItem, null,sequenceRecipe.SubstrateSize, ref index);
- schedulerSequences.Add(secondEfemRobotSequence);
- //Aligner
- SchedulerSequence alignerSequence = null;
- if (sequenceRecipe == null)
- {
- alignerSequence= CreateAlignerSequence(0,sequenceRecipe.SubstrateSize, ref index);
- }
- else
- {
- alignerSequence=CreateAlignerSequence(sequenceRecipe.AlignmentAngle,sequenceRecipe.SubstrateSize, ref index);
- }
- schedulerSequences.Add(alignerSequence);
- //Aligner至Puf
- MoveItem alignerToPufMoveItem = new MoveItem(ModuleName.Aligner1, 0, pufModule, 1, Aitex.Sorter.Common.Hand.Blade1);
- SchedulerSequence alignerToPufEfemRobotSequence = CreateEfemRobotSequence(alignerToPufMoveItem, null,sequenceRecipe.SubstrateSize, ref index);
- schedulerSequences.Add(alignerToPufEfemRobotSequence);
- SchedulerSequence pufSequence = CreatePufSequence(pufModule,sequenceRecipe, side,true, ref index);
- schedulerSequences.Add(pufSequence);
- return schedulerSequences;
- }
- /// <summary>
- /// Loader装载后Recipe工序
- /// </summary>
- /// <param name="waferHolderInfo"></param>
- /// <param name="sequenceRecipe"></param>
- /// <param name="index"></param>
- /// <returns></returns>
- private List<SchedulerSequence> WaferHolderAfterLoadedAllSchedulerSequences(WaferHolderInfo waferHolderInfo,SequenceRecipe sequenceRecipe,ref int index)
- {
- List<SchedulerSequence> schedulerSequences = new List<SchedulerSequence>();
- if(!Enum.TryParse(waferHolderInfo.OriginalBuffer,out ModuleName moduleName))
- {
- return schedulerSequences;
- }
- //Loader To Buffer
- TransporterAction loaderMoveToBufferAction = GenerateTransporterTransferAction(ModuleName.Loader1, ModuleType.Loader,
- moduleName, ModuleType.Buffer);
- SchedulerSequence loaderToBufferSequence = CreateLoaderTransporterSequence(loaderMoveToBufferAction,null,sequenceRecipe.SubstrateSize, ref index);
- schedulerSequences.Add(loaderToBufferSequence);
- //解析sequence recipe后续的工序
- var result = AnalyseSequenceRecipeScheduler(sequenceRecipe);
- //buffer to recipe第一个工序
- TransporterAction bufferToFirstAction = GenerateTransporterTransferAction(moduleName, ModuleType.Buffer, ModuleName.Unknown, result.firstModuleType);
- SchedulerSequence bufferSequence = CreateLoaderTransporterSequence(bufferToFirstAction,null,sequenceRecipe.SubstrateSize, ref index);
- schedulerSequences.Add(bufferSequence);
- //调整工序后面的索引
- foreach (SchedulerSequence item in result.sequences)
- {
- item.SequenceIndex = index;
- index++;
- }
- schedulerSequences.AddRange(result.sequences);
- //从recipe最后工序
- TransporterAction lastToBufferAction = GenerateTransporterTransferAction(ModuleName.Unknown, result.lastModuleType, moduleName, ModuleType.Buffer);
- SchedulerSequence lastToBufferSequence = CreateLoaderTransporterSequence(lastToBufferAction,null,sequenceRecipe.SubstrateSize, ref index);
- schedulerSequences.Add(lastToBufferSequence);
- return schedulerSequences;
- }
- /// <summary>
- /// 分析Sequence recipe对应的调度步骤
- /// </summary>
- /// <param name="sequenceRecipe"></param>
- /// <returns></returns>
- private (ModuleType firstModuleType,List<SchedulerSequence> sequences,ModuleType lastModuleType) AnalyseSequenceRecipeScheduler(SequenceRecipe sequenceRecipe)
- {
- ModuleType firstModuleType = default;
- ModuleType lastModuleType = default;
- List<SchedulerSequence> schedulerSequences= new List<SchedulerSequence>();
- List<SchedulerSequence> tmpLst = new List<SchedulerSequence>();
- var processResult = AnalyseLastProcessRecipeIndex(sequenceRecipe.Recipes);
- bool isExistSrd = sequenceRecipe.Recipes.FindIndex(O=>O.ToLower().EndsWith("srd.rcp"))!=-1;
- int lastIndex = isExistSrd ? sequenceRecipe.Recipes.Count - 2 : sequenceRecipe.Recipes.Count - 1;
- for(int i=0;i<sequenceRecipe.Recipes.Count;i++)
- {
- string item = sequenceRecipe.Recipes[i];
- if(item.ToLower().EndsWith("srd.rcp"))//跳过SRD
- {
- continue;
- }
- SchedulerSequence schedulerSequence = new SchedulerSequence();
- schedulerSequence.ModuleName = ModuleName.Unknown;
- schedulerSequence.ModuleType=SequenceRecipeManager.Instance.GetModuleType(item);
- schedulerSequence.SequenceIndex=i;
- schedulerSequence.WaferSize = sequenceRecipe.SubstrateSize;
- MECF.Framework.Common.RecipeCenter.RecipeType recipeType =SequenceRecipeManager.Instance.GetRecipeType(item);
- schedulerSequence.Recipe = SequenceRecipeManager.Instance.LoadSequenceTypeRecipe(sequenceRecipe.SequenceType,item, recipeType);
- schedulerSequence.SequenceType = sequenceRecipe.SequenceType;
- schedulerSequence.State = RState.Init;
- schedulerSequence.MaterialType = MaterialType.WaferHolder;
- tmpLst.Add(schedulerSequence);
- if (i == 0)
- {
- firstModuleType = schedulerSequence.ModuleType;
- }
- if(i==lastIndex)
- {
- lastModuleType = schedulerSequence.ModuleType;
- }
- else
- {
- string nextModule = sequenceRecipe.Recipes[i + 1];
- schedulerSequence.NextModuleType= SequenceRecipeManager.Instance.GetModuleType(nextModule);
- MECF.Framework.Common.RecipeCenter.RecipeType nextRecipeType = SequenceRecipeManager.Instance.GetRecipeType(nextModule);
- schedulerSequence.NextRecipe= SequenceRecipeManager.Instance.LoadSequenceTypeRecipe(sequenceRecipe.SequenceType,nextModule,nextRecipeType);
- }
- schedulerSequence.IsProcessSequece = true;
- if(i==processResult.lastIndex)
- {
- schedulerSequence.IsLastProcessSequence = true;
- }
-
- }
- int index = 0;
- for(int i=0;i<tmpLst.Count;i++)
- {
- tmpLst[i].SequenceIndex = 0;
- schedulerSequences.Add(tmpLst[i]);
- index++;
- if(i<tmpLst.Count-1)
- {
- TransporterAction transporterAction = new TransporterAction();
- transporterAction.ActionMsg = TransporterMSG.Transfer;
- WaferHolderMoveItem moveItem = new WaferHolderMoveItem(ModuleName.Unknown, tmpLst[i].ModuleType, ModuleName.Unknown, tmpLst[i + 1].ModuleType);
- transporterAction.Parameter = moveItem;
- SchedulerSequence schedulerSequence=CreateProcessTransporterSequence(transporterAction,sequenceRecipe.SubstrateSize,ref index);
- schedulerSequences.Add(schedulerSequence);
- }
- }
- return (firstModuleType,schedulerSequences,lastModuleType);
- }
- /// <summary>
- /// 分析最后加工recipe索引
- /// </summary>
- /// <param name="recipes"></param>
- /// <returns></returns>
- private (int lastIndex,List<int> processIndexList) AnalyseLastProcessRecipeIndex(List<string> recipes)
- {
- int index = 0;
- List<int> lst = new List<int>();
- for(int i=0;i<recipes.Count; i++)
- {
- string item=recipes[i];
- if(item.ToLower().EndsWith("dep.rcp"))
- {
- index = i;
- if(lst.Contains(i))
- {
- lst.Add(i);
- }
- }
- }
- if(lst.Count==0)
- {
- lst.Add(0);
- }
- return (index,lst);
- }
- /// <summary>
- /// 创建EFEM Robot步骤
- /// </summary>
- /// <param name="index"></param>
- /// <returns></returns>
- private SchedulerSequence CreateEfemRobotSequence(MoveItem moveItem,List<SchedulerSyncModuleMessage> synModules,int waferSize,ref int index)
- {
- SchedulerSequence sequence = new SchedulerSequence();
- sequence.SchedulerModule = SchedulerManager.Instance.GetScheduler(ModuleName.EfemRobot);
- sequence.SequenceIndex= index;
- sequence.ModuleName=ModuleName.EfemRobot;
- sequence.State = RState.Init;
- sequence.Recipe = null;
- sequence.ModuleType=ModuleType.EfemRobot;
- sequence.Parameters =moveItem;
- sequence.MaterialType = MaterialType.Wafer;
- sequence.SynchronousModuleMessages = synModules;
- sequence.WaferSize = waferSize;
- index++;
- return sequence;
- }
- /// <summary>
- /// 创建Aligner步骤
- /// </summary>
- /// <param name="index"></param>
- /// <returns></returns>
- private SchedulerSequence CreateAlignerSequence(double angle,int waferSize,ref int index)
- {
- SchedulerSequence sequence = new SchedulerSequence();
- sequence.SchedulerModule = SchedulerManager.Instance.GetScheduler(ModuleName.Aligner1);
- sequence.SequenceIndex = index;
- sequence.ModuleName = ModuleName.Aligner1;
- sequence.State = RState.Init;
- sequence.Recipe = null;
- sequence.ModuleType = ModuleType.Aligner;
- sequence.Parameters = angle;
- sequence.MaterialType = MaterialType.Wafer;
- sequence.WaferSize = waferSize;
- index++;
- return sequence;
- }
- /// <summary>
- /// 创建PUF步骤
- /// </summary>
- /// <param name="pufModuleName"></param>
- /// <param name="index"></param>
- /// <returns></returns>
- private SchedulerSequence CreatePufSequence(ModuleName pufModuleName,SequenceRecipe sequenceRecipe,string side,bool forward,ref int index)
- {
- SchedulerSequence sequence = new SchedulerSequence();
- sequence.SchedulerModule = SchedulerManager.Instance.GetScheduler(pufModuleName);
- sequence.SequenceIndex = index;
- sequence.ModuleName = pufModuleName;
- sequence.State = RState.Init;
- sequence.Recipe = sequenceRecipe;
- PufSchedulerParameter parameter = new PufSchedulerParameter()
- {
- IsForward = forward,
- Side = side,
- };
- sequence.Parameters = parameter;
- sequence.IsWaitNotify = !forward;
- sequence.ModuleType = ModuleType.PUF;
- sequence.MaterialType = MaterialType.Wafer;
- sequence.WaferSize = sequenceRecipe.SubstrateSize;
- index++;
- return sequence;
- }
- /// <summary>
- /// 创建Loader步骤
- /// </summary>
- /// <param name="index"></param>
- /// <returns></returns>
- private SchedulerSequence CreateLoaderSequence(LoaderParameter parameter,int waferSize,ref int index)
- {
- SchedulerSequence sequence = new SchedulerSequence();
- sequence.SchedulerModule = SchedulerManager.Instance.GetScheduler(ModuleName.Loader1);
- sequence.SequenceIndex = index;
- sequence.ModuleName = ModuleName.Loader1;
- sequence.State = RState.Init;
- sequence.Recipe = null;
- sequence.Parameters = parameter;
- sequence.ModuleType = ModuleType.Loader;
- sequence.MaterialType = MaterialType.WaferHolder;
- sequence.WaferSize = waferSize;
- index++;
- return sequence;
- }
- /// <summary>
- /// 创建Loader步骤
- /// </summary>
- /// <param name="index"></param>
- /// <returns></returns>
- private SchedulerSequence CreateSRDSequence(SrdRecipe recipe,ref int index)
- {
- SchedulerSequence sequence = new SchedulerSequence();
- sequence.SequenceIndex = index;
- sequence.State = RState.Init;
- sequence.Recipe = recipe;
- sequence.ModuleType = ModuleType.SRD;
- sequence.MaterialType = MaterialType.Wafer;
- index++;
- return sequence;
- }
- /// <summary>
- /// 创建LoaderTransporter步骤
- /// </summary>
- /// <param name="index"></param>
- /// <returns></returns>
- private SchedulerSequence CreateLoaderTransporterSequence(TransporterAction transporterAction, List<SchedulerSyncModuleMessage> synModules,int waferSize, ref int index)
- {
- SchedulerSequence sequence = new SchedulerSequence();
- sequence.ModuleType = ModuleType.Transporter;
- sequence.ModuleName = ModuleName.Transporter2;
- sequence.SequenceIndex = index;
- sequence.State = RState.Init;
- sequence.Recipe = null;
- sequence.SchedulerModule = SchedulerManager.Instance.GetScheduler(ModuleName.Transporter2);
- sequence.Parameters = transporterAction;
- sequence.MaterialType = MaterialType.WaferHolder;
- sequence.SynchronousModuleMessages = synModules;
- sequence.WaferSize = waferSize;
- index++;
- return sequence;
- }
- /// <summary>
- /// 创建LoaderTransporter步骤
- /// </summary>
- /// <param name="index"></param>
- /// <returns></returns>
- private SchedulerSequence CreateProcessTransporterSequence(TransporterAction transporterAction,int waferSize, ref int index)
- {
- SchedulerSequence sequence = new SchedulerSequence();
- sequence.ModuleType = ModuleType.Transporter;
- sequence.ModuleName = ModuleName.Transporter1;
- sequence.SequenceIndex = index;
- sequence.State = RState.Init;
- sequence.Recipe = null;
- sequence.SchedulerModule = SchedulerManager.Instance.GetScheduler(ModuleName.Transporter1);
- sequence.Parameters= transporterAction;
- sequence.MaterialType = MaterialType.WaferHolder;
- sequence.WaferSize = waferSize;
- index++;
- return sequence;
- }
- /// <summary>
- /// 获取可用Dummy slot
- /// </summary>
- /// <param name="moduleType"></param>
- /// <returns></returns>
- public (ModuleName moduleName, int slot) GetAvaibleDummySlots(WaferSize waferSize)
- {
- if (ModuleHelper.IsInstalled(ModuleName.Dummy1))
- {
- DummyEntity dummyEntity = Singleton<RouteManager>.Instance.GetModule<DummyEntity>(ModuleName.Dummy1.ToString());
- DummyDevice dummyDevice = Singleton<RouteManager>.Instance.EFEM.GetDummyDevice(0);
- if (dummyDevice != null && dummyDevice.HasCassette && dummyDevice.WaferSize == waferSize)
- {
- for (int i = 0; i < dummyEntity.MaxSlotNumber; i++)
- {
- if (WaferManager.Instance.CheckNoWafer(ModuleName.Dummy1, i))
- {
- return (ModuleName.Dummy1, i);
- }
- }
- }
- }
- if (ModuleHelper.IsInstalled(ModuleName.Dummy2))
- {
- DummyEntity dummyEntity = Singleton<RouteManager>.Instance.GetModule<DummyEntity>(ModuleName.Dummy2.ToString());
- DummyDevice dummyDevice = Singleton<RouteManager>.Instance.EFEM.GetDummyDevice(1);
- if (dummyDevice != null && dummyDevice.HasCassette && dummyDevice.WaferSize == waferSize)
- {
- for (int i = 0; i < dummyEntity.MaxSlotNumber; i++)
- {
- if (WaferManager.Instance.CheckNoWafer(ModuleName.Dummy2, i))
- {
- return (ModuleName.Dummy2, i);
- }
- }
- }
- }
- return (ModuleName.Unknown, -1);
- }
- /// <summary>
- /// 根据模块类型获取可用模块
- /// </summary>
- /// <param name="moduleType"></param>
- /// <returns></returns>
- public ModuleName GetAvaibleModuleCell(string sequenceType,ModuleType moduleType, ModuleName moduleName = ModuleName.Unknown)
- {
- if (ModuleHelper.IsMetal(moduleName))
- {
- List<IModuleEntity> entities = Singleton<RouteManager>.Instance.GetModulesByModuleType(moduleType);
- return GetMetalAvaibleRinseModule(entities, moduleName);
- }
- else
- {
- List<IModuleEntity> entities = Singleton<RouteManager>.Instance.GetModulesByModuleType(moduleType);
- List<IModuleEntity> avaibles = new List<IModuleEntity>();
- foreach (var item in entities)
- {
- bool result = CheckAvaibleModule(item,moduleType,sequenceType);
- if (result)
- {
- avaibles.Add(item);
- }
- }
- return GetMinTimeToReadyModule(avaibles,moduleType);
- }
- }
- /// <summary>
- /// 根据模块类型获取可用模块(不包含WH)
- /// </summary>
- /// <param name="moduleType"></param>
- /// <returns></returns>
- public ModuleName GetAvaibleEmptyModuleCell(ModuleType moduleType,string sequenceType, ModuleName moduleName = ModuleName.Unknown)
- {
- if (ModuleHelper.IsMetal(moduleName))
- {
- List<IModuleEntity> entities = Singleton<RouteManager>.Instance.GetModulesByModuleType(moduleType);
- return GetMetalAvaibleEmptyRinseModule(entities, moduleName);
- }
- else
- {
- List<IModuleEntity> entities = Singleton<RouteManager>.Instance.GetModulesByModuleType(moduleType);
- List<IModuleEntity> avaibles = new List<IModuleEntity>();
- foreach (var item in entities)
- {
- bool result = CheckAvaibleModule(item,moduleType,sequenceType);
- if (result&&!WaferHolderManager.Instance.HasWaferHolder(item.Module.ToString()))
- {
- avaibles.Add(item);
- }
- }
- return avaibles.Count != 0 ? avaibles[0].Module : ModuleName.Unknown;
- }
- }
- /// <summary>
- /// 根据化学液计算时间获取可用MetalCell(参考其他Metal剩余时间)
- /// </summary>
- /// <param name="chemistry"></param>
- /// <returns></returns>
- public ModuleName CalculateAvaibleMetalCellByChemistry(string chemistry,string startRinse,string sequenceType,int waferSize,ref bool isExistEnableMetal)
- {
- if(!Enum.TryParse(startRinse,out ModuleName startRinseModule)||!ModuleHelper.IsRinse(startRinseModule))
- {
- startRinse = "";
- }
- isExistEnableMetal = false;
- List<MetalEntity> moduleEntities = GetAvaibleMetalList(chemistry,sequenceType,waferSize,true);
- List<IModuleEntity> avaibleMetalEntities = new List<IModuleEntity>();
- foreach (var item in moduleEntities)
- {
- if(CheckAvaibleModule(item,ModuleType.Metal,sequenceType))
- {
- if (item.WaferHolderInfo == null)
- {
- if (CheckMetalModuleRinseAvaible(item, startRinse))
- {
- avaibleMetalEntities.Add(item);
- }
- }
- isExistEnableMetal = true;
- }
- }
- if (avaibleMetalEntities.Count > 0)
- {
- return GetMinUsageMetal(avaibleMetalEntities);
- }
- return ModuleName.Unknown;
- }
- /// <summary>
- /// 根据化学液获取可用Metal
- /// </summary>
- /// <param name="chemistry"></param>
- /// <param name="sequenceType"></param>
- /// <returns></returns>
- public bool CalculateAvaibleMetalCellByChemistry(string chemistry,string sequenceType,int waferSize)
- {
- List<MetalEntity> moduleEntities = GetAvaibleMetalList(chemistry, sequenceType,waferSize,false);
- return moduleEntities.Count != 0;
- }
- /// <summary>
- /// 检验Metal模块Rinse可用性
- /// </summary>
- /// <param name="item"></param>
- /// <returns></returns>
- private bool CheckMetalModuleRinseAvaible(MetalEntity item,string startRinse)
- {
- List<LayoutCellItem> rinseItems = CellItemManager.Instance.GetRinseItemsByMetal(item.Module.ToString());
- List<string> sharedRinseItems = new List<string>();
- List<string> singleRinseItems = new List<string>();
- foreach (var cellItem in rinseItems)
- {
- RinseEntity rinseEntity = Singleton<RouteManager>.Instance.GetModule<RinseEntity>(cellItem.ModuleName);
- if (!CellItemManager.Instance.CheckRinseIsShared(cellItem.ModuleName))
- {
- if (CheckAvaibleModule(rinseEntity, ModuleType.Rinse, "") && rinseEntity.WaferHolderInfo == null)
- {
- singleRinseItems.Add(cellItem.ModuleName);
- }
- }
- else
- {
- if (CheckAvaibleModule(rinseEntity,ModuleType.Rinse,"") && rinseEntity.WaferHolderInfo == null)
- {
- sharedRinseItems.Add(cellItem.ModuleName);
- }
- //增加自己
- if (cellItem.ModuleName == startRinse && rinseEntity != null && (rinseEntity.IsIdle||rinseEntity.State==(int)RinseState.KeepWeting))
- {
- sharedRinseItems.Add(startRinse);
- }
- }
- }
- //独立的Rinse集合
- if(singleRinseItems.Count!=0)
- {
- bool result = CheckSingleRinseItemsCanUsed(singleRinseItems, item.Module.ToString());
- if(result)
- {
- return true;
- }
- }
- //仅剩下共享Rinse
- List<string> avaibleSharedList = new List<string>();
- if (sharedRinseItems.Count != 0)
- {
- foreach (string sharedRinse in sharedRinseItems)
- {
- RinseEntity rinseEntity = Singleton<RouteManager>.Instance.GetModule<RinseEntity>(sharedRinse);
- if (rinseEntity.IsBusy&&sharedRinse!=startRinse)
- {
- continue;
- }
- //检验共享Rinse是否可用
- if (CheckShardRinseCanUse(sharedRinse, item.Module.ToString(),startRinse))
- {
- avaibleSharedList.Add(sharedRinse);
- }
- }
- }
- if (avaibleSharedList.Count != 0)
- {
- var result = CalculateMetalReservoirAllBusyMetalCount(item.Module.ToString());
- if (result.success)
- {
- bool transporterTransfering = CheckProcessTransporterTransfering(avaibleSharedList);
- if(transporterTransfering)
- {
- return result.busyCount + 1 < avaibleSharedList.Count;
- }
- else
- {
- return result.busyCount < avaibleSharedList.Count+singleRinseItems.Count;
- }
- }
- }
- return false;
- }
- /// <summary>
- /// 检验Process transporter正在Transfer WH移动至Rinse
- /// </summary>
- /// <returns></returns>
- private bool CheckProcessTransporterTransfering(List<string> rinseList)
- {
- TransporterEntity processTransporterEntity = Singleton<RouteManager>.Instance.GetModule<TransporterEntity>(ModuleName.Transporter1.ToString());
- if(processTransporterEntity!=null)
- {
- if (processTransporterEntity.IsBusy)
- {
- string targetCell = processTransporterEntity.TargetCell;
- if (rinseList.Contains(targetCell))
- {
- return true;
- }
- }
- }
- return false;
- }
- /// <summary>
- /// 计算Metal所在Reservoir Busy Metal数量
- /// </summary>
- /// <param name="item"></param>
- /// <returns></returns>
- private (bool success,int busyCount) CalculateMetalReservoirAllBusyMetalCount(string metalName)
- {
- string reservoirName = ReservoirItemManager.Instance.GetReservoirByMetal(metalName);
- if (string.IsNullOrEmpty(reservoirName))
- {
- return (false,0);
- }
- List<string> metals = ReservoirItemManager.Instance.GetMetalsByReservoir(reservoirName);
- int count = 0;
- foreach (string item in metals)
- {
- if (metalName == item)
- {
- continue;
- }
- MetalEntity metalEntity = Singleton<RouteManager>.Instance.GetModule<MetalEntity>(item);
- if (metalEntity.IsBusy || metalEntity.WaferHolderInfo != null)
- {
- count++;
- }
- }
- return (true,count);
- }
- /// <summary>
- /// 检验独立Rinse是否可用
- /// </summary>
- /// <param name="singleRinseItems"></param>
- /// <param name="metalName"></param>
- /// <returns></returns>
- private bool CheckSingleRinseItemsCanUsed(List<string> singleRinseItems, string metalName)
- {
- var result = CalculateMetalReservoirAllBusyMetalCount(metalName);
- if(result.success)
- {
- bool transporterTransfering = CheckProcessTransporterTransfering(singleRinseItems);
- if (transporterTransfering)
- {
- return result.busyCount + 1 < singleRinseItems.Count;
- }
- else
- {
- return result.busyCount < singleRinseItems.Count;
- }
- }
- return false;
- }
- /// <summary>
- /// 检验共享Rinse是否可用
- /// </summary>
- /// <param name="sharedRinse"></param>
- /// <param name="metalName"></param>
- /// <returns></returns>
- private bool CheckShardRinseCanUse(string sharedRinse, string metalName,string startRinse)
- {
- string reservoirName = ReservoirItemManager.Instance.GetReservoirByMetal(metalName);
- List<string> shardReservoirs = CellItemManager.Instance.GetReservoirsBySharedRinse(sharedRinse);
- if (shardReservoirs == null || shardReservoirs.Count == 0)
- {
- return false;
- }
- foreach (string reservoir in shardReservoirs)
- {
- if (reservoir==reservoirName)
- {
- continue;
- }
- List<string> metals=ReservoirItemManager.Instance.GetMetalsByReservoir(reservoir);
- int metalCount = 0;
- int busyMetalCount = 0;
- foreach(string metal in metals)
- {
- MetalEntity metalEntity = Singleton<RouteManager>.Instance.GetModule<MetalEntity>(metal);
- if(metalEntity.IsAuto&&metalEntity.IsInitialized)
- {
- metalCount++;
- }
- if(metalEntity.IsBusy||metalEntity.WaferHolderInfo!=null)
- {
- busyMetalCount++;
- }
- }
- List<string> reservoirRinseLst = CellItemManager.Instance.GetRinsesByReservoir(reservoir);
- int rinseCount = 0;
- int busyRinseCount = 0;
- foreach(string rinseItem in reservoirRinseLst)
- {
- RinseEntity rinseEntity = Singleton<RouteManager>.Instance.GetModule<RinseEntity>(rinseItem);
- if(rinseEntity.IsAuto&&rinseEntity.IsInitialized)
- {
- rinseCount++;
- }
- if (rinseItem == sharedRinse)
- {
- continue;
- }
- if (rinseItem == startRinse)
- {
- continue;
- }
- if(rinseEntity.IsBusy||rinseEntity.WaferHolderInfo!=null)
- {
- busyRinseCount++;
- }
- }
- int resRinseCount=rinseCount- busyRinseCount;
- //计算剩余Rinse数量小于等于busy metal数量,则不可用
- if (resRinseCount <= busyMetalCount)
- {
- return false;
- }
- }
- return true;
- }
- /// <summary>
- /// 检验模块是否可用(不包含WH)
- /// </summary>
- /// <param name="item"></param>
- /// <returns></returns>
- private bool CheckAvaibleEmptyModule(IModuleEntity item,ModuleType moduleType,string sequenceType)
- {
- if (!CheckAvaibleModule(item, moduleType, sequenceType))
- {
- return false;
- }
- if (!ModuleHelper.IsSRD(item.Module))
- {
- WaferHolderInfo waferHolderInfo = WaferHolderManager.Instance.GetWaferHolder(item.Module.ToString());
- if (waferHolderInfo == null)
- {
- return true;
- }
- }
- else
- {
- if (!WaferManager.Instance.CheckHasWafer(item.Module, 0))
- {
- return true;
- }
- }
- return false;
- }
- /// <summary>
- /// 检验模块是否可用
- /// </summary>
- /// <param name="item"></param>
- /// <returns></returns>
- public bool CheckAvaibleModule(IModuleEntity item,ModuleType moduleType,string sequenceType)
- {
- if (item.IsDisable)
- {
- return false;
- }
- if (!item.IsAuto)
- {
- return false;
- }
- if (item.IsError)
- {
- return false;
- }
- if (item.IsInit)
- {
- return false;
- }
- if (moduleType==ModuleType.Metal)
- {
- if(item.IsProduction && sequenceType == ENGINEERING)
- return false;
- if (item.IsEngineering && sequenceType == PRODUCTION)
- return false;
- }
- return true;
- }
- /// <summary>
- /// 获取剩余时间最小的模块
- /// </summary>
- /// <param name="avaibles"></param>
- /// <returns></returns>
- private ModuleName GetMinTimeToReadyModule(List<IModuleEntity> avaibles,ModuleType moduleType)
- {
- if (avaibles.Count == 1)
- {
- return avaibles[0].Module;
- }
- int timeToReady = int.MaxValue;
- IModuleEntity selectedModule = null;
- List<IModuleEntity> idleModuleEtities = new List<IModuleEntity>();
- foreach (var item in avaibles)
- {
- if (item.IsIdle)
- {
- if(moduleType!=ModuleType.Metal)
- {
- return item.Module;
- }
- idleModuleEtities.Add(item);
- }
- if (item.TimeToReady < timeToReady&&idleModuleEtities.Count==0)
- {
- timeToReady = item.TimeToReady;
- selectedModule = item;
- }
- }
- if (idleModuleEtities.Count != 0)
- {
- return GetMinUsageMetal(idleModuleEtities);
- }
- if (selectedModule != null)
- {
- return selectedModule.Module;
- }
- return ModuleName.Unknown;
- }
- /// <summary>
- /// 获取电量最小的Metal
- /// </summary>
- /// <param name="idleModuleEntities"></param>
- /// <returns></returns>
- private ModuleName GetMinUsageMetal(List<IModuleEntity> idleModuleEntities)
- {
- double usage = double.MaxValue;
- ModuleName selectedModuleName = ModuleName.Unknown;
- foreach (var item in idleModuleEntities)
- {
- MetalEntity metalEntity= item as MetalEntity;
- if(metalEntity!=null)
- {
- MetalUsage metalUsage = metalEntity.MetalUsage;
- if (metalUsage == null)
- {
- return metalEntity.Module;
- }
- if (metalUsage.TotalUsage < usage)
- {
- usage= metalUsage.TotalUsage;
- selectedModuleName = metalEntity.Module;
- }
- }
- }
- return selectedModuleName;
- }
- /// <summary>
- /// 获取Metal可用的Rinse模块
- /// </summary>
- /// <param name="metalName"></param>
- /// <returns></returns>
- private ModuleName GetMetalAvaibleRinseModule(List<IModuleEntity> items, ModuleName metalName)
- {
- int metalId = CellItemManager.Instance.GetCellIdByModuleName(metalName.ToString());
- if (metalId == 0)
- {
- return ModuleName.Unknown;
- }
- List<LayoutCellItem> rinseItems = CellItemManager.Instance.GetRinseItemsByMetal(metalName.ToString());
- if (rinseItems.Count == 0)
- {
- return ModuleName.Unknown;
- }
- List<IModuleEntity> avaibles = new List<IModuleEntity>();
- foreach (var item in items)
- {
- LayoutCellItem cellItem = rinseItems.Find(O => O.ModuleName == item.Module.ToString());
- if (cellItem != null)
- {
- RinseEntity rinseEntity = (RinseEntity)item;
- if (rinseEntity.IsInitialized && rinseEntity.IsAuto)
- {
- avaibles.Add(rinseEntity);
- }
- }
- }
- int minInterval = int.MaxValue;
- IModuleEntity moduleEntity = null;
- foreach (var item in avaibles)
- {
- LayoutCellItem cellItem = rinseItems.Find(O => O.ModuleName == item.Module.ToString());
- if (cellItem != null)
- {
- int abiasId = Math.Abs(metalId - cellItem.CellID);
- if (abiasId < minInterval)
- {
- minInterval = abiasId;
- moduleEntity = item;
- }
- }
- }
- if (moduleEntity != null)
- {
- return moduleEntity.Module;
- }
- return ModuleName.Unknown;
- }
- /// <summary>
- /// 检验Metal可用的Rinse模块
- /// </summary>
- /// <param name="metalName"></param>
- /// <returns></returns>
- private ModuleName GetMetalAvaibleEmptyRinseModule(List<IModuleEntity> items, ModuleName metalName)
- {
- int metalId = CellItemManager.Instance.GetCellIdByModuleName(metalName.ToString());
- if (metalId == 0)
- {
- return ModuleName.Unknown;
- }
- List<LayoutCellItem> rinseItems = CellItemManager.Instance.GetRinseItemsByMetal(metalName.ToString());
- if (rinseItems.Count == 0)
- {
- return ModuleName.Unknown;
- }
- List<IModuleEntity> avaibles = new List<IModuleEntity>();
- List<ModuleName> sharedRinseList = new List<ModuleName>();
- foreach (var item in items)
- {
- LayoutCellItem cellItem = rinseItems.Find(O => O.ModuleName == item.Module.ToString());
- if (cellItem != null)
- {
- RinseEntity rinseEntity = (RinseEntity)item;
- if (rinseEntity.IsIdle && rinseEntity.IsAuto && rinseEntity.WaferHolderInfo == null)
- {
- avaibles.Add(rinseEntity);
- if(CellItemManager.Instance.CheckRinseIsShared(rinseEntity.Module.ToString()))
- {
- sharedRinseList.Add(rinseEntity.Module);
- }
- }
- }
- }
- int minInterval = int.MaxValue;
- IModuleEntity moduleEntity = null;
- foreach (var item in avaibles)
- {
- if (sharedRinseList.Contains(item.Module))
- {
- continue;
- }
- LayoutCellItem cellItem = rinseItems.Find(O => O.ModuleName == item.Module.ToString());
- if (cellItem != null)
- {
- int abiasId = Math.Abs(metalId - cellItem.CellID);
- if (abiasId < minInterval)
- {
- minInterval = abiasId;
- moduleEntity = item;
- }
- }
- }
- if (moduleEntity != null)
- {
- return moduleEntity.Module;
- }
- else if(sharedRinseList.Count!=0)
- {
- return sharedRinseList[0];
- }
- return ModuleName.Unknown;
- }
- /// <summary>
- /// 检验Metal cell recipe时间是否可用
- /// </summary>
- /// <param name="depRecipe"></param>
- /// <returns></returns>
- public bool CheckMetalCellRecipeTimeAvaible(IModuleEntity metalEntity,DepRecipe depRecipe)
- {
- List<IModuleEntity> metalEntities=Singleton<RouteManager>.Instance.GetModulesByModuleType(ModuleType.Metal);
- int maxTimeToReady = 0;
- foreach (MetalEntity item in metalEntities)
- {
- if (metalEntity.Module == item.Module)
- {
- continue;
- }
- if(item.IsBusy)
- {
- if(maxTimeToReady>item.TimeToReady)
- {
- maxTimeToReady = item.TimeToReady;
- }
- }
- }
- int transferOffSecond = SC.GetValue<int>("Transporter.TransporterTransferOffSeconds");
- int recipeTotalTime = depRecipe.CalculateRecipeTotalTime();
- //增加了Transporter最大传输时间和最小传输时间的差值
- if (recipeTotalTime>=maxTimeToReady+transferOffSecond)
- {
- return true;
- }
- return false;
- }
- /// <summary>
- /// 根据化学液获取可用的metal集合
- /// </summary>
- /// <param name="chemistry"></param>
- /// <returns></returns>
- public List<MetalEntity> GetAvaibleMetalList(string chemistry, string sequenceType,int waferSize, bool isEmpty)
- {
- List<IModuleEntity> reservoirEntities = Singleton<RouteManager>.Instance.GetModulesByModuleType(ModuleType.Reservoir);
- List<string> avaibles = new List<string>();
- foreach (IModuleEntity item in reservoirEntities)
- {
- ReservoirEntity entity = item as ReservoirEntity;
- if (entity.Chemistry == chemistry && entity.IsAuto && entity.IsInitialized)
- {
- avaibles.Add(entity.Module.ToString());
- }
- }
- List<MetalEntity> metals = new List<MetalEntity>();
- foreach (string item in avaibles)
- {
- ReservoirItem reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(item);
- if (reservoirItem == null)
- {
- continue;
- }
- foreach (MetalItem subItem in reservoirItem.MetalCells)
- {
- MetalEntity entity = Singleton<RouteManager>.Instance.GetModule<MetalEntity>($"Metal{subItem.MetalID}");
- if (!CheckAvaibleModule(entity, ModuleType.Metal, sequenceType))
- {
- continue;
- }
- if (entity.MetalWaferSize != waferSize)
- {
- continue;
- }
- if (!isEmpty || (isEmpty && entity.WaferHolderInfo == null))
- {
- metals.Add(entity);
- }
- }
- }
- return metals;
- }
- /// <summary>
- /// 获取上一个Metal
- /// </summary>
- /// <param name="sequenceIndex"></param>
- /// <param name="sequences"></param>
- /// <returns></returns>
- public ModuleName GetPreMetalModuleName(int sequenceIndex,List<SchedulerSequence> sequences)
- {
- for(int i = sequenceIndex - 1; i >= 0; i--)
- {
- SchedulerSequence schedulerSequence= sequences[i];
- if (schedulerSequence.ModuleType == ModuleType.Metal && ModuleHelper.IsMetal(schedulerSequence.ModuleName))
- {
- return schedulerSequence.ModuleName;
- }
- }
- return ModuleName.Unknown;
- }
- }
- }
|