PMPrepareTransferRoutine.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. using Aitex.Core.RT.Routine;
  2. using Aitex.Core.RT.SCCore;
  3. using MECF.Framework.Common.Equipment;
  4. using MECF.Framework.Common.Schedulers;
  5. using FurnaceRT.Equipments.PMs;
  6. using FurnaceRT.Equipments.PMs.Routines;
  7. using System;
  8. namespace FurnaceRT.Modules.PMs
  9. {
  10. public class PMPrepareTransferRoutine : PMBaseRoutine
  11. {
  12. enum RoutineStep
  13. {
  14. Vent,
  15. MovePinUp,
  16. OpenDoor,
  17. Delay1,
  18. Delay2,
  19. }
  20. private EnumTransferType _paramTransferType;
  21. private int _timeout;
  22. private bool _needVent;
  23. public PMPrepareTransferRoutine(string module, PMModule pm) : base(ModuleHelper.Converter(module), pm)
  24. {
  25. Module = module;
  26. Name = "Prepare transfer";
  27. }
  28. public Result Init(EnumTransferType type)
  29. {
  30. _paramTransferType = type;
  31. return Result.DONE;
  32. }
  33. public override Result Start(params object[] objs)
  34. {
  35. Reset();
  36. _timeout = SC.GetValue<int>("PM.PrepareTransferTimeout");
  37. double basePressure = SC.GetValue<double>($"PM.AtmPressureBase");
  38. //_needVent = PMModule.ChamberDoor.IsClose &&
  39. // PMModule.ChamberPressure < basePressure;
  40. Notify("Start");
  41. return Result.RUN;
  42. }
  43. public override Result Monitor()
  44. {
  45. try
  46. {
  47. //先开门,再升pin,避免升起来之后,气流导致的偏移
  48. OpenDoor((int)RoutineStep.OpenDoor, PMModule, _paramTransferType, _timeout);
  49. Delay((int)RoutineStep.Delay1, 1);
  50. MovePinUp((int)RoutineStep.MovePinUp, PMModule, _paramTransferType, _timeout);
  51. //Delay((int)RoutineStep.Delay2, 2);
  52. }
  53. catch (RoutineBreakException)
  54. {
  55. return Result.RUN;
  56. }
  57. catch (RoutineFaildException)
  58. {
  59. return Result.FAIL;
  60. }
  61. Notify("Finished");
  62. return Result.DONE;
  63. }
  64. public override void Abort()
  65. {
  66. }
  67. public void MovePinUp(int id, PMModule pm, EnumTransferType type, int timeout)
  68. {
  69. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  70. {
  71. Notify($"{pm.Name} lift pin up ");
  72. //if (!pm.ChamberLiftPin.MoveUp(out string reason))
  73. //{
  74. // Stop(reason);
  75. // return false;
  76. //}
  77. return true;
  78. }, () =>
  79. {
  80. return true/*pm.ChamberLiftPin.IsUp*/;
  81. }, timeout * 1000);
  82. if (ret.Item1)
  83. {
  84. if (ret.Item2 == Result.FAIL)
  85. {
  86. throw (new RoutineFaildException());
  87. }
  88. else if (ret.Item2 == Result.TIMEOUT) //timeout
  89. {
  90. Stop($"{pm.Name} move lift pin up timeout, over {timeout} seconds");
  91. throw (new RoutineFaildException());
  92. }
  93. else
  94. throw (new RoutineBreakException());
  95. }
  96. }
  97. public void OpenDoor(int id, PMModule pm, EnumTransferType type, int timeout)
  98. {
  99. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  100. {
  101. Notify($"{pm.Name} open door");
  102. //if (!pm.ChamberDoor.Open(out string reason))
  103. //{
  104. // Stop(reason);
  105. // return false;
  106. //}
  107. return true;
  108. }, () =>
  109. {
  110. return true/*pm.ChamberDoor.IsOpen*/;
  111. }, timeout * 1000);
  112. if (ret.Item1)
  113. {
  114. if (ret.Item2 == Result.FAIL)
  115. {
  116. throw (new RoutineFaildException());
  117. }
  118. else if (ret.Item2 == Result.TIMEOUT) //timeout
  119. {
  120. Stop($"{pm.Name} open door timeout, over {timeout} seconds");
  121. throw (new RoutineFaildException());
  122. }
  123. else
  124. throw (new RoutineBreakException());
  125. }
  126. }
  127. }
  128. }