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, RotationHomeStation, RotationHomeStationWait, End } #region 常量 private const string WAFER_PRESENT = "WaferPresent"; #endregion #region 内部变量 private JetAxisBase _rotationAxis; private PufVacuum _vacuum; #endregion /// /// 构造函数 /// /// public PufReadyForSwapRoutine(string module) : base(module) { } /// /// 中止 /// public void Abort() { Runner.Stop("Manual Abort"); } /// /// 监控 /// /// public RState Monitor() { Runner.Run(ReadyForSwapStep.VacuumOn, VacuumBOn, CheckWaferPresence, _delay_5s) .Run(ReadyForSwapStep.RotationHomeStation, RotationGotoHome, _delay_1ms) .WaitWithStopCondition(ReadyForSwapStep.RotationHomeStationWait, () => _rotationAxis.Status == RState.End, CheckRotationStopStatus) .End(ReadyForSwapStep.End, NullFun, _delay_1ms); return Runner.Status; } /// /// Vacuum B On /// /// private bool VacuumBOn() { bool result = _vacuum.VacuumBOn(); if(!result) { NotifyError(eEvent.ERR_PUF, "side B Vacuum on failed", 0); } return result; } /// /// 检验是否存在Wafer /// /// private bool CheckWaferPresence() { return _vacuum.ChuckBVacuumStatus == WAFER_PRESENT; } /// /// Rotation Goto Park /// /// private bool RotationGotoHome() { bool result = _rotationAxis.PositionStation("Home"); if (!result) { NotifyError(eEvent.ERR_PUF, "rotation goto Home failed", 0); } return result; } /// /// 检验Rotation异常状态 /// /// 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; } /// /// 启动 /// /// /// public RState Start(params object[] objs) { InitializeParameters(); return Runner.Start(Module, "Start Go to Park For Swap"); } /// /// 初始化参数 /// private void InitializeParameters() { _rotationAxis = DEVICE.GetDevice($"{Module}.Rotation"); _vacuum = DEVICE.GetDevice($"{Module}.Vacuum"); } /// /// 重试 /// /// public RState Retry(int step) { InitializeParameters(); List preStepIds = new List(); return Runner.Retry(ReadyForSwapStep.VacuumOn, preStepIds, Module, "ReadyForSwap Retry"); } /// /// 检验完成情况 /// /// public bool CheckCompleteCondition() { double rotationPosition = _rotationAxis.MotionData.MotorPosition; if (!_rotationAxis.CheckPositionIsInStation(rotationPosition, "Home")) { NotifyError(eEvent.ERR_PUF, $"rotation {rotationPosition} not in Home", 0); return false; } return true; } } }