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, WaitRotation, CloseRinseValve, End } #region 常量 /// /// ROTATION电机转速比例 /// private const int SPEED_RATIO = 1; #endregion /// /// recipe /// private DepRecipe _recipe; /// /// Rotation axis /// private JetAxisBase _rotationAxis; /// /// Platingcell device /// private PlatingCellDevice _device; /// ///rotation Provider对象 /// private BeckhoffProviderAxis _rotationProviderAxis; /// /// rotation运动的目的地 /// private int _targetPosition; /// /// 构造函数 /// /// public PlatingCellInterRinseRoutine(string module) : base(module) { } /// /// 中止 /// public void Abort() { Runner.Stop("Manual Abort"); } /// /// 监控 /// /// public RState Monitor() { Runner.Run(RunRecipeStep.OpenRinseValve, _device.RinseEnableAction, _delay_1ms) .Run(RunRecipeStep.StartRotation, () => { return StartRotation(_targetPosition); }, _delay_1ms) .Delay(RunRecipeStep.WaitRotation, _recipe.IntervalRinseTime*1000) .Run(RunRecipeStep.CloseRinseValve, _device.RinseDisableAction, _delay_1ms) .End(RunRecipeStep.End, NullFun); return Runner.Status; } /// /// rotation开始旋转 /// /// /// private bool StartRotation(int targetPosition) { bool result = _rotationAxis.ProfilePosition(targetPosition, _recipe.IntervalRinseSpeed * SPEED_RATIO * 6, 0, 0); //rpm->deg/s if (!result) { NotifyError(eEvent.ERR_PLATINGCELL, "Start Rotation is failed", 0); return false; } return true; } /// /// 启动 /// /// /// public RState Start(params object[] objs) { _recipe = (DepRecipe)objs[0]; _rotationAxis = (JetAxisBase)objs[1]; _device = (PlatingCellDevice)objs[2]; _rotationProviderAxis = (BeckhoffProviderAxis)objs[3]; _targetPosition = (int)objs[4]; return Runner.Start(Module, "start intervale rinse"); } } }