using Aitex.Core.RT.Routine; using Aitex.Core.RT.SCCore; using Venus_RT.Devices; using MECF.Framework.Common.Routine; using Venus_Core; using Aitex.Core.Common.DeviceData; using System; namespace Venus_RT.Modules.PMs { class RFPowerSwitchRoutine : PMRoutineBase, IRoutine { enum RFPowerStep { kSetPower, kEnd, } private bool _bOn = true; private bool _enableBias; private double _rfPower; private double _rfPowerBias; private BiasRfMatchMode _matchMode; private double _matchC1; private double _matchC2; private int _rfPowerOnTime; public RFPowerSwitchRoutine(JetPMBase chamber, bool bOn) : base(chamber) { Name = "RF Power Switch"; _bOn = bOn; } public RState Start(params object[] objs) { if (!_chamber.IsFastPumpOpened) { Stop("Pump 阀没有打开"); return RState.Failed; } _enableBias = SC.GetValue($"{_chamber.Module}.BiasRf.EnableBiasRF"); if (_bOn) { if (objs == null || objs.Length < 3) { Stop("RF routine argument error"); return RState.Failed; } _rfPower = Convert.ToDouble(objs[0]); _rfPowerBias = Convert.ToDouble(objs[1]); _rfPowerOnTime = (int)Convert.ToDouble(objs[2]) * 1000; _matchMode = Convert.ToInt32(objs[3]) == 1 ? BiasRfMatchMode.Preset : BiasRfMatchMode.Hold; _matchC1 = Convert.ToDouble(objs[4]); _matchC2 = Convert.ToDouble(objs[5]); } else { _rfPower = 0.0; _rfPowerBias = 0.0; _matchMode = BiasRfMatchMode.Preset; _matchC1 = 0.0; _matchC2 = 0.0; _rfPowerOnTime = 2000; } Reset(); return Runner.Start(Module, Name); } public RState Monitor() { Runner.Run(RFPowerStep.kSetPower, SetRFPower, _rfPowerOnTime) .End(RFPowerStep.kEnd, RFPowerFinished, _delay_1s); return Runner.Status; } private bool SetRFPower() { if(_bOn) { if (_enableBias) Notify($"放电开始, 源射频设定值 {_rfPower}, 偏压射频设定值 {_rfPowerBias}"); else Notify($"放电开始, 源射频设定值 {_rfPower}"); if (Math.Abs(_rfPower) > 0.01 && Math.Abs(_rfPowerBias) > 0.01) { _chamber.GeneratorSetpower((float)_rfPower); _chamber.GeneratorBiasSetpower((float)_rfPowerBias); if (_matchMode == BiasRfMatchMode.Preset) { _chamber.GeneratorBiasSetMatchMode(true); Notify($"Bias RF Match C1设定值 {_matchC1}, Bias RF Match C2设定值 {_matchC2}"); _chamber.SetBiasMatchPosition((float)_matchC1, (float)_matchC2); } else if (_matchMode == BiasRfMatchMode.Hold) { _chamber.GeneratorBiasSetMatchMode(false); } return _chamber.GeneratorPowerOn(true) && _chamber.GeneratorBiasPowerOn(true); } else if (Math.Abs(_rfPower) < 0.01 && Math.Abs(_rfPowerBias) > 0.01) { if (_matchMode == BiasRfMatchMode.Preset) { _chamber.GeneratorBiasSetMatchMode(true); Notify($"Bias RF Match C1设定值 {_matchC1}, Bias RF Match C2设定值 {_matchC2}"); _chamber.SetBiasMatchPosition((float)_matchC1, (float)_matchC2); } else if (_matchMode == BiasRfMatchMode.Hold) { _chamber.GeneratorBiasSetMatchMode(false); } _chamber.GeneratorBiasSetpower((float)_rfPowerBias); return _chamber.GeneratorBiasPowerOn(true); } else if (Math.Abs(_rfPower) > 0.01 && Math.Abs(_rfPowerBias) < 0.01) { _chamber.GeneratorSetpower((float)_rfPower); return _chamber.GeneratorPowerOn(true); } else { Notify("放电结束"); return false; } } else { Notify("放电停止"); if (!_enableBias) return _chamber.GeneratorPowerOn(false); return _chamber.GeneratorPowerOn(false) && _chamber.GeneratorBiasPowerOn(false); } } private bool RFPowerFinished() { if(_bOn) { Notify("放电结束"); _chamber.StopAllGases(); _chamber.OpenValve(ValveType.GasFinal, false); _chamber.GeneratorPowerOn(false); _chamber.GeneratorBiasPowerOn(false); } return true; } public void Abort() { _chamber.GeneratorSetpower(0); _chamber.GeneratorBiasSetpower(0); _chamber.GeneratorPowerOn(false); _chamber.GeneratorBiasPowerOn(false); } } }