123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Routine;
- using MECF.Framework.Common.Routine;
- using CyberX8_Core;
- using CyberX8_RT.Devices.AXIS;
- using CyberX8_RT.Devices.PUF;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Aitex.Core.RT.Log;
- using MECF.Framework.Common.Utilities;
- namespace CyberX8_RT.Modules.PUF
- {
- public class PufReadyForSwapRoutine : RoutineBase, IRoutine
- {
- private enum ReadyForSwapStep
- {
- VacuumOn,
- RotationPark,
- RotationParkWait,
- VerticalPark,
- VerticalParkWait,
- End
- }
- #region 常量
- private const string WAFER_PRESENT = "WaferPresent";
- #endregion
- #region 内部变量
- private JetAxisBase _rotationAxis;
- private JetAxisBase _verticalAxis;
- private PufVacuum _vacuum;
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="module"></param>
- public PufReadyForSwapRoutine(string module) : base(module)
- {
- }
- /// <summary>
- /// 中止
- /// </summary>
- public void Abort()
- {
- Runner.Stop("Manual Abort");
- }
- /// <summary>
- /// 监控
- /// </summary>
- /// <returns></returns>
- public RState Monitor()
- {
- Runner.Run(ReadyForSwapStep.VacuumOn, VacuumBOn, CheckWaferPresence, _delay_5s)
- .Run(ReadyForSwapStep.RotationPark, RotationGotoPark, _delay_1ms)
- .WaitWithStopCondition(ReadyForSwapStep.RotationParkWait, () => _rotationAxis.Status == RState.End, CheckRotationStopStatus)
- .Run(ReadyForSwapStep.VerticalPark, VerticalGotoPark, _delay_1ms)
- .WaitWithStopCondition(ReadyForSwapStep.VerticalParkWait, () => _verticalAxis.Status == RState.End, CheckVerticalStopStatus)
- .End(ReadyForSwapStep.End, NullFun, _delay_1ms);
- return Runner.Status;
- }
- /// <summary>
- /// Vacuum B On
- /// </summary>
- /// <returns></returns>
- private bool VacuumBOn()
- {
- bool result = _vacuum.VacuumBOn();
- if(!result)
- {
- NotifyError(eEvent.ERR_PUF, "side B Vacuum on failed", 0);
- }
- return result;
- }
- /// <summary>
- /// 检验是否存在Wafer
- /// </summary>
- /// <returns></returns>
- private bool CheckWaferPresence()
- {
- return _vacuum.ChuckBVacuumStatus == WAFER_PRESENT;
- }
- /// <summary>
- /// Rotation Goto Park
- /// </summary>
- /// <returns></returns>
- private bool RotationGotoPark()
- {
- bool result = _rotationAxis.PositionStation("Park");
- if (!result)
- {
- NotifyError(eEvent.ERR_PUF, "rotation goto park failed", 0);
- }
- return result;
- }
- /// <summary>
- /// 检验Rotation异常状态
- /// </summary>
- /// <returns></returns>
- private bool CheckRotationStopStatus()
- {
- bool result = _rotationAxis.Status == RState.Failed || _rotationAxis.Status == RState.Timeout;
- if (result)
- {
- NotifyError(eEvent.ERR_PUF, "rotaion motion failed", 0);
- }
- return result;
- }
- /// <summary>
- /// Vertical Goto Park
- /// </summary>
- /// <returns></returns>
- private bool VerticalGotoPark()
- {
- bool result = _verticalAxis.PositionStation("Park");
- if (!result)
- {
- NotifyError(eEvent.ERR_PUF, "vertical goto park failed", 0);
- }
- return result;
- }
- /// <summary>
- /// 检验Vertical异常状态
- /// </summary>
- /// <returns></returns>
- private bool CheckVerticalStopStatus()
- {
- bool result = _verticalAxis.Status == RState.Failed || _verticalAxis.Status == RState.Timeout;
- if (result)
- {
- NotifyError(eEvent.ERR_PUF, "vertical motion failed", 0);
- }
- return result;
- }
- /// <summary>
- /// 启动
- /// </summary>
- /// <param name="objs"></param>
- /// <returns></returns>
- public RState Start(params object[] objs)
- {
- InitializeParameters();
- return Runner.Start(Module, "Start Go to Park For Swap");
- }
- /// <summary>
- /// 初始化参数
- /// </summary>
- private void InitializeParameters()
- {
- _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
- _verticalAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Vertical");
- _vacuum = DEVICE.GetDevice<PufVacuum>($"{Module}.Vacuum");
- }
- /// <summary>
- /// 重试
- /// </summary>
- /// <param name="step"></param>
- public RState Retry(int step)
- {
- InitializeParameters();
- List<Enum> preStepIds = new List<Enum>();
- return Runner.Retry(ReadyForSwapStep.VacuumOn, preStepIds, Module, "ReadyForSwap Retry");
- }
- /// <summary>
- /// 检验完成情况
- /// </summary>
- /// <returns></returns>
- public bool CheckCompleteCondition()
- {
- double rotationPosition = _rotationAxis.MotionData.MotorPosition;
- if (!_rotationAxis.CheckPositionIsInStation(rotationPosition, "Park"))
- {
- NotifyError(eEvent.ERR_PUF, $"rotation {rotationPosition} not in Park", 0);
- return false;
- }
- double verticalPosition = _verticalAxis.MotionData.MotorPosition;
- if (!_verticalAxis.CheckPositionIsInStation(verticalPosition, "Park"))
- {
- NotifyError(eEvent.ERR_PUF, $"vertical {verticalPosition} not in Park", 0);
- return false;
- }
- return true;
- }
- }
- }
|