using Aitex.Core.RT.Device; using Aitex.Core.RT.Log; using Aitex.Core.RT.Routine; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.RecipeCenter; using MECF.Framework.Common.Routine; using PunkHPX8_Core; using PunkHPX8_RT.Devices.VpwCell; using PunkHPX8_RT.Devices.VpwMain; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PunkHPX8_RT.Modules.VpwCell { public class VpwRecipeRoutine : RoutineBase, IRoutine { private enum RecipeStep { ChamberUp, CloseDrain, CheckLoopDO, End } #region 内部变量 /// /// recipe /// private VpwRecipe _recipe; /// /// 设备 /// private VpwCellDevice _vpwCellDevice; /// /// Main设备 /// private VpwMainDevice _mainDevice; #endregion /// /// 构造函数 /// /// public VpwRecipeRoutine(string module) : base(module) { } /// /// 中止 /// public void Abort() { Runner.Stop("Manual stop"); } /// /// 监控 /// /// public RState Monitor() { Runner.Run(RecipeStep.ChamberUp, ChamberUp, CheckChamberClosed) .Run(RecipeStep.CloseDrain, _vpwCellDevice.DrainValveOff, _delay_1ms) .Run(RecipeStep.CheckLoopDO, CheckLoopDO, _delay_1ms) .End(RecipeStep.End, NullFun, _delay_1ms); return Runner.Status; } /// /// chamber up /// /// private bool ChamberUp() { bool result = _mainDevice.ChamberUp(); if (!result) { NotifyError(eEvent.ERR_VPW, "chamber up failed", -1); } return result; } /// /// 检验Chamber是否关闭 /// /// private bool CheckChamberClosed() { return _mainDevice.CommonData.ChamberClosed && !_mainDevice.CommonData.ChamberOpened; } /// /// Check LoopDO数值 /// /// private bool CheckLoopDO() { double loopDoValue = _vpwCellDevice.LoopDOValue; bool result = loopDoValue < _recipe.DiwLoopDoSet; if (!result) { NotifyError(eEvent.ERR_VPW, $"LoopDO value {loopDoValue} is less than {_recipe.DiwLoopDoSet}", -1); } return result; } /// /// 启动 /// /// /// public RState Start(params object[] objs) { _recipe = objs[0] as VpwRecipe; _vpwCellDevice = DEVICE.GetDevice(Module); _mainDevice = DEVICE.GetDevice(ModuleName.VPWMain1.ToString()); return Runner.Start(Module, "start run recipe"); } /// /// 重试 /// /// public RState Retry(int step) { if (_recipe == null) { NotifyError(eEvent.ERR_RINSE, "recipe is null", -1); return RState.Failed; } List preStepIds = new List(); return Runner.Retry(RecipeStep.ChamberUp, preStepIds, Module, "Run recipe Retry"); } } }