123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- 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.Log;
- using Aitex.Core.RT.OperationCenter;
- using Aitex.Core.RT.RecipeCenter;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.Util;
- using Aitex.Core.Utilities;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.SubstrateTrackings;
- using MECF.Framework.RT.Core.Applications;
- using MECF.Framework.RT.Core.IoProviders;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
- using MECF.Framework.RT.ModuleLibrary.Commons;
- using MECF.Framework.RT.ModuleLibrary.EfemModules;
- using MECF.Framework.RT.ModuleLibrary.LPModules;
- using MECF.Framework.RT.ModuleLibrary.SystemModules.Routines;
- using SecsGem.Core.Application;
- namespace MECF.Framework.RT.ModuleLibrary.SystemModules
- {
- public enum RtState
- {
- Init,
- Initializing,
- Idle,
- Transfer,
- AutoRunning,
- AutoIdle,
- ReturnAllWafer,
- TMCycling,
- TMCyclePaused,
- Error,
- }
- public class EquipmentManager : FsmDevice, IEquipmentCommand
- {
- public enum MSG
- {
- MoveWafer,
- ReturnAllWafer,
- TMCycleStart,
- TMCyclePause,
- TMCycleResume,
- Stop,
- HOME,
- RESET,
- ABORT,
- ERROR,
- ToInit,
- SetAutoMode,
- SetManualMode,
- ResetIdleCleanTime,
- ResetIdlePurgeTime,
- FAJobCommand,
- CreateJob,
- PauseJob,
- ResumeJob,
- StartJob,
- StopJob,
- AbortJob,
- JobDone,
- ModuleError,
- Map,
- }
- public static Dictionary<ModuleName, ModuleFsmDevice> Modules { get; set; }
- public bool IsAutoIdle
- {
- get
- {
- return FsmState == (int)RtState.AutoIdle;
- }
- }
- public bool IsAutoMode
- {
- get
- {
- return FsmState == (int)RtState.AutoRunning || FsmState == (int)RtState.AutoIdle;
- }
- }
- public bool IsInit
- {
- get { return FsmState == (int)RtState.Init; }
- }
- public bool IsIdle
- {
- get { return FsmState == (int)RtState.Idle; }
- }
- public bool IsAlarm
- {
- get { return FsmState == (int)RtState.Error; }
- }
- public bool IsRunning
- {
- get
- {
- return !IsAlarm && !IsIdle && !IsInit && (FsmState != (int)RtState.AutoIdle);
- }
- }
- private bool _isInited;
- protected IRoutine _manualTransfer;
- protected IAutoTransfer _auto;
- protected IRoutine _homeAll;
- protected IRoutine _returnAll;
- protected IRoutine _tmCycle;
- private List<string> _modules;
- public EquipmentManager()
- {
- Module = "System";
- Name = "System";
- Modules = new Dictionary<ModuleName, ModuleFsmDevice>();
- _modules = new List<string>() { "System" };
- }
- public override bool Initialize()
- {
- InitDevices();
- InitModules();
- EnumLoop<RtState>.ForEach((item) =>
- {
- MapState((int)item, item.ToString());
- });
- EnumLoop<MSG>.ForEach((item) =>
- {
- MapMessage((int)item, item.ToString());
- });
- EnableFsm(100, RtState.Init);
- BuildTransitionTable();
- SubscribeDataVariable();
- SubscribeOperation();
- InitRoutine();
- Singleton<EventManager>.Instance.OnAlarmEvent += Instance_OnAlarmEvent;
- return true;
- }
- protected void BuildModules(params ModuleFsmDevice[] modules)
- {
- if (modules != null && modules.Length > 0)
- {
- foreach (var moduleFsmDevice in modules)
- {
- Modules[ModuleHelper.Converter(moduleFsmDevice.Module)] = moduleFsmDevice;
- }
- foreach (var modulesKey in Modules.Keys)
- {
- _modules.Add(modulesKey.ToString());
- }
- foreach (var modulesValue in Modules.Values)
- {
- if (modulesValue.Module != ModuleName.TM.ToString() && modulesValue.Module != ModuleName.EFEM.ToString())
- {
- if (!SC.GetValue<bool>($"System.SetUp.{modulesValue.Module}.IsInstalled"))
- {
- continue;
- }
- }
- modulesValue.Initialize();
- }
- }
- }
- protected virtual void InitRoutine()
- {
- }
- protected virtual void InitModules()
- {
- }
- protected virtual void InitDevices()
- {
- }
- //private PeriodicJob _job1;
- //Stopwatch _sw = new Stopwatch();
- //private bool OnJob1()
- //{
- // _sw.Restart();
- // BufferModule buffer = Modules[ModuleName.Buffer] as BufferModule;
- // if (!buffer.CheckToPostMessage(BufferModule.MSG.InTransfer))
- // {
- // System.Diagnostics.Trace.Assert(false)
- // System.Diagnostics.Trace.WriteLine("fail to in transfer");
- // }
- // if (buffer.IsIdle)
- // {
- // System.Diagnostics.Trace.Assert(false);
- // System.Diagnostics.Trace.WriteLine("!!!==========>IsIdle");
- // }
- // //System.Diagnostics.Trace.Assert(buffer.IsIdle, $"in {buffer.StringFsmStatus}");
- // while (buffer.IsIdle)
- // {
- // Thread.Sleep(5);
- // }
- // //buffer.NoteTransferStop(ModuleName.EfemRobot, Hand.Blade1, 0, EnumTransferType.Place);
- // //Thread.Sleep(15);
- // if (!buffer.CheckToPostMessage(BufferModule.MSG.TransferComplete))
- // {
- // System.Diagnostics.Trace.Assert(false);
- // System.Diagnostics.Trace.WriteLine("fail to complete");
- // }
- // //if (!buffer.IsIdle)
- // //{
- // // System.Diagnostics.Trace.WriteLine("not idle");
- // //}
- // System.Diagnostics.Trace.WriteLine($" === {_sw.ElapsedMilliseconds}");
- // while (!buffer.IsIdle)
- // {
- // Thread.Sleep(5);
- // }
- // 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);
- Transition(RtState.Error, MSG.ToInit, null, RtState.Init);
- Transition(RtState.Initializing, FSM_MSG.TIMER, FsmMonitorHome, RtState.Idle);
- Transition(RtState.Initializing, MSG.ERROR, fError, RtState.Error);
- Transition(RtState.Initializing, MSG.ABORT, FsmAbort, RtState.Init);
- //Reset
- AnyStateTransition(MSG.RESET, fStartReset, RtState.Idle);
- AnyStateTransition(MSG.ERROR, fError, RtState.Error);
- AnyStateTransition((int)FSM_MSG.ALARM, fError, (int)RtState.Error);
- //Auto/manual sequence
- Transition(RtState.Idle, MSG.SetAutoMode, fStartAutoTransfer, RtState.AutoIdle);
- Transition(RtState.AutoRunning, FSM_MSG.TIMER, fAutoTransfer, RtState.AutoRunning);
- Transition(RtState.AutoRunning, MSG.ABORT, FsmAbort, RtState.AutoIdle);
- Transition(RtState.AutoRunning, MSG.JobDone, null, RtState.AutoIdle);
- Transition(RtState.AutoRunning, MSG.CreateJob, FsmCreateJob, RtState.AutoRunning);
- //Transition(RtState.AutoRunning, MSG.FAJobCommand, FsmFAJobCommand, 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.ModuleError, FsmModuleError, 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);
- EnterExitTransition<RtState, FSM_MSG>(RtState.AutoRunning, null, FSM_MSG.NONE, fExitAutoTransfer);
- Transition(RtState.AutoIdle, FSM_MSG.TIMER, FsmMonitorAutoIdle, RtState.AutoIdle);
- //Transition(RtState.AutoIdle, MSG.FAJobCommand, FsmFAJobCommand, 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.ABORT, FsmAbort, RtState.AutoIdle);
- Transition(RtState.AutoIdle, MSG.AbortJob, FsmAbortJob, RtState.AutoIdle);
- Transition(RtState.AutoIdle, MSG.Map, FsmMap, RtState.AutoIdle);
- Transition(RtState.AutoIdle, MSG.ResetIdleCleanTime, FsmResetIdleCleanTime, RtState.AutoIdle);
- Transition(RtState.AutoIdle, MSG.ResetIdlePurgeTime, FsmResetIdlePurgeTime, RtState.AutoIdle);
- //return all wafer
- Transition(RtState.Idle, MSG.ReturnAllWafer, FsmStartReturnAllWafer, RtState.ReturnAllWafer);
- Transition(RtState.ReturnAllWafer, FSM_MSG.TIMER, FsmMonitorReturnAllWafer, RtState.Idle);
- Transition(RtState.ReturnAllWafer, MSG.ABORT, FsmAbortReturnAllWafer, RtState.Idle);
- //return all wafer
- Transition(RtState.Idle, MSG.TMCycleStart, FsmStartTMCycle, RtState.TMCycling);
- Transition(RtState.TMCycling, MSG.TMCyclePause, null, RtState.TMCyclePaused);
- Transition(RtState.TMCyclePaused, MSG.TMCycleResume, null, RtState.TMCycling);
- Transition(RtState.TMCycling, FSM_MSG.TIMER, FsmMonitorTMCycle, RtState.Idle);
- Transition(RtState.TMCycling, MSG.ABORT, FsmAbortTMCycle, RtState.Idle);
- //Transfer sequence
- Transition(RtState.Idle, MSG.MoveWafer, fStartTransfer, RtState.Transfer);
- Transition(RtState.Transfer, FSM_MSG.TIMER, fTransfer, RtState.Idle);
- Transition(RtState.Transfer, MSG.ABORT, FsmAbort, RtState.Idle);
- EnterExitTransition<RtState, FSM_MSG>(RtState.Transfer, null, FSM_MSG.NONE, fExitTransfer);
- }
- void SubscribeDataVariable()
- {
- DATA.Subscribe("Rt.Status", () => StringFsmStatus);
- DATA.Subscribe("System.IsIdle", () => IsIdle || IsInit|| IsAutoIdle);
- DATA.Subscribe("System.IsAlarm", () => IsAlarm);
- DATA.Subscribe("System.IsBusy", () => IsRunning);
- DATA.Subscribe("System.IsAutoRunning", () => IsRunning);
- DATA.Subscribe("System.IsAutoMode", () => IsAutoMode);
- DATA.Subscribe("System.IsConnectedWithHost", () => CheckSecsGemOnline(Singleton<SecGemApplication>.Instance.ControlState));
- DATA.Subscribe("System.IsDisconnectWithHost", () => CheckSecsGemOnline(Singleton<SecGemApplication>.Instance.ControlState));
- DATA.Subscribe("System.Modules", () => _modules);
- DATA.Subscribe("System.EquipmentMode", () => IsAutoMode ? 0 : 1, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe("System.EquipmentStatus", () =>
- {
- //"0 = Uninit
- //1 = Idle
- //2 = Running
- //3 = Error
- //4 = Pause
- //"
- if (IsInit) return 0;
- if (IsIdle) return 1;
- if (IsAlarm) return 3;
- return 2;
- }, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- }
- /// <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;
- }
- void SubscribeOperation()
- {
- OP.Subscribe("Create8InchWafer", InvokeCreate8InchWafer);
- OP.Subscribe("Create12InchWafer", InvokeCreate12InchWafer);
- OP.Subscribe("CreateWafer", InvokeCreateWafer);
- OP.Subscribe("DeleteWafer", InvokeDeleteWafer);
- OP.Subscribe("ReturnWafer", InvokeReturnWafer);
- OP.Subscribe("System.ReturnAllWafer", (string cmd, object[] args) =>
- {
- return CheckToPostMessage((int)MSG.ReturnAllWafer, args);
- });
- OP.Subscribe("System.TMCycleStart", (string cmd, object[] args) =>
- {
- return CheckToPostMessage((int)MSG.TMCycleStart, args);
- });
- OP.Subscribe("System.TMCyclePause", (string cmd, object[] args) =>
- {
- return CheckToPostMessage((int)MSG.TMCyclePause);
- });
- OP.Subscribe("System.TMCycleResume", (string cmd, object[] args) =>
- {
- return CheckToPostMessage((int)MSG.TMCycleResume);
- });
- 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.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 (args.Length > 8)
- {
- return CheckToPostMessage((int)MSG.MoveWafer, source, (int)args[1], destination, (int)args[3],
- (bool)args[4], (int)args[5], (bool)args[6], (int)args[7]);
- }
- else if (args.Length > 5)
- {
- return CheckToPostMessage((int)MSG.MoveWafer, source, (int)args[1], destination, (int)args[3], (bool)args[4]);
- }
- return CheckToPostMessage((int)MSG.MoveWafer, source, (int)args[1], destination, (int)args[3]);
- });
- 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) =>
- {
- bool result= CheckToPostMessage((int)MSG.PauseJob, args[0]);
- //if(result)
- //{
- // OP.DoOperation("E94PauseJob",args);
- //}
- return result;
- });
- OP.Subscribe("System.ResumeJob", (string cmd, object[] args) =>
- {
- bool result = CheckToPostMessage((int)MSG.ResumeJob, args[0]);
- //if(result)
- //{
- // OP.DoOperation("E94ResumeJob", args);
- //}
- return result;
- });
- OP.Subscribe("System.StopJob", (string cmd, object[] args) =>
- {
- bool result= CheckToPostMessage((int)MSG.StopJob, args[0]);
- //if(result)
- //{
- // OP.DoOperation("E94StopJob", args);
- //}
- return result;
- });
- OP.Subscribe("System.AbortJob", (string cmd, object[] args) =>
- {
- bool result= CheckToPostMessage((int)MSG.AbortJob, args[0]);
- //if(result)
- //{
- // OP.DoOperation("E94AbortJob", args);
- //}
- return result;
- });
- OP.Subscribe("System.ShutDown", InvokeShutDown);
- OP.Subscribe("System.MapWafer", InvokeEfemMap);
- OP.Subscribe("System.LP1.Map", (string cmd, object[] args) =>
- {
- if (IsAutoMode)
- {
- return CheckToPostMessage((int)MSG.Map, ModuleName.LP1.ToString());
- }
- return false;
- });
- OP.Subscribe("System.LP2.Map", (string cmd, object[] args) =>
- {
- if (IsAutoMode)
- {
- return CheckToPostMessage((int)MSG.Map, ModuleName.LP2.ToString());
- }
- return false;
- });
- OP.Subscribe("System.LP3.Map", (string cmd, object[] args) =>
- {
- if (IsAutoMode)
- {
- return CheckToPostMessage((int)MSG.Map, ModuleName.LP3.ToString());
- }
- return false;
- });
- }
- private void Instance_OnAlarmEvent(EventItem obj)
- {
- }
- #region Init
- private bool FsmStartHome(object[] objs)
- {
- _isInited = false;
- return _homeAll.Start() == Result.RUN;
- }
- private bool FsmMonitorHome(object[] objs)
- {
- Result ret = _homeAll.Monitor();
- if (ret == Result.DONE)
- {
- _isInited = true;
- return true;
- }
- if (ret == Result.FAIL)
- {
- PostMsg(MSG.ERROR);
- }
- return false;
- }
- private bool fError(object[] objs)
- {
- if (FsmState == (int)RtState.Transfer)
- {
- }
- return true;
- }
- #endregion
- #region AutoTransfer
- private bool FsmMonitorAutoIdle(object[] param)
- {
- //fMonitorFAJob(param);
- //return true;
- Result ret = _auto.Monitor();
- if (!_auto.CheckAllJobDone())
- {
- return false;
- }
- return ret == Result.DONE;
- }
- private bool FsmStartSetManualMode(object[] objs)
- {
- if (_auto.HasJobRunning)
- {
- EV.PostWarningLog("System", "Can not change to manual mode, abort running job first");
- return false;
- }
- return true;
- }
- private bool fStartAutoTransfer(object[] objs)
- {
- Result ret = _auto.Start(objs);
- return ret == Result.RUN;
- }
- private bool fAutoTransfer(object[] objs)
- {
- //fMonitorFAJob(objs);
- Result ret = _auto.Monitor();
- if (_auto.CheckAllJobDone())
- {
- if (!CheckToPostMessage((int)MSG.JobDone))
- return false;
- }
- return ret == Result.DONE;
- }
- private bool fExitAutoTransfer(object[] objs)
- {
- return true;
- }
- private bool fAbortAutoTransfer(object[] objs)
- {
- return true;
- }
- #endregion
- #region return all wafer
- private bool FsmAbortReturnAllWafer(object[] param)
- {
- _returnAll.Abort();
- return true;
- }
- private bool FsmMonitorReturnAllWafer(object[] param)
- {
- return _returnAll.Monitor() == Result.DONE;
- }
- private bool FsmStartReturnAllWafer(object[] param)
- {
- return _returnAll.Start(param) == Result.RUN;
- }
- #endregion
- #region return all wafer
- private bool FsmAbortTMCycle(object[] param)
- {
- _tmCycle.Abort();
- return true;
- }
- private bool FsmMonitorTMCycle(object[] param)
- {
- return _tmCycle.Monitor() == Result.DONE;
- }
- private bool FsmStartTMCycle(object[] param)
- {
- return _tmCycle.Start(param) == Result.RUN;
- }
- #endregion
- #region Transfer
- private bool fStartTransfer(object[] objs)
- {
- Result ret = _manualTransfer.Start(objs);
- if (ret == Result.FAIL || ret == Result.DONE)
- return false;
- return ret == Result.RUN;
- }
- private bool fTransfer(object[] objs)
- {
- Result ret = _manualTransfer.Monitor();
- if (ret == Result.FAIL)
- {
- PostMsg(MSG.ERROR);
- return false;
- }
- return ret == Result.DONE;
- }
- private bool fExitTransfer(object[] objs)
- {
- return true;
- }
- private bool fAbortTransfer(object[] objs)
- {
- return true;
- }
- #endregion
- #region reset
- private bool fStartReset(object[] objs)
- {
- EV.ClearAlarmEvent();
- //Singleton<DeviceEntity>.Instance.PostMsg(DeviceEntity.MSG.RESET);
- IoProviderManager.Instance.Reset();
- foreach (var modulesValue in Modules.Values)
- {
- if (modulesValue.Module != ModuleName.TM.ToString() &&
- modulesValue.Module != ModuleName.EFEM.ToString() &&
- !SC.GetValue<bool>($"System.SetUp.{modulesValue.Module}.IsInstalled"))
- continue;
- modulesValue.Reset();
- }
- if (FsmState == (int)RtState.Error)
- {
- if (!_isInited)
- {
- PostMsg(MSG.ToInit);
- return false;
- }
- return true;
- }
- return false;
- }
- #endregion
- private bool FsmCreateJob(object[] param)
- {
- _auto.CreateJob((Dictionary<string, object>)param[0]);
- return true;
- }
- private bool FsmAbortJob(object[] param)
- {
- _auto.AbortJob((string)param[0]);
- return true;
- }
- private bool FsmStopJob(object[] param)
- {
- _auto.StopJob((string)param[0]);
- //CheckToPostMessage((int)MSG.StopJob);//
- return true;
- }
- private bool FsmResumeJob(object[] param)
- {
- _auto.ResumeJob((string)param[0]);
- return true;
- }
- private bool FsmPauseJob(object[] param)
- {
- _auto.PauseJob((string)param[0]);
- return true;
- }
- private bool FsmStartJob(object[] param)
- {
- return _auto.StartJob((string)param[0]);
- }
- private bool FsmAbort(object[] param)
- {
- if (FsmState == (int)RtState.Transfer)
- {
- // _manualTransfer.Clear();
- }
- if (FsmState == (int)RtState.AutoRunning || FsmState == (int)RtState.AutoIdle)
- {
- _auto.Clear();
- }
- if (FsmState == (int)RtState.Initializing)
- {
- _homeAll.Abort();
- }
- return true;
- }
- private bool FsmModuleError(object[] param)
- {
- _auto.ModuleError((string)param[0]);
- return true;
- }
- private bool FsmMap(object[] param)
- {
- _auto.Map((string)param[0]);
- return true;
- }
- private bool FsmResetIdlePurgeTime(object[] param)
- {
- _auto.ResetIdlePurgeTime((string)param[0]);
- return true;
- }
- private bool FsmResetIdleCleanTime(object[] param)
- {
- _auto.ResetIdleCleanTime((string)param[0]);
- return true;
- }
- private bool InvokeReturnWafer(string arg1, object[] args)
- {
- ModuleName target = ModuleHelper.Converter(args[0].ToString());
- int slot = (int)args[1];
- if (ModuleHelper.IsLoadPort(target))
- {
- EV.PostInfoLog("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))
- {
- EV.PostWarningLog("System", string.Format("Invalid position,{0},{1}", target.ToString(), slot.ToString()));
- return false;
- }
- WaferInfo wafer = WaferManager.Instance.GetWafer(target, slot);
- if (wafer.IsEmpty)
- {
- EV.PostInfoLog("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);
- }
- 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
- {
- 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 = ModuleHelper.Converter(args[0].ToString());
- int slot = (int)args[1];
- WaferStatus state = WaferStatus.Normal;
- //if (ModuleHelper.IsLoadPort(chamber))
- //{
- // var lp = Modules[chamber] as LoadPortModule;
- // if (lp.LPDevice.CassetteState != LoadportCassetteState.Normal)
- // {
- // EV.PostWarningLog("System", $"Can not create wafer at {chamber}.{slot + 1}, Cassette not placed.");
- // return false;
- // }
- //}
- WaferSize ws = WaferSize.WS0;
- switch (SC.GetValueOrDefault<int>("System.DefaultCreateWaferSize"))
- {
- case 0:
- ws = WaferSize.WS0;
- break;
- case 4:
- ws = WaferSize.WS4;
- break;
- case 6:
- ws = WaferSize.WS6;
- break;
- case 8:
- ws = WaferSize.WS8;
- break;
- case 12:
- ws = WaferSize.WS12;
- break;
- }
- if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slot))
- {
- var wafer = WaferManager.Instance.GetWafer(chamber,slot);
- if(wafer != null && !wafer.IsEmpty)
- {
- EV.PostInfoLog("System", string.Format("{0} slot {1} already has wafer.create wafer is not valid", chamber, slot));
- }
- else if (WaferManager.Instance.CreateWafer(chamber, slot, state, ws) != 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;
- }
- private bool InvokeCreate8InchWafer(string arg1, object[] args)
- {
- ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
- int slot = (int)args[1];
- WaferStatus state = WaferStatus.Normal;
- //if (ModuleHelper.IsLoadPort(chamber))
- //{
- // var lp = Modules[chamber] as LoadPortModule;
- // if (lp.LPDevice.CassetteState != LoadportCassetteState.Normal)
- // {
- // EV.PostWarningLog("System", $"Can not create wafer at {chamber}.{slot + 1}, Cassette not placed.");
- // return false;
- // }
- //}
- 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 (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;
- }
- private bool InvokeCreate12InchWafer(string arg1, object[] args)
- {
- ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
- int slot = (int)args[1];
- WaferStatus state = WaferStatus.Normal;
- //if (ModuleHelper.IsLoadPort(chamber))
- //{
- // var lp = Modules[chamber] as LoadPortModule;
- // if (lp.LPDevice.CassetteState != LoadportCassetteState.Normal)
- // {
- // EV.PostWarningLog("System", $"Can not create wafer at {chamber}.{slot + 1}, Cassette not placed.");
- // return false;
- // }
- //}
- 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 (WaferManager.Instance.CreateWafer(chamber, slot, state, WaferSize.WS12) != 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;
- }
- private bool InvokeShutDown(string arg1, object[] arg2)
- {
- if (IsAlarm || IsIdle || IsInit)
- {
- EV.PostWarningLog(Module, $"System start shut down");
- EV.PostKickoutMessage("ShutDown");
- RtApplication.Instance.Terminate();
- return true;
- }
- EV.PostWarningLog(Module, $"System in {StringFsmStatus} mode, can not shut down");
- return false;
- }
- private bool InvokeEfemMap(string arg1, object[] arg2)
- {
- ModuleName target = ModuleHelper.Converter((string)arg2[0]);
- if (!ModuleHelper.IsLoadPort(target))
- {
- EV.PostWarningLog("System", $"Invalid map target {target}");
- return false;
- }
- for (int i = 0; i < 25; i++)
- {
- WaferInfo wafer = WaferManager.Instance.GetWafer(target, i);
- if (wafer.IsEmpty)
- continue;
- if (wafer.ProcessState == EnumWaferProcessStatus.Completed ||
- wafer.ProcessState == EnumWaferProcessStatus.Failed)
- {
- EV.PostWarningLog("System", $"{target} wafer is processed, can not map again");
- return false;
- }
- }
- if (IsAutoMode)
- {
- _auto.Map((string)arg2[0]);
- return true;
- }
- //EfemModule efem = Modules[ModuleName.EfemRobot] as EfemModule;
- //if (!efem.Map(ModuleHelper.Converter((string) arg2[0]), out string reason))
- //{
- // EV.PostWarningLog(Module, reason);
- //}
- return true;
- }
- private void OnModuleError(string module)
- {
- if (FsmState == (int)RtState.AutoRunning)
- {
- ModuleName mod = ModuleHelper.Converter(module);
- PostMsg(MSG.ModuleError, module);
- }
- }
- public override void Monitor()
- {
- base.Monitor();
- }
- string sourceModule = "";
- #region control job /process job nnotation
- /*
- private bool fMonitorFAJob(object[] param)
- {
- //Singleton<FAJobController>.Instance.MonitorJob();
- E40ProcessJob[] pjs = Singleton<FAJobController>.Instance.FAProcessJobs.Values.ToArray();
- E94ControlJob[] cjs = Singleton<FAJobController>.Instance.FAControlJobs.Values.ToArray();
- foreach (var pj in pjs)
- {
- if ((pj.PJstate == ProcessJobState.NONE || pj.PJstate == ProcessJobState.PROCESS_COMPLETE)
- && Singleton<FAJobController>.Instance.FAProcessJobs.ContainsKey(pj.ObjtID))
- Singleton<FAJobController>.Instance.FAProcessJobs.Remove(pj.ObjtID);
- if (pj.PJstate == ProcessJobState.ABORTING)
- Singleton<FAJobController>.Instance.FAProcessJobs[pj.ObjtID].PJAborted();
- if (pj.PJstate == ProcessJobState.ABORTED)
- Singleton<FAJobController>.Instance.FAProcessJobs.Remove(pj.ObjtID);
- }
- foreach (var cj in cjs)
- {
- if ((cj.state == ControlJobState.NONE || cj.state == ControlJobState.COMPLETED)
- && Singleton<FAJobController>.Instance.FAControlJobs.ContainsKey(cj.ObjtID))
- Singleton<FAJobController>.Instance.FAControlJobs.Remove(cj.ObjtID);
- }
- if (Singleton<FAJobController>.Instance.FAProcessJobs.Count == 0) return true;
- if (Singleton<FAJobController>.Instance.FAControlJobs.Count == 0) return true;
- foreach (var pj in pjs)
- {
- if (pj.PJstate == ProcessJobState.POOLED)
- {
- foreach (var mtrlname in pj.PRMtlNameList)
- {
- string lp = CarrierManager.Instance.GetLocationByCarrierId(mtrlname.CarrierID);
- if (lp == null)
- continue;
- if (Singleton<FAJobController>.Instance.FAloadports[lp].GetCarrierIDStatus() == CarrierIDStatus.ID_VERIFICATION_OK &&
- Singleton<FAJobController>.Instance.FAloadports[lp].GetSlotMapStatus() == SlotMapStatus.SLOT_MAP_VERIFICATION_OK)
- {
- pj.MaterialPresentAndResourceReady();
- AssignProcessJob(mtrlname, pj.RecID, pj.PRRecipeMethod, pj.RecVariableList, pj.ObjtID);
- }
- }
- }
- }
- foreach (var cj in cjs)
- {
- if (cj.state == ControlJobState.QUEUED)
- {
- bool allPjSetUp = true;
- cj.MtrlOutSpec = new List<MtrlOutSpecPair>();
- foreach (var pj in cj.ProcessingCtrlSpec)
- {
- if (!Singleton<FAJobController>.Instance.FAProcessJobs.ContainsKey(pj))
- {
- allPjSetUp = false;
- break;
- }
- if (Singleton<FAJobController>.Instance.FAProcessJobs[pj].PJstate != ProcessJobState.SETTING_UP)
- {
- allPjSetUp = false;
- break;
- }
- foreach (var PRMtl in Singleton<FAJobController>.Instance.FAProcessJobs[pj].PRMtlNameList)
- {
- cj.MtrlOutSpec.Add(new MtrlOutSpecPair() { sourceCarID = PRMtl.CarrierID, DestCarID = PRMtl.CarrierID, sourceSlots = PRMtl.SlotID, destSlots = PRMtl.SlotID });
- }
- }
- if (allPjSetUp)
- {
- cj.ProcessResourceReady();
- }
- }
- if (cj.MtrlOutSpec == null || cj.MtrlOutSpec.Count == 0)
- continue;
- //string sourceModule = "";
- //检查source ready
- if (cj.state == ControlJobState.SELECTED)
- {
- bool sourceReady = true;
- for (int i = 0; i < cj.MtrlOutSpec.Count; i++)
- {
- sourceModule = cj.MtrlOutSpec[i].sourceCarID;
- if (!CheckCJMaterialSourceReady(cj.MtrlOutSpec[i]) || !CheckCJMaterialDestReady(cj.MtrlOutSpec[i]))
- {
- sourceReady = false;
- break;
- }
- }
- if (!sourceReady)
- continue;
- Task.Delay(500).ContinueWith(x =>
- {
- cj.MaterialArrived();
- });
- Task.Delay(1000).ContinueWith(x =>
- {
- foreach (var pj in cj.ProcessingCtrlSpec)
- {
- Singleton<FAJobController>.Instance.FAProcessJobs[pj].MaterialReadyForProcessing();
- }
- });
- }
- if (cj.state == ControlJobState.EXECUTING)
- {
- cj.MtrlOutSpec.Clear();
- AssignControlJob(cj.ObjtID, CarrierManager.Instance.GetLocationByCarrierId(sourceModule), cj.ProcessingCtrlSpec);
- }
- }
- return true;
- }
- public bool CheckCJMaterialSourceReady(MtrlOutSpecPair mtp)
- {
- string lp = CarrierManager.Instance.GetLocationByCarrierId(mtp.sourceCarID);
- if (string.IsNullOrEmpty(lp)) return false;
- if (Singleton<FAJobController>.Instance.FAloadports[lp].GetSlotMapStatus()
- != SlotMapStatus.SLOT_MAP_VERIFICATION_OK) return false;
- if (Singleton<FAJobController>.Instance.FAloadports[lp].GetCarrierIDStatus()
- != CarrierIDStatus.ID_VERIFICATION_OK) return false;
- foreach (var slot in mtp.sourceSlots)
- {
- var wafer = WaferManager.Instance.GetWafer((ModuleName)Enum.Parse(typeof(ModuleName), lp), slot - 1);
- if (wafer.IsEmpty) return false;
- if (wafer.SubstE90Status != EnumE90Status.NeedProcessing) return false;
- }
- return true;
- }
- public bool CheckCJMaterialDestReady(MtrlOutSpecPair mtp)
- {
- string lp = CarrierManager.Instance.GetLocationByCarrierId(mtp.DestCarID);
- if (string.IsNullOrEmpty(lp)) return false;
- if (Singleton<FAJobController>.Instance.FAloadports[lp].GetSlotMapStatus()
- != SlotMapStatus.SLOT_MAP_VERIFICATION_OK) return false;
- if (Singleton<FAJobController>.Instance.FAloadports[lp].GetCarrierIDStatus()
- != CarrierIDStatus.ID_VERIFICATION_OK) return false;
- return true;
- }
- public bool AssignProcessJob(ProcessMaterialName matrial, string recipe, ProcessRecipeMethod method, Dictionary<string, object> RecVariableList, string pjID)
- {
- string lp = CarrierManager.Instance.GetLocationByCarrierId(matrial.CarrierID);
- string[] slotsequence = new string[25];
- for (int i = 0; i < 25; i++)
- {
- if (matrial.SlotID.Contains(i + 1)) slotsequence[i] = recipe;
- else slotsequence[i] = "";
- }
- Dictionary<string, object> para = new Dictionary<string, object>();
- para.Add("JobId", pjID);
- para.Add("Module", lp);
- para.Add("SlotSequence", slotsequence);
- para.Add("AutoStart", true);
- //OP.DoOperation("System.CreateJob", new object[] { para });
- List<int> slot = new List<int>();
- foreach (var i in matrial.SlotID)
- {
- slot.Add(i - 1);
- }
- CheckToPostMessage((int)MSG.FAJobCommand, new object[] { "CreateProcessJob", pjID, recipe, slot, true });
- return true;
- }
- public bool AssignControlJob(string cjID, string module, List<string> pjList)
- {
- //OP.DoOperation("System.StartJob", new object[] { pjID });
- CheckToPostMessage((int)MSG.FAJobCommand, new object[] { "CreateControlJob", cjID, module, pjList, true });
- return true;
- }
- private bool FsmFAJobCommand(object[] param)
- {
- switch ((string)param[0])
- {
- case "CreateProcessJob":
- _auto.CreateProcessJob((string)param[1], (string)param[2], (List<int>)param[3], (bool)param[4]);
- break;
- case "CreateControlJob":
- _auto.CreateControlJob((string)param[1], (string)param[2], (List<string>)param[3], (bool)param[4]);
- CheckToPostMessage((int)MSG.StartJob, (string)param[1]);
- break;
- }
- return true;
- }
- */
- #endregion
- public bool RegisterEvent(bool isAlarm, string eventname, string eventcontext)
- {
- return true;
- }
- public bool PostEvent(bool isAlarm, string eventname, Dictionary<string, string> dvid, Dictionary<string, object> objdvid)
- {
- return true;
- }
- public bool ExcuteCommand(string command, object[] paras, out string reason)
- {
- reason = "";
- int portID;
- string jobID;
- string lotId;
- object[] sequence;
- string[] slotsequence;
- LoadPortModuleBase lp;
- switch (command.ToUpper())
- {
- case "PP-SELECT":
- if(!IsAutoMode)
- {
- reason = "system is not auto";
- return false;
- }
- portID = int.Parse(paras[0].ToString());
- jobID = paras[1].ToString();
- lotId = paras[2].ToString();
- sequence = (object[])paras[3];
- slotsequence = new string[25];
- for (int i = 0; i < 25; i++)
- {
- slotsequence[i] = sequence[i].ToString() == "*null*" ? "" : sequence[i].ToString();
- }
- Dictionary<string, object> para = new Dictionary<string, object>();
- para.Add("JobId", jobID);
- para.Add("LotId", lotId);
- para.Add("Module", ((ModuleName)portID).ToString());
- para.Add("SlotSequence", slotsequence);
- para.Add("AutoStart", true);
- return CheckToPostMessage((int)MSG.CreateJob, para);
- case "STARTJOB":
- jobID = paras[0].ToString();
- return CheckToPostMessage((int)MSG.StartJob, jobID);
- case "ABORTJOB":
- jobID = paras[0].ToString();
- return _auto.AbortJob(jobID);
- case "PAUSEJOB":
- jobID = paras[0].ToString();
- return _auto.PauseJob(jobID);
- case "RESUMEJOB":
- jobID = paras[0].ToString();
- return _auto.ResumeJob(jobID);
- case "STOPJOB":
- jobID = paras[0].ToString();
- return _auto.StopJob(jobID);
- case "LOAD":
- portID = int.Parse(paras[0].ToString());
- lp = Modules[(ModuleName)portID] as LoadPortModuleBase;
- if (lp != null)
- {
- return lp.Load();
- }
- reason = $"Not Find LP{portID}";
- return false;
- case "UNLOAD":
- portID = int.Parse(paras[0].ToString());
- lp = Modules[(ModuleName)portID] as LoadPortModuleBase;
- if (lp != null)
- {
- return lp.Unload();
- }
- reason = $"Not Find LP{portID}";
- return false;
- case "MAPCASSETTE":
- portID = int.Parse(paras[0].ToString());
- var efem = Modules[ModuleName.EFEM] as EfemModuleBase;
- if (efem != null && (portID == 1 || portID == 2))
- {
- return efem.Map((ModuleName)portID, out reason);
- }
- reason = $"Not Find LP{portID}";
- return false;
- case "READID":
- case "READRFID":
- case "READTAG":
- portID = int.Parse(paras[0].ToString());
- LoadPort lpDevice = DEVICE.GetDevice<LoadPort>("LP" + portID.ToString());
- if (lpDevice != null)
- {
- return lpDevice.ReadRfId(out reason);
- }
- else
- {
- reason = $"Not Find LP{portID}";
- return false;
- }
- case "CLAMP":
- case "LOCK":
- {
- portID = int.Parse(paras[0].ToString());
- lpDevice = DEVICE.GetDevice<LoadPort>("LP" + portID.ToString());
- if (lpDevice != null)
- {
- return lpDevice.Clamp(out reason);
- }
- else
- {
- reason = $"Not Find LP{portID}";
- return false;
- }
- }
- case "UNCLAMP":
- case "UNLOCK":
- {
- portID = int.Parse(paras[0].ToString());
- lpDevice = DEVICE.GetDevice<LoadPort>("LP" + portID.ToString());
- if (lpDevice != null)
- {
- return lpDevice.Unclamp(out reason);
- }
- else
- {
- reason = $"Not Find LP{portID}";
- return false;
- }
- }
- case "WRITEID":
- case "WRITERFID":
- case "WRITETAG":
- {
- portID = int.Parse(paras[0].ToString());
- string rfid = paras[1].ToString();
- lpDevice = DEVICE.GetDevice<LoadPort>("LP" + portID.ToString());
- if (lpDevice != null)
- {
- return lpDevice.WriteRfId(rfid, out reason);
- }
- else
- {
- reason = $"Not Find LP{portID}";
- return false;
- }
- }
-
- }
- return true;
- }
- public string[] GetRecipeList(string param)
- {
- if (param == "SEQUENCE")
- return RecipeFileManager.Instance.GetSequenceNameList().ToArray();
- if (param == "PMA")
- return RecipeFileManager.Instance.GetRecipes("PMA", true).ToArray();
- if (param == "PMB")
- return RecipeFileManager.Instance.GetRecipes("PMB", true).ToArray();
- return RecipeFileManager.Instance.GetSequenceNameList().ToArray();
- }
- public string GetRecipeBody(string param, string recipename)
- {
- if (param == "SEQUENCE")
- return RecipeFileManager.Instance.GetSequence(recipename, false);
- if (param == "PMA")
- return RecipeFileManager.Instance.LoadRecipe("PMA", recipename, false);
- if (param == "PMB")
- return RecipeFileManager.Instance.LoadRecipe("PMB", recipename, false);
- return RecipeFileManager.Instance.GetSequence(recipename, false);
- }
- 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"))
- {
- content = RecipeFileManager.Instance.LoadRecipe("", ppid, false);
- }
- else
- {
- content = RecipeFileManager.Instance.GetSequence(ppid, false);
- }
- result.Add(content);
- }
- catch (Exception ex)
- {
- reason = ex.Message;
- }
- return result;
- }
- public bool deleteSequence(string ppid)
- {
- return RecipeFileManager.Instance.DeleteSequence(ppid);
- }
- public bool UpdateSequence(string ppid, string body)
- {
- return RecipeFileManager.Instance.SaveSequence(ppid, body, false);
- }
- public void ShowTerminalMessage(string message)
- {
- }
- /// <summary>
- /// 创建ProcessJob
- /// </summary>
- /// <param name="processJobId"></param>
- /// <param name="sequenceName"></param>
- /// <param name="carrierId"></param>
- /// <returns></returns>
- public bool CreateProcessJob(string processJobId, string sequenceName,string carrierId,out string reason)
- {
- if(!IsAutoMode)
- {
- reason = "system is not auto";
- return false;
- }
- return _auto.CreateProcessJob(processJobId, sequenceName,carrierId, out reason);
- }
- /// <summary>
- /// 更新processJob carrierSlot信息
- /// </summary>
- /// <param name="processJobId"></param>
- /// <param name="moduleName"></param>
- /// <param name="slots"></param>
- public void UpdateProcessJobCarrierSlot(string processJobId, string moduleName, List<int> slots)
- {
- _auto.UpdateProcessJobSlotWafer(processJobId, moduleName, slots);
- }
- /// <summary>
- /// 检验创建ControlJob的条件
- /// </summary>
- /// <returns></returns>
- public bool CheckCreateControlJobCondition(List<string> modules, out string reason)
- {
- if (!IsAutoMode)
- {
- reason = "system is not auto";
- return false;
- }
- return _auto.CheckCreateControlJobCondition(modules,out reason);
- }
- /// <summary>
- /// 创建ControlJob
- /// </summary>
- /// <param name="controlJobId"></param>
- /// <param name="moduleName"></param>
- /// <param name="carrierId"></param>
- /// <param name="processJobs"></param>
- /// <param name="reason"></param>
- /// <returns></returns>
- public void CreateControlJob(string controlJobId, string carrierId, List<string> processJobs)
- {
- _auto.CreateControlJob(controlJobId, carrierId, processJobs);
- }
- /// <summary>
- /// 更新ControlJob Module信息
- /// </summary>
- /// <param name="controlJobId"></param>
- /// <param name="moduleName"></param>
- public void UpdateControlJobModule(string controlJobId, string moduleName)
- {
- _auto.UpdateControlJobModule(controlJobId, moduleName);
- }
- /// <summary>
- /// 启动任务
- /// </summary>
- /// <param name="controlJob"></param>
- /// <returns></returns>
- public bool StartControlJob(string controlJob)
- {
- return CheckToPostMessage((int)MSG.StartJob, controlJob);
- }
- /// <summary>
- /// 停止任务
- /// </summary>
- /// <param name="controlJob"></param>
- /// <returns></returns>
- public bool StopControlJob(string controlJob)
- {
- return CheckToPostMessage((int)MSG.StopJob, controlJob);
- }
- /// <summary>
- /// 中止任务
- /// </summary>
- /// <param name="controlJob"></param>
- /// <returns></returns>
- public bool AbortControlJob(string controlJob)
- {
- return CheckToPostMessage((int)MSG.AbortJob, controlJob);
- }
- /// <summary>
- /// 暂停任务
- /// </summary>
- /// <param name="controlJob"></param>
- /// <returns></returns>
- public bool PauseControlJob(string controlJob)
- {
- return CheckToPostMessage((int)MSG.PauseJob, controlJob);
- }
- /// <summary>
- /// 启动任务
- /// </summary>
- /// <param name="controlJob"></param>
- /// <returns></returns>
- public bool ResumeControlJob(string controlJob)
- {
- return CheckToPostMessage((int)MSG.ResumeJob, controlJob);
- }
- /// <summary>
- /// 检验Auto
- /// </summary>
- /// <returns></returns>
- public bool CheckAuto()
- {
- return IsAutoMode;
- }
- /// <summary>
- /// 告警日志
- /// </summary>
- /// <param name="message"></param>
- public void WriteWarningLog(string message)
- {
- LOG.Warning($"EAP {message}");
- }
- /// <summary>
- /// 错误日志
- /// </summary>
- /// <param name="message"></param>
- public void WriteErrorLog(string message)
- {
- EV.PostAlarmLog("EAP", $"EAP {message}");
- }
- /// <summary>
- /// 正常日志
- /// </summary>
- /// <param name="message"></param>
- public void WriteInfoLog(string message)
- {
- LOG.Write($"EAP {message}" );
- }
- }
- }
|