| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545 |
- 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;
- 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
- /// <summary>
- /// Flipper Entity
- /// </summary>
- public FlipperEntity FLPEntity => _flp;
- 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);
- }
- 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
- }
- }
|