| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354 | 
							- using Aitex.Core.RT.Device;
 
- using Aitex.Core.RT.Log;
 
- using Aitex.Core.RT.RecipeCenter;
 
- using Aitex.Core.RT.Routine;
 
- using Aitex.Core.RT.SCCore;
 
- using MECF.Framework.Common.RecipeCenter;
 
- using MECF.Framework.Common.Routine;
 
- using MECF.Framework.Common.Utilities;
 
- using CyberX8_Core;
 
- using CyberX8_RT.Devices.AXIS;
 
- using CyberX8_RT.Devices.Facilities;
 
- using CyberX8_RT.Devices.SRD;
 
- using System;
 
- using System.Collections.Generic;
 
- using System.Linq;
 
- using System.Reflection;
 
- using System.Runtime.InteropServices;
 
- using System.Text;
 
- using System.Threading;
 
- using System.Threading.Tasks;
 
- namespace CyberX8_RT.Modules.SRD
 
- {
 
-     internal class SRDPresenceTestRoutine : RoutineBase, IRoutine
 
-     {
 
-         private enum PresenceTestStep
 
-         {
 
-             Ready,           
 
-             CloseDoor,
 
-             CheckCloseDoor,
 
-             ChuckVacuumOn,
 
-             RunWafer,
 
-             RunWaferWait,
 
-             InitialUnloadingStateMachine,
 
-             Unloading,
 
-             UnloadingWait,
 
-             End
 
-         }
 
-         #region 内部变量
 
-         /// <summary>
 
-         /// Rotation Axis
 
-         /// </summary>
 
-         private JetAxisBase _rotationAxis;
 
-         /// <summary>
 
-         /// Arm Axis
 
-         /// </summary>
 
-         private JetAxisBase _armAxis;
 
-         /// <summary>
 
-         /// SRD Common
 
-         /// </summary>
 
-         private SrdCommonDevice _srdCommon;
 
-         /// <summary>
 
-         /// recipe名称
 
-         /// </summary>
 
-         private string _recipe;
 
-         /// <summary>
 
-         /// SRD Recipe
 
-         /// </summary>
 
-         private SrdRecipe _srdRecipe;
 
-         /// <summary>
 
-         /// Module
 
-         /// </summary>
 
-         private string _module;
 
-         /// <summary>
 
-         /// Wafer Presence Test功能是否启用
 
-         /// </summary>
 
-         private bool _presenceTestEnabled;
 
-         /// <summary>
 
-         /// Run wafer Recipe Routine
 
-         /// </summary>
 
-         private SRDRunWaferRecipeRoutine _runWaferRecipRoutine;
 
-         /// <summary>
 
-         /// Unload Routine
 
-         /// </summary>
 
-         private SRDUnloadRoutine _unloadRoutine;
 
-         #endregion
 
-         #region 属性
 
-         /// <summary>
 
-         /// 当前子状态机
 
-         /// </summary>
 
-         public string CurrentStateMachine
 
-         {
 
-             get { return GetCurrentStateMachine(); }
 
-         }
 
-         #endregion
 
-         /// <summary>
 
-         /// 构造函数
 
-         /// </summary>
 
-         /// <param name="module"></param>
 
-         public SRDPresenceTestRoutine(string module) : base(module)
 
-         {
 
-             _module = module;
 
-             _srdCommon = DEVICE.GetDevice<SrdCommonDevice>($"{module}.Common");
 
-             _runWaferRecipRoutine = new SRDRunWaferRecipeRoutine(module);
 
-             _unloadRoutine = new SRDUnloadRoutine(module);
 
-         }
 
-         /// <summary>
 
-         /// Abort
 
-         /// </summary>
 
-         public void Abort()
 
-         {
 
-             if(_unloadRoutine.Monitor() == RState.Running)
 
-             {
 
-                 _unloadRoutine.Abort();
 
-             }
 
-             if (_runWaferRecipRoutine.Monitor() == RState.Running)
 
-             {
 
-                 _runWaferRecipRoutine.Abort();
 
-             }          
 
-             Runner.Stop("Presence Test Abort");
 
-             if (_srdCommon != null)
 
-             {
 
-                 _srdCommon.EnterErrorOperation();
 
-             }
 
-         }
 
-         public RState Monitor()
 
-         {
 
-             Runner.Wait(PresenceTestStep.Ready, CheckReadyStatus, _delay_1ms)
 
-                 .Run(PresenceTestStep.CloseDoor, CloseDoor, CheckDoorClosed, _delay_1s)
 
-                 .Run(PresenceTestStep.ChuckVacuumOn, EngageChuckVacuum, CheckVacuum, _delay_1s)
 
-                 .Run(PresenceTestStep.RunWafer, () => { return StartRunWaferRecipeRoutine(_recipe); }, _delay_1ms)
 
-                 .WaitWithStopCondition(PresenceTestStep.RunWaferWait, CheckRunWaferRoutineCompleteStatus, CheckRunWaferRoutineErrorStatus)
 
-                 .Run(PresenceTestStep.Unloading, () => { return StartUnloadingRoutine(); }, _delay_1ms)
 
-                 .WaitWithStopCondition(PresenceTestStep.UnloadingWait, CheckUnloadingRoutineCompleteStatus, CheckUnloadingRoutineErrorStatus)
 
-                 .End(PresenceTestStep.End, NullFun, _delay_1ms);
 
-             return Runner.Status;
 
-         }
 
-         /// <summary>
 
-         /// 启动
 
-         /// </summary>
 
-         /// <param name="objs"></param>
 
-         /// <returns></returns>
 
-         public RState Start(params object[] objs)
 
-         {
 
-             _recipe = objs[0].ToString();          
 
-             _srdRecipe = RecipeFileManager.Instance.LoadGenericityRecipe<SrdRecipe>(_recipe);
 
-             if (_srdRecipe == null)
 
-             {
 
-                 LOG.WriteLog(eEvent.INFO_SRD, Module.ToString(), $"Start Run Wafer State Machine, recipe[{_recipe}] is null");
 
-                 return RState.Failed;
 
-             }
 
-             Runner.Start(Module, "PresenceTest");
 
-             return RState.Running;
 
-         }
 
-         private bool CheckReadyStatus()
 
-         {
 
-             //Arm是否开启,是否home
 
-             _armAxis = DEVICE.GetDevice<JetAxisBase>($"{_module}.Arm");
 
-             if (_armAxis.IsSwitchOn)
 
-             {
 
-                 if (!_armAxis.IsHomed)
 
-                 {
 
-                     LOG.WriteLog(eEvent.ERR_SRD, _module, "Arm is not swicth on");
 
-                     return false;
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_SRD, _module, "Arm is not home");
 
-                 return false;
 
-             }            
 
-             //Rotation是否开启,是否home
 
-             _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{_module}.Rotation");
 
-             if (_rotationAxis.IsSwitchOn)
 
-             {
 
-                 if (!_rotationAxis.IsHomed)
 
-                 {
 
-                     LOG.WriteLog(eEvent.ERR_SRD, _module, "Rotation is not homed");
 
-                     return false;
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 
 
-                 LOG.WriteLog(eEvent.ERR_SRD, _module, "Rotation is not switched on ");
 
-                 return false;
 
-                 
 
-             }
 
-             //检查N2与CDA
 
-             SystemFacilities systemFacilities = DEVICE.GetDevice<SystemFacilities>("System.Facilities");
 
-             var result = systemFacilities.CheckCDAN2();
 
-             if (!result.result)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_SRD, _module, $"CheckCDAN2 is failed");
 
-                 return false;
 
-             }
 
-          
 
-             //Wafer Presence Test功能是否开启
 
-             if (SC.ContainsItem($"SRD.{_module}EnablePresenceCheckvalue"))
 
-             {
 
-                 _presenceTestEnabled = SC.GetValue<bool>($"SRD.{_module}EnablePresenceCheckvalue");
 
-                 if (!_presenceTestEnabled)
 
-                 {
 
-                     LOG.WriteLog(eEvent.ERR_SRD, _module, $"{_module}EnablePresenceCheckvalue is unable");
 
-                     return false;
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_SRD, _module, $"Config dosen't have EnablePresenceCheckvalue");
 
-                 return false;
 
-             }
 
-             return true;
 
-         }
 
-         /// <summary>
 
-         /// Close Door
 
-         /// </summary>
 
-         /// <param name="param"></param>
 
-         /// <returns></returns>
 
-         private bool CloseDoor()
 
-         {
 
-             bool result = _srdCommon.DoorCloseAction("", null);
 
-             if (!result)
 
-             {
 
-                 return false;
 
-             }
 
-             return result;
 
-         }
 
-         /// <summary>
 
-         /// 检验DoorClosed
 
-         /// </summary>
 
-         /// <param name="param"></param>
 
-         /// <returns></returns>
 
-         private bool CheckDoorClosed()
 
-         {
 
-             if (_srdCommon.Status == RState.Failed || _srdCommon.Status == RState.Timeout)
 
-             {               
 
-                 return false;
 
-             }
 
-             return _srdCommon.Status == RState.End && _srdCommon.CommonData.DoorClosed;
 
-         }
 
-         /// <summary>
 
-         /// Chuck Vacuum On
 
-         /// </summary>
 
-         /// <param name="param"></param>
 
-         /// <returns></returns>
 
-         private bool EngageChuckVacuum()
 
-         {
 
-             bool result = _srdCommon.ChuckVacuumOnAction("", null);
 
-             if (!result)
 
-             {
 
-                 return false;
 
-             }
 
-             return result;
 
-         }
 
-         /// <summary>
 
-         /// 检查真空状态
 
-         /// </summary>
 
-         /// <param name="param"></param>
 
-         /// <returns></returns>
 
-         private bool CheckVacuum()
 
-         {
 
-             if (_srdCommon.Status == RState.Failed || _srdCommon.Status == RState.Timeout)
 
-             {
 
-                 return false;
 
-             }
 
-             return _srdCommon.Status == RState.End && !_srdCommon.CommonData.ChuckVacuum;
 
-         }
 
-         #region SRD RunWaferRecipeRoutine
 
-         /// <summary>
 
-         /// 启动RunWaferRecipeRoutine
 
-         /// </summary>
 
-         /// <param name="recipe"></param>
 
-         /// <returns></returns>
 
-         private bool StartRunWaferRecipeRoutine(string recipe)
 
-         {
 
-             bool presenceTestFlag = true;
 
-             return _runWaferRecipRoutine.Start(_srdRecipe, presenceTestFlag) == RState.Running;
 
-         }
 
-         /// <summary>
 
-         /// 检验RunWaferRecipeRoutine是否完成
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool CheckRunWaferRoutineCompleteStatus()
 
-         {
 
-             return CommonFunction.CheckRoutineEndState(_runWaferRecipRoutine);
 
-         }
 
-         /// <summary>
 
-         /// 检验RunWaferRecipeRoutine是否出错
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool CheckRunWaferRoutineErrorStatus()
 
-         {
 
-             bool result = CommonFunction.CheckRoutineStopState(_runWaferRecipRoutine);
 
-             if (result && _srdCommon != null)
 
-             {
 
-                 _srdCommon.EnterErrorOperation();
 
-             }
 
-             return result;
 
-         }
 
-         #endregion
 
-         #region SRD UnloadingRoutine
 
-         /// <summary>
 
-         /// 启动UnloadingRoutine
 
-         /// </summary>
 
-         /// <param name="recipe"></param>
 
-         /// <returns></returns>
 
-         private bool StartUnloadingRoutine()
 
-         {
 
-             return _unloadRoutine.Start() == RState.Running;
 
-         }
 
-         /// <summary>
 
-         /// 检验UnloadingRoutine是否完成
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool CheckUnloadingRoutineCompleteStatus()
 
-         {
 
-             return CommonFunction.CheckRoutineEndState(_unloadRoutine);
 
-         }
 
-         /// <summary>
 
-         /// 检验UnloadingRoutine是否出错
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool CheckUnloadingRoutineErrorStatus()
 
-         {
 
-             return CommonFunction.CheckRoutineStopState(_unloadRoutine);
 
-         }
 
-         
 
-         #endregion
 
-         /// <summary>
 
-         /// 获取当前子状态机
 
-         /// </summary>
 
-         private string GetCurrentStateMachine()
 
-         {
 
-             string result;
 
-             if (Runner.CurrentStep.ToString() == "Ready")
 
-             {
 
-                 result = "Ready";
 
-             }
 
-             else if (Runner.CurrentStep.ToString().Contains("RunWafer"))
 
-             {
 
-                 result = _runWaferRecipRoutine.CurrentStep;
 
-             }
 
-             else if (Runner.CurrentStep.ToString().Contains("Unloading"))
 
-             {
 
-                 result = _unloadRoutine.CurrentStep;
 
-             }
 
-             else
 
-             {
 
-                 result = "End";
 
-             }
 
-             return result;
 
-         }
 
-     }
 
- }
 
 
  |