PMPostTransferRoutine.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using System;
  2. using Aitex.Core.RT.Routine;
  3. using Aitex.Core.RT.SCCore;
  4. using VirgoRT.Devices;
  5. namespace VirgoRT.Modules.PMs
  6. {
  7. class PMPostTransferRoutine : PMRoutineBase, IRoutine
  8. {
  9. enum RoutineStep
  10. {
  11. PumpDown,
  12. SetSlitDoor,
  13. SlitDoorDelay,
  14. kEnd
  15. }
  16. private int _timeout;
  17. public PMPostTransferRoutine(JetPM chamber) : base(chamber)
  18. {
  19. Name = "PostTransfer";
  20. }
  21. public Result Start(params object[] objs)
  22. {
  23. Reset();
  24. _timeout = SC.GetValue<int>($"{Module}.PrepareTransferTimeout");
  25. Notify("开始");
  26. return Result.RUN;
  27. }
  28. public Result Monitor()
  29. {
  30. try
  31. {
  32. CloseSlitDoor((int)RoutineStep.SetSlitDoor, _timeout);
  33. End((int)RoutineStep.kEnd);
  34. }
  35. catch (RoutineBreakException)
  36. {
  37. return Result.RUN;
  38. }
  39. catch (RoutineFaildException)
  40. {
  41. Notify("出错");
  42. return Result.FAIL;
  43. }
  44. catch (Exception ex)
  45. {
  46. Stop(ex.Message);
  47. return Result.FAIL;
  48. }
  49. Notify("结束");
  50. return Result.DONE;
  51. }
  52. public override void Abort() { }
  53. protected void CloseSlitDoor(int id, int timeout)
  54. {
  55. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  56. {
  57. Notify($"设置传送门 {_chamber.Name} " + (false ? "开" : "关"));
  58. _chamber.SetSlitDoor(false, out _);
  59. return true;
  60. }, () => true, timeout * 1000);
  61. if (ret.Item1)
  62. {
  63. if (ret.Item2 == Result.FAIL)
  64. {
  65. throw new RoutineFaildException();
  66. }
  67. else if (ret.Item2 == Result.TIMEOUT) //timeout
  68. {
  69. Stop($"无法关传送门 in {timeout} seconds");
  70. throw new RoutineFaildException();
  71. }
  72. else
  73. throw new RoutineBreakException();
  74. }
  75. }
  76. }
  77. }