123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583 |
- 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;
- using SciChart.Charting.ChartModifiers;
- 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,
- StopCycle
- }
- //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);
- //Transition(RtState.Cycle, MSG.StopCycle, fStopCycle, RtState.Idle);
-
- //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("System.StopCycle", InvokeStopCycle);
- 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 InvokeStopCycle(string arg1, object[] arg2)
- {
- return CheckToPostMsg(MSG.ABORT);
- }
- 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 fStopCycle(object[] objs)
- {
- _cycle.Stop();
- _robot.Stop();
- if (!IsLP1Disable)
- {
- var lp = DEVICE.GetDevice<LoadPortBaseDevice>(ModuleName.LP1.ToString());
- if (lp != null)
- lp.NoteTransferStop();
- }
- if (!IsLP2Disable)
- {
- var lp = DEVICE.GetDevice<LoadPortBaseDevice>(ModuleName.LP2.ToString());
- if (lp != null)
- lp.NoteTransferStop();
- }
- 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
-
- }
- }
|