123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336 |
- using System;
- using System.Collections.Generic;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using JetVirgoPM.Devices;
- using JetVirgoPM.PMs.Routines;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.Routine;
- using MECF.Framework.Common.SubstrateTrackings;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.PMs;
- using MECF.Framework.RT.ModuleLibrary.PMModules;
- namespace JetVirgoPM.PMs.RecipeExecutors
- {
- class PostProcessRoutine : PMRoutineBase
- {
- private enum PostProcessSequence
- {
- DelayForTest,
- RFPowerOff,
- StopGasFlow,
- CloseAllValves,
- ClosePumpValve,
- DelayWaitValve,
- Loop,
- SetLiftPin1,
- SetLiftPin2,
- Pump,
- PumpDelay,
- Vent,
- VentDelay,
- EndLoop,
- ClosePurgeValve,
- VentEndToPrecision,
- VentEndDelay,
- VentEndCloseVentValve,
- SetSlitDoor,
- VentAndPinDown,
- End,
- };
- private RecipeHead head;
- private int _purgeCycleCount;
- private int _purgeVentPressure;
- private int _purgePumpPressure;
- private int _purgeVentTimeLimit;
- private int _purgePumpTimeLimit;
- private int _purgeVentStableTime;
- private int _purgePumpStableTime;
- private int _ventTime;
- //private int _ventTimeLimit;
- private readonly RfPowerRoutine _rfPowerRoutine;
- private readonly VentRoutine _ventRoutine;
- private readonly int _VentingAndPinUpTimeout = 60 * 1000;
- private bool _isSimulatorMode;
- private bool _isVented = false;
- //---------------------------------Properties------------------------------------
- //
- public string RecipeName { get; private set; }
- public string RecipeContext { get; private set; }
- private bool PurgeActive
- {
- get
- {
- if (head != null)
- {
- if (!string.IsNullOrEmpty(head.PurgeActive))
- {
- return Convert.ToBoolean(head.PurgeActive);
- }
- }
- return true;
- }
- }
- //For keep vacuum after idle clean
- private bool NotToPurgeOrVent
- {
- get
- {
- if (head != null)
- {
- if (!string.IsNullOrEmpty(head.NotToPurgeOrVent))
- {
- return Convert.ToBoolean(head.NotToPurgeOrVent);
- }
- }
- return false;
- }
- }
- private bool LiftPinWhileVenting
- {
- get
- {
- if (head != null)
- {
- if (!string.IsNullOrEmpty(head.VentingPinState))
- {
- return head.VentingPinState == "Up" ? true : false;
- }
- }
- return false;
- }
- }
- //--------------------------------Constructor------------------------------------
- //
- public PostProcessRoutine(JetDualPM chamber, VentRoutine _vRoutine) : base(chamber)
- {
- Name = "PostProcess";
- _rfPowerRoutine = new RfPowerRoutine(_chamber, false);
- _ventRoutine = _vRoutine;
- }
- public void Terminate()
- {
- }
- public RState Start(params object[] objs)
- {
- try
- {
- Reset();
- //this.UpdateSCValue();
- RecipeName = (string)objs[0];
- RecipeContext = (string)objs[1];
- List<RecipeStep> recipeSteps;
- if (!Recipe.Parse(Module, RecipeContext, out head, out recipeSteps))
- {
- return RState.Failed;
- }
- _purgeCycleCount = (int)SC.GetValue<double>($"{_chamber.Module}.Purge.PurgeCycleCount");
- _purgeVentPressure = (int)SC.GetValue<double>($"{_chamber.Module}.Purge.PurgeVentPressure");
- _purgePumpPressure = (int)SC.GetValue<double>($"{_chamber.Module}.Purge.PurgePumpPressure");
- _purgeVentTimeLimit = (int)SC.GetValue<double>($"{_chamber.Module}.Purge.PurgeVentTimeLimit");
- _purgePumpTimeLimit = (int)SC.GetValue<double>($"{_chamber.Module}.Purge.PurgePumpTimeLimit");
- _purgeVentStableTime = (int)SC.GetValue<double>($"{_chamber.Module}.Purge.PurgeVentStableTime");
- _purgePumpStableTime = (int)SC.GetValue<double>($"{_chamber.Module}.Purge.PurgePumpStableTime");
- _isSimulatorMode = SC.GetValue<bool>("System.IsSimulatorMode");
- _ventTime = (int)SC.GetValue<double>($"{_chamber.Module}.VentTime");
- //_ventTimeLimit = (int)SC.GetSC<double>(SCName.System_VentTimeLimit).Value;
- }
- catch (Exception ex)
- {
- LOG.Write(ex, "Post process Start has exception");
- return RState.Failed;
- }
- return Runner.Start(_chamber.Module.ToString(), Name);
- }
- public RState Monitor()
- {
- var hasWafer0 = WaferManager.Instance.CheckHasWafer(Module, 0);
- var hasWafer1 = WaferManager.Instance.CheckHasWafer(Module, 1);
- var pos = (hasWafer0 && hasWafer1) ? EnumDualPM.Both : hasWafer0 ? EnumDualPM.Left : hasWafer1 ? EnumDualPM.Right : EnumDualPM.None;
- var pos2 = LiftPinWhileVenting ? EnumDualPM.None : EnumDualPM.Both;
- if (!NotToPurgeOrVent && PurgeActive) //For keep vacuum after idle clean
- {
- Runner.Run(PostProcessSequence.DelayForTest, HOFs.Apply(DelayTime, _isSimulatorMode ? _delay_1s : 0), _isSimulatorMode ? _delay_1s : 0)
- .Run(PostProcessSequence.RFPowerOff, RFPowerOff, CheckRFPowerOff)
- .Wait(PostProcessSequence.CloseAllValves, CloseAllValve, _delay_1s)
- .LoopStart(PostProcessSequence.Loop, "", _purgeCycleCount, HOFs.Apply(Pump, _purgePumpPressure), HOFs.Apply(CheckPump, _purgePumpPressure, true), _purgePumpTimeLimit * 1000)
- .LoopDelay(PostProcessSequence.PumpDelay, _purgePumpStableTime * 1000)
- .LoopRun(PostProcessSequence.Vent, HOFs.Apply(Vent, _purgeVentPressure), HOFs.Apply(CheckVent, _purgeVentPressure, true), _purgeVentTimeLimit * 1000)
- .LoopDelay(PostProcessSequence.VentDelay, _purgeVentStableTime * 1000)
- .LoopEnd(PostProcessSequence.EndLoop, NullFun, _delay_1s)
- .Run(PostProcessSequence.VentAndPinDown, ParallellyVentAndLiftPin, CheckParallellyVentAndLiftPin, _VentingAndPinUpTimeout * 1000)
- .Run(PostProcessSequence.SetLiftPin1, HOFs.Apply(SetLiftPinUpDown, pos2, false), HOFs.Apply(ChecktLiftPinUpDown, pos2, false), _delay_5s)
- .Run(PostProcessSequence.VentEndToPrecision, Vent, CheckVent)
- .Wait(PostProcessSequence.VentEndCloseVentValve, CloseValve, valveOpenCloseTimeout*1000)
- .Run(PostProcessSequence.SetLiftPin2, HOFs.Apply(SetLiftPinUpDown, pos, true), HOFs.Apply(ChecktLiftPinUpDown, pos, true), _delay_5s)
- .Run(PostProcessSequence.SetSlitDoor, HOFs.Apply(SetSlitDoor, pos, true), HOFs.Apply(CheckSlitDoor, pos, true), _delay_5s)
- .End(PostProcessSequence.End, EndFunc, _delay_1s);
- }
- else if(!NotToPurgeOrVent)
- {
- Runner.Run(PostProcessSequence.DelayForTest, HOFs.Apply(DelayTime, _isSimulatorMode ? _delay_1s : 0), _isSimulatorMode ? _delay_1s : 0)
- .Run(PostProcessSequence.RFPowerOff, RFPowerOff, CheckRFPowerOff)
- .Wait(PostProcessSequence.CloseAllValves, CloseAllValve, _delay_1s)
- .Run(PostProcessSequence.VentAndPinDown, ParallellyVentAndLiftPin, CheckParallellyVentAndLiftPin, _VentingAndPinUpTimeout * 1000)
- .Run(PostProcessSequence.SetLiftPin1, HOFs.Apply(SetLiftPinUpDown, pos2, false), HOFs.Apply(ChecktLiftPinUpDown, pos2, false), _delay_5s)
- .Run(PostProcessSequence.VentEndToPrecision, Vent, CheckVent)
- .Wait(PostProcessSequence.VentEndCloseVentValve, CloseValve, valveOpenCloseTimeout * 1000)
- .Run(PostProcessSequence.SetLiftPin2, HOFs.Apply(SetLiftPinUpDown, pos, true), HOFs.Apply(ChecktLiftPinUpDown, pos, true), _delay_5s)
- .Run(PostProcessSequence.SetSlitDoor, HOFs.Apply(SetSlitDoor, pos, true), HOFs.Apply(CheckSlitDoor, pos, true), _delay_5s)
- .End(PostProcessSequence.End, EndFunc, _delay_1s);
- }
- else
- {
- Runner.Run(PostProcessSequence.DelayForTest, HOFs.Apply(DelayTime, _isSimulatorMode ? _delay_1s : 0), _isSimulatorMode ? _delay_1s : 0)
- .Run(PostProcessSequence.RFPowerOff, RFPowerOff, CheckRFPowerOff)
- .Wait(PostProcessSequence.CloseAllValves, CloseAllValve, _delay_1s)
- .End(PostProcessSequence.End, EndFunc, _delay_1s);
- }
- return Runner.Status;
- }
- bool RFPowerOff()
- {
- return _rfPowerRoutine.Start() == RState.Running;
- }
- bool CheckRFPowerOff()
- {
- var status = _rfPowerRoutine.Monitor();
- if (status == RState.End)
- {
- return true;
- }
- else if (status == RState.Failed || status == RState.Timeout)
- {
- Runner.Stop($"RF power off failed.");
- return true;
- }
- return false;
- }
- bool Vent()
- {
- if (LiftPinWhileVenting) return true;
- _isVented = _ventRoutine.Start() == RState.End;
- return _ventRoutine.Start() == RState.Running || _isVented;
- }
- bool CheckVent()
- {
- if (LiftPinWhileVenting || _isVented) return true;
- var status = _ventRoutine.Monitor();
- if (status == RState.End)
- {
- return true;
- }
- else if (status == RState.Failed || status == RState.Timeout)
- {
- Runner.Stop($"Vent failed.");
- return true;
- }
- return false;
- }
- public void Exit()
- {
- //ProcessDataRecorder.End(RecipeRunGuid.ToString(), SusceptorStatus.Processed.ToString(), Module);
- //if (DeviceModel.SignalTower != null)
- //{
- // DeviceModel.SignalTower.BuzzerBlinking(SC.GetValue<double>(SCName.System_BuzzerBlinkingTime));
- //}
- //update processing end time
- //Singleton<ProcessRecorder>.Instance.EndRecipeProcess(Singleton<PMEntity>.Instance.CurrentRunningJob.RecipeRunId, SusceptorStatus.Processed);
- }
- private bool ParallellyVentAndLiftPin()
- {
- if(LiftPinWhileVenting)
- {
- Notify($"设置 lift pin {_chamber.Name} " + "升");
- if (!_chamber.Chamber1Disable)
- {
- if (!_chamber.SetLiftPin1(MovementPosition.Up, out string reasonPin1))
- {
- Stop(reasonPin1);
- return false;
- }
- }
- if (!_chamber.Chamber2Disable)
- {
- if (!_chamber.SetLiftPin2(MovementPosition.Up, out string reasonPin2))
- {
- Stop(reasonPin2);
- return false;
- }
- }
- _ventRoutine.Start();
- return true;
- }
- else
- return true;
- }
- bool CheckParallellyVentAndLiftPin()
- {
- if (LiftPinWhileVenting)
- {
- bool res1 = _chamber.CheckLift1Up();
- bool res2 = _chamber.CheckLift2Up();
- if (_chamber.Chamber1Disable)
- {
- res1 = true;
- }
- if (_chamber.Chamber2Disable)
- {
- res2 = true;
- }
- var result = _ventRoutine.Monitor();
- if (result == RState.Failed || result == RState.Timeout)
- {
- Runner.Stop($"Vent failed.");
- if (result == RState.Timeout)
- {
- Stop(_chamber.CheckLift1Up() ? $"Set Lift1 Pin Up timeout in {_VentingAndPinUpTimeout / 1000} seconds" : $"Venting timeout in {_VentingAndPinUpTimeout / 1000} seconds");
- Stop(_chamber.CheckLift2Up() ? $"Set Lift2 Pin Up timeout in {_VentingAndPinUpTimeout / 1000} seconds" : $"Venting timeout in {_VentingAndPinUpTimeout / 1000} seconds");
- }
- return true;
- }
- return res1 && res2 && result == RState.End;
- }
- else
- return true;
- }
- }
- }
|