using Aitex.Core.RT.Device; using Aitex.Core.RT.Event; using Aitex.Core.RT.Routine; using Aitex.Core.RT.SCCore; using Aitex.Sorter.Common; using athosRT.tool; using athosRT.FSM; using MECF.Framework.Common.Equipment; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using MECF.Framework.Common.SubstrateTrackings; namespace athosRT.Modules.LPs { public class UnloadFoupRoutine : ModuleRoutineBase, FSM.IRoutine { int _timeout = -1; public ModuleName _chamber { get; set; } private RobotBaseDevice _robot = null; private LoadPortBaseDevice _device = (LoadPortBaseDevice)null; private string _reason = string.Empty; public UnloadFoupRoutine(ModuleName chamber, RobotBaseDevice robot) : base(chamber) { _chamber = chamber; _timeout = 3000; _robot = robot; } public void Abort() { } public RState Start(params object[] objs) { Reset(); _device = DEVICE.GetDevice(this._chamber.ToString()); ModuleName chamber = this._chamber; string module = chamber.ToString(); object[] objArray = new object[1]; chamber = this._chamber; objArray[0] = (object)chamber.ToString(); //EV.PostMessage(module, EventEnum.UnloadFOUPStart, objArray); string reason = string.Empty; LogObject.Info(this._chamber.ToString(), "Check DockState"); if (this._device.DockState == FoupDockState.Undocked) { LogObject.Warning(this._chamber.ToString(), $"lp is unload, can't do again"); return RState.Failed; } LogObject.Info(this._chamber.ToString(), "Check LPRobotActionIntervene && CheckLoadportMotionInterlock"); if (SC.GetValue("System.LPRobotActionIntervene") && !CheckLoadportMotionInterlock()) { LogObject.Warning(this._chamber.ToString(), "LPRobotActionIntervene && CheckLoadportMotionInterlock"); return RState.Failed; } LogObject.Info(this._chamber.ToString(), "Check Is Enable Unload"); if (!this._device.IsEnableUnload(out reason)) { LogObject.Warning(this._chamber.ToString(), "Is not Enable Unload"); return RState.Failed; } LogObject.Info(this._chamber.ToString(), "Is going to Unloadfoup"); return Runner.Start(Module, $"{Module}=>UnloadFoup"); } public RState Monitor() { Runner.Run(UnloadFoupStep.Unload, Unload, WaitLoadportMotion, _timeout) .End(UnloadFoupStep.WaitLoadportMotion, NullFun, 500); //.End(UnloadFoupStep.WaitLoadportMotion, WaitLoadportMotion, _timeout); return Runner.Status; } public bool Unload() => _device.Unload(out _reason); protected bool WaitLoadportMotion() { LogObject.Info(Module.ToString(), "正在等待LoadportMotion"); if (_device.CurrentState == LoadPortStateEnum.Error) return false; if (!_device.IsReady()) return false; LogObject.Info(Module.ToString(), "等待Load port Motion完毕"); //Clear WaferInfo WaferManager.Instance.DeleteWafer(Module, 0, 25); return true; } public bool CheckLoadportMotionInterlock() { if (_robot.RobotState != RobotStateEnum.Idle) { LogObject.Info(Module.ToString(), "robot非空闲状态"); return false; } if (_robot.IsReady()) { LogObject.Info(Module.ToString(), "robot尚未准备好"); return true; } return false; } public enum UnloadFoupStep { Unload, WaitLoadportMotion } } }