123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- using System;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using VirgoRT.Devices;
- namespace VirgoRT.Modules.PMs
- {
- class PMPostTransferRoutine : PMRoutineBase, IRoutine
- {
- enum RoutineStep
- {
- PumpDown,
- SetSlitDoor,
- SlitDoorDelay,
- kEnd
- }
- private int _timeout;
- public PMPostTransferRoutine(JetPM chamber) : base(chamber)
- {
- Name = "PostTransfer";
- }
- public Result Start(params object[] objs)
- {
- Reset();
- _timeout = SC.GetValue<int>($"{Module}.PrepareTransferTimeout");
- Notify("开始");
- return Result.RUN;
- }
- public Result Monitor()
- {
- try
- {
- CloseSlitDoor((int)RoutineStep.SetSlitDoor, _timeout);
- End((int)RoutineStep.kEnd);
- }
- catch (RoutineBreakException)
- {
- return Result.RUN;
- }
- catch (RoutineFaildException)
- {
- Notify("出错");
- return Result.FAIL;
- }
- catch (Exception ex)
- {
- Stop(ex.Message);
- return Result.FAIL;
- }
- Notify("结束");
- return Result.DONE;
- }
- public override void Abort() { }
- protected void CloseSlitDoor(int id, int timeout)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify($"设置传送门 {_chamber.Name} " + (false ? "开" : "关"));
- _chamber.SetSlitDoor(false, out _);
- return true;
- }, () => true, timeout * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw new RoutineFaildException();
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- Stop($"无法关传送门 in {timeout} seconds");
- throw new RoutineFaildException();
- }
- else
- throw new RoutineBreakException();
- }
- }
- }
- }
|