PlatingCellInterRinseRoutine.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. using Aitex.Core.RT.Log;
  2. using Aitex.Core.RT.Routine;
  3. using MECF.Framework.Common.Beckhoff.AxisProvider;
  4. using MECF.Framework.Common.RecipeCenter;
  5. using MECF.Framework.Common.Routine;
  6. using MECF.Framework.Common.Utilities;
  7. using PunkHPX8_Core;
  8. using PunkHPX8_RT.Devices.AXIS;
  9. using PunkHPX8_RT.Devices.PlatingCell;
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. namespace PunkHPX8_RT.Modules.PlatingCell
  16. {
  17. public class PlatingCellInterRinseRoutine : RoutineBase, IRoutine
  18. {
  19. private enum RunRecipeStep
  20. {
  21. OpenRinseValve,
  22. StartRotation,
  23. WaitRotation,
  24. CloseRinseValve,
  25. End
  26. }
  27. #region 常量
  28. /// <summary>
  29. /// ROTATION电机转速比例
  30. /// </summary>
  31. private const int SPEED_RATIO = 1;
  32. #endregion
  33. /// <summary>
  34. /// recipe
  35. /// </summary>
  36. private DepRecipe _recipe;
  37. /// <summary>
  38. /// Rotation axis
  39. /// </summary>
  40. private JetAxisBase _rotationAxis;
  41. /// <summary>
  42. /// Platingcell device
  43. /// </summary>
  44. private PlatingCellDevice _device;
  45. /// <summary>
  46. ///rotation Provider对象
  47. /// </summary>
  48. private BeckhoffProviderAxis _rotationProviderAxis;
  49. /// <summary>
  50. /// rotation运动的目的地
  51. /// </summary>
  52. private int _targetPosition;
  53. /// <summary>
  54. /// 构造函数
  55. /// </summary>
  56. /// <param name="module"></param>
  57. public PlatingCellInterRinseRoutine(string module) : base(module)
  58. {
  59. }
  60. /// <summary>
  61. /// 中止
  62. /// </summary>
  63. public void Abort()
  64. {
  65. Runner.Stop("Manual Abort");
  66. }
  67. /// <summary>
  68. /// 监控
  69. /// </summary>
  70. /// <returns></returns>
  71. public RState Monitor()
  72. {
  73. Runner.Run(RunRecipeStep.OpenRinseValve, _device.RinseEnableAction, _delay_1ms)
  74. .Run(RunRecipeStep.StartRotation, () => { return StartRotation(_targetPosition); }, _delay_1ms)
  75. .Delay(RunRecipeStep.WaitRotation, _recipe.IntervalRinseTime*1000)
  76. .Run(RunRecipeStep.CloseRinseValve, _device.RinseDisableAction, _delay_1ms)
  77. .End(RunRecipeStep.End, NullFun);
  78. return Runner.Status;
  79. }
  80. /// <summary>
  81. /// rotation开始旋转
  82. /// </summary>
  83. /// <param name="param"></param>
  84. /// <returns></returns>
  85. private bool StartRotation(int targetPosition)
  86. {
  87. bool result = _rotationAxis.ProfilePosition(targetPosition, _recipe.IntervalRinseSpeed * SPEED_RATIO * 6, 0, 0); //rpm->deg/s
  88. if (!result)
  89. {
  90. NotifyError(eEvent.ERR_PLATINGCELL, "Start Rotation is failed", 0);
  91. return false;
  92. }
  93. return true;
  94. }
  95. /// <summary>
  96. /// 启动
  97. /// </summary>
  98. /// <param name="objs"></param>
  99. /// <returns></returns>
  100. public RState Start(params object[] objs)
  101. {
  102. _recipe = (DepRecipe)objs[0];
  103. _rotationAxis = (JetAxisBase)objs[1];
  104. _device = (PlatingCellDevice)objs[2];
  105. _rotationProviderAxis = (BeckhoffProviderAxis)objs[3];
  106. _targetPosition = (int)objs[4];
  107. return Runner.Start(Module, "start intervale rinse");
  108. }
  109. }
  110. }