PMPostTransferRoutine.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. using System;
  2. using Aitex.Core.RT.Routine;
  3. using Aitex.Core.RT.SCCore;
  4. using MECF.Framework.Common.Schedulers;
  5. namespace FurnaceRT.Equipments.PMs.Routines
  6. {
  7. public class PMPostTransferRoutine : ModuleRoutine, IRoutine
  8. {
  9. enum RoutineStep
  10. {
  11. CloseDoor,
  12. LiftPinDown,
  13. }
  14. private EnumTransferType _paramTransferType;
  15. private int _timeout;
  16. private PMModule _pm;
  17. public PMPostTransferRoutine(string module, PMModule pm)
  18. {
  19. Module = module.ToString();
  20. Name = "Post transfer";
  21. _pm = pm;
  22. }
  23. public Result Init(EnumTransferType type)
  24. {
  25. _paramTransferType = type;
  26. return Result.DONE;
  27. }
  28. public Result Start(params object[] objs)
  29. {
  30. Reset();
  31. _timeout = SC.GetValue<int>($"PM.PostTransferTimeout");
  32. Notify($"Start");
  33. return Result.RUN;
  34. }
  35. public Result Monitor()
  36. {
  37. try
  38. {
  39. CloseChamberDoor((int)RoutineStep.CloseDoor, _pm, _paramTransferType, _timeout);
  40. //放到process过程中,提高产能
  41. //if (_paramTransferType == EnumTransferType.Place)
  42. //{
  43. // LiftPinDown((int)RoutineStep.LiftPinDown, _pm, _paramTransferType, _timeout);
  44. //}
  45. }
  46. catch (RoutineBreakException)
  47. {
  48. return Result.RUN;
  49. }
  50. catch (RoutineFaildException)
  51. {
  52. return Result.FAIL;
  53. }
  54. Notify("Finished");
  55. return Result.DONE;
  56. }
  57. public void Abort()
  58. {
  59. }
  60. public void CloseChamberDoor(int id, PMModule pm, EnumTransferType type, int timeout)
  61. {
  62. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  63. {
  64. Notify($"{pm.Name} close chamber door");
  65. //if (!pm.ChamberDoor.Close(out string reason))
  66. //{
  67. // Stop(reason);
  68. // return false;
  69. //}
  70. return true;
  71. }, () =>
  72. {
  73. //检查到开始关闭,就离开,为了提高产能做的优化。正常需要判断是否关闭
  74. return true/*!pm.ChamberDoor.OpenFeedback*/;
  75. }, timeout * 1000);
  76. if (ret.Item1)
  77. {
  78. if (ret.Item2 == Result.FAIL)
  79. {
  80. throw (new RoutineFaildException());
  81. }
  82. else if (ret.Item2 == Result.TIMEOUT) //timeout
  83. {
  84. Stop($"{pm.Name} close chamber door timeout, over {timeout} seconds");
  85. throw (new RoutineFaildException());
  86. }
  87. else
  88. throw (new RoutineBreakException());
  89. }
  90. }
  91. public void LiftPinDown(int id, PMModule pm, EnumTransferType type, int timeout)
  92. {
  93. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  94. {
  95. Notify($"{pm.Name} lift pin down");
  96. //if (!pm.ChamberLiftPin.MoveDown(out string reason))
  97. //{
  98. // Stop(reason);
  99. // return false;
  100. //}
  101. return true;
  102. }, () =>
  103. {
  104. return true/*pm.ChamberLiftPin.IsDown*/;
  105. }, timeout * 1000);
  106. if (ret.Item1)
  107. {
  108. if (ret.Item2 == Result.FAIL)
  109. {
  110. throw (new RoutineFaildException());
  111. }
  112. else if (ret.Item2 == Result.TIMEOUT) //timeout
  113. {
  114. Stop($"{pm.Name} move down lift pin timeout, over {timeout} seconds");
  115. throw (new RoutineFaildException());
  116. }
  117. else
  118. throw (new RoutineBreakException());
  119. }
  120. }
  121. }
  122. }