RobotCycleMoveRoutine.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using Aitex.Core.RT.Routine;
  2. using Aitex.Core.RT.SCCore;
  3. using PunkHPX8_Core;
  4. using PunkHPX8_RT.Devices.EFEM;
  5. using MECF.Framework.Common.Equipment;
  6. using MECF.Framework.Common.Routine;
  7. using MECF.Framework.Common.Schedulers;
  8. using MECF.Framework.Common.Utilities;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. namespace PunkHPX8_RT.Modules.EFEM
  15. {
  16. public class RobotCycleMoveRoutine : RoutineBase, IRoutine
  17. {
  18. private enum CycleStep
  19. {
  20. LoopStart,
  21. LoopRun,
  22. LoopCheck,
  23. LoopEnd,
  24. End
  25. }
  26. private EfemPickRoutine _efemPickRoutine;
  27. private EfemPlaceRoutine _efemPlaceRoutine;
  28. private EFEMAlignRoutine _efemAlignRoutine;
  29. private IRoutine _currentRoutine;
  30. private List<EfemCycleAction> _moveActionQueue;
  31. /// <summary>
  32. /// 构建函数
  33. /// </summary>
  34. /// <param name="module"></param>
  35. public RobotCycleMoveRoutine(EfemBase efem) : base(ModuleName.EfemRobot.ToString())
  36. {
  37. _efemPickRoutine = new EfemPickRoutine(efem);
  38. _efemPlaceRoutine = new EfemPlaceRoutine(efem);
  39. _efemAlignRoutine = new EFEMAlignRoutine(efem);
  40. }
  41. /// <summary>
  42. /// 中止
  43. /// </summary>
  44. public void Abort()
  45. {
  46. Runner.Stop("Manual abort");
  47. }
  48. /// <summary>
  49. /// 中止
  50. /// </summary>
  51. /// <returns></returns>
  52. public RState Monitor()
  53. {
  54. Runner.LoopStart(CycleStep.LoopStart, "start efem cycle action", _moveActionQueue.Count, NullFun, _delay_1ms)
  55. .LoopRun(CycleStep.LoopRun, RunAction, _delay_1ms)
  56. .LoopRunWithStopStatus(CycleStep.LoopCheck, () => CommonFunction.CheckRoutineEndState(_currentRoutine),
  57. () => CommonFunction.CheckRoutineStopState(_currentRoutine))
  58. .LoopEnd(CycleStep.LoopEnd, NullFun, _delay_1ms)
  59. .End(CycleStep.End, NullFun, _delay_1ms);
  60. return Runner.Status;
  61. }
  62. private bool RunAction()
  63. {
  64. EfemCycleAction action = _moveActionQueue[Runner.LoopCounter];
  65. switch(action.Action)
  66. {
  67. case "Pick":
  68. Queue<MoveItem> moveItems = new Queue<MoveItem>();
  69. moveItems.Enqueue((MoveItem)action.Parameter);
  70. _currentRoutine = _efemPickRoutine;
  71. return _efemPickRoutine.Start(moveItems) == RState.Running;
  72. case "Place":
  73. Queue<MoveItem> placeMoveItems = new Queue<MoveItem>();
  74. placeMoveItems.Enqueue((MoveItem)action.Parameter);
  75. _currentRoutine= _efemPlaceRoutine;
  76. return _efemPlaceRoutine.Start(placeMoveItems) == RState.Running;
  77. case "Align":
  78. _currentRoutine = _efemAlignRoutine;
  79. object[] alignerParamater = new object[4];//初始化Align参数
  80. alignerParamater[0] = ModuleName.Aligner1;
  81. alignerParamater[1] = 0;
  82. alignerParamater[2] = action.Parameter;
  83. alignerParamater[3] = SC.GetValue<int>("EFEM.Aligner1.AlignerPlatType");
  84. return _efemAlignRoutine.Start(alignerParamater) ==RState.Running;
  85. }
  86. return false;
  87. }
  88. /// <summary>
  89. /// 启动
  90. /// </summary>
  91. /// <param name="objs"></param>
  92. /// <returns></returns>
  93. public RState Start(params object[] objs)
  94. {
  95. _moveActionQueue = (List<EfemCycleAction>)objs[0];
  96. return Runner.Start(Module, "Robot Cycle move");
  97. }
  98. }
  99. }