using Aitex.Core.RT.Device; using Aitex.Core.RT.Device.Unit; using Aitex.Core.RT.Event; using Aitex.Core.RT.Routine; using Aitex.Core.RT.SCCore; using MECF.Framework.Common.Equipment; using SicPM.Devices; using System; using System.Collections.Generic; using System.Diagnostics; namespace SicPM.Routines { class PMToProcessIdleRoutine : PMBaseRoutine { private enum RoutineStep { RotationEnable, HeatEnable, VentPumpClose, ArSupply, OpenH2Valve, SetGroupA, SetGroupB, SetGroupC, SetGroupE, SetGroupF, SetGroupH, SetGroupD, SetGroupG, SetGroupK, SetMFCMode, SetPCMode, SetM1to16, SetPC, SetGroupJ, SetM19to38, SetPC567Close, SetPC567Default, SetPC567Mode, SetGasOut, SetTv, SetM291519to38, SetGasIn1, //V65,V67,V68 OpenFinal1, //V91-96 SetMfcFinal1, //M32-38 SetM291519to26, SetTVCloseMode, SetTvPositionToZero, CheckPM1000, SetGasIn2, SetGroupJOpen, CloseFinal2, OpenFinal2, SetMfcFinal2, WaitPmPressureUp, WaitPmPressureUp1020, SetTvOpen, SetTvMode, SetTVto1050, SetTVto300, WaitTvTo300, CheckPmVac, CheckPmAtm, CheckV72Open, SetV72, SetV25, SetV76, SetV75, SetEPV1, SetEPV2, SetEPV11, SetEPV22, SetTvModeToPress, SetMfc28to31Special, SetMfc28to40Default, SetPressUpOrDown1, SetPressureDown, EnableRotation, EnableHeater, SetRotation1, SetTC1Mode, SetTC1Ratio, SetTC1Ref, SetTC2Mode, SetTC2Ratio, SetTC2Ref, EnableTC1, EnableTC2, SetFinal1ToDefault, SetFinal1To0, SetFinal2ToDefault, SetFinal2To0, CheckFinal1Open, CheckFinal2Open, CheckTvOpen, SetRotation2, SetGroupV38, SetGroupV25, SetScrReset, CheckEpv2Open, CheckEpv1Open, DelayV25, TimeDelay0, TimeDelay1, TimeDelay2, TimeDelay3, TimeDelay4, TimeDelay5, TimeDelay6, TimeDelay7, TimeDelay8, TimeDelay9, TimeDelay10, TimeDelay11, TimeDelay12, TimeDelay13, TimeDelay14, TimeDelay15, Notify1, Notify2 } //private PMModule _pmModule; private IoThrottleValve2 _IoThrottle; List _lstPcList = new List { 1, 2, 3, 4, 5, 6, 7 }; private int _rotationCheckSpeed=0; //设置旋转速度为0后检查是否转速低于此数值 private int _rotationCloseTimeout; //旋转停止超时 private int _IoValueOpenCloseTimeout = 10; //开关超时时间 private int _heatTimeOut = 5; //Heat关闭等待Di反馈超时时间 private double _pmPressureMaxDiff; //蝶阀与目标压力的差值范围(认为调整到位了) private int _throttleTimeout; //蝶阀调整到指定压力的超时时间 private double _throttleFinalPressure = 300;//蝶阀最终调整对的压力 private int _EPV2OpenTimeDelay = 10; private int _waitPMPressureUpTimeout = 300; //等待反应腔压力到达1000的超时时间 private double _pmNoVacPressure = 10; //腔体高于此压力(判断V72打开复合条件) //private int _pressure1 = 1000; //private int _pressure2 = 1020; private bool _psuHeatEnable = false; //是否启用PSU 加热 private float _psuHeatMode = 0; //private float _psuPowerRef = 0; private float _psuL1Ratio = 0; private float _psuL2Ratio = 0; private float _psuL3Ratio = 0; private bool _scrHeatEnable = false; //是否启用SCR 加热 private float _scrHeatMode = 0; //private float _scrPowerRef = 0; private float _scrL1Ratio = 0; private float _scrL2Ratio = 0; private float _scrL3Ratio = 0; private double _mfc28SpecialFlow = 15000; private double _mfc29SpecialFlow = 5000; private double _mfc31SpecialFlow = 10000; private int _rotationSpeed = 60; private int _routineTimeOut; private int _EPV2OpenDelayTime = 9; private Stopwatch _swTimer = new Stopwatch(); private IoInterLock _pmInterLock; public PMToProcessIdleRoutine(ModuleName module, PMModule pm) : base(module, pm) { Module = module.ToString(); Name = "ProcessIdle"; } public override Result Start(params object[] objs) { Reset(); _IoThrottle = DEVICE.GetDevice($"{Module}.TV"); _pmInterLock = DEVICE.GetDevice($"{Module}.PMInterLock"); if (!_pmInterLock.SetPMProcessIdleRunning(true, out string reason)) { EV.PostAlarmLog(Module, $"can not run ProcessIdle, {reason}"); return Result.FAIL; } if (!PMDevice.CheckHeadHeaterEnable(true)) { EV.PostAlarmLog(Module, $"Should set HeatEnable on first!"); return Result.FAIL; } _v72IsOpen = false; _checkPMPressureOver1000 = false; _rotationCloseTimeout = SC.GetValue($"PM.{Module}.RotationCloseTimeout"); _EPV2OpenTimeDelay = SC.GetConfigItem($"PM.{Module}.EPV2OpenTimeDelayAlterEPV1Open").IntValue; _pmPressureMaxDiff = SC.GetValue($"PM.{Module}.ThrottlePressureMaxDiff"); _throttleTimeout = SC.GetValue($"PM.{Module}.ThrottlePressureTimeout"); _mfc28SpecialFlow = SC.GetValue($"PM.{Module}.Mfc28FlowSpecail"); _mfc29SpecialFlow = SC.GetValue($"PM.{Module}.Mfc29FlowSpecail"); _mfc31SpecialFlow = SC.GetValue($"PM.{Module}.Mfc31FlowSpecail"); _rotationSpeed = SC.GetValue($"PM.{Module}.ProcessIdle.RotationSpeed"); _throttleFinalPressure = SC.GetValue($"PM.{Module}.ProcessIdle.FinalPressure"); _psuHeatEnable= SC.GetValue($"PM.{Module}.ProcessIdle.PSUHeaterEnable"); _psuHeatMode = (float)SC.GetValue($"PM.{Module}.ProcessIdle.PSUHeaterMode"); _psuL1Ratio = (float)SC.GetValue($"PM.{Module}.ProcessIdle.PSUInnerRatio"); _psuL2Ratio = (float)SC.GetValue($"PM.{Module}.ProcessIdle.PSUMiddleRatio"); _psuL3Ratio = (float)SC.GetValue($"PM.{Module}.ProcessIdle.PSUOuterRatio"); _scrHeatEnable = SC.GetValue($"PM.{Module}.ProcessIdle.SCRHeaterEnable"); _scrHeatMode = (float)SC.GetValue($"PM.{Module}.ProcessIdle.SCRHeaterMode"); _scrL1Ratio = (float)SC.GetValue($"PM.{Module}.ProcessIdle.SCRUpperRatio"); _scrL2Ratio = (float)SC.GetValue($"PM.{Module}.ProcessIdle.SCRMiddleRatio"); _scrL3Ratio = (float)SC.GetValue($"PM.{Module}.ProcessIdle.SCRLowerRatio"); _routineTimeOut= SC.GetValue($"PM.{Module}.ProcessIdle.RoutineTimeOut"); _EPV2OpenDelayTime = SC.GetValue($"PM.{Module}.TimeDelayAlterEPV2Open"); _finalOpen = false; _isTvOpen = false; currentPressureUpOrDown = PressureUpOrDown.None; _swTimer.Restart(); Notify("Start"); return Result.RUN; } public override Result Monitor() { try { //if (SC.GetValue("System.IsSimulatorMode")) //{ // CheckChamberV72Open((int)RoutineStep.CheckV72Open, 10); // OpenH2Valve((int)RoutineStep.OpenH2Valve, PMDevice, 2); // SetIoValueByGroup((int)RoutineStep.ArSupply, IoGroupName.ArSupply, true, _IoValueOpenCloseTimeout); // SetIoValueByGroup((int)RoutineStep.SetGroupB, IoGroupName.B, false, _IoValueOpenCloseTimeout); // SetIoValueByGroup((int)RoutineStep.SetGroupC, IoGroupName.C, false, _IoValueOpenCloseTimeout); // SetIoValueByGroup((int)RoutineStep.SetGroupE, IoGroupName.E, false, _IoValueOpenCloseTimeout); // SetIoValueByGroup((int)RoutineStep.SetGroupF, IoGroupName.F, false, _IoValueOpenCloseTimeout); // SetIoValueByGroup((int)RoutineStep.SetGroupH, IoGroupName.H, false, _IoValueOpenCloseTimeout); // SetIoValueByGroup((int)RoutineStep.SetGroupV38, IoGroupName.V38, true, _IoValueOpenCloseTimeout); // SetIoValueByGroup((int)RoutineStep.SetGroupK, IoGroupName.K, false, _IoValueOpenCloseTimeout); // SetIoValueByGroup((int)RoutineStep.SetV72, IoGroupName.VentPump, true, _IoValueOpenCloseTimeout); // SetIoValueByGroup((int)RoutineStep.SetV25, IoGroupName.V25, false, _IoValueOpenCloseTimeout); // SetIoValueByGroup((int)RoutineStep.SetGroupD, IoGroupName.D, true, _IoValueOpenCloseTimeout); // SetIoValueByGroup((int)RoutineStep.SetGroupG, IoGroupName.G, true, _IoValueOpenCloseTimeout); // SetIoValueByGroup((int)RoutineStep.SetV76, IoGroupName.V76, false, _IoValueOpenCloseTimeout); // SetIoValueByGroup((int)RoutineStep.SetV75, IoGroupName.V75, true, _IoValueOpenCloseTimeout); // SetMfcModeToNormalByGroup((int)RoutineStep.SetMFCMode, MfcGroupName.All); // SetPcModeToNormal((int)RoutineStep.SetPCMode, _lstPcList); // SetIoValueByGroup((int)RoutineStep.SetGasIn1, IoGroupName.GasIn1, true, _IoValueOpenCloseTimeout); // SetIoValueByGroup((int)RoutineStep.OpenFinal2, IoGroupName.Final2, true, _IoValueOpenCloseTimeout); // SetIoValueByGroup((int)RoutineStep.OpenFinal1, IoGroupName.Final1, true, _IoValueOpenCloseTimeout); // SetIoValueByGroup((int)RoutineStep.SetEPV1, IoGroupName.EPV1, true, _IoValueOpenCloseTimeout); // SetIoValueByGroup((int)RoutineStep.OpenFinal2, IoGroupName.Final2, true, _IoValueOpenCloseTimeout); // SetThrottleEnableAndWait((int)RoutineStep.SetTvOpen, _IoThrottle, 10); // SetThrottleToPressModeAndWait((int)RoutineStep.SetTvModeToPress, _IoThrottle, 10); // return Result.DONE; //} CheckRoutineTimeOut(); //检查Final1和Final2是否打开 CheckFinalIoStatue((int)RoutineStep.CheckFinal1Open); CheckChamberV72Open((int)RoutineStep.CheckV72Open, 10); OpenH2Valve((int)RoutineStep.OpenH2Valve, PMDevice, 2); SetIoValueByGroup((int)RoutineStep.ArSupply, IoGroupName.ArSupply, true, _IoValueOpenCloseTimeout); SetIoValueByGroup((int)RoutineStep.SetGroupB, IoGroupName.B, false, _IoValueOpenCloseTimeout); SetIoValueByGroup((int)RoutineStep.SetGroupC, IoGroupName.C, false, _IoValueOpenCloseTimeout); SetIoValueByGroup((int)RoutineStep.SetGroupE, IoGroupName.E, false, _IoValueOpenCloseTimeout); SetIoValueByGroup((int)RoutineStep.SetGroupF, IoGroupName.F, false, _IoValueOpenCloseTimeout); SetIoValueByGroup((int)RoutineStep.SetGroupH, IoGroupName.H, false, _IoValueOpenCloseTimeout); SetIoValueByGroup((int)RoutineStep.SetGroupV38, IoGroupName.V38, true, _IoValueOpenCloseTimeout); SetIoValueByGroup((int)RoutineStep.SetGroupK, IoGroupName.K, false, _IoValueOpenCloseTimeout); if (!_v72IsOpen) { SetIoValueByGroup((int)RoutineStep.SetGroupV25, IoGroupName.V25, true, _IoValueOpenCloseTimeout); } SetIoValueByGroup((int)RoutineStep.SetGroupD, IoGroupName.D, true, _IoValueOpenCloseTimeout); SetIoValueByGroup((int)RoutineStep.SetGroupG, IoGroupName.G, true, _IoValueOpenCloseTimeout); SetIoValueByGroup((int)RoutineStep.SetV76, IoGroupName.V76, false, _IoValueOpenCloseTimeout); SetIoValueByGroup((int)RoutineStep.SetV75, IoGroupName.V75, true, _IoValueOpenCloseTimeout); SetMfcModeToNormalByGroup((int)RoutineStep.SetMFCMode, MfcGroupName.All); SetPcModeToNormal((int)RoutineStep.SetPCMode, _lstPcList); SetMfcToDefaultByGroup((int)RoutineStep.SetM1to16, MfcGroupName.M1to16, 0); SetPcToDefault((int)RoutineStep.SetPC, _lstPcList); if (!_finalOpen) { SetMfcByGroup((int)RoutineStep.SetM291519to38, MfcGroupName.M291519to38, 0, 5); } TimeDelay((int)RoutineStep.TimeDelay0, 1); //打开进气系统 (V65,V67,V68) SetIoValueByGroup((int)RoutineStep.SetGasIn1, IoGroupName.GasIn1, true, _IoValueOpenCloseTimeout); SetMfcToDefaultByGroup((int)RoutineStep.SetM19to38, MfcGroupName.M19to38, 5); TimeDelay((int)RoutineStep.TimeDelay1, 5); //3.打开Final valves 和对应的MFC值 SetIoValueByGroup((int)RoutineStep.OpenFinal2, IoGroupName.Final2, true, _IoValueOpenCloseTimeout); SetMfcToDefaultByGroup((int)RoutineStep.SetMfcFinal2, MfcGroupName.Final2, 3); TimeDelay((int)RoutineStep.TimeDelay2, 3); SetIoValueByGroup((int)RoutineStep.OpenFinal1, IoGroupName.Final1, true, _IoValueOpenCloseTimeout); SetMfcToDefaultByGroup((int)RoutineStep.SetMfcFinal1, MfcGroupName.Final1, 3); TimeDelay((int)RoutineStep.TimeDelay3, 3); //5.打开J Valves SetIoValueByGroup((int)RoutineStep.SetGroupJOpen, IoGroupName.J, true, _IoValueOpenCloseTimeout); SetMfcToDefaultByGroup((int)RoutineStep.SetM291519to26, MfcGroupName.M291519to26, 3); CheckTvOpen((int)RoutineStep.CheckTvOpen); if (!_isTvOpen) { CheckEPV2Open((int)RoutineStep.CheckEpv2Open); if (!_isEPV2Open) { CheckEPV1Open((int)RoutineStep.CheckEpv1Open); if (!_isEPV1Open) { //检查EPV1是否打开 SetIoValueByGroup((int)RoutineStep.SetEPV1, IoGroupName.EPV1, true, _IoValueOpenCloseTimeout); TimeDelay((int)RoutineStep.TimeDelay4, _EPV2OpenTimeDelay); } //检查EPV2是否打开 SetIoValueByGroup((int)RoutineStep.SetEPV2, IoGroupName.EPV2, true, _IoValueOpenCloseTimeout); TimeDelay((int)RoutineStep.TimeDelay5, _EPV2OpenTimeDelay); } //打开蝶阀,压力设定为1050 SetThrottleEnableAndWait((int)RoutineStep.SetTvOpen, _IoThrottle, 10); SetThrottleToPressModeAndWait((int)RoutineStep.SetTvModeToPress, _IoThrottle, 10); SetThrottleToTargetAndNoWait((int)RoutineStep.SetTVto1050, _IoThrottle, 1050); TimeDelay((int)RoutineStep.TimeDelay6, 2); } //打开V72 SetIoValueByGroup((int)RoutineStep.SetV72, IoGroupName.VentPump, true, _IoValueOpenCloseTimeout); TimeDelay((int)RoutineStep.DelayV25, 1); SetIoValueByGroup((int)RoutineStep.SetV25, IoGroupName.V25, false, _IoValueOpenCloseTimeout); //蝶阀调整到300 SetPressureUpOrDown((int)RoutineStep.SetPressUpOrDown1, PressureUpOrDown.Dowing); SetThrottleToTargetAndNoWait((int)RoutineStep.SetPressureDown, _IoThrottle, _throttleFinalPressure); WaitThrottleToPressureAndSetMfcSpecial((int)RoutineStep.SetTVto300, _IoThrottle, _throttleFinalPressure, _pmPressureMaxDiff, _throttleTimeout); TimeDelay((int)RoutineStep.TimeDelay7, 10); //转速Enable,Set 60rpm(可配置) ,加热Enable, 电流功率可配置 EnableRotation((int)RoutineStep.EnableRotation, 5); SetRotationValveAndNoWait((int)RoutineStep.SetRotation1, _rotationSpeed); //SetHeatEnable((int)RoutineStep.EnableHeater, true, 5); TimeDelay((int)RoutineStep.TimeDelay8, 1); if (_psuHeatEnable) { SetPSUEnable((int)RoutineStep.EnableTC1, true, 5); SetPSUHeatMode((int)RoutineStep.SetTC1Mode, _psuHeatMode); TimeDelay((int)RoutineStep.TimeDelay9, 1); SetPSUHeatRatio((int)RoutineStep.SetTC1Ratio, _psuL1Ratio,_psuL2Ratio,_psuL3Ratio); } if (_scrHeatEnable) { SetSCRReset((int)RoutineStep.SetScrReset); TimeDelay((int)RoutineStep.TimeDelay10, 1); SetSCREnable((int)RoutineStep.EnableTC2, true, 5); SetSCRHeatMode((int)RoutineStep.SetTC2Mode, _scrHeatMode); TimeDelay((int)RoutineStep.TimeDelay11, 1); SetSCRHeatRatio((int)RoutineStep.SetTC2Ratio, _scrL1Ratio, _scrL2Ratio, _scrL3Ratio); } SetRotationValve((int)RoutineStep.SetRotation2, _rotationSpeed,true, _rotationSpeed/2); } catch (RoutineBreakException) { return Result.RUN; } catch (RoutineFaildException) { return Result.FAIL; } _pmInterLock.SetPMProcessIdleRunning(false, out string reason); Notify($"Finished ! Elapsed time: {(int)(_swTimer.ElapsedMilliseconds / 1000)} s"); _swTimer.Stop(); return Result.DONE; } private void CheckRoutineTimeOut() { if (_routineTimeOut > 10) { if ((int)(_swTimer.ElapsedMilliseconds / 1000) > _routineTimeOut) { Notify($"Routine TimeOut! over {_routineTimeOut} s"); throw (new RoutineFaildException()); } } } public override void Abort() { _pmInterLock.SetPMProcessIdleRunning(false, out string reason); PMDevice._ioThrottleValve.StopRamp(); PMDevice.SetMfcStopRamp(PMDevice.GetMfcListByGroupName(MfcGroupName.All)); PMDevice.SetHeaterStopRamp(); PMDevice.SetRotationStopRamp(); PMDevice.SetRotationServo(0, 0); base.Abort(); } } }