123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.Util;
- using MECF.Framework.Common.CommonData;
- using MECF.Framework.Common.CommonData.Prewet;
- using MECF.Framework.Common.CommonData.Vpw;
- using MECF.Framework.Common.RecipeCenter;
- using MECF.Framework.Common.Routine;
- using PunkHPX8_Core;
- using PunkHPX8_RT.Devices.LinMot;
- using PunkHPX8_RT.Devices.VpwCell;
- using PunkHPX8_RT.Modules.VpwMain;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PunkHPX8_RT.Modules.VpwCell
- {
- public class VpwCycleManualProcessRecipeRoutine : RoutineBase, IRoutine
- {
- private const int LOTTRACK_TIME = 1000;
- private enum CycleManualRunRecipeStep
- {
- LoopStart,
- LoopRunProcess,
- LoopWaitRunProcess,
- LoopDelay,
- LoopEnd,
- End
- }
- #region 内部变量
- private VpwManualRecipeRoutine _processRecipeRoutine;
- private int _cycle = 0;
- private int _achievedCycle;
- private object[] param;
- /// <summary>
- /// Vpw recipe
- /// </summary>
- private VpwRecipe _recipe;
- /// <summary>
- /// lock track time
- /// </summary>
- private DateTime _lotTackTime = DateTime.Now;
- /// <summary>
- /// LotTrack数据
- /// </summary>
- private List<VpwLotTrackData> _datas = new List<VpwLotTrackData>();
- /// <summary>
- /// LotTrack文件头数据
- /// </summary>
- private LotTrackFileHeaderCommonData _header = new LotTrackFileHeaderCommonData();
- /// <summary>
- /// 设备对象
- /// </summary>
- private VpwCellDevice _vpwCellDevice;
- #endregion
- #region 属性
- /// <summary>
- /// 当前执行到循环哪一步
- /// </summary>
- public string CurrentStatus
- {
- get { return Runner.CurrentStep.ToString(); }
- }
- /// <summary>
- /// 当前执行到循环哪一步内的哪个动作
- /// </summary>
- public string CurrentStateMachine
- {
- get { return _processRecipeRoutine.CurrentStep; }
- }
- /// <summary>
- /// LotTrack数据
- /// </summary>
- public List<VpwLotTrackData> VpwLotTrackDatas { get { return _datas; } }
- /// <summary>
- /// LotTrack文件头数据
- /// </summary>
- public LotTrackFileHeaderCommonData VpwLotTrackHeaderDatas { get { return _header; } }
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="module"></param>
- public VpwCycleManualProcessRecipeRoutine(string module) : base(module)
- {
- _processRecipeRoutine = new VpwManualRecipeRoutine(module);
- }
- /// <summary>
- /// Abort
- /// </summary>
- public void Abort()
- {
- _processRecipeRoutine.Abort();
- Runner.Stop("Vpw Cycle ManualRunRecipe Abort");
- }
- public RState Start(params object[] objs)
- {
- _cycle = (int)objs[1];
- _achievedCycle = 0;
- param = objs;
- _vpwCellDevice = DEVICE.GetDevice<VpwCellDevice>(Module);
- _datas.Clear();
- _recipe = objs[0] as VpwRecipe;
- if (_recipe == null)
- {
- LOG.WriteLog(eEvent.ERR_VPW, Module, "recipe is null");
- return RState.Failed;
- }
- if (SC.ContainsItem("System.ToolID")) _header.ToolID = SC.GetStringValue("System.ToolID");
- _header.SoftWareVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
- _header.Recipe = $"{_recipe.Ppid}.vpw.rcp";
-
- //lotTract记录SequenceRecipe
- //VpwCellEntity vpwCellEntity = Singleton<RouteManager>.Instance.GetModule<VpwCellEntity>(Module);
- //if (vpwCellEntity.WaferHolderInfo != null && vpwCellEntity.WaferHolderInfo.SequenceRecipe != null && !string.IsNullOrEmpty(vpwCellEntity.WaferHolderInfo.SequenceRecipe.Ppid.ToString()))
- //{
- // _header.SequenceRecipe = vpwCellEntity.WaferHolderInfo.SequenceRecipe.Ppid.ToString();
- // _header.ProcessTransferList = new List<string>();
- // _header.ProcessTransferList.AddRange(vpwCellEntity.WaferHolderInfo.SchedulerModules);
- // vpwCellEntity.WaferHolderInfo.SchedulerModules.Clear();
- //}
-
- _lotTackTime = DateTime.Now;
- return Runner.Start(Module, "Start Vpw Cycle ManualRunRecipe");
- }
- public RState Monitor()
- {
- LottrackRecord();
- Runner.LoopStart(CycleManualRunRecipeStep.LoopStart, "Loop Start ManualRunRecipe", _cycle, NullFun, _delay_1ms)
- .LoopRun(CycleManualRunRecipeStep.LoopRunProcess, () => _processRecipeRoutine.Start(param) == RState.Running, _delay_1ms)
- .LoopRunWithStopStatus(CycleManualRunRecipeStep.LoopWaitRunProcess, () => CheckRoutineEndStatus(_processRecipeRoutine), () => CheckRoutineStopStatus(_processRecipeRoutine))
- .LoopDelay(CycleManualRunRecipeStep.LoopDelay, _delay_1s)
- .LoopEnd(CycleManualRunRecipeStep.LoopEnd, AchievedCycleCount, _delay_1ms)
- .End(CycleManualRunRecipeStep.End, NullFun, _delay_1ms);
- return Runner.Status;
- }
- private bool CheckRoutineEndStatus(IRoutine routine)
- {
- bool result = routine.Monitor() == RState.End;
- return result;
- }
- private bool CheckRoutineStopStatus(IRoutine routine)
- {
- RState state = routine.Monitor();
- if (state == RState.Failed || state == RState.Timeout)
- {
- AddLotTrackData();
- return true;
- }
- return false;
- }
- /// <summary>
- /// 统计完成的Cycle次数
- /// </summary>
- /// <returns></returns>
- private bool AchievedCycleCount()
- {
- _achievedCycle += 1;
- return true;
- }
- /// <summary>
- /// 获取已经完成的Cycle次数
- /// </summary>
- /// <returns></returns>
- public int GetAchievedCycle()
- {
- return _achievedCycle;
- }
- /// <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()
- {
- VpwLotTrackData data = new VpwLotTrackData();
- data.TimeStamp = DateTime.Now;
- data.StateMachine = CurrentStateMachine;
- data.VacuumPressure = _vpwCellDevice.CommonData.VacuumPressure;
- data.CellFlow = _vpwCellDevice.CommonData.DiwFlow;
- data.DiwLoopDo = _vpwCellDevice.LoopDOValue;
- data.WaterPressure = _vpwCellDevice.MainCommonData.DiwPressure;
- data.DripValve = _vpwCellDevice.CommonData.FlowDrip;
- data.SmallValve = _vpwCellDevice.CommonData.FlowSmall;
- data.LargeValve = _vpwCellDevice.CommonData.FlowLarge;
- data.ChamberClosed = _vpwCellDevice.MainCommonData.ChamberClosed;
- _datas.Add(data);
- }
- }
- }
|