123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- 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<RobotMoveHelper>
- {
- private enum RobotOperation
- {
- None,
- Pick,
- PickWait,
- CheckLoaderPrepare,
- Place,
- PlaceWait
- }
- #region 内部变量
- private Queue<MoveItem> _queue=new Queue<MoveItem>();
- 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 属性
- /// <summary>
- /// 是否忙碌
- /// </summary>
- public bool IsBusy
- {
- get { return _state == RState.Running; }
- }
- /// <summary>
- /// 是否空闲
- /// </summary>
- public bool IsIdle
- {
- get { return _state == RState.End; }
- }
- /// <summary>
- /// 是否错误
- /// </summary>
- public bool IsError
- {
- get { return _state == RState.Failed || _state == RState.Timeout; }
- }
- /// <summary>
- /// 当前模块名称
- /// </summary>
- public string Module { get { return _module; } }
- /// <summary>
- /// 是否完成
- /// </summary>
- public bool IsPickCompleted { get { return _currentOperation >= RobotOperation.Place; } }
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="queue"></param>
- public RobotMoveHelper()
- {
- }
- /// <summary>
- /// 启动
- /// </summary>
- /// <param name="queue"></param>
- /// <returns></returns>
- public bool Start(MoveItem moveItem,string module)
- {
- _efemEntity = Singleton<RouteManager>.Instance.EFEM;
- _loaderEntity = Singleton<RouteManager>.Instance.GetModule<LoaderEntity>(ModuleName.Loader1.ToString());
- _puf1Entity = Singleton<RouteManager>.Instance.GetModule<PUFEntity>(ModuleName.PUF1.ToString());
- _puf2Entity = Singleton<RouteManager>.Instance.GetModule<PUFEntity>(ModuleName.PUF2.ToString());
- _moveItem = moveItem;
- _queue.Clear();
- _queue.Enqueue(moveItem);
- _state = RState.Running;
- _currentOperation = RobotOperation.Pick;
- _module = module;
- return true;
- }
- /// <summary>
- /// 监控状态
- /// </summary>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 取片
- /// </summary>
- /// <param name="moveItem"></param>
- /// <returns></returns>
- private bool Pick()
- {
- return _efemEntity.CheckToPostMessage<EfemEntity.STATE, EfemEntity.MSG>(eEvent.ERR_EFEM_COMMON_FAILED,
- ModuleName.EFEM.ToString(), (int)EfemEntity.MSG.Pick, _queue);
- }
- /// <summary>
- /// 放片
- /// </summary>
- /// <param name="moveItem"></param>
- /// <returns></returns>
- private bool Place()
- {
- return _efemEntity.CheckToPostMessage<EfemEntity.STATE, EfemEntity.MSG>(eEvent.ERR_EFEM_COMMON_FAILED,
- ModuleName.EFEM.ToString(), (int)EfemEntity.MSG.Place, _queue);
- }
- /// <summary>
- /// 重置
- /// </summary>
- public void Reset()
- {
- _state = RState.End;
- _queue.Clear();
- }
- }
- }
|