| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340 | 
							- using Aitex.Core.Common;
 
- using Aitex.Core.RT.DataCenter;
 
- using Aitex.Core.RT.Device;
 
- using Aitex.Core.RT.Log;
 
- using Aitex.Core.RT.Routine;
 
- using Aitex.Core.Util;
 
- using MECF.Framework.Common.DBCore;
 
- using MECF.Framework.Common.Equipment;
 
- using MECF.Framework.Common.Routine;
 
- using MECF.Framework.Common.SubstrateTrackings;
 
- using MECF.Framework.Common.Utilities;
 
- using MECF.Framework.Common.WaferHolder;
 
- using CyberX8_Core;
 
- using CyberX8_RT.Devices.AXIS;
 
- using CyberX8_RT.Devices.Loader;
 
- using CyberX8_RT.Devices.PUF;
 
- using CyberX8_RT.Modules.Loader;
 
- using System;
 
- using System.Collections.Generic;
 
- using System.Linq;
 
- using System.Text;
 
- using System.Threading.Tasks;
 
- namespace CyberX8_RT.Modules.PUF
 
- {
 
-     public class PufPlaceToLoaderRoutine : RoutineBase, IRoutine
 
-     {
 
-         private enum PlaceStep
 
-         {
 
-             OnlyPlaceToLoader,
 
-             OnlyPlaceToLoaderWait,
 
-             SwitchWaferHolder,
 
-             LastRotationHomeStation,
 
-             LastRotationHomeStationWait,
 
-             End
 
-         }
 
-         #region 常量
 
-         private const string CURRENT_STATION_LIST = "CurrentStationList";
 
-         private const string SIDE_A = "SideA";
 
-         private const string SIDE_B = "SideB";
 
-         #endregion
 
-         #region 内部变量
 
-         private string _loaderSide;
 
-         private string _pufSide = "";
 
-         private LoaderEntity _loaderEntity;
 
-         private JetAxisBase _flipAxis;
 
-         private JetAxisBase _rotationAxis;
 
-         private PufVacuum _vacuum;
 
-         private LoaderSideDevice _loaderSideDevice;
 
-         private JetAxisBase _loaderCrsAxis;
 
-         private JetAxisBase _gantryAxis;
 
-         private PufOnlyPlaceToLoaderRoutine _onlyPlaceToLoaderRoutine;
 
-         #endregion
 
-         /// <summary>
 
-         /// 构造函数
 
-         /// </summary>
 
-         /// <param name="module"></param>
 
-         public PufPlaceToLoaderRoutine(string module) : base(module)
 
-         {
 
-         }
 
-         /// <summary>
 
-         /// 中止
 
-         /// </summary>
 
-         public void Abort()
 
-         {
 
-             if (_onlyPlaceToLoaderRoutine != null)
 
-             {
 
-                 _onlyPlaceToLoaderRoutine.Abort();
 
-             }
 
-             _flipAxis.StopPositionOperation();
 
-             _rotationAxis.StopPositionOperation();
 
-             Runner.Stop("Manual Abort");            
 
-         }
 
-         /// <summary>
 
-         /// 监控
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         public RState Monitor()
 
-         {
 
-             Runner.Run(PlaceStep.OnlyPlaceToLoader,StartOnlyPlaceToLoader,_delay_1ms)
 
-                 .WaitWithStopCondition(PlaceStep.OnlyPlaceToLoaderWait,CheckPlaceEndStatus,CheckPlaceStopStatus)
 
-                 .Run(PlaceStep.SwitchWaferHolder,SwitchWaferHolderSideWafer,_delay_1ms)
 
-                 .Run(PlaceStep.LastRotationHomeStation, () => _rotationAxis.PositionStation("Home"), _delay_1ms)
 
-                 .WaitWithStopCondition(PlaceStep.LastRotationHomeStationWait, CheckRotationPositionStatus, CheckRotationPositionRunStop)
 
-                 .End(PlaceStep.End, NullFun, _delay_1ms);
 
-             return Runner.Status;
 
-         }
 
-         /// <summary>
 
-         /// 执行放片至Loader
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool StartOnlyPlaceToLoader()
 
-         {
 
-             return _onlyPlaceToLoaderRoutine.Start(_pufSide,_loaderSide) == RState.Running;
 
-         }
 
-         /// <summary>
 
-         /// 检验放片状态 
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool CheckPlaceEndStatus()
 
-         {
 
-             return _onlyPlaceToLoaderRoutine.Monitor() ==RState.End;
 
-         }
 
-         /// <summary>
 
-         /// 检验放片停止状态
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool CheckPlaceStopStatus()
 
-         {
 
-             RState state = _onlyPlaceToLoaderRoutine.Monitor();
 
-             if(state==RState.Failed||state==RState.Timeout)
 
-             {
 
-                 NotifyError(eEvent.ERR_PUF, "puf place wafer failed", 0);
 
-                 return true;
 
-             }
 
-             return false;
 
-         }
 
-         /// <summary>
 
-         /// WaferHolder交换片
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool SwitchWaferHolderSideWafer()
 
-         {
 
-             WaferHolderInfo waferHolderInfo = _loaderEntity.WaferHolderInfo;
 
-             if (waferHolderInfo != null)
 
-             {
 
-                 if (_loaderSide==SIDE_A)
 
-                 {
 
-                     WaferManager.Instance.WaferMoved(ModuleHelper.Converter(Module), 1, ModuleName.Loader1, 0);
 
-                     WaferInfo loaderWaferInfo = WaferManager.Instance.GetWafer(ModuleName.Loader1, 0);
 
-                     waferHolderInfo.WaferAId = loaderWaferInfo.WaferID;
 
-                     waferHolderInfo.WaferAType = (int)loaderWaferInfo.WaferType;
 
-                     WaferHolderDataRecorder.UpdateWaferHolderData(waferHolderInfo.Id, waferHolderInfo);
 
-                     MaterialTrackerManager.Instance.UpdateModuleMaterial(ModuleName.Loader1.ToString());
 
-                 }
 
-                 else
 
-                 {
 
-                     WaferManager.Instance.WaferMoved(ModuleHelper.Converter(Module), 1, ModuleName.Loader1, 1);
 
-                     WaferInfo loaderWaferInfo = WaferManager.Instance.GetWafer(ModuleName.Loader1, 1);
 
-                     waferHolderInfo.WaferBId = loaderWaferInfo.WaferID;
 
-                     waferHolderInfo.WaferBType = (int)loaderWaferInfo.WaferType;
 
-                     WaferHolderDataRecorder.UpdateWaferHolderData(waferHolderInfo.Id, waferHolderInfo);
 
-                     MaterialTrackerManager.Instance.UpdateModuleMaterial(ModuleName.Loader1.ToString());
 
-                 }
 
-             }
 
-             return true;
 
-         }
 
-         /// <summary>
 
-         /// 检验Rotation移动状态
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool CheckRotationPositionStatus()
 
-         {
 
-             return _rotationAxis.Status == RState.End;
 
-         }
 
-         /// <summary>
 
-         /// 检验Rotation是否还在运动
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool CheckRotationPositionRunStop()
 
-         {
 
-             bool result= _rotationAxis.Status == RState.Failed;
 
-             if (result)
 
-             {
 
-                 NotifyError(eEvent.ERR_PUF, "rotation axis goto home failed", 0);
 
-             }
 
-             return result;
 
-         }
 
-         /// <summary>
 
-         /// 启动
 
-         /// </summary>
 
-         /// <param name="objs"></param>
 
-         /// <returns></returns>
 
-         public RState Start(params object[] objs)
 
-         {
 
-             _pufSide = objs[0].ToString();
 
-             _loaderEntity = Singleton<RouteManager>.Instance.GetModule<LoaderEntity>(ModuleName.Loader1.ToString());
 
-             _flipAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Flip");
 
-             _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
 
-             _vacuum = DEVICE.GetDevice<PufVacuum>($"{Module}.Vacuum");
 
-             _gantryAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Transporter2}.Gantry");
 
-             if (!CheckPreCondition())
 
-             {
 
-                 return RState.Failed;
 
-             }
 
-             GetCrsAxis();
 
-             _onlyPlaceToLoaderRoutine = new PufOnlyPlaceToLoaderRoutine(Module.ToString());
 
-             return Runner.Start(Module, "Place To Loader");
 
-         }
 
-         /// <summary>
 
-         /// 检验是否存在Wafer
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool CheckWaferPresent()
 
-         {
 
-             if (_pufSide == "SideA")
 
-             {
 
-                 if (!_vacuum.ChuckAWaferPresent)
 
-                 {
 
-                     NotifyError(eEvent.ERR_PUF, $"{_pufSide} has no Wafer", -1);
 
-                     return false;
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 if (!_vacuum.ChuckBWaferPresent)
 
-                 {
 
-                     NotifyError(eEvent.ERR_PUF, $"{_pufSide} has no Wafer",-1);
 
-                     return false;
 
-                 }
 
-             }
 
-             return true;
 
-         }
 
-         /// <summary>
 
-         /// 检验前置条件
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool CheckPreCondition()
 
-         {
 
-             if(!CheckWaferPresent())
 
-             {
 
-                 return false;
 
-             }
 
-             bool isLoaderInstall = ModuleHelper.IsInstalled(ModuleName.Loader1);
 
-             if (isLoaderInstall)
 
-             {
 
-                 JetAxisBase loaderRotationaxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.Rotation");
 
-                
 
-                 if (loaderRotationaxis != null)
 
-                 {
 
-                     double loaderRotationPosition = loaderRotationaxis.MotionData.MotorPosition;
 
-                     if (!loaderRotationaxis.CheckPositionInStationIgnoreWaferSize(loaderRotationPosition, "LOAD"))
 
-                     {
 
-                         NotifyError(eEvent.ERR_PUF, $"Loader Rotation {loaderRotationPosition} is not in LOAD", -1);
 
-                         return false;
 
-                     }
 
-                     bool isLoadA = loaderRotationaxis.CheckPositionInStationIgnoreWaferSize(loaderRotationPosition, "LOADA");
 
-                     bool isLoadB = loaderRotationaxis.CheckPositionInStationIgnoreWaferSize(loaderRotationPosition, "LOADB");
 
-                     _loaderSide = isLoadA ? SIDE_A : SIDE_B;
 
-                 } 
 
-                 string side = _loaderSide == SIDE_A ? "A" : "B";
 
-                 GetLoaderSide();
 
-                 if (_loaderSideDevice.SideData.WaferPresent)
 
-                 {
 
-                     NotifyError(eEvent.ERR_PUF, $"{_loaderSideDevice.Module}.{_loaderSideDevice.Name} wafer present sensor is true", -1);
 
-                     return false;
 
-                 }
 
-                 //Loader1.SwingA 在Open
 
-                 JetAxisBase loaderShuttleAAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.Shuttle{side}");
 
-                 if (loaderShuttleAAxis != null)
 
-                 {
 
-                     double loaderShuttleAPosition = loaderShuttleAAxis.MotionData.MotorPosition;
 
-                     if (!loaderShuttleAAxis.CheckPositionInStationIgnoreWaferSize(loaderShuttleAPosition, "OUT"))
 
-                     {
 
-                         NotifyError(eEvent.ERR_PUF, $"Loader Shuttle{side} {loaderShuttleAPosition} is not in OUT", -1);
 
-                         return false;
 
-                     }
 
-                 }
 
-                 //Loader1.TiltA 在HORI
 
-                 JetAxisBase loaderTiltAAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.Tilt{side}");
 
-                 if (loaderTiltAAxis != null)
 
-                 {
 
-                     double loaderTiltAPosition = loaderTiltAAxis.MotionData.MotorPosition;
 
-                     if (!loaderTiltAAxis.CheckPositionIsInStation(loaderTiltAPosition, "HORI"))
 
-                     {
 
-                         NotifyError(eEvent.ERR_PUF, $"Loader Tilt{side} {loaderTiltAPosition} is not in HORI", -1);
 
-                         return false;
 
-                     }
 
-                 }
 
-                 //Loader Handle Wafer状态确认
 
-                 // Lip Seal Vacuum "ON"
 
-                 if (!_loaderSideDevice.SideData.CRSVacuum)
 
-                 {
 
-                     NotifyError(eEvent.ERR_PUF, "Loader1 LS Vacuum is off", -1);
 
-                     return false;
 
-                 }
 
-                 //Bernoulli Bladder "ON",Retracted Green Light
 
-                 if (!_loaderSideDevice.SideData.BernoulliBladder)
 
-                 {
 
-                     NotifyError(eEvent.ERR_PUF, "Loader1 Bernoulli Bladder is off",-1);
 
-                     return false;
 
-                 }
 
-                 //其他SideA/B均为OFF
 
-                 if (_loaderSideDevice.SideData.BernoulliN2)
 
-                 {
 
-                     NotifyError(eEvent.ERR_PUF, "Loader1 Bernoulli N2 is on",-1);
 
-                     return false;
 
-                 }
 
-             }
 
-             double rotationPosition = _rotationAxis.MotionData.MotorPosition;
 
-             if (_rotationAxis.CheckPositionIsEmpty(rotationPosition))
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_PUF, Module, $"rotation axis {rotationPosition} is not at Station");
 
-                 return false;
 
-             }
 
-             double flipPosition = _flipAxis.MotionData.MotorPosition;
 
-             if (_flipAxis.CheckPositionIsEmpty(flipPosition))
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_PUF, Module, $"flip axis {flipPosition} is not at Station");
 
-                 return false;
 
-             }
 
-             return true;
 
-         }
 
-         /// <summary>
 
-         /// 获取LoaderSide
 
-         /// </summary>
 
-         private void GetLoaderSide()
 
-         {
 
-             if (_loaderSide==SIDE_A)
 
-             {
 
-                 _loaderSideDevice = DEVICE.GetDevice<LoaderSideDevice>($"{ModuleName.Loader1}.SideA");
 
-             }
 
-             else
 
-             {
 
-                 _loaderSideDevice = DEVICE.GetDevice<LoaderSideDevice>($"{ModuleName.Loader1}.SideB");
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 获取lipseal Axis
 
-         /// </summary>
 
-         private void GetCrsAxis()
 
-         {
 
-             if(_loaderSide==SIDE_A)
 
-             {
 
-                 _loaderCrsAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.LSA");
 
-             }
 
-             else
 
-             {
 
-                 _loaderCrsAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.LSB");
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |