using Aitex.Core.RT.Routine; using Aitex.Core.RT.SCCore; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.Schedulers; using FurnaceRT.Equipments.PMs; using FurnaceRT.Equipments.PMs.Routines; using System; namespace FurnaceRT.Modules.PMs { public class PMPrepareTransferRoutine : PMBaseRoutine { enum RoutineStep { Vent, MovePinUp, OpenDoor, Delay1, Delay2, } private EnumTransferType _paramTransferType; private int _timeout; private bool _needVent; public PMPrepareTransferRoutine(string module, PMModule pm) : base(ModuleHelper.Converter(module), pm) { Module = module; Name = "Prepare transfer"; } public Result Init(EnumTransferType type) { _paramTransferType = type; return Result.DONE; } public override Result Start(params object[] objs) { Reset(); _timeout = SC.GetValue("PM.PrepareTransferTimeout"); double basePressure = SC.GetValue($"PM.AtmPressureBase"); //_needVent = PMModule.ChamberDoor.IsClose && // PMModule.ChamberPressure < basePressure; Notify("Start"); return Result.RUN; } public override Result Monitor() { try { //先开门,再升pin,避免升起来之后,气流导致的偏移 OpenDoor((int)RoutineStep.OpenDoor, PMModule, _paramTransferType, _timeout); Delay((int)RoutineStep.Delay1, 1); MovePinUp((int)RoutineStep.MovePinUp, PMModule, _paramTransferType, _timeout); //Delay((int)RoutineStep.Delay2, 2); } catch (RoutineBreakException) { return Result.RUN; } catch (RoutineFaildException) { return Result.FAIL; } Notify("Finished"); return Result.DONE; } public override void Abort() { } public void MovePinUp(int id, PMModule pm, EnumTransferType type, int timeout) { Tuple ret = ExecuteAndWait(id, () => { Notify($"{pm.Name} lift pin up "); //if (!pm.ChamberLiftPin.MoveUp(out string reason)) //{ // Stop(reason); // return false; //} return true; }, () => { return true/*pm.ChamberLiftPin.IsUp*/; }, timeout * 1000); if (ret.Item1) { if (ret.Item2 == Result.FAIL) { throw (new RoutineFaildException()); } else if (ret.Item2 == Result.TIMEOUT) //timeout { Stop($"{pm.Name} move lift pin up timeout, over {timeout} seconds"); throw (new RoutineFaildException()); } else throw (new RoutineBreakException()); } } public void OpenDoor(int id, PMModule pm, EnumTransferType type, int timeout) { Tuple ret = ExecuteAndWait(id, () => { Notify($"{pm.Name} open door"); //if (!pm.ChamberDoor.Open(out string reason)) //{ // Stop(reason); // return false; //} return true; }, () => { return true/*pm.ChamberDoor.IsOpen*/; }, timeout * 1000); if (ret.Item1) { if (ret.Item2 == Result.FAIL) { throw (new RoutineFaildException()); } else if (ret.Item2 == Result.TIMEOUT) //timeout { Stop($"{pm.Name} open door timeout, over {timeout} seconds"); throw (new RoutineFaildException()); } else throw (new RoutineBreakException()); } } } }