ProcessDefine.cs 39 KB

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