123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344 |
- 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
- /// <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 waferCount)
- {
- 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, waferCount);
- List<SchedulerSyncModuleMessage> synModules = GenerateLoaderTransporterSyncModuleMessage(strTRNP);
- SchedulerSequence bufferToLoaderSequence = CreateLoaderTransporterSequence(transporterAction,synModules,waferHolderInfo.WaferSize, ref index);
- schedulerSequences.Add(bufferToLoaderSequence);
- //尺寸不一致
- bool needFlip = CheckLoaderWaferSizeNotEqual() && waferCount == 2;
- //Loader
- LoaderParameter parameter = new LoaderParameter();
- parameter.WaferCount= needFlip?1: waferCount;
- 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 waferCount)
- {
- int sideAWaferSize = SC.GetValue<int>($"Loader1.SideAWaferSize");
- int sideBWaferSize = SC.GetValue<int>($"Loader1.SideBWaferSize");
- //单片,同时loader两边尺寸不一致
- if (waferCount == 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()
- {
- int sideAWaferSize = SC.GetValue<int>($"Loader1.SideAWaferSize");
- int sideBWaferSize = SC.GetValue<int>($"Loader1.SideBWaferSize");
- 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 waferCount)
- {
- int index = 0;
- List<SchedulerSequence> schedulerSequences = new List<SchedulerSequence>();
- string strTRNP = AnalyseLoadTransporterSide(waferHolderInfo.SequenceRecipe, waferCount);
- //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() && waferCount == 2;
- //Loader
- LoaderParameter parameter = new LoaderParameter();
- parameter.WaferCount = needFlip ? 1 : waferCount; ;
- 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;
- }
- }
- }
|