|  | @@ -1,6 +1,12 @@
 | 
	
		
			
				|  |  | -using Aitex.Core.RT.Routine;
 | 
	
		
			
				|  |  | +using Aitex.Core.RT.Log;
 | 
	
		
			
				|  |  | +using Aitex.Core.RT.Routine;
 | 
	
		
			
				|  |  | +using MECF.Framework.Common.Beckhoff.AxisProvider;
 | 
	
		
			
				|  |  | +using MECF.Framework.Common.RecipeCenter;
 | 
	
		
			
				|  |  |  using MECF.Framework.Common.Routine;
 | 
	
		
			
				|  |  | +using MECF.Framework.Common.Utilities;
 | 
	
		
			
				|  |  |  using PunkHPX8_Core;
 | 
	
		
			
				|  |  | +using PunkHPX8_RT.Devices.AXIS;
 | 
	
		
			
				|  |  | +using PunkHPX8_RT.Devices.PlatingCell;
 | 
	
		
			
				|  |  |  using System;
 | 
	
		
			
				|  |  |  using System.Collections.Generic;
 | 
	
		
			
				|  |  |  using System.Linq;
 | 
	
	
		
			
				|  | @@ -13,15 +19,43 @@ namespace PunkHPX8_RT.Modules.PlatingCell
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  |          private enum RunRecipeStep
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | -            Delay,
 | 
	
		
			
				|  |  | +            OpenRinseValve,
 | 
	
		
			
				|  |  | +            StartRotation,
 | 
	
		
			
				|  |  | +            CheckRotationStop,
 | 
	
		
			
				|  |  | +            CloseRinseValve,
 | 
	
		
			
				|  |  |              End
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        #region 常量
 | 
	
		
			
				|  |  | +        /// <summary>
 | 
	
		
			
				|  |  | +        /// ROTATION电机转速比例
 | 
	
		
			
				|  |  | +        /// </summary>
 | 
	
		
			
				|  |  | +        private const int SPEED_RATIO = 1;
 | 
	
		
			
				|  |  | +        #endregion
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        /// <summary>
 | 
	
		
			
				|  |  | +        /// recipe
 | 
	
		
			
				|  |  | +        /// </summary>
 | 
	
		
			
				|  |  | +        private DepRecipe _recipe;
 | 
	
		
			
				|  |  | +        /// <summary>
 | 
	
		
			
				|  |  | +        /// Rotation axis
 | 
	
		
			
				|  |  | +        /// </summary>
 | 
	
		
			
				|  |  | +        private JetAxisBase _rotationAxis;
 | 
	
		
			
				|  |  | +        /// <summary>
 | 
	
		
			
				|  |  | +        /// Platingcell device
 | 
	
		
			
				|  |  | +        /// </summary>
 | 
	
		
			
				|  |  | +        private PlatingCellDevice _device;
 | 
	
		
			
				|  |  | +        /// <summary>
 | 
	
		
			
				|  |  | +        ///rotation Provider对象
 | 
	
		
			
				|  |  | +        /// </summary>
 | 
	
		
			
				|  |  | +        private BeckhoffProviderAxis _rotationProviderAxis;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          /// <summary>
 | 
	
		
			
				|  |  |          /// 构造函数
 | 
	
		
			
				|  |  |          /// </summary>
 | 
	
		
			
				|  |  |          /// <param name="module"></param>
 | 
	
		
			
				|  |  |          public PlatingCellInterRinseRoutine(string module) : base(module)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          /// <summary>
 | 
	
		
			
				|  |  |          /// 中止
 | 
	
	
		
			
				|  | @@ -36,10 +70,60 @@ namespace PunkHPX8_RT.Modules.PlatingCell
 | 
	
		
			
				|  |  |          /// <returns></returns>
 | 
	
		
			
				|  |  |          public RState Monitor()
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | -            Runner.Delay(RunRecipeStep.Delay, 5000)
 | 
	
		
			
				|  |  | +            Runner.Run(RunRecipeStep.OpenRinseValve, _device.RinseEnableAction, _delay_1ms)
 | 
	
		
			
				|  |  | +                .Run(RunRecipeStep.StartRotation, StartRotation, _delay_1ms)
 | 
	
		
			
				|  |  | +                .WaitWithStopCondition(RunRecipeStep.CheckRotationStop, CheckRotationEndStatus, CheckRotationStopStatus)
 | 
	
		
			
				|  |  | +                .Run(RunRecipeStep.CloseRinseValve, _device.RinseDisableAction, _delay_1ms)
 | 
	
		
			
				|  |  |                  .End(RunRecipeStep.End, NullFun);
 | 
	
		
			
				|  |  |              return Runner.Status;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        /// <summary>
 | 
	
		
			
				|  |  | +        /// rotation开始旋转
 | 
	
		
			
				|  |  | +        /// </summary>
 | 
	
		
			
				|  |  | +        /// <param name="param"></param>
 | 
	
		
			
				|  |  | +        /// <returns></returns>
 | 
	
		
			
				|  |  | +        private bool StartRotation()
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            //比例
 | 
	
		
			
				|  |  | +            double _scale = _rotationProviderAxis.ScaleFactor;
 | 
	
		
			
				|  |  | +            //rinse 目标位置 
 | 
	
		
			
				|  |  | +            double rinsePosition = _recipe.IntervalRinseTime * BeckhoffVelocityUtil.ConvertVelocityToDegPerSecondByRPM(_recipe.IntervalRinseSpeed);
 | 
	
		
			
				|  |  | +            int targetPosition = (int)Math.Round((rinsePosition + _recipe.IntervalRinseZoffset) * _scale, 0);
 | 
	
		
			
				|  |  | +            bool result = _rotationAxis.ProfilePosition(targetPosition, _recipe.IntervalRinseSpeed * SPEED_RATIO, 0, 0);
 | 
	
		
			
				|  |  | +            if (!result)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                NotifyError(eEvent.ERR_PLATINGCELL, "Start Rotation is failed", 0);
 | 
	
		
			
				|  |  | +                return false;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            return true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        /// <summary>
 | 
	
		
			
				|  |  | +        /// 检验Rotation是否停止
 | 
	
		
			
				|  |  | +        /// </summary>
 | 
	
		
			
				|  |  | +        /// <returns></returns>
 | 
	
		
			
				|  |  | +        private bool CheckRotationEndStatus()
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            if (!_rotationAxis.IsRun && _rotationAxis.Status == RState.End)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                return true;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            return false;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        /// <summary>
 | 
	
		
			
				|  |  | +        /// 检验Rotation停止状态
 | 
	
		
			
				|  |  | +        /// </summary>
 | 
	
		
			
				|  |  | +        /// <returns></returns>
 | 
	
		
			
				|  |  | +        private bool CheckRotationStopStatus()
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            if (_rotationAxis.Status == RState.Failed || _rotationAxis.Status == RState.Timeout)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                NotifyError(eEvent.ERR_PLATINGCELL, $"{Module}.Rotation is failed", 0);
 | 
	
		
			
				|  |  | +                return true;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            return false;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          /// <summary>
 | 
	
		
			
				|  |  |          /// 启动
 | 
	
		
			
				|  |  |          /// </summary>
 | 
	
	
		
			
				|  | @@ -47,7 +131,11 @@ namespace PunkHPX8_RT.Modules.PlatingCell
 | 
	
		
			
				|  |  |          /// <returns></returns>
 | 
	
		
			
				|  |  |          public RState Start(params object[] objs)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | -            return Runner.Start(Module, "start inter rinse");
 | 
	
		
			
				|  |  | +            _recipe = (DepRecipe)objs[0];
 | 
	
		
			
				|  |  | +            _rotationAxis = (JetAxisBase)objs[1];
 | 
	
		
			
				|  |  | +            _device = (PlatingCellDevice)objs[2];
 | 
	
		
			
				|  |  | +            _rotationProviderAxis = (BeckhoffProviderAxis)objs[3];
 | 
	
		
			
				|  |  | +            return Runner.Start(Module, "start intervale rinse");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 |