| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526 | 
							- using Aitex.Core.Common;
 
- using Aitex.Core.RT.Device;
 
- using Aitex.Core.RT.Log;
 
- using Aitex.Core.RT.Routine;
 
- using Aitex.Core.RT.SCCore;
 
- using CyberX8_Core;
 
- using CyberX8_RT.Devices.AXIS;
 
- using CyberX8_RT.Devices.Facilities;
 
- using CyberX8_RT.Devices.SRD;
 
- using MECF.Framework.Common.Equipment;
 
- using MECF.Framework.Common.RecipeCenter;
 
- using MECF.Framework.Common.Routine;
 
- using MECF.Framework.Common.SubstrateTrackings;
 
- using System;
 
- using System.Windows.Input;
 
- namespace CyberX8_RT.Modules.SRD
 
- {
 
-     public class SRDUnloaderRoutine : RoutineBase, IRoutine
 
-     {         
 
-         private enum SRDUnloaderStep
 
-         {
 
-             Unloader_FlippersOut,
 
-             Unloader_ChuckVacuumOff,
 
-             Unloader_ChuckATMOn,
 
-             Unloader_CheckVacuum,
 
-             Unloader_LiftUpOn,
 
-             Unloader_CheckWaferPresent,
 
-             Unloader_OpenDoor,
 
-             End
 
-         }
 
-         #region 常量 
 
-         private const int RETRY_TIMES = 3;
 
-         #endregion
 
-         #region 内部变量
 
-         /// <summary>
 
-         /// Rotation Axis
 
-         /// </summary>
 
-         private JetAxisBase _rotationAxis;
 
-         /// <summary>
 
-         /// SRD Common
 
-         /// </summary>
 
-         private SrdCommonDevice _srdCommon;
 
-         /// <summary>
 
-         /// Total SRD
 
-         /// </summary>
 
-         private TotalSRDDevice _totalSRDDevice;
 
-         /// <summary>
 
-         /// System Facility
 
-         /// </summary>
 
-         private SystemFacilities _systemFacilities;
 
-         /// <summary>
 
-         /// 当前WaferSize
 
-         /// </summary>
 
-         private int _waferSize = 200;
 
-         /// <summary>
 
-         /// 当前Retry次数
 
-         /// </summary>
 
-         private int _currentRetryTimes = 0;
 
-         /// <summary>
 
-         /// 真空值
 
-         /// </summary>
 
-         private int _vacuumOffLimit = 0;
 
-         /// <summary>
 
-         /// Process Error状态
 
-         /// </summary>
 
-         private bool _isProcessError = false;
 
-         #endregion
 
-         #region 属性
 
-         #endregion
 
-         /// <summary>
 
-         /// 构造函数
 
-         /// </summary>
 
-         /// <param name="module"></param>
 
-         public SRDUnloaderRoutine(string module) : base(module)
 
-         {
 
-         }
 
-         /// <summary>
 
-         /// 中止
 
-         /// </summary>
 
-         public void Abort()
 
-         {
 
-             Runner.Stop("SRD Loader Abort");
 
-         }
 
-         /// <summary>
 
-         /// 监控
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         public RState Monitor()
 
-         {
 
-             Runner.RunIf(SRDUnloaderStep.Unloader_FlippersOut, _isProcessError, FlippersOut, CheckFlippersOutEndStatus, CheckFlippersOutStopStatus)
 
-                 .Run(SRDUnloaderStep.Unloader_ChuckVacuumOff, ChuckVacuumOff, CheckChuckVacuumOffEndStatus, CheckChuckVacuumOffStopStatus)
 
-                 .Run(SRDUnloaderStep.Unloader_ChuckATMOn, ChuckATMOn, CheckChuckATMEndStatus, CheckChuckATMStopStatus)
 
-                 .WaitWithStopCondition(SRDUnloaderStep.Unloader_CheckVacuum, CheckVacuumEndStatus, CheckVacuumStopStatus)
 
-                 .Run(SRDUnloaderStep.Unloader_LiftUpOn, LiftUpOn, CheckLiftUpOnEndStatus, CheckLiftUpOnStopStatus)
 
-                 .Run(SRDUnloaderStep.Unloader_CheckWaferPresent, CheckWaferPresent, _delay_1ms)
 
-                 .Run(SRDUnloaderStep.Unloader_OpenDoor, OpenDoor, CheckDoorOpenedEndStatus, CheckDoorOpenedStopStatus)
 
-                 .End(SRDUnloaderStep.End, NullFun, _delay_1ms);
 
-             return Runner.Status;
 
-         }
 
-         /// <summary>
 
-         /// 启动
 
-         /// </summary>
 
-         /// <param name="objs"></param>
 
-         /// <returns></returns>
 
-         public RState Start(params object[] objs)
 
-         {
 
-             _srdCommon = DEVICE.GetDevice<SrdCommonDevice>($"{Module}.Common");
 
-             _totalSRDDevice = DEVICE.GetDevice<TotalSRDDevice>("SRD");
 
-             _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
 
-             _systemFacilities = DEVICE.GetDevice<SystemFacilities>("System.Facilities");
 
-             _vacuumOffLimit = SC.GetValue<int>("SRD.ChuckVacuumOffLimit");
 
-             if (objs.Length >= 1)
 
-             {
 
-                 _isProcessError = (bool)objs[0];
 
-             } 
 
-             if (!_isProcessError && !CheckPreCondition())
 
-             {
 
-                 return RState.Failed;
 
-             }
 
-             if (!GetWaferSize())
 
-             {
 
-                 NotifyError(eEvent.ERR_SRD, "Wafer Size is invalid", 0);
 
-                 return RState.Failed;
 
-             }
 
-             return Runner.Start(Module, "SRD Unloader Start");
 
-         }
 
-         /// <summary>
 
-         /// Check Pre Condition
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool CheckPreCondition()
 
-         {
 
-             //Check Rotation Home
 
-             if (!_rotationAxis.IsHomed)
 
-             {
 
-                 NotifyError(eEvent.ERR_SRD, "Rotation is not homed", 0);
 
-                 return false;
 
-             }
 
-             //Check LiftUp
 
-             if (_srdCommon.CommonData.LiftUp)
 
-             {
 
-                 NotifyError(eEvent.ERR_SRD, "LiftUp is on", 0);
 
-                 return false;
 
-             }
 
-             //Check LiftUp Status
 
-             if (_srdCommon.CommonData.LiftUpStatus)
 
-             {
 
-                 NotifyError(eEvent.ERR_SRD, "LiftUp sensor is on", 0);
 
-                 return false;
 
-             }
 
-             //Check Wafer Present
 
-             if (!_srdCommon.CommonData.WaferPresent)
 
-             {
 
-                 NotifyError(eEvent.ERR_SRD, "WaferPresent sensor is off", 0);
 
-                 return false;
 
-             }
 
-             //Check LoaderDI
 
-             if (!_systemFacilities.LoaderDiEnable)
 
-             {
 
-                 NotifyError(eEvent.ERR_SRD, "Load DI Is Disable", 0);
 
-                 return false;
 
-             }
 
-             //Check Vacuum
 
-             int vacuumOnLimit = SC.GetValue<int>("SRD.ChuckVacuumOnLimit");
 
-             if (!_srdCommon.CommonData.ChuckVacuum)
 
-             {
 
-                 if(_srdCommon.CommonData.VacuumValue >= vacuumOnLimit)
 
-                 {
 
-                     LOG.WriteLog(eEvent.ERR_SRD, Module, $"VacuumValue:{_srdCommon.CommonData.VacuumValue}, VacuumOn Limit:{vacuumOnLimit}");
 
-                     return false;
 
-                 }              
 
-             }
 
-             else
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_SRD, Module, $"Chuck Vacuum is off");
 
-                 return false;
 
-             }
 
-             //Check Flippers
 
-             if (_srdCommon.CommonData.FlippersIn150 || _srdCommon.CommonData.FlippersIn200) //|| _srdCommon.CommonData.FlippersIn100
 
-             {
 
-                 NotifyError(eEvent.ERR_SRD, "FlippersIn is on", 0);
 
-                 return false;
 
-             }
 
-             if (!_srdCommon.CommonData.Flipper1Out150Status || !_srdCommon.CommonData.Flipper2Out150Status || !_srdCommon.CommonData.Flipper3Out150Status
 
-                 || !_srdCommon.CommonData.Flipper1Out200Status || !_srdCommon.CommonData.Flipper2Out200Status || !_srdCommon.CommonData.Flipper3Out200Status)
 
-             //|| !_srdCommon.CommonData.Flipper1Out100Status || !_srdCommon.CommonData.Flipper2Out100Status || !_srdCommon.CommonData.Flipper3Out100Status
 
-             {
 
-                 NotifyError(eEvent.ERR_SRD, "Flippers are at In position", 0);
 
-                 return false;
 
-             }
 
-             return true;
 
-         }
 
-         /// <summary>
 
-         /// ChuckATMOn
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool ChuckATMOn()
 
-         {
 
-             bool result = _srdCommon.ChuckATMAction("", null);
 
-             if (!result)
 
-             {
 
-                 NotifyError(eEvent.ERR_SRD, "Chuck ATM Action is failed", 0);
 
-                 return result;
 
-             }
 
-             return true;
 
-         }
 
-         /// <summary>
 
-         /// Chuck ATM On End
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool CheckChuckATMEndStatus()
 
-         {
 
-             return _srdCommon.Status == RState.End && !_srdCommon.CommonData.ChuckATMOn;
 
-         }
 
-         /// <summary>
 
-         /// Chuck ATM On Stop
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool CheckChuckATMStopStatus()
 
-         {
 
-             if (_srdCommon.Status == RState.Failed || _srdCommon.Status == RState.Timeout)
 
-             {
 
-                 NotifyError(eEvent.ERR_SRD, "Check ChuckATM is failed", 0);
 
-                 return true;
 
-             }
 
-             return false;
 
-         }
 
-         /// <summary>
 
-         /// Check Vacuum End
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool CheckVacuumEndStatus()
 
-         {
 
-             if(_srdCommon.Status == RState.End && CheckVacuumValue())
 
-             {
 
-                 return true;
 
-             }          
 
-             return false;
 
-         }
 
-         /// <summary>
 
-         /// Check Vacuum Stop
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool CheckVacuumStopStatus()
 
-         {
 
-             if (_srdCommon.Status == RState.Failed || _srdCommon.Status == RState.Timeout)
 
-             {
 
-                 NotifyError(eEvent.ERR_SRD, "Check ChuckATM is failed", 0);
 
-                 return true;
 
-             }
 
-             else if (_srdCommon.Status == RState.End)
 
-             {
 
-                 if (_currentRetryTimes < RETRY_TIMES)
 
-                 {
 
-                     _currentRetryTimes++;
 
-                     NotifyError(eEvent.WARN_SRD, $"Current Chuck ATM Retry Times is {_currentRetryTimes}", 0);
 
-                     _srdCommon.ChuckATMAction("", null);
 
-                 }
 
-                 else
 
-                 {
 
-                     NotifyError(eEvent.ERR_SRD, $"Chuck ATM Retry Times is over {RETRY_TIMES}. ChuckATM is failed!", 0);
 
-                     return true;
 
-                 }
 
-             }
 
-                     
 
-             return false;
 
-         }
 
-         /// <summary>
 
-         /// Check Vacuum Value
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool CheckVacuumValue()
 
-         {
 
-             if (_srdCommon.CommonData.VacuumValue >= _vacuumOffLimit)
 
-             {
 
-                 //LOG.WriteLog(eEvent.INFO_SRD, Module, $"VacuumValue:{_srdCommon.CommonData.VacuumValue}, VacuumOn Limit:{_vacuumOffLimit}");
 
-                 return true;
 
-             }
 
-             else
 
-             {
 
-                 LOG.WriteLog(eEvent.WARN_SRD, Module, $"VacuumValue:{_srdCommon.CommonData.VacuumValue}, VacuumOn Limit:{_vacuumOffLimit}");
 
-                 return false;
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// LiftUpOff
 
-         /// </summary>
 
-         /// <param name="param"></param>
 
-         /// <returns></returns>
 
-         private bool LiftUpOn()
 
-         {
 
-             bool result = _srdCommon.LiftUpOnAction("", null);
 
-             if (!result)
 
-             {
 
-                 NotifyError(eEvent.ERR_SRD, "Lift Up On Action is failed", 0);
 
-                 return result;
 
-             }
 
-             return true;
 
-         }
 
-         /// <summary>
 
-         /// 检验LiftUpOff结束状态
 
-         /// </summary>
 
-         /// <param name="param"></param>
 
-         /// <returns></returns>
 
-         private bool CheckLiftUpOnEndStatus()
 
-         {
 
-             return _srdCommon.Status == RState.End && _srdCommon.CommonData.LiftUpStatus;
 
-         }
 
-         /// <summary>
 
-         /// 检验LiftUpOff结束状态
 
-         /// </summary>
 
-         /// <param name="param"></param>
 
-         /// <returns></returns>
 
-         private bool CheckLiftUpOnStopStatus()
 
-         {
 
-             if (_srdCommon.Status == RState.Failed || _srdCommon.Status == RState.Timeout)
 
-             {
 
-                 NotifyError(eEvent.ERR_SRD, "Check LiftUpOn is failed", 0);
 
-                 return true;
 
-             }
 
-             return false;
 
-         }        
 
-         /// <summary>
 
-         /// ChuckVacuumOn
 
-         /// </summary>
 
-         /// <param name="param"></param>
 
-         /// <returns></returns>
 
-         private bool ChuckVacuumOff()
 
-         {
 
-             bool result = _srdCommon.ChuckVacuumOffAction("", null);
 
-             if (!result)
 
-             {
 
-                 NotifyError(eEvent.ERR_SRD, "ChuckVacuumOff Action is failed", 0);
 
-                 return result;
 
-             }
 
-             return true;
 
-         }
 
-         /// <summary>
 
-         /// 检验ChuckVacuumOn结束状态
 
-         /// </summary>
 
-         /// <param name="param"></param>
 
-         /// <returns></returns>
 
-         private bool CheckChuckVacuumOffEndStatus()
 
-         {
 
-             return _srdCommon.Status == RState.End && _srdCommon.CommonData.ChuckVacuum;
 
-         }
 
-         /// <summary>
 
-         /// 检验ChuckVacuumOn结束状态
 
-         /// </summary>
 
-         /// <param name="param"></param>
 
-         /// <returns></returns>
 
-         private bool CheckChuckVacuumOffStopStatus()
 
-         {
 
-             if (_srdCommon.Status == RState.Failed || _srdCommon.Status == RState.Timeout)
 
-             {
 
-                 NotifyError(eEvent.ERR_SRD, "Check ChuckVacuumOff is failed", 0);
 
-                 return true;
 
-             }
 
-             return false;
 
-         }
 
-         /// <summary>
 
-         /// Check WaferPresent
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool CheckWaferPresent()
 
-         {
 
-             if (!_srdCommon.CommonData.WaferPresent)
 
-             {
 
-                 NotifyError(eEvent.ERR_SRD, "WaferPresent sensor is off", 0);
 
-                 return false;
 
-             }
 
-             return true;
 
-         }
 
-         /// <summary>
 
-         /// Open Door
 
-         /// </summary>
 
-         /// <param name="param"></param>
 
-         /// <returns></returns>
 
-         private bool OpenDoor()
 
-         {
 
-             return _srdCommon.DoorOpenAction("", null);
 
-         }
 
-         /// <summary>
 
-         /// 检验DoorOpened
 
-         /// </summary>
 
-         /// <param name="param"></param>
 
-         /// <returns></returns>
 
-         private bool CheckDoorOpenedEndStatus()
 
-         {
 
-             bool result = _srdCommon.Status == RState.End;
 
-             if (result)
 
-             {
 
-                 if (_srdCommon.CommonData.DoorOpened && !_srdCommon.CommonData.DoorClosed)
 
-                 {
 
-                     return true;
 
-                 }
 
-                 else
 
-                 {
 
-                     NotifyError(eEvent.ERR_SRD, $"Opened {_srdCommon.CommonData.DoorOpened}&&Closed {_srdCommon.CommonData.DoorClosed}", 0);
 
-                     return false;
 
-                 }
 
-             }
 
-             return false;
 
-         }
 
-         /// <summary>
 
-         /// 检验Door
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool CheckDoorOpenedStopStatus()
 
-         {
 
-             return _srdCommon.Status == RState.Failed || _srdCommon.Status == RState.Timeout;
 
-         }
 
-         /// <summary>
 
-         /// Flippers Out
 
-         /// </summary>
 
-         /// <param name="param"></param>
 
-         /// <returns></returns>
 
-         private bool FlippersOut()
 
-         {
 
-             bool result = false;
 
-             object[] objects = new object[1];
 
-             objects[0] = _waferSize;
 
-             result = _srdCommon.FlipperOutAction("", objects);
 
-             if (!result)
 
-             {
 
-                 NotifyError(eEvent.ERR_SRD, $"FlipperOut{_waferSize} Action is failed", 0);
 
-                 return result;
 
-             }
 
-             return true;
 
-         }
 
-         /// <summary>
 
-         /// 检验FlippersOut结束状态
 
-         /// </summary>
 
-         /// <param name="param"></param>
 
-         /// <returns></returns>
 
-         private bool CheckFlippersOutEndStatus()
 
-         {
 
-             return _srdCommon.Status == RState.End;
 
-         }
 
-         /// <summary>
 
-         /// 检验FlippersOut结束状态
 
-         /// </summary>
 
-         /// <param name="param"></param>
 
-         /// <returns></returns>
 
-         private bool CheckFlippersOutStopStatus()
 
-         {
 
-             if (_srdCommon.Status == RState.Failed || _srdCommon.Status == RState.Timeout)
 
-             {
 
-                 NotifyError(eEvent.ERR_SRD, $"Check FlipperOut{_waferSize} Action is failed", 0);
 
-                 return true;
 
-             }
 
-             return false;
 
-         }
 
-         /// <summary>
 
-         /// Get current WaferSize
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool GetWaferSize()
 
-         {
 
-             WaferInfo waferInfo = WaferManager.Instance.GetWafer(ModuleNameString.ToEnum(Module), 0);
 
-             if (waferInfo == null)
 
-             {
 
-                 return false;
 
-             }
 
-             switch (waferInfo.Size)
 
-             {
 
-                 case WaferSize.WS4:
 
-                     _waferSize = 100;
 
-                     break;
 
-                 case WaferSize.WS6:
 
-                 case WaferSize.WS150:
 
-                 case WaferSize.WS159:
 
-                     _waferSize = 150;
 
-                     break;
 
-                 case WaferSize.WS0:
 
-                 case WaferSize.WS8:
 
-                     _waferSize = 200;
 
-                     break;
 
-                 default:
 
-                     return false;
 
-             }
 
-             return true;
 
-         }
 
-         /// <summary>
 
-         /// 关闭 Wafer N2
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool N2Off()
 
-         {
 
-             if(!_srdCommon.CommonData.N2On) return true;
 
-             bool result = _srdCommon.N2OffAction("", null);
 
-             if (!result)
 
-             {
 
-                 NotifyError(eEvent.ERR_SRD, $"N2 Off Action is failed", 0);
 
-             }
 
-             return result;
 
-         }
 
-         /// <summary>
 
-         /// Water Off
 
-         /// </summary>
 
-         /// <param name="param"></param>
 
-         /// <returns></returns>
 
-         private bool WaterOff()
 
-         {
 
-             if (_srdCommon.CommonData.WaterOn)
 
-             {
 
-                 bool result = _srdCommon.WaterOff();
 
-                 if (!result)               
 
-                 {
 
-                     NotifyError(eEvent.ERR_SRD, "Water On is failed", 0);
 
-                 }
 
-                 return result;
 
-             }
 
-             return true;
 
-         }
 
-     }
 
- }
 
 
  |