123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- 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.Alarm;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.RecipeCenter;
- using MECF.Framework.Common.Routine;
- using MECF.Framework.Common.SubstrateTrackings;
- using PunkHPX8_Core;
- using PunkHPX8_RT.Devices.AXIS;
- using PunkHPX8_RT.Devices.VpwCell;
- using PunkHPX8_RT.Devices.VpwMain;
- using PunkHPX8_RT.Modules.VpwMain;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PunkHPX8_RT.Modules.VpwCell
- {
- public class VpwExtendCleanRoutine : RoutineBase, IRoutine
- {
- private enum PrepareStep
- {
- OpenDrainValve,
- OpenCellValve,
- LoopStart,
- LoopRun,
- LoopEnd,
- End
- }
- #region 内部变量
- /// <summary>
- /// recipe
- /// </summary>
- private VpwRecipe _recipe;
- /// <summary>
- /// 设备
- /// </summary>
- private VpwCellDevice _vpwCellDevice;
- /// <summary>
- /// Main设备
- /// </summary>
- private VpwMainDevice _mainDevice;
- /// <summary>
- /// 总时长
- /// </summary>
- private int _totalMicrosecond = 0;
- /// <summary>
- /// 步骤
- /// </summary>
- private int _stepIndex = 0;
- /// <summary>
- /// 启动步骤时间
- /// </summary>
- private DateTime _startStepTime = DateTime.Now;
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="module"></param>
- public VpwExtendCleanRoutine(string module) : base(module)
- {
- }
- /// <summary>
- /// 中止
- /// </summary>
- public void Abort()
- {
- Runner.Stop("Manual abort");
- }
- /// <summary>
- /// 监控
- /// </summary>
- /// <returns></returns>
- public RState Monitor()
- {
- Runner.Run(PrepareStep.OpenDrainValve, OpenDrainValve, _delay_1ms)
- .Run(PrepareStep.OpenCellValve,OpenCellValve,_delay_1ms)
- .LoopStart(PrepareStep.LoopStart,"Loop Step",_recipe.VentRinseStep.Count,NullFun,_delay_1ms)
- .LoopRunWithStopStatus(PrepareStep.LoopRun, CheckStepComplete, () => { return false; }, _totalMicrosecond + 60 * 1000)//总时长再延迟1分种
- .LoopEnd(PrepareStep.LoopEnd,NullFun,_delay_1ms)
- .End(PrepareStep.End,NullFun,_delay_1ms);
- return Runner.Status;
- }
- /// <summary>
- /// open vent valve
- /// </summary>
- /// <returns></returns>
- private bool OpenDrainValve()
- {
- bool result = _vpwCellDevice.DrainValveOn();
- if (!result)
- {
- NotifyError(eEvent.ERR_VPW, "open drain valve failed", 0);
- }
- return result;
- }
- /// <summary>
- /// 打开相应的cell valve
- /// </summary>
- /// <returns></returns>
- private bool OpenCellValve()
- {
- int count = 0;
- int enableCount = 0;
- if (_recipe.ExtendCleanDripEnable)
- {
- count += _vpwCellDevice.FlowDripOn()?1:0;
- enableCount++;
- }
- if (_recipe.ExtendCleanLargeEnable)
- {
- count += _vpwCellDevice.FlowLargeOn() ? 1 : 0;
- enableCount++;
- }
- if (_recipe.ExtendCleanSmallEnable)
- {
- count += _vpwCellDevice.FlowSmallOn() ? 1 : 0;
- enableCount++;
- }
- bool result= count == enableCount;
- if (!result)
- {
- NotifyError(eEvent.ERR_VPW, "open cell valve failed", 0);
- }
- foreach (var item in _recipe.ExtendCleanRinseStep)
- {
- _totalMicrosecond += item.DurationSeconds * 1000;
- }
- _startStepTime = DateTime.Now;
- _stepIndex = 0;
- return result;
- }
- /// <summary>
- /// 检验步骤是否完成
- /// </summary>
- /// <returns></returns>
- private bool CheckStepComplete()
- {
- _mainDevice.CellFlow = _vpwCellDevice.CommonData.DiwFlow;
- if (_stepIndex >= _recipe.ExtendCleanRinseStep.Count)
- {
- LOG.WriteLog(eEvent.INFO_VPW, Module, $"step {_stepIndex} is over step count {_recipe.ExtendCleanRinseStep.Count}");
- return true;
- }
- int length = _recipe.ExtendCleanRinseStep[_stepIndex].DurationSeconds;
- if (DateTime.Now.Subtract(_startStepTime).TotalSeconds >= length)
- {
- _stepIndex++;
- _startStepTime = DateTime.Now;
- if (_stepIndex >= _recipe.ExtendCleanRinseStep.Count)
- {
- LOG.WriteLog(eEvent.INFO_VPW, Module, $"step {_stepIndex} is over step count {_recipe.ExtendCleanRinseStep.Count}");
- return true;
- }
- bool result = _vpwCellDevice.ChangeRotationSpeed(_recipe.ExtendCleanRinseStep[_stepIndex].RotationSpeed*6);
- if (result)
- {
- LOG.WriteLog(eEvent.INFO_VPW, Module, $"step {_stepIndex} complete");
- }
- return result;
- }
- int firstDelay = SC.GetValue<int>($"{Module}.FlowCheckDelay") * 1000;
- if (DateTime.Now.Subtract(_startStepTime).TotalMilliseconds >= firstDelay)
- {
- bool abnormal = CheckDisable();
- if (abnormal)
- {
- return false;
- }
- }
- return false;
- }
- /// <summary>
- /// 检验数据
- /// </summary>
- /// <returns></returns>
- private bool CheckDisable()
- {
- double flow = _vpwCellDevice.CommonData.DiwFlow;
- double lowError = _recipe.ExtendCleanFlowSetPoint * (1 - (double)_recipe.ExtendCleanFlowErrorPercent / 100);
- double upError = _recipe.ExtendCleanFlowSetPoint * (1 + (double)_recipe.ExtendCleanFlowErrorPercent / 100);
- double lowWarn = _recipe.ExtendCleanFlowSetPoint * (1 - (double)_recipe.ExtendCleanFlowWarningPercent / 100);
- double upWarn = _recipe.ExtendCleanFlowSetPoint * (1 + (double)_recipe.ExtendCleanFlowWarningPercent / 100);
- if (flow<lowError)
- {
- NotifyError(eEvent.ERR_VPW, $"{Module} cell flow {flow} is less than {lowError} ", 0);
- Abort();
- return true;
- }
- if (flow > upError)
- {
- NotifyError(eEvent.ERR_VPW, $"{Module} cell flow {flow} is up than {upError} ", 0);
- Abort();
- return true;
- }
- if ((flow <= upError && flow >= upWarn) || (flow >= lowError && flow <= lowWarn))
- {
- string str = $"{Module} cell flow {flow} is in warning";
- if (AlarmListManager.Instance.AddWarn(Module, $"{Module} cell flow", str))
- {
- LOG.WriteLog(eEvent.WARN_VPW, Module, str);
- }
- }
- bool isSimulatorMode = SC.GetValue<bool>("System.IsSimulatorMode");
- if (!isSimulatorMode)
- {
- if (!_vpwCellDevice.CheckRotationRunning())
- {
- NotifyError(eEvent.ERR_VPW, $"{Module} rotation is stopped", 0);
- Abort();
- return true;
- }
- }
- return false;
- }
- /// <summary>
- /// 启动
- /// </summary>
- /// <param name="objs"></param>
- /// <returns></returns>
- public RState Start(params object[] objs)
- {
- _recipe=(VpwRecipe)objs[0];
- _vpwCellDevice = DEVICE.GetDevice<VpwCellDevice>(Module);
- _mainDevice = DEVICE.GetDevice<VpwMainDevice>(ModuleName.VPWMain1.ToString());
- _totalMicrosecond = 0;
- _stepIndex = 0;
- return Runner.Start(Module, $"{Module} extend clean");
- }
- /// <summary>
- /// 重试
- /// </summary>
- /// <param name="step"></param>
- public RState Retry(int step)
- {
- if (_recipe == null)
- {
- NotifyError(eEvent.ERR_VPW, "recipe is null", -1);
- return RState.Failed;
- }
- List<Enum> preStepIds = new List<Enum>();
- return Runner.Retry(PrepareStep.OpenDrainValve, preStepIds, Module, "Extend clean Retry");
- }
- }
- }
|