123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- 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<int>($"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<bool, Result> 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<bool, Result> 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());
- }
- }
- }
- }
|