using Aitex.Core.RT.Device; using Aitex.Core.RT.Log; using Aitex.Core.RT.Routine; using Aitex.Core.Util; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.Routine; using MECF.Framework.Common.Utilities; using CyberX8_Core; using CyberX8_RT.Devices.AXIS; using CyberX8_RT.Devices.Facilities; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using CyberX8_RT.Devices.Safety; using CyberX8_RT.Modules.PUF; using CyberX8_RT.Modules.Loader; namespace CyberX8_RT.Modules.Transporter { public class TransporterHomeRoutine : RoutineBase, IRoutine { private enum HomeAllStep { //CheckCDAWithN2, VerticalHome, VerticalHomeWait, VerticalLow, VerticalLowWait, GantryHome, GantryHomeWait, GantryPark, GantryParkWait, End } #region 内部变量 private JetAxisBase _gantryAxis; private JetAxisBase _elevatorAxis; private SystemFacilities _facilities; private TransporterEntity _transporterEntity; #endregion public TransporterHomeRoutine(string module) : base(module) { } public void Abort() { Runner.Stop("Manual Abort"); } public RState Monitor() { Runner //.Run(HomeAllStep.CheckCDAWithN2, StartEnaleCDAndN2, CheckCDAWithN2, _delay_1s) .Run(HomeAllStep.VerticalHome, VerticalAxisHome, _delay_1ms) .WaitWithStopCondition(HomeAllStep.VerticalHomeWait, CheckVerticalPositionStatus, CheckVerticalPositionRunStop) .Run(HomeAllStep.VerticalLow, () => { return _elevatorAxis.PositionStation("UP", true); },NullFun,100) .WaitWithStopCondition(HomeAllStep.VerticalLowWait,CheckVerticalPositionStatus, CheckVerticalPositionRunStop) .Run(HomeAllStep.GantryHome, GantryAxisHome, _delay_1ms) .WaitWithStopCondition(HomeAllStep.GantryHomeWait,CheckGantryPositionStatus,CheckGantryPositionRunStop) .Run(HomeAllStep.GantryPark, () => { return _gantryAxis.PositionStation("Park", true); }, NullFun, 100) .WaitWithStopCondition(HomeAllStep.GantryParkWait, CheckGantryPositionStatus, CheckGantryPositionRunStop) .End(HomeAllStep.End,NullFun); return Runner.Status; } /// /// 检验前置条件 /// /// private bool CheckPreCondition() { //所有运动模块均已Initialized if(! _gantryAxis.IsSwitchOn) { LOG.WriteLog(eEvent.ERR_TRANSPORTER, Module.ToString(), "Gantry is switchoff"); return false; } if(!_elevatorAxis.IsSwitchOn) { LOG.WriteLog(eEvent.ERR_TRANSPORTER, Module.ToString(), "Elevator is switchoff"); return false; } if(_transporterEntity.WaferHolderInfo!=null) { LOG.WriteLog(eEvent.ERR_TRANSPORTER, Module.ToString(), "transporter exsit wafer Shuttle,can not home"); return false; } if (Module == ModuleName.Transporter1.ToString()) { TransporterEntity transporterEntity1 = Singleton.Instance.GetModule(ModuleName.Transporter2.ToString()); if (!transporterEntity1.IsHomed) { LOG.WriteLog(eEvent.ERR_TRANSPORTER, Module.ToString(), "Loader Transporter is not homed"); return false; } } //Loader Home if (ModuleHelper.IsInstalled(ModuleName.Loader1)) { LoaderEntity loaderEntity = Singleton.Instance.GetModule(ModuleName.Loader1.ToString()); if (!loaderEntity.IsHomed) { NotifyError(eEvent.ERR_LOADER, "Loader is not homed", -1); return false; } } return true; } /// /// 启动CDA和N2 /// /// private bool StartEnaleCDAndN2() { if(!_facilities.CDAEnable) { bool result= _facilities.N2EnableOperation("", true); if(!result) { return false; } } if(!_facilities.N2Enable) { bool result = _facilities.CDAEnableOperation("", true); if(!result) { return false; } } return true; } /// /// 检验CDA和N2 Enable /// /// private bool CheckCDAWithN2() { return _facilities.CDAEnable && _facilities.N2Enable; } /// /// Vertical Home /// /// private bool VerticalAxisHome() { return _elevatorAxis.Home(); } /// /// 检验Vertical Home状态 /// /// private bool CheckVerticalHome() { return _elevatorAxis.IsHomed&&_elevatorAxis.Status==RState.End; } /// /// 检验Vertical移动状态 /// /// private bool CheckVerticalPositionStatus() { return _elevatorAxis.Status == RState.End; } /// /// 检验Vertical是否还在运动 /// /// private bool CheckVerticalPositionRunStop() { return _elevatorAxis.Status==RState.Failed; } /// /// Gantry Home /// /// private bool GantryAxisHome() { return _gantryAxis.Home(); } /// /// 检验Gantry Home状态 /// /// private bool CheckGantryHome() { return _gantryAxis.IsHomed && _gantryAxis.Status == RState.End; } /// /// 检验Gantry移动状态 /// /// private bool CheckGantryPositionStatus() { return _gantryAxis.Status == RState.End; } /// /// 检验Gantry是否还在运动 /// /// private bool CheckGantryPositionRunStop() { return _gantryAxis.Status == RState.Failed; } /// /// 启动 /// /// /// public RState Start(params object[] objs) { _transporterEntity = Singleton.Instance.GetModule(Module); _gantryAxis = DEVICE.GetDevice($"{Module}.Gantry"); _elevatorAxis = DEVICE.GetDevice($"{Module}.Elevator"); _facilities = DEVICE.GetDevice("System.Facilities"); if (!CheckPreCondition()) { return RState.Failed; } return Runner.Start(Module, "Home"); } } }