ProcessDefine.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. using System;
  2. using System.Collections.Generic;
  3. //using System.
  4. using Venus_RT.Devices;
  5. using Venus_RT.Modules;
  6. using Aitex.Core.RT.Log;
  7. using Venus_Core;
  8. using Aitex.Core.RT.SCCore;
  9. using System.Reflection;
  10. using System.Diagnostics;
  11. //#pragma warning disable 0436
  12. namespace Venus_RT.Modules.PMs
  13. {
  14. class ProcessHelper
  15. {
  16. protected JetPMBase Chamber;
  17. private string Module;
  18. private static Dictionary<string, Func<ProcessUnitBase, RecipeStep, RState>> startHelper = new Dictionary<string, Func<ProcessUnitBase, RecipeStep, RState>>();
  19. private static Dictionary<string, Func<ProcessUnitBase, RecipeStep, RState>> checkerHelper = new Dictionary<string, Func<ProcessUnitBase, RecipeStep, RState>>();
  20. private static Dictionary<string, Action<ProcessUnitBase, RecipeStep>> endHelper = new Dictionary<string, Action<ProcessUnitBase, RecipeStep>>();
  21. public ProcessHelper(JetPMBase pm)
  22. {
  23. Chamber = pm;
  24. Module = pm.Module.ToString() ;
  25. Init();
  26. }
  27. private void Init()
  28. {
  29. startHelper [$"{Module}.PressureByPressureModeUnit"] = (ProcessUnitBase unit, RecipeStep step) => PressureByPressureModeUnit_Start(unit, step);
  30. checkerHelper [$"{Module}.PressureByPressureModeUnit"] = (ProcessUnitBase unit, RecipeStep step) => PressureByPressureModeUnit_Check(unit, step);
  31. endHelper [$"{Module}.PressureByPressureModeUnit"] = (ProcessUnitBase unit, RecipeStep step) => PressureByPressureModeUnit_End(unit, step);
  32. startHelper [$"{Module}.PressureByValveModeUnit"] = (ProcessUnitBase unit, RecipeStep step) => PressureByValveModeUnit_Start(unit, step);
  33. checkerHelper [$"{Module}.PressureByValveModeUnit"] = (ProcessUnitBase unit, RecipeStep step) => PressureByValveModeUnit_Check(unit, step);
  34. endHelper [$"{Module}.PressureByValveModeUnit"] = (ProcessUnitBase unit, RecipeStep step) => PressureByValveModeUnit_End(unit, step);
  35. startHelper [$"{Module}.TCPUnit"] = (ProcessUnitBase unit, RecipeStep step) => TCPUnit_Start(unit, step);
  36. checkerHelper [$"{Module}.TCPUnit"] = (ProcessUnitBase unit, RecipeStep step) => TCPUnit_Check(unit, step);
  37. endHelper [$"{Module}.TCPUnit"] = (ProcessUnitBase unit, RecipeStep step) => TCPUnit_End(unit, step);
  38. startHelper [$"{Module}.BiasUnit"] = (ProcessUnitBase unit, RecipeStep step) => BiasUnit_Start(unit, step);
  39. checkerHelper [$"{Module}.BiasUnit"] = (ProcessUnitBase unit, RecipeStep step) => BiasUnit_Check(unit, step);
  40. endHelper [$"{Module}.BiasUnit"] = (ProcessUnitBase unit, RecipeStep step) => BiasUnit_End(unit, step);
  41. startHelper [$"{Module}.GasControlUnit"] = (ProcessUnitBase unit, RecipeStep step) => GasControlUnit_Start(unit, step);
  42. checkerHelper [$"{Module}.GasControlUnit"] = (ProcessUnitBase unit, RecipeStep step) => GasControlUnit_Check(unit, step);
  43. endHelper [$"{Module}.GasControlUnit"] = (ProcessUnitBase unit, RecipeStep step) => GasControlUnit_End(unit, step);
  44. startHelper [$"{Module}.ESCHVUnit"] = (ProcessUnitBase unit, RecipeStep step) => ESCHVUnit_Start(unit, step);
  45. checkerHelper [$"{Module}.ESCHVUnit"] = (ProcessUnitBase unit, RecipeStep step) => ESCHVUnit_Check(unit, step);
  46. endHelper [$"{Module}.ESCHVUnit"] = (ProcessUnitBase unit, RecipeStep step) => ESCHVUnit_End(unit, step);
  47. startHelper [$"{Module}.ProcessKitUnit"] = (ProcessUnitBase unit, RecipeStep step) => ProcessKitUnit_Start(unit, step);
  48. checkerHelper [$"{Module}.ProcessKitUnit"] = (ProcessUnitBase unit, RecipeStep step) => ProcessKitUnit_Check(unit, step);
  49. endHelper [$"{Module}.ProcessKitUnit"] = (ProcessUnitBase unit, RecipeStep step) => ProcessKitUnit_End(unit, step);
  50. }
  51. private RState PressureByPressureModeUnit_Start(ProcessUnitBase unit, RecipeStep step)
  52. {
  53. var ProcessUnit = unit as PressureByPressureModeUnit;
  54. if (ProcessUnit.PressureUnitMode == PressureUnitMode.Pressure)
  55. {
  56. if (Chamber.SetPVPressure(ProcessUnit.StartValue))
  57. {
  58. return RState.Running;
  59. }
  60. }
  61. else if (ProcessUnit.PressureUnitMode == PressureUnitMode.Valve)
  62. {
  63. if (Chamber.SetPVPostion(ProcessUnit.StartValue))
  64. {
  65. return RState.Running;
  66. }
  67. }
  68. return RState.Failed;
  69. }
  70. private RState PressureByPressureModeUnit_Check(ProcessUnitBase unit, RecipeStep step)
  71. {
  72. var ProcessUnit = unit as PressureByPressureModeUnit;
  73. if(ProcessUnit.EnableRamp)
  74. {
  75. if (ProcessUnit.PressureUnitMode == PressureUnitMode.Pressure)
  76. {
  77. if (Chamber.SetPVPressure(ProcessUnit.StartValue+ (int)((ProcessUnit.TargetValue - ProcessUnit.StartValue) * step.RampFactor())))
  78. return RState.Running;
  79. else
  80. return RState.Failed;
  81. }
  82. else if (ProcessUnit.PressureUnitMode == PressureUnitMode.Valve)
  83. {
  84. if (Chamber.SetPVPressure(ProcessUnit.StartValue + (int)((ProcessUnit.TargetValue - ProcessUnit.StartValue) * step.RampFactor())))
  85. return RState.Running;
  86. else
  87. return RState.Failed;
  88. }
  89. }
  90. if (ProcessUnit.PressureUnitMode == PressureUnitMode.Pressure)
  91. {
  92. if (step.Type == StepType.Stable && Chamber.ChamberPressure == ProcessUnit.StartValue)
  93. {
  94. return RState.End;
  95. }
  96. }
  97. else if (ProcessUnit.PressureUnitMode == PressureUnitMode.Valve )
  98. {
  99. if (step.Type == StepType.Stable && Chamber.GetPVPosition() == ProcessUnit.StartValue)
  100. {
  101. return RState.End;
  102. }
  103. }
  104. return RState.Running;
  105. }
  106. private void PressureByPressureModeUnit_End(ProcessUnitBase unit, RecipeStep step)
  107. {
  108. }
  109. #region Valve Mode已取消,合并到压力模式
  110. private RState PressureByValveModeUnit_Start(ProcessUnitBase unit, RecipeStep step)
  111. {
  112. var ProcessUnit = unit as PressureByValveModeUnit;
  113. if (Chamber.SetPVPostion(ProcessUnit.StartPosition))
  114. {
  115. return RState.Running;
  116. }
  117. return RState.Failed;
  118. }
  119. private RState PressureByValveModeUnit_Check(ProcessUnitBase unit, RecipeStep step)
  120. {
  121. var ProcessUnit = unit as PressureByValveModeUnit;
  122. if (ProcessUnit.EnableRamp)
  123. {
  124. if (Chamber.SetPVPostion(ProcessUnit.StartPosition + (int)((ProcessUnit.TargetPosition - ProcessUnit.StartPosition) * step.RampFactor())))
  125. return RState.Running;
  126. else
  127. return RState.Failed;
  128. }
  129. return RState.Running;
  130. }
  131. private void PressureByValveModeUnit_End(ProcessUnitBase unit, RecipeStep step)
  132. {
  133. }
  134. #endregion
  135. private RState TCPUnit_Start(ProcessUnitBase unit, RecipeStep step)
  136. {
  137. var ProcessUnit = unit as TCPUnit;
  138. if (ProcessUnit.RFPower > 5)
  139. {
  140. Chamber.GeneratorSetpower(ProcessUnit.RFPower);
  141. Chamber.GeneratorPowerOn(true);
  142. }
  143. Chamber.SetMatchPosition(ProcessUnit.TuneCapPreset, ProcessUnit.LoadCapPreset);
  144. return RState.Running;
  145. }
  146. private RState TCPUnit_Check(ProcessUnitBase unit, RecipeStep step)
  147. {
  148. var _scPowerAlarmTime= SC.GetValue<double>($"{Chamber.Name}.Rf.PowerAlarmTime");
  149. var ProcessUnit = unit as TCPUnit;
  150. if(ProcessUnit.MaxReflectedPower > 0 && Chamber.ReflectPower > ProcessUnit.MaxReflectedPower && step.ElapsedTime() > _scPowerAlarmTime*1000)
  151. {
  152. LOG.Write(eEvent.ERR_PROCESS, Chamber.Module, $"Step:{step.StepNo} failed, RF Reflect Power:{Chamber.ReflectPower} exceeds the Max Limit:{ProcessUnit.MaxReflectedPower}");
  153. return RState.Failed;
  154. }
  155. if(step.ElapsedTime() > ProcessUnit.HoldTime * 1000)
  156. {
  157. Chamber.GeneratorSetpower(0);
  158. Chamber.GeneratorPowerOn(false);
  159. }
  160. return RState.Running;
  161. }
  162. private void TCPUnit_End(ProcessUnitBase unit, RecipeStep step)
  163. {
  164. Chamber.GeneratorSetpower(0);
  165. Chamber.GeneratorPowerOn(false);
  166. }
  167. private RState BiasUnit_Start(ProcessUnitBase unit, RecipeStep step)
  168. {
  169. var ProcessUnit = unit as BiasUnit;
  170. if (ProcessUnit.BiasRFPower > 5)
  171. {
  172. Chamber.GeneratorBiasSetpower(ProcessUnit.BiasRFPower);
  173. Chamber.GeneratorBiasPowerOn(true);
  174. }
  175. Chamber.SetBiasMatchPosition(ProcessUnit.BiasTuneCapPreset, ProcessUnit.BiasLoadCapPreset);
  176. if(ProcessUnit.BiasGeneratorMode == GeneratorMode.Pulsing)
  177. {
  178. Chamber.SetBiasPulseMode(true);
  179. Chamber.SetBiasPulseRateFreq(ProcessUnit.PulseRateFreq);
  180. Chamber.SetDiasPulseDutyCycle(ProcessUnit.PulseDutyCycle);
  181. }
  182. return RState.Running;
  183. }
  184. private RState BiasUnit_Check(ProcessUnitBase unit, RecipeStep step)
  185. {
  186. var _scPowerAlarmTime = SC.GetValue<double>($"{Chamber.Name}.BiasRf.PowerAlarmTime");
  187. var ProcessUnit = unit as BiasUnit;
  188. if (ProcessUnit.BiasMaxReflectedPower > 0 && Chamber.BiasReflectPower > ProcessUnit.BiasMaxReflectedPower && step.ElapsedTime() > _scPowerAlarmTime * 1000)
  189. {
  190. LOG.Write(eEvent.ERR_PROCESS, Chamber.Module, $"Step:{step.StepNo} failed, Bias Reflect Power:{Chamber.BiasReflectPower} exceeds the Max Limit:{ProcessUnit.BiasMaxReflectedPower}");
  191. return RState.Failed;
  192. }
  193. if (step.ElapsedTime() > ProcessUnit.BiasRFHoldTime * 1000)
  194. {
  195. Chamber.GeneratorBiasSetpower(0);
  196. Chamber.GeneratorBiasPowerOn(false);
  197. }
  198. return RState.Running;
  199. }
  200. private void BiasUnit_End(ProcessUnitBase unit, RecipeStep step)
  201. {
  202. Chamber.GeneratorBiasSetpower(0);
  203. Chamber.GeneratorBiasPowerOn(false);
  204. }
  205. private RState GasControlUnit_Start(ProcessUnitBase unit, RecipeStep step)
  206. {
  207. Chamber.OpenValve(ValveType.GasFinal, true);
  208. var ProcessUnit = unit as GasControlUnit;
  209. Chamber.FlowGas(0, ProcessUnit.Gas1);
  210. if (ProcessUnit.Gas1 >= 1)
  211. {
  212. Chamber.OpenValve(ValveType.PV11, true);
  213. }
  214. Chamber.FlowGas(1, ProcessUnit.Gas2);
  215. if (ProcessUnit.Gas2 >= 1)
  216. {
  217. Chamber.OpenValve(ValveType.PV21, true);
  218. }
  219. Chamber.FlowGas(2, ProcessUnit.Gas3);
  220. if (ProcessUnit.Gas3 >= 1)
  221. {
  222. Chamber.OpenValve(ValveType.PV31,true);
  223. }
  224. Chamber.FlowGas(3, ProcessUnit.Gas4);
  225. if (ProcessUnit.Gas4 >= 1)
  226. {
  227. Chamber.OpenValve(ValveType.PV41, true);
  228. }
  229. Chamber.FlowGas(4, ProcessUnit.Gas5);
  230. Chamber.FlowGas(5, ProcessUnit.Gas6);
  231. Chamber.FlowGas(6, ProcessUnit.Gas7);
  232. Chamber.FlowGas(7, ProcessUnit.Gas8);
  233. return RState.Running;
  234. }
  235. private RState GasControlUnit_Check(ProcessUnitBase unit, RecipeStep step)
  236. {
  237. var ProcessUnit = unit as GasControlUnit;
  238. if(ProcessUnit.EnableRamp)
  239. {
  240. double rampFactor = step.RampFactor();
  241. Chamber.FlowGas(0, ProcessUnit.Gas1 + (ProcessUnit.Gas1Target - ProcessUnit.Gas1) * rampFactor);
  242. Chamber.FlowGas(1, ProcessUnit.Gas2 + (ProcessUnit.Gas2Target - ProcessUnit.Gas2) * rampFactor);
  243. Chamber.FlowGas(2, ProcessUnit.Gas3 + (ProcessUnit.Gas3Target - ProcessUnit.Gas3) * rampFactor);
  244. Chamber.FlowGas(3, ProcessUnit.Gas4 + (ProcessUnit.Gas4Target - ProcessUnit.Gas4) * rampFactor);
  245. Chamber.FlowGas(4, ProcessUnit.Gas5 + (ProcessUnit.Gas5Target - ProcessUnit.Gas5) * rampFactor);
  246. Chamber.FlowGas(5, ProcessUnit.Gas6 + (ProcessUnit.Gas6Target - ProcessUnit.Gas6) * rampFactor);
  247. Chamber.FlowGas(6, ProcessUnit.Gas7 + (ProcessUnit.Gas7Target - ProcessUnit.Gas7) * rampFactor);
  248. Chamber.FlowGas(7, ProcessUnit.Gas8 + (ProcessUnit.Gas8Target - ProcessUnit.Gas8) * rampFactor);
  249. }
  250. return RState.Running;
  251. }
  252. private void GasControlUnit_End(ProcessUnitBase unit, RecipeStep step)
  253. {
  254. Chamber.FlowGas(0, 0);
  255. Chamber.FlowGas(1, 0);
  256. Chamber.FlowGas(2, 0);
  257. Chamber.FlowGas(3, 0);
  258. Chamber.FlowGas(4, 0);
  259. Chamber.FlowGas(5, 0);
  260. Chamber.FlowGas(6, 0);
  261. Chamber.FlowGas(7, 0);
  262. }
  263. private RState ESCHVUnit_Start(ProcessUnitBase unit, RecipeStep step)
  264. {
  265. var ProcessUnit = unit as ESCHVUnit;
  266. Chamber.SetESCClampVoltage(ProcessUnit.ESCClampValtage);
  267. Chamber.SetBacksideHePressure(ProcessUnit.BacksideHelum);
  268. Chamber.SetBacksideHeThreshold(ProcessUnit.MinHeFlow, ProcessUnit.MaxHeFlow);
  269. return RState.Running;
  270. }
  271. private RState ESCHVUnit_Check(ProcessUnitBase unit, RecipeStep step)
  272. {
  273. if(Chamber.BackSideHeOutOfRange)
  274. {
  275. LOG.Write(eEvent.ERR_PROCESS, Chamber.Module, $"Step:{step.StepNo} failed, Backside Helium out of range.");
  276. return RState.Failed;
  277. }
  278. return RState.Running;
  279. }
  280. private void ESCHVUnit_End(ProcessUnitBase unit, RecipeStep step)
  281. {
  282. Chamber.SetESCClampVoltage(0);
  283. //Chamber.SetBacksideHePressure(0);
  284. Chamber.SetBacksideHeThreshold(0, 0);
  285. }
  286. private RState ProcessKitUnit_Start(ProcessUnitBase unit, RecipeStep step)
  287. {
  288. var ProcessUnit = unit as ProcessKitUnit;
  289. return RState.Running;
  290. }
  291. private RState ProcessKitUnit_Check(ProcessUnitBase unit, RecipeStep step)
  292. {
  293. var ProcessUnit = unit as ProcessKitUnit;
  294. return RState.Running;
  295. }
  296. private void ProcessKitUnit_End(ProcessUnitBase unit, RecipeStep step)
  297. {
  298. }
  299. public bool LoadMethods(ProcessUnitBase unit)
  300. {
  301. var className = $"{Module}.{unit.GetType().Name}";
  302. if(startHelper.ContainsKey(className) && checkerHelper.ContainsKey(className) && endHelper.ContainsKey(className))
  303. {
  304. unit.starter = startHelper[className];
  305. unit.checker = checkerHelper[className];
  306. unit.end = endHelper[className];
  307. return true;
  308. }
  309. return false;
  310. }
  311. private RState stepStarter(RecipeStep step)
  312. {
  313. step.StartStepTimer();
  314. switch (step.Type)
  315. {
  316. case StepType.EndPoint:
  317. Chamber.EPDStepStart(step.EPDConfig, step.StepNo);
  318. break;
  319. }
  320. return RState.Running;
  321. }
  322. private RState stepChecker(RecipeStep step)
  323. {
  324. switch(step.Type)
  325. {
  326. case StepType.Time:
  327. return step.ElapsedTime() >= step.Time * 1000 ? RState.End : RState.Running;
  328. case StepType.OverEtch:
  329. return step.ElapsedTime() >= (step.GetLastEPDStepTime() * step.OverEtchPercent / 100) ? RState.End : RState.Running;
  330. case StepType.EndPoint:
  331. if (step.ElapsedTime() > step.MaxEndPointTime * 1000)
  332. {
  333. LOG.Write(eEvent.INFO_PROCESS, Chamber.Module, $"Step:{step.StepNo} timeout, did not capture endpoint signal in {step.MaxEndPointTime} seconds");
  334. return RState.End;
  335. }
  336. else
  337. return Chamber.EPDCaptured ? RState.End : RState.Running;
  338. }
  339. return RState.Running;
  340. }
  341. private RState stepEnder(RecipeStep step)
  342. {
  343. if(step.Type == StepType.EndPoint)
  344. {
  345. Chamber.EPDStepStop();
  346. }
  347. //Chamber.GeneratorBiasPowerOn(false);
  348. //Chamber.GeneratorPowerOn(false);
  349. //Chamber.TurnPendulumValve(false);
  350. //Chamber.CloseValves();
  351. //Chamber.OpenValve(ValveType.TurboPumpPumping, true);
  352. //Chamber.OpenValve(ValveType.TurboPumpPurge, true);
  353. return RState.End;
  354. }
  355. public bool LoadStepFuns(RecipeStep step)
  356. {
  357. step.starter = stepStarter;
  358. step.checker = stepChecker;
  359. step.ender = stepEnder;
  360. return true;
  361. }
  362. }
  363. }