using System; using System.Linq; using System.Windows.Forms; using Aitex.Core.RT.Device.Unit; using Aitex.Core.RT.Fsm; using Aitex.Core.RT.Job; using Aitex.Core.Utilities; using Aitex.RT.Properties; using Aitex.Triton160.RT.Device; using Aitex.Triton160.RT.Routine.PM; using Aitex.Core.RT.DataCenter; using Aitex.Triton160.Common; using Aitex.Triton160.RT.Routine.Process; using Aitex.Core.RT.Event; 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.RT.FactoryAutomation; using System.Threading.Tasks; using Aitex.Core.MES; using Aitex.Core.MES.YZQZ; using System.Collections.Generic; namespace Aitex.Triton160.RT.Module { public enum EnumEquipmentMode { Auto, Manual, } public enum EnumEquipmentStatus { Uninit, Idle, Running, Error, } public class PMEntity : Entity, IEntity { //public enum STATE //{ //}; public enum MSG { Idle, SetAutoMode, SetManualMode, Abort, Vent, PumpDown, StopPumpDown, GasFlow, StopGasFlow, RfPower, CyclePurge, LeakCheck, RunRecipe, Process, PreProcess, PostProcess, RciepeAbort, RecipeSkipStep, RecipePause, RecipeResume, RecipeUpdate, Error, Reset, }; private VentRountine _ventRountine = new VentRountine(ModuleName.System.ToString(), "Vent"); private PumpDownRoutine _pumpRoutine = new PumpDownRoutine(ModuleName.System.ToString(), "Pump"); private StopPumpRoutine _stopPumpRoutine = new StopPumpRoutine(ModuleName.System.ToString(), "Stop Pump"); private GasFlowRoutine _gasFlowRoutine = new GasFlowRoutine(ModuleName.System.ToString(), "Gas Flow"); private StopGasFlowRoutine _stopGasFlowRoutine = new StopGasFlowRoutine(ModuleName.System.ToString(), "Stop Gas Flow"); private RfPowerRoutine _rfPowerRoutine = new RfPowerRoutine(ModuleName.System.ToString(), "Rf PowerOn"); private CyclePurgeRoutine cyclePurgeRoutine = new CyclePurgeRoutine(ModuleName.System.ToString(), "Cycle Purge"); private Process processRoutine = new Process(ModuleName.System.ToString(), "Process"); private PreProcess preProcessRoutine = new PreProcess(ModuleName.System.ToString(), "PreProcess"); private PostProcess postProcessRoutine = new PostProcess(ModuleName.System.ToString(), "PostProcess"); private LeakCheckRoutine _leakCheckRoutine = new LeakCheckRoutine(ModuleName.System.ToString(), "Leak Check"); public string Name { get; set; } public bool IsIdle { get { return fsm.State == (int)PMState.Idle; } } public string Status { get { return fsm.State.ToString(); } } public bool IsAutoMode { get; private set; } public bool IsProcessMode { get { return (fsm.State == (int)PMState.LoadProcessRecipe) || (fsm.State == (int)PMState.Processing) || (fsm.State == (int)PMState.PreProcess) || (fsm.State == (int)PMState.PostProcess); } } public bool IsRunRecipe { get { return (fsm.State == (int)PMState.Processing); } } //public bool IsAlarm { get; private set; } //public bool IsWarning { get; private set; } //public Guid CurrentRecipeRunGuid { get; set; } public JobInfo CurrentRunningJob { get; set; } private string _processStatus = string.Empty; private DateTime _pumpStartTime; private TimeSpan _pumpElapsedTime; private string PumpTime { get { if ((fsm.State == (int)PMState.Pumping) || (fsm.State == (int)PMState.PreProcess)) _pumpElapsedTime = DateTime.Now - _pumpStartTime; return string.Format("{0}:{1}:{2}", ((int)_pumpElapsedTime.TotalHours).ToString("00"), _pumpElapsedTime.Minutes.ToString("00"), _pumpElapsedTime.Seconds.ToString("00")); } } //private int _rfTime; //int RfTime //{ // get // { // if (fsm.State == (int)PMState.RfPowering) // _rfTime = _rfPowerRoutine.Elapsed; // else // { // _rfTime = 0; // } // return _rfTime; // } //} bool IsPumpingOkForProcess { get { return DeviceModel.MainPump.IsRunning && DeviceModel.ValveChamberPumping.Status; } } bool IsGasFlowingOkForProcess { get { if (!IsPumpingOkForProcess) return false; if (! ( (DeviceModel.ValveProcessGasFinal!=null && DeviceModel.ValveProcessGasFinal.Status))) return false; IoValve[] valves = { DeviceModel.ValveMfc1, DeviceModel.ValveMfc2 , DeviceModel.ValveMfc3, DeviceModel.ValveMfc4, DeviceModel.ValveMfc5}; if (!Array.Exists(valves, v => v!=null && v.Status)) return false; IoMfc[] mfcs = { DeviceModel.MfcGas1, DeviceModel.MfcGas2, DeviceModel.MfcGas3, DeviceModel.MfcGas4, DeviceModel.MfcGas5 }; if (!Array.Exists(mfcs, m => m!=null && m.FeedBack > 0.1)) return false; return true ; } } private DateTime _recipeStartTime; private TimeSpan _recipeElapsedTime; public string RecipeElapsedTime { get { if (fsm.State == (int) PMState.LoadProcessRecipe || fsm.State == (int) PMState.PreProcess || fsm.State == (int) PMState.Processing || fsm.State == (int) PMState.PostProcess) _recipeElapsedTime = DateTime.Now - _recipeStartTime; return string.Format("{0}:{1}:{2}", ((int)_recipeElapsedTime.TotalHours).ToString("00"), _recipeElapsedTime.Minutes.ToString("00"), _recipeElapsedTime.Seconds.ToString("00")); } } private DateTime _leakCheckStartTime; private TimeSpan _leakCheckElapsedTime; private string LeakCheckElapseTime { get { if ((fsm.State == (int)PMState.LeakCheck) ) _leakCheckElapsedTime = DateTime.Now - _leakCheckStartTime; return string.Format("{0}:{1}:{2}", ((int)_leakCheckElapsedTime.TotalHours).ToString("00"), _leakCheckElapsedTime.Minutes.ToString("00"), _leakCheckElapsedTime.Seconds.ToString("00")); } } private const string EventCarrierLoaded = "CarrierLoaded"; private const string EventCarrierUnloaded = "CarrierUnloaded"; private const string EventLotStart = "LotStart"; private const string EventLotFinished = "LotFinished"; private const string EventEquipmentStatusChanged = "EquipmentStatusChanged"; private const string EventEquipmentModeChanged = "EquipmentModeChanged"; private int _preEquipmentState; public PMEntity() { Running = false; IsAutoMode = false; //IsAlarm = false; //IsWarning = false; Name = "Chamber"; fsm = new StateMachine(Name, (int)PMState.Init, 50); EnterExitTransition(PMState.Init, fEnterInit, MSG.Idle, null); Transition(PMState.Init, MSG.Idle, fInit, PMState.Idle); EnterExitTransition(PMState.Error, fEnterError, FSM_MSG.NONE, null); AnyStateTransition(FSM_MSG.WARNING, fWarning, FSM_STATE.SAME); AnyStateTransition((int)FSM_MSG.ALARM, fAlarm, (int)PMState.Error); AnyStateTransition(MSG.Reset, fReset, PMState.Idle); //Auto/manual sequence Transition(PMState.Idle, MSG.SetAutoMode, fSetAutoMode, PMState.Idle); Transition(PMState.Idle, MSG.SetManualMode, fSetManualMode, PMState.Idle); //vent sequence Transition(PMState.Idle, MSG.Vent, fStartVent, PMState.Vent); Transition(PMState.Vent, FSM_MSG.TIMER, fVent, PMState.Idle); Transition(PMState.Vent, MSG.Abort, fAbortVent, PMState.Idle); Transition(PMState.Vent, MSG.PumpDown, fVentToPumping, PMState.Pumping); //Pump sequence Transition(PMState.Idle, MSG.PumpDown, fStartPumpDown, PMState.Pumping); Transition(PMState.Pumping, FSM_MSG.TIMER, fPumpDown, PMState.Idle); Transition(PMState.Pumping, MSG.Abort, fAbortPumping, PMState.Idle); Transition(PMState.Pumping, MSG.Vent, fPumpingToVent, PMState.Vent); //Stop Pump sequence Transition(PMState.Idle, MSG.StopPumpDown, fStartStopPump, PMState.StopPumping); Transition(PMState.StopPumping, FSM_MSG.TIMER, fStopPump, PMState.Idle); Transition(PMState.StopPumping, MSG.Abort, fAbortStopPump, PMState.Idle); //Gas Flow sequence Transition(PMState.Idle, MSG.GasFlow, fStartGasFlow, PMState.GasFlowing); Transition(PMState.GasFlowing, FSM_MSG.TIMER, fGasFlow, PMState.Idle); Transition(PMState.GasFlowing, MSG.Abort, fAbortGasFlow, PMState.Idle); //Stop Gas Flow sequence Transition(PMState.Idle, MSG.StopGasFlow, fStartStopGasFlow, PMState.StopGasFlowing); Transition(PMState.StopGasFlowing, FSM_MSG.TIMER, fStopGasFlow, PMState.Idle); Transition(PMState.StopGasFlowing, MSG.Abort, fAbortStopGasFlow, PMState.Idle); //RF Power sequence Transition(PMState.Idle, MSG.RfPower, fStartRfPower, PMState.RfPowering); Transition(PMState.RfPowering, FSM_MSG.TIMER, fRfPower, PMState.Idle); Transition(PMState.RfPowering, MSG.Abort, fAbortRfPower, PMState.Idle); //Leak check sequence Transition(PMState.Idle, MSG.LeakCheck, fStartLeakCheck, PMState.LeakCheck); Transition(PMState.LeakCheck, FSM_MSG.TIMER, fLeakCheck, PMState.Idle); Transition(PMState.LeakCheck, MSG.Abort, fAbortLeakCheck, PMState.Idle); //CyclePurge sequence Transition(PMState.Idle, MSG.CyclePurge, fStartCyclePurge, PMState.CyclePurge); Transition(PMState.CyclePurge, FSM_MSG.TIMER, fCyclePurge, PMState.Idle); Transition(PMState.CyclePurge, MSG.Abort, fAbortCyclePurge, PMState.Idle); //PreProcess sequence Transition(PMState.Idle, MSG.RunRecipe, fProcessLoadRecipe, PMState.LoadProcessRecipe ); Transition(PMState.LoadProcessRecipe, MSG.PreProcess, fStartPreProcess, PMState.PreProcess); Transition(PMState.LoadProcessRecipe, MSG.Abort, null, PMState.Idle); Transition(PMState.LoadProcessRecipe, MSG.Error, null, PMState.Idle); Transition(PMState.PreProcess, FSM_MSG.TIMER, fPreProcess, PMState.PreProcess); Transition(PMState.PreProcess, MSG.Abort, fAbortPreProcess, PMState.Idle); Transition(PMState.PreProcess, MSG.RciepeAbort, fAbortPreProcess, PMState.Idle); Transition(PMState.PreProcess, MSG.Error, fAbortPreProcess, PMState.Error); Transition(PMState.PreProcess, MSG.Process, fStartProcess, PMState.Processing); Transition(PMState.Processing, FSM_MSG.TIMER, fProcess, PMState.Processing); Transition(PMState.Processing, MSG.Error, fAbortProcess, PMState.Error); Transition(PMState.Processing, MSG.RciepeAbort, fAbortProcess, PMState.PostProcess); Transition(PMState.Processing, MSG.RecipePause, fPauseProcess, PMState.Processing); Transition(PMState.Processing, MSG.RecipeResume, fResumeRecipe, PMState.Processing); Transition(PMState.Processing, MSG.RecipeUpdate, fUpdateRecipe, PMState.Processing); Transition(PMState.Processing, MSG.RecipeSkipStep, fSkipStep, PMState.Processing); EnterExitTransition(PMState.Processing, fEnterProcess, FSM_MSG.NONE, fExitProcess); //PostProcess sequence Transition(PMState.Processing, MSG.PostProcess, fStartPostProcess, PMState.PostProcess); Transition(PMState.PostProcess, FSM_MSG.TIMER, fPostProcess, PMState.Idle); Transition(PMState.PostProcess, MSG.Abort, fAbortPostProcess, PMState.Idle); Transition(PMState.PostProcess, MSG.RciepeAbort, fAbortPostProcess, PMState.Idle); EnterExitTransition(PMState.PostProcess, null, FSM_MSG.NONE, fExitPostProcess); DATA.Subscribe(ModuleName.System.ToString(), StateData.IsAutoMode.ToString(), () => IsAutoMode); DATA.Subscribe(ModuleName.System.ToString(), StateData.PMState.ToString(), () => fsm.State); DATA.Subscribe(ModuleName.System.ToString(), StateData.IsPumpingOkForProcess.ToString(), () => IsPumpingOkForProcess); DATA.Subscribe(ModuleName.System.ToString(), StateData.IsGasFlowingOkForProcess.ToString(), () => IsGasFlowingOkForProcess); DATA.Subscribe(ModuleName.System.ToString(), StateData.PumpTime.ToString(), () => PumpTime); //DATA.Subscribe(ModuleName.System.ToString(), StateData.RfTimeElapsed.ToString(), () => RfTime); DATA.Subscribe(ModuleName.System.ToString(), StateData.RecipeStepRfTimeSetPoint.ToString(), () => (processRoutine.CurStepTotalRfTime /1000).ToString("F0")); DATA.Subscribe(ModuleName.System.ToString(), StateData.RecipeStepTimeElapsed.ToString(), () => (processRoutine.CurStepElpasedTime / 1000).ToString("F0")); DATA.Subscribe(ModuleName.System.ToString(), StateData.RecipeStepTimeSetPoint.ToString(), () => (processRoutine.CurStepTotalTime / 1000) .ToString("F0")); DATA.Subscribe(ModuleName.System.ToString(), StateData.ProcessStatus.ToString(), () => _processStatus); DATA.Subscribe(ModuleName.System.ToString(), StateData.RecipeProcessTime.ToString(), () => RecipeElapsedTime); DATA.Subscribe(ModuleName.System.ToString(), StateData.LeakCheckElapseTime.ToString(), () => LeakCheckElapseTime); DATA.Subscribe(string.Format("{0}.{1}", ModuleName.System, StateData.AlarmEvent), EV.GetAlarmEvent); DATA.Subscribe(ModuleName.System.ToString(), StateData.RecipeStepNo.ToString(), () => processRoutine.CurStepNum + 1); DATA.Subscribe(ModuleName.System.ToString(), StateData.RecipeName.ToString(), () => { switch ((PMState)fsm.State) { case PMState.PreProcess: return preProcessRoutine.CurrentRecipeBaseName; default: return processRoutine.CurrentRecipeBaseName; } }); DATA.Subscribe(ModuleName.System.ToString(), StateData.TotalCycle.ToString(), () => processRoutine.TotalCycle); DATA.Subscribe(ModuleName.System.ToString(), StateData.DataLogName.ToString(), () => processRoutine.CurrentRecipeRunningName); DATA.Subscribe(ModuleName.System.ToString(), StateData.LotName.ToString(), () => { switch ((PMState)fsm.State) { case PMState.PreProcess: return preProcessRoutine.CurrentLotName; default: return processRoutine.CurrentLotName; } }); DATA.Subscribe("RecipeList", () => RecipeFileManager.Instance.GetRecipes("System", false).ToList()); DATA.Subscribe("EquipmentMode", () => { return (int) (IsAutoMode ? EnumEquipmentMode.Auto : EnumEquipmentMode.Manual); }); DATA.Subscribe("EquipmentStatus", () => { int result = 0; switch ((PMState)fsm.State) { case PMState.Error: result = (int) EnumEquipmentStatus.Error; break; case PMState.Init: result = (int) EnumEquipmentStatus.Uninit; break; case PMState.Idle: result = (int) EnumEquipmentStatus.Idle; break; default: result = (int) EnumEquipmentStatus.Running; break; } if (_preEquipmentState != result) { EV.Notify(EventEquipmentStatusChanged, new SerializableDictionary()); } _preEquipmentState = result; return result; }); EnumLoop.ForEach((item) => { fsm.MapState((int)item, item.ToString()); }); EnumLoop.ForEach((item) => { fsm.MapMessage((int)item, item.ToString()); }); EV.Subscribe(new EventItem("Event", EventCarrierLoaded, "Event Carrier Loaded")); EV.Subscribe(new EventItem("Event", EventCarrierUnloaded, "Event Carrier Unloaded")); EV.Subscribe(new EventItem("Event", EventLotStart, "EventLotStart")); EV.Subscribe(new EventItem("Event", EventLotFinished, "EventLotFinished")); EV.Subscribe(new EventItem("Event", EventEquipmentStatusChanged, "EventEquipmentStatusChanged")); EV.Subscribe(new EventItem("Event", EventEquipmentModeChanged, "EventEquipmentModeChanged")); OP.Subscribe("CarrierLoad", (string cmd, object[] args) => { var dvid = new SerializableDictionary(); EV.Notify(EventCarrierLoaded, dvid); return true; }); OP.Subscribe("CarrierUnload", (string cmd, object[] args) => { //var dvid = new SerializableDictionary(); //EV.Notify(EventCarrierUnloaded, dvid); EV.Notify(EventCarrierUnloaded, new SerializableDictionary() { {DVIDName.LotId, preProcessRoutine.CurrentLotName}, {DVIDName.JobId, preProcessRoutine.CurrentJobName}, {DVIDName.RecipeId, preProcessRoutine.CurrentRecipeBaseName } }); return true; }); } public Tuple GetRecipeInfo() { if (fsm.State == (int)PMState.PreProcess) return new Tuple(preProcessRoutine.CurrentRecipeRunningName, preProcessRoutine.CurrentRecipeContent); else if(fsm.State == (int)PMState.Processing) return new Tuple(processRoutine.CurrentRecipeRunningName, processRoutine.CurrentRecipeContent); return new Tuple(String.Empty, String.Empty); } public bool Check(int msg, out string reason, params object[] args) { if (!fsm.FindTransition(fsm.State, msg)) { reason = String.Format("{0} is in {1},can not do {2}", Name, (PMState)fsm.State, (MSG)msg); return false; } bool bRet = true; reason = ""; switch (msg) { case (int)MSG.RunRecipe: if (fsm.State != (int)PMState.Idle) { reason = String.Format("{0} Is In {1},Can not do {2}", Name, (PMState)fsm.State, (MSG)msg); bRet = false; } break; case (int)MSG.RecipePause: case (int)MSG.RecipeResume: case (int)MSG.RecipeSkipStep: case (int)MSG.RecipeUpdate: if (fsm.State != (int)PMState.Processing) { reason = String.Format("{0} not running recipe,can not do {1}", Name, (MSG)(msg)); bRet = false; } break; default: break; } return bRet; } protected override bool Init() { _rfPowerRoutine.Initialize(); _gasFlowRoutine.Initialize(); _stopGasFlowRoutine.Initialize(); _pumpRoutine.Initialize(); _stopPumpRoutine.Initialize(); cyclePurgeRoutine.Initialize(); _ventRountine.Initialize(); processRoutine.Initialize(); preProcessRoutine.Initialize(); postProcessRoutine.Initialize(); _leakCheckRoutine.Initialize(); Running = true; Default(); return true; } private bool fSetAutoMode(object[] objs) { if (IsAutoMode) return true; IsAutoMode = true; EV.Notify(EventEquipmentModeChanged, new SerializableDictionary() { }); EV.PostMessage(ModuleNameString.System, Triton160EventEnum.RunningModeChanged, Resources.GlobalLableAutoMode); return true; } private bool fSetManualMode(object[] objs) { if (!IsAutoMode) return true; if (SC.GetValue(SCName.System_EnableFa) && Singleton.Instance.FaControlState== "OnlineRemote" && Singleton.Instance.FaCommunicationState == "EnabledCommunicating") { EV.PostWarningLog("System", Aitex.RT.Properties.Resources.SystemInOnlineRemoteModeCanNotSwitchToManualSwitchOffHostControlFirst); return true; } IsAutoMode = false; EV.Notify(EventEquipmentModeChanged, new SerializableDictionary() { }); EV.PostMessage(ModuleNameString.System, Triton160EventEnum.RunningModeChanged, Resources.GlobalLableManualMode ); return true; } private bool fEnterInit(object[] objs) { return true; } private bool fInit(object[] objs) { return true; } private bool fEnterError(object[] objs) { if (IsProcessMode) { EV.Notify(EventLotFinished, new SerializableDictionary() { {DVIDName.LotId, preProcessRoutine.CurrentLotName}, {DVIDName.JobId, preProcessRoutine.CurrentJobName}, {DVIDName.RecipeId, preProcessRoutine.CurrentRecipeBaseName } }); } return true; } private bool fWarning(object[] objs) { //IsWarning = false; return true; } private bool fAlarm(object[] objs) { StartJobRecord(false); if (fsm.State == (int)PMState.Init) return false; if (fsm.State == (int) PMState.Processing) { PostMsg(MSG.Error); MESErrorRecordAlarm(processRoutine.CurrentLotName, processRoutine.CurrentRecipeBaseName, objs); return false; } //IsAlarm = true; return true; } private async void MESErrorRecordAlarm(string lotId, string receipeName, object[] objs) { await Task.Run(() => { string erroMsg=string.Empty; if (objs != null && objs.Length > 0) { foreach (var o in objs) erroMsg += o.ToString()+"|"; } erroMsg= erroMsg.TrimEnd('|'); Fab fb = (Fab)Enum.Parse(typeof(Fab), SC.GetValue(SCName.System_Company).ToString()); if (fb == Fab.YZQZ) { List records = new List(); FabAutoComm com = new YZQZFabAuto(); lotId = lotId.TrimEnd('/'); string[] items = lotId.Split('/'); foreach (var item in items) { RequestMachineErrorRecord record = new RequestMachineErrorRecord() { LotId = item, RecipeName = receipeName, MachineNumber = SC.GetSCString(SCName.System_YZQZMachineNumber).Value, MachineType = SC.GetSCString(SCName.System_YZQZMachineType).Value, ErrorMessage = erroMsg }; records.Add(record); } com.SaveMachineErrorRecord(records); } }); } private bool fReset(object[] objs) { //IsAlarm = false; if (fsm.State == (int)PMState.Error) return true; return false; } public void ToggleChamberStatus() { string reason = string.Empty; } public void Default() { } public void AlarmEvent() { } #region Vent private bool fStartVent(object[] objs) { Result ret = _ventRountine.Start(); if (ret == Result.DONE) { return false; } else if (ret == Result.FAIL) { return false; //do noting } return true; } private bool fVent(object[] objs) { Result ret = _ventRountine.Monitor(); if (ret == Result.DONE) return true; else if (ret == Result.FAIL) { //do nothing return true; } return false; ; } private bool fAbortVent(object[] objs) { _ventRountine.Abort(); return true; } private bool fVentToPumping(object[] objs) { if (_ventRountine.Abort() != Result.DONE) { PostMsg(MSG.Error); return true; } fStartPumpDown(null); return true; } #endregion #region Pumping private bool fStartPumpDown(object[] objs) { _pumpStartTime = DateTime.Now; Result ret = _pumpRoutine.Start(); if (ret == Result.DONE) { return false; } else if (ret == Result.FAIL || ret == Result.TIMEOUT) { return false; //do noting } return true; } private bool fPumpDown(object[] objs) { Result ret = _pumpRoutine.Monitor(); if (ret == Result.DONE) return true; else if (ret == Result.FAIL || ret == Result.TIMEOUT) { //do nothing return true; } return false; ; } private bool fAbortPumping(object[] objs) { _pumpRoutine.Abort(); return true; } private bool fPumpingToVent(object[] objs) { if (_pumpRoutine.Abort() != Result.DONE) { PostMsg(MSG.Error); return true; } fStartVent(null); return true; } #endregion #region Stop Pump private bool fStartStopPump(object[] objs) { Result ret = _stopPumpRoutine.Start(objs); if (ret == Result.DONE) { return false; } else if (ret == Result.FAIL || ret == Result.TIMEOUT) { return false; //do noting } return true; } private bool fStopPump(object[] objs) { Result ret = _stopPumpRoutine.Monitor(); if (ret == Result.DONE) return true; else if (ret == Result.FAIL || ret == Result.TIMEOUT) { //do nothing return true; } return false; ; } private bool fAbortStopPump(object[] objs) { _stopPumpRoutine.Abort(); return true; } #endregion #region Gas Flow private bool fStartGasFlow(object[] objs) { Result ret = _gasFlowRoutine.Start(objs); if (ret == Result.DONE) { return false; } else if (ret == Result.FAIL || ret == Result.TIMEOUT) { return false; //do noting } return true; } private bool fGasFlow(object[] objs) { Result ret = _gasFlowRoutine.Monitor(); if (ret == Result.DONE) return true; else if (ret == Result.FAIL || ret == Result.TIMEOUT) { //do nothing return true; } return false; ; } private bool fAbortGasFlow(object[] objs) { _gasFlowRoutine.Abort(); return true; } #endregion #region Stop Gas Flow private bool fStartStopGasFlow(object[] objs) { Result ret = _stopGasFlowRoutine.Start(objs); if (ret == Result.DONE) { return false; } else if (ret == Result.FAIL || ret == Result.TIMEOUT) { return false; //do noting } return true; } private bool fStopGasFlow(object[] objs) { Result ret = _stopGasFlowRoutine.Monitor(); if (ret == Result.DONE) return true; else if (ret == Result.FAIL || ret == Result.TIMEOUT) { //do nothing return true; } return false; ; } private bool fAbortStopGasFlow(object[] objs) { _stopGasFlowRoutine.Abort(); return true; } #endregion #region Rf Power On private bool fStartRfPower(object[] objs) { Result ret = _rfPowerRoutine.Start(objs); if (ret == Result.DONE) { return false; } else if (ret == Result.FAIL || ret == Result.TIMEOUT) { return false; //do noting } return true; } private bool fRfPower(object[] objs) { Result ret = _rfPowerRoutine.Monitor(); if (ret == Result.DONE) return true; else if (ret == Result.FAIL || ret == Result.TIMEOUT) { //do nothing return true; } return false; ; } private bool fAbortRfPower(object[] objs) { _rfPowerRoutine.AbortRf(); _rfPowerRoutine.Abort(); return true; } #endregion #region CyclePurge private bool fStartCyclePurge(object[] objs) { Result ret = cyclePurgeRoutine.Start(objs); if (ret == Result.DONE) { return false; } else if (ret == Result.FAIL) { return false; //do noting } return true; } private bool fCyclePurge(object[] objs) { Result ret = cyclePurgeRoutine.Monitor(); if (ret == Result.DONE) return true; else if (ret == Result.FAIL) { //do nothing return true; } return false; ; } private bool fAbortCyclePurge(object[] objs) { cyclePurgeRoutine.Abort(); return true; } #endregion #region PreProcess private bool fProcessLoadRecipe(object[] objs) { _processStatus = Resources.PMEntity_fProcessLoadRecipe_LoadingRecipeFile; _recipeStartTime = DateTime.Now; Result ret = preProcessRoutine.LoadRecipe(objs); if (ret == Result.DONE) { //if (preProcessRoutine.HighVac) // PostMsg(MSG.HighVacTest); //else PostMsg(MSG.PreProcess); return true; } else if (ret == Result.FAIL) { _processStatus = Resources.PMEntity_fProcessLoadRecipe_LoadingRecipeFileFailed; return false; //do noting } return true; } private bool fStartPreProcess(object[] objs) { _pumpStartTime = DateTime.Now; _processStatus = Resources.PMEntity_fStartPreProcess_PreparingRunningRecipe; Result ret = preProcessRoutine.Start(objs); if (ret == Result.DONE) { return false; } else if (ret == Result.FAIL) { _processStatus = Resources.PMEntity_fStartPreProcess_PreparingRunningRecipeFailed; PostMsg(MSG.Error); return false; //do noting } EV.Notify(EventLotStart, new SerializableDictionary() { {DVIDName.LotId, preProcessRoutine.CurrentLotName}, {DVIDName.RecipeId, preProcessRoutine.CurrentRecipeBaseName }, {DVIDName.JobId, preProcessRoutine.CurrentJobName}, }); StartJobRecord(true,preProcessRoutine.CurrentLotName, preProcessRoutine.CurrentRecipeBaseName,preProcessRoutine.CurrentJobName, preProcessRoutine.CurrentUserId); return true; } private async void StartJobRecord(bool startEnd, string lotId="", string receipeName = "",string operation="",string operatorId="" ) { await Task.Run(() => { Fab fb = (Fab)Enum.Parse(typeof(Fab), SC.GetValue(SCName.System_Company).ToString()); if (fb == Fab.YZQZ) { FabAutoComm com = new YZQZFabAuto(); if (startEnd) com.StartJobRecord(lotId, receipeName,operation,operatorId); else com.EndJobRecord(); } }); } private bool fPreProcess(object[] objs) { _processStatus = Resources.PMEntity_fPreProcess_RunRecipePumpingDown; Result ret = preProcessRoutine.Monitor(); if (ret == Result.DONE) { PostMsg(MSG.Process, preProcessRoutine.CurrentRecipeBaseName, preProcessRoutine.CurrentRecipeRunningName, 0, preProcessRoutine.CurrentLotName, preProcessRoutine.CurrentRecipeContent, preProcessRoutine.CurrentRecipeHead, preProcessRoutine.CurrentRecipeStepList, preProcessRoutine.CurrentJobName); return true; } else if (ret == Result.FAIL) { _processStatus = Resources.PMEntity_fPreProcess_RunRecipePumpingDownFailed; PostMsg(MSG.Error); return true; } return false; ; } private bool fAbortPreProcess(object[] objs) { _processStatus = Resources.PMEntity_fAbortPreProcess_RunRecipePumpingDownAborted; preProcessRoutine.Abort(); return true; } #endregion #region Process private bool fStartProcess(object[] objs) { _processStatus = Resources.PMEntity_fStartProcess_StartRunningRecipe; Result ret = processRoutine.Start(objs); if (ret == Result.DONE) { return true; } else if (ret == Result.FAIL) { _processStatus = Resources.PMEntity_fStartProcess_RunRecipeFailed; PostMsg(MSG.Error); return true; //do noting } return true; } private bool fProcess(object[] objs) { _processStatus = Resources.PMEntity_fProcess_RunningRecipe; Result ret = processRoutine.Monitor(); { if (ret == Result.DONE) { PostMsg(MSG.PostProcess, processRoutine.CurrentRecipeRunningName, processRoutine.CurrentRecipeContent); return true; } else if (ret == Result.FAIL) { _processStatus = Resources.PMEntity_fStartProcess_RunRecipeFailed; PostMsg(MSG.Error); //MESErrorRecordAlarm(processRoutine.CurrentRecipeRunningName, MSG.Error); return true; } return false; } } private bool fAbortProcess(object[] objs) { _processStatus = Resources.PMEntity_fAbortProcess_RunningRecipeAborted; processRoutine.AbortRecipe(); Result ret = postProcessRoutine.Start(new object[] { processRoutine.CurrentRecipeRunningName, processRoutine.CurrentRecipeContent }); if (ret == Result.DONE) { return false; } else if (ret == Result.FAIL) { PostMsg(MSG.Error); _processStatus = Resources.PMEntity_fAbortProcess_RunRecipeAborted; return false; //do noting } return true; } private bool fEnterProcess(object[] objs) { return true; } private bool fExitProcess(object[] objs) { processRoutine.Exit(); return true; } private bool fExitPostProcess(object[] objs) { postProcessRoutine.Exit(); EV.Notify(EventLotFinished, new SerializableDictionary() { {DVIDName.LotId, preProcessRoutine.CurrentLotName}, {DVIDName.JobId, preProcessRoutine.CurrentJobName}, {DVIDName.RecipeId, preProcessRoutine.CurrentRecipeBaseName } }); StartJobRecord(false); return true; } private bool fPauseProcess(object[] objs) { _processStatus = "run recipe paused"; processRoutine.PauseRecipe(); return false; } private bool fResumeRecipe(object[] objs) { _processStatus = "run recipe resumed"; processRoutine.ResumeRecipe(); return false; } private bool fSkipStep(object[] objs) { _processStatus = Resources.PMEntity_fSkipStep_RunRecipeSkipped; processRoutine.SkipCurrentRecipeStep(); return false; } private bool fUpdateRecipe(object[] objs) { processRoutine.UpdateRecipe((string)objs[0]); return false; } #endregion #region PostProcess private bool fStartPostProcess(object[] objs) { _processStatus = Resources.PMEntity_fStartPostProcess_RunRecipePostProcess; Result ret = postProcessRoutine.Start(objs); if (ret == Result.DONE) { return false; } else if (ret == Result.FAIL) { PostMsg(MSG.Error); return false; //do noting } return true; } private bool fPostProcess(object[] objs) { _processStatus = Resources.PMEntity_fPostProcess_RunRecipeCyclePurge; Result ret = postProcessRoutine.Monitor(); if (ret == Result.DONE) { _processStatus = Resources.PMEntity_fPostProcess_RecipeCompleted; if ((int)SC.GetValue(SCName.ProcessConfig_ProcessFinishedReminderFlag) != 0) { processRoutine.PopProcessEndDialog(); } return true; } else if (ret == Result.FAIL) { _processStatus = Resources.PMEntity_fPostProcess_RunRecipeCyclePurgeError; PostMsg(MSG.Error); return true; } return false; } private bool fAbortPostProcess(object[] objs) { _processStatus = Resources.PMEntity_fAbortPostProcess_RecipeAborted; postProcessRoutine.Abort(); return true; } #endregion #region Leak Check private bool fStartLeakCheck(object[] objs) { _leakCheckStartTime = DateTime.Now; Result ret = _leakCheckRoutine.Start(objs); if (ret == Result.DONE) { return false; } else if (ret == Result.FAIL || ret == Result.TIMEOUT) { return false; //do noting } return true; } private bool fLeakCheck(object[] objs) { Result ret = _leakCheckRoutine.Monitor(); if (ret == Result.DONE) return true; else if (ret == Result.FAIL || ret == Result.TIMEOUT) { PostMsg(MSG.Error); EV.PostMessage(ModuleNameString.System, EventEnum.GeneralInfo, "Leak check stopped due to error"); return true; } return false; ; } private bool fAbortLeakCheck(object[] objs) { _leakCheckRoutine.AbortLeakCheck(); return true; } #endregion } }