ProcessDefine.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971
  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. float p1;
  180. float 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. float p1;
  286. float 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. else
  316. {
  317. Chamber.GeneratorBiasPowerOn(false);
  318. Chamber.GeneratorBiasSetpower(0);
  319. }
  320. if (ProcessUnit.BiasMatchWorkMode == MatchWorkMode.Auto)
  321. {
  322. Chamber.SetBiasMatchWorkMode(MatchWorkMode.Auto);
  323. }
  324. else if (ProcessUnit.BiasMatchWorkMode == MatchWorkMode.Manual)
  325. {
  326. Chamber.SetBiasMatchWorkMode(MatchWorkMode.Manual);
  327. }
  328. if (ProcessUnit.BiasGeneratorMode == GeneratorMode.Pulsing)
  329. {
  330. Chamber.SetBiasPulseMode(true);
  331. Chamber.SetBiasPulseRateFreq(ProcessUnit.PulseRateFreq);
  332. Chamber.SetDiasPulseDutyCycle(ProcessUnit.PulseDutyCycle);
  333. }
  334. else
  335. {
  336. Chamber.SetBiasPulseMode(false);
  337. }
  338. _scBiasRFPowerAlarmTime = SC.GetValue<double>($"{Chamber.Name}.BiasRf.PowerAlarmTime");
  339. biasRfMatchC1.Clear();
  340. biasRfMatchC1.Clear();
  341. biasRfMatchC1C2Index = 0;
  342. biasRFSetPointFlag = true;
  343. return RState.Running;
  344. }
  345. private RState BiasUnit_Check(ProcessUnitBase unit, RecipeStep step)
  346. {
  347. //var _scPowerAlarmTime = SC.GetValue<double>($"{Chamber.Name}.BiasRf.PowerAlarmTime");
  348. var ProcessUnit = unit as BiasUnit;
  349. if (ProcessUnit.BiasMaxReflectedPower > 0 && Chamber.BiasReflectPower > ProcessUnit.BiasMaxReflectedPower && step.ElapsedTime() > _scBiasRFPowerAlarmTime * 1000)
  350. {
  351. LOG.Write(eEvent.ERR_PROCESS, Chamber.Module, $"Step:{step.StepNo} failed, Bias Reflect Power:{Chamber.BiasReflectPower} exceeds the Max Limit:{ProcessUnit.BiasMaxReflectedPower}");
  352. return RState.Failed;
  353. }
  354. if (step.ElapsedTime() > m_RecipeHead.BiasRFHoldTime * 1000)
  355. {
  356. Chamber.GeneratorBiasSetpower(0);
  357. Chamber.GeneratorBiasPowerOn(false);
  358. }
  359. if (step.ElapsedTime() > biasRfMatchC1C2Index * 1000)
  360. {
  361. biasRfMatchC1.Add(Chamber.BiasRFMatchC1);
  362. biasRfMatchC2.Add(Chamber.BiasRFMatchC2);
  363. biasRfMatchC1C2Index += 1;
  364. }
  365. if (ProcessUnit.EnableRamp)
  366. {
  367. //if (step.ElapsedTime() <= 500*cycleIndex)
  368. //{
  369. // return RState.Running;
  370. //}
  371. //cycleIndex += 1;
  372. if (ProcessUnit.TargetMode == TargetMode.Cycle)
  373. {
  374. if (biasRFSetPointFlag == true)
  375. {
  376. biasRFSetPointFlag = false;
  377. Chamber.GeneratorBiasSetpower((float)((ProcessUnit.BiasRFPower + (float)((float)(ProcessUnit.TargetBiasRFPower - ProcessUnit.BiasRFPower) / ((float)(loopsteps - 1) / (float)(currentStepIndex))))));
  378. }
  379. //float rampFactor = (float)currentStepIndex / (float)(loopsteps-1);
  380. //double rampFactor = step.RampFactor();
  381. //Chamber.GeneratorBiasSetpower((float)((ProcessUnit.BiasRFPower+ (ProcessUnit.TargetBiasRFPower - ProcessUnit.BiasRFPower)/(loopsteps)*currentStepIndex) + ((double)(ProcessUnit.TargetBiasRFPower - ProcessUnit.BiasRFPower) / ((double)loopsteps)) * rampFactor));
  382. }
  383. else
  384. {
  385. //double rampFactor = step.RampFactor();
  386. //Chamber.GeneratorBiasSetpower((float)(ProcessUnit.BiasRFPower + (ProcessUnit.TargetBiasRFPower - ProcessUnit.BiasRFPower) * rampFactor));
  387. }
  388. }
  389. return RState.Running;
  390. }
  391. private void BiasUnit_End(ProcessUnitBase unit, RecipeStep step)
  392. {
  393. var ProcessUnit = unit as BiasUnit;
  394. //Chamber.GeneratorBiasSetpower(0);
  395. //Chamber.GeneratorBiasPowerOn(false);
  396. if (biasRfMatchC1.Count >= 6)
  397. {
  398. float allValue = 0;
  399. for (int i = 4; i < biasRfMatchC1.Count; i++)
  400. {
  401. allValue += biasRfMatchC1[i];
  402. }
  403. var average = allValue / (biasRfMatchC1.Count - 4);
  404. ProcessUnit.AutoBiasC1 = (int)average;
  405. }
  406. if (biasRfMatchC2.Count >= 6)
  407. {
  408. float allValue = 0;
  409. for (int i = 4; i < biasRfMatchC2.Count; i++)
  410. {
  411. allValue += biasRfMatchC2[i];
  412. }
  413. var average = allValue / (biasRfMatchC2.Count - 4);
  414. ProcessUnit.AutoBiasC2 = (int)average;
  415. }
  416. biasRfMatchC1.Clear();
  417. biasRfMatchC1.Clear();
  418. biasRfMatchC1C2Index = 0;
  419. //cycleIndex = 0;
  420. biasRFSetPointFlag = true;
  421. }
  422. private RState GasControlUnit_Start(ProcessUnitBase unit, RecipeStep step)
  423. {
  424. List<ToleranceObject> toleranceObjects = new List<ToleranceObject>();
  425. Chamber.OpenValve(ValveType.GasFinal, true);
  426. var ProcessUnit = unit as GasControlUnit;
  427. if (ProcessUnit.Gas1 >= 1)
  428. {
  429. Chamber.FlowGas(0, ProcessUnit.Gas1);
  430. }
  431. else
  432. {
  433. Chamber.FlowGas(0, 0);
  434. }
  435. if (ProcessUnit.Gas2 >= 1)
  436. {
  437. Chamber.FlowGas(1, ProcessUnit.Gas2);
  438. }
  439. else
  440. {
  441. Chamber.FlowGas(1, 0);
  442. }
  443. if (ProcessUnit.Gas3 >= 1)
  444. {
  445. Chamber.FlowGas(2, ProcessUnit.Gas3);
  446. }
  447. else
  448. {
  449. Chamber.FlowGas(2, 0);
  450. }
  451. if (ProcessUnit.Gas4 >= 1)
  452. {
  453. Chamber.FlowGas(3, ProcessUnit.Gas4);
  454. }
  455. else
  456. {
  457. Chamber.FlowGas(3, 0);
  458. }
  459. if (ProcessUnit.Gas5 >= 1)
  460. {
  461. Chamber.FlowGas(4, ProcessUnit.Gas5);
  462. }
  463. else
  464. {
  465. Chamber.FlowGas(4, 0);
  466. }
  467. if (ProcessUnit.Gas6 >= 1)
  468. {
  469. Chamber.FlowGas(5, ProcessUnit.Gas6);
  470. }
  471. else
  472. {
  473. Chamber.FlowGas(5, 0);
  474. }
  475. if (ProcessUnit.Gas7 >= 1)
  476. {
  477. Chamber.FlowGas(6, ProcessUnit.Gas7);
  478. }
  479. else
  480. {
  481. Chamber.FlowGas(6, 0);
  482. }
  483. if (ProcessUnit.Gas8 >= 1)
  484. {
  485. Chamber.FlowGas(7, ProcessUnit.Gas8);
  486. }
  487. else
  488. {
  489. Chamber.FlowGas(7, 0);
  490. }
  491. if (ProcessUnit.ToleranceMode != ToleranceMode.None)
  492. {
  493. toleranceObjects.Add(new ToleranceObject("Gas1", ProcessUnit.Gas1, ProcessUnit.Gas1WarningRange, ProcessUnit.Gas1AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  494. toleranceObjects.Add(new ToleranceObject("Gas2", ProcessUnit.Gas2, ProcessUnit.Gas2WarningRange, ProcessUnit.Gas2AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  495. toleranceObjects.Add(new ToleranceObject("Gas3", ProcessUnit.Gas3, ProcessUnit.Gas3WarningRange, ProcessUnit.Gas3AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  496. toleranceObjects.Add(new ToleranceObject("Gas4", ProcessUnit.Gas4, ProcessUnit.Gas4WarningRange, ProcessUnit.Gas4AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  497. toleranceObjects.Add(new ToleranceObject("Gas5", ProcessUnit.Gas5, ProcessUnit.Gas5WarningRange, ProcessUnit.Gas5AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  498. toleranceObjects.Add(new ToleranceObject("Gas6", ProcessUnit.Gas6, ProcessUnit.Gas6WarningRange, ProcessUnit.Gas6AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  499. toleranceObjects.Add(new ToleranceObject("Gas7", ProcessUnit.Gas7, ProcessUnit.Gas7WarningRange, ProcessUnit.Gas7AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  500. toleranceObjects.Add(new ToleranceObject("Gas8", ProcessUnit.Gas8, ProcessUnit.Gas8WarningRange, ProcessUnit.Gas8AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  501. }
  502. if (ProcessUnit.ToleranceMode != ToleranceMode.None)
  503. {
  504. _GasFlowToleranceChecker.Start(toleranceObjects);
  505. }
  506. return RState.Running;
  507. }
  508. private RState GasControlUnit_Check(ProcessUnitBase unit, RecipeStep step)
  509. {
  510. var ProcessUnit = unit as GasControlUnit;
  511. if (ProcessUnit.EnableRamp)
  512. {
  513. double rampFactor = step.RampFactor();
  514. Chamber.FlowGas(0, ProcessUnit.Gas1 + (ProcessUnit.Gas1Target - ProcessUnit.Gas1) * rampFactor);
  515. Chamber.FlowGas(1, ProcessUnit.Gas2 + (ProcessUnit.Gas2Target - ProcessUnit.Gas2) * rampFactor);
  516. Chamber.FlowGas(2, ProcessUnit.Gas3 + (ProcessUnit.Gas3Target - ProcessUnit.Gas3) * rampFactor);
  517. Chamber.FlowGas(3, ProcessUnit.Gas4 + (ProcessUnit.Gas4Target - ProcessUnit.Gas4) * rampFactor);
  518. Chamber.FlowGas(4, ProcessUnit.Gas5 + (ProcessUnit.Gas5Target - ProcessUnit.Gas5) * rampFactor);
  519. Chamber.FlowGas(5, ProcessUnit.Gas6 + (ProcessUnit.Gas6Target - ProcessUnit.Gas6) * rampFactor);
  520. Chamber.FlowGas(6, ProcessUnit.Gas7 + (ProcessUnit.Gas7Target - ProcessUnit.Gas7) * rampFactor);
  521. Chamber.FlowGas(7, ProcessUnit.Gas8 + (ProcessUnit.Gas8Target - ProcessUnit.Gas8) * rampFactor);
  522. }
  523. if (ProcessUnit.ToleranceMode != ToleranceMode.None)
  524. {
  525. _GasFlowToleranceChecker.Monitor(Chamber.MFC1FeedBack, Chamber.MFC2FeedBack, Chamber.MFC3FeedBack, Chamber.MFC4FeedBack, Chamber.MFC5FeedBack, Chamber.MFC6FeedBack, Chamber.MFC7FeedBack, Chamber.MFC8FeedBack);
  526. }
  527. return RState.Running;
  528. }
  529. private void GasControlUnit_End(ProcessUnitBase unit, RecipeStep step)
  530. {
  531. var ProcessUnit = unit as GasControlUnit;
  532. if (ProcessUnit.ToleranceMode != ToleranceMode.None)
  533. {
  534. _GasFlowToleranceChecker.End();
  535. }
  536. }
  537. private RState Kepler2200GasControlUnit_Start(ProcessUnitBase unit, RecipeStep step)
  538. {
  539. List<ToleranceObject> toleranceObjects = new List<ToleranceObject>();
  540. Chamber.OpenValve(ValveType.GasFinal, true);
  541. var ProcessUnit = unit as Kepler2200GasControlUnit;
  542. if (ProcessUnit.Gas1 >= 1)
  543. {
  544. Chamber.FlowGas(0, ProcessUnit.Gas1);
  545. }
  546. else
  547. {
  548. Chamber.FlowGas(0, 0);
  549. }
  550. if (ProcessUnit.Gas2 >= 1)
  551. {
  552. Chamber.FlowGas(1, ProcessUnit.Gas2);
  553. }
  554. else
  555. {
  556. Chamber.FlowGas(1, 0);
  557. }
  558. if (ProcessUnit.Gas3 >= 1)
  559. {
  560. Chamber.FlowGas(2, ProcessUnit.Gas3);
  561. }
  562. else
  563. {
  564. Chamber.FlowGas(2, 0);
  565. }
  566. if (ProcessUnit.Gas4 >= 1)
  567. {
  568. Chamber.FlowGas(3, ProcessUnit.Gas4);
  569. }
  570. else
  571. {
  572. Chamber.FlowGas(3, 0);
  573. }
  574. if (ProcessUnit.Gas5 >= 1)
  575. {
  576. Chamber.FlowGas(4, ProcessUnit.Gas5);
  577. }
  578. else
  579. {
  580. Chamber.FlowGas(4, 0);
  581. }
  582. if (ProcessUnit.Gas6 >= 1)
  583. {
  584. Chamber.FlowGas(5, ProcessUnit.Gas6);
  585. }
  586. else
  587. {
  588. Chamber.FlowGas(5, 0);
  589. }
  590. if (ProcessUnit.ToleranceMode != ToleranceMode.None)
  591. {
  592. toleranceObjects.Add(new ToleranceObject("Gas1", ProcessUnit.Gas1, ProcessUnit.Gas1WarningRange, ProcessUnit.Gas1AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  593. toleranceObjects.Add(new ToleranceObject("Gas2", ProcessUnit.Gas2, ProcessUnit.Gas2WarningRange, ProcessUnit.Gas2AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  594. toleranceObjects.Add(new ToleranceObject("Gas3", ProcessUnit.Gas3, ProcessUnit.Gas3WarningRange, ProcessUnit.Gas3AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  595. toleranceObjects.Add(new ToleranceObject("Gas4", ProcessUnit.Gas4, ProcessUnit.Gas4WarningRange, ProcessUnit.Gas4AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  596. toleranceObjects.Add(new ToleranceObject("Gas5", ProcessUnit.Gas5, ProcessUnit.Gas5WarningRange, ProcessUnit.Gas5AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  597. toleranceObjects.Add(new ToleranceObject("Gas6", ProcessUnit.Gas6, ProcessUnit.Gas6WarningRange, ProcessUnit.Gas6AlarmRange, ProcessUnit.ToleranceDelayTime_ms, ProcessUnit.ToleranceMode));
  598. }
  599. if (ProcessUnit.ToleranceMode != ToleranceMode.None)
  600. {
  601. _GasFlowToleranceChecker.Start(toleranceObjects);
  602. }
  603. return RState.Running;
  604. }
  605. private RState Kepler2200GasControlUnit_Check(ProcessUnitBase unit, RecipeStep step)
  606. {
  607. var ProcessUnit = unit as Kepler2200GasControlUnit;
  608. if (ProcessUnit.ToleranceMode != ToleranceMode.None)
  609. {
  610. _GasFlowToleranceChecker.Monitor(Chamber.MFC1FeedBack, Chamber.MFC2FeedBack, Chamber.MFC3FeedBack, Chamber.MFC4FeedBack, Chamber.MFC5FeedBack, Chamber.MFC6FeedBack);
  611. }
  612. return RState.Running;
  613. }
  614. private void Kepler2200GasControlUnit_End(ProcessUnitBase unit, RecipeStep step)
  615. {
  616. var ProcessUnit = unit as Kepler2200GasControlUnit;
  617. if (ProcessUnit.ToleranceMode != ToleranceMode.None)
  618. {
  619. _GasFlowToleranceChecker.End();
  620. }
  621. }
  622. private RState VenusSEGasControlUnit_Start(ProcessUnitBase unit, RecipeStep step)
  623. {
  624. Chamber.OpenValve(ValveType.GasFinal, true);
  625. var ProcessUnit = unit as VenusSEGasControlUnit;
  626. Chamber.FlowGas(0, ProcessUnit.Gas1);
  627. if (ProcessUnit.Gas1 >= 1)
  628. {
  629. Chamber.OpenValve(ValveType.PV11, true);
  630. }
  631. Chamber.FlowGas(1, ProcessUnit.Gas2);
  632. if (ProcessUnit.Gas2 >= 1)
  633. {
  634. Chamber.OpenValve(ValveType.PV21, true);
  635. }
  636. Chamber.FlowGas(2, ProcessUnit.Gas3);
  637. if (ProcessUnit.Gas3 >= 1)
  638. {
  639. Chamber.OpenValve(ValveType.PV31, true);
  640. }
  641. Chamber.FlowGas(3, ProcessUnit.Gas4);
  642. if (ProcessUnit.Gas4 >= 1)
  643. {
  644. Chamber.OpenValve(ValveType.PV41, true);
  645. }
  646. Chamber.FlowGas(4, ProcessUnit.Gas5);
  647. if (ProcessUnit.Gas5 >= 1)
  648. {
  649. Chamber.OpenValve(ValveType.PV51, true);
  650. }
  651. Chamber.FlowGas(5, ProcessUnit.Gas6);
  652. if (ProcessUnit.Gas6 >= 1)
  653. {
  654. Chamber.OpenValve(ValveType.PV61, true);
  655. }
  656. Chamber.FlowGas(6, ProcessUnit.Gas7);
  657. if (ProcessUnit.Gas7 >= 1)
  658. {
  659. Chamber.OpenValve(ValveType.PV71, true);
  660. }
  661. Chamber.FlowGas(7, ProcessUnit.Gas8);
  662. if (ProcessUnit.Gas8 >= 1)
  663. {
  664. Chamber.OpenValve(ValveType.PV81, true);
  665. }
  666. Chamber.FlowGas(8, ProcessUnit.Gas9);
  667. if (ProcessUnit.Gas9 >= 1)
  668. {
  669. Chamber.OpenValve(ValveType.PV91, true);
  670. }
  671. Chamber.FlowGas(9, ProcessUnit.Gas10);
  672. if (ProcessUnit.Gas10 >= 1)
  673. {
  674. Chamber.OpenValve(ValveType.PVA1, true);
  675. }
  676. Chamber.FlowGas(10, ProcessUnit.Gas11);
  677. if (ProcessUnit.Gas11 >= 1)
  678. {
  679. Chamber.OpenValve(ValveType.PVB1, true);
  680. }
  681. Chamber.FlowGas(11, ProcessUnit.Gas12);
  682. if (ProcessUnit.Gas12 >= 1)
  683. {
  684. Chamber.OpenValve(ValveType.PVC1, true);
  685. }
  686. return RState.Running;
  687. }
  688. private RState VenusSEGasControlUnit_Check(ProcessUnitBase unit, RecipeStep step)
  689. {
  690. return RState.Running;
  691. }
  692. private void VenusSEGasControlUnit_End(ProcessUnitBase unit, RecipeStep step)
  693. {
  694. Chamber.FlowGas(0, 0);
  695. Chamber.FlowGas(1, 0);
  696. Chamber.FlowGas(2, 0);
  697. Chamber.FlowGas(3, 0);
  698. Chamber.FlowGas(4, 0);
  699. Chamber.FlowGas(5, 0);
  700. Chamber.FlowGas(6, 0);
  701. Chamber.FlowGas(7, 0);
  702. Chamber.FlowGas(8, 0);
  703. Chamber.FlowGas(9, 0);
  704. Chamber.FlowGas(10, 0);
  705. Chamber.FlowGas(11, 0);
  706. Chamber.FlowGas(12, 0);
  707. }
  708. private RState ESCHVUnit_Start(ProcessUnitBase unit, RecipeStep step)
  709. {
  710. var ProcessUnit = unit as ESCHVUnit;
  711. Chamber.SetESCClampVoltage(ProcessUnit.ESCClampValtage);
  712. Chamber.SetBacksideHePressure(ProcessUnit.BacksideHelum);
  713. Chamber.SetBacksideHeThreshold(ProcessUnit.MinHeFlow, ProcessUnit.MaxHeFlow);
  714. return RState.Running;
  715. }
  716. private RState ESCHVUnit_Check(ProcessUnitBase unit, RecipeStep step)
  717. {
  718. var ProcessUnit = unit as ESCHVUnit;
  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. }