using System; using Aitex.Core.RT.Routine; using Aitex.Core.RT.SCCore; using MECF.Framework.Common.Schedulers; namespace FurnaceRT.Equipments.PMs.Routines { public class PMPostTransferRoutine : ModuleRoutine, IRoutine { enum RoutineStep { CloseDoor, LiftPinDown, } private EnumTransferType _paramTransferType; private int _timeout; private PMModule _pm; public PMPostTransferRoutine(string module, PMModule pm) { Module = module.ToString(); Name = "Post transfer"; _pm = pm; } public Result Init(EnumTransferType type) { _paramTransferType = type; return Result.DONE; } public Result Start(params object[] objs) { Reset(); _timeout = SC.GetValue($"PM.PostTransferTimeout"); Notify($"Start"); return Result.RUN; } public Result Monitor() { try { CloseChamberDoor((int)RoutineStep.CloseDoor, _pm, _paramTransferType, _timeout); //放到process过程中,提高产能 //if (_paramTransferType == EnumTransferType.Place) //{ // LiftPinDown((int)RoutineStep.LiftPinDown, _pm, _paramTransferType, _timeout); //} } catch (RoutineBreakException) { return Result.RUN; } catch (RoutineFaildException) { return Result.FAIL; } Notify("Finished"); return Result.DONE; } public void Abort() { } public void CloseChamberDoor(int id, PMModule pm, EnumTransferType type, int timeout) { Tuple ret = ExecuteAndWait(id, () => { Notify($"{pm.Name} close chamber door"); //if (!pm.ChamberDoor.Close(out string reason)) //{ // Stop(reason); // return false; //} return true; }, () => { //检查到开始关闭,就离开,为了提高产能做的优化。正常需要判断是否关闭 return true/*!pm.ChamberDoor.OpenFeedback*/; }, timeout * 1000); if (ret.Item1) { if (ret.Item2 == Result.FAIL) { throw (new RoutineFaildException()); } else if (ret.Item2 == Result.TIMEOUT) //timeout { Stop($"{pm.Name} close chamber door timeout, over {timeout} seconds"); throw (new RoutineFaildException()); } else throw (new RoutineBreakException()); } } public void LiftPinDown(int id, PMModule pm, EnumTransferType type, int timeout) { Tuple ret = ExecuteAndWait(id, () => { Notify($"{pm.Name} lift pin down"); //if (!pm.ChamberLiftPin.MoveDown(out string reason)) //{ // Stop(reason); // return false; //} return true; }, () => { return true/*pm.ChamberLiftPin.IsDown*/; }, timeout * 1000); if (ret.Item1) { if (ret.Item2 == Result.FAIL) { throw (new RoutineFaildException()); } else if (ret.Item2 == Result.TIMEOUT) //timeout { Stop($"{pm.Name} move down lift pin timeout, over {timeout} seconds"); throw (new RoutineFaildException()); } else throw (new RoutineBreakException()); } } } }