using Aitex.Core.RT.Log; using Aitex.Core.Util; using CyberX8_Core; using CyberX8_RT.Modules; using CyberX8_RT.Modules.Loader; using CyberX8_RT.Modules.PUF; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.Schedulers; using MECF.Framework.Common.SubstrateTrackings; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; namespace CyberX8_RT.Schedulers.EfemRobot { public class RobotMoveHelper : Singleton { private enum RobotOperation { None, Pick, PickWait, CheckLoaderPrepare, Place, PlaceWait } #region 内部变量 private Queue _queue=new Queue(); private MoveItem _moveItem; private RState _state = RState.End; private RobotOperation _currentOperation=RobotOperation.None; private EfemEntity _efemEntity; private LoaderEntity _loaderEntity; private PUFEntity _puf1Entity; private PUFEntity _puf2Entity; private string _module; #endregion #region 属性 /// /// 是否忙碌 /// public bool IsBusy { get { return _state == RState.Running; } } /// /// 是否空闲 /// public bool IsIdle { get { return _state == RState.End; } } /// /// 是否错误 /// public bool IsError { get { return _state == RState.Failed || _state == RState.Timeout; } } /// /// 当前模块名称 /// public string Module { get { return _module; } } /// /// 是否完成 /// public bool IsPickCompleted { get { return _currentOperation >= RobotOperation.Place; } } #endregion /// /// 构造函数 /// /// public RobotMoveHelper() { } /// /// 启动 /// /// /// public bool Start(MoveItem moveItem,string module) { _efemEntity = Singleton.Instance.EFEM; _loaderEntity = Singleton.Instance.GetModule(ModuleName.Loader1.ToString()); _puf1Entity = Singleton.Instance.GetModule(ModuleName.PUF1.ToString()); _puf2Entity = Singleton.Instance.GetModule(ModuleName.PUF2.ToString()); _moveItem = moveItem; _queue.Clear(); _queue.Enqueue(moveItem); _state = RState.Running; _currentOperation = RobotOperation.Pick; _module = module; return true; } /// /// 监控状态 /// /// public bool Monitor(string module) { if (_module != module) { return false; } if (_currentOperation == RobotOperation.Pick) { if (CheckOtherModuleError()) { return false; } if (_efemEntity.IsIdle) { bool result = Pick(); if (result) { _currentOperation = RobotOperation.PickWait; } } } else if (_currentOperation == RobotOperation.PickWait) { if (_efemEntity.IsIdle && WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, 0) && WaferManager.Instance.CheckNoWafer(_moveItem.SourceModule, _moveItem.SourceSlot)) { if (_moveItem.DestinationType == ModuleType.PUF) { _currentOperation = RobotOperation.CheckLoaderPrepare; } else { _currentOperation = RobotOperation.Place; } } } else if (_currentOperation == RobotOperation.CheckLoaderPrepare) { if(_loaderEntity.State==(int)LOADERSTATE.WaitForUnload) { _currentOperation = RobotOperation.Place; } } else if (_currentOperation == RobotOperation.Place) { if (CheckOtherModuleError()) { return false; } if (_efemEntity.IsIdle) { bool result = Place(); if (result) { _currentOperation = RobotOperation.PlaceWait; } } } else if (_currentOperation == RobotOperation.PlaceWait) { if (_efemEntity.IsIdle && WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, 0) && WaferManager.Instance.CheckHasWafer(_moveItem.DestinationModule, _moveItem.DestinationSlot)) { _state = RState.End; _currentOperation = RobotOperation.None; } } return true; } //检验其他模块是否故障 private bool CheckOtherModuleError() { return _loaderEntity.IsError||_puf1Entity.IsError||_puf2Entity.IsError; } /// /// 取片 /// /// /// private bool Pick() { return _efemEntity.CheckToPostMessage(eEvent.ERR_EFEM_COMMON_FAILED, ModuleName.EFEM.ToString(), (int)EfemEntity.MSG.Pick, _queue); } /// /// 放片 /// /// /// private bool Place() { return _efemEntity.CheckToPostMessage(eEvent.ERR_EFEM_COMMON_FAILED, ModuleName.EFEM.ToString(), (int)EfemEntity.MSG.Place, _queue); } /// /// 重置 /// public void Reset() { _state = RState.End; _queue.Clear(); } } }