12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- using Aitex.Core.Common;
- using Aitex.Core.RT.DataCenter;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Event;
- using Aitex.Core.RT.Fsm;
- using Aitex.Core.RT.OperationCenter;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.Util;
- using EFEM.RT.Devices;
- using EFEM.RT.Routines;
- using EFEM.RT.Routines.LP;
- using EFEM.RT.Tasks;
- using Aitex.Sorter.Common;
- using EFEMSC;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.SubstrateTrackings;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
- using IEntity = Aitex.Core.RT.Fsm.IEntity;
- using Aitex.Sorter.RT.Module;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase;
- using Aitex.Core.RT.Log;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.BufferStations;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Flipper.FlipperBase;
- using static EFEM.RT.Devices.FlipperEntity;
- namespace EFEM.RT.Modules
- {
- public class RouteManager : Entity, IEntity, IModuleEntity
- {
- public enum MSG
- {
- MultiMoveWafer,
- MoveWafer,
- ReturnWafer,
- SetSpeed,
- HomeUnit,
- ReadID,
- WriteID,
- ReadAndLoad,
- LOAD,
- UNLOAD,
- Pause,
- Resume,
- Stop,
- StartCycle,
- Init,
- HOME,
- RESET,
- ABORT,
- ERROR,
- StartRecipe,
- StopRecipe,
- PauseRecipe,
- ResumeRecipe,
- SetAutoMode,
- SetManualMode,
- //SetLocalMode,
- //SetRemoteMode,
- SetMaintenanceMode,
- MapWafer,
- Pick,
- Place,
- MPNTPick,
- MPNTPlace,
-
- RobotActionDone,
- LoadPortActionDone,
- ChangeCassette
- }
- //routine
- private readonly bool _isInterferencePrevent =
- DeviceDefineManager.Instance.GetValue<bool>("InterferencePrevent") ?? false;
- private IEfemRoutine initRoutine = null;
- private SetSpeedRoutine setspeedRoutine = null;
- private WaferMappingRoutine _waferMapRoutine;
- private LoadFoupRoutine _loadFoupRoutine;
- private PickRoutine _pickRoutine;
- private PickExtendRoutine _pickExtendRoutine;
- private PlaceRoutine _placeRoutine;
- private PlaceExtendRoutine _placeExtendRoutine;
- private SorterCycleManager _cycle = new SorterCycleManager();
- //TrigRobotSafetyToLP1 Locker
- //private static readonly object _robotSafetyToLP1Locker = new object();
- //TrigRobotSafetyToLP2 Locker
- //private static readonly object _robotSafetyToLP2Locker = new object();
- private int LoadPortQuantity = DeviceDefineManager.Instance.GetValue<int>("LoadPortQuantity") ?? 0;
- //private int LoadLockQuantity = DeviceDefineManager.Instance.GetValue<int>("LoadLockQuantity") ?? 0;
- private static readonly bool FlipperIsDisable = SC.ContainsItem("System.FlipperDisable") ? SC.GetValue<bool>("System.FlipperDisable") : true;
- public bool IsTransferMode { get; private set; }
- public bool IsAutoMode { get; private set; }
- public bool IsFFUOk { get; set; }
- public bool IsEMSStop { get; set; }
- public string Name { get; set; }
- public bool IsInit
- {
- get { return fsm.State == (int)RtState.Init; }
- }
- public bool IsIdle
- {
- get { return fsm.State == (int)RtState.Idle; }
- }
-
- public bool IsError
- {
- get { return fsm.State == (int)RtState.Error; }
- }
- public bool IsMaintenanceMode
- {
- get { return fsm.State == (int)RtState.Maintenance; }
- }
- public bool IsCycle
- {
- get { return fsm.State == (int)RtState.Cycle; }
- }
- public bool Initializing
- {
- get { return fsm.State == (int)RtState.Initializing; }
- }
- public bool IsRunning
- {
- get
- {
- return !IsIdle && !IsInit && !IsError && !IsMaintenanceMode;
- }
- }
- public int RTStatus { get { return fsm.State; } }
- private double lastTime = 0;
- private double elapsedTime = 0;
- public double TransferTime
- {
- get
- {
- elapsedTime = 0;
- if (!_timerTransfer.IsIdle())
- {
- elapsedTime = (_timerTransfer.GetElapseTime() / 1000);
- }
- return lastTime + elapsedTime;
- }
- }
- private static LoadPortEntity _lp1 = new LoadPortEntity(ModuleName.LP1.ToString());
- private static LoadPortEntity _lp2 = new LoadPortEntity(ModuleName.LP2.ToString());
- private static LoadPortEntity _lp3 = new LoadPortEntity(ModuleName.LP3.ToString());
- private static LoadPortEntity _lp4 = new LoadPortEntity(ModuleName.LP4.ToString());
- private static LoadPortEntity _lp5 = new LoadPortEntity(ModuleName.LP5.ToString());
- private static LoadPortEntity _lp6 = new LoadPortEntity(ModuleName.LP6.ToString());
- private static LoadPortEntity _lp7 = new LoadPortEntity(ModuleName.LP7.ToString());
- private static LoadPortEntity _lp8 = new LoadPortEntity(ModuleName.LP8.ToString());
- private static LoadPortEntity _lp9 = new LoadPortEntity(ModuleName.LP9.ToString());
- private static LoadPortEntity _lp10 = new LoadPortEntity(ModuleName.LP10.ToString());
- private static FlipperEntity _flp = new FlipperEntity(ModuleName.Flipper);
- private LoadPortEntity[] _loadportEntities =
- {
- _lp1,
- _lp2,
- _lp3,
- _lp4,
- _lp5,
- _lp6,
- _lp7,
- _lp8,
- _lp9,
- _lp10
- };
-
- public bool IsBusy
- {
- get { return !IsInit && !IsError && !IsIdle; }
- }
- public bool IsOnline { get; set; }
- private DeviceTimer _timerTransfer = new DeviceTimer();
- private TransferManager _transferManager = new TransferManager();
- private StaticTransfer _staticTransfer = new StaticTransfer();
- private IMoveManager _mover = null;
- private DualArmMoveManager _dualMover = new DualArmMoveManager();
- private SingleArmMoveManager _singleMover = new SingleArmMoveManager();
-
- private RobotBaseDevice _robot = null;
- public bool ClearEventLogEnable;
- public Result GetTaskState(string task)
- {
- if (_taskState.ContainsKey(task))
- return _taskState[task];
- return Result.DONE;
- }
- public string EFemNum
- {
- get
- { if(SC.ContainsItem("System.EFEMNUM"))
- return SC.GetStringValue("System.EFEMNUM");
- return "001";
- }
- }
- public string DeviceType
- {
- get
- {
- if (SC.ContainsItem("System.DeviceType"))
- return SC.GetStringValue("System.DeviceType").Remove(0, 6);
- return "001";
- }
- }
- Dictionary<string, Result> _taskState = new Dictionary<string, Result>();
- #region Module Insatlled
- public bool IsLP1Disable { get; set; }
- public bool IsLP2Disable { get; set; }
- public bool IsAligner1Disable { get; set; }
- public bool IsAligner2Disable { get; set; }
- public bool IsPMADisable { get; set; }
- public bool IsPMBDisable { get; set; }
- public bool IsBufferDisable { get; set; }
- public bool IsBuffer1Disable { get; set; }
- public bool IsBuffer2Disable { get; set; }
- public bool IsCoolingBuffer1Disable { get; set; }
- public bool IsCoolingBuffer2Disable { get; set; }
- public bool IsFlipperDisable { get; set; }
- #endregion
- #region Flipper
- /// <summary>
- /// Flipper Entity
- /// </summary>
- public FlipperEntity FLPEntity => _flp;
- #endregion
- public RouteManager()
- {
- Name = "System";
- switch(EFemNum)
- {
- case "001":
- {
- DeviceModel.SensorPMASystemInterlock.OnSignalChanged += SensorPMASystemInterlock_OnSignalChanged;
- DeviceModel.SensorPMBSystemInterlock.OnSignalChanged += SensorPMBSystemInterlock_OnSignalChanged;
- DeviceModel.SensorRBNotExtendSIMF1.OnSignalChanged += SensorRBNotExtendSIMF1_OnSignalChanged;
- DeviceModel.SensorRBNotExtendSIMF2.OnSignalChanged += SensorRBNotExtendSIMF2_OnSignalChanged;
- DeviceModel.SensorSMIF1PODOPEN.OnSignalChanged += SensorSMIF1PODOPEN_OnSignalChanged;
- DeviceModel.SensorSMIF2PODOPEN.OnSignalChanged += SensorSMIF2PODOPEN_OnSignalChanged;
- DeviceModel.SensorWaterLeakSW.OnSignalChanged += SensorWaterLeakSW_OnSignalChanged;
- DeviceModel.SensorGratingSensorIN1.OnSignalChanged += SensorGratingSensorIN1_OnSignalChanged;
- }
- break;
- case "002":
- {
- DeviceModel.SensorSMIF1PODOPEN.OnSignalChanged += SensorSMIF1PODOPEN_OnSignalChanged;
- DeviceModel.SensorSMIF2PODOPEN.OnSignalChanged += SensorSMIF2PODOPEN_OnSignalChanged;
- DeviceModel.SensorWaterLeakSW.OnSignalChanged += SensorWaterLeakSW_OnSignalChanged;
- DeviceModel.SensorGratingSensorIN1.OnSignalChanged += SensorGratingSensorIN1_OnSignalChanged;
- }
- break;
- case "003":
- {
- DeviceModel.SensorSMIF1PODOPEN.OnSignalChanged += SensorSMIF1PODOPEN_OnSignalChanged;
- DeviceModel.SensorSMIF2PODOPEN.OnSignalChanged += SensorSMIF2PODOPEN_OnSignalChanged;
- DeviceModel.SensorWaterLeakSW.OnSignalChanged += SensorWaterLeakSW_OnSignalChanged;
- DeviceModel.SensorGratingSensorIN1.OnSignalChanged += SensorGratingSensorIN1_OnSignalChanged;
- }
- break;
- case "004":
- {
- DeviceModel.SensorSMIF1PODOPEN.OnSignalChanged += SensorSMIF1PODOPEN_OnSignalChanged;
- DeviceModel.SensorSMIF2PODOPEN.OnSignalChanged += SensorSMIF2PODOPEN_OnSignalChanged;
- DeviceModel.SensorWaterLeakSW.OnSignalChanged += SensorWaterLeakSW_OnSignalChanged;
- DeviceModel.SensorGratingSensorIN1.OnSignalChanged += SensorGratingSensorIN1_OnSignalChanged;
- }
- break;
- case "005":
- {
- DeviceModel.SensorWaterLeakSW.OnSignalChanged += SensorWaterLeakSW_OnSignalChanged;
- DeviceModel.SensorCDAPressureSW.OnSignalChanged += SensorCDAPressureSW_OnSignalChanged;
- ///DeviceModel.SensorRBNotExtendSIMF1.OnSignalChanged += SensorRBNotExtendSIMF1_OnSignalChanged1;
- }
- break;
- case "006":
- {
- ;
- }
- break;
- default:
- {
- DeviceModel.SensorPMASystemInterlock.OnSignalChanged += SensorPMASystemInterlock_OnSignalChanged;
- DeviceModel.SensorPMBSystemInterlock.OnSignalChanged += SensorPMBSystemInterlock_OnSignalChanged;
- DeviceModel.SensorRBNotExtendSIMF1.OnSignalChanged += SensorRBNotExtendSIMF1_OnSignalChanged;
- DeviceModel.SensorRBNotExtendSIMF2.OnSignalChanged += SensorRBNotExtendSIMF2_OnSignalChanged;
- DeviceModel.SensorSMIF1PODOPEN.OnSignalChanged += SensorSMIF1PODOPEN_OnSignalChanged;
- DeviceModel.SensorSMIF2PODOPEN.OnSignalChanged += SensorSMIF2PODOPEN_OnSignalChanged;
- DeviceModel.SensorWaterLeakSW.OnSignalChanged += SensorWaterLeakSW_OnSignalChanged;
- DeviceModel.SensorGratingSensorIN1.OnSignalChanged += SensorGratingSensorIN1_OnSignalChanged;
- }
- break;
- }
-
- Singleton<EventManager>.Instance.OnAlarmEvent += Instance_OnAlarmEvent;
- InitRouterManager();
- }
-
- private void SensorRBNotExtendSIMF1_OnSignalChanged1(Aitex.Core.RT.Device.Unit.IoSensor arg1, bool arg2)
- {
- if (arg2)
- DeviceModel.TrigSafetytoSMIF1.SetTrigger(true, out _);
- else
- DeviceModel.TrigSafetytoSMIF1.SetTrigger(false, out _);
- }
- private void SensorCDAPressureSW_OnSignalChanged(Aitex.Core.RT.Device.Unit.IoSensor arg1, bool arg2)
- {
- if (arg2)
- DeviceModel.TrigCDAPressureOkToPM.SetTrigger(true,out _);
- else
- DeviceModel.TrigCDAPressureOkToPM.SetTrigger(false, out _);
- }
- private void Instance_OnAlarmEvent(EventItem obj)
- {
- //if (obj.Level == EventLevel.Alarm && !obj.Source.StartsWith("LP"))
- //{
- // if (!obj.Description.Contains("Has c Error.")|| obj.Description.Contains("PLM Error"))
- // {
- // CheckToPostMsg(MSG.ERROR);
- // }
- // //if (fsm.State == (int)RtState.Cycle||fsm.State==(int)RtState.Transfer || fsm.State == (int)RtState.Picking || fsm.State == (int)RtState.Placing)
- // //{
- // // _tazmoRobot.Stop();
- // //}
- //}
- if (obj.Level == EventLevel.Alarm)
- {
- if(!CheckIsLpAlarmInfo(obj))//||!obj.Description.Contains("obj.Source.StartsWith("LP")"))!string.IsNullOrEmpty(obj.Source) &&
- CheckToPostMsg(MSG.ERROR);
- }
- }
- public bool CheckIsLpAlarmInfo(EventItem obj)
- {
- try
- {
- if (string.IsNullOrEmpty(obj.Source))
- {
- if (obj.EventEnum.Equals("UnloadFOUPFailed"))
- return true;
- else if (obj.EventEnum.Equals("LoadFOUPFailed"))
- return true;
- }
- else if (obj.Source.StartsWith("LP"))
- return true;
- else if (obj.Source.Contains("LoadPort"))
- return true;
- }
- catch(Exception ex)
- {
- LOG.Write(ex);
- return false;
- }
- return false;
- }
- private void SensorRBNotExtendSIMF2_OnSignalChanged(Aitex.Core.RT.Device.Unit.IoSensor arg1, bool arg2)
- {
- if (!arg2)
- {
- DeviceModel.TrigRBbusytoSIMF2.SetTrigger(true, out _);
- LOG.Write("SensorRBNotExtendSIMF2 signal change,set TrigRBbusytoSIMF2 signal on.");
- }
- else
- {
- DeviceModel.TrigRBbusytoSIMF2.SetTrigger(false, out _);
- LOG.Write("SensorRBNotExtendSIM2 signal change,set TrigRBbusytoSIMF2 signal off.");
- }
- }
- private void SensorRBNotExtendSIMF1_OnSignalChanged(Aitex.Core.RT.Device.Unit.IoSensor arg1, bool arg2)
- {
- if (!arg2)
- {
- DeviceModel.TrigRBbusytoSIMF1.SetTrigger(true, out _);
- LOG.Write("SensorRBNotExtendSIMF1 signal change,set TrigRBbusytoSIMF1 signal on.");
- }
- else
- {
- DeviceModel.TrigRBbusytoSIMF1.SetTrigger(false, out _);
- LOG.Write("SensorRBNotExtendSIMF1 signal change,set TrigRBbusytoSIMF1 signal off.");
- }
- }
- private void SensorGratingSensorIN1_OnSignalChanged(Aitex.Core.RT.Device.Unit.IoSensor arg1, bool arg2)
- {
- if (!arg2)
- {
- if(fsm.State==(int)RtState.Cycle|| fsm.State == (int)RtState.Transfer
- || fsm.State == (int)RtState.Placing||fsm.State == (int)RtState.Picking)
- DeviceModel.TrigPauseResumetoRobot.SetTrigger(true, out _);
- }
- else
- {
- DeviceModel.TrigPauseResumetoRobot.SetTrigger(false, out _);
- }
- }
- private void SensorWaterLeakSW_OnSignalChanged(Aitex.Core.RT.Device.Unit.IoSensor arg1, bool arg2)
- {
- if (!arg2)
- {
- if (EFemNum != "005")
- {
- if (fsm.State == (int)RtState.Cycle || fsm.State == (int)RtState.Transfer
- || fsm.State == (int)RtState.Placing || fsm.State == (int)RtState.Picking)
- DeviceModel.TrigPauseResumetoRobot.SetTrigger(true, out _);
- }
- else
- {
- DeviceModel.TrigWaterLeakOkToPM.SetTrigger(false, out _);
- }
- }
- else
- {
- if (EFemNum != "005")
- {
- DeviceModel.TrigPauseResumetoRobot.SetTrigger(false, out _);
- }
- else
- {
- DeviceModel.TrigWaterLeakOkToPM.SetTrigger(true, out _);
- }
- }
- }
-
- private void SensorSMIF2PODOPEN_OnSignalChanged(Aitex.Core.RT.Device.Unit.IoSensor arg1, bool arg2)
- {
- if (arg2)
- {
- DeviceModel.TrigSafetytoSMIF2.SetTrigger(true, out _);
- LOG.Write("SensorSMIF2PODOPEN signal change,set TrigSafetytoSMIF2 signal on.");
- }
- else
- {
- DeviceModel.TrigSafetytoSMIF2.SetTrigger(false, out _);
- LOG.Write("SensorSMIF2PODOPEN signal change,set TrigSafetytoSMIF2 signal off.");
- }
- }
-
- private void SensorSMIF1PODOPEN_OnSignalChanged(Aitex.Core.RT.Device.Unit.IoSensor arg1, bool arg2)
- {
- if (arg2)
- {
- DeviceModel.TrigSafetytoSMIF1.SetTrigger(true, out _);
- LOG.Write("SensorSMIF1PODOPEN signal change,set TrigSafetytoSMIF1 signal on.");
- }
- else
- {
- DeviceModel.TrigSafetytoSMIF1.SetTrigger(false, out _);
- LOG.Write("SensorSMIF1PODOPEN signal change,set TrigSafetytoSMIF1 signal off.");
- }
- }
- private void SensorPMBSystemInterlock_OnSignalChanged(Aitex.Core.RT.Device.Unit.IoSensor arg1, bool arg2)
- {
- if (arg2)
- {
- DeviceModel.TrigSafetytoPMB.SetTrigger(true, out _);
- LOG.Write("SensorPMBSystemInterlock signal change,set TrigSafetytoPMB signal on.");
- }
- else
- {
- DeviceModel.TrigSafetytoPMB.SetTrigger(false, out _);
- LOG.Write("SensorPMBSystemInterlock signal change,set TrigSafetytoPMA signal off.");
- }
- }
- private void SensorPMASystemInterlock_OnSignalChanged(Aitex.Core.RT.Device.Unit.IoSensor arg1, bool arg2)
- {
- if (arg2)
- {
- DeviceModel.TrigSafetytoPMA.SetTrigger(true, out _);
- LOG.Write("SensorPMASystemInterlock signal change,set TrigSafetytoPMB signal on.");
- }
- else
- {
- DeviceModel.TrigSafetytoPMA.SetTrigger(false, out _);
- LOG.Write("SensorPMASystemInterlock signal change,set TrigSafetytoPMB signal off.");
- }
- }
- public void InitRouterManager()
- {
- BuildTransitionTable();
- InitModuleInstallment();
- SubscribeDataVariable();
- SubscribeOperation();
- _robot = DEVICE.GetDevice<RobotBaseDevice>(DeviceName.Robot);
- Running = false;
- IsAutoMode = false;
- }
- #region Initialization
- private void BuildTransitionTable()
- {
- fsm = new StateMachine<RouteManager>(Name, (int)RtState.Init, 50);
- //Init sequence
- Transition(RtState.Init, MSG.Init, null, RtState.Idle);
- //Init sequence
- Transition(RtState.Init, MSG.HOME, fStartInit, RtState.Initializing);
- Transition(RtState.Idle, MSG.HOME, fStartInit, RtState.Initializing);
- Transition(RtState.Error, MSG.HOME, fStartInit, RtState.Initializing);
- // EnterExitTransition<RtState, FSM_MSG>(RtState.Initializing, fStartInit, FSM_MSG.NONE, null);
- Transition(RtState.Initializing, FSM_MSG.TIMER, fInit, RtState.Idle);
- Transition(RtState.Initializing, MSG.ERROR, fError, RtState.Error);
- Transition(RtState.Initializing, MSG.ABORT, null, RtState.Init);
- EnterExitTransition<RtState, FSM_MSG>(RtState.Idle, fIdle, FSM_MSG.NONE, null);
- //Reset
- AnyStateTransition(MSG.RESET, fStartReset, RtState.Idle);
- AnyStateTransition(MSG.ERROR, fError, RtState.Error);
- AnyStateTransition((int)FSM_MSG.ALARM, fError, (int)RtState.Error);
- //MaintanceMode
- Transition(RtState.Maintenance, MSG.SetManualMode, null, RtState.Idle);
- AnyStateTransition(MSG.SetMaintenanceMode, fSetMaintenanceMode, RtState.Maintenance);
- //Auto/manual sequence
- Transition(RtState.Idle, MSG.SetAutoMode, fSetAutoMode, RtState.Idle);
- Transition(RtState.Idle, MSG.SetManualMode, fSetManualMode, RtState.Idle);
- //Loadport operation
- Transition(RtState.Idle, MSG.LOAD, fLoad, RtState.Idle);
- Transition(RtState.Idle, MSG.ReadAndLoad, fReadAndLoad, RtState.Idle);
- Transition(RtState.Idle, MSG.UNLOAD, fUnload, RtState.Idle);
- Transition(RtState.Idle, MSG.ReadID, fReadID, RtState.Idle);
- Transition(RtState.Idle, MSG.WriteID, fWriteID, RtState.Idle);
- //SetSpeed
- Transition(RtState.Idle, MSG.SetSpeed, fStartSetSpeed, RtState.SetSpeed);
- Transition(RtState.SetSpeed, FSM_MSG.TIMER, fSetSpeed, RtState.Idle);
- //Wafer Map Routine
- Transition(RtState.Init, MSG.MapWafer, FsmStartMapWafer, RtState.WaferMapping);
- Transition(RtState.Idle, MSG.MapWafer, FsmStartMapWafer, RtState.WaferMapping);
- Transition(RtState.WaferMapping, FSM_MSG.TIMER, FsmMonitorWaferMapping, RtState.Idle);
- Transition(RtState.WaferMapping, MSG.ChangeCassette, FsmChangeCassette, RtState.Error);
- //Transfer sequence
- Transition(RtState.Idle, MSG.MoveWafer, fStartTransfer, RtState.Transfer);
- Transition(RtState.Transfer, FSM_MSG.TIMER, fTransfer, RtState.Idle);
- Transition(RtState.Transfer, MSG.ABORT, fAbortTransfer, RtState.Idle);
- EnterExitTransition<RtState, FSM_MSG>(RtState.Transfer, null, FSM_MSG.NONE, fExitTransfer);
- //Return sequence
- Transition(RtState.Idle, MSG.ReturnWafer, fStartReturn, RtState.Transfer);
- Transition(RtState.Transfer, FSM_MSG.TIMER, fTransfer, RtState.Idle);
- Transition(RtState.Transfer, MSG.ChangeCassette, FsmChangeCassette, RtState.Error);
- //Cycle sequence
- Transition(RtState.Idle, MSG.StartCycle, fStartCycle, RtState.Cycle);
- Transition(RtState.Cycle, FSM_MSG.TIMER, fCycle, RtState.Idle);
- Transition(RtState.Cycle, MSG.Stop, fCycleStop, RtState.Cycle);
- EnterExitTransition<RtState, FSM_MSG>(RtState.Cycle, FsmEnterCycle, FSM_MSG.NONE, FsmExitCycle);
- Transition(RtState.Cycle, MSG.ABORT, fAbortRunProcess, RtState.Idle);
- Transition(RtState.Cycle, MSG.ChangeCassette, FsmChangeCassette, RtState.Error);
- Transition(RtState.Cycle, MSG.RobotActionDone, fCycle, RtState.Cycle);
-
- //robot pick
- Transition(RtState.Idle, MSG.Pick, FsmStartRobotPick, RtState.Picking);
- Transition(RtState.Picking, FSM_MSG.TIMER, FsmMonitorPick, RtState.Idle);
- Transition(RtState.Picking, MSG.ABORT, FsmAbortTask, RtState.Idle);
- Transition(RtState.Picking, MSG.ChangeCassette, FsmChangeCassette, RtState.Error);
- //robot place
- Transition(RtState.Idle, MSG.Place, FsmStartRobotPlace, RtState.Placing);
- Transition(RtState.Placing, FSM_MSG.TIMER, FsmMonitorPlace, RtState.Idle);
- Transition(RtState.Placing, MSG.ABORT, FsmAbortTask, RtState.Idle);
- Transition(RtState.Placing, MSG.ChangeCassette, FsmChangeCassette, RtState.Error);
- //robot mpnt pick
- Transition(RtState.Idle, MSG.MPNTPick, FsmStartRobotMpntPick, RtState.PickingPM);
- Transition(RtState.PickingPM, FSM_MSG.TIMER, FsmMonitorMpntPick, RtState.Idle);
- Transition(RtState.PickingPM, MSG.ABORT, FsmAbortTask, RtState.Idle);
- //robot mpnt place
- Transition(RtState.Idle, MSG.MPNTPlace, FsmStartRobotMpntPlace, RtState.PlacingPM);
- Transition(RtState.PlacingPM, FSM_MSG.TIMER, FsmMonitorMpntPlace, RtState.Idle);
- Transition(RtState.PlacingPM, MSG.ABORT, FsmAbortTask, RtState.Idle);
- }
- void InitModuleInstallment()
- {
- IsBufferDisable = SC.ContainsItem("System.BufferDisable") ? SC.GetValue<bool>("System.BufferDisable") : true;
- IsBuffer1Disable = SC.ContainsItem("System.Buffer1Disable") ? SC.GetValue<bool>("System.Buffer1Disable") : true;
- IsBuffer2Disable = SC.ContainsItem("System.Buffer2Disable") ? SC.GetValue<bool>("System.Buffer2Disable") : true;
- IsAligner1Disable = SC.ContainsItem("System.Aligner1Disable") ? SC.GetValue<bool>("System.Aligner1Disable") : true;
- IsAligner2Disable = SC.ContainsItem("System.Aligner2Disable") ? SC.GetValue<bool>("System.Aligner2Disable") : true;
- IsPMADisable = SC.ContainsItem("System.PMADisable") ? SC.GetValue<bool>("System.PMADisable") : true;
- IsPMBDisable = SC.ContainsItem("System.PMBDisable") ? SC.GetValue<bool>("System.PMBDisable") : true;
- IsCoolingBuffer1Disable = SC.ContainsItem("System.CoolingBuffer1Disable") ? SC.GetValue<bool>("System.CoolingBuffer1Disable") : true;
- IsCoolingBuffer2Disable = SC.ContainsItem("System.CoolingBuffer2Disable") ? SC.GetValue<bool>("System.CoolingBuffer2Disable") : true;
- IsLP1Disable = SC.ContainsItem("LoadPort.LP1.Disable") ? SC.GetValue<bool>("LoadPort.LP1.Disable") : true;
- IsLP2Disable = SC.ContainsItem("LoadPort.LP2.Disable") ? SC.GetValue<bool>("LoadPort.LP2.Disable") : true;
- IsFlipperDisable = SC.ContainsItem("System.FlipperDisable") ? SC.GetValue<bool>("System.FlipperDisable") : true;
- }
- void SubscribeDataVariable()
- {
- //Parameter Register
- DATA.Subscribe(ModuleName.System.ToString(), ParamName.RTStatus, () => fsm.State);
- DATA.Subscribe(ModuleName.System.ToString(), ParamName.SystemIdle, () => IsIdle || IsInit);
- DATA.Subscribe(ModuleName.System.ToString(), ParamName.SystemRunning, () => IsRunning);
- DATA.Subscribe(ModuleName.System.ToString(), ParamName.SystemAlarm, () => IsError);
- DATA.Subscribe(ModuleName.System.ToString(), ParamName.IsProcessPaused, () => _mover != null && _mover.IsPaused);
- DATA.Subscribe(ModuleName.System.ToString(), ParamName.FFUOk, () => IsFFUOk);
- // DATA.Subscribe(ModuleName.System.ToString(), ParamName.TransferCount, () => TransferCount);
- // DATA.Subscribe(ModuleName.System.ToString(), ParamName.TransferTime, () => TransferTime);
- // DATA.Subscribe(ModuleName.System.ToString(), ParamName.TranserThroughput, () => TranserThroughput);
- // DATA.Subscribe(ModuleName.System.ToString(), ParamName.TotalWaferCount, () => SC.GetValue<int>(SorterCommon.ScPathName.System_TotalWaferCount));
- DATA.Subscribe(string.Format("{0}.{1}", ChamberSetString.System, ParamName.AlarmEvent), EV.GetAlarmEvent);
- // DATA.Subscribe(ModuleName.System.ToString(), ParamName.CycleCount, () => CycleCount);
- DATA.Subscribe(ParamName.System.IsAlarm, () => IsError);
- DATA.Subscribe(ParamName.System.IsManualMode, () => !IsAutoMode);
- DATA.Subscribe(ParamName.System.IsAutoMode, () => IsAutoMode);
- DATA.Subscribe(ParamName.System.IsMaintenanceMode, () => IsMaintenanceMode);
- DATA.Subscribe(ParamName.System.IsRunning, () => IsRunning);
- DATA.Subscribe(ParamName.System.IsIdle, () => IsIdle);
- DATA.Subscribe("System.IsNoRunning", () => !IsRunning);
- DATA.Subscribe("System.CoolingBuffer1Disable",()=>SC.GetValue<bool>("System.CoolingBuffer1Disable"));
- DATA.Subscribe("System.CoolingBuffer2Disable", () => SC.GetValue<bool>("System.CoolingBuffer2Disable"));
- DATA.Subscribe("System.Aligner1Disable", () => SC.GetValue<bool>("System.Aligner1Disable"));
- DATA.Subscribe("System.Aligner2Disable", () => SC.GetValue<bool>("System.Aligner2Disable"));
- DATA.Subscribe("LP1.WaferThickness", () => SC.GetStringValue("CarrierInfo.LP1ThicknessType"));
- DATA.Subscribe("LP2.WaferThickness", () => SC.GetStringValue("CarrierInfo.LP2ThicknessType"));
- DATA.Subscribe("Cooling1.WaferThickness", () => SC.GetStringValue("CarrierInfo.CoolingBuffer1ThicknessType"));
- DATA.Subscribe("Cooling2.WaferThickness", () => SC.GetStringValue("CarrierInfo.CoolingBuffer2ThicknessType"));
- DATA.Subscribe("LL1.WaferThickness", () => SC.GetStringValue("CarrierInfo.LL1ThicknessType"));
- DATA.Subscribe("LL2.WaferThickness", () => SC.GetStringValue("CarrierInfo.LL2ThicknessType"));
- DATA.Subscribe("Buffer1.WaferThickness", () => SC.GetStringValue("CarrierInfo.Buffer1ThicknessType"));
- DATA.Subscribe("Buffer2.WaferThickness", () => SC.GetStringValue("CarrierInfo.Buffer2ThicknessType"));
- DATA.Subscribe("Aligner1.WaferThickness", () => SC.GetStringValue("CarrierInfo.Aligner1ThicknessType"));
- DATA.Subscribe("Aligner2.WaferThickness", () => SC.GetStringValue("CarrierInfo.Aligner2ThicknessType"));
- DATA.Subscribe("Upper.WaferThickness", () => SC.GetStringValue("CarrierInfo.UpperThicknessType"));
- DATA.Subscribe("Lower.WaferThickness", () => SC.GetStringValue("CarrierInfo.LowerThicknessType"));
- DATA.Subscribe($"System.IsEnableBufferMap", () => SC.GetValue<bool>("System.IsEnableBufferMap"));
- DATA.Subscribe("System.IsEnableIdentifyThickness", () => SC.GetValue<bool>("System.IsEnableIdentifyThickness"));
- DATA.Subscribe("System.IsEnableMultiWaferSize", () => SC.GetValue<bool>("System.IsEnableMultiWaferSize"));
- DATA.Subscribe("System.IsEnableMultiWaferSizeShow", () => SC.GetValue<bool>("System.IsEnableMultiWaferSizeShow"));
- DATA.Subscribe("System.IsSlotShowOpposite", () => SC.GetValue<bool>("System.IsSlotShowOpposite"));
- DATA.Subscribe("System.ClearEventLogEnable", () => ClearEventLogEnable);
-
- var robot = DEVICE.GetDevice<RobotBaseDevice>(DeviceName.Robot);
- robot.ActionDone += Robot_ActionDone;
- //foreach (var moduleName in Singleton<DeviceManager>.Instance.LpNames)
- //{
- // LoadPort lp = DEVICE.GetDevice<LoadPort>(moduleName.ToString());
- // lp.ActionDone += Lp_ActionDone;
- //}
- DATA.Subscribe("LP1.IsEnable", () => !IsLP1Disable);
- DATA.Subscribe("LP2.IsEnable", () => !IsLP2Disable);
- DATA.Subscribe("Aligner1.IsEnable", () => !IsAligner1Disable);
- DATA.Subscribe("Aligner2.IsEnable", () => !IsAligner2Disable);
- DATA.Subscribe("Buffer.IsEnable", () => !IsBufferDisable);
- DATA.Subscribe("Buffer1.IsEnable", () => !IsBuffer1Disable);
- DATA.Subscribe("Buffer2.IsEnable", () => !IsBuffer2Disable);
- DATA.Subscribe("CoolingBuffer1.IsEnable", () => !IsCoolingBuffer1Disable);
- DATA.Subscribe("CoolingBuffer2.IsEnable", () => !IsCoolingBuffer2Disable);
- DATA.Subscribe("PMA.IsEnable", () => !IsPMADisable);
- DATA.Subscribe("PMB.IsEnable", () => !IsPMBDisable);
- DATA.Subscribe("Flipper.IsEnable", () => !IsFlipperDisable);
- DATA.Subscribe("System.IsPMADoorOpen", () => DeviceModel.SensorPMASystemInterlock.Value);
- DATA.Subscribe("System.IsPMBDoorOpen", () => DeviceModel.SensorPMBSystemInterlock.Value);
- }
- private void Lp_ActionDone(bool obj)
- {
- if (fsm.State == (int)RtState.Cycle)
- {
- EV.PostInfoLog("System", "Notified LoadPort action done");
- CheckToPostMsg(MSG.LoadPortActionDone);
- }
- }
- private void Robot_ActionDone(bool obj)
- {
- if (fsm.State == (int) RtState.Cycle)
- {
- EV.PostInfoLog("System", "Notified robot action done");
- CheckToPostMsg(MSG.RobotActionDone);
- }
- if (obj == false && (fsm.State == (int) RtState.Picking || fsm.State == (int) RtState.Placing))
- {
- CheckToPostMsg(MSG.ERROR);
- }
- }
- void SubscribeOperation()
- {
- OP.Subscribe(OperationName.CreatWafer, InvokeCreateWafer);
- OP.Subscribe(OperationName.DeleteWafer, InvokeDeleteWafer);
- OP.Subscribe(OperationName.ResetRouteManager, InvokeResetRouteManager);
- //OP.Subscribe(OperationName.SetSpeed, InvokeSetSpeed);
- OP.Subscribe(OperationName.HomeUnit, InvokeHomeUnit);
- OP.Subscribe(OperationName.LoadFoup, InvokeLoadFoup);
- OP.Subscribe(OperationName.UnloadFoup, InvokeUnloadFoup);
- OP.Subscribe(OperationName.ReadFoupID, InvokeReadFoupID);
- OP.Subscribe(OperationName.WriteFoupID, InvokeWriteFoupID);
- OP.Subscribe(OperationName.MoveWafer, InvokeMoveWafer);
- OP.Subscribe(OperationName.ReturnWafer, InvokeReturnWafer);
- OP.Subscribe(OperationName.MultiMoveWafer, InvokeMultiMoveWafer);
- OP.Subscribe(OperationName.Stop, InvokeStop);
-
- OP.Subscribe("Benchmark", InvokeBenchmark);
- OP.Subscribe("System.StartCycle", InvokeCycle);
- OP.Subscribe(OperationName.SetAutoMode, InvokeSetAutoMode);
- OP.Subscribe(OperationName.SetManualMode, InvokeSetManualMode);
- OP.Subscribe(OperationName.HomeAll, InvokeHomeAll);
- OP.Subscribe(OperationName.AbortHomeAll, InvokeAbortHomeAll);
- OP.Subscribe(OperationName.SelectRecipe, InvokeSelectRecipe);
- OP.Subscribe(OperationName.StartRecipe, (string cmd, object[] args) =>
- {
- if (args.Length > 1)
- {
- return CheckToPostMsg(MSG.StartRecipe, args[0], args[1]);
- }
- return CheckToPostMsg(MSG.StartRecipe, args[0]);
- });
- OP.Subscribe(OperationName.PauseRecipe, InvokePauseRecipe);
- OP.Subscribe(OperationName.ResumeRecipe, InvokeResumeRecipe);
- OP.Subscribe(OperationName.StopRecipe, InvokeStopRecipe);
- OP.Subscribe("MapWafer", InvokeMapWafer);
- OP.Subscribe(ParamName.System.OPName.Reset, (string cmd, object[] args) =>
- {
- EV.ClearAlarmEvent();
- Singleton<DeviceEntity>.Instance.PostMsg(DeviceEntity.MSG.RESET);
- Singleton<EfemEntity>.Instance.PostMsg(EfemEntity.MSG.Reset);
- return CheckToPostMsg(MSG.RESET);
- });
- OP.Subscribe("System.SetWaferSize3", (string cmd, object[] args) =>
- {
- string module = (string)args[0];
- if (module == "Lower")
- {
- WaferManager.Instance.UpdateWaferSize(ModuleName.Robot, 0, WaferSize.WS3);
- return true;
- }
- if (module == "Upper")
- {
- WaferManager.Instance.UpdateWaferSize(ModuleName.Robot, 1, WaferSize.WS3);
- return true;
- }
- if (ModuleHelper.IsBuffer(ModuleHelper.Converter(module)))
- {
- var buffer = DEVICE.GetDevice<BufferStation>(module);
- if (buffer != null)
- {
- for (int i = 0; i < buffer.ValidSlotsNumber; i++)
- {
- WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), i, WaferSize.WS3);
- }
- }
- SC.SetItemValue($"System.{module}WaferSize", 3);
- return true;
- }
- WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS3);
- //string module = (string) args[0];
- //WaferManager.Instance.CheckWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS3);
- //if (ModuleHelper.Converter(module) == ModuleName.Robot)
- //{
- // WaferManager.Instance.CheckWaferSize(ModuleHelper.Converter(module), 1, WaferSize.WS3);
- //}
- return true;
- });
- OP.Subscribe("System.SetWaferSize4", (string cmd, object[] args) =>
- {
- string module = (string)args[0];
- if (module == "Lower")
- {
- WaferManager.Instance.UpdateWaferSize(ModuleName.Robot, 0, WaferSize.WS4);
- return true;
- }
- if (module == "Upper")
- {
- WaferManager.Instance.UpdateWaferSize(ModuleName.Robot, 1, WaferSize.WS4);
- return true;
- }
- if(ModuleHelper.IsBuffer(ModuleHelper.Converter(module)))
- {
- var buffer = DEVICE.GetDevice<BufferStation>(module);
- if (buffer != null)
- {
- for (int i=0;i<buffer.ValidSlotsNumber;i++)
- {
- WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), i, WaferSize.WS4);
- }
- }
- SC.SetItemValue($"System.{module}WaferSize", 4);
- return true;
- }
- WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS4);
- //WaferManager.Instance.CheckWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS4);
- //if(ModuleHelper.Converter(module) == ModuleName.Robot)
- //{
- // WaferManager.Instance.CheckWaferSize(ModuleHelper.Converter(module), 1, WaferSize.WS4);
- //}
- return true;
- });
- OP.Subscribe("System.SetWaferSize6", (string cmd, object[] args) =>
- {
- string module = (string)args[0];
- if (module == "Lower")
- {
- WaferManager.Instance.UpdateWaferSize(ModuleName.Robot, 0, WaferSize.WS6);
- return true;
- }
- if (module == "Upper")
- {
- WaferManager.Instance.UpdateWaferSize(ModuleName.Robot, 1, WaferSize.WS6);
- return true;
- }
- if (ModuleHelper.IsBuffer(ModuleHelper.Converter(module)))
- {
- var buffer = DEVICE.GetDevice<BufferStation>(module);
- if (buffer != null)
- {
- for (int i = 0; i < buffer.ValidSlotsNumber; i++)
- {
- WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), i, WaferSize.WS6);
- }
- }
- SC.SetItemValue($"System.{module}WaferSize", 6);
- return true;
- }
- WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS6);
- //string module = (string)args[0];
- //WaferManager.Instance.CheckWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS6);
- //if (ModuleHelper.Converter(module) == ModuleName.Robot)
- //{
- // WaferManager.Instance.CheckWaferSize(ModuleHelper.Converter(module), 1, WaferSize.WS6);
- //}
- return true;
- });
- OP.Subscribe("System.SetWaferSize8", (string cmd, object[] args) =>
- {
- string module = (string)args[0];
- if (module == "Lower")
- {
- WaferManager.Instance.UpdateWaferSize(ModuleName.Robot, 0, WaferSize.WS8);
- return true;
- }
- if (module == "Upper")
- {
- WaferManager.Instance.UpdateWaferSize(ModuleName.Robot, 1, WaferSize.WS8);
- return true;
- }
- if (ModuleHelper.IsBuffer(ModuleHelper.Converter(module)))
- {
- var buffer = DEVICE.GetDevice<BufferStation>(module);
- if (buffer != null)
- {
- for (int i = 0; i < buffer.ValidSlotsNumber; i++)
- {
- WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), i, WaferSize.WS8);
- }
- }
- return true;
- SC.SetItemValue($"System.{module}WaferSize", 8);
- }
- WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS8);
- //string module = (string)args[0];
- //WaferManager.Instance.CheckWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS6);
- //if (ModuleHelper.Converter(module) == ModuleName.Robot)
- //{
- // WaferManager.Instance.CheckWaferSize(ModuleHelper.Converter(module), 1, WaferSize.WS6);
- //}
- return true;
- });
- OP.Subscribe("System.SetWaferThick", (string cmd, object[] args) =>
- {
- string module = (string)args[0];
- SC.SetItemValueFromString($"CarrierInfo.{module}ThicknessType", "THICK");
- return true;
- });
- OP.Subscribe("System.SetWaferThin", (string cmd, object[] args) =>
- {
- string module = (string)args[0];
- SC.SetItemValueFromString($"CarrierInfo.{module}ThicknessType", "THIN");
- return true;
- });
- OP.Subscribe("System.SetSlot13", (string cmd, object[] args) =>
- {
- string module = (string)args[0];
- //SC.SetItemValue($"CarrierInfo.Carrier0.CarrierSlotsNumber", 13);
- SC.SetItemValue($"LoadPort.{module}.SlotsNumber", 13);
- return true;
- });
- OP.Subscribe("System.SetSlot25", (string cmd, object[] args) =>
- {
- string module = (string)args[0];
- // SC.SetItemValue($"CarrierInfo.Carrier0.CarrierSlotsNumber", 25);
- SC.SetItemValue($"LoadPort.{module}.SlotsNumber", 25);
- return true;
- });
- OP.Subscribe("System.ClearEventLogEnable", (string cmd, object[] args) =>
- {
- ClearEventLogEnable = false;
- return true;
- });
- }
- private bool InvokeMapWafer(string arg1, object[] arg2)
- {
- return CheckToPostMsg(MSG.MapWafer, arg2[0].ToString());
- }
- private bool InvokeStopRecipe(string arg1, object[] arg2)
- {
- return CheckToPostMsg(MSG.StopRecipe);
- }
- private bool InvokeResumeRecipe(string arg1, object[] arg2)
- {
- //ret = PostMsg<RouteManager, RouteManager.MSG>(RouteManager.MSG.ResumeRecipe, out reason);
- return true;
- }
- private bool InvokePauseRecipe(string arg1, object[] arg2)
- {
- //ret = PostMsg<RouteManager, RouteManager.MSG>(RouteManager.MSG.PauseRecipe, out reason);
- return true;
- }
- private bool InvokeSelectRecipe(string arg1, object[] arg2)
- {
- //JobManager.Instance.SelectRecipe(arg2[0].ToString());
- //ret = true;
- return true;
- }
- private bool InvokeAbortHomeAll(string arg1, object[] arg2)
- {
- return CheckToPostMsg(MSG.ABORT);
- }
- private bool InvokeHomeAll(string arg1, object[] arg2)
- {
- return CheckToPostMsg(MSG.HOME);
- }
- private bool InvokeSetManualMode(string arg1, object[] arg2)
- {
- return CheckToPostMsg(MSG.SetManualMode);
- }
- private bool InvokeSetAutoMode(string arg1, object[] arg2)
- {
- if (!CheckEnableAuto())
- {
- return false;
- }
- return CheckToPostMsg(MSG.SetAutoMode); ;
- }
- private bool InvokeCycle(string arg1, object[] arg2)
- {
- string reason;
- if (!checkCycle(out reason))
- {
- EV.PostWarningLog("System", $"Can not start cycle, {reason}");
- return false;
- }
- return CheckToPostMsg(MSG.StartCycle, arg2[0], arg2[1], arg2[2]);
- }
-
- private bool InvokeBenchmark(string arg1, object[] arg2)
- {
- string reason;
- if (!checkCycle(out reason))
- {
- EV.PostWarningLog("System", $"Can not start cycle, {reason}");
- return false;
- }
- return CheckToPostMsg(MSG.StartCycle, arg2[0], arg2[1], arg2[2], "Benchmark");
- }
- private bool InvokeStop(string arg1, object[] arg2)
- {
- return CheckToPostMsg(MSG.Stop);
- }
- private bool InvokeMultiMoveWafer(string arg1, object[] arg2)
- {
- Running = false;
- string reason = "";
- bool ret = CheckMultiMove(out reason, arg2);
- if (ret)
- {
- MoveType type = (MoveType)arg2[0];
- MoveOption option = (MoveOption)arg2[1];
- Hand blade = (Hand)arg2[2];
- ModuleName schamber1 = (ModuleName)arg2[3];
- int sslot1 = (int)arg2[4];
- ModuleName dchamber1 = (ModuleName)arg2[5];
- int dslot1 = (int)arg2[6];
- ModuleName schamber2 = (ModuleName)arg2[3];
- int sslot2 = (int)arg2[4];
- ModuleName dchamber2 = (ModuleName)arg2[5];
- int dslot2 = (int)arg2[6];
- if (type != MoveType.Move)
- {
- schamber2 = (ModuleName)arg2[7];
- sslot2 = (int)arg2[8];
- dchamber2 = (ModuleName)arg2[9];
- dslot2 = (int)arg2[10];
- }
- _taskState[arg1] = Result.RUN;
- PostMsg(RouteManager.MSG.MoveWafer, type, option, blade,
- schamber1, sslot1, dchamber1, dslot1,
- schamber2, sslot2, dchamber2, dslot2
- );
- }
- else
- {
- _taskState[arg1] = Result.FAIL;
- return false;
- }
- return true;
- }
- private bool InvokeReturnWafer(string arg1, object[] arg2)
- {
- return CheckToPostMsg(MSG.ReturnWafer);
- }
- public bool InvokeMoveWafer(string arg1, object[] args)
- {
- Running = false;
- string reason = "";
- bool ret = checkMove(out reason, args);
- if (ret)
- {
- MoveType type = (MoveType)args[0];
- MoveOption option = (MoveOption)args[1];
- Hand blade = (Hand)args[2];
- ModuleName schamber1 = (ModuleName)args[3];
- int sslot1 = (int)args[4];
- ModuleName dchamber1 = (ModuleName)args[5];
- int dslot1 = (int)args[6];
- ModuleName schamber2 = (ModuleName)args[3];
- int sslot2 = (int)args[4];
- ModuleName dchamber2 = (ModuleName)args[5];
- int dslot2 = (int)args[6];
- if (type != MoveType.Move)
- {
- schamber2 = (ModuleName)args[7];
- sslot2 = (int)args[8];
- dchamber2 = (ModuleName)args[9];
- dslot2 = (int)args[10];
- }
- _taskState[arg1] = Result.RUN;
- PostMsg(RouteManager.MSG.MoveWafer, type, option, blade,
- schamber1, sslot1, dchamber1, dslot1,
- schamber2, sslot2, dchamber2, dslot2
- );
- }
- else
- {
- _taskState[arg1] = Result.FAIL;
- }
- return true;
- }
- private bool InvokeWriteFoupID(string arg1, object[] arg2)
- {
- //{
- // ret = true;
- // ret = PostMsg<RouteManager, RouteManager.MSG>(RouteManager.MSG.WriteID, out reason, args);
- //}
- return true;
- }
- private bool InvokeReadFoupID(string arg1, object[] arg2)
- {
- return CheckToPostMsg(MSG.ReadID, arg2[0]);
- }
- private bool InvokeUnloadFoup(string arg1, object[] arg2)
- {
- return CheckToPostMsg(MSG.UNLOAD, arg2[0]);
- }
- private bool InvokeLoadFoup(string arg1, object[] arg2)
- {
- return CheckToPostMsg(MSG.LOAD, arg2[0]);
- //var lp = DEVICE.GetDevice<LoadPortBaseDevice>(arg2[0].ToString());
- //return lp.Load(out _);
- }
- private bool InvokeHomeUnit(string arg1, object[] arg2)
- {
- var lp = DEVICE.GetDevice<LoadPortBaseDevice>(arg2[0].ToString());
- return lp.Unload(out _);
- }
- private bool InvokeSetSpeed(string arg1, object[] args)
- {
- int speed = 3;
- string reason;
- if (int.TryParse((string)args[0], out speed))
- {
- if (!(speed <= 3 || speed >= 1))
- {
- EV.PostWarningLog(ModuleName.Robot.ToString(), "Error Parameter,speed should be range in 1, 3");
- }
- PostMsg(MSG.SetSpeed, int.Parse((string)args[0]));
- return true;
- }
- EV.PostWarningLog(ModuleName.Robot.ToString(), $"invalid parameters. {args[0]}");
- return false;
- }
- private bool InvokeResetRouteManager(string arg1, object[] arg2)
- {
- PostMsg(MSG.RESET);
- return true;
- }
- private bool InvokeDeleteWafer(string arg1, object[] args)
- {
- ModuleName chamber = (ModuleName)args[0];
- int slot = (int)args[1];
- if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slot))
- {
- if (WaferManager.Instance.CheckHasWafer(chamber, slot))
- {
- WaferManager.Instance.DeleteWafer(chamber, slot);
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferDelete, chamber.ToString(), slot + 1);
- }
- else
- {
- EV.PostInfoLog("System", string.Format("No wafer at {0} {1}, delete not valid", chamber.ToString(), slot + 1));
- }
- }
- else
- {
- EV.PostWarningLog("System", string.Format("Invalid position,{0},{1}", chamber.ToString(), slot.ToString()));
- return false;
- }
- return true;
- }
- private bool InvokeCreateWafer(string arg1, object[] args)
- {
- ModuleName chamber = (ModuleName)args[0];
- int slot = (int)args[1];
- WaferStatus state = (WaferStatus)args[2];
- if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slot))
- {
- if (WaferManager.Instance.CheckHasWafer(chamber, slot))
- {
- EV.PostInfoLog("System", string.Format("{0} slot {1} already has wafer.create wafer is not valid", chamber, slot));
- }
- else
- {
- if (ModuleHelper.IsLoadPort(chamber))
- {
- var lp = DEVICE.GetDevice<LoadPortBaseDevice>(chamber.ToString());
- if (WaferManager.Instance.CreateWafer(chamber, slot, state, lp.GetCurrentWaferSize()) != null)
- {
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferCreate, chamber.ToString(), slot + 1, state.ToString());
- }
- }
- else if (WaferManager.Instance.CreateWafer(chamber, slot, state, WaferSize.WS8) != null)
- {
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferCreate, chamber.ToString(), slot + 1, state.ToString());
- }
- }
-
- }
- else
- {
- EV.PostWarningLog("System", string.Format("Invalid position,{0},{1}", chamber.ToString(), slot.ToString()));
- return false;
- }
- return true;
- }
- #endregion
- protected override bool Init()
- {
- for (var i = 0; i < LoadPortQuantity; i++)
- {
- _loadportEntities[i].Initialize();
- }
- if(!FlipperIsDisable) _flp.Initialize();
- _cycle.Initialize();
- setspeedRoutine = new SetSpeedRoutine("System", "Set Speed");
- setspeedRoutine.Initalize();
- initRoutine = _isInterferencePrevent
- ? (IEfemRoutine)new InitRoutine2Step("System", "Init")
- : (IEfemRoutine)new InitRoutine("System", "Init");
- initRoutine.Initalize();
- _waferMapRoutine = new WaferMappingRoutine();
- _waferMapRoutine.Initalize();
- _staticTransfer.Initialize();
- _dualMover.Initialize();
- _singleMover.Initialize();
- _loadFoupRoutine = new LoadFoupRoutine(ModuleName.LP1.ToString(), "Load");
- _loadFoupRoutine.Initalize();
- _pickRoutine = new PickRoutine("System", "Pick");
- _pickRoutine.Initalize();
- _placeRoutine = new PlaceRoutine("System", "Place");
- _placeRoutine.Initalize();
-
- _pickExtendRoutine = new PickExtendRoutine("System", "PickExtend");
- _pickExtendRoutine.Initalize();
- _placeExtendRoutine = new PlaceExtendRoutine("System", "PlaceExtend");
- _placeExtendRoutine.Initalize();
- return true;
- }
- protected override void Term()
- {
- //_loadportA.Terminate();
- //_loadportB.Terminate();
- }
- #region Mode change
- private bool fSetAutoMode(object[] objs)
- {
- IsAutoMode = true;
- EV.PostMessage(ChamberSetString.System, EventEnum.RunningModeChanged, "AutoMode");
- return true;
- }
- private bool fSetManualMode(object[] objs)
- {
- IsAutoMode = false;
- EV.PostMessage(ChamberSetString.System, EventEnum.RunningModeChanged, "ManualMode");
- return true;
- }
- private bool fSetMaintenanceMode(object[] param)
- {
- IsAutoMode = false;
- EV.PostMessage(ChamberSetString.System, EventEnum.RunningModeChanged, "Maintenance");
- return true;
- }
- #endregion
- #region Init
- private bool fStartInit(object[] objs)
- {
- Result ret = initRoutine.Start(objs);
- if (ret == Result.DONE)
- {
- return false;
- }
- else if (ret == Result.FAIL)
- {
- return false; //do noting
- }
- return true;
- }
- private bool fInit(object[] objs)
- {
- Result ret = initRoutine.Monitor();
- if (ret == Result.DONE)
- {
- //state = (int)STATE.IDLE;
- return true;
- }
- else if (ret == Result.FAIL)
- {
- //do nothing
- //state = (int)STATE.ERROR;
- PostMsg(MSG.ERROR);
- return false;
- }
- return false; ;
- }
- private bool fError(object[] objs)
- {
- for (int i = 0; i < _taskState.Count; i++)
- {
- _taskState[_taskState.ElementAt(i).Key] = Result.FAIL;
- }
- return true;
- }
- private bool fIdle(object[] objs)
- {
- _taskState.Clear();
- return true;
- }
- #endregion
- #region setspeed
- private bool fStartSetSpeed(object[] objs)
- {
- Result ret = setspeedRoutine.Start(objs);
- setspeedRoutine.Speed = (int)objs[0];
- if (ret == Result.DONE)
- {
- return false;
- }
- else if (ret == Result.FAIL)
- {
- return false; //do noting
- }
- return true;
- }
- private bool fSetSpeed(object[] objs)
- {
- Result ret = setspeedRoutine.Monitor();
- if (ret == Result.DONE)
- {
- //state = (int)STATE.IDLE;
- return true;
- }
- else if (ret == Result.FAIL)
- {
- //do nothing
- //state = (int)STATE.ERROR;
- return true;
- }
- return false;
- }
- #endregion
- #region Transfer
- private bool fStartTransfer(object[] objs)
- {
- Running = true;
- return _staticTransfer.Start(objs);
- }
- private bool fStartReturn(object[] objs)
- {
- return _staticTransfer.Return(objs);
- }
- private bool fTransfer(object[] objs)
- {
- return _staticTransfer.Monitor(objs);
- }
- private bool fExitTransfer(object[] objs)
- {
- _staticTransfer.Clear();
- _taskState.Remove("MoveWafer");
- return true;
- }
- private void ProcessFinished()
- {
- }
- private IMoveManager GetMoveManager(bool bAligner)
- {
- if (!_robot.Blade1Enable)
- {
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.DefaultWarning, "Robot arm1 is disable, can't execute transfer");
- return null;
- }
- if (bAligner)
- {
- _singleMover.Blade = Hand.Blade1;
- return _singleMover;
- }
- if (_robot.Blade1Enable && _robot.Blade2Enable && SC.GetValue<bool>(SorterCommon.ScPathName.Robot_DualBlade1TransferEnable))
- return _dualMover;
- _singleMover.Blade = Hand.Blade1;
- return _singleMover;
- }
-
- private bool fAbortTransfer(object[] objs)
- {
- return true;
- }
- private bool FsmStartRobotPick(object[] param)
- {
- Result ret = Result.DONE;
- if (param.Length == 3)
- {
- _pickRoutine.Source = ModuleHelper.Converter((string)param[0]);
- _pickRoutine.Slot = (int)param[1];
- _pickRoutine.Blade = (Hand)param[2];
- ret = _pickRoutine.Start();
- }
- else
- {
- return false;
- }
- if (ret == Result.FAIL || ret == Result.DONE)
- return false;
- return ret == Result.RUN;
- }
-
- private bool FsmStartRobotMpntPick(object[] param)
- {
- Result ret = Result.DONE;
- if (param.Length == 4)
- {
- _pickExtendRoutine.Source = ModuleHelper.Converter((string)param[0]);
- _pickExtendRoutine.Slot = (int)param[1];
- _pickExtendRoutine.Blade = (Hand)param[2];
- _pickExtendRoutine.TaskEnum = (MpntTaskEnum)param[3];
- ret = _pickExtendRoutine.Start();
- }
- else
- {
- return false;
- }
- if (ret == Result.FAIL || ret == Result.DONE)
- return false;
- return ret == Result.RUN;
- }
- private bool FsmStartRobotPlace(object[] param)
- {
- Result ret = Result.DONE;
- if (param.Length == 3)
- {
- _placeRoutine.Station = ModuleHelper.Converter((string)param[0]);
- _placeRoutine.Slot = (int)param[1];
- _placeRoutine.Blade = (Hand)param[2];
- ret = _placeRoutine.Start();
- }
- else
- {
- return false;
- }
- if (ret == Result.FAIL || ret == Result.DONE)
- return false;
- return ret == Result.RUN;
- }
-
- private bool FsmStartRobotMpntPlace(object[] param)
- {
- Result ret = Result.DONE;
- if (param.Length == 4)
- {
- _placeExtendRoutine.Station = ModuleHelper.Converter((string)param[0]);
- _placeExtendRoutine.Slot = (int)param[1];
- _placeExtendRoutine.Blade = (Hand)param[2];
- _placeExtendRoutine.TaskEnum = (MpntTaskEnum)param[3];
- ret = _placeExtendRoutine.Start();
- }
- else
- {
- return false;
- }
- if (ret == Result.FAIL || ret == Result.DONE)
- return false;
- return ret == Result.RUN;
- }
- private bool FsmChangeCassette(object[] param)
- {
- var lp = param[0].ToString();
- switch (fsm.State)
- {
- case (int)RtState.Cycle when lp == _cycle.OriginStation.ToString() || lp == _cycle.ToStation.ToString():
- _transferManager.Clear();
- IsTransferMode = false;
- _robot.Stop();
- EV.PostWarningLog("System", "Cassette changed during cycle");
- return true;
- case (int)RtState.Transfer when lp == _staticTransfer.TargetStation.ToString() || lp == _staticTransfer.SourceStation.ToString():
- _transferManager.Clear();
- _staticTransfer.Clear();
- IsTransferMode = false;
- _robot.Stop();
- EV.PostWarningLog("System", "Cassette changed during transfer");
- return true;
- case (int)RtState.WaferMapping when lp == _waferMapRoutine.Source.ToString():
- _transferManager.Clear();
- _staticTransfer.Clear();
- IsTransferMode = false;
- _robot.Stop();
- EV.PostWarningLog("System", "Cassette changed during wafer mapping");
- return true;
- case (int)RtState.Picking when lp == _pickRoutine.Source.ToString():
- case (int)RtState.Placing when lp == _placeRoutine.Station.ToString():
- _transferManager.Clear();
- IsTransferMode = false;
- _robot.Stop();
- EV.PostWarningLog("System", "Cassette changed during transfer");
- return true;
- default:
- return false;
- }
- }
-
- private bool FsmAbortTask(object[] param)
- {
- return true;
- }
- private bool FsmMonitorPick(object[] param)
- {
- Result ret = _pickRoutine.Monitor();
- if (ret == Result.FAIL)
- {
- PostMsg(MSG.ERROR);
- return false;
- }
- return ret == Result.DONE;
- }
-
- private bool FsmMonitorMpntPick(object[] param)
- {
- Result ret = _pickExtendRoutine.Monitor();
- if (ret == Result.FAIL)
- {
- PostMsg(MSG.ERROR);
- return false;
- }
- return ret == Result.DONE;
- }
- private bool FsmMonitorPlace(object[] param)
- {
- Result ret = _placeRoutine.Monitor();
- if (ret == Result.FAIL)
- {
- PostMsg(MSG.ERROR);
- return false;
- }
- return ret == Result.DONE;
- }
-
- private bool FsmMonitorMpntPlace(object[] param)
- {
- Result ret = _placeExtendRoutine.Monitor();
- if (ret == Result.FAIL)
- {
- PostMsg(MSG.ERROR);
- return false;
- }
- return ret == Result.DONE;
- }
- #endregion
- #region reset
- private bool fStartReset(object[] objs)
- {
- Singleton<EfemEntity>.Instance.EventError?.Clear();
- if(DEVICE.GetDevice<LoadPortBaseDevice>(ModuleName.LP1.ToString())!=null&& DEVICE.GetDevice<LoadPortBaseDevice>(ModuleName.LP1.ToString()).State==DeviceState.Error)
- DEVICE.GetDevice<LoadPortBaseDevice>(ModuleName.LP1.ToString()).CheckToPostMessage((int)LoadPortMsg.Reset, null); ;
- if (DEVICE.GetDevice<LoadPortBaseDevice>(ModuleName.LP2.ToString()) != null && DEVICE.GetDevice<LoadPortBaseDevice>(ModuleName.LP2.ToString()).State == DeviceState.Error)
- DEVICE.GetDevice<LoadPortBaseDevice>(ModuleName.LP2.ToString()).CheckToPostMessage((int)LoadPortMsg.Reset, null); ;
- if (fsm.State == (int)RtState.Error)
- return true;
- return false;
- }
- #endregion
- #region cycle
- private bool bCycle = false;
- private bool bReturn = false;
- private ModuleName _cycleSource;
- private ModuleName _cycleTarget;
- private bool bMappingSource = false;
- private bool _bUnload = false;
- private MoveOption _moveOption;
- private bool fStartCycle(object[] objs)
- {
- if (objs.Length < 2)
- {
- EV.PostWarningLog("System", "Cycle parameter is not valid, should be 2 LP modules");
- return false;
- }
- if (!Enum.TryParse((string)objs[0], out ModuleName from) || !Enum.TryParse((string)objs[1], out ModuleName to))
- {
- EV.PostWarningLog(ChamberSetString.System,
- ("Cycle parameter error, please check source and destination."));
- return false;
- }
- Result ret = Result.FAIL;
-
- if (objs.Length >= 3)
- {
- string[] _moveOption = (string[])objs[2];
- ret = _cycle.Start(from, to, (string[])objs[2]);
- }
-
-
- if (ret == Result.FAIL)
- {
- EV.PostWarningLog(ChamberSetString.System,
- ("There is wafer on the passing route"));
- return false;
- }
- return ret == Result.RUN;
- }
- private bool fCycle(object[] objs)
- {
- Result ret = _cycle.Monitor();
- if (ret == Result.DONE)
- return true;
- if (ret == Result.FAIL)
- {
- PostMsg(MSG.ERROR);
- return false;
- }
- return false; //continue
- }
- private bool fAbortRunProcess(object[] objs)
- {
- if (fsm.State == (int)RtState.Cycle)
- {
- bool _swapHand = false;
- if (SC.ContainsItem("Process.CycleSwapHand"))
- {
- _swapHand = SC.GetValue<bool>("Process.CycleSwapHand");
- }
- if (_swapHand &&
- ((_moveOption & MoveOption.LoadLock1) == MoveOption.LoadLock1 ||
- (_moveOption & MoveOption.LoadLock2) == MoveOption.LoadLock2 ||
- (_moveOption & MoveOption.LoadLock3) == MoveOption.LoadLock3 ||
- (_moveOption & MoveOption.LoadLock4) == MoveOption.LoadLock4 ||
- (_moveOption & MoveOption.LoadLock5) == MoveOption.LoadLock5 ||
- (_moveOption & MoveOption.LoadLock6) == MoveOption.LoadLock6 ||
- (_moveOption & MoveOption.LoadLock7) == MoveOption.LoadLock7 ||
- (_moveOption & MoveOption.LoadLock8) == MoveOption.LoadLock8 ||
- (_moveOption & MoveOption.Buffer) == MoveOption.Buffer))
- {
- SC.SetItemValue(ScPathName.Robot_Blade1Enable, true);
- SC.SetItemValue(ScPathName.Robot_Blade2Enable, true);
- }
- _moveOption = MoveOption.None;
- }
- _transferManager.Clear();
- IsTransferMode = false;
- return true;
- }
- private bool fCycleStop(object[] objs)
- {
- _cycle.Stop();
- bool _swapHand = false;
- if (SC.ContainsItem("Process.CycleSwapHand"))
- {
- _swapHand = SC.GetValue<bool>("Process.CycleSwapHand");
- }
- if (_swapHand &&
- ((_moveOption & MoveOption.LoadLock1) == MoveOption.LoadLock1 ||
- (_moveOption & MoveOption.LoadLock2) == MoveOption.LoadLock2 ||
- (_moveOption & MoveOption.LoadLock3) == MoveOption.LoadLock3 ||
- (_moveOption & MoveOption.LoadLock4) == MoveOption.LoadLock4 ||
- (_moveOption & MoveOption.LoadLock5) == MoveOption.LoadLock5 ||
- (_moveOption & MoveOption.LoadLock6) == MoveOption.LoadLock6 ||
- (_moveOption & MoveOption.LoadLock7) == MoveOption.LoadLock7 ||
- (_moveOption & MoveOption.LoadLock8) == MoveOption.LoadLock8 ||
- (_moveOption & MoveOption.Buffer) == MoveOption.Buffer))
- {
- SC.SetItemValue(ScPathName.Robot_Blade1Enable, true);
- SC.SetItemValue(ScPathName.Robot_Blade2Enable, true);
- }
- _moveOption = MoveOption.None;
- return true;
- }
- private bool FsmExitCycle(object[] param)
- {
- _cycle.Stop();
- EV.PostInfoLog("System", "Stop Cycle");
- bool _swapHand = false;
- if (SC.ContainsItem("Process.CycleSwapHand"))
- {
- _swapHand = SC.GetValue<bool>("Process.CycleSwapHand");
- }
- if (_swapHand &&
- ((_moveOption & MoveOption.LoadLock1) == MoveOption.LoadLock1 ||
- (_moveOption & MoveOption.LoadLock2) == MoveOption.LoadLock2 ||
- (_moveOption & MoveOption.LoadLock3) == MoveOption.LoadLock3 ||
- (_moveOption & MoveOption.LoadLock4) == MoveOption.LoadLock4 ||
- (_moveOption & MoveOption.LoadLock5) == MoveOption.LoadLock5 ||
- (_moveOption & MoveOption.LoadLock6) == MoveOption.LoadLock6 ||
- (_moveOption & MoveOption.LoadLock7) == MoveOption.LoadLock7 ||
- (_moveOption & MoveOption.LoadLock8) == MoveOption.LoadLock8 ||
- (_moveOption & MoveOption.Buffer) == MoveOption.Buffer))
- {
- SC.SetItemValue(ScPathName.Robot_Blade1Enable, true);
- SC.SetItemValue(ScPathName.Robot_Blade2Enable, true);
- }
- _moveOption = MoveOption.None;
- return true;
- }
- private bool FsmEnterCycle(object[] param)
- {
- EV.PostInfoLog("System", "Start Cycle");
- return true;
- }
- #endregion
- #region Loadport
- private bool fHome(object[] objs)
- {
- ModuleName chamber = (ModuleName)(objs[0]);
- Post(chamber, LoadPortEntity.MSG.HOME);
- return true;
- }
- private bool fLoad(object[] objs)
- {
- ModuleName chamber = (ModuleName)(objs[0]);
- Post(chamber, LoadPortEntity.MSG.Load);
- return true;
- }
- private bool fReadAndLoad(object[] objs)
- {
- ModuleName chamber = (ModuleName)(objs[0]);
- Post(chamber, LoadPortEntity.MSG.ReadAndLoad);
- return true;
- }
- private bool fUnload(object[] objs)
- {
- ModuleName chamber = (ModuleName)(objs[0]);
- Post(chamber, LoadPortEntity.MSG.Unload);
- return true;
- }
- private bool fReadID(object[] objs)
- {
- ModuleName chamber = (ModuleName)(objs[0]);
- Post(chamber, LoadPortEntity.MSG.ReadRFID);
- return true;
- }
- private bool fWriteID(object[] objs)
- {
- ModuleName chamber = (ModuleName)(objs[0]);
- Post(chamber, LoadPortEntity.MSG.WriteRFID);
- return true;
- }
- private bool Post(ModuleName chamber, LoadPortEntity.MSG msg, params object[] objs)
- {
- string pattern = "[1-9]\\d*";
- Regex rgx = new Regex(pattern);
- var match = int.Parse(rgx.Match(chamber.ToString()).ToString());
- if (match <= LoadPortQuantity)
- _loadportEntities[match - 1].PostMsg(msg, objs);
- return true;
- }
- #endregion
- #region validation
- /// <summary>
- ///
- /// </summary>
- /// <param name="msg"></param>
- /// <param name="reason"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- public bool CheckMsg(int msg, out string reason, bool eventOutReason, params object[] args)
- {
- Running = true;
- if (!fsm.FindTransition(fsm.State, msg))
- {
- reason = String.Format("{0} is in {1} state,can not do {2}", Name, (RtState)fsm.State, (MSG)msg);
- if (eventOutReason)
- {
- EV.PostMessage("System", EventEnum.DefaultWarning, reason);
- }
- Running = false;
- return false;
- }
- if (msg == (int)MSG.StartRecipe || msg == (int)MSG.StartCycle)
- {
- if (!IsAutoMode)
- {
- reason = String.Format("can not do {0}, isn't auto mode.", msg.ToString());
- if (eventOutReason)
- {
- EV.PostMessage("System", EventEnum.DefaultWarning, reason);
- }
- Running = false;
- return false;
- }
- }
- reason = "";
- return true;
- }
- public bool CheckToPostMsg(MSG msg)
- {
- if (!fsm.FindTransition(fsm.State, (int)msg))
- {
- EV.PostMessage("System", EventEnum.DefaultWarning,
- string.Format("{0} is in {1} state,can not do {2}", Name, (RtState)fsm.State, (MSG)msg));
- return false;
- }
- PostMsg(msg);
- return true;
- }
- public bool CheckToPostMsg(MSG msg, object param1)
- {
- if (!fsm.FindTransition(fsm.State, (int)msg))
- {
- EV.PostMessage("System", EventEnum.DefaultWarning,
- string.Format("{0} is in {1} state,can not do {2}", Name, (RtState)fsm.State, (MSG)msg));
- return false;
- }
- PostMsg(msg, param1);
- return true;
- }
- public bool CheckToPostMsg(MSG msg, object param1, object param2)
- {
- if (!fsm.FindTransition(fsm.State, (int)msg))
- {
- EV.PostMessage("System", EventEnum.DefaultWarning,
- string.Format("{0} is in {1} state,can not do {2}", Name, (RtState)fsm.State, (MSG)msg));
- return false;
- }
- PostMsg(msg, param1, param2);
- return true;
- }
- public bool CheckToPostMsg(MSG msg, object param1, object param2, object param3)
- {
- if (!fsm.FindTransition(fsm.State, (int)msg))
- {
- EV.PostMessage("System", EventEnum.DefaultWarning,
- string.Format("{0} is in {1} state,can not do {2}", Name, (RtState)fsm.State, (MSG)msg));
- return false;
- }
- PostMsg(msg, param1, param2, param3);
- return true;
- }
-
- public bool CheckToPostMsg(MSG msg, object param1, object param2, object param3, object param4)
- {
- if (!fsm.FindTransition(fsm.State, (int)msg))
- {
- EV.PostMessage("System", EventEnum.DefaultWarning,
- string.Format("{0} is in {1} state,can not do {2}", Name, (RtState)fsm.State, (MSG)msg));
- return false;
- }
- PostMsg(msg, param1, param2, param3, param4);
- return true;
- }
- private bool check(ModuleName source, int slot, ModuleName dest, int dslot, Hand blade, MoveOption option, out string reason)
- {
- reason = string.Empty;
- if (!checkFoup(source, out reason))
- {
- return false;
- }
- if (!checkFoup(dest, out reason))
- {
- return false;
- }
- if (!WaferManager.Instance.IsWaferSlotLocationValid(source, slot))
- {
- reason = string.Format("Invalid source parameter, {0}:{1:D2}", source.ToString(), slot);
- return false;
- }
- if (!WaferManager.Instance.IsWaferSlotLocationValid(dest, dslot))
- {
- reason = string.Format("Invalid destination parameter, {0}:{1:D2}", dest.ToString(), dslot);
- return false;
- }
- if (!WaferManager.Instance.CheckWafer(source, slot, WaferStatus.Normal))
- {
- if (ModuleHelper.IsLoadLock(source) && Singleton<EfemEntity>.Instance.IsOnlineMode)
- {
- //online mode, CreateWafer in LoadLock
- WaferManager.Instance.CreateWafer(source, slot, WaferStatus.Normal);
- }
- else
- {
- reason = string.Format("Source no normal wafer, {0}:{1:D2}", source.ToString(), slot);
- return false;
- }
- }
- if (!WaferManager.Instance.CheckWafer(dest, dslot, WaferStatus.Empty))
- {
- reason = string.Format("destination has wafer, {0}:{1:D2}", dest.ToString(), dslot);
- return false;
- }
- if (source != ModuleName.Robot && dest != ModuleName.Robot)
- {
- if (!WaferManager.Instance.CheckWafer(ModuleName.Robot, (int)blade, WaferStatus.Empty))
- {
- reason = string.Format("robot has wafer on arm");
- return false;
- }
- }
- bool bAligner = ((option & MoveOption.Align) == MoveOption.Align) ||
- ((option & MoveOption.ReadID) == MoveOption.ReadID) ||
- ((option & MoveOption.ReadID2) == MoveOption.ReadID2);
- if (bAligner)
- {
- if (source != ModuleName.Aligner && dest != ModuleName.Aligner)
- {
- if (!WaferManager.Instance.CheckWafer(ModuleName.Aligner, 0, WaferStatus.Empty))
- {
- reason = string.Format("aligner has wafer on");
- return false;
- }
- }
- }
- return true;
- }
- private bool check(ModuleName source, int slot, ModuleName dest, int dslot, out string reason)
- {
- reason = string.Empty;
- if (!checkFoup(source, out reason))
- {
- return false;
- }
- if (!checkFoup(dest, out reason))
- {
- return false;
- }
- if (!WaferManager.Instance.IsWaferSlotLocationValid(source, slot))
- {
- reason = string.Format("非法的参数。{0}:{1:D2}", source.ToString(), slot);
- return false;
- }
- if (!WaferManager.Instance.IsWaferSlotLocationValid(dest, dslot))
- {
- reason = string.Format("非法的参数。{0}:{1:D2}", dest.ToString(), dslot);
- return false;
- }
- if (!WaferManager.Instance.CheckWafer(source, slot, WaferStatus.Normal))
- {
- reason = string.Format("源位置没有wafer。{0}:{1:D2}", source.ToString(), slot);
- return false;
- }
- if (!WaferManager.Instance.CheckWafer(dest, dslot, WaferStatus.Empty))
- {
- reason = string.Format("目标位置有wafer。{0}:{1:D2}", dest.ToString(), dslot);
- return false;
- }
- return true;
- }
- private bool checkCycle(out string reason, params object[] args)
- {
- reason = string.Empty;
- //bool isAutoMode = (bool)DATA.Poll(ModuleName.System.ToString(), ParamName.IsAutoMode);
- //if (!isAutoMode)
- //{
- // reason = String.Format("can not cycle, isn't auto mode.");
- // return false;
- //}
- if (!WaferManager.Instance.CheckWafer(ModuleName.Robot, 0, WaferStatus.Empty))
- {
- reason = string.Format("Upper arm has wafer");
- return false;
- }
- if (!WaferManager.Instance.CheckWafer(ModuleName.Robot, 1, WaferStatus.Empty))
- {
- reason = string.Format("Lower arm has wafer");
- return false;
- }
- if (DeviceModel.SensorRBupperArmhavewafer != null && !DeviceModel.SensorRBupperArmhavewafer.Value)
- {
- reason = string.Format("Upper arm has wafer");
- return false;
- }
- if (DeviceModel.SensorRBlowerArmhavewafer != null && !DeviceModel.SensorRBlowerArmhavewafer.Value)
- {
- reason = string.Format("Lower arm has wafer");
- return false;
- }
- return true;
- }
- private bool CheckEnableAuto()
- {
- string reason = string.Empty;
- DeviceState state = (DeviceState)DATA.Poll(ModuleName.Robot.ToString(), ParamName.RobotState);
- if (state != DeviceState.Idle)
- {
- EV.PostMessage("System", EventEnum.DefaultWarning, "can not change auto mode, Robot isn't ready.");
- return false;
- }
- if (!Singleton<DeviceManager>.Instance.IsAnyLPIdle())
- {
- EV.PostMessage("System", EventEnum.DefaultWarning, "can not change auto mode, no loadport is ready.");
- return false;
- }
- if (!WaferManager.Instance.CheckWafer(ModuleName.Robot, 0, WaferStatus.Empty))
- {
- EV.PostMessage("System", EventEnum.DefaultWarning, "Upper arm has wafer");
- return false;
- }
- if (!WaferManager.Instance.CheckWafer(ModuleName.Robot, 1, WaferStatus.Empty))
- {
- EV.PostMessage("System", EventEnum.DefaultWarning, "Lower arm has wafer");
- return false;
- }
- if (!SC.GetValue<bool>(SorterCommon.ScPathName.System_IsSimulatorMode))
- {
- if (!DeviceModel.SensorRBupperArmhavewafer.Value)
- {
- EV.PostMessage("System", EventEnum.DefaultWarning, "Upper arm has wafer");
- return false;
- }
- if (!DeviceModel.SensorRBlowerArmhavewafer.Value)
- {
- EV.PostMessage("System", EventEnum.DefaultWarning, "Lower arm has wafer");
- return false;
- }
- }
- return true;
- }
- private bool checkMove(out string reason, params object[] args)
- {
- MoveType type = (MoveType)args[0];
- MoveOption option = (MoveOption)args[1];
- Hand blade = (Hand)args[2];
- ModuleName schamber1 = (ModuleName)args[3];
- int sslot1 = (int)args[4];
- ModuleName dchamber1 = (ModuleName)args[5];
- int dslot1 = (int)args[6];
- ModuleName schamber2 = (ModuleName)args[3];
- int sslot2 = (int)args[4];
- ModuleName dchamber2 = (ModuleName)args[5];
- int dslot2 = (int)args[6];
- if (type != MoveType.Move)
- {
- schamber2 = (ModuleName)args[7];
- sslot2 = (int)args[8];
- dchamber2 = (ModuleName)args[9];
- dslot2 = (int)args[10];
- }
- if (!check(type, blade, out reason))
- {
- EV.PostWarningLog("System", "Can not move wafer, " + reason);
- return false;
- }
- if (!check(schamber1, sslot1, dchamber1, dslot1, blade, option, out reason))
- {
- EV.PostWarningLog("System", "Can not move wafer, " + reason);
- return false;
- }
- if (type != MoveType.Move)
- {
- if (!check(schamber2, sslot2, dchamber2, dslot2, out reason))
- {
- EV.PostWarningLog("System", "Can not move wafer, " + reason);
- return false;
- }
- }
- return true;
- }
- private bool CheckMultiMove(out string reason, params object[] args)
- {
- MoveType type = (MoveType)args[0];
- MoveOption option = (MoveOption)args[1];
- Hand blade = (Hand)args[2];
- ModuleName schamber1 = (ModuleName)args[3];
- int sslot1 = (int)args[4];
- ModuleName dchamber1 = (ModuleName)args[5];
- int dslot1 = (int)args[6];
- ModuleName schamber2 = (ModuleName)args[3];
- int sslot2 = (int)args[4];
- ModuleName dchamber2 = (ModuleName)args[5];
- int dslot2 = (int)args[6];
- if (type != MoveType.Move)
- {
- schamber2 = (ModuleName)args[7];
- sslot2 = (int)args[8];
- dchamber2 = (ModuleName)args[9];
- dslot2 = (int)args[10];
- }
- if (!check(type, blade, out reason))
- {
- EV.PostWarningLog("System", "Can not move wafer, " + reason);
- return false;
- }
- //检查双臂, *若该机器人类型为下手臂1上手臂2
- if (!check(schamber1, sslot1, dchamber1, dslot1, Hand.Blade1, option, out reason))
- {
- EV.PostWarningLog("System", "Can not move wafer, " + reason);
- return false;
- }
- if (!check(schamber1, sslot1 + 1, dchamber1, dslot1 + 1, Hand.Blade2, option, out reason))
- {
- EV.PostWarningLog("System", "Can not move wafer, " + reason);
- return false;
- }
- if (type != MoveType.Move)
- {
- if (!check(schamber2, sslot2, dchamber2, dslot2, out reason))
- {
- EV.PostWarningLog("System", "Can not move wafer, " + reason);
- return false;
- }
- }
- return true;
- }
- private bool check(MoveType type, Hand blade, out string reason)
- {
- reason = string.Empty;
- if (type != MoveType.Move && blade == Hand.Both)
- {
- reason = string.Format("非法的参数。单片传盘时,不能指定Both blade");
- return false;
- }
- return true;
- }
-
- private bool checkFoup(ModuleName chamber, out string reason)
- {
- reason = string.Empty;
- if (ModuleHelper.IsLoadPort(chamber))
- {
- LoadPortBaseDevice loadport = DEVICE.GetDevice<LoadPortBaseDevice>(chamber.ToString());
- if (!loadport.IsEnableTransferWafer(out reason))
- {
- reason = string.Format("{0} isn't Ready, {1}", chamber.ToString(), reason);
- return false;
- }
- return true;
- }
- //reason = string.Format("Not Foup, parameter {0} is not valid.", chamber.ToString());
- return true;
- }
- public bool Check(int msg, out string reason, params object[] args)
- {
- if (!fsm.FindTransition(fsm.State, msg))
- {
- reason = String.Format("{0} is in {1} state,can not do {2}", Name, (RtState)fsm.State, (MSG)msg);
- return false;
- }
- if (msg == (int)MSG.StartRecipe || msg == (int)MSG.StartCycle)
- {
- if (!IsAutoMode)
- {
- reason = String.Format("can not do {0}, isn't auto mode.", msg.ToString());
- return false;
- }
- }
- reason = "";
- return true;
- }
- #endregion
- #region Map Wafer
- private bool FsmStartMapWafer(object[] param)
- {
- Running = false;
- Result ret = _waferMapRoutine.Start(param);
- if (ret == Result.DONE || (ret == Result.FAIL))
- {
- return false; //do noting
- }
- return true;
- }
- private bool FsmMonitorWaferMapping(object[] param)
- {
- Result ret = _waferMapRoutine.Monitor();
- if (ret == Result.DONE)
- {
- return true;
- }
- else if (ret == Result.FAIL)
- {
- return true;
- }
- return false;
- }
- public void MapBuffer()
- {
- var sensors = new List<bool>
- {
- false,false,false,false,false,
- //DeviceModel.SensorCoolingStageSLOT2WaferON.Value,
- //DeviceModel.SensorCoolingStageSLOT3WaferON.Value,
- //DeviceModel.SensorCoolingStageSLOT4WaferON.Value,
- //DeviceModel.SensorCoolingStageSLOT5WaferON.Value,
- //DeviceModel.SensorCoolingStageSLOT6WaferON.Value
- };
- var index = 0;
- foreach (var sensor in sensors)
- {
- if (!sensor && WaferManager.Instance.CheckNoWafer(ModuleName.Buffer, index))
- {
- WaferManager.Instance.CreateWafer(ModuleName.Buffer, index, WaferStatus.Normal);
- }
- else if (sensor && WaferManager.Instance.CheckHasWafer(ModuleName.Buffer, index))
- {
- WaferManager.Instance.DeleteWafer(ModuleName.Buffer, index);
- }
- index++;
- }
- var robotSensors = new List<bool>
- {
- DeviceModel.SensorRBlowerArmhavewafer.Value,
- DeviceModel.SensorRBupperArmhavewafer.Value
- };
- index = 0;
- foreach (var sensor in robotSensors)
- {
- if (!sensor && WaferManager.Instance.CheckNoWafer(ModuleName.Robot, index))
- {
- WaferManager.Instance.CreateWafer(ModuleName.Robot, index, WaferStatus.Normal);
- }
- else if (sensor && WaferManager.Instance.CheckHasWafer(ModuleName.Robot, index))
- {
- WaferManager.Instance.DeleteWafer(ModuleName.Robot, index);
- }
- index++;
- }
- }
- public int Invoke(string function, params object[] args)
- {
- switch (function)
- {
- case "Place":
- CheckToPostMsg(MSG.Place, args[0], args[1], args[2]);
- return (int)MSG.Place;
- case "Pick":
- CheckToPostMsg(MSG.Pick, args[0], args[1], args[2]);
- return (int)MSG.Pick;
- case "MPNTPick":
- CheckToPostMsg(MSG.MPNTPick, args[0], args[1], args[2], args[3]);
- return (int)MSG.MPNTPick;
- case "MPNTPlace":
- CheckToPostMsg(MSG.MPNTPlace, args[0], args[1], args[2], args[3]);
- return (int)MSG.MPNTPlace;
- case "Reset":
- CheckToPostMsg(MSG.RESET );
- return (int)MSG.RESET;
- }
- return (int)FSM_MSG.NONE;
- }
- public bool CheckAcked(int msg)
- {
- return fsm.CheckExecuted(msg);
- }
- #endregion
-
- }
- }
|