using Aitex.Core.RT.Routine; using Aitex.Core.RT.SCCore; using Venus_RT.Devices; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.SubstrateTrackings; using Venus_Core; namespace Venus_RT.Modules.PMs { class LLPickRoutine : PMRoutineBase, IRoutine { private enum LLPickStep { kPrepareTransfer, kExtend, kPinUp, kRetract, kPostTransfer, kVentLoadLock, } private readonly LoadLockVentRoutine _loadLockVentRoutine; private int _prepareTransferTimeout = 120; private int _transferWaferTimeout = 120; private bool _isATMMode = false; public LLPickRoutine(JetPM chamber, LoadLockVentRoutine ventRoutine) : base(chamber) { Name = "PickWafer"; _loadLockVentRoutine = ventRoutine; } public RState Start(params object[] objs) { _prepareTransferTimeout = SC.GetValue($"{Module}.PrepareTransferTimeout"); _transferWaferTimeout = SC.GetValue($"{Module}.TransferWaferTimeout"); _isATMMode = SC.GetValue("System.IsATMMode"); if(WaferManager.Instance.CheckNoWafer(ModuleName.PMA, 0)) { Stop("腔体没有 Wafer,不能执行取片动作"); return RState.Failed; } if (WaferManager.Instance.CheckHasWafer(ModuleName.LLA, 0)) { Stop("Loadlock 里面有片 Wafer,不能执行取片动作"); return RState.Failed; } if(WaferManager.Instance.GetWafer(ModuleName.PMA, 0).ChuckState == Aitex.Core.Common.EnumWaferChuckStatus.Chucked) { Stop("腔体中Wafer没有 Dechuck,不能执行取片动作"); return RState.Failed; } if (_isATMMode) { if (!_chamber.IsATM || !_chamber.IsATMLoadlock) { Stop("腔体非大气状态,请先执行充气动作"); return RState.Failed; } } else { if (!_chamber.IsVAC || !_chamber.IsVACLoadLock) { Stop("腔体非真空状态,请先执行抽真空动作"); return RState.Failed; } } _chamber.OpenValve(ValveType.FastPump, false); _chamber.OpenValve(ValveType.LoadlockPumping, false); Reset(); return Runner.Start(Module, Name); } public RState Monitor() { Runner.Run((int)LLPickStep.kPrepareTransfer, PrepareTransfer, IsPrepareReady, _prepareTransferTimeout * 1000) .Run((int)LLPickStep.kExtend, _chamber.ExtendWafer, () => { return _chamber.IsLoadlockArmExtend; }, _transferWaferTimeout * 1000) .Run((int)LLPickStep.kPinUp, SetLiftPinDown, () => { return _chamber.CheckLiftDown(); }) .Run((int)LLPickStep.kRetract, _chamber.RetractWafer, () => { return _chamber.IsLoadlockArmRetract; }, _transferWaferTimeout * 1000) .Run((int)LLPickStep.kPostTransfer, PostTransfer, IsPostTransferReady, _prepareTransferTimeout * 1000) .End((int)LLPickStep.kVentLoadLock, VentLoadLock, IsVentDone); return Runner.Status; } private bool PrepareTransfer() { _chamber.SetLiftPin(MovementPosition.Up, out _); _chamber.SetSlitDoor(true, out _); return true; } private bool IsPrepareReady() { return _chamber.CheckLiftUp() && _chamber.CheckSlitDoorOpen(); } private bool PostTransfer() { WaferManager.Instance.WaferMoved(ModuleName.PMA, 0, ModuleName.LLA, 0); _chamber.SetSlitDoor(false, out _); return true; } private bool IsPostTransferReady() { return _chamber.CheckLiftDown() && _chamber.CheckSlitDoorClose(); } private bool SetLiftPinDown() { return _chamber.SetLiftPin(MovementPosition.Down, out _); } private bool VentLoadLock() { if (!_isATMMode) { return _loadLockVentRoutine.Start() == RState.Running; } else return true; } private bool IsVentDone() { if(!_isATMMode) { RState ret = _loadLockVentRoutine.Monitor(); if (ret == RState.Failed || ret == RState.Timeout) { Runner.Stop("Vent Failed"); return false; } return ret == RState.End; } return true; } public void Abort() { } } }