| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- 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;
- using System.Text;
- using System.Threading.Tasks;
- namespace PunkHPX8_RT.Modules.PlatingCell
- {
- public class PlatingCellInterRinseRoutine : RoutineBase, IRoutine
- {
- private enum RunRecipeStep
- {
- 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>
- /// 中止
- /// </summary>
- public void Abort()
- {
- Runner.Stop("Manual Abort");
- }
- /// <summary>
- /// 监控
- /// </summary>
- /// <returns></returns>
- public RState Monitor()
- {
- 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>
- /// <param name="objs"></param>
- /// <returns></returns>
- public RState Start(params object[] objs)
- {
- _recipe = (DepRecipe)objs[0];
- _rotationAxis = (JetAxisBase)objs[1];
- _device = (PlatingCellDevice)objs[2];
- _rotationProviderAxis = (BeckhoffProviderAxis)objs[3];
- return Runner.Start(Module, "start intervale rinse");
- }
- }
- }
|