12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Diagnostics;
- using Aitex.Core.Common;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using Aitex.Sorter.Common;
- using Aitex.Core.RT.Log;
- using Aitex.Core.Util;
- using Aitex.Core.RT.DataCenter;
- using Aitex.Core.RT.RecipeCenter;
- using Aitex.Core.RT.Fsm;
- using MECF.Framework.Common.Jobs;
- using MECF.Framework.Common.Routine;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.SubstrateTrackings;
- using MECF.Framework.Common.Schedulers;
- using MECF.Framework.Common.DBCore;
- using Venus_Core;
- using Venus_RT.Modules.Schedulers;
- using Venus_RT.Scheduler;
- using Venus_Unity;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.PMs;
- using System.Linq.Expressions;
- using Aitex.Core.UI.Control;
- namespace Venus_RT.Modules
- {
- public class WaferTask
- {
- public ModuleName sourceMod { get; }
- public int sourceSlot { get; }
- public ModuleName destMod { get; private set; }
- public int destSlot { get; private set; }
- public ModuleName currentMod { get; private set; }
- public int currentSlot { get; private set; }
- public ModuleName nextMod { get; private set; }
- public int nextSlot { get; private set; }
- public ModuleName routedMod { get; private set; }
- public int routedSlot { get; private set; }
- public Hand hand { get; private set; }
- public SequenceLLInOutPath llInOutPath { get; }
- public string processRecipe { get; }
- public string wtwCleanRecipe { get; }
- public float temperature { get; }
- public Guid waferId { get; }
- public Guid lotId { get; }
- public int elapseTime { get { return (int)(DateTime.Now - _scheduledTime).TotalSeconds; } }
- public int llDelayTime { get; }
- public RState pressureStatus { get; private set; }
- public RState temperatureStatus { get; private set; }
- public RState movingStatus { get; private set; }
- public bool IsCompleted { get { return movingStatus == RState.End && currentMod == destMod && currentSlot == destSlot; } }
- public bool IsTimeout { get { return elapseTime > 600; } }
- public bool IsAligned { get; set; }
- public bool IsWaitingAtmMoving
- {
- get
- {
- if (movingStatus != RState.Init)
- return false;
- return !IsWaitingVacMoving;
- }
- }
- public bool IsWaitingVacMoving
- {
- get
- {
- if (movingStatus == RState.Init &&
- (ModuleHelper.IsPm(nextMod) ||
- ModuleHelper.IsTMRobot(nextMod) ||
- ModuleHelper.IsPm(currentMod) ||
- ModuleHelper.IsTMRobot(currentMod)))
- return true;
- return false;
- }
- }
- public delegate void WaferMoveHandler(WaferTask wafer, MoveItem item);
- public event WaferMoveHandler OnWaferArrived;
- public event WaferMoveHandler OnWaferLeaved;
- private DateTime _scheduledTime;
- public WaferTask(ModuleName source, int srcSlot, ModuleName dest, int dstSlot, float temp, Guid waferID, Guid lotID, string recipeName, string wtwClean, SequenceLLInOutPath inOutPath, int LLDelay, bool needAlign)
- {
- sourceMod = currentMod = nextMod = routedMod = source;
- sourceSlot = currentSlot = nextSlot = routedSlot = srcSlot;
- destMod = dest;
- destSlot = dstSlot;
- hand = Hand.None;
- temperature = temp;
- waferId = waferID;
- lotId = lotID;
- processRecipe = recipeName;
- wtwCleanRecipe = wtwClean;
- llInOutPath = inOutPath;
- llDelayTime = LLDelay;
- IsAligned = !needAlign;
- pressureStatus = RState.Init;
- temperatureStatus = RState.End;
- movingStatus = RState.Init;
- _scheduledTime = DateTime.Now;
- }
- public RState Run()
- {
- if (movingStatus == RState.Running)
- {
- var wafer = WaferManager.Instance.GetWafer(nextMod, nextSlot);
- if (!wafer.IsEmpty && wafer.InnerId == waferId)
- {
- LOG.Write(eEvent.EV_ROUTER, ModuleName.System, $"Wafer {wafer.WaferOrigin} from {currentMod}.{currentSlot + 1} move to {nextMod}.{nextSlot + 1}");
- if (!ModuleHelper.IsTMRobot(currentMod) && !ModuleHelper.IsEFEMRobot(currentMod))
- {
- OnWaferLeaved(this, new MoveItem(currentMod, currentSlot, nextMod, nextSlot, hand));
- }
- if (!ModuleHelper.IsTMRobot(nextMod) && !ModuleHelper.IsEFEMRobot(nextMod))
- {
- _scheduledTime = DateTime.Now;
- wafer.NextSequenceStep++;
- OnWaferArrived(this, new MoveItem(currentMod, currentSlot, nextMod, nextSlot, hand));
- }
- currentMod = nextMod;
- currentSlot = nextSlot;
- movingStatus = RState.End;
- }
- }
- return RState.Running;
- }
- public void RouteTo(ModuleName mod, int slot)
- {
- routedMod = mod;
- routedSlot = slot;
- movingStatus = RState.Init;
- }
- public void MoveTo(ModuleName mod, int slot)
- {
- nextMod = mod;
- nextSlot = slot;
- movingStatus = RState.Running;
- if (ModuleHelper.IsLoadLock(currentMod) && ModuleHelper.IsTMRobot(nextMod) && ModuleHelper.IsLoadLock(routedMod))
- {
- routedMod = ModuleName.TMRobot; // fix the bug which missing call RouteTo() on Vac side
- }
- }
- public void ReAssignPM(ModuleName pm, int slot)
- {
- destMod = pm;
- destSlot = slot;
- }
- public void Return()
- {
- destMod = sourceMod;
- destSlot = sourceSlot;
- movingStatus = RState.End;
- pressureStatus = RState.End;
- temperatureStatus = RState.End;
- }
- }
- public enum ModuleStatus
- {
- Idle,
- WaitMove,
- Moving,
- NotReady,
- // PM Status
- WaitProcess,
- StartProcess,
- Processing,
- StartIdleClean,
- IdleClean,
- WaitPreJobClean,
- StartPreJobClean,
- PreJobClean,
- WaitPostJobClean,
- StartPostJobClean,
- PostJobClean,
- WaitWTWClean,
- StartWTWClean,
- WTWClean,
- // Align Status
- WaitAlign,
- StartAlign,
- Aligning,
- // Loadlock Status
- StartPump,
- Pumping,
- VacReady,
- StartVent,
- Venting,
- AtmReady,
- WaitCooling,
- StartCooling,
- Cooling,
- CoolingDone,
- // Unknown
- Unknown,
- }
- public class ModuleTask
- {
- public ModuleName Module { get; }
- public ModuleStatus Status { get; set; }
- public SchedulerModule Scheduler { get; }
- public virtual int SlotNum { get; protected set; }
- public virtual bool IsIdle { get { return Status == ModuleStatus.Idle; } }
- public virtual bool HasWafer { get { return WaferManager.Instance.CheckHasWafer(Module, 0); } }
- private int _currentActionTime = 0;
- public virtual int IdleTime
- {
- get
- {
- if (Status != ModuleStatus.Idle)
- return 0;
- return (int)(DateTime.Now - _moduleTimer).TotalSeconds;
- }
- }
- public virtual int BusyTime
- {
- get
- {
- if (Status == ModuleStatus.Idle)
- return 0;
- return (int)(DateTime.Now - _moduleTimer).TotalSeconds;
- }
- }
- public virtual int BusyLastTime
- {
- get
- {
- if (Status == ModuleStatus.Idle)
- return 0;
- return _currentActionTime - BusyTime;
- }
- }
- public virtual int TimeToReady
- {
- get
- {
- if (Scheduler.IsAvailable)
- return 0;
- return int.MaxValue / 2;
- }
- }
- protected DateTime _moduleTimer;
- public ModuleTask(ModuleName mod)
- {
- Module = mod;
- Scheduler = Singleton<TransferModule>.Instance.GetScheduler(mod);
- SlotNum = 1;
- _moduleTimer = DateTime.Now;
- }
- public virtual RState Run()
- {
- Status = Scheduler.IsAvailable ? ModuleStatus.Idle : ModuleStatus.NotReady;
- return RState.Running;
- }
- public virtual void WaferArrived(WaferTask wafer, int slot)
- {
- }
- public virtual void WaferLeaved(WaferTask wafer, int slot)
- {
- }
- public virtual void ResetTask()
- {
- }
- }
- public class PMTask : ModuleTask
- {
- enum CleanType
- {
- IdleClean,
- PreJobClean,
- PostJobClean,
- WTWClean,
- }
- public override int TimeToReady
- {
- get
- {
- switch (Status)
- {
- case ModuleStatus.Idle:
- case ModuleStatus.Processing:
- case ModuleStatus.IdleClean:
- case ModuleStatus.PreJobClean:
- {
- return Scheduler.IsAvailable ? 0 : (Scheduler.TimeToReady + 500) / 1000;
- }
- case ModuleStatus.PostJobClean:
- case ModuleStatus.WTWClean:
- {
- if (_pendingCleanTask.Count == 0)
- {
- return Scheduler.IsAvailable ? 0 : (Scheduler.TimeToReady + 500) / 1000;
- }
- }
- break;
- }
- return int.MaxValue / 2;
- }
- }
- public bool HasPendingCleanTask => _pendingCleanTask.Count > 0;
- private WaferTask _wafer;
- private SchedulerPM _pmScheduler => Scheduler as SchedulerPM;
- private string _preJobCleanRecipe;
- private string _postJobCleanRecipe;
- private string _wtwCleanRecipe;
- private Queue<CleanType> _pendingCleanTask = new Queue<CleanType>();
- public PMTask(ModuleName pm) : base(pm)
- {
- }
- public override RState Run()
- {
- if (Scheduler.IsIdle)
- {
- switch (Status)
- {
- case ModuleStatus.Idle:
- {
- if (WaferManager.Instance.CheckNoWafer(Module, 0) && Scheduler.IsOnline)
- {
- if (_pendingCleanTask.Count > 0)
- {
- var cleanTask = _pendingCleanTask.Dequeue();
- if (cleanTask == CleanType.PostJobClean && !string.IsNullOrWhiteSpace(_postJobCleanRecipe))
- {
- Status = ModuleStatus.WaitPostJobClean;
- }
- else if (cleanTask == CleanType.PreJobClean && !string.IsNullOrWhiteSpace(_preJobCleanRecipe))
- {
- Status = ModuleStatus.WaitPreJobClean;
- }
- }
- else if (_pmScheduler.RunIdleCleanTask()) // Check Idle Clean
- {
- Status = ModuleStatus.StartIdleClean;
- }
- }
- }
- break;
- case ModuleStatus.WaitProcess:
- {
- Scheduler.EventWaferArrived?.Invoke(this, new WaferMoveArgs(ModuleName.TMRobot, 0, Module, 0));
- Status = ModuleStatus.StartProcess;
- }
- break;
- case ModuleStatus.WaitPreJobClean:
- {
- if (WaferManager.Instance.CheckNoWafer(Module, 0))
- {
- if (_pmScheduler.RunJobCleanTask(_preJobCleanRecipe))
- {
- Status = ModuleStatus.StartPreJobClean;
- }
- else
- {
- LOG.Write(eEvent.WARN_ROUTER, Module, $"Run Prejob clean recipe{_preJobCleanRecipe} failed");
- Status = ModuleStatus.Idle;
- _preJobCleanRecipe = string.Empty;
- }
- }
- }
- break;
- case ModuleStatus.WaitPostJobClean:
- {
- if (WaferManager.Instance.CheckNoWafer(Module, 0))
- {
- if (_pmScheduler.RunJobCleanTask(_postJobCleanRecipe))
- {
- Status = ModuleStatus.StartPostJobClean;
- }
- else
- {
- LOG.Write(eEvent.WARN_ROUTER, Module, $"Run Postjob clean recipe{_postJobCleanRecipe} failed");
- Status = ModuleStatus.Idle;
- _postJobCleanRecipe = string.Empty;
- }
- }
- }
- break;
- case ModuleStatus.WaitWTWClean:
- {
- if (WaferManager.Instance.CheckNoWafer(Module, 0))
- {
- if (_pmScheduler.RunJobCleanTask(_wtwCleanRecipe))
- {
- Status = ModuleStatus.StartWTWClean;
- }
- else
- {
- LOG.Write(eEvent.WARN_ROUTER, Module, $"Run WTW Wafer clean recipe{_wtwCleanRecipe} failed");
- Status = ModuleStatus.Idle;
- _wtwCleanRecipe = string.Empty;
- }
- }
- }
- break;
- case ModuleStatus.Processing:
- {
- var wafer = WaferManager.Instance.GetWafer(Module, 0);
- if (Scheduler.IsOnline)
- {
- if (!wafer.IsEmpty && wafer.ProcessState == EnumWaferProcessStatus.Completed)
- {
- _wafer.Return();
- Status = ModuleStatus.Idle;
- }
- }
- else // handle offline exception situation
- {
- Status = ModuleStatus.Idle;
- }
- }
- break;
- case ModuleStatus.PreJobClean:
- {
- _preJobCleanRecipe = string.Empty;
- Status = ModuleStatus.Idle;
- }
- break;
- case ModuleStatus.PostJobClean:
- {
- _postJobCleanRecipe = string.Empty;
- if (_pendingCleanTask.Count > 0)
- {
- var cleanTask = _pendingCleanTask.Dequeue();
- if (cleanTask == CleanType.PreJobClean && !string.IsNullOrWhiteSpace(_preJobCleanRecipe))
- {
- Status = ModuleStatus.WaitPreJobClean;
- break;
- }
- }
- Status = ModuleStatus.Idle;
- }
- break;
- case ModuleStatus.WTWClean:
- {
- if (_pendingCleanTask.Count > 0)
- {
- var cleanTask = _pendingCleanTask.Dequeue();
- if (cleanTask == CleanType.PostJobClean && !string.IsNullOrWhiteSpace(_postJobCleanRecipe))
- {
- Status = ModuleStatus.WaitPostJobClean;
- }
- else if (cleanTask == CleanType.PreJobClean && !string.IsNullOrWhiteSpace(_preJobCleanRecipe))
- {
- Status = ModuleStatus.WaitPreJobClean;
- }
- }
- else
- {
- Status = ModuleStatus.Idle;
- }
- _wtwCleanRecipe = string.Empty;
- }
- break;
- case ModuleStatus.IdleClean:
- {
- Status = ModuleStatus.Idle;
- }
- break;
- case ModuleStatus.StartProcess:
- {
- if (RouteManager.IsATMMode)
- {
- Status = ModuleStatus.Processing;
- }
- }
- break;
- }
- }
- else
- {
- switch (Status)
- {
- case ModuleStatus.StartProcess:
- Status = ModuleStatus.Processing;
- break;
- case ModuleStatus.StartIdleClean:
- Status = ModuleStatus.IdleClean;
- break;
- case ModuleStatus.StartPreJobClean:
- Status = ModuleStatus.PreJobClean;
- break;
- case ModuleStatus.StartPostJobClean:
- Status = ModuleStatus.PostJobClean;
- break;
- case ModuleStatus.StartWTWClean:
- Status = ModuleStatus.WTWClean;
- break;
- }
- }
- return RState.Running;
- }
- public override void WaferArrived(WaferTask wafer, int slot)
- {
- _wafer = wafer;
- Status = ModuleStatus.WaitProcess;
- }
- public override void WaferLeaved(WaferTask wafer, int slot)
- {
- if (!string.IsNullOrWhiteSpace(_wafer.wtwCleanRecipe.Trim()) && (_pendingCleanTask.Count == 0 || _pendingCleanTask.First() != CleanType.PostJobClean))
- {
- Status = ModuleStatus.WaitWTWClean;
- _wtwCleanRecipe = _wafer.wtwCleanRecipe;
- }
- else if (_pendingCleanTask.Count > 0)
- {
- var cleanTask = _pendingCleanTask.Dequeue();
- if (cleanTask == CleanType.PostJobClean && !string.IsNullOrWhiteSpace(_postJobCleanRecipe))
- {
- Status = ModuleStatus.WaitPostJobClean;
- }
- else if (cleanTask == CleanType.PreJobClean && !string.IsNullOrWhiteSpace(_preJobCleanRecipe))
- {
- Status = ModuleStatus.WaitPreJobClean;
- }
- }
- _wafer = null;
- }
- public void InvokePreJobClean(string preJobClean)
- {
- _preJobCleanRecipe = preJobClean;
- _pendingCleanTask.Enqueue(CleanType.PreJobClean);
- //LOG.Write(eEvent.INFO_TROUGHPUT_ENHANCE_TRACE, Module, $"Invoke preClean {preJobClean}");
- }
- public bool IsPreJobCleanDone()
- {
- return !_pendingCleanTask.Contains(CleanType.PreJobClean) && string.IsNullOrWhiteSpace(_preJobCleanRecipe);
- }
- public void InvokePostJobClean(string postJobClean)
- {
- _postJobCleanRecipe = postJobClean;
- _pendingCleanTask.Enqueue(CleanType.PostJobClean);
- //LOG.Write(eEvent.INFO_TROUGHPUT_ENHANCE_TRACE, Module, $"Invoke postClean {postJobClean}");
- }
- public bool IsPostJobCleanDone()
- {
- return !_pendingCleanTask.Contains(CleanType.PostJobClean) && string.IsNullOrWhiteSpace(_postJobCleanRecipe);
- }
- }
- public class AlignerTask : ModuleTask
- {
- private WaferTask _wafer;
- public AlignerTask(ModuleName aligner) : base(aligner)
- {
- }
- public override RState Run()
- {
- var efemRobot = Singleton<TransferModule>.Instance.GetScheduler(ModuleName.EfemRobot) as SchedulerEfemRobot;
- if (efemRobot == null || !efemRobot.IsAvailable)
- return RState.Running;
- switch (Status)
- {
- case ModuleStatus.WaitAlign:
- {
- efemRobot.Align(0);
- Status = ModuleStatus.Aligning;
- }
- break;
- case ModuleStatus.Aligning:
- {
- _wafer.IsAligned = true;
- Status = ModuleStatus.Idle;
- }
- break;
- }
- return RState.Running;
- }
- public override void WaferArrived(WaferTask wafer, int slot)
- {
- _wafer = wafer;
- Status = ModuleStatus.WaitAlign;
- }
- public override void WaferLeaved(WaferTask wafer, int slot)
- {
- _wafer = null;
- }
- }
- public class LoadPortTask : ModuleTask
- {
- public LoadPortTask(ModuleName lp) : base(lp)
- {
- SlotNum = SC.GetValue<int>($"EFEM.LoadPort.SlotNumber");
- }
- public override RState Run()
- {
- return base.Run();
- }
- }
- public class TMRobotTask : ModuleTask
- {
- public TMRobotTask(ModuleName tmRobot) : base(tmRobot)
- {
- SlotNum = 2;
- }
- public override RState Run()
- {
- return base.Run();
- }
- }
- public class EFEMRobotTask : ModuleTask
- {
- public EFEMRobotTask(ModuleName efemRobot) : base(efemRobot)
- {
- SlotNum = 2;
- }
- public override RState Run()
- {
- return base.Run();
- }
- public bool PostMoveItems(MoveItem[] items)
- {
- Status = ModuleStatus.Moving;
- return (Scheduler as SchedulerEfemRobot).PostMoveItems(items);
- }
- }
- public enum LLStatus
- {
- StartPump,
- Pumping,
- VacReady,
- StartVent,
- Venting,
- AtmReady,
- Unknow,
- }
- public class LoadlockTask : ModuleTask
- {
- private Dictionary<int, int> _wafersDelayTime = new Dictionary<int, int>();
- public LoadlockTask(ModuleName ll) : base(ll)
- {
- SlotNum = SC.GetValue<int>($"{ll}.SlotNumber");
- for (int slot = 0; slot < SlotNum; slot++)
- _wafersDelayTime[slot] = -1;
- }
- public override int TimeToReady
- {
- get { return Scheduler.IsAvailable ? 0 : (Scheduler.TimeToReady + 500) / 1000; }
- }
- public bool ReayForTMInTime(int seconds)
- {
- return ((RouteManager.IsATMMode ? Status == ModuleStatus.AtmReady : Status == ModuleStatus.Pumping) && TimeToReady < seconds) || Status == ModuleStatus.VacReady;
- }
- public bool ReayForEfemInTime(int seconds)
- {
- return (Status == ModuleStatus.Venting && TimeToReady < seconds) || Status == ModuleStatus.AtmReady;
- }
- public override void WaferArrived(WaferTask wafer, int slot)
- {
- Scheduler.WaferArrived(slot);
- if (ModuleHelper.IsLoadPort(wafer.destMod))
- {
- _wafersDelayTime[slot] = wafer.llDelayTime;
- }
- else
- {
- _wafersDelayTime[slot] = -1;
- }
- }
- public override void WaferLeaved(WaferTask wafer, int slot)
- {
- _wafersDelayTime[slot] = -1;
- }
- public bool PreVent()
- {
- if (Scheduler.IsAvailable && !Scheduler.IsAtm)
- {
- if ((Scheduler as SchedulerLoadLock).PreVent())
- {
- Status = ModuleStatus.StartVent;
- return true;
- }
- }
- return false;
- }
- public bool PrePump()
- {
- if (Scheduler.IsAvailable && !Scheduler.IsVac)
- {
- if ((Scheduler as SchedulerLoadLock).PrePump())
- {
- Status = ModuleStatus.StartPump;
- return true;
- }
- }
- return false;
- }
- public bool Cooling()
- {
- if (Scheduler.IsAvailable && !Scheduler.IsAtm)
- {
- if ((Scheduler as SchedulerLoadLock).Cooling())
- {
- Status = ModuleStatus.StartCooling;
- return true;
- }
- }
- return false;
- }
- public override RState Run()
- {
- if (Scheduler.IsIdle)
- {
- if (Scheduler.IsAvailable)
- {
- switch (Status)
- {
- case ModuleStatus.Pumping:
- if (Scheduler.IsVac)
- {
- Status = ModuleStatus.VacReady;
- }
- break;
- case ModuleStatus.Venting:
- if (Scheduler.IsAtm)
- {
- Status = ModuleStatus.AtmReady;
- }
- break;
- case ModuleStatus.Cooling:
- if (Scheduler.IsAtm)
- {
- Status = ModuleStatus.CoolingDone;
- }
- break;
- default:
- {
- Status = Scheduler.IsAtm ? ModuleStatus.AtmReady : Scheduler.IsVac ? ModuleStatus.VacReady : Status;
- }
- break;
- }
- }
- }
- else
- {
- switch (Status)
- {
- case ModuleStatus.StartPump:
- Status = ModuleStatus.Pumping;
- break;
- case ModuleStatus.StartVent:
- Status = ModuleStatus.Venting;
- break;
- case ModuleStatus.StartCooling:
- Status = ModuleStatus.Cooling;
- break;
- }
- }
- return RState.Running;
- }
- public int Distance
- {
- get
- {
- switch (Status)
- {
- case ModuleStatus.Idle:
- return Scheduler.IsVac ? 1 : Scheduler.IsAtm ? 7 : 5;
- case ModuleStatus.StartPump:
- case ModuleStatus.Pumping:
- return 3;
- case ModuleStatus.StartCooling:
- case ModuleStatus.Cooling:
- case ModuleStatus.StartVent:
- case ModuleStatus.Venting:
- return 9;
- default:
- return 5;
- }
- }
- }
- }
- enum LLSlotInOutOpt
- {
- AllInAllOut,
- UpperInLowerOut,
- LowerInUpperOut,
- }
- enum SpecialRoutingPattern
- {
- Disable,
- LongTimeRecipe,
- }
- class SystemDispatcher : ICycle
- {
- private List<ControlJobInfo> _lstControlJobs = new List<ControlJobInfo>();
- private List<ProcessJobInfo> _lstProcessJobs = new List<ProcessJobInfo>();
- private Queue<ControlJobInfo> _qePollingJobs = new Queue<ControlJobInfo>();
- private List<WaferTask> _lstWaferTasks = new List<WaferTask>();
- private Dictionary<ModuleName, ModuleTask> _dictModuleTask = new Dictionary<ModuleName, ModuleTask>();
- private Queue<WaferInfo> _qeReturnWafers = new Queue<WaferInfo>();
- private Queue<Guid> _qeWaitInWafers = new Queue<Guid>();
- private Queue<ModuleName> _qeWaitCoolingLLs = new Queue<ModuleName>();
- private Queue<List<MoveItem>> _efemSchdActions = new Queue<List<MoveItem>>();
- private Queue<List<MoveItem>> _tmSchdActions = new Queue<List<MoveItem>>();
- private List<MoveItem> _curEfemAction = new List<MoveItem>();
- private List<MoveItem> _curTmAction = new List<MoveItem>();
- private RState _efemRobotStatus { get { return (_dictModuleTask[ModuleName.EfemRobot].Scheduler as SchedulerEfemRobot).RobotStatus; } }
- private RState _tmRobotStatus { get { return (_dictModuleTask[ModuleName.TMRobot].Scheduler as SchedulerTMRobot).RobotStatus; } }
- private SchedulerFACallback _faCallback;
- private SchedulerDBCallback _dbCallback;
- private readonly int _LLASlotNumber = 4;
- private readonly int _LLBSlotNumber = 4;
- private int _efemRobotSingleArmOption = 0;
- private int _tmRobotSingleArmOption = 0;
- private LLSlotInOutOpt _LLSlotInOutOption = 0;
- private Dictionary<ModuleName, int> _lpCycleWafer = new Dictionary<ModuleName, int> { { ModuleName.LP1, 0 }, { ModuleName.LP2, 0 }, { ModuleName.LP3, 0 } };
- private Dictionary<ModuleName, int> _lpCycleCount = new Dictionary<ModuleName, int> { { ModuleName.LP1, 0 }, { ModuleName.LP2, 0 }, { ModuleName.LP3, 0 } };
- private Dictionary<ModuleName, int> _lpCycleSP = new Dictionary<ModuleName, int> { { ModuleName.LP1, 1 }, { ModuleName.LP2, 1 }, { ModuleName.LP3, 1 } };
- private Dictionary<ModuleName, float> _lpThroughput = new Dictionary<ModuleName, float> { { ModuleName.LP1, 0 }, { ModuleName.LP2, 0 }, { ModuleName.LP3, 0 } };
- private Dictionary<ModuleName, Stopwatch> _lpCycleWatch = new Dictionary<ModuleName, Stopwatch> { { ModuleName.LP1, new Stopwatch() }, { ModuleName.LP2, new Stopwatch() }, { ModuleName.LP3, new Stopwatch() } };
- private Dictionary<ModuleName, List<Guid>> _preLotCleanMarks = new Dictionary<ModuleName, List<Guid>>();
- private Dictionary<ModuleName, List<Guid>> _postLotCleanMarks = new Dictionary<ModuleName, List<Guid>>();
- private Stopwatch _cycleWatch = new Stopwatch();
- private SequenceLLInOutPath _LLInOutPath = SequenceLLInOutPath.DInDOut;
- private SpecialRoutingPattern _specialRoutingPattern = SpecialRoutingPattern.Disable;
- public SequenceLLInOutPath LLInOutPath => _LLInOutPath;
- public bool HasJobRunning => _lstControlJobs.Count > 0;
- private RState _cycleState = RState.Init;
- public RState CycleState => _cycleState;
- private Dictionary<string, ControlJobInfo> _loadportControlJobDic = new Dictionary<string, ControlJobInfo>();
- public List<string> InUseRecipes = new List<string>();
- public List<string> LP1InUseRecipes = new List<string>();
- public List<string> LP2InUseRecipes = new List<string>();
- public List<string> LP3InUseRecipes = new List<string>();
- #region public interface
- public SystemDispatcher()
- {
- _faCallback = new SchedulerFACallback();
- _dbCallback = new SchedulerDBCallback();
- _efemRobotSingleArmOption = SC.GetValue<int>("EFEM.SingleArmOption");
- _tmRobotSingleArmOption = SC.GetValue<int>("TM.SingleArmOption");
- _LLASlotNumber = SC.GetValue<int>("LLA.SlotNumber");
- _LLBSlotNumber = SC.GetValue<int>("LLB.SlotNumber");
- InitModules();
- DATA.Subscribe("Scheduler.PjIdList", () => Array.ConvertAll(_lstProcessJobs.ToArray(), x => x.InnerId.ToString()).ToList());
- DATA.Subscribe("Scheduler.PjNameList", () => Array.ConvertAll(_lstProcessJobs.ToArray(), x => x.LotName.ToString()).ToList());
- DATA.Subscribe("Scheduler.InUsingRecipe", () => InUseRecipes);
- foreach (var lp in new List<ModuleName> { ModuleName.LP1, ModuleName.LP2, ModuleName.LP3 })
- {
- _loadportControlJobDic[lp.ToString()] = null;
- DATA.Subscribe($"{lp}.CurrentControlJob", () => _loadportControlJobDic[lp.ToString()], SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{lp}.CycledCount", () => _lpCycleCount[lp], SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{lp}.CycledWafer", () => _lpCycleWafer[lp], SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{lp}.CycleSetPoint", () => _lpCycleSP[lp], SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{lp}.Throughput", () => _lpThroughput[lp], SubscriptionAttribute.FLAG.IgnoreSaveDB);
- }
- DATA.Subscribe("Scheduler.LP1.InUsingRecipe", () => LP1InUseRecipes);
- DATA.Subscribe("Scheduler.LP2.InUsingRecipe", () => LP2InUseRecipes);
- DATA.Subscribe("Scheduler.LP3.InUsingRecipe", () => LP3InUseRecipes);
- if (RtInstance.ConfigType == ConfigType.Kepler2200)
- {
- LOG.ModuleErrorInterrupt += (modulename, id) => ModuleErrorInterrupt(modulename, id);
- }
- }
- private void ModuleErrorInterrupt(ModuleName pmname, eEvent eEventid)
- {
- List<ModuleName> modules = new List<ModuleName>();
- _lstProcessJobs.ForEach(x =>
- {
- x.Sequence.PMs.ForEach(m => modules.Add(m));
- });
- if (modules.Contains(pmname) && (eEventid == eEvent.ERR_PM_SCRUBBER_NOOK_CONTINUEPROCESS || eEventid == eEvent.ERR_PM_SCRUBBER_NOOK_STOPPROCESS))
- {
- Singleton<RouteManager>.Instance.InvokeAbort(new object[] { ModuleName.System });
- LOG.Write(eEvent.ERR_PM_SCRUBBER_NOOK_STOPTRANSFER, ModuleName.System, $"{pmname} Scrubber Alarm ,Tranfer Stop");
- }
- }
- /// <summary>
- /// 获取lp当前的ControlJob
- /// </summary>
- /// <param name="lp"></param>
- /// <returns></returns>
- public ControlJobInfo GetLoadPortCurrentControlJob(ModuleName lp)
- {
- if (ModuleHelper.IsLoadPort(lp))
- {
- return _loadportControlJobDic.ContainsKey(lp.ToString()) ? _loadportControlJobDic[lp.ToString()] : null;
- }
- else
- {
- return null;
- }
- }
- public RState Start(params object[] objs)
- {
- if (WaferManager.Instance.HasDuplicatedWafer)
- {
- LOG.Write(eEvent.ERR_ROUTER, ModuleName.System, "System has dummy wafers, please verify all the wafer position, and delete the invalid wafer");
- return RState.Failed;
- }
- _efemRobotSingleArmOption = SC.GetValue<int>("EFEM.SingleArmOption");
- _tmRobotSingleArmOption = SC.GetValue<int>("TM.SingleArmOption");
- _LLSlotInOutOption = (LLSlotInOutOpt)SC.GetValue<int>("System.LoadlockSlotInOutOption");
- _specialRoutingPattern = (SpecialRoutingPattern)SC.GetValue<int>("System.SpecialRoutingPattern");
- // rounding TM robot single arm option
- if (_tmRobotSingleArmOption > 2 && _LLSlotInOutOption == LLSlotInOutOpt.AllInAllOut)
- {
- _tmRobotSingleArmOption = 0;
- }
- _cycleWatch.Stop();
- Clear();
- // reset cycle/throughput couter
- _lpCycleWafer = new Dictionary<ModuleName, int> { { ModuleName.LP1, 0 }, { ModuleName.LP2, 0 }, { ModuleName.LP3, 0 } };
- _lpCycleCount = new Dictionary<ModuleName, int> { { ModuleName.LP1, 0 }, { ModuleName.LP2, 0 }, { ModuleName.LP3, 0 } };
- _lpCycleSP = new Dictionary<ModuleName, int> { { ModuleName.LP1, 1 }, { ModuleName.LP2, 1 }, { ModuleName.LP3, 1 } };
- _lpThroughput = new Dictionary<ModuleName, float> { { ModuleName.LP1, 0 }, { ModuleName.LP2, 0 }, { ModuleName.LP3, 0 } };
- _lpCycleWatch = new Dictionary<ModuleName, Stopwatch> { { ModuleName.LP1, new Stopwatch() }, { ModuleName.LP2, new Stopwatch() }, { ModuleName.LP3, new Stopwatch() } };
- return RState.Running;
- }
- public RState Monitor()
- {
- if (_lstControlJobs.Any(x => x.State == EnumControlJobState.Paused))
- {
- return RState.Running;
- }
- prelude();
- RunWaferTask();
- RunModuleTasks();
- RoutingATMWafers();
- RoutingVacWafers();
- epilogue();
-
- return _cycleState;
- }
- public void Abort()
- {
- }
- public bool CreateJob(Dictionary<string, object> param, out string reason)
- {
- reason = "";
- string[] slotSequence = (string[])param["SlotSequence"];
- string module = (string)param["Module"];
- string jobId = (string)param["JobId"];
- if (string.IsNullOrEmpty(jobId))
- {
- jobId = "CJ_Local_" + module;
- }
- foreach (var item in _loadportControlJobDic.Values)
- {
- if (item?.Name == jobId)
- {
- reason = $"The same jobid {jobId} already exists, please re-enter the jobid";
- LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, reason);
- return false;
- }
- }
- string lotId = (string)param["LotId"];
- if (string.IsNullOrEmpty(lotId))
- {
- lotId = "CJ_Local_" + module;
- }
- string preCleanRecipe = param.ContainsKey("PreCleanRecipeName") ? (string)param["PreCleanRecipeName"] : string.Empty;
- string postCleanRecipe = param.ContainsKey("PostCleanRecipeName") ? (string)param["PostCleanRecipeName"] : string.Empty;
- int cycleNumber = param.ContainsKey("CycleNumber") ? (int)param["CycleNumber"] : 1;
- if (slotSequence.Length != SC.GetValue<int>("EFEM.LoadPort.SlotNumber"))
- {
- reason = $"slot sequence parameter not valid, length is {slotSequence.Length}, should be {SC.GetValue<int>("EFEM.LoadPort.SlotNumber")}";
- LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, reason);
- _faCallback.JobCreateFailed(module, lotId, jobId, "");
- return false;
- }
- if (!ModuleHelper.IsLoadPort(ModuleHelper.Converter(module)))
- {
- reason = $"{module} should be LoadPort";
- LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, reason);
- _faCallback.JobCreateFailed(module, lotId, jobId, "");
- return false;
- }
- if (_lstControlJobs.Exists(x => x.Name == jobId))
- {
- reason = $"{jobId} already created";
- LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, reason);
- _faCallback.JobCreateFailed(module, lotId, jobId, "");
- return false;
- }
- ControlJobInfo cj = new ControlJobInfo();
- cj.Name = jobId;
- cj.Module = module;
- cj.LotName = lotId;
- cj.LotInnerId = Guid.NewGuid();
- cj.LotWafers = new List<WaferInfo>();
- cj.SetState(EnumControlJobState.WaitingForStart);
- cj.JetState = EnumJetCtrlJobState.Created;
- cj.PreJobClean = preCleanRecipe;
- cj.PostJobClean = postCleanRecipe;
- cj.SequenceNameList = slotSequence;
- cj.CycleNumber = cycleNumber;
- _lpCycleSP[ModuleHelper.Converter(module)] = cj.CycleNumber;
- Dictionary<string, bool[]> seqSlot = new Dictionary<string, bool[]>();
- Dictionary<string, List<Tuple<ModuleName, int>>> seqSlotWafers = new Dictionary<string, List<Tuple<ModuleName, int>>>();
- Dictionary<string, string> indexSequence = new Dictionary<string, string>();
- bool enableGroupBySequence = SC.GetValue<bool>("Scheduler.GroupWaferBySequence");
- for (int i = 0; i < SC.GetValue<int>("EFEM.LoadPort.SlotNumber"); i++)
- {
- if (string.IsNullOrEmpty(slotSequence[i]) || string.IsNullOrEmpty(slotSequence[i].Trim()))
- continue;
- string groupName = enableGroupBySequence ? slotSequence[i].Trim() : i.ToString();
- indexSequence[groupName] = slotSequence[i];
- if (!seqSlot.ContainsKey(groupName))
- {
- seqSlot[groupName] = new bool[SC.GetValue<int>("EFEM.LoadPort.SlotNumber")];
- }
- if (!seqSlotWafers.ContainsKey(groupName))
- {
- seqSlotWafers[groupName] = new List<Tuple<ModuleName, int>>();
- }
- seqSlot[groupName][i] = true;
- if (!WaferManager.Instance.CheckHasWafer(module, i))
- {
- LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, $"job wafer: {module} slot {i + 1} not in the carrier");
- return false;
- }
- if (!WaferManager.Instance.CheckWafer(ModuleHelper.Converter(module), i, WaferStatus.Normal))
- {
- reason = $"job wafer: {module} slot {i + 1} status is {WaferManager.Instance.GetWafer(ModuleHelper.Converter(module), i).Status}";
- LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, reason);
- _faCallback.JobCreateFailed(module, lotId, jobId, "");
- return false;
- }
- if (WaferManager.Instance.GetWafer(ModuleHelper.Converter(module), i).ProcessState != EnumWaferProcessStatus.Idle)
- {
- reason = $"job wafer: {module} slot {i + 1} process status is {WaferManager.Instance.GetWafer(ModuleHelper.Converter(module), i).ProcessState}";
- LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, reason);
- _faCallback.JobCreateFailed(module, lotId, jobId, "");
- return false;
- }
- //--- 2024-03-21 增加了waferinfo 相应的lotId信息 start---
- WaferInfo waferInfo = WaferManager.Instance.GetWafer(ModuleHelper.Converter(module), i);
- cj.LotWafers.Add(waferInfo);
- waferInfo.SequenceName = slotSequence[i];
- waferInfo.LotId = lotId;
- //--- 2024-03-21 增加了waferinfo 相应的lotId信息 end---
- seqSlotWafers[groupName].Add(Tuple.Create(ModuleHelper.Converter(module), i));
- cj.JobWaferSize = WaferManager.Instance.GetWafer(ModuleHelper.Converter(module), i).Size;
- LOG.Write(eEvent.EV_ROUTER, ModuleName.System, $"Assigned wafer job, wafer {module}.{i + 1}, sequence: {slotSequence[i]}");
- }
- if (seqSlotWafers.Count == 0)
- {
- reason = $"job has not assign wafer";
- LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, reason);
- _faCallback.JobCreateFailed(module, lotId, jobId, "");
- return false;
- }
- List<ProcessJobInfo> pjs = new List<ProcessJobInfo>();
- string[] seqs = seqSlot.Keys.ToArray();
- for (int i = 0; i < seqs.Length; i++)
- {
- ProcessJobInfo pj = new ProcessJobInfo();
- pj.Name = jobId + "_" + (i + 1);
- pj.Sequence = SequenceInfoHelper.KeplerGetInfo(indexSequence[seqs[i]]);
- if (pj.Sequence == null)
- {
- reason = $"invalid sequence[{indexSequence[seqs[i]]}]";
- return false;
- }
- pj.ControlJobName = cj.Name;
- pj.LotName = lotId;
- pj.SlotWafers = seqSlotWafers[seqs[i]];
- pj.SetState(EnumProcessJobState.Queued);
- if (!CheckSequencePmReady(pj.Sequence, out reason))
- {
- LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, $"no valid chamber for the {reason}");
- _faCallback.JobCreateFailed(module, lotId, jobId, "");
- return false;
- }
- if (!RouteManager.IsATMMode && !CheckSequenceRecipeFileValid(pj.Sequence, out reason))
- {
- LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, $"recipe file not valid in the sequence, {reason}");
- _faCallback.JobCreateFailed(module, lotId, jobId, "");
- return false;
- }
- pjs.Add(pj);
- }
- _dbCallback.LotUpdate(cj);
- foreach (var pj in pjs)
- {
- cj.ProcessJobNameList.Add(pj.Name);
- _lstProcessJobs.Add(pj);
- }
- _lstControlJobs.Add(cj);
- //AssociatedPMWithLP(cj);
- _loadportControlJobDic[cj.Module] = cj;
- _faCallback.JobCreated(cj, GetFirstProcessJob(cj));
- return true;
- }
- public bool CheckAllJobDone()
- {
- foreach (var cj in _lstControlJobs)
- {
- if (cj.State == EnumControlJobState.Executing || cj.State == EnumControlJobState.Paused)
- return false;
- }
- InUseRecipes.Clear();
- LP1InUseRecipes.Clear();
- LP2InUseRecipes.Clear();
- LP3InUseRecipes.Clear();
- return true;
- }
- public bool CheckJobJustDone(out string sJobName)
- {
- foreach (var cj in _lstControlJobs)
- {
- if (cj.State == EnumControlJobState.Completed && !cj.BeenPosted)
- {
- if (cj.Module == "LP1")
- {
- LP1InUseRecipes.Clear();
- }
- else if (cj.Module == "LP2")
- {
- LP2InUseRecipes.Clear();
- }
- else if (cj.Module == "LP3")
- {
- LP3InUseRecipes.Clear();
- }
- //_lstControlJobs.Remove(doneJob);
- _loadportControlJobDic[cj.Module] = null;
- //LP;WaferSize;Lot;Number;Start;End;
- sJobName = $"{cj.Module};{cj.JobWaferSize};{cj.LotName};{cj.LotWafers.Count};{cj.StartTime:T};{cj.EndTime:T}";
- cj.BeenPosted = true;
- return true;
- }
- }
- //var doneJob = _lstControlJobs.Where(cj => cj.State == EnumControlJobState.Completed && !cj.BeenPosted).FirstOrDefault();
- //if (doneJob != null)
- //{
- // return true;
- //}
- sJobName = "NULL";
- return false;
- }
- public ProcessJobInfo GetFirstProcessJob(ControlJobInfo cj)
- {
- foreach (var pj in _lstProcessJobs)
- {
- if (pj.ControlJobName == cj.Name)
- return pj;
- }
- return null;
- }
- public bool AbortJob(string jobName, out string reason)
- {
- reason = "";
- ControlJobInfo cj = _lstControlJobs.Find(x => x.Name == jobName);
- if (cj == null)
- {
- reason = $"abort job rejected, not found job with id {jobName}";
- LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, reason);
- return false;
- }
- List<ProcessJobInfo> pjAbortList = new List<ProcessJobInfo>();
- foreach (var pj in _lstProcessJobs)
- {
- if (pj.ControlJobName == cj.Name)
- {
- pj.SetState(EnumProcessJobState.Aborting);
- pjAbortList.Add(pj);
- int unprocessed = 0;
- int aborted = 0;
- WaferInfo[] wafers = WaferManager.Instance.GetWaferByProcessJob(pj.Name);
- foreach (var waferInfo in wafers)
- {
- waferInfo.ProcessJob = null;
- waferInfo.NextSequenceStep = 0;
- if (waferInfo.ProcessState != EnumWaferProcessStatus.Completed)
- unprocessed++;
- }
- JobDataRecorder.EndPJ(pj.InnerId.ToString(), aborted, unprocessed);
- }
- }
- _faCallback.JobAborted(cj, GetFirstProcessJob(cj));
- _dbCallback.LotFinished(cj);
- // remove control job
- var deletedPollingJobs = new Queue<ControlJobInfo>();
- foreach (var item in _qePollingJobs)
- {
- if (cj.InnerId != item.InnerId)
- deletedPollingJobs.Enqueue(item);
- }
- _qePollingJobs = deletedPollingJobs;
- foreach (var pj in pjAbortList)
- {
- _lstProcessJobs.Remove(pj);
- }
- _lstControlJobs.Remove(cj);
- if (_loadportControlJobDic.ContainsKey(cj.Module))
- {
- _loadportControlJobDic[cj.Module] = null;
- }
- return true;
- }
- public bool StopJob(string jobName, out string reason)
- {
- reason = "";
- ControlJobInfo cj = _lstControlJobs.Find(x => x.Name == jobName);
- if (cj == null)
- {
- reason = $"stop job rejected, not found job with id {jobName}";
- LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, reason);
- return false;
- }
- foreach (var pj in _lstProcessJobs)
- {
- if (pj.ControlJobName == cj.Name)
- {
- pj.SetState(EnumProcessJobState.Stopping);
- }
- }
- cj.LotWafers.Clear();
- LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, $"{cj.Module} {jobName} job stop, 剩余wafer不再抓取");
- //_faCallback.JobStopped(cj, GetFirstProcessJob(cj));
- //_dbCallback.LotFinished(cj);
- //if (_loadportControlJobDic.ContainsKey(cj.Module))
- //{
- // _loadportControlJobDic[cj.Module] = null;
- //}
- //var deletedPollingJobs = new Queue<ControlJobInfo>();
- //foreach (var item in _qePollingJobs)
- //{
- // if (cj.InnerId != item.InnerId)
- // deletedPollingJobs.Enqueue(item);
- //}
- //_qePollingJobs = deletedPollingJobs;
- return true;
- }
- public bool ResumeJob(string jobName, out string reason)
- {
- reason = "";
- ControlJobInfo cj = _lstControlJobs.Find(x => x.Name == jobName);
- if (cj == null)
- {
- reason = $"resume job rejected, not found job with id {jobName}";
- //LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, $"resume job rejected, not found job with id {jobName}");
- return false;
- }
- if (cj.State == EnumControlJobState.Paused)
- {
- cj.SetState(EnumControlJobState.Executing);
- }
- _faCallback.JobResumed(cj, GetFirstProcessJob(cj));
- _cycleState = RState.Running;
- return true;
- }
- public bool PauseJob(string jobName, out string reason)
- {
- reason = "";
- ControlJobInfo cj = _lstControlJobs.Find(x => x.Name == jobName);
- if (cj == null)
- {
- reason = $"pause job rejected, not found job with id {jobName}";
- //LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, $"pause job rejected, not found job with id {jobName}");
- return false;
- }
- if (cj.State == EnumControlJobState.Executing)
- {
- cj.SetState(EnumControlJobState.Paused);
- }
- _faCallback.JobPaused(cj, GetFirstProcessJob(cj));
- var deletedPollingJobs = new Queue<ControlJobInfo>();
- foreach (var item in _qePollingJobs)
- {
- if (cj.InnerId != item.InnerId)
- deletedPollingJobs.Enqueue(item);
- }
- _qePollingJobs = deletedPollingJobs;
- if (!_lstControlJobs.Exists(job => job.State == EnumControlJobState.Executing))
- _cycleState = RState.Paused;
- return true;
- }
- public bool StartJob(string jobName, out string reason)
- {
- reason = "";
- ControlJobInfo cj = _lstControlJobs.Find(x => x.Name == jobName);
- if (cj == null)
- {
- reason = $"start job rejected, not found job with id {jobName}";
- LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, reason);
- return false;
- }
- if (RtInstance.ConfigType == ConfigType.Kepler2200)
- {
- var item = _lstProcessJobs.Where(x => x.LotName == cj.LotName).FirstOrDefault();
- if (item != null && item.ControlJobName == cj.Name && !CheckSequenceKepler2200TemperatureReady(item.Sequence))
- {
- return false;
- }
- if (cj.Module == "LP1")
- {
- GetAllJobRecipe(LP1InUseRecipes, cj, item.Sequence);
- }
- else if (cj.Module == "LP2")
- {
- GetAllJobRecipe(LP2InUseRecipes, cj, item.Sequence);
- }
- else if (cj.Module == "LP3")
- {
- GetAllJobRecipe(LP3InUseRecipes, cj, item.Sequence);
- }
- }
- if (cj.State == EnumControlJobState.WaitingForStart)
- {
- cj.SetState(EnumControlJobState.Executing);
- //PreJobClean(cj);
- cj.JetState = EnumJetCtrlJobState.Quequed;
- cj.StartTime = DateTime.Now;
- _dbCallback.LotCreated(cj);
- _faCallback.JobStarted(cj, GetFirstProcessJob(cj));
- //if (!_blockingWatcher.IsRunning)
- // _blockingWatcher.Restart();
- //ResetTraceFlag();
- }
- if (!_cycleWatch.IsRunning)
- {
- _cycleWatch.Restart();
- }
- var lp = ModuleHelper.Converter(cj.Module);
- _lpCycleCount[lp] = 0;
- _lpCycleWafer[lp] = 0;
- _lpThroughput[lp] = 0;
- _cycleState = RState.Running;
- return true;
- }
- public void Clear()
- {
- foreach (var module in _dictModuleTask)
- {
- module.Value.Status = ModuleStatus.Idle;
- module.Value.Scheduler.ResetTask();
- }
- List<string> keys = _loadportControlJobDic.Keys.ToList();
- foreach (var key in keys)
- {
- _loadportControlJobDic[key] = null;
- }
- foreach (var preLot in _preLotCleanMarks)
- {
- preLot.Value.Clear();
- }
- foreach (var postLot in _postLotCleanMarks)
- {
- postLot.Value.Clear();
- }
- _lstWaferTasks.Clear();
- _qeWaitInWafers.Clear();
- _tmSchdActions.Clear();
- _curTmAction.Clear();
- _efemSchdActions.Clear();
- _curEfemAction.Clear();
- _lstControlJobs.Clear();
- _lstProcessJobs.Clear();
- InUseRecipes.Clear();
- LP1InUseRecipes.Clear();
- LP2InUseRecipes.Clear();
- LP3InUseRecipes.Clear();
- _qePollingJobs.Clear();
- _qeWaitCoolingLLs.Clear();
- _cycleState = RState.End;
- }
- // manual return one wafer while system is auto running
- public bool ManualReturnWafer(object[] objs)
- {
- ModuleName SourceModule = (ModuleName)objs[0];
- int SourceSlot = (int)objs[1];
- if (!_dictModuleTask.Keys.Contains(SourceModule))
- {
- LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, $"Invalid source module {SourceModule} for manual return wafer");
- return false;
- }
- if (WaferManager.Instance.CheckNoWafer(SourceModule, SourceSlot))
- {
- LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, $"Can not return wafer as {SourceModule} {SourceSlot} has no wafer");
- return false;
- }
- if (!_dictModuleTask[SourceModule].Scheduler.IsIdle)
- {
- LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, $"The module: {SourceModule} is not ready for return wafer");
- return false;
- }
- var wafer = WaferManager.Instance.GetWafer(SourceModule, SourceSlot);
- LOG.Write(eEvent.EV_ROUTER, ModuleName.System, $"Manual return wafer: {wafer.WaferOrigin} at {SourceModule} {SourceSlot} while system is auto running");
- _qeReturnWafers.Enqueue(wafer);
- return true;
- }
- public RState CheckManualReturnWafer()
- {
- var pmWaferCount = _dictModuleTask.Where(mod => ModuleHelper.IsPm(mod.Key) && WaferManager.Instance.CheckHasWafer(mod.Key, 0)).Count();
- var tmRobotWaferCount = (WaferManager.Instance.CheckHasWafer(ModuleName.TMRobot, 0) ? 1 : 0) + (WaferManager.Instance.CheckHasWafer(ModuleName.TMRobot, 1) ? 1 : 0);
- if (!_dictModuleTask[ModuleName.TMRobot].Scheduler.IsIdle && (pmWaferCount > 0 || tmRobotWaferCount > 0))
- {
- LOG.Write(eEvent.ERR_ROUTER, ModuleName.TMRobot, $"The TM Robot is not ready for return wafer.");
- return RState.Failed;
- }
- if (!_dictModuleTask[ModuleName.EfemRobot].Scheduler.IsIdle)
- {
- LOG.Write(eEvent.ERR_ROUTER, ModuleName.EfemRobot, $"The EFEM Robot is not ready for return wafer.");
- return RState.Failed;
- }
- foreach (var mod in _dictModuleTask)
- {
- if (ModuleHelper.IsLoadPort(mod.Key))
- continue;
- if (!mod.Value.Scheduler.IsInclude)
- continue;
- if (!mod.Value.Scheduler.IsIdle)
- {
- LOG.Write(eEvent.ERR_ROUTER, mod.Key, $"{mod.Key} is not ready for return wafer.");
- return RState.Failed;
- }
- int nSlotNumber = ModuleHelper.IsLoadLock(mod.Key) ? (mod.Key == ModuleName.LLA ? _LLASlotNumber : _LLBSlotNumber) : (ModuleHelper.IsTMRobot(mod.Key) || ModuleHelper.IsEFEMRobot(mod.Key) ? 2 : 1);
- for (int slot = 0; slot < nSlotNumber; slot++)
- {
- var wafer = WaferManager.Instance.GetWafer(mod.Key, slot);
- if (wafer.IsEmpty)
- continue;
- var destLP = (ModuleName)wafer.OriginStation;
- if (!_dictModuleTask[destLP].Scheduler.IsAvailable)
- {
- LOG.Write(eEvent.ERR_ROUTER, destLP, $"The destination Loadport {destLP} is not ready for return wafer.");
- return RState.Failed;
- }
- if (!ModuleHelper.IsLoadPort(destLP))
- {
- LOG.Write(eEvent.ERR_ROUTER, ModuleName.System, $"The wafer {wafer.WaferOrigin} cannot be return, please manually drag it.");
- return RState.Failed;
- }
- }
- }
- Clear();
- return RState.Running;
- }
- public RState ReturnAllWafers()
- {
- int systemWaferCount = 0;
- foreach (var mod in _dictModuleTask)
- {
- if (ModuleHelper.IsLoadPort(mod.Key) || !mod.Value.Scheduler.IsInclude)
- continue;
- int nSlotNumber = ModuleHelper.IsLoadLock(mod.Key) ? (mod.Key == ModuleName.LLA ? _LLASlotNumber : _LLBSlotNumber) : (ModuleHelper.IsTMRobot(mod.Key) || ModuleHelper.IsEFEMRobot(mod.Key) ? 2 : 1);
- for (int slot = 0; slot < nSlotNumber; slot++)
- {
- var wafer = WaferManager.Instance.GetWafer(mod.Key, slot);
- if (!wafer.IsEmpty)
- systemWaferCount++;
- }
- }
- if (systemWaferCount == 0)
- return RState.End;
- if(_qeWaitCoolingLLs.Count > 0 && _dictModuleTask[_qeWaitCoolingLLs.First()].Scheduler.IsIdle && !IsLLReservedByEFEM(_qeWaitCoolingLLs.First()) && !IsLLReservedByTM(_qeWaitCoolingLLs.First()))
- {
- if ((_dictModuleTask[_qeWaitCoolingLLs.First()] as LoadlockTask).Cooling())
- {
- _qeWaitCoolingLLs.Dequeue();
- return RState.Running;
- }
- }
- ReturnVacWafers();
- ReturnAtmWafers();
- return RState.Running;
- }
- #endregion
- #region internal implementation
- private void InitModules()
- {
- foreach (var module in ModuleHelper.InstalledModules)
- {
- if (ModuleHelper.IsInstalled(module))
- {
- if (ModuleHelper.IsPm(module))
- {
- _dictModuleTask[module] = new PMTask(module);
- _preLotCleanMarks[module] = new List<Guid>();
- _postLotCleanMarks[module] = new List<Guid>();
- }
- else if (ModuleHelper.IsLoadLock(module))
- {
- _dictModuleTask[module] = new LoadlockTask(module);
- }
- else if (ModuleHelper.IsLoadPort(module))
- {
- _dictModuleTask[module] = new LoadPortTask(module);
- }
- else if (ModuleHelper.IsTMRobot(module))
- {
- _dictModuleTask[module] = new TMRobotTask(module);
- }
- else if (ModuleHelper.IsEFEMRobot(module))
- {
- _dictModuleTask[module] = new EFEMRobotTask(module);
- }
- else if (ModuleHelper.IsAligner(module))
- {
- _dictModuleTask[module] = new AlignerTask(module);
- }
- }
- }
- }
- private void prelude()
- {
- bool available = true;
- foreach (var mod in _dictModuleTask)
- {
- available = mod.Value.Scheduler.IsAvailable; // force scheduler update
- }
- }
- private void epilogue()
- {
- UpdateProcessJobStatus();
- UpdateControlJobStatus();
- UpdateLLInOutPathProperty();
- PrepareLLPressure();
- RunLotCleanTasks();
- CreateNewWaferTask();
- _lstWaferTasks.RemoveAll(item => ModuleHelper.IsLoadPort(item.destMod) && ModuleHelper.IsLoadPort(item.currentMod) && item.pressureStatus == RState.End);
- ReDispatchBlockingWafers();
- }
- private void RunWaferTask()
- {
- foreach (var task in _lstWaferTasks)
- {
- task.Run();
- }
- }
- private void RunModuleTasks()
- {
- foreach (var task in _dictModuleTask)
- {
- task.Value.Run();
- }
- }
- private bool CheckAllWaferReturned(ProcessJobInfo pj, bool checkAllProcessed)
- {
- bool allWaferReturn = true;
- foreach (var slot in pj.SlotWafers)
- {
- var wafer = WaferManager.Instance.GetWafer(slot.Item1, slot.Item2);
- if (wafer.IsEmpty || (wafer.ProcessState != EnumWaferProcessStatus.Completed && checkAllProcessed))
- {
- allWaferReturn = false;
- break;
- }
- }
- return allWaferReturn;
- }
- private void UpdateProcessJobStatus()
- {
- if (_efemRobotStatus == RState.Running || _tmRobotStatus == RState.Running)
- return;
- foreach (var pj in _lstProcessJobs)
- {
- if (CheckAllWaferReturned(pj, pj.State != EnumProcessJobState.Stopping))
- {
- pj.SetState(EnumProcessJobState.ProcessingComplete);
- JobDataRecorder.EndPJ(pj.InnerId.ToString(), 0, 0);
- }
- }
- }
- private bool IsControlJobIntersect(ControlJobInfo cj1, ControlJobInfo cj2)
- {
- var cj1Pms = GetWaitPreCleanPMsByCtrlJob(cj1);
- var cj2Pms = GetWaitPreCleanPMsByCtrlJob(cj2);
- return cj1Pms.Intersect(cj2Pms).Count() > 0;
- }
- private void UpdateControlJobStatus()
- {
- if (_lstControlJobs.Count == 0 || _efemRobotStatus == RState.Running || _tmRobotStatus == RState.Running)
- return;
- var runningJobs = _lstControlJobs.FindAll(cj => IsCtrlJobRuning(cj));
- var queueJobs = _lstControlJobs.FindAll(cj => cj.JetState == EnumJetCtrlJobState.Quequed).OrderBy(cj => cj.StartTime);
- if (runningJobs.Count == 0)
- {
- if (queueJobs.Count() > 0)
- {
- // start the first waiting job
- RunControlJob(queueJobs.First());
- }
- }
- else
- {
- foreach (var runningjob in runningJobs)
- {
- // update the running job
- RunControlJob(runningjob);
- }
- foreach (var queueJob in queueJobs)
- {
- if (!runningJobs.Exists(cj => IsControlJobIntersect(cj, queueJob)))
- {
- // parallelly start the not intersect job
- RunControlJob(queueJob);
- }
- else
- {
- foreach (var cj in runningJobs)
- {
- if (!_qePollingJobs.Contains(cj))
- _qePollingJobs.Enqueue(cj);
- }
- RunControlJob(queueJob);
- if (!_qePollingJobs.Contains(queueJob))
- _qePollingJobs.Enqueue(queueJob);
- }
- }
- }
- // update system cycle status
- if (_lstControlJobs.All(cj => cj.State == EnumControlJobState.Completed))
- _cycleState = RState.End;
- List<ControlJobInfo> cjRemoveList = new List<ControlJobInfo>();
- foreach (var cj in _lstControlJobs)
- {
- LoadportCassetteState state = (LoadportCassetteState)DATA.Poll($"{cj.Module}.CassetteState");
- if (cj.State == EnumControlJobState.Completed && state != LoadportCassetteState.Normal)
- {
- cjRemoveList.Add(cj);
- }
- }
- foreach (var cj in cjRemoveList)
- {
- List<ProcessJobInfo> pjRemoveList = new List<ProcessJobInfo>();
- foreach (var pj in _lstProcessJobs)
- {
- if (pj.ControlJobName == cj.Name)
- pjRemoveList.Add(pj);
- }
- foreach (var pj in pjRemoveList)
- {
- _lstProcessJobs.Remove(pj);
- }
- _lstControlJobs.Remove(cj);
- }
- }
- private bool ActiveProcessJob(ProcessJobInfo pj)
- {
- foreach (var pjSlotWafer in pj.SlotWafers)
- {
- WaferInfo wafer = WaferManager.Instance.GetWafer(pjSlotWafer.Item1, pjSlotWafer.Item2);
- wafer.ProcessJob = pj;
- wafer.NextSequenceStep = 0;
- WaferDataRecorder.SetPjInfo(wafer.InnerId.ToString(), pj.InnerId.ToString());
- }
- ControlJobInfo cj = _lstControlJobs.Find(x => x.Name == pj.ControlJobName);
- CarrierInfo carrier = CarrierManager.Instance.GetCarrier(cj.Module);
- JobDataRecorder.StartPJ(pj.InnerId.ToString(), carrier.InnerId.ToString(), cj.InnerId.ToString(), pj.Name, cj.Module, cj.Module, pj.SlotWafers.Count);
- pj.SetState(EnumProcessJobState.Processing);
- return true;
- }
- private bool ActiveControlJob(ControlJobInfo cj)
- {
- cj.JetState = EnumJetCtrlJobState.Processing;
- foreach (var pjName in cj.ProcessJobNameList)
- {
- var pj = _lstProcessJobs.Find(x => x.Name == pjName);
- if (pj == null)
- {
- LOG.Write(eEvent.ERR_ROUTER, ModuleName.System, $"Not find pj named {pjName} in {cj.Name}");
- continue;
- }
- if (pj.State == EnumProcessJobState.Queued)
- {
- ActiveProcessJob(pj);
- }
- }
- return true;
- }
- private bool RunControlJob(ControlJobInfo cj)
- {
- // polling the sequencial jobs
- if (_qePollingJobs.Contains(cj))
- {
- if (_qePollingJobs.First() == cj)
- {
- if (!cj.LotWafers.Exists(wafer => !wafer.IsEmpty && wafer.NextSequenceStep == 0) && (IsAllJobWaferProcessedOrProcessing(cj) || IsAllProcessJobComplete(cj)))
- {
- _qePollingJobs.Dequeue();
- _qePollingJobs.Enqueue(cj);
- }
- }
- }
- switch (cj.JetState)
- {
- case EnumJetCtrlJobState.Quequed:
- {
- ActiveControlJob(cj);
- }
- break;
- case EnumJetCtrlJobState.Processing:
- {
- if (IsAllProcessJobComplete(cj))
- {
- cj.JetState = EnumJetCtrlJobState.Completed;
- }
- }
- break;
- }
- // caculate processed wafer by control job
- var lp = ModuleHelper.Converter(cj.Module);
- int countProcessed = 0;
- foreach (var pjName in cj.ProcessJobNameList)
- {
- var pj = _lstProcessJobs.Find(x => x.Name == pjName);
- if (pj == null)
- {
- LOG.Write(eEvent.ERR_ROUTER, ModuleName.System, $"Not find pj named {pjName} in {cj.Name}");
- continue;
- }
- // caculate process wafer by process
- if (_lpCycleCount[lp] < cj.CycleNumber)
- {
- foreach (var pjSlotWafer in pj.SlotWafers)
- {
- WaferInfo wafer = WaferManager.Instance.GetWafer(pjSlotWafer.Item1, pjSlotWafer.Item2);
- if (!wafer.IsEmpty && wafer.ProcessState == EnumWaferProcessStatus.Completed)
- countProcessed++;
- }
- }
- }
- int lpCycleWafer = 0;
- if (cj.JetState == EnumJetCtrlJobState.Completed)
- {
- cj.EndTime = DateTime.Now;
- _faCallback.JobFinished(cj, GetFirstProcessJob(cj));
- _dbCallback.LotFinished(cj);
- if (_lpCycleCount[lp] >= cj.CycleNumber)
- (Singleton<TransferModule>.Instance.GetScheduler(lp) as SchedulerLoadPort).NoteJobComplete();
- _lpCycleCount[lp]++;
- lpCycleWafer = _lpCycleCount[lp] * cj.LotWafers.Count;
- _lpThroughput[lp] = (float)(lpCycleWafer / (DateTime.Now - cj.StartTime).TotalHours);
- LOG.Write(eEvent.EV_ROUTER, lp, $"Cycle Count: {_lpCycleCount[lp]}, Total Processed Wafer: {lpCycleWafer}, Throughput: {_lpThroughput[lp]}");
- if (_lpCycleCount[lp] < cj.CycleNumber)
- {
- cj.SetState(EnumControlJobState.Executing);
- cj.JetState = EnumJetCtrlJobState.Quequed;
- cj.LotInnerId = Guid.NewGuid();
- _dbCallback.LotCreated(cj);
- foreach (var pj in _lstProcessJobs)
- {
- if (pj.ControlJobName == cj.Name)
- {
- foreach (var marks in _preLotCleanMarks)
- {
- if (marks.Value.Contains(pj.InnerId))
- marks.Value.Remove(pj.InnerId);
- }
- foreach (var marks in _postLotCleanMarks)
- {
- if (marks.Value.Contains(pj.InnerId))
- marks.Value.Remove(pj.InnerId);
- }
- pj.SetState(EnumProcessJobState.Queued);
- pj.InnerId = Guid.NewGuid();
- foreach (var pjSlotWafer in pj.SlotWafers)
- {
- WaferInfo wafer = WaferManager.Instance.GetWafer(pjSlotWafer.Item1, pjSlotWafer.Item2);
- wafer.ProcessJob = null;
- wafer.NextSequenceStep = 0;
- wafer.ProcessState = EnumWaferProcessStatus.Idle;
- }
- }
- }
- _lstWaferTasks.RemoveAll(wt => wt.currentMod == lp);
- }
- else
- {
- cj.SetState(EnumControlJobState.Completed);
- if (_qePollingJobs.Contains(cj))
- {
- Queue<ControlJobInfo> removedPolingJobs = new Queue<ControlJobInfo>();
- foreach (var pj in _qePollingJobs)
- {
- if (pj != cj)
- removedPolingJobs.Enqueue(pj);
- }
- if (removedPolingJobs.Count > 1)
- _qePollingJobs = removedPolingJobs;
- else
- _qePollingJobs.Clear();
- }
- }
- }
- else
- {
- lpCycleWafer = _lpCycleCount[lp] * cj.LotWafers.Count + countProcessed;
- }
- if (lpCycleWafer != _lpCycleWafer[lp])
- {
- _lpCycleWafer[lp] = lpCycleWafer;
- RefreshThroughput();
- }
- return cj.State == EnumControlJobState.Completed;
- }
- void RefreshThroughput()
- {
- foreach (var cj in _lstControlJobs)
- {
- if (cj.State == EnumControlJobState.Executing)
- {
- var lp = ModuleHelper.Converter(cj.Module);
- if (_lpCycleCount[lp] > 0)
- {
- _lpThroughput[lp] = (float)((_lpCycleWafer[lp] - 2) / _lpCycleWatch[lp].Elapsed.TotalHours);
- }
- }
- }
- }
- private bool IsAllJobWaferProcessedOrProcessing(ControlJobInfo cj)
- {
- List<ModuleName> allModules = _dictModuleTask.Keys.ToList();
- int original = (int)ModuleHelper.Converter(cj.Module);
- foreach (var mod in allModules)
- {
- if (ModuleHelper.IsLoadPort(mod) && (int)mod != original)
- continue;
- var wafers = WaferManager.Instance.GetWafers(mod);
- foreach (var wafer in wafers)
- {
- if (wafer.IsEmpty || wafer.ProcessJob == null || wafer.ProcessJob.Sequence == null || wafer.ProcessJob.ControlJobName != cj.Name)
- continue;
- if (wafer.ProcessState != EnumWaferProcessStatus.Completed && wafer.ProcessState != EnumWaferProcessStatus.InProcess)
- return false; ;
- }
- }
- return true;
- }
- private bool IsAllProcessJobComplete(ControlJobInfo cj)
- {
- foreach (var pj in _lstProcessJobs)
- {
- if (pj.ControlJobName == cj.Name && pj.State != EnumProcessJobState.ProcessingComplete)
- {
- return false;
- }
- }
- return true;
- }
- private bool IsCtrlJobExecuting(ModuleName lp)
- {
- var cJob = _lstControlJobs.Find(cj => ModuleHelper.Converter(cj.Module) == lp);
- if (cJob != null && cJob.State == EnumControlJobState.Executing)
- return true;
- return false;
- }
- private bool IsCtrlJobRuning(ControlJobInfo cj)
- {
- return cj.JetState == EnumJetCtrlJobState.PreJobClean ||
- cj.JetState == EnumJetCtrlJobState.Processing ||
- cj.JetState == EnumJetCtrlJobState.PostJobClean;
- }
- private bool IsCtrlJobNeedPreClean(ControlJobInfo cj)
- {
- return !string.IsNullOrWhiteSpace(cj.PreJobClean);
- }
- private bool IsCtrlJobNeedPostClean(ControlJobInfo cj)
- {
- return !string.IsNullOrWhiteSpace(cj.PostJobClean.Trim());
- }
- private List<ModuleName> GetWaitPreCleanPMsByCtrlJob(ControlJobInfo cj)
- {
- var pmlist = new List<ModuleName>();
- foreach (var pj in _lstProcessJobs)
- {
- if (pj.ControlJobName == cj.Name)
- {
- foreach (var pm in pj.Sequence.PMs)
- {
- if (!pmlist.Contains(pm))
- pmlist.Add(pm);
- }
- }
- }
- return pmlist;
- }
- private bool IsPreJobCleanDone(ControlJobInfo cj)
- {
- var pms = GetWaitPreCleanPMsByCtrlJob(cj);
- foreach (var pm in pms)
- {
- var pmTask = _dictModuleTask[pm] as PMTask;
- if (pmTask.Scheduler.IsOnline && !pmTask.IsPreJobCleanDone())
- return false;
- }
- return true;
- }
- private bool IsPostJobCleanDone(ControlJobInfo cj)
- {
- var pms = GetWaitPreCleanPMsByCtrlJob(cj);
- foreach (var pm in pms)
- {
- var pmTask = _dictModuleTask[pm] as PMTask;
- if (pmTask.Scheduler.IsOnline && !pmTask.IsPostJobCleanDone())
- return false;
- }
- return true;
- }
- private void WaferArrived(WaferTask wafer, MoveItem item)
- {
- _dictModuleTask[item.DestinationModule].WaferArrived(wafer, item.DestinationSlot);
- //--2024-03-21 增加了PortJobWaferEnd 上报事件 start--
- if (ModuleHelper.IsLoadPort(item.DestinationModule))
- {
- ControlJobInfo currentControlJob = GetLoadPortCurrentControlJob(item.DestinationModule);
- if (currentControlJob != null)
- {
- _faCallback.JobWaferEnd(currentControlJob, item.SourceSlot);
- }
- }
- if (ModuleHelper.IsLoadPort(item.DestinationModule))
- {
- if (!_lpCycleWatch[wafer.sourceMod].IsRunning)
- _lpCycleWatch[wafer.sourceMod].Start();
- }
- //--2024-03-21 增加了PortJobWaferEnd 上报事件 end--
- }
- private void WaferLeaved(WaferTask wafer, MoveItem item)
- {
- _dictModuleTask[item.SourceModule].WaferLeaved(wafer, item.DestinationSlot);
- //--2024-03-21 增加了PortJobWaferStart 上报事件 start--
- if (ModuleHelper.IsLoadPort(item.SourceModule))
- {
- ControlJobInfo currentControlJob = GetLoadPortCurrentControlJob(item.SourceModule);
- if (currentControlJob != null)
- {
- _faCallback.JobWaferStart(currentControlJob, item.SourceSlot);
- }
- }
- //--2024-03-21 增加了PortJobWaferStart 上报事件 end--
- }
- private ModuleName GetComingAvailablePM(ControlJobInfo cj)
- {
- var lstInProcessPMs = new List<ModuleName>();
- foreach (var wafer in cj.LotWafers)
- {
- if (!wafer.IsEmpty && wafer.NextSequenceStep == 0 && wafer.ProcessJob != null)
- {
- foreach (var pm in wafer.ProcessJob.Sequence.PMs)
- {
- if (!lstInProcessPMs.Contains(pm) && _dictModuleTask[pm].Scheduler.IsOnline)
- lstInProcessPMs.Add(pm);
- }
- }
- }
- // blocking check while only one loadlock in out
- if (LLInOutPath == SequenceLLInOutPath.AInAOut ||
- LLInOutPath == SequenceLLInOutPath.BInBOut ||
- !_dictModuleTask[ModuleName.LLA].Scheduler.IsOnline ||
- !_dictModuleTask[ModuleName.LLB].Scheduler.IsOnline)
- {
- if (_lstWaferTasks.Count >= lstInProcessPMs.Count + _LLASlotNumber / 2)
- return ModuleName.System;
- }
- Dictionary<ModuleName, int> pmAssociatedWaferCount = new Dictionary<ModuleName, int>();
- foreach (var mod in _dictModuleTask)
- {
- if (ModuleHelper.IsPm(mod.Key) && mod.Value.Scheduler.IsOnline && lstInProcessPMs.Contains(mod.Key))
- {
- pmAssociatedWaferCount[mod.Key] = 0;
- }
- }
- var unprocessedWafer = _lstWaferTasks.Where(task => ModuleHelper.IsPm(task.destMod));
- foreach (var wafer in unprocessedWafer)
- {
- if (ModuleHelper.IsPm(wafer.destMod) && _dictModuleTask[wafer.destMod].Scheduler.IsOnline && lstInProcessPMs.Contains(wafer.destMod))
- {
- pmAssociatedWaferCount[wafer.destMod]++;
- }
- }
- var oderedPMCount = pmAssociatedWaferCount.OrderBy(p => p.Value).ToDictionary(p => p.Key, o => o.Value);
- if (oderedPMCount.Count > 0 && oderedPMCount.First().Value < 2)
- return oderedPMCount.First().Key;
- return ModuleName.System;
- }
- private void CreateNewWaferTask()
- {
- var runningJobs = _lstControlJobs.FindAll(cj => cj.JetState == EnumJetCtrlJobState.PreJobClean || cj.JetState == EnumJetCtrlJobState.Processing);
- var onDutyPms = new Dictionary<ModuleName, int>();
- foreach (var job in runningJobs)
- {
- var pms = GetWaitPreCleanPMsByCtrlJob(job);
- foreach (var pm in pms)
- {
- if (_dictModuleTask[pm].Scheduler.IsOnline && !onDutyPms.ContainsKey(pm))
- {
- onDutyPms[pm] = _lstWaferTasks.Where(wt => wt.destMod == pm || wt.currentMod == pm).Count();
- }
- }
- }
- if (runningJobs.Count == 0 || onDutyPms.Count == 0)
- return;
- var oderedPMs = onDutyPms.OrderBy(kv => kv.Value).OrderBy(kv => _dictModuleTask[kv.Key].TimeToReady);
- if (oderedPMs.First().Value < 1)
- {
- foreach (var runningJob in runningJobs)
- {
- if (_qePollingJobs.Contains(runningJob) && _qePollingJobs.First() != runningJob)
- continue;
- foreach (var wafer in runningJob.LotWafers)
- {
- if (wafer.IsEmpty || wafer.ProcessJob == null)
- continue;
- if (wafer.ProcessJob.Sequence.PMs.Contains(oderedPMs.First().Key) && wafer.NextSequenceStep == 0 && !_lstWaferTasks.Exists(task => task.sourceMod == (ModuleName)wafer.OriginStation && task.sourceSlot == wafer.OriginSlot))
- {
- CreateWaferTasks(wafer, oderedPMs.First().Key);
- return;
- }
- }
- }
- }
- if (_tmRobotStatus == RState.Running)
- return;
- // keep two raw atm wafer, try match a double place to LL
- var atmWaferCount = _lstWaferTasks.Count(wt => ModuleHelper.IsPm(wt.destMod) && (ModuleHelper.IsLoadPort(wt.currentMod) || ModuleHelper.IsAligner(wt.currentMod) || ModuleHelper.IsEFEMRobot(wt.currentMod) || ModuleHelper.IsLoadLock(wt.currentMod)));
- if (atmWaferCount < 2)
- {
- var busyPMs = oderedPMs.Where(pv => pv.Value == 1 && _dictModuleTask[pv.Key].HasWafer).OrderBy(pv => _dictModuleTask[pv.Key].TimeToReady);
- if (busyPMs.Count() == 0)
- return;
- ModuleName nextPM = busyPMs.First().Key;
- if (_lpCycleWafer.Sum(kv => kv.Value) == 0)
- {
- if (busyPMs.ToList().Exists(kv => _dictModuleTask[kv.Key].TimeToReady > 36000) && busyPMs.ToList().Exists(pv => _dictModuleTask[pv.Key].TimeToReady < 3600))
- {
- foreach (var pm in busyPMs)
- {
- if (_dictModuleTask[pm.Key].TimeToReady > 36000)
- {
- nextPM = pm.Key;
- break;
- }
- }
- }
- }
- foreach (var runningJob in runningJobs)
- {
- if (_qePollingJobs.Contains(runningJob) && _qePollingJobs.First() != runningJob)
- continue;
- foreach (var wafer in runningJob.LotWafers)
- {
- if (wafer.IsEmpty || wafer.ProcessJob == null)
- continue;
- if (wafer.ProcessJob.Sequence.PMs.Contains(nextPM) && wafer.NextSequenceStep == 0 && !_lstWaferTasks.Exists(task => task.sourceMod == (ModuleName)wafer.OriginStation && task.sourceSlot == wafer.OriginSlot))
- {
- CreateWaferTasks(wafer, nextPM);
- return;
- }
- }
- }
- }
- }
- private void CreateWaferTasks(WaferInfo wafer, ModuleName pm)
- {
- var recipeName = wafer.ProcessJob.Sequence.GetRecipe(pm);
- var recipeContent = RecipeFileManager.Instance.LoadRecipe(pm.ToString(), recipeName, false, RecipeType.Process.ToString());
- Recipe recipe = Recipe.Load(recipeContent);
- int temperature = 0;
- if (int.TryParse(recipe.Header.Temperature, out int temp))
- {
- temperature = temp;
- }
- var waferTask = new WaferTask((ModuleName)wafer.OriginStation,
- wafer.OriginSlot,
- pm,
- 0,
- temperature,
- wafer.InnerId,
- wafer.ProcessJob.InnerId,
- recipeName,
- wafer.ProcessJob.Sequence.GetWTWCleanRecipe(pm),
- wafer.ProcessJob.Sequence.LLInOutPath,
- wafer.ProcessJob.Sequence.LLDelayTime,
- IsSequenceNeedAlign(wafer.ProcessJob.Sequence));
- waferTask.OnWaferArrived += WaferArrived;
- waferTask.OnWaferLeaved += WaferLeaved;
- _lstWaferTasks.Add(waferTask);
- _qeWaitInWafers.Enqueue(wafer.InnerId);
- //LOG.Write(eEvent.INFO_TROUGHPUT_ENHANCE_TRACE, waferTask.sourceMod, $"Routing wafer: {waferTask.sourceMod}.{waferTask.sourceSlot + 1} to {pm}");
- }
- private void ReDispatchBlockingWafers()
- {
- foreach (var wt in _lstWaferTasks)
- {
- if (ModuleHelper.IsPm(wt.destMod) && !ModuleHelper.IsPm(wt.currentMod) && !ModuleHelper.IsLoadPort(wt.currentMod))
- {
- if (!_dictModuleTask[wt.destMod].Scheduler.IsOnline && wt.elapseTime > 120)
- {
- var wafer = WaferManager.Instance.GetWafer(wt.currentMod, wt.currentSlot);
- var otherPMs = _dictModuleTask.Where(mod => wafer.ProcessJob.Sequence.PMs.Contains(mod.Key) && mod.Value.Scheduler.IsOnline).OrderBy(mod => _lstWaferTasks.Where(task => task.destMod == mod.Key).Count()).ToList();
- if (otherPMs.Count > 0)
- {
- LOG.Write(eEvent.WARN_ROUTER, wt.currentMod, $"Re-assign process chamber {otherPMs.First().Key} for {wafer.WaferOrigin} as {wt.destMod} unexpected offline");
- wt.ReAssignPM(otherPMs.First().Key, 0);
- }
- }
- }
- }
- }
- private bool ForwardATMWafers(ModuleName ll)
- {
- if (_qeWaitInWafers.Count == 0)
- return false;
- var emptySlots = GetLLReadyInOutSlots(ll).emptySlot;
- var atmWafers = _lstWaferTasks.Where(wafer => (wafer.movingStatus == RState.End || wafer.movingStatus == RState.Init) && (ModuleHelper.IsEFEMRobot(wafer.currentMod) || ModuleHelper.IsAligner(wafer.currentMod))).ToList();
- var notAlignedWafer = atmWafers.Where(wafer => !wafer.IsAligned).ToList();
- var freeHands = GetEFEMFreeHand();
- var waitInWafer = _lstWaferTasks.Find(wt => wt.waferId == _qeWaitInWafers.First());
- if (atmWafers.Count >= 2 && freeHands.Count == 0 || waitInWafer == null)
- return false;
- // do not need pass by aligner
- if (waitInWafer.IsAligned)
- {
- _efemSchdActions.Enqueue(new List<MoveItem> { new MoveItem(waitInWafer.currentMod, waitInWafer.currentSlot, ModuleName.EfemRobot, (int)freeHands[0], freeHands[0]) });
- _qeWaitInWafers.Dequeue();
- }
- else
- {
- if (atmWafers.Count == 0)
- {
- // push one wafer to aligner
- _efemSchdActions.Enqueue(new List<MoveItem> { new MoveItem(waitInWafer.currentMod, waitInWafer.currentSlot, ModuleName.EfemRobot, (int)freeHands[0], freeHands[0]) });
- _efemSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.EfemRobot, (int)freeHands[0], ModuleName.Aligner1, 0, freeHands[0]) });
- _qeWaitInWafers.Dequeue();
- }
- else if (_lstWaferTasks.Exists(wt => ModuleHelper.IsAligner(wt.currentMod)) && freeHands.Count == 2)
- {
- // forward another wafer to aligner
- _efemSchdActions.Enqueue(new List<MoveItem> { new MoveItem(waitInWafer.currentMod, waitInWafer.currentSlot, ModuleName.EfemRobot, (int)freeHands[1], freeHands[1]) });
- _efemSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.Aligner1, 0, ModuleName.EfemRobot, (int)freeHands[0], freeHands[0]) });
- _efemSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.EfemRobot, (int)freeHands[1], ModuleName.Aligner1, 0, freeHands[1]) });
- _qeWaitInWafers.Dequeue();
- }
- }
- return _efemSchdActions.Count > 0;
- }
- private bool ExchangeWaferWithLL(ModuleName ll)
- {
- if (IsLLReservedByTM(ll))
- return false;
- var waferStaus = GetLLReadyInOutSlots(ll);
- var atmWafers = _lstWaferTasks.Where(wafer => (wafer.movingStatus == RState.End || wafer.movingStatus == RState.Init) && wafer.IsAligned && (ModuleHelper.IsEFEMRobot(wafer.currentMod) || ModuleHelper.IsAligner(wafer.currentMod))).ToList();
- var freeHands = GetEFEMFreeHand();
- var swapActions = new List<MoveItem>();
- var validHands = new List<Hand>();
- int placeCount = 0;
- if (waferStaus.emptySlot.Count > 0 &&
- freeHands.Count >= 1 &&
- atmWafers.Count(wafer => ModuleHelper.IsAligner(wafer.currentMod)) == 1 &&
- (atmWafers.Count(wafer => ModuleHelper.IsEFEMRobot(wafer.currentMod)) == 0 || waferStaus.emptySlot.Count >= 2))
- {
- var alignerWafer = atmWafers.Where(wafer => ModuleHelper.IsAligner(wafer.currentMod)).First();
- if (CanWaferGotoLL(alignerWafer, ll))
- {
- alignerWafer.RouteTo(ll, waferStaus.emptySlot[placeCount]);
- _efemSchdActions.Enqueue(new List<MoveItem> { new MoveItem(alignerWafer.currentMod, alignerWafer.currentSlot, ModuleName.EfemRobot, (int)freeHands[0], freeHands[0]) });
- swapActions.Add(new MoveItem(ModuleName.EfemRobot, (int)freeHands[0], ll, waferStaus.emptySlot[placeCount], freeHands[0]));
- validHands.Add(freeHands[0]);
- placeCount++;
- }
- }
- var armWafers = atmWafers.Where(wafer => ModuleHelper.IsEFEMRobot(wafer.currentMod)).ToArray();
- foreach (var wafer in armWafers)
- {
- if (CanWaferGotoLL(wafer, ll) && placeCount < waferStaus.emptySlot.Count)
- {
- wafer.RouteTo(ll, waferStaus.emptySlot[placeCount]);
- swapActions.Add(new MoveItem(wafer.currentMod, wafer.currentSlot, ll, waferStaus.emptySlot[placeCount], (Hand)wafer.currentSlot));
- if (!validHands.Contains((Hand)wafer.currentSlot))
- validHands.Add((Hand)wafer.currentSlot);
- placeCount++;
- }
- }
- if (!validHands.Contains(Hand.Blade1) && WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, (int)Hand.Blade1) && _efemRobotSingleArmOption != 2)
- validHands.Add(Hand.Blade1);
- if (!validHands.Contains(Hand.Blade2) && WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, (int)Hand.Blade2) && _efemRobotSingleArmOption != 1)
- validHands.Add(Hand.Blade2);
- int pickCount = 0;
- var returnActions = new List<MoveItem>();
- foreach (var slot in waferStaus.outSlot)
- {
- if (pickCount < validHands.Count)
- {
- var outWafer = _lstWaferTasks.Find(wafer => (wafer.movingStatus == RState.End || wafer.movingStatus == RState.Init) && wafer.currentMod == ll && wafer.currentSlot == slot);
- if (outWafer != null)
- {
- outWafer.RouteTo(outWafer.destMod, outWafer.destSlot);
- swapActions.Add(new MoveItem(ll, waferStaus.outSlot[pickCount], ModuleName.EfemRobot, (int)validHands[pickCount], validHands[pickCount]));
- returnActions.Add(new MoveItem(ModuleName.EfemRobot, (int)validHands[pickCount], outWafer.destMod, outWafer.destSlot, validHands[pickCount]));
- pickCount++;
- }
- }
- }
- if (swapActions.Count > 0)
- {
- _efemSchdActions.Enqueue(swapActions);
- }
- foreach (var action in returnActions)
- {
- _efemSchdActions.Enqueue(new List<MoveItem> { action });
- }
- return _efemSchdActions.Count > 0;
- }
- private bool ExchangeWaferWithFixedSlotLL(ModuleName ll)
- {
- if (IsLLReservedByTM(ll))
- return false;
- var llWaferStatus = GetLLFixedReadyInOutSlots(ll);
- var atmWafers = _lstWaferTasks.Where(wafer => (wafer.movingStatus == RState.End || wafer.movingStatus == RState.Init) && wafer.IsAligned && (ModuleHelper.IsEFEMRobot(wafer.currentMod) || ModuleHelper.IsAligner(wafer.currentMod))).ToList();
- var freeHands = GetEFEMFreeHand();
- var swapActions = new List<MoveItem>();
- var validHands = new List<Hand>();
- int placeCount = 0;
- if (llWaferStatus.eInSlot.Count > 0 &&
- freeHands.Count >= 1 &&
- atmWafers.Count(wafer => ModuleHelper.IsAligner(wafer.currentMod)) == 1 &&
- (atmWafers.Count(wafer => ModuleHelper.IsEFEMRobot(wafer.currentMod)) == 0 || llWaferStatus.eInSlot.Count >= 2))
- {
- var alignerWafer = atmWafers.Where(wafer => ModuleHelper.IsAligner(wafer.currentMod)).First();
- if (CanWaferGotoLL(alignerWafer, ll))
- {
- alignerWafer.RouteTo(ll, llWaferStatus.eInSlot[placeCount]);
- _efemSchdActions.Enqueue(new List<MoveItem> { new MoveItem(alignerWafer.currentMod, alignerWafer.currentSlot, ModuleName.EfemRobot, (int)freeHands[0], freeHands[0]) });
- swapActions.Add(new MoveItem(ModuleName.EfemRobot, (int)freeHands[0], ll, llWaferStatus.eInSlot[placeCount], freeHands[0]));
- validHands.Add(freeHands[0]);
- placeCount++;
- }
- }
- var armWafers = atmWafers.Where(wafer => ModuleHelper.IsEFEMRobot(wafer.currentMod)).ToArray();
- foreach (var wafer in armWafers)
- {
- if (CanWaferGotoLL(wafer, ll) && placeCount < llWaferStatus.eInSlot.Count)
- {
- wafer.RouteTo(ll, llWaferStatus.eInSlot[placeCount]);
- swapActions.Add(new MoveItem(wafer.currentMod, wafer.currentSlot, ll, llWaferStatus.eInSlot[placeCount], (Hand)wafer.currentSlot));
- if (!validHands.Contains((Hand)wafer.currentSlot))
- validHands.Add((Hand)wafer.currentSlot);
- placeCount++;
- }
- }
- if (!validHands.Contains(Hand.Blade1) && WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, (int)Hand.Blade1) && _efemRobotSingleArmOption != 2)
- validHands.Add(Hand.Blade1);
- if (!validHands.Contains(Hand.Blade2) && WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, (int)Hand.Blade2) && _efemRobotSingleArmOption != 1)
- validHands.Add(Hand.Blade2);
- int pickCount = 0;
- var returnActions = new List<MoveItem>();
- foreach (var slot in llWaferStatus.eOutSlot)
- {
- if (pickCount < validHands.Count)
- {
- var outWafer = _lstWaferTasks.Find(wafer => (wafer.movingStatus == RState.End || wafer.movingStatus == RState.Init) && wafer.currentMod == ll && wafer.currentSlot == slot);
- if (outWafer != null)
- {
- outWafer.RouteTo(outWafer.destMod, outWafer.destSlot);
- swapActions.Add(new MoveItem(ll, llWaferStatus.eOutSlot[pickCount], ModuleName.EfemRobot, (int)validHands[pickCount], validHands[pickCount]));
- returnActions.Add(new MoveItem(ModuleName.EfemRobot, (int)validHands[pickCount], outWafer.destMod, outWafer.destSlot, validHands[pickCount]));
- pickCount++;
- }
- }
- }
- if (swapActions.Count > 0)
- {
- _efemSchdActions.Enqueue(swapActions);
- }
- foreach (var action in returnActions)
- {
- _efemSchdActions.Enqueue(new List<MoveItem> { action });
- }
- return _efemSchdActions.Count > 0;
- }
- private void RoutingATMWafers()
- {
- if (_efemSchdActions.Count > 0 || _curEfemAction.Count > 0)
- {
- RunSchdEFEMActions();
- return;
- }
- if (_efemRobotStatus != RState.End)
- return;
- if (_LLSlotInOutOption == LLSlotInOutOpt.AllInAllOut)
- {
- if (_LLASlotNumber == 2)
- {
- Routing2SlotATMSystem();
- }
- else if (_LLASlotNumber == 4)
- {
- Routing4SlotATMSystem();
- }
- }
- else
- {
- RoutingFixedSlotATMSystem();
- }
- }
- private void Routing4SlotATMSystem()
- {
- var atmWaferCount = _lstWaferTasks.Where(wafer => ModuleHelper.IsEFEMRobot(wafer.currentMod) || ModuleHelper.IsAligner(wafer.currentMod)).Count();
- var efemRobotWafers = _lstWaferTasks.Where(wafer => ModuleHelper.IsEFEMRobot(wafer.currentMod)).ToList();
- if (LLInOutPath == SequenceLLInOutPath.AInBOut || LLInOutPath == SequenceLLInOutPath.BInAOut) // don need check system wafer existence as no blocking risk
- {
- var inLL = LLInOutPath == SequenceLLInOutPath.AInBOut ? ModuleName.LLA : ModuleName.LLB;
- var outLL = LLInOutPath == SequenceLLInOutPath.AInBOut ? ModuleName.LLB : ModuleName.LLA;
- var inLLWaferStatus = GetLLReadyInOutSlots(inLL);
- var outLLWaferStatus = GetLLReadyInOutSlots(outLL);
- if (efemRobotWafers.Count() >= 1)
- {
- if (inLLWaferStatus.emptySlot.Count >= 2 && !IsLLReservedByTM(inLL)) // wait for in loadlock ready
- {
- if (_dictModuleTask[inLL].TimeToReady < 2)
- {
- ExchangeWaferWithLL(inLL);
- }
- }
- if ((inLLWaferStatus.emptySlot.Count == 0 || (outLLWaferStatus.outSlot.Count >= 1 && _dictModuleTask[outLL].TimeToReady < 2)) && !IsLLReservedByTM(outLL)) // ready return wafer
- {
- ExchangeWaferWithLL(outLL);
- }
- }
- else
- {
- if (((outLLWaferStatus.outSlot.Count >= 2 && _dictModuleTask[outLL].TimeToReady < 10) ||
- (outLLWaferStatus.outSlot.Count == 1 && _dictModuleTask[outLL].TimeToReady < 2)) && !IsLLReservedByTM(outLL))
- {
- ExchangeWaferWithLL(outLL);
- }
- else if (inLLWaferStatus.emptySlot.Count >= 2)
- {
- if (((_dictModuleTask[inLL].TimeToReady > 20 || _dictModuleTask[inLL].Scheduler.IsVac) && atmWaferCount < 2) || atmWaferCount == 0)
- {
- ForwardATMWafers(inLL);
- }
- else if (atmWaferCount >= 2 && !IsLLReservedByTM(inLL))
- {
- ExchangeWaferWithLL(inLL);
- }
- }
- }
- }
- else
- {
- RoutingSameLLInOutATMSystem();
- }
- }
- private void Routing2SlotATMSystem()
- {
- var atmWaferCount = _lstWaferTasks.Where(wafer => ModuleHelper.IsEFEMRobot(wafer.currentMod) || ModuleHelper.IsAligner(wafer.currentMod)).Count();
- var efemRobotWafers = _lstWaferTasks.Where(wafer => ModuleHelper.IsEFEMRobot(wafer.currentMod)).ToList();
- var validHands = (_efemRobotSingleArmOption == 0 ? 2 : 1);
- if (LLInOutPath == SequenceLLInOutPath.AInBOut || LLInOutPath == SequenceLLInOutPath.BInAOut) // don need check system wafer existence as no blocking risk
- {
- var inLL = LLInOutPath == SequenceLLInOutPath.AInBOut ? ModuleName.LLA : ModuleName.LLB;
- var outLL = LLInOutPath == SequenceLLInOutPath.AInBOut ? ModuleName.LLB : ModuleName.LLA;
- var inLLWaferStatus = GetLLReadyInOutSlots(inLL);
- var outLLWaferStatus = GetLLReadyInOutSlots(outLL);
- var inLLModule = _dictModuleTask[inLL] as LoadlockTask;
- var outLLModule = _dictModuleTask[outLL] as LoadlockTask;
- var needAlign = _lstProcessJobs.Exists(pj => pj.State == EnumProcessJobState.Processing && IsSequenceNeedAlign(pj.Sequence));
- // return wafer while out LL ready or cooling state
- //if ((outLLWaferStatus.outSlot.Count > 0 && outLLWaferStatus.outSlot.Count <= (validHands - efemRobotWafers.Count)) && outLLModule.ReayForEfemInTime(10))
- if (outLLWaferStatus.outSlot.Count > 0 && outLLModule.ReayForEfemInTime(10))
- {
- if (ExchangeWaferWithLL(outLL))
- {
- //LOG.Write(eEvent.INFO_TROUGHPUT_ENHANCE_TRACE, outLL, $"{outLL} will be ready in {outLLModule.TimeToReady}");
- return;
- }
- }
- if (needAlign)
- {
- if (atmWaferCount == 0 ||
- (inLLModule.ReayForEfemInTime(20) && Math.Min(validHands, inLLWaferStatus.emptySlot.Count) > atmWaferCount))
- {
- if (ForwardATMWafers(inLL))
- {
- ////LOG.Write(eEvent.INFO_TROUGHPUT_ENHANCE_TRACE, inLL, $"{inLL} will be ready in {inLLModule.TimeToReady}");
- return;
- }
- }
- }
- else
- {
- if (inLLModule.ReayForEfemInTime(20) && inLLWaferStatus.emptySlot.Count > efemRobotWafers.Count && ((outLLModule.TimeToReady - inLLModule.TimeToReady > 10) || !outLLModule.ReayForEfemInTime(30) || outLLWaferStatus.emptySlot.Count < efemRobotWafers.Count))
- {
- if (ForwardATMWafers(inLL))
- {
- //LOG.Write(eEvent.INFO_TROUGHPUT_ENHANCE_TRACE, inLL, $"{inLL} will be ready in {inLLModule.TimeToReady}");
- return;
- }
- }
- }
- if (inLLModule.ReayForEfemInTime(5) &&
- (Math.Min(validHands, inLLWaferStatus.emptySlot.Count) == atmWaferCount || _qeWaitInWafers.Count == 0))
- {
- if (ExchangeWaferWithLL(inLL))
- {
- //LOG.Write(eEvent.INFO_TROUGHPUT_ENHANCE_TRACE, inLL, $"{inLL} will be ready in {inLLModule.TimeToReady}");
- return;
- }
- }
- }
- else
- {
- RoutingSameLLInOutATMSystem();
- }
- }
- private void RoutingFixedSlotATMSystem()
- {
- var atmWaferCount = _lstWaferTasks.Where(wafer => ModuleHelper.IsEFEMRobot(wafer.currentMod) || ModuleHelper.IsAligner(wafer.currentMod)).Count();
- var lls = _dictModuleTask.Where(mod => ModuleHelper.IsLoadLock(mod.Key) && mod.Value.Scheduler.IsOnline);
- if (atmWaferCount == 0 || (_efemRobotSingleArmOption == 0 && atmWaferCount == 1))
- {
- foreach (var ll in lls)
- {
- if (ForwardATMWafers(ll.Key))
- return;
- }
- }
- // try to match a ll swap action
- var readyReturnLL = lls.Where(ll => (GetLLFixedReadyInOutSlots(ll.Key).eOutSlot.Count + GetLLFixedReadyInOutSlots(ll.Key).eInSlot.Count > 0) && ll.Value.TimeToReady <= 10)
- .OrderByDescending(ll => GetLLFixedReadyInOutSlots(ll.Key).eInSlot.Count + GetLLFixedReadyInOutSlots(ll.Key).eOutSlot.Count)
- .OrderBy(ll => ll.Value.TimeToReady);
- foreach (var ll in readyReturnLL)
- {
- if (ExchangeWaferWithFixedSlotLL(ll.Key))
- return;
- }
- }
- private void RoutingSameLLInOutATMSystem()
- {
- var atmWaferCount = _lstWaferTasks.Where(wafer => ModuleHelper.IsEFEMRobot(wafer.currentMod) || ModuleHelper.IsAligner(wafer.currentMod)).Count();
- var vacWaferCount = _lstWaferTasks.Where(task => ModuleHelper.IsPm(task.currentMod) || ModuleHelper.IsTMRobot(task.currentMod) || ModuleHelper.IsLoadLock(task.currentMod)).Count();
- var preferWaferVacCount = _dictModuleTask.Where(mod => ModuleHelper.IsPm(mod.Key) && mod.Value.Scheduler.IsOnline).Count() +
- (LLInOutPath == SequenceLLInOutPath.AInAOut ? _LLASlotNumber / 2 : (LLInOutPath == SequenceLLInOutPath.BInBOut ? _LLBSlotNumber / 2 : _LLASlotNumber));
- var inOutIndicator = vacWaferCount - preferWaferVacCount;
- if (inOutIndicator < 0)
- {
- // ready to push in
- var readyLLs = _dictModuleTask.Where(mod => ModuleHelper.IsLoadLock(mod.Key) &&
- ((mod.Key == ModuleName.LLA && LLInOutPath != SequenceLLInOutPath.BInBOut) || (mod.Key == ModuleName.LLB && LLInOutPath != SequenceLLInOutPath.AInAOut)) &&
- mod.Value.TimeToReady <= 10 &&
- !IsLLReservedByTM(mod.Key) &&
- GetLLReadyInOutSlots(mod.Key).emptySlot.Count >= 1).
- OrderBy(mod => mod.Value.TimeToReady).ToList();
- if (atmWaferCount >= 1)
- {
- foreach (var ll in readyLLs)
- {
- if (ExchangeWaferWithLL(ll.Key))
- return;
- }
- }
- // forward wafer to system
- if (atmWaferCount < 2)
- {
- var targetLL = readyLLs.Count > 0 ? readyLLs.First().Key : (LLInOutPath == SequenceLLInOutPath.BInBOut ? ModuleName.LLB : ModuleName.LLA);
- ForwardATMWafers(targetLL);
- }
- if (_efemSchdActions.Count == 0)
- {
- var readyReturnLL = _dictModuleTask.Where(mod => ModuleHelper.IsLoadLock(mod.Key) &&
- ((mod.Key == ModuleName.LLA && LLInOutPath != SequenceLLInOutPath.BInBOut) || (mod.Key == ModuleName.LLB && LLInOutPath != SequenceLLInOutPath.AInAOut)) &&
- mod.Value.TimeToReady <= 5 &&
- !IsLLReservedByTM(mod.Key) &&
- GetLLReadyInOutSlots(mod.Key).outSlot.Count >= 1).
- OrderByDescending(mod => GetLLReadyInOutSlots(mod.Key).outSlot.Count).ToList();
- foreach (var ll in readyReturnLL)
- {
- if (ExchangeWaferWithLL(readyReturnLL.First().Key))
- return;
- }
- }
- }
- else
- {
- // ready double return LL
- var readyDoubleReturnLL = _dictModuleTask.Where(mod => ModuleHelper.IsLoadLock(mod.Key) &&
- mod.Value.TimeToReady < 10 &&
- !IsLLReservedByTM(mod.Key) &&
- GetLLReadyInOutSlots(mod.Key).outSlot.Count > 1).
- OrderBy(mod => mod.Value.TimeToReady).ToList();
- foreach (var ll in readyDoubleReturnLL)
- {
- if (ExchangeWaferWithLL(ll.Key))
- return;
- }
- // ready single return LL
- var readySingleReturnLL = _dictModuleTask.Where(mod => ModuleHelper.IsLoadLock(mod.Key) &&
- mod.Value.TimeToReady < 2 &&
- !IsLLReservedByTM(mod.Key) &&
- GetLLReadyInOutSlots(mod.Key).outSlot.Count == 1).
- OrderBy(mod => mod.Value.TimeToReady).ToList();
- foreach (var ll in readySingleReturnLL)
- {
- if (ExchangeWaferWithLL(ll.Key))
- return;
- }
- if (atmWaferCount == 0)
- {
- // ready to push in
- var readyLLs = _dictModuleTask.Where(mod => ModuleHelper.IsLoadLock(mod.Key) &&
- ((mod.Key != ModuleName.LLA && LLInOutPath == SequenceLLInOutPath.BInBOut) || (mod.Key != ModuleName.LLB && LLInOutPath == SequenceLLInOutPath.AInAOut)) &&
- mod.Value.TimeToReady <= 10 &&
- !IsLLReservedByTM(mod.Key) &&
- GetLLReadyInOutSlots(mod.Key).emptySlot.Count > 1).
- OrderBy(mod => mod.Value.TimeToReady).ToList();
- foreach (var ll in readyLLs)
- {
- if (ForwardATMWafers(ll.Key))
- return;
- }
- }
- }
- }
- private bool isReturnActionsDone(List<MoveItem> items)
- {
- foreach (var item in items)
- {
- if (WaferManager.Instance.CheckHasWafer(item.SourceModule, item.SourceSlot) || WaferManager.Instance.CheckNoWafer(item.DestinationModule, item.DestinationSlot))
- return false;
- }
- return true;
- }
- private bool IsMovingActionsDone(List<MoveItem> actions)
- {
- bool CheckWaferExistence(ModuleName mod, int slot)
- {
- return ModuleHelper.IsLoadPort(mod) ? WaferManager.Instance.CheckHasWafer(mod, slot) : _lstWaferTasks.Exists(wt => wt.currentMod == mod && wt.currentSlot == slot);
- }
- if (actions.Count == 1)
- {
- if (CheckWaferExistence(actions.First().SourceModule, actions.First().SourceSlot) ||
- !CheckWaferExistence(actions.First().DestinationModule, actions.First().DestinationSlot))
- return false;
- }
- else
- {
- // initialize all the wafer existance before move
- var slotWafers = new Dictionary<KeyValuePair<ModuleName, int>, bool>();
- foreach (var ac in actions)
- {
- var scrSlot = new KeyValuePair<ModuleName, int>(ac.SourceModule, ac.SourceSlot);
- var destSlot = new KeyValuePair<ModuleName, int>(ac.DestinationModule, ac.DestinationSlot);
- if (!slotWafers.ContainsKey(scrSlot))
- {
- slotWafers[scrSlot] = true;
- }
- if (!slotWafers.ContainsKey(destSlot))
- {
- slotWafers[destSlot] = false;
- }
- }
- // simulate moved result
- foreach (var ac in actions)
- {
- var scrSlot = new KeyValuePair<ModuleName, int>(ac.SourceModule, ac.SourceSlot);
- var destSlot = new KeyValuePair<ModuleName, int>(ac.DestinationModule, ac.DestinationSlot);
- if (!slotWafers[scrSlot])
- {
- LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, $"{slotWafers[scrSlot]} do not has a wafer");
- }
- else
- {
- slotWafers[scrSlot] = false;
- }
- if (slotWafers[destSlot])
- {
- LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, $"{slotWafers[destSlot]} has a wafer");
- }
- else
- {
- slotWafers[destSlot] = true;
- }
- }
- foreach (var slot in slotWafers)
- {
- if (slot.Value != CheckWaferExistence(slot.Key.Key, slot.Key.Value))
- return false;
- }
- }
- return true;
- }
- private bool IsLLReservedByTM(ModuleName ll)
- {
- foreach (var item in _curTmAction)
- {
- if (item.DestinationModule == ll || item.SourceModule == ll)
- return true;
- }
- foreach (var action in _tmSchdActions)
- {
- foreach (var item in action)
- {
- if (item.DestinationModule == ll || item.SourceModule == ll)
- return true;
- }
- }
- return false;
- }
- private bool IsLLReservedByEFEM(ModuleName ll)
- {
- foreach (var item in _curEfemAction)
- {
- if (item.DestinationModule == ll || item.SourceModule == ll)
- return true;
- }
- foreach (var action in _efemSchdActions)
- {
- foreach (var item in action)
- {
- if (item.DestinationModule == ll || item.SourceModule == ll)
- return true;
- }
- }
- return false;
- }
- private void RunSchdEFEMActions()
- {
- var efemRobot = Singleton<TransferModule>.Instance.GetScheduler(ModuleName.EfemRobot) as SchedulerEfemRobot;
- if (efemRobot == null || !efemRobot.IsAvailable)
- return;
- if (_dictModuleTask[ModuleName.EfemRobot].IsIdle)
- {
- if (_efemSchdActions.Count > 0)
- {
- if (_curEfemAction.Count == 0 || IsMovingActionsDone(_curEfemAction))
- {
- var nextActions = _efemSchdActions.First();
- if (nextActions.Exists(action => !_lstWaferTasks.Exists(wafer => (wafer.movingStatus == RState.End || wafer.movingStatus == RState.Init) && wafer.currentMod == action.SourceModule && wafer.currentSlot == action.SourceSlot)))
- return;
- var nextModule = nextActions.First().Module;
- if (ModuleHelper.IsLoadLock(nextModule) && !_dictModuleTask[nextModule].Scheduler.IsAvailable)
- return;
- _curEfemAction = _efemSchdActions.Dequeue();
- foreach (var action in _curEfemAction)
- {
- var waferTask = _lstWaferTasks.Find(wafer => (wafer.movingStatus == RState.End || wafer.movingStatus == RState.Init) && wafer.currentMod == action.SourceModule && wafer.currentSlot == action.SourceSlot);
- waferTask.MoveTo(action.DestinationModule, action.DestinationSlot);
- //--2024-03-21 增加了PortJobWaferStart 上报事件 start--
- if (ModuleHelper.IsLoadPort(action.SourceModule))
- {
- ControlJobInfo currentControlJob = GetLoadPortCurrentControlJob(action.SourceModule);
- if (currentControlJob != null)
- {
- _faCallback.JobWaferStart(currentControlJob, action.SourceSlot);
- }
- }
- if (ModuleHelper.IsLoadPort(action.DestinationModule))
- {
- ControlJobInfo currentControlJob = GetLoadPortCurrentControlJob(action.DestinationModule);
- if (currentControlJob != null)
- {
- _faCallback.JobWaferEnd(currentControlJob, action.SourceSlot);
- }
- }
- //--2024-03-21 增加了PortJobWaferStart 上报事件 end--
- }
- (_dictModuleTask[ModuleName.EfemRobot].Scheduler as SchedulerEfemRobot).PostMoveItems(_curEfemAction.ToArray());
- }
- }
- else if (_curEfemAction.Count >= 0 && IsMovingActionsDone(_curEfemAction)) // all scheduled actions done
- {
- _curEfemAction.Clear();
- }
- }
- }
- private void RunSchdTMActions()
- {
- if (_dictModuleTask[ModuleName.TMRobot].IsIdle)
- {
- if (_tmSchdActions.Count > 0)
- {
- if (_curTmAction.Count == 0 || IsMovingActionsDone(_curTmAction))
- {
- var nextActions = _tmSchdActions.First();
- if (nextActions.Exists(action => !_lstWaferTasks.Exists(wafer => (wafer.movingStatus == RState.End || wafer.movingStatus == RState.Init) && wafer.currentMod == action.SourceModule && wafer.currentSlot == action.SourceSlot)))
- return;
- if (ModuleHelper.IsPm(nextActions.First().Module) && !_dictModuleTask[nextActions.First().Module].IsIdle) /// wait PMTask status update to idle
- return;
- _curTmAction = _tmSchdActions.Dequeue();
- foreach (var action in _curTmAction)
- {
- var waferTask = _lstWaferTasks.Find(wafer => (wafer.movingStatus == RState.End || wafer.movingStatus == RState.Init) && wafer.currentMod == action.SourceModule && wafer.currentSlot == action.SourceSlot);
- waferTask.MoveTo(action.DestinationModule, action.DestinationSlot);
- }
- (_dictModuleTask[ModuleName.TMRobot].Scheduler as SchedulerTMRobot).SendMoveItems(_curTmAction.ToArray());
- }
- }
- else if (_curTmAction.Count >= 0 && IsMovingActionsDone(_curTmAction)) // all scheduled actions done
- {
- _curTmAction.Clear();
- }
- }
- }
- private int TimeForNextModuleReady(WaferTask task)
- {
- if (ModuleHelper.IsPm(task.destMod) && (ModuleHelper.IsLoadLock(task.currentMod) || ModuleHelper.IsTMRobot(task.currentMod)))
- return _dictModuleTask[task.destMod].TimeToReady;
- var llbWaferStatus = GetLLReadyInOutSlots(ModuleName.LLB);
- var llaWaferStatus = GetLLReadyInOutSlots(ModuleName.LLA);
- if (ModuleHelper.IsLoadPort(task.destMod) && (ModuleHelper.IsPm(task.currentMod) || ModuleHelper.IsTMRobot(task.currentMod)))
- {
- if (task.llInOutPath == SequenceLLInOutPath.AInBOut || task.llInOutPath == SequenceLLInOutPath.BInBOut)
- {
- if (llbWaferStatus.emptySlot.Count > 0)
- {
- return _dictModuleTask[ModuleName.LLB].TimeToReady;
- }
- }
- else if (task.llInOutPath == SequenceLLInOutPath.BInAOut || task.llInOutPath == SequenceLLInOutPath.AInAOut)
- {
- if (llaWaferStatus.emptySlot.Count > 0)
- {
- return _dictModuleTask[ModuleName.LLA].TimeToReady;
- }
- }
- else if (task.llInOutPath == SequenceLLInOutPath.DInDOut)
- {
- if (llaWaferStatus.emptySlot.Count > 0 && llbWaferStatus.emptySlot.Count > 0)
- {
- if (_dictModuleTask[ModuleName.LLA].TimeToReady == _dictModuleTask[ModuleName.LLB].TimeToReady)
- {
- return _dictModuleTask[ModuleName.LLA].TimeToReady;
- }
- else
- {
- return Math.Min(_dictModuleTask[ModuleName.LLA].TimeToReady, _dictModuleTask[ModuleName.LLB].TimeToReady);
- }
- }
- else if (llaWaferStatus.emptySlot.Count > 0)
- {
- return _dictModuleTask[ModuleName.LLA].TimeToReady;
- }
- else if (llbWaferStatus.emptySlot.Count > 0)
- {
- return _dictModuleTask[ModuleName.LLB].TimeToReady;
- }
- }
- }
- else if (ModuleHelper.IsPm(task.destMod) && (ModuleHelper.IsLoadLock(task.currentMod) || ModuleHelper.IsTMRobot(task.currentMod)))
- {
- if (_lstWaferTasks.Find(wafer => wafer.currentMod == task.destMod || wafer.routedMod == task.destMod) == null)
- {
- return _dictModuleTask[task.destMod].TimeToReady;
- }
- }
- return int.MaxValue / 2;
- }
- List<Hand> GetTMValidFreeHands(List<WaferTask> robotWafers, List<MoveItem> swapActions)
- {
- var hands = new List<Hand>();
- for (int i = 0; i < 2; i++)
- {
- if (_tmRobotSingleArmOption == 0 || _tmRobotSingleArmOption == i + 1)
- {
- if ((!robotWafers.Exists(wafer => wafer.currentSlot == i) ||
- (robotWafers.Exists(wafer => wafer.currentSlot == i) &&
- swapActions.Exists(item => item.SourceModule == ModuleName.TMRobot && item.SourceSlot == i))) &&
- !swapActions.Exists(item => item.DestinationModule == ModuleName.TMRobot && item.DestinationSlot == i))
- hands.Add((Hand)i);
- }
- }
- return hands;
- }
- (ModuleName llPath, List<MoveItem> swapActions) FindBestLLSwapPlan(ModuleName ll, List<WaferTask> robotWafers)
- {
- ModuleName path = ll == ModuleName.System ? ModuleName.System : ll;
- List<ModuleName> lls = ll == ModuleName.System ? new List<ModuleName> { ModuleName.LLA, ModuleName.LLB } : new List<ModuleName> { ll };
- List<MoveItem> actions = new List<MoveItem>();
- Dictionary<ModuleName, List<MoveItem>> llSwapActions = new Dictionary<ModuleName, List<MoveItem>>();
- foreach (var loadlock in lls)
- {
- llSwapActions[loadlock] = new List<MoveItem>();
- if (IsLLReservedByEFEM(loadlock))
- continue;
- var llWaferStatus = GetLLReadyInOutSlots(loadlock);
- foreach (var wafer in robotWafers)
- {
- if (_dictModuleTask[loadlock].TimeToReady == 0 && !IsLLReservedByEFEM(loadlock) && CanWaferGotoLL(wafer, loadlock) && llWaferStatus.emptySlot.Count > llSwapActions[loadlock].Count)
- {
- llSwapActions[loadlock].Add(new MoveItem(ModuleName.TMRobot, wafer.currentSlot, loadlock, llWaferStatus.emptySlot[llSwapActions[loadlock].Count], (Hand)wafer.currentSlot));
- }
- }
- int prePickTime = 20;
- int prePickCount = 0;
- var hands = GetTMValidFreeHands(robotWafers, llSwapActions[loadlock]);
- foreach (var slot in llWaferStatus.inSlot)
- {
- var wafer = _lstWaferTasks.Find(task => task.currentMod == loadlock && task.currentSlot == slot);
- if (wafer != null && _dictModuleTask[wafer.destMod].TimeToReady <= prePickTime && _dictModuleTask[wafer.destMod].Scheduler.IsOnline && hands.Count > prePickCount)
- {
- if (_lstWaferTasks.Exists(task => task.currentMod == wafer.destMod))
- {
- if (hands.Count == 2 && prePickCount == 0 && (_dictModuleTask.Count(mod => ModuleHelper.IsPm(mod.Key) && mod.Value.TimeToReady < prePickTime && WaferManager.Instance.CheckNoWafer(mod.Key, 0)) == 0 || llWaferStatus.inSlot.Count == 1))
- {
- llSwapActions[loadlock].Add(new MoveItem(loadlock, slot, ModuleName.TMRobot, (int)hands[prePickCount], hands[prePickCount]));
- prePickCount++;
- break;
- }
- }
- else
- {
- llSwapActions[loadlock].Add(new MoveItem(loadlock, slot, ModuleName.TMRobot, (int)hands[prePickCount], hands[prePickCount]));
- prePickCount++;
- }
- }
- }
- }
- var validateActions = llSwapActions.Where(item => item.Value.Count > 0).ToDictionary(k => k.Key, v => v.Value);
- if (validateActions.Count == 1)
- {
- (path, actions) = (validateActions.First().Key, validateActions.First().Value);
- }
- else if (validateActions.Count == 2)
- {
- var sortedActions = validateActions.OrderByDescending(item => item.Value.Count + (_dictModuleTask[item.Key].Scheduler.IsVac ? 2 : 0)).ToDictionary(k => k.Key, v => v.Value);
- (path, actions) = (sortedActions.First().Key, sortedActions.First().Value);
- }
- return (path, actions);
- }
- (List<WaferTask> pmWafers, ModuleName destLL, List<MoveItem> swapAction) FindBestReturnWafersPlan(Hand[] freeHands)
- {
- Dictionary<ModuleName, List<WaferTask>> returnWafers = new Dictionary<ModuleName, List<WaferTask>>();
- Dictionary<ModuleName, List<MoveItem>> llSwapActions = new Dictionary<ModuleName, List<MoveItem>>();
- Dictionary<ModuleName, int> llValues = new Dictionary<ModuleName, int>();
- foreach (var ll in new List<ModuleName> { ModuleName.LLA, ModuleName.LLB })
- {
- var llWaferStatus = GetLLReadyInOutSlots(ll);
- returnWafers[ll] = new List<WaferTask>();
- llSwapActions[ll] = new List<MoveItem>();
- llValues[ll] = 0;
- if (IsLLReservedByEFEM(ll))
- continue;
- var readyReturnWafers = _lstWaferTasks.Where(wafer => ModuleHelper.IsPm(wafer.currentMod) &&
- ModuleHelper.IsLoadPort(wafer.destMod) &&
- wafer.movingStatus == RState.End &&
- _dictModuleTask[wafer.currentMod].TimeToReady <= 2 &&
- CanWaferGotoLL(wafer, ll)).Take(Math.Min(freeHands.Length, llWaferStatus.emptySlot.Count)).ToList();
- int prePickTime = 10 * llSwapActions[ll].Count;
- int handIndex = 0;
- if (_dictModuleTask[ll].TimeToReady <= prePickTime)
- {
- foreach (var wafer in readyReturnWafers)
- {
- if (handIndex < freeHands.Length)
- {
- returnWafers[ll].Add(wafer);
- llSwapActions[ll].Add(new MoveItem(ModuleName.TMRobot, (int)freeHands[handIndex], ll, llWaferStatus.emptySlot[handIndex], freeHands[handIndex]));
- handIndex++;
- }
- }
- int prePickCount = 0;
- handIndex = 0;
- foreach (var slot in llWaferStatus.inSlot)
- {
- var wafer = _lstWaferTasks.Find(task => task.currentMod == ll && task.currentSlot == slot);
- if (wafer != null && _dictModuleTask[wafer.destMod].TimeToReady <= prePickTime && _dictModuleTask[wafer.destMod].Scheduler.IsOnline && freeHands.Length > prePickCount)
- {
- if (_lstWaferTasks.Exists(task => task.currentMod == wafer.destMod))
- {
- if (freeHands.Length == 2 && prePickCount == 0 && (_dictModuleTask.Count(mod => ModuleHelper.IsPm(mod.Key) && mod.Value.TimeToReady <= prePickTime && WaferManager.Instance.CheckNoWafer(mod.Key, 0)) == 0 || llWaferStatus.inSlot.Count == 1))
- {
- llSwapActions[ll].Add(new MoveItem(ll, slot, ModuleName.TMRobot, (int)freeHands[prePickCount], freeHands[prePickCount]));
- prePickCount++;
- break;
- }
- }
- else
- {
- llSwapActions[ll].Add(new MoveItem(ll, slot, ModuleName.TMRobot, (int)freeHands[prePickCount], freeHands[prePickCount]));
- prePickCount++;
- }
- }
- }
- llValues[ll] = returnWafers[ll].Count * 2 + llSwapActions[ll].Count + (_dictModuleTask[ll].Scheduler.IsVac && returnWafers[ll].Count > 0 ? 2 : 0);
- }
- }
- var preferLL = llValues.OrderByDescending(v => v.Value).First().Key;
- return (returnWafers[preferLL], preferLL, llSwapActions[preferLL]);
- }
- ModuleName FindTheBestMovePathWithFixSlot(IEnumerable<KeyValuePair<ModuleName, ModuleTask>> lls, List<WaferTask> pmWafers)
- {
- Dictionary<ModuleName, int> moveValues = new Dictionary<ModuleName, int>();
- foreach (var ll in lls)
- {
- var llWaferStatus = GetLLFixedReadyInOutSlots(ll.Key);
- moveValues[ll.Key] = Math.Min(pmWafers.Where(wt => CanWaferGotoLL(wt, ll.Key)).Count(), GetLLFixedReadyInOutSlots(ll.Key).tInSlot.Count) + llWaferStatus.tOutSlot.Count;
- }
- var preferLL = moveValues.OrderByDescending(v => v.Value).First().Key;
- return moveValues[preferLL] > 0 ? preferLL : ModuleName.System;
- }
- void RoutingTMSwapActions(List<MoveItem> actions)
- {
- foreach (var action in actions)
- {
- if (ModuleHelper.IsTMRobot(action.SourceModule))
- {
- var waferTask = _lstWaferTasks.Find(wafer => wafer.currentMod == ModuleName.TMRobot && wafer.currentSlot == action.SourceSlot);
- waferTask.RouteTo(action.DestinationModule, action.DestinationSlot);
- }
- else
- {
- var waferTask = _lstWaferTasks.Find(wafer => wafer.currentMod == action.SourceModule && wafer.currentSlot == action.SourceSlot);
- waferTask.RouteTo(action.DestinationModule, action.DestinationSlot);
- }
- }
- }
- private bool ManaulReturnPMWafer()
- {
- var mReturnWafer = _qeReturnWafers.Peek();
- if (ModuleHelper.IsPm((ModuleName)mReturnWafer.Station) && _lstWaferTasks.Count(wt => ModuleHelper.IsTMRobot(wt.currentMod)) == 0)
- {
- var hands = GetTMValidFreeHands(_lstWaferTasks.Where(wt => ModuleHelper.IsTMRobot(wt.currentMod)).ToList(), new List<MoveItem>());
- var waferTask = _lstWaferTasks.Find(wt => wt.currentMod == (ModuleName)mReturnWafer.Station && wt.waferId == mReturnWafer.InnerId);
- if (waferTask != null && hands.Count > 0)
- {
- waferTask.Return();
- var outLL = _dictModuleTask.Where(mod => ModuleHelper.IsLoadLock(mod.Key) && CanWaferGotoLL(waferTask, mod.Key) && GetLLReadyInOutSlots(mod.Key).emptySlot.Count > 0 && !IsLLReservedByEFEM(mod.Key));
- if (outLL.Count() > 0)
- {
- var slot = GetLLReadyInOutSlots(outLL.First().Key).emptySlot.First();
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(waferTask.currentMod, 0, ModuleName.TMRobot, (int)hands.First(), hands.First()) });
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.TMRobot, (int)hands.First(), outLL.First().Key, slot, hands.First()) });
- _qeReturnWafers.Dequeue();
- return true;
- }
- }
- }
- return false;
- }
- private void RoutingVacWafers()
- {
- if (_tmSchdActions.Count > 0 || _curTmAction.Count > 0)
- {
- RunSchdTMActions();
- return;
- }
- if (_tmRobotStatus == RState.End)
- {
- // handle manual return wafer if exist
- if (_qeReturnWafers.Count > 0)
- {
- if (ManaulReturnPMWafer())
- return;
- }
- if (_LLSlotInOutOption == LLSlotInOutOpt.AllInAllOut)
- {
- if (_LLASlotNumber == 2)
- {
- Routing2SlotVacSystem();
- }
- else if (_LLASlotNumber == 4)
- {
- Routing4SlotVacSystem();
- }
- }
- else
- {
- RoutingFixedSlotVacSystem();
- }
- }
- }
- private bool HasPendingCleanTask()
- {
- foreach (var mod in _dictModuleTask)
- {
- if (ModuleHelper.IsPm(mod.Key) && mod.Value.Scheduler.IsOnline)
- {
- if ((mod.Value as PMTask).HasPendingCleanTask)
- return true;
- }
- }
- return false;
- }
- private void Routing2SlotVacSystem()
- {
- var robotWafers = _lstWaferTasks.Where(wafer => ModuleHelper.IsTMRobot(wafer.currentMod)).OrderBy(wafer => TimeForNextModuleReady(wafer)).ToList();
- var freeHands = GetTMFreeHand();
- if (LLInOutPath == SequenceLLInOutPath.AInBOut || LLInOutPath == SequenceLLInOutPath.BInAOut)
- {
- var inLL = LLInOutPath == SequenceLLInOutPath.AInBOut ? ModuleName.LLA : ModuleName.LLB;
- var outLL = LLInOutPath == SequenceLLInOutPath.AInBOut ? ModuleName.LLB : ModuleName.LLA;
- var inLLWaferStatus = GetLLReadyInOutSlots(inLL);
- var outLLWaferStatus = GetLLReadyInOutSlots(outLL);
- var inLLModule = _dictModuleTask[inLL] as LoadlockTask;
- var outLLModule = _dictModuleTask[outLL] as LoadlockTask;
- if (robotWafers.Count == 0)
- {
- #region special routing pattern
- if (_specialRoutingPattern != SpecialRoutingPattern.Disable)
- {
- if (_specialRoutingPattern == SpecialRoutingPattern.LongTimeRecipe && freeHands.Count == 2 && !HasPendingCleanTask())
- {
- if (_dictModuleTask.Where(mod => ModuleHelper.IsPm(mod.Key) && !mod.Value.HasWafer && mod.Value.Scheduler.IsOnline).Count() == 0 && inLLWaferStatus.inSlot.Count > 0)
- {
- var readyOutPMs = _dictModuleTask.Where(mod => ModuleHelper.IsPm(mod.Key) && mod.Value.HasWafer && mod.Value.TimeToReady < 25).OrderBy(mod => mod.Value.TimeToReady).ToList();
- if (readyOutPMs.Count > 0 && inLLModule.ReayForTMInTime(5) && _lstWaferTasks.Exists(wt => wt.currentMod == inLL && readyOutPMs.Exists(kv => kv.Key == wt.destMod)))
- {
- var llWafer = _lstWaferTasks.Find(wt => wt.currentMod == inLL && wt.destMod == readyOutPMs.First().Key);
- if (llWafer == null)
- {
- llWafer = _lstWaferTasks.Find(wt => wt.currentMod == inLL && readyOutPMs.Exists(pm => pm.Key == wt.destMod && pm.Value.TimeToReady < 5));
- }
- if (llWafer != null)
- {
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(inLL, llWafer.currentSlot, ModuleName.TMRobot, (int)freeHands[0], freeHands[0]) });
- var pmSwap = new List<MoveItem>
- { new MoveItem(readyOutPMs.First().Key, 0, ModuleName.TMRobot, (int)freeHands[1], freeHands[1]),
- new MoveItem(ModuleName.TMRobot, (int)freeHands[0], readyOutPMs.First().Key, 0, freeHands[0])
- };
- _tmSchdActions.Enqueue(pmSwap);
- if (outLLModule.ReayForTMInTime(25) && outLLWaferStatus.emptySlot.Count > 0)
- {
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.TMRobot, (int)freeHands[1], outLL, outLLWaferStatus.emptySlot[0], freeHands[1]) });
- }
- }
- }
- return;
- }
- }
- }
- #endregion
- if (_dictModuleTask.Count(mod => ModuleHelper.IsPm(mod.Key) && mod.Value.HasWafer && mod.Value.TimeToReady < 5) > 0 && outLLModule.ReayForTMInTime(30) && outLLWaferStatus.emptySlot.Count > 0)
- {
- var readyOutPMs = _dictModuleTask.Where(mod => ModuleHelper.IsPm(mod.Key) && mod.Value.HasWafer && mod.Value.TimeToReady < 25).OrderBy(mod => mod.Value.TimeToReady).ToList();
- var placeActions = new List<MoveItem>();
- int pickCount = 0;
- foreach (var pm in readyOutPMs)
- {
- var pmWafer = _lstWaferTasks.Find(wt => wt.currentMod == pm.Key);
- if (pmWafer != null && pickCount < freeHands.Count && pickCount < outLLWaferStatus.emptySlot.Count)
- {
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(pm.Key, 0, ModuleName.TMRobot, (int)freeHands[pickCount], freeHands[pickCount]) });
- placeActions.Add(new MoveItem(ModuleName.TMRobot, (int)freeHands[pickCount], outLL, outLLWaferStatus.emptySlot[pickCount], freeHands[pickCount]));
- pickCount++;
- //LOG.Write(eEvent.INFO_TROUGHPUT_ENHANCE_TRACE, pm.Key, $"{pm.Key} will be ready in {pm.Value.TimeToReady} seconds");
- }
- }
- if (pickCount > 0)
- {
- //LOG.Write(eEvent.INFO_TROUGHPUT_ENHANCE_TRACE, outLL, $"{outLL} will be ready in {outLLModule.TimeToReady} seconds");
- _tmSchdActions.Enqueue(placeActions);
- return;
- }
- }
- // push wafer from LL to PM and avoid blocking two robot arms
- if (inLLModule.ReayForTMInTime(10) && inLLWaferStatus.inSlot.Count > 0)
- {
- var pickActions = new List<MoveItem>();
- var inLLWafers = _lstWaferTasks.FindAll(wt => wt.currentMod == inLL).ToList();
- if (inLLWaferStatus.inSlot.Count < 2 || inLLWafers.Exists(wt => !_dictModuleTask[wt.destMod].HasWafer && _dictModuleTask[wt.destMod].TimeToReady < 20))
- {
- for (int i = 0; i < Math.Min(inLLWaferStatus.inSlot.Count, freeHands.Count); i++)
- {
- pickActions.Add(new MoveItem(inLL, inLLWaferStatus.inSlot[i], ModuleName.TMRobot, (int)freeHands[i], freeHands[i]));
- }
- }
- if (pickActions.Count > 0)
- {
- //LOG.Write(eEvent.INFO_TROUGHPUT_ENHANCE_TRACE, inLL, $"{inLL} will be ready in {inLLModule.TimeToReady} seconds");
- _tmSchdActions.Enqueue(pickActions);
- return;
- }
- }
- }
- else
- {
- #region special routing pattern
- if (_specialRoutingPattern != SpecialRoutingPattern.Disable)
- {
- if (_specialRoutingPattern == SpecialRoutingPattern.LongTimeRecipe && _tmRobotSingleArmOption == 0 && !HasPendingCleanTask())
- {
- if (_dictModuleTask.Where(mod => ModuleHelper.IsPm(mod.Key) && !mod.Value.HasWafer && mod.Value.Scheduler.IsOnline).Count() == 0 && ModuleHelper.IsLoadPort(robotWafers[0].destMod))
- {
- if (outLLModule.ReayForTMInTime(10) && outLLWaferStatus.emptySlot.Count > 0)
- {
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.TMRobot, robotWafers[0].currentSlot, outLL, outLLWaferStatus.emptySlot[0], (Hand)(robotWafers[0].currentSlot)) });
- }
- return;
- }
- }
- }
- #endregion
- foreach (var robotWafer in robotWafers)
- {
- if (ModuleHelper.IsPm(robotWafer.destMod))
- {
- if (_dictModuleTask[robotWafer.destMod].TimeToReady < 5)
- {
- var pmWafer = _lstWaferTasks.Find(wt => wt.currentMod == robotWafer.destMod);
- if (_dictModuleTask[robotWafer.destMod].HasWafer && pmWafer != null)
- {
- // PM Swap
- if (freeHands.Count > 0)
- {
- if (string.IsNullOrWhiteSpace(pmWafer.wtwCleanRecipe) && !(_dictModuleTask[pmWafer.currentMod] as PMTask).HasPendingCleanTask)
- {
- var pmActions = new List<MoveItem>
- {
- new MoveItem(robotWafer.destMod, 0, ModuleName.TMRobot, (int)freeHands[0], freeHands[0]),
- new MoveItem(ModuleName.TMRobot, robotWafer.currentSlot, robotWafer.destMod, 0, (Hand)robotWafer.currentSlot)
- };
- _tmSchdActions.Enqueue(pmActions);
- //LOG.Write(eEvent.INFO_TROUGHPUT_ENHANCE_TRACE, robotWafer.destMod, $"{robotWafer.destMod} will be ready in {_dictModuleTask[robotWafer.destMod].TimeToReady} seconds");
- return;
- }
- else
- {
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(robotWafer.destMod, 0, ModuleName.TMRobot, (int)freeHands[0], freeHands[0]) });
- return;
- }
- }
- }
- else
- {
- //LOG.Write(eEvent.INFO_TROUGHPUT_ENHANCE_TRACE, robotWafer.destMod, $"{robotWafer.destMod} will be ready in {_dictModuleTask[robotWafer.destMod].TimeToReady} seconds");
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.TMRobot, robotWafer.currentSlot, robotWafer.destMod, 0, (Hand)robotWafer.currentSlot) });
- return;
- }
- }
- else if (_dictModuleTask[robotWafer.destMod].TimeToReady > 20 && freeHands.Count > 0)
- {
- if (outLLWaferStatus.emptySlot.Count > 0 && outLLModule.ReayForTMInTime(10) && _lstWaferTasks.Count(wt => ModuleHelper.IsPm(wt.currentMod) && ModuleHelper.IsLoadPort(wt.destMod)) > 0)
- {
- // try to return one wafer from PM to LL
- var readyOutWafer = _lstWaferTasks.Find(wt => ModuleHelper.IsPm(wt.currentMod) && ModuleHelper.IsLoadPort(wt.destMod));
- if (readyOutWafer != null && _dictModuleTask[readyOutWafer.currentMod].TimeToReady < 5)
- {
- //LOG.Write(eEvent.INFO_TROUGHPUT_ENHANCE_TRACE, readyOutWafer.currentMod, $"{readyOutWafer.currentMod} will be ready in {_dictModuleTask[readyOutWafer.currentMod].TimeToReady} seconds");
- //LOG.Write(eEvent.INFO_TROUGHPUT_ENHANCE_TRACE, outLL, $"{outLL} will be ready in {outLLModule.TimeToReady} seconds");
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(readyOutWafer.currentMod, 0, ModuleName.TMRobot, (int)freeHands[0], freeHands[0]) });
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.TMRobot, (int)freeHands[0], outLL, outLLWaferStatus.emptySlot[0], freeHands[0]) });
- return;
- }
- }
- if (inLLModule.ReayForTMInTime(5) && inLLWaferStatus.inSlot.Count > 0)
- {
- var inLLWafers = _lstWaferTasks.FindAll(wt => wt.currentMod == inLL).OrderBy(wt => _dictModuleTask[wt.destMod].TimeToReady);
- foreach (var inWafer in inLLWafers)
- {
- if (!_dictModuleTask[inWafer.destMod].HasWafer && _dictModuleTask[inWafer.destMod].TimeToReady < 10)
- {
- //LOG.Write(eEvent.INFO_TROUGHPUT_ENHANCE_TRACE, inWafer.destMod, $"{inWafer.destMod} will be ready in {_dictModuleTask[inWafer.destMod].TimeToReady} seconds");
- //LOG.Write(eEvent.INFO_TROUGHPUT_ENHANCE_TRACE, inLL, $"{inLL} will be ready in {inLLModule.TimeToReady} seconds");
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(inLL, inWafer.currentSlot, ModuleName.TMRobot, (int)freeHands[0], freeHands[0]) });
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.TMRobot, (int)freeHands[0], inWafer.destMod, 0, freeHands[0]) });
- return;
- }
- }
- }
- }
- }
- else
- {
- if (freeHands.Count > 0 &&
- outLLWaferStatus.emptySlot.Count == 2 &&
- outLLModule.ReayForTMInTime(10) &&
- _lstWaferTasks.Count(wt => ModuleHelper.IsPm(wt.currentMod) && ModuleHelper.IsLoadPort(wt.destMod)) > 0)
- {
- // try to get one wafer from PM, and match a double place next time
- var readyOutWafer = _lstWaferTasks.Find(wt => ModuleHelper.IsPm(wt.currentMod) && ModuleHelper.IsLoadPort(wt.destMod));
- if (readyOutWafer != null && _dictModuleTask[readyOutWafer.currentMod].TimeToReady < 5)
- {
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(readyOutWafer.currentMod, 0, ModuleName.TMRobot, (int)freeHands[0], freeHands[0]) });
- return;
- }
- }
- if (outLLModule.ReayForTMInTime(5))
- {
- // try match a double place
- if (robotWafers.Count == 2 && robotWafers.All(wt => ModuleHelper.IsLoadPort(wt.destMod)) && outLLWaferStatus.emptySlot.Count == 2)
- {
- var doublePlace = new List<MoveItem>
- {
- new MoveItem(ModuleName.TMRobot, 0, outLL, 0, Hand.Blade1),
- new MoveItem(ModuleName.TMRobot, 1, outLL, 1, Hand.Blade2)
- };
- //LOG.Write(eEvent.INFO_TROUGHPUT_ENHANCE_TRACE, outLL, $"{outLL} will be ready in {outLLModule.TimeToReady} seconds");
- _tmSchdActions.Enqueue(doublePlace);
- return;
- }
- if (outLLWaferStatus.emptySlot.Count > 0)
- {
- //LOG.Write(eEvent.INFO_TROUGHPUT_ENHANCE_TRACE, outLL, $"{outLL} will be ready in {outLLModule.TimeToReady} seconds");
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.TMRobot, robotWafer.currentSlot, outLL, outLLWaferStatus.emptySlot[0], (Hand)robotWafer.currentSlot) });
- return;
- }
- }
- }
- }
- if (freeHands.Count == 0)
- return;
- // try to push one wafer in pm
- if (inLLWaferStatus.inSlot.Count == 1 && inLLModule.ReayForTMInTime(5))
- {
- var inWafer = _lstWaferTasks.Find(wt => wt.currentMod == inLL && wt.currentSlot == inLLWaferStatus.inSlot.First());
- if (inWafer != null && !_dictModuleTask[inWafer.destMod].HasWafer && _dictModuleTask[inWafer.destMod].TimeToReady < 20)
- {
- //LOG.Write(eEvent.INFO_TROUGHPUT_ENHANCE_TRACE, inWafer.destMod, $"{inWafer.destMod} will be ready in {_dictModuleTask[inWafer.destMod].TimeToReady} seconds");
- //LOG.Write(eEvent.INFO_TROUGHPUT_ENHANCE_TRACE, inLL, $"{inLL} will be ready in {inLLModule.TimeToReady} seconds");
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(inLL, inLLWaferStatus.inSlot.First(), ModuleName.TMRobot, (int)freeHands[0], freeHands[0]) });
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.TMRobot, (int)freeHands[0], inWafer.destMod, 0, freeHands[0]) });
- return;
- }
- }
- // try to return one wafer
- if (outLLModule.ReayForTMInTime(15) && outLLWaferStatus.emptySlot.Count > 0)
- {
- var readyReturnPMs = _dictModuleTask.Where(mod => ModuleHelper.IsPm(mod.Key) && mod.Value.HasWafer && mod.Value.TimeToReady < 5).OrderBy(mod => mod.Value.TimeToReady).ToList();
- if (readyReturnPMs.Count > 0)
- {
- //LOG.Write(eEvent.INFO_TROUGHPUT_ENHANCE_TRACE, readyReturnPMs.First().Key, $"{readyReturnPMs.First().Key} will be ready in {readyReturnPMs.First().Value.TimeToReady} seconds");
- //LOG.Write(eEvent.INFO_TROUGHPUT_ENHANCE_TRACE, outLL, $"{outLL} will be ready in {outLLModule.TimeToReady} seconds");
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(readyReturnPMs.First().Key, 0, ModuleName.TMRobot, (int)freeHands[0], freeHands[0]) });
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.TMRobot, (int)freeHands[0], outLL, outLLWaferStatus.emptySlot.First(), freeHands[0]) });
- return;
- }
- }
- }
- }
- else
- {
- if (robotWafers.Count == 2)
- {
- foreach (var wafer in robotWafers)
- {
- if (wafer.movingStatus == RState.End &&
- ModuleHelper.IsPm(wafer.destMod) &&
- _dictModuleTask[wafer.destMod].TimeToReady == 0 &&
- !_lstWaferTasks.Exists(waferT => waferT.currentMod == wafer.destMod) &&
- !_lstWaferTasks.Exists(waferT => waferT.routedMod == wafer.destMod))
- {
- wafer.RouteTo(wafer.destMod, 0);
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.TMRobot, wafer.currentSlot, wafer.destMod, 0, (Hand)wafer.currentSlot) });
- }
- }
- if (_tmSchdActions.Count == 0)
- {
- var swapActions = FindBestLLSwapPlan(ModuleName.System, robotWafers);
- if (swapActions.llPath != ModuleName.System && swapActions.swapActions.Count > 0)
- {
- RoutingTMSwapActions(swapActions.swapActions);
- _tmSchdActions.Enqueue(swapActions.swapActions);
- }
- }
- }
- else if (robotWafers.Count == 1)
- {
- if (ModuleHelper.IsPm(robotWafers[0].destMod) && _dictModuleTask[robotWafers[0].destMod].TimeToReady == 0)
- {
- var pmActions = new List<MoveItem>();
- var pmWafer = _lstWaferTasks.Find(wafer => (wafer.movingStatus == RState.End || wafer.movingStatus == RState.Init) && wafer.currentMod == robotWafers[0].destMod && ModuleHelper.IsLoadPort(wafer.destMod));
- if (pmWafer != null)
- {
- int pickSlot = 1 - robotWafers[0].currentSlot;
- pmWafer.RouteTo(ModuleName.TMRobot, pickSlot);
- pmActions.Add(new MoveItem(pmWafer.currentMod, 0, ModuleName.TMRobot, pickSlot, (Hand)pickSlot));
- if (string.IsNullOrWhiteSpace(pmWafer.wtwCleanRecipe) && !(_dictModuleTask[robotWafers[0].destMod] as PMTask).HasPendingCleanTask)
- {
- pmActions.Add(new MoveItem(ModuleName.TMRobot, robotWafers[0].currentSlot, pmWafer.currentMod, 0, (Hand)robotWafers[0].currentSlot));
- }
- _tmSchdActions.Enqueue(pmActions);
- return;
- }
- if (!_lstWaferTasks.Exists(wafer => wafer.currentMod == robotWafers[0].destMod))
- {
- robotWafers[0].RouteTo(robotWafers[0].destMod, 0);
- pmActions.Add(new MoveItem(ModuleName.TMRobot, robotWafers[0].currentSlot, robotWafers[0].destMod, 0, (Hand)robotWafers[0].currentSlot));
- _tmSchdActions.Enqueue(pmActions);
- return;
- }
- }
- // try to pick a wafer from LL
- if (_tmSchdActions.Count == 0)
- {
- var swapActions = FindBestLLSwapPlan(ModuleName.System, robotWafers);
- if (swapActions.llPath != ModuleName.System && swapActions.swapActions.Count > 0)
- {
- RoutingTMSwapActions(swapActions.swapActions);
- _tmSchdActions.Enqueue(swapActions.swapActions);
- return;
- }
- }
- // try to return a wafer from PM
- var freeHand = GetTMValidFreeHands(robotWafers, new List<MoveItem>());
- var moveActions = FindBestReturnWafersPlan(freeHand.ToArray());
- if (moveActions.pmWafers.Count > 0)
- {
- MoveItem placeAction = moveActions.swapAction.Find(ac => ModuleHelper.IsLoadLock(ac.DestinationModule));
- moveActions.pmWafers.First().RouteTo(placeAction.DestinationModule, placeAction.DestinationSlot);
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(moveActions.pmWafers.First().currentMod, 0, ModuleName.TMRobot, (int)freeHand[0], freeHand[0]) });
- MoveItem pickAction = moveActions.swapAction.Find(ac => ModuleHelper.IsLoadLock(ac.SourceModule));
- if (pickAction != null)
- {
- var pickWafer = _lstWaferTasks.Find(wafer => wafer.currentMod == pickAction.SourceModule && wafer.currentSlot == pickAction.SourceSlot);
- pickWafer.RouteTo(pickAction.DestinationModule, pickAction.DestinationSlot);
- }
- _tmSchdActions.Enqueue(moveActions.swapAction);
- }
- }
- else // robot arm is empty
- {
- // try return wafers from PM
- var freeHand = GetTMValidFreeHands(robotWafers, new List<MoveItem>());
- var moveActions = FindBestReturnWafersPlan(freeHand.ToArray());
- if (moveActions.pmWafers.Count > 0)
- {
- int handIndex = 0;
- var placeActions = moveActions.swapAction.Where(ac => ModuleHelper.IsLoadLock(ac.DestinationModule));
- foreach (var action in placeActions)
- {
- moveActions.pmWafers[handIndex].RouteTo(action.DestinationModule, action.DestinationSlot);
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(moveActions.pmWafers[handIndex].currentMod, 0, ModuleName.TMRobot, (int)freeHand[handIndex], freeHand[handIndex]) });
- handIndex++;
- }
- var pickActions = moveActions.swapAction.Where(ac => ModuleHelper.IsLoadLock(ac.SourceModule)).ToList();
- foreach (var ac in pickActions)
- {
- var llWafer = _lstWaferTasks.Find(wafer => wafer.currentMod == ac.SourceModule && wafer.currentSlot == ac.SourceSlot);
- llWafer.RouteTo(ac.DestinationModule, ac.DestinationSlot);
- }
- _tmSchdActions.Enqueue(moveActions.swapAction);
- }
- if (_tmSchdActions.Count == 0)
- {
- var swapActions = FindBestLLSwapPlan(ModuleName.System, robotWafers);
- if (swapActions.llPath != ModuleName.System && swapActions.swapActions.Count > 0)
- {
- RoutingTMSwapActions(swapActions.swapActions);
- _tmSchdActions.Enqueue(swapActions.swapActions);
- }
- }
- }
- }
- }
- private void Routing4SlotVacSystem()
- {
- var robotWafers = _lstWaferTasks.Where(wafer => (wafer.movingStatus == RState.End || wafer.movingStatus == RState.Init) && ModuleHelper.IsTMRobot(wafer.currentMod)).OrderBy(wafer => TimeForNextModuleReady(wafer)).ToList();
- if (robotWafers.Count == 2)
- {
- foreach (var wafer in robotWafers)
- {
- if (wafer.movingStatus == RState.End &&
- ModuleHelper.IsPm(wafer.destMod) &&
- _dictModuleTask[wafer.destMod].TimeToReady == 0 &&
- !_lstWaferTasks.Exists(waferT => waferT.currentMod == wafer.destMod) &&
- !_lstWaferTasks.Exists(waferT => waferT.routedMod == wafer.destMod))
- {
- wafer.RouteTo(wafer.destMod, 0);
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.TMRobot, wafer.currentSlot, wafer.destMod, 0, (Hand)wafer.currentSlot) });
- }
- }
- if (_tmSchdActions.Count == 0)
- {
- var swapActions = FindBestLLSwapPlan(ModuleName.System, robotWafers);
- if (swapActions.llPath != ModuleName.System && swapActions.swapActions.Count > 0)
- {
- RoutingTMSwapActions(swapActions.swapActions);
- _tmSchdActions.Enqueue(swapActions.swapActions);
- }
- }
- }
- else if (robotWafers.Count == 1)
- {
- if (ModuleHelper.IsPm(robotWafers[0].destMod) && _dictModuleTask[robotWafers[0].destMod].TimeToReady == 0)
- {
- var pmActions = new List<MoveItem>();
- var pmWafer = _lstWaferTasks.Find(wafer => (wafer.movingStatus == RState.End || wafer.movingStatus == RState.Init) && wafer.currentMod == robotWafers[0].destMod && ModuleHelper.IsLoadPort(wafer.destMod));
- if (pmWafer != null && string.IsNullOrWhiteSpace(pmWafer.wtwCleanRecipe))
- {
- int pickSlot = 1 - robotWafers[0].currentSlot;
- pmWafer.RouteTo(ModuleName.TMRobot, pickSlot);
- pmActions.Add(new MoveItem(pmWafer.currentMod, 0, ModuleName.TMRobot, pickSlot, (Hand)pickSlot));
- pmActions.Add(new MoveItem(ModuleName.TMRobot, robotWafers[0].currentSlot, pmWafer.currentMod, 0, (Hand)robotWafers[0].currentSlot));
- _tmSchdActions.Enqueue(pmActions);
- return;
- }
- if (!_lstWaferTasks.Exists(wafer => wafer.currentMod == robotWafers[0].destMod))
- {
- robotWafers[0].RouteTo(robotWafers[0].destMod, 0);
- pmActions.Add(new MoveItem(ModuleName.TMRobot, robotWafers[0].currentSlot, robotWafers[0].destMod, 0, (Hand)robotWafers[0].currentSlot));
- _tmSchdActions.Enqueue(pmActions);
- return;
- }
- }
- // try to pick a wafer from LL
- if (_tmSchdActions.Count == 0)
- {
- var swapActions = FindBestLLSwapPlan(ModuleName.System, robotWafers);
- if (swapActions.llPath != ModuleName.System && swapActions.swapActions.Count > 0)
- {
- RoutingTMSwapActions(swapActions.swapActions);
- _tmSchdActions.Enqueue(swapActions.swapActions);
- return;
- }
- }
- // try to return a wafer from PM
- var freeHand = GetTMValidFreeHands(robotWafers, new List<MoveItem>());
- var moveActions = FindBestReturnWafersPlan(freeHand.ToArray());
- if (moveActions.pmWafers.Count > 0)
- {
- MoveItem placeAction = moveActions.swapAction.Find(ac => ModuleHelper.IsLoadLock(ac.DestinationModule));
- moveActions.pmWafers.First().RouteTo(placeAction.DestinationModule, placeAction.DestinationSlot);
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(moveActions.pmWafers.First().currentMod, 0, ModuleName.TMRobot, (int)freeHand[0], freeHand[0]) });
- MoveItem pickAction = moveActions.swapAction.Find(ac => ModuleHelper.IsLoadLock(ac.SourceModule));
- if (pickAction != null)
- {
- var pickWafer = _lstWaferTasks.Find(wafer => wafer.currentMod == pickAction.SourceModule && wafer.currentSlot == pickAction.SourceSlot);
- pickWafer.RouteTo(pickAction.DestinationModule, pickAction.DestinationSlot);
- }
- _tmSchdActions.Enqueue(moveActions.swapAction);
- }
- }
- else // robot arm is empty
- {
- // try return wafers from PM
- var freeHand = GetTMValidFreeHands(robotWafers, new List<MoveItem>());
- var moveActions = FindBestReturnWafersPlan(freeHand.ToArray());
- if (moveActions.pmWafers.Count > 0)
- {
- int handIndex = 0;
- var placeActions = moveActions.swapAction.Where(ac => ModuleHelper.IsLoadLock(ac.DestinationModule));
- foreach (var action in placeActions)
- {
- moveActions.pmWafers[handIndex].RouteTo(action.DestinationModule, action.DestinationSlot);
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(moveActions.pmWafers[handIndex].currentMod, 0, ModuleName.TMRobot, (int)freeHand[handIndex], freeHand[handIndex]) });
- handIndex++;
- }
- var pickActions = moveActions.swapAction.Where(ac => ModuleHelper.IsLoadLock(ac.SourceModule)).ToList();
- foreach (var ac in pickActions)
- {
- var llWafer = _lstWaferTasks.Find(wafer => wafer.currentMod == ac.SourceModule && wafer.currentSlot == ac.SourceSlot);
- llWafer.RouteTo(ac.DestinationModule, ac.DestinationSlot);
- }
- _tmSchdActions.Enqueue(moveActions.swapAction);
- }
- if (_tmSchdActions.Count == 0)
- {
- var swapActions = FindBestLLSwapPlan(ModuleName.System, robotWafers);
- if (swapActions.llPath != ModuleName.System && swapActions.swapActions.Count > 0)
- {
- RoutingTMSwapActions(swapActions.swapActions);
- _tmSchdActions.Enqueue(swapActions.swapActions);
- }
- }
- }
- }
- private void RoutingFixedSlotVacSystem()
- {
- var robotWafers = _lstWaferTasks.Where(wt => ModuleHelper.IsTMRobot(wt.currentMod));
- var lls = _dictModuleTask.Where(mod => ModuleHelper.IsLoadLock(mod.Key) && mod.Value.Scheduler.IsOnline);
- if (_LLASlotNumber == 2)
- {
- if (robotWafers.Count() == 1)
- {
- if (ModuleHelper.IsPm(robotWafers.First().destMod))
- {
- var destPM = robotWafers.First().destMod;
- if (_dictModuleTask[destPM].TimeToReady <= 5)
- {
- if (_lstWaferTasks.Exists(wt => wt.currentMod == destPM))
- {
- var pickHand = SelectTMPickArm(destPM);
- if (pickHand != Hand.None)
- {
- var pmSwap = new List<MoveItem>
- {
- new MoveItem(destPM, 0, ModuleName.TMRobot, (int)pickHand, pickHand),
- new MoveItem(ModuleName.TMRobot, robotWafers.First().currentSlot, destPM, 0, (Hand)robotWafers.First().currentSlot)
- };
- _tmSchdActions.Enqueue(pmSwap);
- return;
- }
- }
- else
- {
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.TMRobot, robotWafers.First().currentSlot, destPM, 0, (Hand)robotWafers.First().currentSlot) });
- return;
- }
- }
- }
- else
- {
- var readySwapLL = lls.Where(ll => CanWaferGotoLL(robotWafers.First(), ll.Key) &&
- GetLLFixedReadyInOutSlots(ll.Key).tOutSlot.Count == 1 &&
- GetLLFixedReadyInOutSlots(ll.Key).tInSlot.Count == 1 &&
- ll.Value.TimeToReady <= 10);
- if (readySwapLL.Count() > 0)
- {
- var destLL = readySwapLL.First().Key;
- Hand pickHand = SelectTMPickArm(destLL);
- if (pickHand != Hand.None)
- {
- Hand placeHand = (Hand)robotWafers.First().currentSlot;
- var llSwap = new List<MoveItem>();
- var llSlots = GetLLFixedReadyInOutSlots(destLL);
- llSwap.Add(new MoveItem(destLL, llSlots.tOutSlot.First(), ModuleName.TMRobot, (int)pickHand, pickHand));
- llSwap.Add(new MoveItem(ModuleName.TMRobot, (int)placeHand, destLL, llSlots.tInSlot.First(), placeHand));
- _tmSchdActions.Enqueue(llSwap);
- return;
- }
- }
- var emptyLL = lls.Where(ll => CanWaferGotoLL(robotWafers.First(), ll.Key) &&
- GetLLFixedReadyInOutSlots(ll.Key).tInSlot.Count == 1 &&
- ll.Value.TimeToReady <= 2);
- if (emptyLL.Count() > 0)
- {
- var destLL = emptyLL.First().Key;
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem( ModuleName.TMRobot,
- robotWafers.First().currentSlot,
- destLL,
- GetLLFixedReadyInOutSlots(destLL).tInSlot.First(),
- (Hand)robotWafers.First().currentSlot) });
- return;
- }
- }
- // try to return a wafer
- var readyReturnWafers = _lstWaferTasks.Where(wt => ModuleHelper.IsPm(wt.currentMod) && ModuleHelper.IsLoadPort(wt.destMod) && _dictModuleTask[wt.currentMod].TimeToReady <= 2);
- foreach (var pmWafer in readyReturnWafers)
- {
- var readyLL = lls.Where(ll => CanWaferGotoLL(pmWafer, ll.Key) && GetLLFixedReadyInOutSlots(ll.Key).tInSlot.Count > 0 && ll.Value.TimeToReady <= 2).OrderBy(ll => ll.Value.Scheduler.IsVac ? 0 : 1);
- if (readyLL.Count() > 0)
- {
- var validHand = (Hand)(1 - robotWafers.First().currentSlot);
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(pmWafer.currentMod, 0, ModuleName.TMRobot, (int)validHand, validHand) });
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.TMRobot, (int)validHand, readyLL.First().Key, GetLLFixedReadyInOutSlots(readyLL.First().Key).tInSlot.First(), validHand) });
- return;
- }
- }
- // try to push in a wafer
- var readyInLL = lls.Where(ll => GetLLFixedReadyInOutSlots(ll.Key).tOutSlot.Count > 0 && ll.Value.TimeToReady <= 2).OrderBy(ll => ll.Value.Scheduler.IsVac ? 0 : 1);
- foreach (var ll in readyInLL)
- {
- var waferStatus = GetLLFixedReadyInOutSlots(ll.Key);
- var wafer = _lstWaferTasks.Find(wt => wt.currentMod == ll.Key && wt.currentSlot == waferStatus.tOutSlot.First());
- if (wafer != null &&
- ModuleHelper.IsPm(wafer.destMod) &&
- !_lstWaferTasks.Exists(wt => wt.currentMod == wafer.destMod) &&
- _dictModuleTask[wafer.destMod].TimeToReady <= 2)
- {
- var validHand = (Hand)(1 - robotWafers.First().currentSlot);
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(wafer.currentMod, wafer.currentSlot, ModuleName.TMRobot, (int)validHand, validHand) });
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.TMRobot, (int)validHand, wafer.destMod, 0, validHand) });
- return;
- }
- }
- }
- else if (robotWafers.Count() == 0)
- {
- var readyReturnWafers = _lstWaferTasks.Where(wt => ModuleHelper.IsPm(wt.currentMod) && ModuleHelper.IsLoadPort(wt.destMod)).ToList();
- if (readyReturnWafers.Count > 0)
- {
- // try to do a LL swap action
- var readySwapLL = lls.Where(ll => GetLLFixedReadyInOutSlots(ll.Key).tOutSlot.Count == 1 && GetLLFixedReadyInOutSlots(ll.Key).tInSlot.Count == 1 && ll.Value.TimeToReady <= 10);
- foreach (var pmWafer in readyReturnWafers)
- {
- foreach (var ll in readySwapLL)
- {
- if (CanWaferGotoLL(pmWafer, ll.Key))
- {
- var returnHand = SelectTMPickArm(pmWafer.currentMod);
- var pickHand = SelectTMPickArm(ll.Key);
- var llWaferStatus = GetLLFixedReadyInOutSlots(ll.Key);
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(pmWafer.currentMod, pmWafer.currentSlot, ModuleName.TMRobot, (int)returnHand, returnHand) });
- var llSwapActions = new List<MoveItem>();
- llSwapActions.Add(new MoveItem(ModuleName.TMRobot, (int)returnHand, ll.Key, llWaferStatus.tInSlot.First(), returnHand));
- llSwapActions.Add(new MoveItem(ll.Key, llWaferStatus.tOutSlot.First(), ModuleName.TMRobot, (int)pickHand, pickHand));
- _tmSchdActions.Enqueue(llSwapActions);
- return;
- }
- }
- }
- // just return to LL
- var readyInLL = lls.Where(ll => GetLLFixedReadyInOutSlots(ll.Key).tInSlot.Count == 1 && ll.Value.TimeToReady <= 5);
- foreach (var pmWafer in readyReturnWafers)
- {
- foreach (var ll in readyInLL)
- {
- if (CanWaferGotoLL(pmWafer, ll.Key))
- {
- var returnHand = SelectTMPickArm(pmWafer.currentMod);
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(pmWafer.currentMod, pmWafer.currentSlot, ModuleName.TMRobot, (int)returnHand, returnHand) });
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.TMRobot, (int)returnHand, ll.Key, GetLLFixedReadyInOutSlots(ll.Key).tInSlot.First(), returnHand) });
- return;
- }
- }
- }
- }
- var readyPushInLLs = lls.Where(ll => GetLLFixedReadyInOutSlots(ll.Key).tOutSlot.Count == 1 && ll.Value.TimeToReady <= 2);
- if (readyPushInLLs.Count() > 0)
- {
- var destLL = readyPushInLLs.First().Key;
- if (readyPushInLLs.Count() == 2 && readyPushInLLs.First().Value.Scheduler.IsAtm && readyPushInLLs.Last().Value.Scheduler.IsVac)
- {
- destLL = readyPushInLLs.Last().Key;
- }
- var pickHand = SelectTMPickArm(destLL);
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(destLL, GetLLFixedReadyInOutSlots(destLL).tOutSlot.First(), ModuleName.TMRobot, (int)pickHand, pickHand) });
- return;
- }
- }
- else
- {
- // should not go here
- LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, "Had better avoid picking two wafers on TM robot arms under Loadlock fixed slot pattern");
- foreach (var wafer in robotWafers)
- {
- if (ModuleHelper.IsPm(wafer.destMod))
- {
- if (!_lstWaferTasks.Exists(wt => wt.currentMod == wafer.destMod) && _dictModuleTask[wafer.destMod].TimeToReady <= 2)
- {
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.TMRobot, wafer.currentSlot, wafer.destMod, 0, (Hand)wafer.currentSlot) });
- return;
- }
- }
- else
- {
- var readyInLL = lls.Where(ll => GetLLFixedReadyInOutSlots(ll.Key).tInSlot.Count == 1 && CanWaferGotoLL(wafer, ll.Key) && ll.Value.TimeToReady <= 2);
- if (readyInLL.Count() > 0)
- {
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.TMRobot, wafer.currentSlot, readyInLL.First().Key, GetLLFixedReadyInOutSlots(readyInLL.First().Key).tInSlot.First(), (Hand)wafer.currentSlot) });
- return;
- }
- }
- }
- }
- }
- else // 4 slot Loadlock
- {
- if (robotWafers.Count() > 0)
- {
- if (robotWafers.Count() == 2)
- {
- if (robotWafers.All(wt => ModuleHelper.IsLoadPort(wt.destMod)))
- {
- var destLL = lls.Where(ll => robotWafers.All(wt => CanWaferGotoLL(wt, ll.Key)) &&
- ll.Value.TimeToReady <= 10 &&
- GetLLFixedReadyInOutSlots(ll.Key).tInSlot.Count == 2).
- OrderByDescending(ll => GetLLFixedReadyInOutSlots(ll.Key).tOutSlot.Count).
- OrderBy(ll => ll.Value.TimeToReady);
- if (destLL.Count() > 0)
- {
- var swapLL = destLL.First().Key;
- var llWaferStatus = GetLLFixedReadyInOutSlots(swapLL);
- var swapActions = new List<MoveItem>();
- swapActions.Add(new MoveItem(ModuleName.TMRobot, robotWafers.First().currentSlot, swapLL, llWaferStatus.tInSlot.First(), (Hand)robotWafers.First().currentSlot));
- swapActions.Add(new MoveItem(ModuleName.TMRobot, robotWafers.Last().currentSlot, swapLL, llWaferStatus.tInSlot.Last(), (Hand)robotWafers.Last().currentSlot));
- int pickCount = 0;
- foreach (var slot in llWaferStatus.eOutSlot)
- {
- swapActions.Add(new MoveItem(swapLL, slot, ModuleName.TMRobot, pickCount, (Hand)pickCount));
- }
- _tmSchdActions.Enqueue(swapActions);
- return;
- }
- }
- foreach (var wafer in robotWafers)
- {
- if (ModuleHelper.IsPm(wafer.destMod))
- {
- if (!_lstWaferTasks.Exists(wt => wt.currentMod == wafer.destMod) && _dictModuleTask[wafer.destMod].TimeToReady <= 5)
- {
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.TMRobot, wafer.currentSlot, wafer.destMod, 0, (Hand)wafer.currentSlot) });
- return;
- }
- }
- else
- {
- var placeLL = lls.Where(ll => CanWaferGotoLL(wafer, ll.Key) && ll.Value.TimeToReady <= 5 && GetLLFixedReadyInOutSlots(ll.Key).tInSlot.Count > 0).OrderBy(ll => ll.Value.TimeToReady);
- if (placeLL.Count() > 0)
- {
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.TMRobot, wafer.currentSlot, placeLL.First().Key, GetLLFixedReadyInOutSlots(placeLL.First().Key).tInSlot.First(), (Hand)wafer.currentSlot) });
- return;
- }
- }
- }
- }
- else if (robotWafers.Count() == 1)
- {
- var robotWafer = robotWafers.First();
- if (ModuleHelper.IsPm(robotWafer.destMod))
- {
- if (_dictModuleTask[robotWafer.destMod].TimeToReady <= 5)
- {
- if (_lstWaferTasks.Exists(wt => wt.currentMod == robotWafer.destMod))
- {
- var pmSwap = new List<MoveItem>();
- pmSwap.Add(new MoveItem(robotWafer.destMod, 0, ModuleName.TMRobot, 1 - robotWafer.currentSlot, (Hand)(1 - robotWafer.currentSlot)));
- pmSwap.Add(new MoveItem(ModuleName.TMRobot, robotWafer.currentSlot, robotWafer.destMod, 0, (Hand)robotWafer.currentSlot));
- _tmSchdActions.Enqueue(pmSwap);
- return;
- }
- else
- {
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.TMRobot, robotWafer.currentSlot, robotWafer.destMod, 0, (Hand)robotWafer.currentSlot) });
- return;
- }
- }
- }
- else
- {
- var destLL = lls.Where(ll => CanWaferGotoLL(robotWafer, ll.Key) &&
- ll.Value.TimeToReady <= 10 &&
- GetLLFixedReadyInOutSlots(ll.Key).tInSlot.Count > 0).
- OrderByDescending(ll => GetLLFixedReadyInOutSlots(ll.Key).tOutSlot.Count).
- OrderBy(ll => ll.Value.TimeToReady);
- if (destLL.Count() > 0)
- {
- var swapLL = destLL.First().Key;
- var llWaferStatus = GetLLFixedReadyInOutSlots(swapLL);
- var llSwap = new List<MoveItem>();
- llSwap.Add(new MoveItem(ModuleName.TMRobot, robotWafer.currentSlot, swapLL, llWaferStatus.tInSlot.First(), (Hand)robotWafer.currentSlot));
- int pickCount = 0;
- foreach (var slot in llWaferStatus.tOutSlot)
- {
- llSwap.Add(new MoveItem(swapLL, slot, ModuleName.TMRobot, pickCount, (Hand)pickCount));
- pickCount++;
- }
- _tmSchdActions.Enqueue(llSwap);
- return;
- }
- }
- // try to return a wafer
- var readyReturnWafers = _lstWaferTasks.Where(wt => ModuleHelper.IsPm(wt.currentMod) && ModuleHelper.IsLoadPort(wt.destMod) && _dictModuleTask[wt.currentMod].TimeToReady <= 2);
- foreach (var pmWafer in readyReturnWafers)
- {
- var readyLL = lls.Where(ll => CanWaferGotoLL(pmWafer, ll.Key) && GetLLFixedReadyInOutSlots(ll.Key).tInSlot.Count > 0 && ll.Value.TimeToReady <= 2).OrderBy(ll => ll.Value.Scheduler.IsVac ? 0 : 1);
- if (readyLL.Count() > 0)
- {
- var validHand = (Hand)(1 - robotWafers.First().currentSlot);
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(pmWafer.currentMod, 0, ModuleName.TMRobot, (int)validHand, validHand) });
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.TMRobot, (int)validHand, readyLL.First().Key, GetLLFixedReadyInOutSlots(readyLL.First().Key).tInSlot.First(), validHand) });
- return;
- }
- }
- // try to push in a wafer
- var readyInLL = lls.Where(ll => GetLLFixedReadyInOutSlots(ll.Key).tOutSlot.Count > 0 && ll.Value.TimeToReady <= 2).OrderBy(ll => ll.Value.Scheduler.IsVac ? 0 : 1);
- foreach (var ll in readyInLL)
- {
- var waferStatus = GetLLFixedReadyInOutSlots(ll.Key);
- var wafer = _lstWaferTasks.Find(wt => wt.currentMod == ll.Key && wt.currentSlot == waferStatus.tOutSlot.First());
- if (wafer != null &&
- ModuleHelper.IsPm(wafer.destMod) &&
- !_lstWaferTasks.Exists(wt => wt.currentMod == wafer.destMod) &&
- _dictModuleTask[wafer.destMod].TimeToReady <= 2)
- {
- var validHand = (Hand)(1 - robotWafers.First().currentSlot);
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(wafer.currentMod, wafer.currentSlot, ModuleName.TMRobot, (int)validHand, validHand) });
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.TMRobot, (int)validHand, wafer.destMod, 0, validHand) });
- return;
- }
- }
- }
- }
- else // robot empty
- {
- var nearlyReadyReturnWafers = _lstWaferTasks.Where(wt => ModuleHelper.IsPm(wt.currentMod) && (ModuleHelper.IsLoadPort(wt.destMod) || _dictModuleTask[wt.currentMod].TimeToReady <= 10)).OrderBy(wt => _dictModuleTask[wt.currentMod].TimeToReady).ToList();
- var readyLL = lls.Where(ll => ll.Value.TimeToReady <= 10);
- if (readyLL.Count() > 0)
- {
- var llPath = FindTheBestMovePathWithFixSlot(readyLL, nearlyReadyReturnWafers);
- if (ModuleHelper.IsLoadLock(llPath))
- {
- int returnCount = 0;
- var llWaferStatus = GetLLFixedReadyInOutSlots(llPath);
- var llSwapActions = new List<MoveItem>();
- foreach (var wafer in nearlyReadyReturnWafers)
- {
- if (CanWaferGotoLL(wafer, llPath) && returnCount < Math.Min(llWaferStatus.tInSlot.Count, 2))
- {
- _tmSchdActions.Enqueue(new List<MoveItem> { new MoveItem(wafer.currentMod, 0, ModuleName.TMRobot, returnCount, (Hand)returnCount) });
- llSwapActions.Add(new MoveItem(ModuleName.TMRobot, returnCount, llPath, llWaferStatus.tInSlot[returnCount], (Hand)returnCount));
- returnCount++;
- }
- }
- int pickCount = 0;
- foreach (var slot in llWaferStatus.tOutSlot)
- {
- if (pickCount < 2)
- {
- llSwapActions.Add(new MoveItem(llPath, slot, ModuleName.TMRobot, pickCount, (Hand)pickCount));
- pickCount++;
- }
- }
- if (llSwapActions.Count > 0)
- {
- _tmSchdActions.Enqueue(llSwapActions);
- }
- return;
- }
- }
- }
- }
- }
- private bool IsTMRobotArmNotReserved(Hand hand)
- {
- if (WaferManager.Instance.CheckHasWafer(ModuleName.TMRobot, (int)hand) || _lstWaferTasks.Exists(wt => wt.currentMod == ModuleName.TMRobot && wt.currentSlot == (int)hand))
- return false;
- foreach (var acs in _tmSchdActions)
- {
- foreach (var ac in acs)
- {
- if ((ac.DestinationModule == ModuleName.TMRobot || ac.SourceModule == ModuleName.TMRobot) && ac.DestinationSlot == (int)hand)
- return false;
- }
- }
- return true;
- }
- private Hand SelectTMPickArm(ModuleName mod)
- {
- switch (_tmRobotSingleArmOption)
- {
- case 0:
- {
- if (IsTMRobotArmNotReserved(Hand.Blade1))
- return Hand.Blade1;
- if (IsTMRobotArmNotReserved(Hand.Blade2))
- return Hand.Blade2;
- }
- break;
- case 1:
- {
- if (IsTMRobotArmNotReserved(Hand.Blade1))
- return Hand.Blade1;
- }
- break;
- case 2:
- {
- if (IsTMRobotArmNotReserved(Hand.Blade2))
- return Hand.Blade2;
- }
- break;
- // Blade1 In Blade2 Out
- case 3:
- {
- if (ModuleHelper.IsLoadLock(mod) && IsTMRobotArmNotReserved(Hand.Blade1))
- return Hand.Blade1;
- if (ModuleHelper.IsPm(mod) && IsTMRobotArmNotReserved(Hand.Blade2))
- return Hand.Blade2;
- }
- break;
- // Blade2 In Blade1 Out
- case 4:
- {
- if (ModuleHelper.IsLoadLock(mod) && IsTMRobotArmNotReserved(Hand.Blade2))
- return Hand.Blade2;
- if (ModuleHelper.IsPm(mod) && IsTMRobotArmNotReserved(Hand.Blade1))
- return Hand.Blade1;
- }
- break;
- }
- return Hand.None;
- }
- private List<Hand> GetTMFreeHand()
- {
- var lstHands = new List<Hand>();
- if (WaferManager.Instance.CheckNoWafer(ModuleName.TMRobot, 0) && _tmRobotSingleArmOption != 2)
- lstHands.Add(Hand.Blade1);
- if (WaferManager.Instance.CheckNoWafer(ModuleName.TMRobot, 1) && _tmRobotSingleArmOption != 1)
- lstHands.Add(Hand.Blade2);
- return lstHands;
- }
- private List<Hand> GetEFEMFreeHand()
- {
- var lstHands = new List<Hand>();
- if (WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, 0) && _efemRobotSingleArmOption != 2)
- lstHands.Add(Hand.Blade1);
- if (WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, 1) && _efemRobotSingleArmOption != 1)
- lstHands.Add(Hand.Blade2);
- return lstHands;
- }
- private bool CanWaferGotoLL(WaferTask task, ModuleName ll)
- {
- bool bVacWafer = ModuleHelper.IsPm(task.currentMod) || ModuleHelper.IsTMRobot(task.currentMod);
- if (bVacWafer)
- {
- if (ModuleHelper.IsPm(task.destMod))
- return false;
- switch (task.llInOutPath)
- {
- case SequenceLLInOutPath.AInAOut:
- case SequenceLLInOutPath.BInAOut:
- return ll == ModuleName.LLA;
- case SequenceLLInOutPath.AInBOut:
- case SequenceLLInOutPath.BInBOut:
- return ll == ModuleName.LLB;
- case SequenceLLInOutPath.DInDOut:
- return true;
- }
- }
- else
- {
- if (ModuleHelper.IsLoadPort(task.destMod))
- return false;
- switch (task.llInOutPath)
- {
- case SequenceLLInOutPath.AInAOut:
- case SequenceLLInOutPath.AInBOut:
- return ll == ModuleName.LLA;
- case SequenceLLInOutPath.BInAOut:
- case SequenceLLInOutPath.BInBOut:
- return ll == ModuleName.LLB;
- case SequenceLLInOutPath.DInDOut:
- return true;
- }
- }
- return false;
- }
- private (List<int> inSlot, List<int> outSlot, List<int> emptySlot) GetLLReadyInOutSlots(ModuleName ll)
- {
- var readInSlots = new List<int>();
- var readyOutSlots = new List<int>();
- var emptySlots = new List<int>();
- for (int slot = 0; slot < (ll == ModuleName.LLA ? _LLASlotNumber : _LLBSlotNumber); slot++)
- {
- if (WaferManager.Instance.CheckNoWafer(ll, slot) && !_lstWaferTasks.Exists(wafer => (wafer.routedMod == ll && wafer.routedSlot == slot) || (wafer.currentMod == ll && wafer.currentSlot == slot) || (wafer.nextMod == ll && wafer.nextSlot == slot)))
- {
- emptySlots.Add(slot);
- }
- if (WaferManager.Instance.CheckHasWafer(ll, slot))
- {
- Guid waferID = WaferManager.Instance.GetWafer(ll, slot).InnerId;
- var waferTask = _lstWaferTasks.Find(wafer => wafer.waferId == waferID);
- if (waferTask != null && waferTask.movingStatus == RState.End)
- {
- if (ModuleHelper.IsPm(waferTask.destMod))
- readInSlots.Add(slot);
- else if (_dictModuleTask[ll].Scheduler.WaferArrivedTicks(slot) > waferTask.llDelayTime * 1000)
- readyOutSlots.Add(slot);
- }
- }
- }
- return (readInSlots, readyOutSlots, emptySlots);
- }
- private (List<int> eInSlot, List<int> eOutSlot, List<int> tInSlot, List<int> tOutSlot) GetLLFixedReadyInOutSlots(ModuleName ll)
- {
- var eInSlot = new List<int>();
- var eOutSlot = new List<int>();
- var tInSlot = new List<int>();
- var tOutSlot = new List<int>();
- int SlotNumber = ll == ModuleName.LLA ? _LLASlotNumber : _LLBSlotNumber;
- for (int slot = 0; slot < SlotNumber; slot++)
- {
- if (WaferManager.Instance.CheckNoWafer(ll, slot) && !_lstWaferTasks.Exists(wafer => (wafer.routedMod == ll && wafer.routedSlot == slot) || (wafer.currentMod == ll && wafer.currentSlot == slot) || (wafer.nextMod == ll && wafer.nextSlot == slot)))
- {
- if ((slot >= SlotNumber / 2 && _LLSlotInOutOption == LLSlotInOutOpt.UpperInLowerOut) ||
- (slot < SlotNumber / 2 && _LLSlotInOutOption == LLSlotInOutOpt.LowerInUpperOut))
- {
- eInSlot.Add(slot);
- }
- else
- {
- tInSlot.Add(slot);
- }
- }
- if (WaferManager.Instance.CheckHasWafer(ll, slot))
- {
- var wafer = WaferManager.Instance.GetWafer(ll, slot);
- var waferTask = _lstWaferTasks.Find(wt => wt.waferId == wafer.InnerId && wt.currentMod == ll && wt.currentSlot == slot);
- if (waferTask == null)
- {
- LOG.Write(eEvent.EV_ROUTER, ll, $"Routing trace: did not find inner task associated with {wafer.WaferOrigin} at {ll}.{slot + 1}");
- }
- else if (waferTask.movingStatus == RState.End)
- {
- if (ModuleHelper.IsPm(waferTask.destMod))
- tOutSlot.Add(slot);
- else if (_dictModuleTask[ll].Scheduler.WaferArrivedTicks(slot) > waferTask.llDelayTime * 1000)
- eOutSlot.Add(slot);
- }
- }
- }
- return (eInSlot, eOutSlot, tInSlot, tOutSlot);
- }
- private (List<WaferInfo> wafers, List<int> emptySlots) GetLLWaferExistance(ModuleName ll)
- {
- var lstWafers = new List<WaferInfo>();
- var lstEmptySlots = new List<int>();
- for (int slot = 0; slot < (ll == ModuleName.LLA ? _LLASlotNumber : _LLBSlotNumber); slot++)
- {
- var wafer = WaferManager.Instance.GetWafer(ll, slot);
- if (wafer != null && !wafer.IsEmpty)
- {
- lstWafers.Add(wafer);
- }
- else
- {
- lstEmptySlots.Add(slot);
- }
- }
- return (lstWafers, lstEmptySlots);
- }
- private bool NeedPairingForNexWafer()
- {
- if (_lstWaferTasks.Exists(wt => ModuleHelper.IsLoadPort(wt.destMod) && (ModuleHelper.IsPm(wt.currentMod) || ModuleHelper.IsTMRobot(wt.currentMod))))
- return true;
- var processingPMs = _dictModuleTask.Where(mod => ModuleHelper.IsPm(mod.Key) && mod.Value.HasWafer && mod.Value.Scheduler.IsOnline).OrderBy(wt => wt.Value.TimeToReady);
- if (processingPMs.Count() > 0)
- {
- int maxWaitingTime = SC.GetValue<int>("TM.MaxWaitTimePairingOutWafer");
- return processingPMs.First().Value.TimeToReady < maxWaitingTime;
- }
- return false;
- }
- private void PrepareLLPressure()
- {
- if (RouteManager.IsATMMode)
- return;
- var schdPumpingLLs = new List<ModuleName>();
- var schdVentingLLs = new List<ModuleName>();
- var schdCoolingLLs = new List<ModuleName>();
- var llaWaferStatus = GetLLReadyInOutSlots(ModuleName.LLA);
- var llbWaferStatus = GetLLReadyInOutSlots(ModuleName.LLB);
- // pre pumping/venting for schedule actions
- if (_efemSchdActions.Count > 0)
- {
- var ventLLs = _efemSchdActions.Where(acs => ModuleHelper.IsLoadLock(acs.First().Module)).Select(item => item.First().Module).ToList();
- foreach (var ll in ventLLs)
- {
- if (!schdVentingLLs.Contains(ll))
- schdVentingLLs.Add(ll);
- }
- }
- if (_tmSchdActions.Count > 0)
- {
- var pumpLLs = _tmSchdActions.Where(acs => ModuleHelper.IsLoadLock(acs.First().Module)).Select(item => item.First().Module).ToList();
- foreach (var ll in pumpLLs)
- {
- if (!schdPumpingLLs.Contains(ll))
- schdPumpingLLs.Add(ll);
- }
- }
- // loadlock in out path advance check
- if (_LLInOutPath == SequenceLLInOutPath.AInBOut)
- {
- if (llaWaferStatus.emptySlot.Count == _LLASlotNumber)
- {
- if (!schdVentingLLs.Contains(ModuleName.LLA))
- schdVentingLLs.Add(ModuleName.LLA);
- }
- else if ((llaWaferStatus.inSlot.Count == _LLASlotNumber) ||
- (llaWaferStatus.inSlot.Count > 0 && llaWaferStatus.inSlot.Count < _LLASlotNumber && _lstWaferTasks.Count(wt => ModuleHelper.IsLoadPort(wt.currentMod) && ModuleHelper.IsPm(wt.destMod)) == 0))
- {
- if (!schdPumpingLLs.Contains(ModuleName.LLA))
- schdPumpingLLs.Add(ModuleName.LLA);
- }
- if (llbWaferStatus.emptySlot.Count == _LLBSlotNumber)
- {
- if (!schdPumpingLLs.Contains(ModuleName.LLB))
- schdPumpingLLs.Add(ModuleName.LLB);
- }
- else if ((llbWaferStatus.outSlot.Count == _LLBSlotNumber) ||
- (llbWaferStatus.outSlot.Count > 0 && llbWaferStatus.outSlot.Count < _LLBSlotNumber && !NeedPairingForNexWafer()))
- {
- schdCoolingLLs.Add(ModuleName.LLB);
- }
- }
- else if (_LLInOutPath == SequenceLLInOutPath.BInAOut)
- {
- if (llbWaferStatus.emptySlot.Count == _LLBSlotNumber)
- {
- if (!schdVentingLLs.Contains(ModuleName.LLA))
- schdVentingLLs.Add(ModuleName.LLB);
- }
- else if ((llbWaferStatus.inSlot.Count == _LLBSlotNumber) ||
- (llbWaferStatus.inSlot.Count > 0 && llbWaferStatus.inSlot.Count < _LLBSlotNumber && _lstWaferTasks.Count(wt => ModuleHelper.IsLoadPort(wt.currentMod) && ModuleHelper.IsPm(wt.destMod)) == 0))
- {
- if (!schdPumpingLLs.Contains(ModuleName.LLB))
- schdPumpingLLs.Add(ModuleName.LLB);
- }
- if (llaWaferStatus.emptySlot.Count == _LLASlotNumber)
- {
- if (!schdPumpingLLs.Contains(ModuleName.LLA))
- schdPumpingLLs.Add(ModuleName.LLA);
- }
- else if ((llaWaferStatus.outSlot.Count == _LLASlotNumber) ||
- (llaWaferStatus.outSlot.Count > 0 && llaWaferStatus.outSlot.Count < _LLASlotNumber && !NeedPairingForNexWafer()))
- {
- schdCoolingLLs.Add(ModuleName.LLA);
- }
- }
- else
- {
- if ((llaWaferStatus.inSlot.Count == _LLASlotNumber) ||
- (llaWaferStatus.inSlot.Count > 0 && llaWaferStatus.inSlot.Count < _LLASlotNumber && _lstWaferTasks.Count(wt => ModuleHelper.IsLoadPort(wt.currentMod) && ModuleHelper.IsPm(wt.destMod)) == 0))
- {
- if (!schdPumpingLLs.Contains(ModuleName.LLA))
- schdPumpingLLs.Add(ModuleName.LLA);
- }
- else if ((llaWaferStatus.outSlot.Count == _LLASlotNumber) ||
- (llaWaferStatus.outSlot.Count > 0 && llaWaferStatus.outSlot.Count < _LLASlotNumber && !NeedPairingForNexWafer()))
- {
- if (!schdVentingLLs.Contains(ModuleName.LLA))
- schdCoolingLLs.Add(ModuleName.LLA);
- }
- if ((llbWaferStatus.inSlot.Count == _LLBSlotNumber) ||
- (llbWaferStatus.inSlot.Count > 0 && llbWaferStatus.inSlot.Count < _LLBSlotNumber && _lstWaferTasks.Count(wt => ModuleHelper.IsLoadPort(wt.currentMod) && ModuleHelper.IsPm(wt.destMod)) == 0))
- {
- if (!schdPumpingLLs.Contains(ModuleName.LLB))
- schdPumpingLLs.Add(ModuleName.LLB);
- }
- else if ((llbWaferStatus.outSlot.Count == _LLBSlotNumber) ||
- (llbWaferStatus.outSlot.Count > 0 && llbWaferStatus.outSlot.Count < _LLBSlotNumber && !NeedPairingForNexWafer()))
- {
- if (!schdVentingLLs.Contains(ModuleName.LLB))
- schdCoolingLLs.Add(ModuleName.LLB);
- }
- }
- foreach (var ventLL in schdVentingLLs)
- {
- if (_dictModuleTask[ventLL].Scheduler.IsAvailable && !_dictModuleTask[ventLL].Scheduler.IsAtm && !schdCoolingLLs.Contains(ventLL))
- (_dictModuleTask[ventLL] as LoadlockTask).PreVent();
- }
- foreach (var pumpLL in schdPumpingLLs)
- {
- if (_dictModuleTask[pumpLL].Scheduler.IsAvailable && !_dictModuleTask[pumpLL].Scheduler.IsVac && !schdVentingLLs.Contains(pumpLL))
- (_dictModuleTask[pumpLL] as LoadlockTask).PrePump();
- }
- foreach (var coolLL in schdCoolingLLs)
- {
- if (_dictModuleTask[coolLL].Scheduler.IsOnline && !_dictModuleTask[coolLL].Scheduler.IsAtm)
- (_dictModuleTask[coolLL] as LoadlockTask).Cooling();
- }
- }
- private void RunLotCleanTasks()
- {
- foreach (var pm in _dictModuleTask)
- {
- if (!ModuleHelper.IsPm(pm.Key))
- continue;
- var pmTask = pm.Value as PMTask;
- if (pmTask.HasWafer)
- {
- var pmWafer = _lstWaferTasks.Find(wt => wt.currentMod == pm.Key);
- if (pmWafer != null && IsProcessJobEnding(pmWafer.lotId, pm.Key) && !_postLotCleanMarks[pm.Key].Contains(pmWafer.lotId))
- {
- var pj = _lstProcessJobs.Find(process => process.InnerId == pmWafer.lotId);
- if (pj != null)
- {
- var postClean = pj.Sequence.GetPostCleanRecipe(pm.Key);
- if (!string.IsNullOrWhiteSpace(postClean))
- {
- pmTask.InvokePostJobClean(postClean);
- _postLotCleanMarks[pm.Key].Add(pmWafer.lotId);
- }
- }
- }
- }
- // pre clean
- var waitInWafer = GetFirstWaitInWafer(pm.Key);
- if (waitInWafer != null && !_preLotCleanMarks[pm.Key].Contains(waitInWafer.lotId))
- {
- var pj = _lstProcessJobs.Find(process => process.InnerId == waitInWafer.lotId);
- if (pj != null)
- {
- var preClean = pj.Sequence.GetPreCleanRecipe(pm.Key);
- if (!string.IsNullOrWhiteSpace(preClean))
- {
- pmTask.InvokePreJobClean(preClean);
- _preLotCleanMarks[pm.Key].Add(waitInWafer.lotId);
- }
- }
- }
- }
- }
- bool IsProcessJobEnding(Guid pjId, ModuleName pm)
- {
- if (!_lstWaferTasks.Exists(wt => wt.lotId == pjId && wt.destMod == pm && !ModuleHelper.IsPm(wt.currentMod)))
- {
- var processJob = _lstProcessJobs.Find(pj => pj.InnerId == pjId);
- if (processJob == null)
- return false;
- foreach (var slot in processJob.SlotWafers)
- {
- if (WaferManager.Instance.CheckHasWafer(slot.Item1, slot.Item2))
- {
- if (WaferManager.Instance.GetWafer(slot.Item1, slot.Item2).NextSequenceStep == 0)
- return false;
- }
- }
- return true;
- }
- return false;
- }
- WaferTask GetFirstWaitInWafer(ModuleName pm)
- {
- int distance(WaferTask wafer)
- {
- if (ModuleHelper.IsTMRobot(wafer.currentMod))
- return 0;
- else if (ModuleHelper.IsLoadLock(wafer.currentMod))
- {
- return (_dictModuleTask[wafer.currentMod] as LoadlockTask).Distance;
- }
- else if (ModuleHelper.IsEFEMRobot(wafer.currentMod))
- {
- if (wafer.IsAligned)
- return 15;
- else
- return 19;
- }
- return 17;
- }
- var waitInWafers = _lstWaferTasks.Where(wt => (wt.destMod == pm) && !ModuleHelper.IsPm(wt.currentMod) && !ModuleHelper.IsLoadPort(wt.currentMod)).OrderBy(wt => distance(wt));
- if (waitInWafers.Count() > 0)
- return waitInWafers.First();
- return null;
- }
- private void ReturnVacWafers()
- {
- if (_tmSchdActions.Count > 0 || _curTmAction.Count > 0)
- {
- RunSchdTMReturnActions();
- return;
- }
- if (_tmRobotStatus != RState.End)
- return;
- var hands = GetTMFreeHand();
- var lls = _dictModuleTask.Where(mod => ModuleHelper.IsLoadLock(mod.Key) && !IsLLReservedByEFEM(mod.Key) && !_qeWaitCoolingLLs.Contains(mod.Key) && mod.Value.Scheduler.IsIdle && mod.Value.Scheduler.IsInclude && GetLLWaferExistance(mod.Key).emptySlots.Count > 0).OrderByDescending(mod => GetLLReadyInOutSlots(mod.Key).emptySlot.Count);
- if (lls.Count() > 0)
- {
- // return robot wafers
- int moveCount = 0;
- var llActions = new List<MoveItem>();
- var emptySlots = GetLLWaferExistance(lls.First().Key).emptySlots;
- for (int arm = 0; arm < 2; arm++)
- {
- var wafer = WaferManager.Instance.GetWafer(ModuleName.TMRobot, arm);
- if (wafer != null && !wafer.IsEmpty && moveCount < emptySlots.Count)
- {
- llActions.Add(new MoveItem(ModuleName.TMRobot, arm, lls.First().Key, emptySlots[moveCount], (Hand)arm));
- moveCount++;
- }
- }
- if (moveCount > 0)
- {
- _tmSchdActions.Enqueue(llActions);
- return;
- }
- // return PM wafers
- var PickActions = new List<MoveItem>();
- var hasWaferPMs = _dictModuleTask.Where(mod => ModuleHelper.IsPm(mod.Key) && mod.Value.Scheduler.IsIdle && mod.Value.Scheduler.IsInclude && WaferManager.Instance.CheckHasWafer(mod.Key, 0));
- foreach (var pm in hasWaferPMs)
- {
- if (moveCount < hands.Count && moveCount < emptySlots.Count)
- {
- PickActions.Add(new MoveItem(pm.Key, 0, ModuleName.TMRobot, (int)hands[moveCount], hands[moveCount]));
- llActions.Add(new MoveItem(ModuleName.TMRobot, (int)hands[moveCount], lls.First().Key, emptySlots[moveCount], hands[moveCount]));
- moveCount++;
- }
- }
- if (moveCount > 0)
- {
- foreach (var ac in PickActions)
- {
- _tmSchdActions.Enqueue(new List<MoveItem> { ac });
- }
- _tmSchdActions.Enqueue(llActions);
- }
- }
- }
- private void ReturnAtmWafers()
- {
- if (_efemSchdActions.Count > 0 || _curEfemAction.Count > 0)
- {
- RunSchdEFEMReturnActions();
- return;
- }
- if (_efemRobotStatus != RState.End)
- return;
- // return Robot Wafer
- for (int i = 0; i < 2; i++)
- {
- var wafer = WaferManager.Instance.GetWafer(ModuleName.EfemRobot, i);
- if (wafer != null && !wafer.IsEmpty)
- {
- _efemSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.EfemRobot, i, (ModuleName)wafer.OriginStation, wafer.OriginSlot, (Hand)i) });
- }
- }
- if (_efemSchdActions.Count > 0)
- return;
- var hands = GetEFEMFreeHand();
- // return Aligner wafer
- var aligner = ModuleHelper.InstalledModules.Where(mod => ModuleHelper.IsAligner(mod)).ToList();
- if (aligner.Count > 0 && WaferManager.Instance.CheckHasWafer(aligner.First(), 0) && hands.Count > 0)
- {
- var wafer = WaferManager.Instance.GetWafer(aligner.First(), 0);
- _efemSchdActions.Enqueue(new List<MoveItem> { new MoveItem(aligner.First(), 0, ModuleName.EfemRobot, (int)hands.First(), hands.First()) });
- _efemSchdActions.Enqueue(new List<MoveItem> { new MoveItem(ModuleName.EfemRobot, (int)hands.First(), (ModuleName)wafer.OriginStation, wafer.OriginSlot, hands.First()) });
- return;
- }
- // return Loadlock wafer
- var lls = _dictModuleTask.Where(mod => ModuleHelper.IsLoadLock(mod.Key) && !IsLLReservedByTM(mod.Key) && !_qeWaitCoolingLLs.Contains(mod.Key) && mod.Value.Scheduler.IsIdle && GetLLWaferExistance(mod.Key).wafers.Count > 0).OrderByDescending(mod => GetLLWaferExistance(mod.Key).wafers.Count);
- if (lls.Count() > 0)
- {
- int returnCount = 0;
- var llActions = new List<MoveItem>();
- var placActions = new List<MoveItem>();
- foreach (var wafer in GetLLWaferExistance(lls.First().Key).wafers)
- {
- if (returnCount < hands.Count)
- {
- llActions.Add(new MoveItem(lls.First().Key, wafer.Slot, ModuleName.EfemRobot, (int)hands[returnCount], hands[returnCount]));
- placActions.Add(new MoveItem(ModuleName.EfemRobot, (int)hands[returnCount], (ModuleName)wafer.OriginStation, wafer.OriginSlot, hands[returnCount]));
- returnCount++;
- }
- }
- if (returnCount > 0)
- {
- _efemSchdActions.Enqueue(llActions);
- foreach (var ac in placActions)
- {
- _efemSchdActions.Enqueue(new List<MoveItem> { ac });
- }
- }
- }
- }
- private void RunSchdEFEMReturnActions()
- {
- var efemRobot = Singleton<TransferModule>.Instance.GetScheduler(ModuleName.EfemRobot) as SchedulerEfemRobot;
- if (efemRobot == null || !efemRobot.IsAvailable)
- return;
- if (_efemSchdActions.Count > 0)
- {
- if (_curEfemAction.Count == 0 || isReturnActionsDone(_curEfemAction))
- {
- var nextActions = _efemSchdActions.First();
- var nextModule = nextActions.First().Module;
- if (ModuleHelper.IsLoadLock(nextModule) && !_dictModuleTask[nextModule].Scheduler.IsIdle)
- return;
- _curEfemAction = _efemSchdActions.Dequeue();
- efemRobot.PostMoveItems(_curEfemAction.ToArray());
- }
- }
- else if (_curEfemAction.Count >= 0 && isReturnActionsDone(_curEfemAction)) // all scheduled actions done
- {
- _curEfemAction.Clear();
- }
- }
- private void RunSchdTMReturnActions()
- {
- var tmRobot = Singleton<TransferModule>.Instance.GetScheduler(ModuleName.TMRobot) as SchedulerTMRobot;
- if (tmRobot == null || !tmRobot.IsAvailable)
- return;
- if (_tmSchdActions.Count > 0)
- {
- if (_curTmAction.Count == 0 || isReturnActionsDone(_curTmAction))
- {
- var nextActions = _tmSchdActions.First();
- var nextModule = nextActions.First().Module;
- if (ModuleHelper.IsLoadLock(nextModule) && !_dictModuleTask[nextModule].Scheduler.IsIdle)
- return;
- var llActions = _curTmAction.Find(ac => ModuleHelper.IsLoadLock(ac.DestinationModule));
- if(llActions != null && !_qeWaitCoolingLLs.Contains(llActions.DestinationModule) && !RouteManager.IsATMMode)
- {
- _qeWaitCoolingLLs.Enqueue(llActions.DestinationModule);
- }
- _curTmAction = _tmSchdActions.Dequeue();
- tmRobot.SendMoveItems(_curTmAction.ToArray());
- }
- }
- else if (_curTmAction.Count >= 0 && isReturnActionsDone(_curTmAction)) // all scheduled actions done
- {
- var llActions = _curTmAction.Find(ac => ModuleHelper.IsLoadLock(ac.DestinationModule));
- if (llActions != null && !_qeWaitCoolingLLs.Contains(llActions.DestinationModule) && !RouteManager.IsATMMode)
- {
- _qeWaitCoolingLLs.Enqueue(llActions.DestinationModule);
- }
- _curTmAction.Clear();
- }
- }
- #endregion
- #region sequence/recipe operation
- private bool CheckSequencePmReady(SequenceInfo seq, out string reason)
- {
- reason = "";
- foreach (var pm in seq.PMs)
- {
- if (ModuleHelper.IsInstalled(pm) && (_dictModuleTask[pm].Scheduler.IsOnline || !Singleton<RouteManager>.Instance.IsAutoMode))
- return true;
- }
- reason = $"Sequence {seq.Name} no valid PM, " + string.Join("|", seq.PMs);
- return false;
- }
- private bool CheckSequenceKepler2200TemperatureReady(SequenceInfo seq)
- {
- for (int i = 0; i < seq.Steps.Count; i++)
- {
- SequenceStepInfo stepInfo = seq.Steps[i];
- foreach (var module in stepInfo.StepModules)
- {
- if (ModuleHelper.IsPm(module))
- {
- string attr = $"{module}Recipe";
- if (stepInfo.StepParameter.ContainsKey(attr)
- && !string.IsNullOrWhiteSpace((string)stepInfo.StepParameter[attr]))
- {
- var recipeName = seq.GetRecipe(module);
- var recipeContent =
- RecipeFileManager.Instance.LoadRecipe($"{module}", recipeName, false, "Process");
- var recipe = Recipe.Load(recipeContent);
- float currentChamberTemperature;
- switch (module)
- {
- case ModuleName.PMA:
- currentChamberTemperature = Singleton<RouteManager>.Instance.PMA.ChamberTemperature;
- break;
- case ModuleName.PMB:
- currentChamberTemperature = Singleton<RouteManager>.Instance.PMB.ChamberTemperature;
- break;
- case ModuleName.PMC:
- currentChamberTemperature = Singleton<RouteManager>.Instance.PMC.ChamberTemperature;
- break;
- case ModuleName.PMD:
- currentChamberTemperature = Singleton<RouteManager>.Instance.PMD.ChamberTemperature;
- break;
- default:
- currentChamberTemperature = 0;
- break;
- }
- if (recipe.Header.Temperature != null && recipe.Header.Temperature != "" && (currentChamberTemperature > Convert.ToSingle(recipe.Header.Temperature) + 10 || currentChamberTemperature < Convert.ToSingle(recipe.Header.Temperature) - 10))
- {
- LOG.Write(eEvent.ERR_ROUTER, ModuleName.System, $"Start job失败,由于{module}腔体温度{currentChamberTemperature}与{recipeName} Recipe温度{recipe.Header.Temperature}不匹配");
- return false;
- }
- }
- }
- }
- }
- return true;
- }
- private bool CheckSequenceRecipeFileValid(SequenceInfo seq, out string reason)
- {
- for (int i = 0; i < seq.Steps.Count; i++)
- {
- SequenceStepInfo stepInfo = seq.Steps[i];
- foreach (var module in stepInfo.StepModules)
- {
- if (ModuleHelper.IsPm(module))
- {
- string attr = $"{module}Recipe";
- if (stepInfo.StepParameter.ContainsKey(attr)
- && !string.IsNullOrWhiteSpace((string)stepInfo.StepParameter[attr]))
- {
- var recipeName = (string)stepInfo.StepParameter[attr];
- if (!string.IsNullOrWhiteSpace(recipeName))
- {
- var recipeContent =
- RecipeFileManager.Instance.LoadRecipe($"{module}", recipeName, false, "Process");
- if (string.IsNullOrWhiteSpace(recipeContent))
- {
- reason = $"Can not find recipe file{recipeName}";
- return false;
- }
- }
- }
- }
- }
- }
- reason = "";
- return true;
- }
- private void UpdateLLInOutPathProperty()
- {
- if (_lstControlJobs.Count == 0)
- return;
- var inOutPaths = new List<SequenceLLInOutPath>();
- foreach (var wt in _lstWaferTasks)
- {
- if (!inOutPaths.Contains(wt.llInOutPath))
- inOutPaths.Add(wt.llInOutPath);
- }
- if (inOutPaths.Count == 1)
- {
- _LLInOutPath = inOutPaths[0];
- }
- else
- _LLInOutPath = SequenceLLInOutPath.DInDOut;
- }
- private bool GetAllJobRecipe(List<string> InUseRecipes, ControlJobInfo cj, SequenceInfo seq)
- {
- for (int i = 0; i < seq.Steps.Count; i++)
- {
- SequenceStepInfo stepInfo = seq.Steps[i];
- foreach (var module in stepInfo.StepModules)
- {
- if (ModuleHelper.IsPm(module))
- {
- string attr = $"{module}Recipe";
- if (stepInfo.StepParameter.ContainsKey(attr)
- && !string.IsNullOrWhiteSpace((string)stepInfo.StepParameter[attr]))
- {
- var recipeName = seq.GetRecipe(module);
- var recipeContent =
- RecipeFileManager.Instance.LoadRecipe($"{module}", recipeName, false, "Process");
- var recipe = Recipe.Load(recipeContent);
- if (recipe.Header.ChuckRecipe != null && recipe.Header.ChuckRecipe != "")
- {
- InUseRecipes.Add($"{module}.ChuckRecipe.{recipe.Header.ChuckRecipe}");
- }
- if (recipe.Header.DechuckRecipe != null && recipe.Header.DechuckRecipe != "")
- {
- InUseRecipes.Add($"{module}.DechuckRecipe.{recipe.Header.DechuckRecipe}");
- }
- InUseRecipes.Add($"{module}.Process.{recipeName}");
- if (cj.PreJobClean != "")
- {
- InUseRecipes.Add($"{module}.Clean.{cj.PreJobClean}");
- }
- if (cj.PostJobClean != "")
- {
- InUseRecipes.Add($"{module}.Clean.{cj.PostJobClean}");
- }
- //if (stepInfo.StepParameter["WTWClean"].ToString() != "")
- //{
- // InUseRecipes.Add($"{module}.Clean.{stepInfo.StepParameter["WTWClean"]}");
- //}
- }
- }
- }
- }
- return true;
- }
- private bool IsSequenceNeedAlign(SequenceInfo sequence)
- {
- // check wether need align
- foreach (var step in sequence.Steps)
- {
- foreach (var mod in step.StepModules)
- {
- if (ModuleHelper.IsAligner(mod))
- return true;
- }
- }
- return false;
- }
- //private bool CheckKepler2200Scrubber()
- //{
- // if (RtInstance.ConfigType != ConfigType.Kepler2200)
- // {
- // return true;
- // }
- // List<ModuleName> modules = new List<ModuleName>();
- // _lstProcessJobs.ForEach(x =>
- // {
- // x.Sequence.PMs.ForEach(m => modules.Add(m));
- // });
- // modules.Distinct().ToList().ForEach(x => _dictModuleTask[x].Scheduler.IsAvailable);
- // //var item = _dictModuleTask.Where(x => ModuleHelper.IsPm(x.Key));
- // //var item1 = _lstProcessJobs[0].Sequence.PMs;
- //}
- #endregion
- }
- }
|