PlatingCellUnloadRoutine.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Routine;
  3. using Aitex.Core.RT.SCCore;
  4. using Aitex.Core.Util;
  5. using MECF.Framework.Common.RecipeCenter;
  6. using MECF.Framework.Common.Routine;
  7. using MECF.Framework.Common.Utilities;
  8. using PunkHPX8_Core;
  9. using PunkHPX8_RT.Devices.AXIS;
  10. using PunkHPX8_RT.Devices.PlatingCell;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Linq;
  14. using System.Reflection;
  15. using System.Text;
  16. using System.Threading.Tasks;
  17. namespace PunkHPX8_RT.Modules.PlatingCell
  18. {
  19. public class PlatingCellUnloadRoutine : RoutineBase, IRoutine
  20. {
  21. private enum RunRecipeStep
  22. {
  23. VerticalGotoLoad,
  24. CheckVerticalGotoLoad,
  25. ClamShellOpen,
  26. End
  27. }
  28. #region 常量
  29. #endregion
  30. /// <summary>
  31. /// Platingcell device
  32. /// </summary>
  33. private PlatingCellDevice _device;
  34. /// <summary>
  35. /// vertical axis entity
  36. /// </summary>
  37. private PlatingCellVerticalEntity _verticalEntity;
  38. /// <summary>
  39. /// 构造函数
  40. /// </summary>
  41. /// <param name="module"></param>
  42. public PlatingCellUnloadRoutine(string module) : base(module)
  43. {
  44. }
  45. /// <summary>
  46. /// 中止
  47. /// </summary>
  48. public void Abort()
  49. {
  50. Runner.Stop("Manual Abort");
  51. }
  52. /// <summary>
  53. /// 监控
  54. /// </summary>
  55. /// <returns></returns>
  56. public RState Monitor()
  57. {
  58. Runner.Run(RunRecipeStep.VerticalGotoLoad, () => StartVertical("Load"), _delay_1ms)
  59. .WaitWithStopCondition(RunRecipeStep.CheckVerticalGotoLoad, CheckVerticalEnd, CheckVerticalError)
  60. .Run(RunRecipeStep.ClamShellOpen, () => _device.ClamShellOpen(), CheckClamShellOpen, _delay_1s)
  61. .End(RunRecipeStep.End, NullFun);
  62. return Runner.Status;
  63. }
  64. /// <summary>
  65. /// vertical 运行
  66. /// </summary>
  67. /// <param name="positionName"></param> 目标位置名称
  68. /// <param name="offset"></param> 偏移量
  69. /// <returns></returns>
  70. private bool StartVertical(string positionName)
  71. {
  72. return _verticalEntity.CheckToPostMessage<PlatingCellVerticalState, PlatingCellVerticalEntity.VerticalMsg>(Aitex.Core.RT.Log.eEvent.INFO_PLATINGCELL,
  73. Module, (int)PlatingCellVerticalEntity.VerticalMsg.Position, positionName,0);
  74. }
  75. /// <summary>
  76. /// 检验垂直电机是否运动完成
  77. /// </summary>
  78. /// <returns></returns>
  79. private bool CheckVerticalEnd()
  80. {
  81. return _verticalEntity.IsIdle;
  82. }
  83. /// <summary>
  84. /// 检验垂直是否出现错误
  85. /// </summary>
  86. /// <returns></returns>
  87. private bool CheckVerticalError()
  88. {
  89. return _verticalEntity.IsError;
  90. }
  91. /// <summary>
  92. /// 检查ClamShell是否Open
  93. /// </summary>
  94. /// <returns></returns>
  95. private bool CheckClamShellOpen()
  96. {
  97. return _device.PlatingCellDeviceData.ClamShellOpened;
  98. }
  99. /// <summary>
  100. /// 启动
  101. /// </summary>
  102. /// <param name="objs"></param>
  103. /// <returns></returns>
  104. public RState Start(params object[] objs)
  105. {
  106. _device = DEVICE.GetDevice<PlatingCellDevice>(Module);
  107. //获取vertical entity
  108. string vertical = ModuleMatcherManager.Instance.GetPlatingVerticalByCell(Module);
  109. _verticalEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellVerticalEntity>(vertical);
  110. return Runner.Start(Module, "start unload");
  111. }
  112. }
  113. }