ProcessDefine.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925
  1. using System;
  2. using System.Collections.Generic;
  3. //using System.
  4. using Venus_RT.Devices;
  5. using Aitex.Core.RT.Log;
  6. using Venus_Core;
  7. using Aitex.Core.RT.SCCore;
  8. using Aitex.Core.RT.Tolerance;
  9. //#pragma warning disable 0436
  10. namespace Venus_RT.Modules.PMs
  11. {
  12. class ProcessHelper
  13. {
  14. protected JetPMBase Chamber;
  15. private string Module;
  16. public RecipeHead m_RecipeHead;
  17. private static Dictionary<string, Func<ProcessUnitBase, RecipeStep, RState>> startHelper = new Dictionary<string, Func<ProcessUnitBase, RecipeStep, RState>>();
  18. private static Dictionary<string, Func<ProcessUnitBase, RecipeStep, RState>> checkerHelper = new Dictionary<string, Func<ProcessUnitBase, RecipeStep, RState>>();
  19. private static Dictionary<string, Action<ProcessUnitBase, RecipeStep>> endHelper = new Dictionary<string, Action<ProcessUnitBase, RecipeStep>>();
  20. private List<float> rfMatchC1 = new List<float>();
  21. private List<float> rfMatchC2 = new List<float>();
  22. private int rfMatchC1C2Index = 0;
  23. private List<float> biasRfMatchC1 = new List<float>();
  24. private List<float> biasRfMatchC2 = new List<float>();
  25. private int biasRfMatchC1C2Index = 0;
  26. public bool isLoop = false;
  27. public int loopsteps = 0;
  28. public int currentStepIndex = 0;
  29. private bool biasRFSetPointFlag = true;
  30. private double _scRFPowerAlarmTime;
  31. private double _scBiasRFPowerAlarmTime;
  32. private RecipeToleranceChecker _GasFlowToleranceChecker;
  33. private RecipeToleranceChecker _RFToleranceChecker;
  34. private RecipeToleranceChecker _BiasRFToleranceChecker;
  35. private bool _isEnableMatchC1C2Offset;
  36. private int _matchC1C2OffsetValue;
  37. private bool _isEnableBiasMatchC1C2Offset;
  38. private int _biasMatchC1C2OffsetValue;
  39. public ProcessHelper(JetPMBase pm)
  40. {
  41. Chamber = pm;
  42. Module = pm.Module.ToString();
  43. Init();
  44. _GasFlowToleranceChecker = new RecipeToleranceChecker(Module);
  45. _RFToleranceChecker = new RecipeToleranceChecker(Module);
  46. _BiasRFToleranceChecker = new RecipeToleranceChecker(Module);
  47. }
  48. private void Init()
  49. {
  50. startHelper[$"{Module}.PressureByPressureModeUnit"] = (ProcessUnitBase unit, RecipeStep step) => PressureByPressureModeUnit_Start(unit, step);
  51. checkerHelper[$"{Module}.PressureByPressureModeUnit"] = (ProcessUnitBase unit, RecipeStep step) => PressureByPressureModeUnit_Check(unit, step);
  52. endHelper[$"{Module}.PressureByPressureModeUnit"] = (ProcessUnitBase unit, RecipeStep step) => PressureByPressureModeUnit_End(unit, step);
  53. //startHelper [$"{Module}.PressureByValveModeUnit"] = (ProcessUnitBase unit, RecipeStep step) => PressureByValveModeUnit_Start(unit, step);
  54. //checkerHelper [$"{Module}.PressureByValveModeUnit"] = (ProcessUnitBase unit, RecipeStep step) => PressureByValveModeUnit_Check(unit, step);
  55. //endHelper [$"{Module}.PressureByValveModeUnit"] = (ProcessUnitBase unit, RecipeStep step) => PressureByValveModeUnit_End(unit, step);
  56. startHelper[$"{Module}.TCPUnit"] = (ProcessUnitBase unit, RecipeStep step) => TCPUnit_Start(unit, step);
  57. checkerHelper[$"{Module}.TCPUnit"] = (ProcessUnitBase unit, RecipeStep step) => TCPUnit_Check(unit, step);
  58. endHelper[$"{Module}.TCPUnit"] = (ProcessUnitBase unit, RecipeStep step) => TCPUnit_End(unit, step);
  59. startHelper[$"{Module}.BiasUnit"] = (ProcessUnitBase unit, RecipeStep step) => BiasUnit_Start(unit, step);
  60. checkerHelper[$"{Module}.BiasUnit"] = (ProcessUnitBase unit, RecipeStep step) => BiasUnit_Check(unit, step);
  61. endHelper[$"{Module}.BiasUnit"] = (ProcessUnitBase unit, RecipeStep step) => BiasUnit_End(unit, step);
  62. startHelper[$"{Module}.GasControlUnit"] = (ProcessUnitBase unit, RecipeStep step) => GasControlUnit_Start(unit, step);
  63. checkerHelper[$"{Module}.GasControlUnit"] = (ProcessUnitBase unit, RecipeStep step) => GasControlUnit_Check(unit, step);
  64. endHelper[$"{Module}.GasControlUnit"] = (ProcessUnitBase unit, RecipeStep step) => GasControlUnit_End(unit, step);
  65. startHelper[$"{Module}.VenusSEGasControlUnit"] = (ProcessUnitBase unit, RecipeStep step) => VenusSEGasControlUnit_Start(unit, step);
  66. checkerHelper[$"{Module}.VenusSEGasControlUnit"] = (ProcessUnitBase unit, RecipeStep step) => VenusSEGasControlUnit_Check(unit, step);
  67. endHelper[$"{Module}.VenusSEGasControlUnit"] = (ProcessUnitBase unit, RecipeStep step) => VenusSEGasControlUnit_End(unit, step);
  68. startHelper[$"{Module}.ESCHVUnit"] = (ProcessUnitBase unit, RecipeStep step) => ESCHVUnit_Start(unit, step);
  69. checkerHelper[$"{Module}.ESCHVUnit"] = (ProcessUnitBase unit, RecipeStep step) => ESCHVUnit_Check(unit, step);
  70. endHelper[$"{Module}.ESCHVUnit"] = (ProcessUnitBase unit, RecipeStep step) => ESCHVUnit_End(unit, step);
  71. startHelper[$"{Module}.ProcessKitUnit"] = (ProcessUnitBase unit, RecipeStep step) => ProcessKitUnit_Start(unit, step);
  72. checkerHelper[$"{Module}.ProcessKitUnit"] = (ProcessUnitBase unit, RecipeStep step) => ProcessKitUnit_Check(unit, step);
  73. endHelper[$"{Module}.ProcessKitUnit"] = (ProcessUnitBase unit, RecipeStep step) => ProcessKitUnit_End(unit, step);
  74. startHelper[$"{Module}.Kepler2200GasControlUnit"] = (ProcessUnitBase unit, RecipeStep step) => Kepler2200GasControlUnit_Start(unit, step);
  75. checkerHelper[$"{Module}.Kepler2200GasControlUnit"] = (ProcessUnitBase unit, RecipeStep step) => Kepler2200GasControlUnit_Check(unit, step);
  76. endHelper[$"{Module}.Kepler2200GasControlUnit"] = (ProcessUnitBase unit, RecipeStep step) => Kepler2200GasControlUnit_End(unit, step);
  77. startHelper[$"{Module}.HeaterUnit"] = (ProcessUnitBase unit, RecipeStep step) => HeaterUnit_Start(unit, step);
  78. checkerHelper[$"{Module}.HeaterUnit"] = (ProcessUnitBase unit, RecipeStep step) => HeaterUnit_Check(unit, step);
  79. endHelper[$"{Module}.HeaterUnit"] = (ProcessUnitBase unit, RecipeStep step) => HeaterUnit_End(unit, step);
  80. startHelper[$"{Module}.RFBoxUnit"] = (ProcessUnitBase unit, RecipeStep step) => RFBoxUnit_Start(unit, step);
  81. checkerHelper[$"{Module}.RFBoxUnit"] = (ProcessUnitBase unit, RecipeStep step) => RFBoxUnit_Check(unit, step);
  82. endHelper[$"{Module}.RFBoxUnit"] = (ProcessUnitBase unit, RecipeStep step) => RFBoxUnit_End(unit, step);
  83. }
  84. private RState PressureByPressureModeUnit_Start(ProcessUnitBase unit, RecipeStep step)
  85. {
  86. var ProcessUnit = unit as PressureByPressureModeUnit;
  87. if (ProcessUnit.PressureUnitMode == PressureUnitMode.Pressure)
  88. {
  89. if (Chamber.SetPVPressure(ProcessUnit.StartValue))
  90. {
  91. return RState.Running;
  92. }
  93. }
  94. else if (ProcessUnit.PressureUnitMode == PressureUnitMode.Valve)
  95. {
  96. if (Chamber.SetPVPostion(Convert.ToInt32(ProcessUnit.StartValue)))
  97. {
  98. return RState.Running;
  99. }
  100. }
  101. return RState.Failed;
  102. }
  103. private RState PressureByPressureModeUnit_Check(ProcessUnitBase unit, RecipeStep step)
  104. {
  105. var ProcessUnit = unit as PressureByPressureModeUnit;
  106. if (ProcessUnit.EnableRamp)
  107. {
  108. if (ProcessUnit.PressureUnitMode == PressureUnitMode.Pressure)
  109. {
  110. if (Chamber.SetPVPressure(ProcessUnit.StartValue + (int)((ProcessUnit.TargetValue - ProcessUnit.StartValue) * step.RampFactor())))
  111. return RState.Running;
  112. else
  113. return RState.Failed;
  114. }
  115. else if (ProcessUnit.PressureUnitMode == PressureUnitMode.Valve)
  116. {
  117. if (Chamber.SetPVPressure(ProcessUnit.StartValue + (int)((ProcessUnit.TargetValue - ProcessUnit.StartValue) * step.RampFactor())))
  118. return RState.Running;
  119. else
  120. return RState.Failed;
  121. }
  122. }
  123. if (ProcessUnit.PressureUnitMode == PressureUnitMode.Pressure)
  124. {
  125. if (step.Type == StepType.Stable && Chamber.ChamberPressure == ProcessUnit.StartValue)
  126. {
  127. return RState.End;
  128. }
  129. }
  130. else if (ProcessUnit.PressureUnitMode == PressureUnitMode.Valve)
  131. {
  132. if (step.Type == StepType.Stable && Chamber.GetPVPosition() == ProcessUnit.StartValue)
  133. {
  134. return RState.End;
  135. }
  136. }
  137. return RState.Running;
  138. }
  139. private void PressureByPressureModeUnit_End(ProcessUnitBase unit, RecipeStep step)
  140. {
  141. }
  142. #region Valve Mode已取消,合并到压力模式
  143. //private RState PressureByValveModeUnit_Start(ProcessUnitBase unit, RecipeStep step)
  144. //{
  145. // var ProcessUnit = unit as PressureByValveModeUnit;
  146. // if (Chamber.SetPVPostion(ProcessUnit.StartPosition))
  147. // {
  148. // return RState.Running;
  149. // }
  150. // return RState.Failed;
  151. //}
  152. //private RState PressureByValveModeUnit_Check(ProcessUnitBase unit, RecipeStep step)
  153. //{
  154. // var ProcessUnit = unit as PressureByValveModeUnit;
  155. // if (ProcessUnit.EnableRamp)
  156. // {
  157. // if (Chamber.SetPVPostion(ProcessUnit.StartPosition + (int)((ProcessUnit.TargetPosition - ProcessUnit.StartPosition) * step.RampFactor())))
  158. // return RState.Running;
  159. // else
  160. // return RState.Failed;
  161. // }
  162. // return RState.Running;
  163. //}
  164. //private void PressureByValveModeUnit_End(ProcessUnitBase unit, RecipeStep step)
  165. //{
  166. //}
  167. #endregion
  168. private RState TCPUnit_Start(ProcessUnitBase unit, RecipeStep step)
  169. {
  170. _isEnableMatchC1C2Offset = SC.GetValue<bool>($"{Module}.Match.EnableC1C2StepOffset");
  171. _matchC1C2OffsetValue = SC.GetValue<int>($"{Module}.Match.C1C2StepOffsetValue");
  172. var ProcessUnit = unit as TCPUnit;
  173. List<ToleranceObject> toleranceObjects = new List<ToleranceObject>();
  174. if (ProcessUnit.ToleranceMode != ToleranceMode.None)
  175. {
  176. toleranceObjects.Add(new ToleranceObject("RF", ProcessUnit.RFPower, ProcessUnit.RFPowerWarningRange, ProcessUnit.RFPowerAlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  177. _RFToleranceChecker.Start(toleranceObjects);
  178. }
  179. int p1;
  180. int p2;
  181. if (ProcessUnit.C1 > 0)
  182. {
  183. p1 = ProcessUnit.C1;
  184. }
  185. else
  186. {
  187. p1 = ProcessUnit.AutoC1;
  188. }
  189. if (ProcessUnit.C2 > 0)
  190. {
  191. p2 = ProcessUnit.C2;
  192. }
  193. else
  194. {
  195. p2 = ProcessUnit.AutoC2;
  196. }
  197. if (_isEnableMatchC1C2Offset = false || Math.Abs(Chamber.RFMatchC1 - p1) > _matchC1C2OffsetValue || Math.Abs(Chamber.RFMatchC2 - p2) > _matchC1C2OffsetValue)
  198. {
  199. Chamber.SetMatchPosition(p1, p2);
  200. }
  201. if (ProcessUnit.RFPower > 5)
  202. {
  203. Chamber.GeneratorSetpower(ProcessUnit.RFPower);
  204. Chamber.GeneratorPowerOn(true);
  205. }
  206. else
  207. {
  208. Chamber.GeneratorSetpower(0);
  209. Chamber.GeneratorPowerOn(false);
  210. }
  211. if (ProcessUnit.MatchWorkMode == MatchWorkMode.Auto)
  212. {
  213. Chamber.SetMatchWorkMode(MatchWorkMode.Auto);
  214. }
  215. else if (ProcessUnit.MatchWorkMode == MatchWorkMode.Manual)
  216. {
  217. Chamber.SetMatchWorkMode(MatchWorkMode.Manual);
  218. }
  219. _scRFPowerAlarmTime = SC.GetValue<double>($"{Chamber.Name}.Rf.PowerAlarmTime");
  220. rfMatchC1.Clear();
  221. rfMatchC1.Clear();
  222. rfMatchC1C2Index = 0;
  223. return RState.Running;
  224. }
  225. private RState TCPUnit_Check(ProcessUnitBase unit, RecipeStep step)
  226. {
  227. var ProcessUnit = unit as TCPUnit;
  228. if (ProcessUnit.MaxReflectedPower > 0 && Chamber.ReflectPower > ProcessUnit.MaxReflectedPower && step.ElapsedTime() > _scRFPowerAlarmTime * 1000)
  229. {
  230. LOG.Write(eEvent.ERR_PROCESS, Chamber.Module, $"Step:{step.StepNo} failed, RF Reflect Power:{Chamber.ReflectPower} exceeds the Max Limit:{ProcessUnit.MaxReflectedPower}");
  231. return RState.Failed;
  232. }
  233. if (step.ElapsedTime() > m_RecipeHead.RFHoldTime * 1000)
  234. {
  235. Chamber.GeneratorSetpower(0);
  236. Chamber.GeneratorPowerOn(false);
  237. }
  238. if (step.ElapsedTime() > rfMatchC1C2Index * 1000)
  239. {
  240. rfMatchC1.Add(Chamber.RFMatchC1);
  241. rfMatchC2.Add(Chamber.RFMatchC2);
  242. rfMatchC1C2Index += 1;
  243. }
  244. if (ProcessUnit.ToleranceMode != ToleranceMode.None)
  245. {
  246. _RFToleranceChecker.Monitor(Chamber.ForwardPower);
  247. }
  248. return RState.Running;
  249. }
  250. private void TCPUnit_End(ProcessUnitBase unit, RecipeStep step)
  251. {
  252. var ProcessUnit = unit as TCPUnit;
  253. if (rfMatchC1.Count >= 6)
  254. {
  255. float allValue = 0;
  256. for (int i = 4; i < rfMatchC1.Count; i++)
  257. {
  258. allValue += rfMatchC1[i];
  259. }
  260. var average = allValue / (rfMatchC1.Count - 4);
  261. ProcessUnit.AutoC1 = (int)average;
  262. }
  263. if (rfMatchC2.Count >= 6)
  264. {
  265. float allValue = 0;
  266. for (int i = 4; i < rfMatchC2.Count; i++)
  267. {
  268. allValue += rfMatchC2[i];
  269. }
  270. var average = allValue / (rfMatchC2.Count - 4);
  271. ProcessUnit.AutoC2 = (int)average;
  272. }
  273. rfMatchC1.Clear();
  274. rfMatchC2.Clear();
  275. if (ProcessUnit.ToleranceMode != ToleranceMode.None)
  276. {
  277. _RFToleranceChecker.End();
  278. }
  279. }
  280. private RState BiasUnit_Start(ProcessUnitBase unit, RecipeStep step)
  281. {
  282. _isEnableBiasMatchC1C2Offset = SC.GetValue<bool>($"{Module}.BiasMatch.EnableC1C2StepOffset");
  283. _biasMatchC1C2OffsetValue = SC.GetValue<int>($"{Module}.BiasMatch.C1C2StepOffsetValue");
  284. var ProcessUnit = unit as BiasUnit;
  285. int p1;
  286. int p2;
  287. if (ProcessUnit.BiasC1 > 0)
  288. {
  289. p1 = ProcessUnit.BiasC1;
  290. }
  291. else
  292. {
  293. p1 = ProcessUnit.AutoBiasC1;
  294. }
  295. if (ProcessUnit.BiasC2 > 0)
  296. {
  297. p2 = ProcessUnit.BiasC2;
  298. }
  299. else
  300. {
  301. p2 = ProcessUnit.AutoBiasC2;
  302. }
  303. if (_isEnableBiasMatchC1C2Offset == false || Math.Abs(Chamber.BiasRFMatchC1 - p1) > _biasMatchC1C2OffsetValue || Math.Abs(Chamber.BiasRFMatchC2 - p2) > _biasMatchC1C2OffsetValue)
  304. {
  305. Chamber.SetBiasMatchPosition(p1, p2);
  306. }
  307. if (ProcessUnit.BiasRFPower > 5)
  308. {
  309. Chamber.GeneratorBiasPowerOn(true);
  310. if ((ProcessUnit.EnableRamp == false))
  311. {
  312. Chamber.GeneratorBiasSetpower(ProcessUnit.BiasRFPower);
  313. }
  314. }
  315. if (ProcessUnit.BiasMatchWorkMode == MatchWorkMode.Auto)
  316. {
  317. Chamber.SetBiasMatchWorkMode(MatchWorkMode.Auto);
  318. }
  319. else if (ProcessUnit.BiasMatchWorkMode == MatchWorkMode.Manual)
  320. {
  321. Chamber.SetBiasMatchWorkMode(MatchWorkMode.Manual);
  322. }
  323. if (ProcessUnit.BiasGeneratorMode == GeneratorMode.Pulsing)
  324. {
  325. Chamber.SetBiasPulseMode(true);
  326. Chamber.SetBiasPulseRateFreq(ProcessUnit.PulseRateFreq);
  327. Chamber.SetDiasPulseDutyCycle(ProcessUnit.PulseDutyCycle);
  328. }
  329. else
  330. {
  331. Chamber.SetBiasPulseMode(false);
  332. }
  333. _scBiasRFPowerAlarmTime = SC.GetValue<double>($"{Chamber.Name}.BiasRf.PowerAlarmTime");
  334. biasRfMatchC1.Clear();
  335. biasRfMatchC1.Clear();
  336. biasRfMatchC1C2Index = 0;
  337. biasRFSetPointFlag = true;
  338. return RState.Running;
  339. }
  340. private RState BiasUnit_Check(ProcessUnitBase unit, RecipeStep step)
  341. {
  342. //var _scPowerAlarmTime = SC.GetValue<double>($"{Chamber.Name}.BiasRf.PowerAlarmTime");
  343. var ProcessUnit = unit as BiasUnit;
  344. if (ProcessUnit.BiasMaxReflectedPower > 0 && Chamber.BiasReflectPower > ProcessUnit.BiasMaxReflectedPower && step.ElapsedTime() > _scBiasRFPowerAlarmTime * 1000)
  345. {
  346. LOG.Write(eEvent.ERR_PROCESS, Chamber.Module, $"Step:{step.StepNo} failed, Bias Reflect Power:{Chamber.BiasReflectPower} exceeds the Max Limit:{ProcessUnit.BiasMaxReflectedPower}");
  347. return RState.Failed;
  348. }
  349. if (step.ElapsedTime() > m_RecipeHead.BiasRFHoldTime * 1000)
  350. {
  351. Chamber.GeneratorBiasSetpower(0);
  352. Chamber.GeneratorBiasPowerOn(false);
  353. }
  354. if (step.ElapsedTime() > biasRfMatchC1C2Index * 1000)
  355. {
  356. biasRfMatchC1.Add(Chamber.BiasRFMatchC1);
  357. biasRfMatchC2.Add(Chamber.BiasRFMatchC2);
  358. biasRfMatchC1C2Index += 1;
  359. }
  360. if (ProcessUnit.EnableRamp)
  361. {
  362. //if (step.ElapsedTime() <= 500*cycleIndex)
  363. //{
  364. // return RState.Running;
  365. //}
  366. //cycleIndex += 1;
  367. if (ProcessUnit.TargetMode == TargetMode.Cycle)
  368. {
  369. if (biasRFSetPointFlag == true)
  370. {
  371. biasRFSetPointFlag = false;
  372. Chamber.GeneratorBiasSetpower((float)((ProcessUnit.BiasRFPower + (float)((float)(ProcessUnit.TargetBiasRFPower - ProcessUnit.BiasRFPower) / ((float)(loopsteps - 1) / (float)(currentStepIndex))))));
  373. }
  374. //float rampFactor = (float)currentStepIndex / (float)(loopsteps-1);
  375. //double rampFactor = step.RampFactor();
  376. //Chamber.GeneratorBiasSetpower((float)((ProcessUnit.BiasRFPower+ (ProcessUnit.TargetBiasRFPower - ProcessUnit.BiasRFPower)/(loopsteps)*currentStepIndex) + ((double)(ProcessUnit.TargetBiasRFPower - ProcessUnit.BiasRFPower) / ((double)loopsteps)) * rampFactor));
  377. }
  378. else
  379. {
  380. //double rampFactor = step.RampFactor();
  381. //Chamber.GeneratorBiasSetpower((float)(ProcessUnit.BiasRFPower + (ProcessUnit.TargetBiasRFPower - ProcessUnit.BiasRFPower) * rampFactor));
  382. }
  383. }
  384. return RState.Running;
  385. }
  386. private void BiasUnit_End(ProcessUnitBase unit, RecipeStep step)
  387. {
  388. var ProcessUnit = unit as BiasUnit;
  389. Chamber.GeneratorBiasSetpower(0);
  390. Chamber.GeneratorBiasPowerOn(false);
  391. if (biasRfMatchC1.Count >= 6)
  392. {
  393. float allValue = 0;
  394. for (int i = 4; i < biasRfMatchC1.Count; i++)
  395. {
  396. allValue += biasRfMatchC1[i];
  397. }
  398. var average = allValue / (biasRfMatchC1.Count - 4);
  399. ProcessUnit.AutoBiasC1 = (int)average;
  400. }
  401. if (biasRfMatchC2.Count >= 6)
  402. {
  403. float allValue = 0;
  404. for (int i = 4; i < biasRfMatchC2.Count; i++)
  405. {
  406. allValue += biasRfMatchC2[i];
  407. }
  408. var average = allValue / (biasRfMatchC2.Count - 4);
  409. ProcessUnit.AutoBiasC2 = (int)average;
  410. }
  411. biasRfMatchC1.Clear();
  412. biasRfMatchC1.Clear();
  413. biasRfMatchC1C2Index = 0;
  414. //cycleIndex = 0;
  415. biasRFSetPointFlag = true;
  416. }
  417. private RState GasControlUnit_Start(ProcessUnitBase unit, RecipeStep step)
  418. {
  419. List<ToleranceObject> toleranceObjects = new List<ToleranceObject>();
  420. Chamber.OpenValve(ValveType.GasFinal, true);
  421. var ProcessUnit = unit as GasControlUnit;
  422. Chamber.FlowGas(0, ProcessUnit.Gas1);
  423. if (ProcessUnit.Gas1 >= 1)
  424. {
  425. Chamber.OpenValve(ValveType.PV11, true);
  426. if (ProcessUnit.ToleranceMode != ToleranceMode.None && ProcessUnit.ToleranceDelayTime_ms > 0)
  427. {
  428. toleranceObjects.Add(new ToleranceObject("Gas1", ProcessUnit.Gas1, ProcessUnit.Gas1WarningRange, ProcessUnit.Gas1AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  429. }
  430. }
  431. Chamber.FlowGas(1, ProcessUnit.Gas2);
  432. if (ProcessUnit.Gas2 >= 1)
  433. {
  434. Chamber.OpenValve(ValveType.PV21, true);
  435. if (ProcessUnit.ToleranceMode != ToleranceMode.None && ProcessUnit.ToleranceDelayTime_ms > 0)
  436. {
  437. toleranceObjects.Add(new ToleranceObject("Gas2", ProcessUnit.Gas2, ProcessUnit.Gas2WarningRange, ProcessUnit.Gas2AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  438. }
  439. }
  440. Chamber.FlowGas(2, ProcessUnit.Gas3);
  441. if (ProcessUnit.Gas3 >= 1)
  442. {
  443. Chamber.OpenValve(ValveType.PV31, true);
  444. if (ProcessUnit.ToleranceMode != ToleranceMode.None && ProcessUnit.ToleranceDelayTime_ms > 0)
  445. {
  446. toleranceObjects.Add(new ToleranceObject("Gas3", ProcessUnit.Gas3, ProcessUnit.Gas3WarningRange, ProcessUnit.Gas3AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  447. }
  448. }
  449. Chamber.FlowGas(3, ProcessUnit.Gas4);
  450. if (ProcessUnit.Gas4 >= 1)
  451. {
  452. Chamber.OpenValve(ValveType.PV41, true);
  453. if (ProcessUnit.ToleranceMode != ToleranceMode.None && ProcessUnit.ToleranceDelayTime_ms > 0)
  454. {
  455. toleranceObjects.Add(new ToleranceObject("Gas4", ProcessUnit.Gas3, ProcessUnit.Gas3WarningRange, ProcessUnit.Gas3AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  456. }
  457. }
  458. Chamber.FlowGas(4, ProcessUnit.Gas5);
  459. Chamber.FlowGas(5, ProcessUnit.Gas6);
  460. Chamber.FlowGas(6, ProcessUnit.Gas7);
  461. Chamber.FlowGas(7, ProcessUnit.Gas8);
  462. if (ProcessUnit.Gas5 >= 1 && ProcessUnit.ToleranceMode != ToleranceMode.None && ProcessUnit.ToleranceDelayTime_ms > 0)
  463. {
  464. toleranceObjects.Add(new ToleranceObject("Gas5", ProcessUnit.Gas5, ProcessUnit.Gas5WarningRange, ProcessUnit.Gas5AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  465. }
  466. if (ProcessUnit.Gas6 >= 1 && ProcessUnit.ToleranceMode != ToleranceMode.None && ProcessUnit.ToleranceDelayTime_ms > 0)
  467. {
  468. toleranceObjects.Add(new ToleranceObject("Gas6", ProcessUnit.Gas6, ProcessUnit.Gas6WarningRange, ProcessUnit.Gas6AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  469. }
  470. if (ProcessUnit.Gas7 >= 1 && ProcessUnit.ToleranceMode != ToleranceMode.None && ProcessUnit.ToleranceDelayTime_ms > 0)
  471. {
  472. toleranceObjects.Add(new ToleranceObject("Gas7", ProcessUnit.Gas7, ProcessUnit.Gas7WarningRange, ProcessUnit.Gas7AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  473. }
  474. if (ProcessUnit.Gas8 >= 1 && ProcessUnit.ToleranceMode != ToleranceMode.None && ProcessUnit.ToleranceDelayTime_ms > 0)
  475. {
  476. toleranceObjects.Add(new ToleranceObject("Gas8", ProcessUnit.Gas8, ProcessUnit.Gas8WarningRange, ProcessUnit.Gas8AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  477. }
  478. if (ProcessUnit.ToleranceMode != ToleranceMode.None)
  479. {
  480. _GasFlowToleranceChecker.Start(toleranceObjects);
  481. }
  482. return RState.Running;
  483. }
  484. private RState GasControlUnit_Check(ProcessUnitBase unit, RecipeStep step)
  485. {
  486. var ProcessUnit = unit as GasControlUnit;
  487. if (ProcessUnit.EnableRamp)
  488. {
  489. double rampFactor = step.RampFactor();
  490. Chamber.FlowGas(0, ProcessUnit.Gas1 + (ProcessUnit.Gas1Target - ProcessUnit.Gas1) * rampFactor);
  491. Chamber.FlowGas(1, ProcessUnit.Gas2 + (ProcessUnit.Gas2Target - ProcessUnit.Gas2) * rampFactor);
  492. Chamber.FlowGas(2, ProcessUnit.Gas3 + (ProcessUnit.Gas3Target - ProcessUnit.Gas3) * rampFactor);
  493. Chamber.FlowGas(3, ProcessUnit.Gas4 + (ProcessUnit.Gas4Target - ProcessUnit.Gas4) * rampFactor);
  494. Chamber.FlowGas(4, ProcessUnit.Gas5 + (ProcessUnit.Gas5Target - ProcessUnit.Gas5) * rampFactor);
  495. Chamber.FlowGas(5, ProcessUnit.Gas6 + (ProcessUnit.Gas6Target - ProcessUnit.Gas6) * rampFactor);
  496. Chamber.FlowGas(6, ProcessUnit.Gas7 + (ProcessUnit.Gas7Target - ProcessUnit.Gas7) * rampFactor);
  497. Chamber.FlowGas(7, ProcessUnit.Gas8 + (ProcessUnit.Gas8Target - ProcessUnit.Gas8) * rampFactor);
  498. }
  499. if (ProcessUnit.ToleranceMode != ToleranceMode.None)
  500. {
  501. _GasFlowToleranceChecker.Monitor(Chamber.MFC1FeedBack, Chamber.MFC2FeedBack, Chamber.MFC3FeedBack, Chamber.MFC4FeedBack, Chamber.MFC5FeedBack, Chamber.MFC6FeedBack, Chamber.MFC7FeedBack, Chamber.MFC8FeedBack);
  502. }
  503. return RState.Running;
  504. }
  505. private void GasControlUnit_End(ProcessUnitBase unit, RecipeStep step)
  506. {
  507. Chamber.FlowGas(0, 0);
  508. Chamber.FlowGas(1, 0);
  509. Chamber.FlowGas(2, 0);
  510. Chamber.FlowGas(3, 0);
  511. Chamber.FlowGas(4, 0);
  512. Chamber.FlowGas(5, 0);
  513. Chamber.FlowGas(6, 0);
  514. Chamber.FlowGas(7, 0);
  515. var ProcessUnit = unit as GasControlUnit;
  516. if (ProcessUnit.ToleranceMode != ToleranceMode.None)
  517. {
  518. _GasFlowToleranceChecker.End();
  519. }
  520. }
  521. private RState Kepler2200GasControlUnit_Start(ProcessUnitBase unit, RecipeStep step)
  522. {
  523. List<ToleranceObject> toleranceObjects = new List<ToleranceObject>();
  524. Chamber.OpenValve(ValveType.GasFinal, true);
  525. var ProcessUnit = unit as Kepler2200GasControlUnit;
  526. Chamber.FlowGas(0, ProcessUnit.Gas1);
  527. if (ProcessUnit.Gas1 >= 1)
  528. {
  529. Chamber.OpenValve(ValveType.PV11, true);
  530. if (ProcessUnit.ToleranceMode != ToleranceMode.None)
  531. {
  532. toleranceObjects.Add(new ToleranceObject("Gas1", ProcessUnit.Gas1, ProcessUnit.Gas1WarningRange, ProcessUnit.Gas1AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  533. }
  534. }
  535. Chamber.FlowGas(1, ProcessUnit.Gas2);
  536. if (ProcessUnit.Gas2 >= 1)
  537. {
  538. Chamber.OpenValve(ValveType.PV21, true);
  539. if (ProcessUnit.ToleranceMode != ToleranceMode.None)
  540. {
  541. toleranceObjects.Add(new ToleranceObject("Gas2", ProcessUnit.Gas2, ProcessUnit.Gas2WarningRange, ProcessUnit.Gas2AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  542. }
  543. }
  544. Chamber.FlowGas(2, ProcessUnit.Gas3);
  545. if (ProcessUnit.Gas3 >= 1)
  546. {
  547. Chamber.OpenValve(ValveType.PV31, true);
  548. if (ProcessUnit.ToleranceMode != ToleranceMode.None)
  549. {
  550. toleranceObjects.Add(new ToleranceObject("Gas3", ProcessUnit.Gas3, ProcessUnit.Gas3WarningRange, ProcessUnit.Gas3AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  551. }
  552. }
  553. Chamber.FlowGas(3, ProcessUnit.Gas4);
  554. if (ProcessUnit.Gas4 >= 1)
  555. {
  556. Chamber.OpenValve(ValveType.PV41, true);
  557. if (ProcessUnit.ToleranceMode != ToleranceMode.None)
  558. {
  559. toleranceObjects.Add(new ToleranceObject("Gas4", ProcessUnit.Gas4, ProcessUnit.Gas4WarningRange, ProcessUnit.Gas4AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  560. }
  561. }
  562. Chamber.FlowGas(4, ProcessUnit.Gas5);
  563. Chamber.FlowGas(5, ProcessUnit.Gas6);
  564. if (ProcessUnit.Gas5 >= 1 && ProcessUnit.ToleranceMode != ToleranceMode.None && ProcessUnit.ToleranceDelayTime_ms > 0)
  565. {
  566. toleranceObjects.Add(new ToleranceObject("Gas5", ProcessUnit.Gas5, ProcessUnit.Gas5WarningRange, ProcessUnit.Gas5AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  567. }
  568. if (ProcessUnit.Gas6 >= 1 && ProcessUnit.ToleranceMode != ToleranceMode.None && ProcessUnit.ToleranceDelayTime_ms > 0)
  569. {
  570. toleranceObjects.Add(new ToleranceObject("Gas6", ProcessUnit.Gas6, ProcessUnit.Gas6WarningRange, ProcessUnit.Gas6AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  571. }
  572. return RState.Running;
  573. }
  574. private RState Kepler2200GasControlUnit_Check(ProcessUnitBase unit, RecipeStep step)
  575. {
  576. var ProcessUnit = unit as Kepler2200GasControlUnit;
  577. if (ProcessUnit.ToleranceMode != ToleranceMode.None)
  578. {
  579. _GasFlowToleranceChecker.Monitor(Chamber.MFC1FeedBack, Chamber.MFC2FeedBack, Chamber.MFC3FeedBack, Chamber.MFC4FeedBack, Chamber.MFC5FeedBack, Chamber.MFC6FeedBack);
  580. }
  581. return RState.Running;
  582. }
  583. private void Kepler2200GasControlUnit_End(ProcessUnitBase unit, RecipeStep step)
  584. {
  585. Chamber.FlowGas(0, 0);
  586. Chamber.FlowGas(1, 0);
  587. Chamber.FlowGas(2, 0);
  588. Chamber.FlowGas(3, 0);
  589. Chamber.FlowGas(4, 0);
  590. Chamber.FlowGas(5, 0);
  591. var ProcessUnit = unit as Kepler2200GasControlUnit;
  592. if (ProcessUnit.ToleranceMode != ToleranceMode.None)
  593. {
  594. _GasFlowToleranceChecker.End();
  595. }
  596. }
  597. private RState VenusSEGasControlUnit_Start(ProcessUnitBase unit, RecipeStep step)
  598. {
  599. Chamber.OpenValve(ValveType.GasFinal, true);
  600. var ProcessUnit = unit as VenusSEGasControlUnit;
  601. Chamber.FlowGas(0, ProcessUnit.Gas1);
  602. if (ProcessUnit.Gas1 >= 1)
  603. {
  604. Chamber.OpenValve(ValveType.PV11, true);
  605. }
  606. Chamber.FlowGas(1, ProcessUnit.Gas2);
  607. if (ProcessUnit.Gas2 >= 1)
  608. {
  609. Chamber.OpenValve(ValveType.PV21, true);
  610. }
  611. Chamber.FlowGas(2, ProcessUnit.Gas3);
  612. if (ProcessUnit.Gas3 >= 1)
  613. {
  614. Chamber.OpenValve(ValveType.PV31, true);
  615. }
  616. Chamber.FlowGas(3, ProcessUnit.Gas4);
  617. if (ProcessUnit.Gas4 >= 1)
  618. {
  619. Chamber.OpenValve(ValveType.PV41, true);
  620. }
  621. Chamber.FlowGas(4, ProcessUnit.Gas5);
  622. if (ProcessUnit.Gas5 >= 1)
  623. {
  624. Chamber.OpenValve(ValveType.PV51, true);
  625. }
  626. Chamber.FlowGas(5, ProcessUnit.Gas6);
  627. if (ProcessUnit.Gas6 >= 1)
  628. {
  629. Chamber.OpenValve(ValveType.PV61, true);
  630. }
  631. Chamber.FlowGas(6, ProcessUnit.Gas7);
  632. if (ProcessUnit.Gas7 >= 1)
  633. {
  634. Chamber.OpenValve(ValveType.PV71, true);
  635. }
  636. Chamber.FlowGas(7, ProcessUnit.Gas8);
  637. if (ProcessUnit.Gas8 >= 1)
  638. {
  639. Chamber.OpenValve(ValveType.PV81, true);
  640. }
  641. Chamber.FlowGas(8, ProcessUnit.Gas9);
  642. if (ProcessUnit.Gas9 >= 1)
  643. {
  644. Chamber.OpenValve(ValveType.PV91, true);
  645. }
  646. Chamber.FlowGas(9, ProcessUnit.Gas10);
  647. if (ProcessUnit.Gas10 >= 1)
  648. {
  649. Chamber.OpenValve(ValveType.PVA1, true);
  650. }
  651. Chamber.FlowGas(10, ProcessUnit.Gas11);
  652. if (ProcessUnit.Gas11 >= 1)
  653. {
  654. Chamber.OpenValve(ValveType.PVB1, true);
  655. }
  656. Chamber.FlowGas(11, ProcessUnit.Gas12);
  657. if (ProcessUnit.Gas12 >= 1)
  658. {
  659. Chamber.OpenValve(ValveType.PVC1, true);
  660. }
  661. return RState.Running;
  662. }
  663. private RState VenusSEGasControlUnit_Check(ProcessUnitBase unit, RecipeStep step)
  664. {
  665. return RState.Running;
  666. }
  667. private void VenusSEGasControlUnit_End(ProcessUnitBase unit, RecipeStep step)
  668. {
  669. Chamber.FlowGas(0, 0);
  670. Chamber.FlowGas(1, 0);
  671. Chamber.FlowGas(2, 0);
  672. Chamber.FlowGas(3, 0);
  673. Chamber.FlowGas(4, 0);
  674. Chamber.FlowGas(5, 0);
  675. Chamber.FlowGas(6, 0);
  676. Chamber.FlowGas(7, 0);
  677. Chamber.FlowGas(8, 0);
  678. Chamber.FlowGas(9, 0);
  679. Chamber.FlowGas(10, 0);
  680. Chamber.FlowGas(11, 0);
  681. Chamber.FlowGas(12, 0);
  682. }
  683. private RState ESCHVUnit_Start(ProcessUnitBase unit, RecipeStep step)
  684. {
  685. var ProcessUnit = unit as ESCHVUnit;
  686. Chamber.SetESCClampVoltage(ProcessUnit.ESCClampValtage);
  687. Chamber.SetBacksideHePressure(ProcessUnit.BacksideHelum);
  688. Chamber.SetBacksideHeThreshold(ProcessUnit.MinHeFlow, ProcessUnit.MaxHeFlow);
  689. return RState.Running;
  690. }
  691. private RState ESCHVUnit_Check(ProcessUnitBase unit, RecipeStep step)
  692. {
  693. if (Chamber.BackSideHeOutOfRange)
  694. {
  695. LOG.Write(eEvent.ERR_PROCESS, Chamber.Module, $"Step:{step.StepNo} failed, Backside Helium out of range.");
  696. return RState.Failed;
  697. }
  698. return RState.Running;
  699. }
  700. private void ESCHVUnit_End(ProcessUnitBase unit, RecipeStep step)
  701. {
  702. Chamber.SetESCClampVoltage(0);
  703. //Chamber.SetBacksideHePressure(0);
  704. Chamber.SetBacksideHeThreshold(0, 0);
  705. //Chamber.OnOffSetESCHV(false);
  706. }
  707. private RState ProcessKitUnit_Start(ProcessUnitBase unit, RecipeStep step)
  708. {
  709. var ProcessUnit = unit as ProcessKitUnit;
  710. if (Chamber.SetLiftPin(ProcessUnit.LiftPinPostion, out string reason))
  711. {
  712. return RState.Running;
  713. }
  714. else
  715. {
  716. LOG.Write(eEvent.ERR_PROCESS, Chamber.Module, $"Step:{step.StepNo} failed. Target Position:{ProcessUnit.LiftPinPostion}");
  717. return RState.Failed;
  718. }
  719. }
  720. private RState ProcessKitUnit_Check(ProcessUnitBase unit, RecipeStep step)
  721. {
  722. var ProcessUnit = unit as ProcessKitUnit;
  723. return RState.Running;
  724. }
  725. private void ProcessKitUnit_End(ProcessUnitBase unit, RecipeStep step)
  726. {
  727. }
  728. private RState HeaterUnit_Start(ProcessUnitBase unit, RecipeStep step)
  729. {
  730. var ProcessUnit = unit as HeaterUnit;
  731. var position = (HighTemperatureHeaterPosition)Enum.Parse(typeof(HighTemperatureHeaterPosition), ProcessUnit.SuspectPosition.ToString());
  732. Chamber.HighTemperatureHeaterGotoPosition(position);
  733. Chamber.SetHighTemperatureHeaterTemperature(ProcessUnit.HeaterTemp);
  734. Chamber.SetHighTemperatureHeaterRatio(ProcessUnit.HeaterRatio);
  735. return RState.Running;
  736. }
  737. private RState HeaterUnit_Check(ProcessUnitBase unit, RecipeStep step)
  738. {
  739. return RState.Running;
  740. }
  741. private void HeaterUnit_End(ProcessUnitBase unit, RecipeStep step)
  742. {
  743. }
  744. private RState RFBoxUnit_Start(ProcessUnitBase unit, RecipeStep step)
  745. {
  746. return RState.Running;
  747. }
  748. private RState RFBoxUnit_Check(ProcessUnitBase unit, RecipeStep step)
  749. {
  750. return RState.Running;
  751. }
  752. private void RFBoxUnit_End(ProcessUnitBase unit, RecipeStep step)
  753. {
  754. }
  755. public bool LoadMethods(ProcessUnitBase unit)
  756. {
  757. var className = $"{Module}.{unit.GetType().Name}";
  758. if (startHelper.ContainsKey(className) && checkerHelper.ContainsKey(className) && endHelper.ContainsKey(className))
  759. {
  760. unit.starter = startHelper[className];
  761. unit.checker = checkerHelper[className];
  762. unit.end = endHelper[className];
  763. return true;
  764. }
  765. return false;
  766. }
  767. //public void loopStep(bool isloop,int loopCount,int loopIndex)
  768. //{
  769. // isLoop = isloop;
  770. // loopsteps=loopCount;
  771. // currentStepIndex = loopIndex;
  772. //}
  773. private RState stepStarter(RecipeStep step)
  774. {
  775. step.StartStepTimer();
  776. switch (step.Type)
  777. {
  778. case StepType.EndPoint:
  779. Chamber.EPDStepStart(step.EPDConfig, step.StepNo);
  780. break;
  781. }
  782. return RState.Running;
  783. }
  784. private RState stepChecker(RecipeStep step)
  785. {
  786. switch (step.Type)
  787. {
  788. case StepType.Time:
  789. return step.ElapsedTime() >= step.Time * 1000 ? RState.End : RState.Running;
  790. case StepType.OverEtch:
  791. return step.ElapsedTime() >= (step.GetLastEPDStepTime() * step.OverEtchPercent / 100) ? RState.End : RState.Running;
  792. case StepType.EndPoint:
  793. if (step.ElapsedTime() > step.MaxEndPointTime * 1000)
  794. {
  795. LOG.Write(eEvent.INFO_PROCESS, Chamber.Module, $"Step:{step.StepNo} timeout, did not capture endpoint signal in {step.MaxEndPointTime} seconds");
  796. return RState.End;
  797. }
  798. else
  799. {
  800. return Chamber.EPDCaptured ? RState.End : RState.Running;
  801. }
  802. }
  803. return RState.Running;
  804. }
  805. private RState stepEnder(RecipeStep step)
  806. {
  807. if (step.Type == StepType.EndPoint)
  808. {
  809. Chamber.EPDStepStop();
  810. }
  811. return RState.End;
  812. }
  813. public bool LoadStepFuns(RecipeStep step)
  814. {
  815. step.starter = stepStarter;
  816. step.checker = stepChecker;
  817. step.ender = stepEnder;
  818. return true;
  819. }
  820. }
  821. }