123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504 |
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Routine;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.Routine;
- using CyberX8_Core;
- using CyberX8_RT.Devices.AXIS;
- using CyberX8_RT.Devices.Loader;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using MECF.Framework.Common.Utilities;
- using Aitex.Core.RT.Log;
- using MECF.Framework.Common.CommonData.Loader;
- using CyberX8_RT.Modules.Dryer;
- using MECF.Framework.Common.Persistent.Temperature;
- using MECF.Framework.Common.WaferHolder;
- namespace CyberX8_RT.Modules.Loader
- {
- public class LoaderLoadAllSideRoutine : RoutineBase, IRoutine
- {
- private enum LoadStep
- {
- SideALoad,
- Delay,
- SideBLoad,
- SideAllLoadWait,
- LeakTest,
- LeakTestWait,
- RotationGoToTRNPA,
- RotationGoToTRNPAWait,
- UnclampWaferHolder,
- End
- }
- #region 常量
- private const string SIDE_A = "SideA";
- private const string SIDE_B = "SideB";
- private const int LOTTRACK_TIME = 1000;
- #endregion
- #region 内部变量
- private JetAxisBase _rotationAxis;
- private LoaderLoadRoutine _sideALoadRoutine;
- private LoaderLoadRoutine _sideBLoadRoutine;
- private LoaderCommonDevice _loaderCommonDevice;
- private bool _isSideALoaded = false;
- private bool _isSideBLoaded = false;
- private bool _isSideAStop = false;
- private bool _isSideBStop = false;
- /// <summary>
- /// lotTrack time
- /// </summary>
- private DateTime _lotTackTime = DateTime.Now;
- /// <summary>
- /// Loader Common
- /// </summary>
- private LoaderCommonDevice _loaderCommon;
- /// <summary>
- /// LoaderSide A
- /// </summary>
- private LoaderSideDevice _loaderSideA;
- /// <summary>
- /// LoaderSide B
- /// </summary>
- private LoaderSideDevice _loaderSideB;
- /// <summary>
- /// Loader LotTrackData
- /// </summary>
- private List<LoaderLotTrackData> _datas = new List<LoaderLotTrackData>();
- /// <summary>
- /// Flow LotTrackData
- /// </summary>
- private List<LoaderFlowLotTrackData> _flowDatas = new List<LoaderFlowLotTrackData>();
- /// <summary>
- /// Loader Start and Finish Time
- /// </summary>
- private List<DateTime> _loadTimeList = new List<DateTime>();
- #endregion
- #region 属性
- /// <summary>
- /// UnLoad LotTrackData
- /// </summary>
- public List<LoaderLotTrackData> LoadLotTrackDatas { get { return _datas; } }
- /// <summary>
- /// Flow LotTrackData
- /// </summary>
- public List<LoaderFlowLotTrackData> FlowLotTrackDatas { get { return _flowDatas; } }
- /// <summary>
- /// LoadTimeList
- /// </summary>
- public List<DateTime> LoadTimeList { get { return _loadTimeList; } }
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="module"></param>
- public LoaderLoadAllSideRoutine(string module) : base(module)
- {
- }
- /// <summary>
- /// 中止
- /// </summary>
- public void Abort()
- {
- }
- /// <summary>
- /// 监控
- /// </summary>
- /// <returns></returns>
- public RState Monitor()
- {
- //记录Lot track
- LottrackRecord();
- Runner.Run(LoadStep.SideALoad, () => StartLoadRoutine(_sideALoadRoutine,_isSideALoaded), _delay_1ms)
- .Delay(LoadStep.Delay,500)
- .Run(LoadStep.SideBLoad, () => StartLoadRoutine(_sideBLoadRoutine,_isSideBLoaded), _delay_1ms)
- .WaitWithStopCondition(LoadStep.SideAllLoadWait, CheckLoadAllRoutineEndStatus,CheckLoadAllRoutineStopStatus)
- .Run(LoadStep.LeakTest, StartFlowTest, _delay_1ms)
- .WaitWithStopCondition(LoadStep.LeakTestWait, CheckFlowTestEndStatus, CheckFlowTestStopStatus)
- .Run(LoadStep.RotationGoToTRNPA,RotationGotoTransporterA,_delay_1s)
- .WaitWithStopCondition(LoadStep.RotationGoToTRNPAWait,CheckRotationPositionStatus,CheckRotationPositionRunStop)
- .Run(LoadStep.UnclampWaferHolder,WaferHolderClampOffAction,_delay_1ms)
- .End(LoadStep.End, UpdateWaferHolderUse, _delay_1ms);
- return Runner.Status;
- }
- /// <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||_rotationAxis.Status==RState.Timeout;
- if (result)
- {
- NotifyError(eEvent.ERR_LOADER, "rotation goto position failed", 2);
- }
- return result;
- }
- /// <summary>
- /// 启动load routine
- /// </summary>
- /// <param name="loadRoutine"></param>
- /// <returns></returns>
- private bool StartLoadRoutine(LoaderLoadRoutine loadRoutine,bool isSideLoaded)
- {
- if (isSideLoaded)
- {
- return true;
- }
- bool result= loadRoutine.Start()==RState.Running;
- if (!result)
- {
- NotifyError(eEvent.ERR_LOADER, loadRoutine.ErrorMsg, 0);
- }
- return result;
- }
- /// <summary>
- /// 检验LoadAll完成状态
- /// </summary>
- /// <returns></returns>
- private bool CheckLoadAllRoutineEndStatus()
- {
- bool sideAResult = true;
- if (!_isSideALoaded)
- {
- sideAResult = CheckLoadRoutineEndStatus(_sideALoadRoutine);
- }
- bool sideBResult = true;
- if(!_isSideBLoaded)
- {
- sideBResult= CheckLoadRoutineEndStatus(_sideBLoadRoutine);
- }
- if (sideAResult && sideBResult)
- {
- _loadTimeList.Add(DateTime.Now);
- }
- return sideAResult && sideBResult;
- }
- /// <summary>
- /// 检验LoadAll停止状态
- /// </summary>
- /// <returns></returns>
- private bool CheckLoadAllRoutineStopStatus()
- {
- bool sideAComplete = false;
- if(!_isSideALoaded&&!_isSideAStop)
- {
- RState ret = _sideALoadRoutine.Monitor();
- _isSideAStop = ret == RState.Failed || ret == RState.Timeout;
- sideAComplete = (ret != RState.Running);
- if (_isSideAStop)
- {
- NotifyError(eEvent.ERR_LOADER, $"load A failed\r\n{_sideALoadRoutine.ErrorMsg}", 0);
- }
- }
- bool sideBComplete = false;
- if (!_isSideBLoaded&&!_isSideBStop)
- {
- RState ret = _sideBLoadRoutine.Monitor();
- _isSideBStop = ret == RState.Failed || ret == RState.Timeout;
- sideBComplete = (ret != RState.Running);
- if (_isSideBStop)
- {
- NotifyError(eEvent.ERR_LOADER, $"load B failed\r\n{_sideBLoadRoutine.ErrorMsg}", 0);
- }
- }
- return (_isSideAStop&&sideBComplete)||(_isSideBStop&&sideAComplete);
- }
- /// <summary>
- /// 检验routine完成状态
- /// </summary>
- /// <param name="loadRoutine"></param>
- /// <returns></returns>
- private bool CheckLoadRoutineEndStatus(LoaderLoadRoutine loadRoutine)
- {
- return loadRoutine.Monitor() == RState.End;
- }
- /// <summary>
- /// 启动Flowtest
- /// </summary>
- /// <returns></returns>
- private bool StartFlowTest()
- {
- bool result= _loaderCommonDevice.StartFlowTestAction();
- if (!result)
- {
- NotifyError(eEvent.ERR_LOADER, "Start Flow Test failed", 1);
- }
- return result;
- }
- /// <summary>
- /// 检验FlowTest停止状态
- /// </summary>
- /// <returns></returns>
- private bool CheckFlowTestStopStatus()
- {
- if (_loaderCommonDevice.Status == RState.Failed || _loaderCommonDevice.Status == RState.Timeout)
- {
- NotifyError(eEvent.ERR_LOADER, "Flow Test failed",1);
- return true;
- }
- return false;
- }
- /// <summary>
- /// 检验FlowTest完成状态
- /// </summary>
- /// <returns></returns>
- private bool CheckFlowTestEndStatus()
- {
- bool result = _loaderCommonDevice.Status == RState.End;
- if (result)
- {
- _flowDatas = _loaderCommonDevice.FlowLotTrackDatas;
- }
- return result;
- }
- /// <summary>
- /// Rotation 运动至TRNPA
- /// </summary>
- /// <returns></returns>
- private bool RotationGotoTransporterA()
- {
- bool result = _rotationAxis.PositionStation("TRNPA", false);
- if (!result)
- {
- NotifyError(eEvent.ERR_LOADER, "rotation start goto TRNPA failed", 2);
- }
- return result;
- }
- /// <summary>
- /// Wafer Holder Clamp Off
- /// </summary>
- /// <returns></returns>
- public bool WaferHolderClampOffAction()
- {
- bool result = _loaderCommonDevice.WaferHolderClampOffAction();
- if (!result)
- {
- NotifyError(eEvent.ERR_LOADER, "Wafer Shuttle Clamp Off failed", 2);
- }
- return result;
- }
- /// <summary>
- /// 更新WaferHolder总用量
- /// </summary>
- /// <returns></returns>
- private bool UpdateWaferHolderUse()
- {
- WaferHolderInfo waferHolderInfo = WaferHolderManager.Instance.GetWaferHolder("Loader");
- if(waferHolderInfo != null)
- {
- waferHolderInfo.TotalUses += 1;
- WaferHolderManager.Instance.UpdateWaferHolderInfo(waferHolderInfo);
- }
- return true;
- }
- /// <summary>
- /// 启动
- /// </summary>
- /// <param name="objs"></param>
- /// <returns></returns>
- public RState Start(params object[] objs)
- {
- InitializeParameters();
- _loaderCommon = DEVICE.GetDevice<LoaderCommonDevice>($"{Module}.Common");
- _loaderSideA = DEVICE.GetDevice<LoaderSideDevice>($"{Module}.SideA");
- _loaderSideB = DEVICE.GetDevice<LoaderSideDevice>($"{Module}.SideB");
- //清除lotTrack数据
- _datas.Clear();
- _flowDatas.Clear();
- _loadTimeList.Clear();
- _loadTimeList.Add(DateTime.Now);
-
- return Runner.Start(Module, "Start LoadAll");
- }
- /// <summary>
- /// 初始化参数
- /// </summary>
- private void InitializeParameters()
- {
- _isSideALoaded = false;
- _isSideBLoaded = false;
- _isSideAStop = false;
- _isSideBStop = false;
- _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
- _sideALoadRoutine = new LoaderLoadRoutine(ModuleName.Loader1.ToString(), SIDE_A);
- _sideBLoadRoutine = new LoaderLoadRoutine(ModuleName.Loader1.ToString(), SIDE_B);
- _loaderCommonDevice = DEVICE.GetDevice<LoaderCommonDevice>($"{ModuleName.Loader1}.Common");
- }
- /// <summary>
- /// 重试
- /// </summary>
- /// <param name="step"></param>
- public RState Retry(int step)
- {
- InitializeParameters();
- List<Enum> preStepIds = new List<Enum>();
- _datas.Clear();
- if (step == 0 || step == -1)
- {
- _isSideALoaded = CheckSideLoadCondition("A", step,false);
- _isSideBLoaded=CheckSideLoadCondition("B", step,false);
- return Runner.Retry(LoadStep.SideALoad, preStepIds, Module, "LoadAll Retry");
- }
- else if (step == 1)
- {
- AddPreSteps(LoadStep.LeakTest, preStepIds);
- return Runner.Retry(LoadStep.LeakTest, preStepIds, Module, $"LoadAll step {LoadStep.LeakTest} start Retry");
- }
- else
- {
- AddPreSteps(LoadStep.RotationGoToTRNPA, preStepIds);
- return Runner.Retry(LoadStep.RotationGoToTRNPA, preStepIds, Module, $"LoadAll step {LoadStep.RotationGoToTRNPA} start Retry");
- }
- }
- /// <summary>
- /// 忽略前
- /// </summary>
- /// <param name="step"></param>
- /// <param name="preStepIds"></param>
- private void AddPreSteps(LoadStep step, List<Enum> preStepIds)
- {
- for (int i = 0; i < (int)step; i++)
- {
- preStepIds.Add((LoadStep)i);
- }
- }
- /// <summary>
- /// 检验前面Unload完成状态
- /// </summary>
- /// <returns></returns>
- public bool CheckCompleteCondition(int index)
- {
- if (!CheckSideLoadCondition("A", index,true))
- {
- return false;
- }
- if (!CheckSideLoadCondition("B", index,true))
- {
- return false;
- }
- JetAxisBase loaderRotationAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.Rotation");
- double loaderRotationPosition = loaderRotationAxis.MotionData.MotorPosition;
- if (!loaderRotationAxis.CheckPositionIsInStation(loaderRotationPosition, "TRNPA"))
- {
- NotifyError(eEvent.ERR_LOADER, $"loader rotation {loaderRotationPosition} not in TRNPA", index);
- }
- return true;
- }
- /// <summary>
- /// 检验Side Unload情况
- /// </summary>
- /// <param name="side"></param>
- /// <param name="index"></param>
- /// <returns></returns>
- private bool CheckSideLoadCondition(string side, int index,bool showError)
- {
- JetAxisBase shuttleAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.Shuttle{side}");
- double shuttlePosition = shuttleAxis.MotionData.MotorPosition;
- if (!shuttleAxis.CheckPositionIsInStation(shuttlePosition, "CLOSED"))
- {
- if (showError)
- {
- NotifyError(eEvent.ERR_LOADER, $"shuttle{side} {shuttlePosition} is not in closed", index);
- }
- return false;
- }
- JetAxisBase tiltAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.Tilt{side}");
- double tiltPosition = tiltAxis.MotionData.MotorPosition;
- if (tiltAxis.CheckPositionIsInStation(tiltPosition, "VERT"))
- {
- if (showError)
- {
- NotifyError(eEvent.ERR_LOADER, $"tilt{side} {tiltPosition} is not in VERT", index);
- }
- return false;
- }
- JetAxisBase crsAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.LS{side}");
- double crsPosition = crsAxis.MotionData.MotorPosition;
- if (!crsAxis.CheckPositionIsInStation(crsPosition, "Setup"))
- {
- if (showError)
- {
- NotifyError(eEvent.ERR_LOADER, $"LS{side} {crsPosition} is not in Setup", index);
- }
- return false;
- }
- LoaderSideDevice loaderSideDevice = DEVICE.GetDevice<LoaderSideDevice>($"{ModuleName.Loader1}.Side{side}");
- if (loaderSideDevice.SideData.DoorLowerUnlocked || loaderSideDevice.SideData.DoorUpperUnlocked)
- {
- if (showError)
- {
- NotifyError(eEvent.ERR_LOADER, $"side{side} door unlocked", index);
- }
- }
- return true;
- }
- /// <summary>
- /// 记录Lottrack
- /// </summary>
- private void LottrackRecord()
- {
- //记录Lottrack
- if (DateTime.Now.Subtract(_lotTackTime).TotalMilliseconds >= LOTTRACK_TIME)
- {
- AddLotTrackData();
- _lotTackTime = DateTime.Now;
- }
- }
- /// <summary>
- /// 获取Lot Track数据
- /// </summary>
- /// <returns></returns>
- private void AddLotTrackData()
- {
- LoadStep step = (LoadStep)Runner.CurrentStep;
- if (step <= LoadStep.SideAllLoadWait)
- {
- LoaderLotTrackData data = new LoaderLotTrackData();
- data.TimeStamp = DateTime.Now;
- data.LoaderABernoulliBladderEnable = _loaderSideA.SideData.BernoulliBladder;
- data.LoaderABernoulliExtended = _loaderSideA.SideData.BernoulliExtended;
- data.LoaderABernoulliBladderPressure = _loaderSideA.SideData.BernoulliBladderPressure;
- data.LoaderABernoulliN2Pressure = _loaderSideA.SideData.BernoulliPressure;
- data.LoaderACRSVacuum = _loaderSideA.SideData.CRSVacuum;
- data.LoaderACRSVacuumAnlg = _loaderSideA.SideData.CRSVacuumValue;
- data.LoaderAWHPressure = _loaderSideA.SideData.WHBladderPressure;
- data.LoaderATranslatePressure = _loaderSideA.SideData.TransPressure;
- data.LoaderBBernoulliBladderEnable = _loaderSideB.SideData.BernoulliBladder;
- data.LoaderBBernoulliExtended = _loaderSideB.SideData.BernoulliExtended;
- data.LoaderBBernoulliBladderPressure = _loaderSideB.SideData.BernoulliBladderPressure;
- data.LoaderBBernoulliN2Pressure = _loaderSideB.SideData.BernoulliPressure;
- data.LoaderBCRSVacuum = _loaderSideB.SideData.CRSVacuum;
- data.LoaderBCRSVacuumAnlg = _loaderSideB.SideData.CRSVacuumValue;
- data.LoaderBWHPressure = _loaderSideB.SideData.WHBladderPressure;
- data.LoaderBTranslatePressure = _loaderSideB.SideData.TransPressure;
- data.LoaderWHClamped = _loaderCommon.CommonData.WaferHolderClamp;
- _datas.Add(data);
- }
- }
-
- }
- }
|