| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 | using System;using System.Collections.Generic;using Aitex.Core.RT.Device;using Aitex.Core.RT.Routine;using MECF.Framework.Common.Routine;using CyberX8_Core;using CyberX8_RT.Devices.LinMot;using CyberX8_RT.Devices.Prewet;using MECF.Framework.Common.CommonData.Prewet;using MECF.Framework.Common.CommonData;using Aitex.Core.RT.SCCore;using Aitex.Core.Util;using Aitex.Core.RT.Log;using MECF.Framework.Common.RecipeCenter;namespace CyberX8_RT.Modules.Prewet{    sealed class CycleManualProcessRecipeRoutine:RoutineBase, IRoutine    {        private const int LOTTRACK_TIME = 1000;        private enum CycleManualRunRecipeStep        {            LoopStart,            LoopRunProcess,            LoopWaitRunProcess,            LoopDelay,            LoopEnd,            End        }        #region 内部变量        private PrewetProcessRoutine _processRecipeRoutine;        private LinMotAxis _linmotAxis;        private int _cycle = 0;        private int _achievedCycle;        private object[] param;        /// <summary>        /// Prewet recipe        /// </summary>        private PwtRecipe _recipe;        /// <summary>        /// lock track time        /// </summary>        private DateTime _lotTackTime = DateTime.Now;        /// <summary>        /// LotTrack数据        /// </summary>        private List<PrewetLotTrackData> _datas = new List<PrewetLotTrackData>();        /// <summary>        /// LotTrack文件头数据        /// </summary>        private LotTrackFileHeaderCommonData _header = new LotTrackFileHeaderCommonData();        /// <summary>        /// 设备对象        /// </summary>        private PrewetDevice _prewetDevice;        #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<PrewetLotTrackData> PrewetLotTrackDatas { get { return _datas; } }        /// <summary>        /// LotTrack文件头数据        /// </summary>        public LotTrackFileHeaderCommonData PrewetLotTrackHeaderDatas { get { return _header; } }        #endregion                /// <summary>        /// 构造函数        /// </summary>        /// <param name="module"></param>        public CycleManualProcessRecipeRoutine(string module, LinMotAxis linMotAxis) : base(module)        {            _linmotAxis = linMotAxis;            _processRecipeRoutine = new PrewetProcessRoutine(module, _linmotAxis);        }        /// <summary>        /// Abort        /// </summary>        public void Abort()        {            _processRecipeRoutine.Abort();            Runner.Stop("Cycle ManualRunRecipe Abort");        }        public RState Start(params object[] objs)        {            _cycle = (int)objs[1];            _achievedCycle = 0;            param = objs;            _prewetDevice = DEVICE.GetDevice<PrewetDevice>(Module);            _datas.Clear();            _recipe = objs[0] as PwtRecipe;            if (_recipe == null)            {                LOG.WriteLog(eEvent.ERR_PREWET, 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}.pwt.rcp";            //lotTract记录SequenceRecipe            PrewetEntity prewetEntity = Singleton<RouteManager>.Instance.GetModule<PrewetEntity>(Module);            if (prewetEntity.WaferHolderInfo != null && prewetEntity.WaferHolderInfo.SequenceRecipe != null && !string.IsNullOrEmpty(prewetEntity.WaferHolderInfo.SequenceRecipe.Ppid.ToString()))            {                _header.SequenceRecipe = prewetEntity.WaferHolderInfo.SequenceRecipe.Ppid.ToString();                _header.ProcessTransferList = new List<string>();                _header.ProcessTransferList.AddRange(prewetEntity.WaferHolderInfo.SchedulerModules);                prewetEntity.WaferHolderInfo.SchedulerModules.Clear();            }            _lotTackTime = DateTime.Now;            return Runner.Start(Module, "Start 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()        {            PrewetLotTrackData data = new PrewetLotTrackData();            data.TimeStamp = DateTime.Now;            data.StateMachine = CurrentStateMachine;            data.Pressure = _prewetDevice.PrewetPumpData.PumpPressureData.Value;            data.Flow = _prewetDevice.PrewetPumpData.PumpFlowData.Value;            data.PumpMode = _prewetDevice.PrewetPumpData.PumpModel;            data.PressureTarget = _prewetDevice.PrewetPumpData.PressureTarget;            data.CurrentScan = _linmotAxis.ScanCount;            data.ScanOn = _linmotAxis.IsMotorOn;            data.ValveState = _prewetDevice.PrewetPumpData.PumpValve;            data.PumpSpeed = _prewetDevice.LastPumpSpeed;            data.PumpControlCurrent = _prewetDevice.PrewetPumpData.PumpCurrent;            _datas.Add(data);        }    }}
 |