1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Aitex.Core.RT.Fsm;
- using Aitex.Core.Common;
- using Aitex.Core.RT.DataCenter;
- using Aitex.Core.RT.Event;
- using Aitex.Core.RT.OperationCenter;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.Util;
- using MECF.Framework.Common.Jobs;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.SubstrateTrackings;
- using Venus_Core;
- using Venus_RT.Modules.PMs;
- using Aitex.Core.RT.Log;
- //using Venus_RT.Modules.VCE;
- using Venus_RT.Devices.PreAligner;
- //using Venus_RT.Modules.TM.VenusEntity;
- using SecsGem.Core.Application;
- using Aitex.Core.RT.RecipeCenter;
- using System.Reflection;
- using Venus_RT.Modules.LPs;
- using System.Runtime.InteropServices;
- using Venus_RT.Devices.EFEM;
- using Venus_RT.Modules.Schedulers;
- using Venus_Unity;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using System.Xml;
- using System.IO;
- using Venus_RT.Devices.YASKAWA;
- namespace Venus_RT.Modules
- {
- class RouteManager : Entity, IEntity, IEquipmentCommand
- {
- public enum MSG
- {
- MoveWafer,
- ReturnWafer,
- HomeUnit,
- PauseAuto,
- ResumeAuto,
- Stop,
- StartCycle,
- StopCycle,
- HOME,
- RESET,
- ABORT,
- ERROR,
- SetAutoMode,
- SetManualMode,
- ResetIdleCleanTime,
- ResetIdlePurgeTime,
- CreateJob,
- PauseJob,
- ResumeJob,
- StartJob,
- StopJob,
- AbortJob,
- JobDone,
- CassetteLeave, //For unload light control off afer job done
- Map,
- ReturnAllWafer,
- TMCycle,
- SETMCycle,
- StopSECycle,
- CreateSEJob,
- StartSEJob,
- AbortSEJob,
- SEMoveWafer,
- SEReturnWafer,
- SEAbort,
- StartEAPJob //kepler与Venus共用
- }
- public PMEntity PMA { get; private set; }
- public PMEntity PMB { get; private set; }
- public PMEntity PMC { get; private set; }
- public PMEntity PMD { get; private set; }
- public TMEntity TM { get; private set; }
- public LLEntity LLA { get; private set; }
- public LLEntity LLB { get; private set; }
- public EfemEntity EFEM { get; private set; }
- //public VceEntity VCE { get; private set; }
- //public VceEntity VCEA { get; private set; }
- //public VceEntity VCEB { get; private set; }
- //public SETMEntity seTM { get; private set; }
- public string Name { get; set; }
- public bool IsAutoMode
- {
- get
- {
- return fsm.State == (int)RtState.AutoRunning || fsm.State == (int)RtState.AutoIdle;
- }
- }
- public bool IsAutoRunning
- {
- get
- {
- return fsm.State == (int)RtState.AutoRunning;
- }
- }
- public bool IsInit
- {
- get { return fsm.State == (int)RtState.Init; }
- }
- public bool IsIdle
- {
- get { return fsm.State == (int)RtState.Idle || fsm.State == (int)RtState.AutoIdle; }
- }
- public bool IsAlarm
- {
- get { return fsm.State == (int)RtState.Error; }
- }
- public bool IsPaused
- {
- get { return _AutoCycle.CycleState == RState.Paused; }
- }
- public bool IsEntityError
- {
- get
- {
- return (EFEM?.IsError ?? false)
- || (PMA?.IsError ?? false)
- || (PMB?.IsError ?? false)
- || (PMC?.IsError ?? false)
- || (PMD?.IsError ?? false);
- }
- }
- public bool IsRunning
- {
- get
- {
- return !IsInit && !IsAlarm && !IsIdle;
- }
- }
- public static bool IsATMMode
- {
- get
- {
- if (_isATMMode == -1)
- {
- _isATMMode = SC.GetValue<bool>("System.IsATMMode") ? 1 : 0;
- }
- return _isATMMode == 1;
- }
- }
- public SequenceLLInOutPath LLInOutPath => _AutoCycle.LLInOutPath;
- private TMCycle _TMCycle;
- private ICycle _AutoCycle;
- private ManualTransfer _manualTransfer;
- //private SETMCycle _seTMCycle;
- //private SEManualTransfer _setransfer;
- //private SEReturnWafer _sereturnWafer;
- private bool _isWaitUnload = true;
- private static int _isATMMode = -1;
- public RouteManager()
- {
- Name = "System";
- if (ModuleHelper.IsInstalled(ModuleName.PMA))
- PMA = new PMEntity(ModuleName.PMA);
- if (ModuleHelper.IsInstalled(ModuleName.PMB))
- PMB = new PMEntity(ModuleName.PMB);
- if (ModuleHelper.IsInstalled(ModuleName.PMC))
- PMC = new PMEntity(ModuleName.PMC);
- if (ModuleHelper.IsInstalled(ModuleName.PMD))
- PMD = new PMEntity(ModuleName.PMD);
- if (ModuleHelper.IsInstalled(ModuleName.TM))
- {
- if (RtInstance.ConfigType == ConfigType.Kepler2200 || RtInstance.ConfigType == ConfigType.Kepler2300)
- TM = new TMEntity();
- //if (RtInstance.ConfigType == ConfigType.VenusDE || RtInstance.ConfigType == ConfigType.VenusSE)
- // seTM = new SETMEntity(ModuleName.TM);
- }
- if (ModuleHelper.IsInstalled(ModuleName.LLA))
- LLA = new LLEntity(ModuleName.LLA);
- if (ModuleHelper.IsInstalled(ModuleName.LLB))
- LLB = new LLEntity(ModuleName.LLB);
- if (ModuleHelper.IsInstalled(ModuleName.EFEM))
- EFEM = new EfemEntity();
- //if (ModuleHelper.IsInstalled(ModuleName.VCE1))
- //{
- // //临时加 后改为配置项
- // VCE = new VceEntity(ModuleName.VCE1);
- //}
- //if (ModuleHelper.IsInstalled(ModuleName.VCEA))
- //{
- // //临时加 后改为配置项
- // VCEA = new VceEntity(ModuleName.VCEA);
- //}
- //if (ModuleHelper.IsInstalled(ModuleName.VCEB))
- //{
- // //临时加 后改为配置项
- // VCEB = new VceEntity(ModuleName.VCEB);
- //}
- fsm = new StateMachine<RouteManager>(Name, (int)RtState.Init, 200);
- SubscribeOperation();
- SubscribeDataVariable();
-
- }
-
- 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, 0, (MSG)msg);
- return false;
- }
- if (msg == (int)MSG.StartCycle)
- {
- if (!IsAutoMode)
- {
- reason = String.Format("can not do {0}, isn't auto mode.", msg.ToString());
- return false;
- }
- }
- reason = "";
- return true;
- }
- void SubscribeDataVariable()
- {
- DATA.Subscribe("Rt.Status", () => ((RtState)fsm.State).ToString(), SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe(ModuleName.System.ToString(), "AlarmEvent", EV.GetAlarmEvent, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe("System.IsAutoMode", () => IsAutoMode, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe("System.IsIdle", () => IsIdle || IsInit, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe("System.IsAlarm", () => IsAlarm || IsEntityError, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe("System.IsBusy", () => IsRunning, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe("System.IsWaitUnload", () => _isWaitUnload && IsAutoMode, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- //DATA.Subscribe("System.IsConnectedWithHost", () => Singleton<SecGemApplication>.Instance., SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe("System.IsAutoRunning", () => fsm.State == (int)RtState.AutoRunning, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe("EquipmentMode", () => IsAutoMode ? 0 : 1, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe("EquipmentStatus", () =>
- {
- //"0 = Uninit
- //1 = Idle
- //2 = Running
- //3 = Error
- //4 = Pause
- //"
- if (IsInit) return 0;
- if (IsIdle) return 1;
- if (IsAlarm) return 3;
- if (IsPaused) return 4;
- return 2;
- }, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- }
- void SubscribeOperation()
- {
- OP.Subscribe("CreateWafer", InvokeCreateWafer);
- OP.Subscribe("DeleteWafer", InvokeDeleteWafer);
- OP.Subscribe("System.Home", (cmd, args) => CheckToPostMessage((int)MSG.HOME, args));
- OP.Subscribe("TMCycle.Start", (cmd, args) => CheckToPostMessage((int)MSG.TMCycle, args));
- OP.Subscribe("TMCycle.Abort", (cmd, args) => CheckToPostMessage((int)MSG.StopCycle, args));
- OP.Subscribe("System.StopSECycle", (cmd, args) => CheckToPostMessage((int)MSG.StopSECycle, args));
- DATA.Subscribe("SYSTEM.FsmState", () => (((RtState)fsm.State).ToString()));
- DATA.Subscribe("TMCycle.CycleIndex", () => (_TMCycle?.CycleIndex));
- DATA.Subscribe("System.IsConnectedWithHost", () => CheckSecsGemOnline(Singleton<SecGemApplication>.Instance.ControlState));
- DATA.Subscribe("System.IsDisconnectWithHost", () => CheckSecsGemOnline(Singleton<SecGemApplication>.Instance.ControlState));
- OP.Subscribe("ReturnWafer", InvokeReturnWafer);
- OP.Subscribe("System.ReturnAllWafer", (string cmd, object[] args) =>
- {
- //if (seTM != null && (VCE != null || VCEA != null || VCEB != null))
- // return CheckToPostMessage((int)MSG.SEReturnWafer, args);
- //else
- // return CheckToPostMessage((int)MSG.ReturnAllWafer, args[0], args[1], args[2], args[3]);
- return CheckToPostMessage((int)MSG.ReturnAllWafer, args[0], args[1], args[2], args[3]);
- });
- OP.Subscribe("System.MoveWafer", (string cmd, object[] args) =>
- {
- if (!Enum.TryParse((string)args[0], out ModuleName source))
- {
- EV.PostWarningLog(Name, $"Parameter source {(string)args[0]} not valid");
- return false;
- }
- if (!Enum.TryParse((string)args[2], out ModuleName destination))
- {
- EV.PostWarningLog(Name, $"Parameter destination {(string)args[1]} not valid");
- return false;
- }
- //if (seTM != null && (VCE != null || VCEA != null || VCEB != null))
- // return CheckToPostMessage((int)MSG.SEMoveWafer,
- // source, (int)args[1],
- // destination, (int)args[3],
- // args[4], args[5],
- // args[6], args[7], (string)args[8]);
- //else
- // return CheckToPostMessage((int)MSG.MoveWafer,
- // source, (int)args[1],
- // destination, (int)args[3],
- // args[4], args[5],
- // args[6], args[7], (string)args[8]);
- return CheckToPostMessage((int)MSG.MoveWafer,
- source, (int)args[1],
- destination, (int)args[3],
- args[4], args[5],
- args[6], args[7], (string)args[8]);
- });
- OP.Subscribe("System.HomeAll", (string cmd, object[] args) =>
- {
- return CheckToPostMessage((int)MSG.HOME);
- });
- OP.Subscribe("System.Abort", (string cmd, object[] args) =>
- {
- return CheckToPostMessage((int)MSG.ABORT);
- });
- OP.Subscribe("System.Reset", (string cmd, object[] args) =>
- {
- return CheckToPostMessage((int)MSG.RESET);
- });
- OP.Subscribe("System.SetAutoMode", (string cmd, object[] args) =>
- {
- return CheckToPostMessage((int)MSG.SetAutoMode);
- });
- OP.Subscribe("System.SetManualMode", (string cmd, object[] args) =>
- {
- return CheckToPostMessage((int)MSG.SetManualMode);
- });
- OP.Subscribe("System.CreateJob", (string cmd, object[] args) =>
- {
- return CheckToPostMessage((int)MSG.CreateJob, args[0]);
- });
- OP.Subscribe("System.StartJob", (string cmd, object[] args) =>
- {
- return CheckToPostMessage((int)MSG.StartJob, args[0]);
- });
- OP.Subscribe("System.PauseJob", (string cmd, object[] args) =>
- {
- return CheckToPostMessage((int)MSG.PauseJob, args[0]);
- });
- OP.Subscribe("System.ResumeJob", (string cmd, object[] args) =>
- {
- return CheckToPostMessage((int)MSG.ResumeJob, args[0]);
- });
- OP.Subscribe("System.StopJob", (string cmd, object[] args) =>
- {
- return CheckToPostMessage((int)MSG.StopJob, args[0]);
- });
- OP.Subscribe("System.AbortJob", (string cmd, object[] args) =>
- {
- return CheckToPostMessage((int)MSG.AbortJob, args[0]);
- });
- OP.Subscribe("SE.AbortJob", (string cmd, object[] args) =>
- {
- return CheckToPostMessage((int)MSG.AbortSEJob, args[0]);
- });
- OP.Subscribe("LP1.Map", (string cmd, object[] args) =>
- {
- if (IsAutoMode)
- {
- return CheckToPostMessage((int)MSG.Map, ModuleName.LP1.ToString());
- }
- return EFEM.InvokeMap(ModuleName.LP1.ToString()) != (int)FSM_MSG.NONE;
- });
- OP.Subscribe("LP2.Map", (string cmd, object[] args) =>
- {
- if (IsAutoMode)
- {
- return CheckToPostMessage((int)MSG.Map, ModuleName.LP2.ToString());
- }
- return EFEM.InvokeMap(ModuleName.LP2.ToString()) != (int)FSM_MSG.NONE;
- });
- OP.Subscribe(RtOperation.SetConfig.ToString(), (name, args) =>
- {
- string sc_key = args[0] as string;
- if (!string.IsNullOrWhiteSpace(sc_key) && args.Length > 1)
- {
- SC.SetItemValue(sc_key, args[1]);
- }
- return true;
- });
- OP.Subscribe("System.ResetIdleCleanTime", (string cmd, object[] args) =>
- {
- return CheckToPostMessage((int)MSG.ResetIdleCleanTime, args[0]);
- });
- OP.Subscribe("System.ResetIdlePurgeTime", (string cmd, object[] args) =>
- {
- return CheckToPostMessage((int)MSG.ResetIdlePurgeTime, args[0]);
- });
- OP.Subscribe("System.SetWaferSize", (string cmd, object[] args) =>
- {
- string module = (string)args[0];
- string size = (string)args[1];
- switch (size)
- {
- case "3":
- WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS3);
- break;
- case "4":
- WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS4);
- break;
- case "6":
- WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS6);
- break;
- default:
- EV.PostWarningLog("System", $"wafer size {size} not valid");
- break;
- }
- return true;
- });
- OP.Subscribe("System.CassetteLeave", (string cmd, object[] args) =>
- {
- return CheckToPostMessage((int)MSG.CassetteLeave);
- });
- OP.Subscribe("System.IsModuleInstalled", (string cmd, object[] args) =>
- {
- return ModuleHelper.IsInstalled((ModuleName)args[0]);
- });
- OP.Subscribe("System.SETMCycle", (cmd, args) => CheckToPostMessage((int)MSG.SETMCycle, args));
- OP.Subscribe("System.CreateSEJob", (cmd, args) => CheckToPostMessage((int)MSG.CreateJob, args));
- OP.Subscribe("System.StartSEJob", (cmd, args) => CheckToPostMessage((int)MSG.StartJob, args));
- OP.Subscribe("System.ReturnAllSEWafer", (cmd, args) => CheckToPostMessage((int)MSG.ReturnAllWafer, args));
- OP.Subscribe("System.SEAbort", (cmd, args) => CheckToPostMessage((int)MSG.ABORT, args));
- }
- public bool CheckToPostMessage(int msg, params object[] args)
- {
- if (!fsm.FindTransition(fsm.State, msg))
- {
- LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, $"System is in {(RtState)fsm.State} state,can not do {(MSG)msg}");
- return false;
- }
- Running = true;
- fsm.PostMsg(msg, args);
- return true;
- }
- public bool InvokeAbort(object[] args)
- {
- return CheckToPostMessage((int)MSG.ABORT, args);
- }
- private bool InvokeCreateWafer(string arg1, object[] args)
- {
- ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
- int slot = (int)args[1];
- WaferStatus state = WaferStatus.Normal;
- if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slot))
- {
- if (WaferManager.Instance.CheckHasWafer(chamber, slot))
- {
- LOG.Write(eEvent.EV_ROUTER, "System", string.Format("{0} slot {1} already has wafer.create wafer is not valid", chamber, slot));
- }
- else if (WaferManager.Instance.CreateWafer(chamber, slot, state) != null)
- {
- LOG.Write(eEvent.EV_WAFER_CREATE, ModuleName.System, chamber.ToString(), (slot + 1).ToString(), state.ToString());
- }
- }
- else
- {
- LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("Invalid position,{0},{1}", chamber.ToString(), slot.ToString()));
- return false;
- }
- return true;
- }
- private bool InvokeDeleteWafer(string arg1, object[] args)
- {
- ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
- 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
- {
- LOG.Write(eEvent.EV_ROUTER, "System", string.Format("No wafer at {0} {1}, delete not valid", chamber.ToString(), slot + 1));
- }
- }
- else
- {
- LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("Invalid position,{0},{1}", chamber.ToString(), slot.ToString()));
- return false;
- }
- return true;
- }
- private bool InvokeReturnWafer(string arg1, object[] args)
- {
- ModuleName target = ModuleHelper.Converter(args[0].ToString());
- int slot = (int)args[1];
- //if (seTM != null && (VCE != null || VCEA != null || VCEB != null))
- //{
- // if (ModuleHelper.IsVCE(target))
- // {
- // LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("Wafer already at vce {0} {1}, return operation is not valid", target.ToString(), slot + 1));
- // return false;
- // }
- // WaferInfo wafer = WaferManager.Instance.GetWafer(target, slot);
- // if (wafer.IsEmpty)
- // {
- // LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("No wafer at {0} {1}, return operation is not valid", target.ToString(), slot + 1));
- // return false;
- // }
- // return CheckToPostMessage((int)MSG.SEMoveWafer,
- // target, slot,
- // (ModuleName)wafer.OriginStation, wafer.OriginSlot,
- // false, 0, false, 0, "Blade1");
- //}
- //else
- //{
- // if (ModuleHelper.IsLoadPort(target))
- // {
- // LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("Wafer already at LoadPort {0} {1}, return operation is not valid", target.ToString(), slot + 1));
- // return false;
- // }
- // if (!WaferManager.Instance.IsWaferSlotLocationValid(target, slot))
- // {
- // LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("Invalid position,{0},{1}", target.ToString(), slot.ToString()));
- // return false;
- // }
- // WaferInfo wafer = WaferManager.Instance.GetWafer(target, slot);
- // if (wafer.IsEmpty)
- // {
- // LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("No wafer at {0} {1}, return operation is not valid", target.ToString(), slot + 1));
- // return false;
- // }
- // return CheckToPostMessage((int)MSG.MoveWafer,
- // target, slot,
- // (ModuleName)wafer.OriginStation, wafer.OriginSlot,
- // false, 0, false, 0, "Blade1");
- //}
- if (ModuleHelper.IsLoadPort(target))
- {
- LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("Wafer already at LoadPort {0} {1}, return operation is not valid", target.ToString(), slot + 1));
- return false;
- }
- if (!WaferManager.Instance.IsWaferSlotLocationValid(target, slot))
- {
- LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("Invalid position,{0},{1}", target.ToString(), slot.ToString()));
- return false;
- }
- WaferInfo wafer = WaferManager.Instance.GetWafer(target, slot);
- if (wafer.IsEmpty)
- {
- LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("No wafer at {0} {1}, return operation is not valid", target.ToString(), slot + 1));
- return false;
- }
- return CheckToPostMessage((int)MSG.MoveWafer,
- target, slot,
- (ModuleName)wafer.OriginStation, wafer.OriginSlot,
- false, 0, false, 0, "Blade1");
- }
- public PMEntity GetPM(ModuleName mod)
- {
- if (ModuleHelper.IsInstalled(mod))
- {
- switch (mod)
- {
- case ModuleName.PMA:
- return PMA;
- case ModuleName.PMB:
- return PMB;
- case ModuleName.PMC:
- return PMC;
- case ModuleName.PMD:
- return PMD;
- }
- }
- return null;
- }
- public LLEntity GetLL(ModuleName mod)
- {
- if (ModuleHelper.IsInstalled(mod))
- {
- switch (mod)
- {
- case ModuleName.LLA:
- return LLA;
- case ModuleName.LLB:
- return LLB;
- }
- }
- return null;
- }
- //public VceEntity GetVCE(ModuleName mod)
- //{
- // if (ModuleHelper.IsInstalled(mod))
- // {
- // switch (mod)
- // {
- // case ModuleName.VCE1:
- // return VCE;
- // case ModuleName.VCEA:
- // return VCEA;
- // case ModuleName.VCEB:
- // return VCEB;
- // }
- // }
- // return null;
- //}
- public bool IsTMIdle()
- {
- //if (RtInstance.ConfigType == ConfigType.VenusSE || RtInstance.ConfigType == ConfigType.VenusDE)
- // return seTM.IsIdle;
- if (RtInstance.ConfigType == ConfigType.Kepler2200 || RtInstance.ConfigType == ConfigType.Kepler2300)
- return TM.IsIdle;
- return false;
- }
- public TMEntity GetTM()
- {
- return TM;
- }
- protected override bool Init()
- {
- PMA?.Initialize();
- PMB?.Initialize();
- PMC?.Initialize();
- PMD?.Initialize();
- LLA?.Initialize();
- LLB?.Initialize();
- EFEM?.Initialize();
- //VCE?.Initialize();
- //VCEA?.Initialize();
- //VCEB?.Initialize();
- //if (RtInstance.ConfigType == ConfigType.VenusSE || RtInstance.ConfigType == ConfigType.VenusDE)
- //{
- // seTM?.Initialize();
- // _seTMCycle = new SETMCycle(ModuleName.TM);
- // _setransfer = new SEManualTransfer();
- // _sereturnWafer = new SEReturnWafer(_setransfer);
- // _AutoCycle = new VenusDispatcher();
- //}
- //else
- //{
- // TM?.Initialize();
- // _TMCycle = new TMCycle();
- // _manualTransfer = new ManualTransfer();
- // _AutoCycle = new SystemDispatcher();
- //}
- TM?.Initialize();
- _TMCycle = new TMCycle();
- _manualTransfer = new ManualTransfer();
- _AutoCycle = new SystemDispatcher();
- BuildTransitionTable();
- return true;
- }
- private void BuildTransitionTable()
- {
- //Init sequence
- Transition(RtState.Init, MSG.HOME, FsmStartHome, RtState.Initializing);
- Transition(RtState.Idle, MSG.HOME, FsmStartHome, RtState.Initializing);
- Transition(RtState.Error, MSG.HOME, FsmStartHome, RtState.Initializing);
- EnterExitTransition<RtState, FSM_MSG>(RtState.AutoRunning, FsmEnterAutoRunning, FSM_MSG.NONE, FsmExitAutoTransfer);
- EnterExitTransition<RtState, FSM_MSG>(RtState.Transfer, null, FSM_MSG.NONE, FsmExitTransfer);
- EnterExitTransition<RtState, FSM_MSG>(RtState.ReturnWafer, null, FSM_MSG.NONE, FsmExitReturnWafer);
- AnyStateTransition(MSG.ERROR, FsmError, RtState.Error);
- Transition(RtState.Idle, FSM_MSG.TIMER, FsmMonitor, RtState.Idle);
- Transition(RtState.Init, FSM_MSG.TIMER, FsmMonitor, RtState.Init);
- Transition(RtState.Initializing, FSM_MSG.TIMER, FsmMonitorHome, RtState.Idle);
- Transition(RtState.Initializing, MSG.ERROR, FsmError, RtState.Error);
- Transition(RtState.Initializing, MSG.ABORT, FsmAbort, RtState.Init);
- // TM Cycle
- Transition(RtState.Idle, MSG.TMCycle, FsmStartTMCycle, RtState.TMCycle);
- Transition(RtState.TMCycle, FSM_MSG.TIMER, FsmMonitorTMCycle, RtState.Idle);
- Transition(RtState.TMCycle, MSG.StopCycle, FsmStopTMCycle, RtState.Idle);
- //Auto/manual
- Transition(RtState.Idle, MSG.SetAutoMode, FsmStartAutoTransfer, RtState.AutoIdle);
- Transition(RtState.AutoRunning, FSM_MSG.TIMER, FsmAutoTransfer, RtState.AutoIdle);
- Transition(RtState.AutoRunning, MSG.ABORT, FsmAbortAutoTransfer, RtState.Idle);
- //Transition(RtState.AutoRunning, MSG.SetManualMode, FsmStartSetManualMode, RtState.Idle);
- Transition(RtState.AutoRunning, MSG.JobDone, FsmJobDone, RtState.AutoIdle);
- //Transition(RtState.AutoRunning, MSG.CassetteLeave, fCassetteLeave, RtState.AutoRunning); //For unload light control off afer job done
- Transition(RtState.AutoRunning, MSG.CreateJob, FsmCreateJob, RtState.AutoRunning);
- Transition(RtState.AutoRunning, MSG.StartJob, FsmStartJob, RtState.AutoRunning);
- Transition(RtState.AutoRunning, MSG.PauseJob, FsmPauseJob, RtState.AutoRunning);
- Transition(RtState.AutoRunning, MSG.ResumeJob, FsmResumeJob, RtState.AutoRunning);
- Transition(RtState.AutoRunning, MSG.StopJob, FsmStopJob, RtState.AutoRunning);
- Transition(RtState.AutoRunning, MSG.AbortJob, FsmAbortJob, RtState.AutoRunning);
- Transition(RtState.AutoRunning, MSG.MoveWafer, FsmAutoReturnWafer, RtState.AutoRunning);
- Transition(RtState.AutoRunning, MSG.Map, FsmMap, RtState.AutoRunning);
- Transition(RtState.AutoRunning, MSG.ResetIdleCleanTime, FsmResetIdleCleanTime, RtState.AutoRunning);
- Transition(RtState.AutoRunning, MSG.ResetIdlePurgeTime, FsmResetIdlePurgeTime, RtState.AutoRunning);
- Transition(RtState.AutoIdle, FSM_MSG.TIMER, FsmMonitorAutoIdle, RtState.AutoIdle);
- Transition(RtState.AutoIdle, MSG.SetManualMode, FsmStartSetManualMode, RtState.Idle);
- Transition(RtState.AutoIdle, MSG.CreateJob, FsmCreateJob, RtState.AutoIdle);
- Transition(RtState.AutoIdle, MSG.StartJob, FsmStartJob, RtState.AutoRunning);
- Transition(RtState.AutoIdle, MSG.PauseJob, FsmPauseJob, RtState.AutoIdle);
- Transition(RtState.AutoIdle, MSG.ResumeJob, FsmResumeJob, RtState.AutoIdle);
- Transition(RtState.AutoIdle, MSG.StopJob, FsmStopJob, RtState.AutoIdle);
- Transition(RtState.AutoIdle, MSG.AbortJob, FsmAbortJob, RtState.AutoIdle);
- Transition(RtState.AutoIdle, MSG.Map, FsmMap, RtState.AutoIdle);
- Transition(RtState.AutoIdle, MSG.StartEAPJob, FsmStartJob, RtState.AutoRunning);
- Transition(RtState.AutoRunning, MSG.StartEAPJob, FsmStartJob, RtState.AutoRunning);
- //Transfer
- Transition(RtState.Idle, MSG.MoveWafer, FsmStartTransfer, RtState.Transfer);
- Transition(RtState.Transfer, FSM_MSG.TIMER, FsmMonitorTransfer, RtState.Idle);
- Transition(RtState.Transfer, MSG.ABORT, FsmAbort, RtState.Idle);
- //Return Wafer
- Transition(RtState.Idle, MSG.ReturnAllWafer, FsmStartReturnWafer, RtState.ReturnWafer);
- Transition(RtState.ReturnWafer, FSM_MSG.TIMER, FsmMonitorReturnWafer, RtState.Idle);
- Transition(RtState.ReturnWafer, MSG.ABORT, FsmAbort, RtState.Idle);
- // SETM Cycle
- Transition(RtState.Idle, MSG.SETMCycle, FsmStartSETMCycle, RtState.SETMCycle);
- Transition(RtState.SETMCycle, FSM_MSG.TIMER, FsmMonitorSETMCycle, RtState.Idle);
- Transition(RtState.SETMCycle, MSG.SEAbort, SEAbort, RtState.Idle);
- Transition(RtState.SETMCycle, MSG.AbortSEJob, SEAbortJob, RtState.Idle);
- // SETM CreateCycle
- Transition(RtState.Idle, MSG.CreateSEJob, FsmStartCreateSEJob, RtState.Idle);
- // SETM StartCycle
- Transition(RtState.Idle, MSG.StartSEJob, FsmStartSEJob, RtState.SERunning);
- Transition(RtState.SERunning, FSM_MSG.TIMER, FsmSEJobMonitor, RtState.Idle);
- Transition(RtState.SERunning, MSG.SEAbort, SEAbort, RtState.Idle);
- Transition(RtState.SERunning, MSG.AbortSEJob, SEAbortJob, RtState.Idle);
- Transition(RtState.Idle, MSG.AbortSEJob, SEAbortJob, RtState.Idle);
- //// SE Transfer
- //Transition(RtState.Idle, MSG.SEMoveWafer, FsmStartSEMoveWafer, RtState.SETransfer);
- //Transition(RtState.SETransfer, FSM_MSG.TIMER, FsmMonitorSEMoveWafer, RtState.Idle);
- //Transition(RtState.SETransfer, MSG.ABORT, SEAbort, RtState.Idle);
- //// SE ReturnWafer
- //Transition(RtState.Idle, MSG.SEReturnWafer, FsmStartSEReturnWafer, RtState.SEReturnWafer);
- //Transition(RtState.SEReturnWafer, FSM_MSG.TIMER, FsmMonitorSEReturnWafer, RtState.Idle);
- //Transition(RtState.SEReturnWafer, MSG.SEAbort, SEAbort, RtState.Idle);
- }
- private bool FsmMonitor(object[] objs)
- {
- _debugRoutine();
- return true;
- }
- private bool FsmStartHome(object[] objs)
- {
- TM?.Invoke("Home");
- EFEM?.Invoke("Home");
- //seTM?.Invoke("Home");
- //VCE?.Invoke("Home");
- //VCEA?.Invoke("Home");
- //VCEB?.Invoke("Home");
- foreach (var mod in ModuleHelper.InstalledModules)
- {
- if (ModuleHelper.IsPm(mod))
- {
- if (GetPM(mod).IsInclude)
- {
- GetPM(mod).Invoke("Home");
- }
- }
- else if (ModuleHelper.IsLoadLock(mod))
- {
- if (GetLL(mod).IsInclude)
- {
- GetLL(mod).Invoke("Home");
- }
- }
- }
- return true;
- }
- private bool FsmMonitorHome(object[] objs)
- {
- ModuleName notReadyModule = ModuleName.System;
- foreach (var mod in ModuleHelper.InstalledModules)
- {
- if ((ModuleHelper.IsPm(mod) && GetPM(mod).IsInclude && !GetPM(mod).IsIdle) ||
- (ModuleHelper.IsLoadLock(mod) && GetLL(mod).IsInclude && !GetLL(mod).IsIdle) ||
- (ModuleHelper.IsTM(mod) && !IsTMIdle()) ||
- //(ModuleHelper.IsVCE(mod) && !GetVCE(mod).IsIdle) ||
- (ModuleHelper.IsEFEM(mod) && !EFEM.IsIdle))
- {
- notReadyModule = mod;
- break;
- }
- }
- if (notReadyModule != ModuleName.System)
- {
- if (fsm.ElapsedTime > 100 * 1000)
- {
- LOG.Write(eEvent.ERR_ROUTER, ModuleName.System, $"{notReadyModule} home timeout");
- PostMsg(MSG.ERROR);
- return true;
- }
- else
- return false;
- }
- return true;
- }
- private bool FsmEnterAutoRunning(object[] objs)
- {
- return true;
- }
- private bool FsmExitAutoTransfer(object[] objs)
- {
- _AutoCycle.Clear();
- //if (RtInstance.ConfigType == ConfigType.VenusDE || RtInstance.ConfigType == ConfigType.VenusSE)
- //{
- // seTM.PostMsg(SETMEntity.MSG.Home);
- //}
- return true;
- }
- private bool FsmExitTransfer(object[] objs)
- {
- _manualTransfer.Clear();
- return true;
- }
- private bool FsmExitReturnWafer(object[] objs)
- {
- return true;
- }
- private bool FsmError(object[] objs)
- {
- return true;
- }
- private bool FsmAbort(object[] objs)
- {
- _manualTransfer?.Clear();
- //_setransfer?.Abort();
- _AutoCycle.Clear();
- return true;
- }
- private bool FsmStartTMCycle(object[] objs)
- {
- return _TMCycle.Start(objs) == RState.Running;
- }
- private bool FsmMonitorTMCycle(object[] objs)
- {
- RState ret = _TMCycle.Monitor();
- if (ret == RState.Failed || ret == RState.Timeout)
- {
- PostMsg(MSG.ERROR);
- return false;
- }
- return ret == RState.End;
- }
- private bool FsmStopTMCycle(object[] objs)
- {
- _TMCycle.Abort();
- return true;
- }
- private bool FsmStartAutoTransfer(object[] objs)
- {
- return _AutoCycle.Start(objs) == RState.Running;
- }
- private bool FsmAutoTransfer(object[] objs)
- {
- if (_AutoCycle.CheckAllJobDone())
- {
- if (!CheckToPostMessage((int)MSG.JobDone))
- return false;
- }
- RState ret = _AutoCycle.Monitor();
- if (_AutoCycle.CheckJobJustDone(out string jobInfo))
- {
- //EV.PostPopDialogMessage(EventLevel.InformationNoDelay, "Job complete", jobInfo);
- LOG.Write(eEvent.EV_ROUTER, ModuleName.System, $"Job complete,{jobInfo}");
- }
- if (ret == RState.Failed)
- {
- if (!CheckToPostMessage((int)MSG.ERROR))
- return false;
- }
- //_isWaitUnload = (bool)DATA.Poll("LP1.NotifyJobDone") || (bool)DATA.Poll("LP2.NotifyJobDone");
- return ret == RState.End;
- }
- private bool FsmAbortAutoTransfer(object[] objs)
- {
- _AutoCycle.Clear();
- return true;
- }
- private bool FsmJobDone(object[] objs)
- {
- _isWaitUnload = true;
- return true;
- }
- private bool FsmCreateJob(object[] objs)
- {
- Dictionary<string, object> obj = (Dictionary<string, object>)objs[0];
- var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), obj["Module"].ToString());
- if ((Singleton<TransferModule>.Instance.GetScheduler(moduleName) as SchedulerLoadPort).IsLoaded)
- {
- return _AutoCycle.CreateJob(obj, out var reason);
- }
- else
- {
- LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, $"{obj["Module"]} is unload,can not create job");
- return false;
- }
- }
- private bool FsmStartJob(object[] objs)
- {
- _AutoCycle.StartJob((string)objs[0], out var reason);
- return true;
- }
- private bool FsmPauseJob(object[] objs)
- {
- _AutoCycle.PauseJob((string)objs[0], out var reason);
- return true;
- }
- private bool FsmResumeJob(object[] objs)
- {
- _AutoCycle.ResumeJob((string)objs[0], out var reason);
- return true;
- }
- private bool FsmStopJob(object[] objs)
- {
- _AutoCycle.StopJob((string)objs[0], out var reason);
- return true;
- }
- private bool FsmAbortJob(object[] objs)
- {
- _AutoCycle.AbortJob((string)objs[0], out var reason);
- return true;
- }
- private bool FsmStartTransfer(object[] objs)
- {
- return _manualTransfer.Start(objs) == RState.Running;
- }
- private bool FsmMonitorTransfer(object[] objs)
- {
- RState ret = _manualTransfer.Monitor();
- if (ret == RState.Failed || ret == RState.Timeout)
- {
- PostMsg(MSG.ERROR);
- return false;
- }
- return ret == RState.End;
- }
- private bool FsmStartReturnWafer(object[] objs)
- {
- //return _returnWafer.Start(objs) == RState.Running;
- return _AutoCycle.CheckManualReturnWafer() == RState.Running;
- }
- private bool FsmMonitorReturnWafer(object[] objs)
- {
- //RState ret = _returnWafer.Monitor();
- RState ret = _AutoCycle.ReturnAllWafers();
- if (ret == RState.Failed || ret == RState.Timeout)
- {
- PostMsg(MSG.ERROR);
- return false;
- }
- return ret == RState.End;
- }
- private bool FsmMap(object[] objs)
- {
- return true;
- }
- private bool FsmResetIdleCleanTime(object[] objs)
- {
- return true;
- }
- private bool FsmResetIdlePurgeTime(object[] objs)
- {
- return true;
- }
- private bool FsmAutoReturnWafer(object[] objs)
- {
- return _AutoCycle.ManualReturnWafer(objs);
- }
- private bool FsmMonitorAutoIdle(object[] objs)
- {
- RState ret = _AutoCycle.Monitor();
- //if (_AutoCycle.CheckAllJobDone())
- //{
- // if (!CheckToPostMessage((int)MSG.JobDone))
- // return false;
- //}
- //_isWaitUnload = (bool)DATA.Poll("LP1.NotifyJobDone") || (bool)DATA.Poll("LP2.NotifyJobDone");
- _debugRoutine();
- return ret == RState.End;
- }
- private bool FsmStartSetManualMode(object[] objs)
- {
- if (_AutoCycle.HasJobRunning)
- {
- LOG.Write(eEvent.WARN_ROUTER, "System", "Can not change to manual mode, abort running job first");
- return false;
- }
- return true;
- }
- private void _debugRoutine()
- {
- int flag = 0;
- // Test Home routine
- if (flag == 1)
- {
- PostMsg(MSG.HOME);
- }
- else if (flag == 2)
- {
- PostMsg(MSG.TMCycle);
- }
- else if (flag == 3)
- {
- PostMsg(MSG.SetAutoMode);
- }
- else if (flag == 4)
- {
- PostMsg(MSG.ReturnAllWafer);
- }
- else if (flag == 5)
- {
- PostMsg(MSG.StartJob, "CJ_Local_LP1");
- }
- }
- private bool FsmStartSETMCycle(object[] objs)
- {
- //return _seTMCycle.Start(objs) == RState.Running;
- return _AutoCycle.Start(objs) == RState.Running;
- }
- private bool FsmMonitorSETMCycle(object[] objs)
- {
- RState ret = _AutoCycle.Monitor();
- if (ret == RState.Failed || ret == RState.Timeout)
- {
- PostMsg(MSG.ERROR);
- return false;
- }
- return ret == RState.End;
- }
- private bool FsmStopSETMCycle(object[] objs)
- {
- _AutoCycle.Abort();
- return true;
- }
- private bool FsmStartCreateSEJob(object[] objs)
- {
- _AutoCycle.CreateJob((Dictionary<string, object>)objs[0], out string reason);
- return true;
- }
- private bool FsmStartSEJob(object[] objs)
- {
- //return _seTMCycle.StartJob(objs[0].ToString()) == RState.Running;
- return _AutoCycle.StartJob(objs[0].ToString(), out string reason);
- }
- private bool FsmSEJobMonitor(object[] objs)
- {
- RState ret = _AutoCycle.Monitor();
- return ret == RState.End;
- }
- //private bool FsmStartSEMoveWafer(object[] objs)
- //{
- // return _setransfer.Start(objs) == RState.Running;
- //}
- //private bool FsmMonitorSEMoveWafer(object[] objs)
- //{
- // RState ret = _setransfer.Monitor();
- // if (ret == RState.Failed || ret == RState.Timeout)
- // {
- // PostMsg(MSG.ERROR);
- // return false;
- // }
- // return ret == RState.End;
- //}
- //private bool FsmStartSEReturnWafer(object[] objs)
- //{
- // return _sereturnWafer.Start(objs) == RState.Running;
- //}
- //private bool FsmMonitorSEReturnWafer(object[] objs)
- //{
- // RState ret = _sereturnWafer.Monitor();
- // if (ret == RState.Failed || ret == RState.Timeout)
- // {
- // PostMsg(MSG.ERROR);
- // return false;
- // }
- // return ret == RState.End;
- //}
- private bool SEAbortJob(object[] objs)
- {
- _AutoCycle.AbortJob((string)objs[0], out var reason);
- return true;
- }
- private bool SEAbort(object[] objs)
- {
- //_seTMCycle.Abort();
- //_setransfer.Abort();
- //_sereturnWafer.Abort();
- //seTM.CheckToPostMessage((int)SETMEntity.MSG.Abort);
- return true;
- }
- #region Fa接口
- /// <summary>
- /// 接口指令
- /// </summary>
- /// <param name="command"></param>
- /// <param name="paras"></param>
- /// <param name="reason"></param>
- /// <returns></returns>
- public bool ExcuteCommand(string command, object[] paras, out string reason)
- {
- reason = "";
- switch (command.ToUpper())
- {
- case "PP-SELECT":
- if (RtInstance.ConfigType == ConfigType.Kepler2200)
- {
- return FaKepler2200CreateJob(paras, out reason);
- }
- else
- {
- return FaCreateJob(paras, out reason);
- }
- case "STARTJOB":
- //return FaStartJob(paras[0].ToString(), out reason);
- return CheckToPostMessage((int)MSG.StartEAPJob, paras);
- case "STOPJOB":
- return FaStopJob(paras[0].ToString(), out reason);
- case "ABORTJOB":
- return FaAbortob(paras[0].ToString(), out reason);
- case "PAUSEJOB":
- return FaPauseJob(paras[0].ToString(), out reason);
- case "RESUMEJOB":
- return FaResumeJob(paras[0].ToString(), out reason);
- case "MAPCASSETTE":
- return FaMapCassete(paras[0].ToString(), out reason);
- case "LOAD":
- return FaLoad(paras[0].ToString(), out reason);
- case "UNLOAD":
- return FaUnLoad(paras[0].ToString(), out reason);
- case "READID":
- return FaReadId(paras[0].ToString(), out reason);
- case "WRITEID":
- return FaWriteId(paras[0].ToString(), paras[1].ToString(), out reason);
- }
- return true;
- }
- /// <summary>
- /// Fa创建任务
- /// </summary>
- /// <param name="paras"></param>
- /// <param name="reason"></param>
- /// <returns></returns>
- private bool FaCreateJob(object[] paras, out string reason)
- {
- if (!CheckAuto())
- {
- reason = "System is not in Auto,cannot create job";
- return false;
- }
- else
- {
- Dictionary<string, object> createParams = new Dictionary<string, object>();
- createParams["Module"] = $"LP{paras[0]}";
- createParams["JobId"] = paras[1].ToString();
- createParams["LotId"] = paras[2].ToString();
- object[] tmpArys=(object[])paras[3];
- string[] strAry = new string[tmpArys.Length];
- for (int i = 0; i < tmpArys.Length; i++)
- {
- strAry[i] = tmpArys[i].ToString();
- }
-
-
- createParams["SlotSequence"] = strAry;
-
- createParams["AutoStart"] = true;
- if (paras.Length >= 5)
- {
- createParams["PreCleanRecipeName"] = paras[4].ToString();
- }
- if (paras.Length >= 6)
- {
- createParams["PostCleabRecipeName"] = paras[5].ToString();
- }
- return _AutoCycle.CreateJob(createParams, out reason);
- }
- }
- /// <summary>
- /// Fa创建任务
- /// </summary>
- /// <param name="paras"></param>
- /// <param name="reason"></param>
- /// <returns></returns>
- private bool FaKepler2200CreateJob(object[] paras, out string reason)
- {
- if (!CheckAuto())
- {
- reason = "System is not in Auto,cannot create job";
- return false;
- }
- else
- {
- Dictionary<string, object> createParams = new Dictionary<string, object>();
- createParams["Module"] = $"LP{paras[0]}";
- createParams["JobId"] = paras[1].ToString();
- createParams["LotId"] = paras[2].ToString();
- object[] tmpArys = (object[])paras[3];
- string[] strAry = new string[tmpArys.Length];
- if (SC.GetValue<int>("System.Job.PPSelectFoupMode") == 0)
- {
- for (int i = 0; i < tmpArys.Length; i++)
- {
- strAry[i] = tmpArys[tmpArys.Length - 1 - i].ToString();
- }
- }
- else
- {
- for (int i = 0; i < tmpArys.Length; i++)
- {
- strAry[i] = tmpArys[i].ToString();
- }
- }
- string[] stringWaferIds = new string[tmpArys.Length];
- //string lotType = "";
- if (paras.Length >= 5)
- {
- object[] waferIdArys = (object[])paras[4];
- if (RtInstance.ConfigType == ConfigType.Kepler2200 && SC.GetValue<int>("System.Job.PPSelectFoupMode") == 0)
- {
- for (int i = 0; i < waferIdArys.Length; i++)
- {
- stringWaferIds[i] = waferIdArys[waferIdArys.Length - 1 - i].ToString();
- }
- }
- else
- {
- for (int i = 0; i < waferIdArys.Length; i++)
- {
- stringWaferIds[i] = waferIdArys[i].ToString();
- }
- }
- }
- if (paras.Length >= 6)
- {
- createParams["LotType"] = paras[5].ToString();
- }
- createParams["SlotSequence"] = strAry;
- createParams["WaferId"] = stringWaferIds;
- createParams["AutoStart"] = true;
- return _AutoCycle.CreateJob(createParams, out reason);
- }
- }
- /// <summary>
- /// Fa启动任务
- /// </summary>
- /// <param name="jobName"></param>
- /// <param name="reason"></param>
- /// <returns></returns>
- private bool FaStartJob(string jobName, out string reason)
- {
- return _AutoCycle.StartJob(jobName, out reason);
- }
- /// <summary>
- /// Fa停止任务
- /// </summary>
- /// <param name="jobName"></param>
- /// <param name="reason"></param>
- /// <returns></returns>
- private bool FaStopJob(string jobName, out string reason)
- {
- return _AutoCycle.StopJob(jobName, out reason);
- }
- /// <summary>
- /// Fa中止任务
- /// </summary>
- /// <param name="jobName"></param>
- /// <param name="reason"></param>
- /// <returns></returns>
- private bool FaAbortob(string jobName, out string reason)
- {
- return _AutoCycle.AbortJob(jobName, out reason);
- }
- /// <summary>
- /// Fa暂停任务
- /// </summary>
- /// <param name="jobName"></param>
- /// <param name="reason"></param>
- /// <returns></returns>
- private bool FaPauseJob(string jobName, out string reason)
- {
- return _AutoCycle.PauseJob(jobName, out reason);
- }
- /// <summary>
- /// Fa恢复任务
- /// </summary>
- /// <param name="jobName"></param>
- /// <param name="reason"></param>
- /// <returns></returns>
- private bool FaResumeJob(string jobName, out string reason)
- {
- return _AutoCycle.ResumeJob(jobName, out reason);
- }
- /// <summary>
- /// Fa Load
- /// </summary>
- /// <param name="lp"></param>
- /// <returns></returns>
- private bool FaLoad(string lp, out string reason)
- {
- reason = "";
- //if (RtInstance.ConfigType == ConfigType.VenusSE || RtInstance.ConfigType == ConfigType.VenusDE)
- //{
- // VceEntity vce = GetVceEntity(lp, out reason);
- // return vce.CheckToPostMessage((int)VceMSG.SafeLoad);
- //}
- //else
- //{
- // Loadport loadport = FaGetLoadPort(lp, out reason);
- // if (loadport != null)
- // {
- // loadport.Load();
- // return true;
- // }
- // else
- // {
- // return false;
- // }
- //}
- Loadport loadport = FaGetLoadPort(lp, out reason);
- if (loadport != null)
- {
- loadport.Load();
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 获取VCE实体
- /// </summary>
- /// <param name="lp"></param>
- /// <param name="reason"></param>
- /// <returns></returns>
- //private VceEntity GetVceEntity(string lp, out string reason)
- //{
- // reason = "";
- // if (int.TryParse(lp, out var lpValue))
- // {
- // if (lpValue == 1)
- // {
- // return VCEA;
- // }
- // else
- // {
- // return VCEB;
- // }
- // }
- // else
- // {
- // reason = $"{lp} is invalid data";
- // return null;
- // }
- //}
- /// <summary>
- /// 获取LoadPort对象
- /// </summary>
- /// <param name="lp"></param>
- /// <param name="reason"></param>
- /// <returns></returns>
- private Loadport FaGetLoadPort(string lp, out string reason)
- {
- reason = "";
- if (int.TryParse(lp, out var lpValue))
- {
- LoadPortModule loadPortModule = EFEM.GetLoadportModule(lpValue);
- if (loadPortModule != null)
- {
- if (loadPortModule.LPDevice.HasCassette)
- {
- return loadPortModule.LPDevice;
- }
- else
- {
- reason = $"LP{lpValue} not found carrier, can not load";
- return null;
- }
- }
- else
- {
- reason = $"LP{lp} is null";
- return null;
- }
- }
- else
- {
- reason = $"{lp} is invalid data";
- return null;
- }
- }
- /// <summary>
- /// 读取Id
- /// </summary>
- /// <param name="lp"></param>
- /// <returns></returns>
- private bool FaMapCassete(string lp, out string reason)
- {
- reason = "";
- //if (RtInstance.ConfigType == ConfigType.VenusSE || RtInstance.ConfigType == ConfigType.VenusDE)
- //{
- // VceEntity vce = GetVceEntity(lp, out reason);
- // return vce.CheckToPostMessage((int)VceMSG.Map);
- //}
- //else
- //{
- // Loadport loadport = FaGetLoadPort(lp, out reason);
- // if (loadport != null)
- // {
- // loadport.Map();
- // return true;
- // }
- // else
- // {
- // return false;
- // }
- //}
- Loadport loadport = FaGetLoadPort(lp, out reason);
- if (loadport != null)
- {
- loadport.Map();
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 读取Id
- /// </summary>
- /// <param name="lp"></param>
- /// <returns></returns>
- private bool FaReadId(string lp, out string reason)
- {
- reason = "";
- if (RtInstance.ConfigType == ConfigType.VenusSE || RtInstance.ConfigType == ConfigType.VenusDE)
- {
- reason = "VCE device not support readId Command";
- return false;
- }
- else
- {
- Loadport loadport = FaGetLoadPort(lp, out reason);
- if (loadport != null)
- {
- loadport.ReadCarrierID();
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- /// <summary>
- /// 读取Id
- /// </summary>
- /// <param name="lp"></param>
- /// <returns></returns>
- private bool FaWriteId(string lp, string carrierId, out string reason)
- {
- reason = "";
- if (RtInstance.ConfigType == ConfigType.VenusSE || RtInstance.ConfigType == ConfigType.VenusDE)
- {
- reason = "VCE device not support readId Command";
- return false;
- }
- else
- {
- Loadport loadport = FaGetLoadPort(lp, out reason);
- if (loadport != null)
- {
- loadport.WriteCarrierID(carrierId);
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- /// <summary>
- /// Fa Unload
- /// </summary>
- /// <param name="lp"></param>
- /// <returns></returns>
- private bool FaUnLoad(string lp, out string reason)
- {
- reason = "";
- Loadport loadport = FaGetLoadPort(lp, out reason);
- if (loadport!=null && !loadport.IsLoaded)
- {
- var dvid = new SerializableDictionary<string, string>
- {
- ["CarrierID"] = loadport.CarrierId ?? "",
- ["PortID"] = loadport.PortId.ToString()
- };
- EV.Notify("CARRIER_UNLOADED", dvid);
- }
- //if (RtInstance.ConfigType == ConfigType.VenusSE || RtInstance.ConfigType == ConfigType.VenusDE)
- //{
- // VceEntity vce = GetVceEntity(lp, out reason);
- // return vce.CheckToPostMessage((int)VceMSG.SafeUnload);
- //}
- //else
- //{
- // if (loadport != null)
- // {
- // loadport.Unload();
- // return true;
- // }
- // else
- // {
- // return false;
- // }
- //}
- if (loadport != null)
- {
- loadport.Unload();
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 获取所有Sequence
- /// </summary>
- /// <returns></returns>
- public string[] GetSequenceList()
- {
- return RecipeFileManager.Instance.GetSequenceNameList().ToArray();
- }
- public string GetSequenceBody(string ppid)
- {
- return RecipeFileManager.Instance.GetSequence(ppid, false);
- }
- public List<string> GetFormatedSequence(string ppid)
- {
- List<string> result = new List<string>();
- string reason = string.Empty;
- try
- {
- string content = "";
- if (ppid.StartsWith("PMA") || ppid.StartsWith("PMB") || ppid.StartsWith("PMC") || ppid.StartsWith("PMD"))
- {
- string[] info = ppid.Split('\\');
- if (info.Length > 1)
- {
- var item = RecipeFileManager.Instance.LoadEAPRecipe(info[0], info[1], false);
- JObject jObject = JObject.Parse(item);
- XmlDocument xmlDocument = new XmlDocument();
- xmlDocument.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\" ?><Root></Root>");
- XmlNode root = xmlDocument.SelectSingleNode("Root");
- AddJObjectToXmlNode(jObject, root);
- content = xmlDocument.InnerXml;
- //File.WriteAllText("Test.xml", content,Encoding.UTF8);
- }
- }
- else
- {
- content = RecipeFileManager.Instance.GetSequence(ppid, false);
- }
- result.Add(content);
- }
- catch (Exception ex)
- {
- reason = ex.Message;
- }
- return result;
- }
- private void AddJObjectToXmlNode(JObject jObject, XmlNode parent)
- {
- foreach (var property in jObject.Properties())
- {
- var name = property.Name;
- var value = property.Value;
- if (value is JArray)
- {
- foreach (var item in (JArray)value)
- {
- if (item is JObject)
- {
- var objectElement = parent.OwnerDocument.CreateElement(name);
- parent.AppendChild(objectElement);
- AddJObjectToXmlNode((JObject)item, objectElement);
- }
- else
- {
- var textElement = parent.OwnerDocument.CreateElement(name);
- textElement.InnerText = item.ToString();
- parent.AppendChild(textElement);
- }
- }
- }
- else if (value is JObject)
- {
- var objectElement = parent.OwnerDocument.CreateElement(name);
- parent.AppendChild(objectElement);
- AddJObjectToXmlNode((JObject)value, objectElement);
- }
- else
- {
- var textElement = parent.OwnerDocument.CreateElement(name);
- textElement.InnerText = value.ToString();
- parent.AppendChild(textElement);
- }
- }
- }
- public bool deleteSequence(string ppid)
- {
- return false;
- //return RecipeFileManager.Instance.DeleteSequence(ppid);
- }
- public bool UpdateSequence(string ppid, string body)
- {
- return false;
- //return RecipeFileManager.Instance.SaveSequence(ppid, body, false);
- }
- public void ShowTerminalMessage(string message)
- {
- }
- public bool CreateProcessJob(string processJobId, string sequenceName, string carrierId, out string reason)
- {
- reason = "";
- return true;
- }
- public void UpdateProcessJobCarrierSlot(string processJobId, string moduleName, List<int> slots)
- {
- }
- public void CreateControlJob(string controlJobId, string carrierId, List<string> processJobs)
- {
- }
- public bool CheckCreateControlJobCondition(List<string> modules, out string reason)
- {
- reason = "";
- return true;
- }
- public bool StartControlJob(string controlJob)
- {
- return true;
- }
- public bool StopControlJob(string controlJob)
- {
- return true;
- }
- public bool AbortControlJob(string controlJob)
- {
- return true;
- }
- public bool PauseControlJob(string controlJob)
- {
- return true;
- }
- public bool ResumeControlJob(string controlJob)
- {
- return true;
- }
- public bool CheckAuto()
- {
- return fsm.State == (int)RtState.AutoIdle || fsm.State == (int)RtState.AutoRunning;
- }
- public void UpdateControlJobModule(string controlJobId, string moduleName)
- {
- }
- /// <summary>
- /// 告警日志
- /// </summary>
- /// <param name="message"></param>
- public void WriteWarningLog(string message)
- {
- LOG.Write(eEvent.WARN_FA, ModuleName.System, message);
- }
- /// <summary>
- /// 错误日志
- /// </summary>
- /// <param name="message"></param>
- public void WriteErrorLog(string message)
- {
- LOG.Write(eEvent.ERR_FA, ModuleName.System, message);
- }
- /// <summary>
- /// 正常日志
- /// </summary>
- /// <param name="message"></param>
- public void WriteInfoLog(string message)
- {
- LOG.Write(eEvent.INFO_FA, ModuleName.System, message);
- }
- /// <summary>
- /// 检验Secsgem在线情况
- /// </summary>
- /// <param name="controlState"></param>
- /// <returns></returns>
- private bool CheckSecsGemOnline(SecsGem.Core.EnumData.ControlState controlState)
- {
- if (controlState == SecsGem.Core.EnumData.ControlState.OnlineLocal || controlState == SecsGem.Core.EnumData.ControlState.OnlineRemote)
- {
- return true;
- }
- return false;
- }
- #endregion
- }
- }
|