using System; using Aitex.Core.Common.DeviceData; using Aitex.Core.RT.Routine; using Aitex.Core.RT.SCCore; using Aitex.Core.Util; using JetVirgoPM.Devices; namespace JetVirgoPM.PMs.Routines { class RfPowerRoutine : PMRoutineBase, IStepRoutine { private enum RoutineStep { kRFPowerOn, kRFPowerOFF, MatchOn, End, }; private readonly bool _ON; private R_TRIG _rf1TimeoutTrig = new R_TRIG(); private R_TRIG _rf2TimeoutTrig = new R_TRIG(); public bool EnableRF1 => Math.Abs(_rf1PowerOnTime) > 0.01; public bool EnableRF2 => Math.Abs(_rf2PowerOnTime) > 0.01; private bool _enableBias1; private double _rf1Power; private double _rf1PowerBias; private BiasRfMatchMode _match1Mode; private double _match1C1; private double _match1C2; private double _rf1PowerOnTime; private bool _enableBias2; private double _rf2Power; private double _rf2PowerBias; private BiasRfMatchMode _match2Mode; private double _match2C1; private double _match2C2; private double _rf2PowerOnTime; public RfPowerRoutine(JetDualPM chamber, bool bON) : base(chamber) { Name = "RF Power"; _ON = bON; } public RState Start(params object[] objs) { if (!_chamber.IsFastPumpOpened) { Stop("Pump 阀没有打开"); return RState.Failed; } if (_ON && _chamber.TotalGasSetpoint <= 0) { Stop("No gas flowing for RF power on"); return RState.Failed; } Reset(); _enableBias1 = SC.GetValue($"{_chamber.Module}.BiasRf1.EnableBiasRF"); _enableBias2 = SC.GetValue($"{_chamber.Module}.BiasRf2.EnableBiasRF"); if (_ON) { if (objs == null || objs.Length < 12) throw new ArgumentException("RF routine argument error"); _rf1Power = Convert.ToDouble(objs[0]); _rf1PowerBias = Convert.ToDouble(objs[1]); _rf1PowerOnTime = Convert.ToDouble(objs[2]); _match1Mode = objs[3].ToString() == "Preset" ? BiasRfMatchMode.Preset : BiasRfMatchMode.Hold; _match1C1 = Convert.ToDouble(objs[4]); _match1C2 = Convert.ToDouble(objs[5]); _rf2Power = Convert.ToDouble(objs[6]); _rf2PowerBias = Convert.ToDouble(objs[7]); _rf2PowerOnTime = Convert.ToDouble(objs[8]); _match2Mode = objs[9].ToString() == "Preset" ? BiasRfMatchMode.Preset : BiasRfMatchMode.Hold; _match2C1 = Convert.ToDouble(objs[10]); _match2C2 = Convert.ToDouble(objs[11]); } else { _rf1Power = 0.0; _rf1PowerBias = 0.0; _match1Mode = BiasRfMatchMode.Preset; _match1C1 = 0.0; _match1C2 = 0.0; _rf1PowerOnTime = 0.0; _rf2Power = 0.0; _rf2PowerBias = 0.0; _match2Mode = BiasRfMatchMode.Preset; _match2C1 = 0.0; _match2C2 = 0.0; _rf2PowerOnTime = 0.0; } return Runner.Start(_chamber.Module.ToString(), Name); } public RState Monitor() { if (_ON) { Runner.Run(RoutineStep.kRFPowerOn, RFPowerOn, CheckRFPowerOn, Math.Max((int)_rf1PowerOnTime, (int)_rf2PowerOnTime) * 1000) .End(RoutineStep.End, EndFunc, _delay_0s); } else { Runner.Run(RoutineStep.kRFPowerOFF, RFPowerOFF, CheckRFPowerOff, 2000) .End(RoutineStep.End, EndFunc, _delay_0s); } return Runner.Status; } bool RFPowerOn() { if (!EnableRF1 && !EnableRF2) { Notify($"放电结束"); return false; } if (EnableRF1) { if (_enableBias1) Notify($"放电开始, 源射频1设定值 {_rf1Power}, 偏压射频1设定值 {_rf1PowerBias}"); else Notify($"放电开始, 源射频1设定值 {_rf1Power}"); if (Math.Abs(_rf1Power) > 0.01 && Math.Abs(_rf1PowerBias) > 0.01) { _chamber.Generator1Setpower((float)_rf1Power); _chamber.GeneratorBias1Setpower((float)_rf1PowerBias); if (_match1Mode == BiasRfMatchMode.Preset) { _chamber.GeneratorBias1SetMatchMode(true); Notify($"Bias RF 1 Match C1设定值 {_match1C1}, Bias RF 1 Match C2设定值 {_match1C2}"); _chamber.SetBias1MatchPosition((float)_match1C1, (float)_match1C2); } else if (_match1Mode == BiasRfMatchMode.Hold) { _chamber.GeneratorBias1SetMatchMode(false); } _chamber.Generator1PowerOn(true); _chamber.GeneratorBias1PowerOn(true); } else if (Math.Abs(_rf1Power) < 0.01 && Math.Abs(_rf1PowerBias) > 0.01) { if (_match1Mode == BiasRfMatchMode.Preset) { _chamber.GeneratorBias1SetMatchMode(true); Notify($"Bias RF 1 Match C1设定值 {_match1C1}, Bias RF 1 Match C2设定值 {_match1C2}"); _chamber.SetBias1MatchPosition((float)_match1C1, (float)_match1C2); } else if (_match1Mode == BiasRfMatchMode.Hold) { _chamber.GeneratorBias1SetMatchMode(false); } _chamber.GeneratorBias1Setpower((float)_rf1PowerBias); _chamber.GeneratorBias1PowerOn(true); } else if (Math.Abs(_rf1Power) > 0.01 && Math.Abs(_rf1PowerBias) < 0.01) { _chamber.Generator1Setpower((float)_rf1Power); _chamber.Generator1PowerOn(true); } } if (EnableRF2) { if (_enableBias2) Notify($"放电开始, 源射频2设定值 {_rf2Power}, 偏压射频2设定值 {_rf2PowerBias}"); else Notify($"放电开始, 源射频2设定值 {_rf2Power}"); if (Math.Abs(_rf2Power) > 0.01 && Math.Abs(_rf2PowerBias) > 0.01) { _chamber.Generator2Setpower((float)_rf2Power); _chamber.GeneratorBias2Setpower((float)_rf2PowerBias); if (_match2Mode == BiasRfMatchMode.Preset) { _chamber.GeneratorBias2SetMatchMode(true); Notify($"Bias RF 2 Match C1设定值 {_match2C1}, Bias RF 2 Match C2设定值 {_match2C2}"); _chamber.SetBias2MatchPosition((float)_match2C1, (float)_match2C2); } else if (_match2Mode == BiasRfMatchMode.Hold) { _chamber.GeneratorBias2SetMatchMode(false); } _chamber.Generator2PowerOn(true); _chamber.GeneratorBias2PowerOn(true); } else if (Math.Abs(_rf2Power) < 0.01 && Math.Abs(_rf2PowerBias) > 0.01) { if (_match2Mode == BiasRfMatchMode.Preset) { _chamber.GeneratorBias2SetMatchMode(true); Notify($"Bias RF 2 Match C1设定值 {_match2C1}, Bias RF 2 Match C2设定值 {_match2C2}"); _chamber.SetBias2MatchPosition((float)_match2C1, (float)_match2C2); } else if (_match2Mode == BiasRfMatchMode.Hold) { _chamber.GeneratorBias2SetMatchMode(false); } _chamber.GeneratorBias2Setpower((float)_rf2PowerBias); _chamber.GeneratorBias2PowerOn(true); } else if (Math.Abs(_rf2Power) > 0.01 && Math.Abs(_rf2PowerBias) < 0.01) { _chamber.Generator2Setpower((float)_rf2Power); _chamber.Generator2PowerOn(true); } } return true; } bool CheckRFPowerOn() { _rf1TimeoutTrig.CLK = Elapsed >= _rf1PowerOnTime; if (_rf1TimeoutTrig.Q) { Notify("RF1放电结束"); _chamber.Generator1PowerOn(false); _chamber.GeneratorBias1PowerOn(false); } _rf2TimeoutTrig.CLK = Elapsed >= _rf2PowerOnTime; if (_rf2TimeoutTrig.Q) { Notify("RF2放电结束"); _chamber.Generator2PowerOn(false); _chamber.GeneratorBias2PowerOn(false); } if (Elapsed >= _rf1PowerOnTime && Elapsed >= _rf2PowerOnTime) { Notify("结束"); _chamber.StopAllGases(); _chamber.OpenValve(ValveType.PROCESS, false); _chamber.OpenValve(ValveType.PURGE, false); _chamber.Generator1PowerOn(false); _chamber.GeneratorBias1PowerOn(false); _chamber.Generator2PowerOn(false); _chamber.GeneratorBias2PowerOn(false); return true; } return false; } bool RFPowerOFF() { Notify("放电停止"); _chamber.Generator1PowerOn(false); _chamber.Generator2PowerOn(false); if (_enableBias1) _chamber.GeneratorBias1PowerOn(false); if (_enableBias2) _chamber.GeneratorBias2PowerOn(false); return true; } bool CheckRFPowerOff() { return true; } public override void Abort() { _chamber.Generator1Setpower(0); _chamber.GeneratorBias1Setpower(0); _chamber.Generator1PowerOn(false); _chamber.GeneratorBias1PowerOn(false); _chamber.Generator2Setpower(0); _chamber.GeneratorBias2Setpower(0); _chamber.Generator2PowerOn(false); _chamber.GeneratorBias2PowerOn(false); } } }