ProcessDefine.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  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. else
  144. {
  145. Chamber.GeneratorSetpower(0);
  146. Chamber.GeneratorPowerOn(false);
  147. }
  148. Chamber.SetMatchPosition(ProcessUnit.TuneCapPreset, ProcessUnit.LoadCapPreset);
  149. return RState.Running;
  150. }
  151. private RState TCPUnit_Check(ProcessUnitBase unit, RecipeStep step)
  152. {
  153. var _scPowerAlarmTime= SC.GetValue<double>($"{Chamber.Name}.Rf.PowerAlarmTime");
  154. var ProcessUnit = unit as TCPUnit;
  155. if(ProcessUnit.MaxReflectedPower > 0 && Chamber.ReflectPower > ProcessUnit.MaxReflectedPower && step.ElapsedTime() > _scPowerAlarmTime*1000)
  156. {
  157. LOG.Write(eEvent.ERR_PROCESS, Chamber.Module, $"Step:{step.StepNo} failed, RF Reflect Power:{Chamber.ReflectPower} exceeds the Max Limit:{ProcessUnit.MaxReflectedPower}");
  158. return RState.Failed;
  159. }
  160. if (step.ElapsedTime() > ProcessUnit.HoldTime * 1000)
  161. {
  162. Chamber.GeneratorSetpower(0);
  163. Chamber.GeneratorPowerOn(false);
  164. }
  165. return RState.Running;
  166. }
  167. private void TCPUnit_End(ProcessUnitBase unit, RecipeStep step)
  168. {
  169. //Chamber.GeneratorSetpower(0);
  170. //Chamber.GeneratorPowerOn(false);
  171. }
  172. private RState BiasUnit_Start(ProcessUnitBase unit, RecipeStep step)
  173. {
  174. var ProcessUnit = unit as BiasUnit;
  175. if (ProcessUnit.BiasRFPower > 5)
  176. {
  177. Chamber.GeneratorBiasSetpower(ProcessUnit.BiasRFPower);
  178. Chamber.GeneratorBiasPowerOn(true);
  179. }
  180. Chamber.SetBiasMatchPosition(ProcessUnit.BiasTuneCapPreset, ProcessUnit.BiasLoadCapPreset);
  181. if(ProcessUnit.BiasGeneratorMode == GeneratorMode.Pulsing)
  182. {
  183. Chamber.SetBiasPulseMode(true);
  184. Chamber.SetBiasPulseRateFreq(ProcessUnit.PulseRateFreq);
  185. Chamber.SetDiasPulseDutyCycle(ProcessUnit.PulseDutyCycle);
  186. }
  187. return RState.Running;
  188. }
  189. private RState BiasUnit_Check(ProcessUnitBase unit, RecipeStep step)
  190. {
  191. var _scPowerAlarmTime = SC.GetValue<double>($"{Chamber.Name}.BiasRf.PowerAlarmTime");
  192. var ProcessUnit = unit as BiasUnit;
  193. if (ProcessUnit.BiasMaxReflectedPower > 0 && Chamber.BiasReflectPower > ProcessUnit.BiasMaxReflectedPower && step.ElapsedTime() > _scPowerAlarmTime * 1000)
  194. {
  195. LOG.Write(eEvent.ERR_PROCESS, Chamber.Module, $"Step:{step.StepNo} failed, Bias Reflect Power:{Chamber.BiasReflectPower} exceeds the Max Limit:{ProcessUnit.BiasMaxReflectedPower}");
  196. return RState.Failed;
  197. }
  198. if (step.ElapsedTime() > ProcessUnit.BiasRFHoldTime * 1000)
  199. {
  200. Chamber.GeneratorBiasSetpower(0);
  201. Chamber.GeneratorBiasPowerOn(false);
  202. }
  203. return RState.Running;
  204. }
  205. private void BiasUnit_End(ProcessUnitBase unit, RecipeStep step)
  206. {
  207. Chamber.GeneratorBiasSetpower(0);
  208. Chamber.GeneratorBiasPowerOn(false);
  209. }
  210. private RState GasControlUnit_Start(ProcessUnitBase unit, RecipeStep step)
  211. {
  212. Chamber.OpenValve(ValveType.GasFinal, true);
  213. var ProcessUnit = unit as GasControlUnit;
  214. Chamber.FlowGas(0, ProcessUnit.Gas1);
  215. if (ProcessUnit.Gas1 >= 1)
  216. {
  217. Chamber.OpenValve(ValveType.PV11, true);
  218. }
  219. Chamber.FlowGas(1, ProcessUnit.Gas2);
  220. if (ProcessUnit.Gas2 >= 1)
  221. {
  222. Chamber.OpenValve(ValveType.PV21, true);
  223. }
  224. Chamber.FlowGas(2, ProcessUnit.Gas3);
  225. if (ProcessUnit.Gas3 >= 1)
  226. {
  227. Chamber.OpenValve(ValveType.PV31,true);
  228. }
  229. Chamber.FlowGas(3, ProcessUnit.Gas4);
  230. if (ProcessUnit.Gas4 >= 1)
  231. {
  232. Chamber.OpenValve(ValveType.PV41, true);
  233. }
  234. Chamber.FlowGas(4, ProcessUnit.Gas5);
  235. Chamber.FlowGas(5, ProcessUnit.Gas6);
  236. Chamber.FlowGas(6, ProcessUnit.Gas7);
  237. Chamber.FlowGas(7, ProcessUnit.Gas8);
  238. return RState.Running;
  239. }
  240. private RState GasControlUnit_Check(ProcessUnitBase unit, RecipeStep step)
  241. {
  242. var ProcessUnit = unit as GasControlUnit;
  243. if(ProcessUnit.EnableRamp)
  244. {
  245. double rampFactor = step.RampFactor();
  246. Chamber.FlowGas(0, ProcessUnit.Gas1 + (ProcessUnit.Gas1Target - ProcessUnit.Gas1) * rampFactor);
  247. Chamber.FlowGas(1, ProcessUnit.Gas2 + (ProcessUnit.Gas2Target - ProcessUnit.Gas2) * rampFactor);
  248. Chamber.FlowGas(2, ProcessUnit.Gas3 + (ProcessUnit.Gas3Target - ProcessUnit.Gas3) * rampFactor);
  249. Chamber.FlowGas(3, ProcessUnit.Gas4 + (ProcessUnit.Gas4Target - ProcessUnit.Gas4) * rampFactor);
  250. Chamber.FlowGas(4, ProcessUnit.Gas5 + (ProcessUnit.Gas5Target - ProcessUnit.Gas5) * rampFactor);
  251. Chamber.FlowGas(5, ProcessUnit.Gas6 + (ProcessUnit.Gas6Target - ProcessUnit.Gas6) * rampFactor);
  252. Chamber.FlowGas(6, ProcessUnit.Gas7 + (ProcessUnit.Gas7Target - ProcessUnit.Gas7) * rampFactor);
  253. Chamber.FlowGas(7, ProcessUnit.Gas8 + (ProcessUnit.Gas8Target - ProcessUnit.Gas8) * rampFactor);
  254. }
  255. return RState.Running;
  256. }
  257. private void GasControlUnit_End(ProcessUnitBase unit, RecipeStep step)
  258. {
  259. Chamber.FlowGas(0, 0);
  260. Chamber.FlowGas(1, 0);
  261. Chamber.FlowGas(2, 0);
  262. Chamber.FlowGas(3, 0);
  263. Chamber.FlowGas(4, 0);
  264. Chamber.FlowGas(5, 0);
  265. Chamber.FlowGas(6, 0);
  266. Chamber.FlowGas(7, 0);
  267. }
  268. private RState ESCHVUnit_Start(ProcessUnitBase unit, RecipeStep step)
  269. {
  270. var ProcessUnit = unit as ESCHVUnit;
  271. Chamber.SetESCClampVoltage(ProcessUnit.ESCClampValtage);
  272. Chamber.SetBacksideHePressure(ProcessUnit.BacksideHelum);
  273. Chamber.SetBacksideHeThreshold(ProcessUnit.MinHeFlow, ProcessUnit.MaxHeFlow);
  274. return RState.Running;
  275. }
  276. private RState ESCHVUnit_Check(ProcessUnitBase unit, RecipeStep step)
  277. {
  278. if(Chamber.BackSideHeOutOfRange)
  279. {
  280. LOG.Write(eEvent.ERR_PROCESS, Chamber.Module, $"Step:{step.StepNo} failed, Backside Helium out of range.");
  281. return RState.Failed;
  282. }
  283. return RState.Running;
  284. }
  285. private void ESCHVUnit_End(ProcessUnitBase unit, RecipeStep step)
  286. {
  287. Chamber.SetESCClampVoltage(0);
  288. //Chamber.SetBacksideHePressure(0);
  289. Chamber.SetBacksideHeThreshold(0, 0);
  290. }
  291. private RState ProcessKitUnit_Start(ProcessUnitBase unit, RecipeStep step)
  292. {
  293. var ProcessUnit = unit as ProcessKitUnit;
  294. return RState.Running;
  295. }
  296. private RState ProcessKitUnit_Check(ProcessUnitBase unit, RecipeStep step)
  297. {
  298. var ProcessUnit = unit as ProcessKitUnit;
  299. return RState.Running;
  300. }
  301. private void ProcessKitUnit_End(ProcessUnitBase unit, RecipeStep step)
  302. {
  303. }
  304. public bool LoadMethods(ProcessUnitBase unit)
  305. {
  306. var className = $"{Module}.{unit.GetType().Name}";
  307. if(startHelper.ContainsKey(className) && checkerHelper.ContainsKey(className) && endHelper.ContainsKey(className))
  308. {
  309. unit.starter = startHelper[className];
  310. unit.checker = checkerHelper[className];
  311. unit.end = endHelper[className];
  312. return true;
  313. }
  314. return false;
  315. }
  316. private RState stepStarter(RecipeStep step)
  317. {
  318. step.StartStepTimer();
  319. switch (step.Type)
  320. {
  321. case StepType.EndPoint:
  322. Chamber.EPDStepStart(step.EPDConfig, step.StepNo);
  323. break;
  324. }
  325. return RState.Running;
  326. }
  327. private RState stepChecker(RecipeStep step)
  328. {
  329. switch(step.Type)
  330. {
  331. case StepType.Time:
  332. return step.ElapsedTime() >= step.Time * 1000 ? RState.End : RState.Running;
  333. case StepType.OverEtch:
  334. return step.ElapsedTime() >= (step.GetLastEPDStepTime() * step.OverEtchPercent / 100) ? RState.End : RState.Running;
  335. case StepType.EndPoint:
  336. if (step.ElapsedTime() > step.MaxEndPointTime * 1000)
  337. {
  338. LOG.Write(eEvent.INFO_PROCESS, Chamber.Module, $"Step:{step.StepNo} timeout, did not capture endpoint signal in {step.MaxEndPointTime} seconds");
  339. return RState.End;
  340. }
  341. else
  342. return Chamber.EPDCaptured ? RState.End : RState.Running;
  343. }
  344. return RState.Running;
  345. }
  346. private RState stepEnder(RecipeStep step)
  347. {
  348. if(step.Type == StepType.EndPoint)
  349. {
  350. Chamber.EPDStepStop();
  351. }
  352. //Chamber.GeneratorBiasPowerOn(false);
  353. //Chamber.GeneratorPowerOn(false);
  354. //Chamber.TurnPendulumValve(false);
  355. //Chamber.CloseValves();
  356. //Chamber.OpenValve(ValveType.TurboPumpPumping, true);
  357. //Chamber.OpenValve(ValveType.TurboPumpPurge, true);
  358. return RState.End;
  359. }
  360. public bool LoadStepFuns(RecipeStep step)
  361. {
  362. step.starter = stepStarter;
  363. step.checker = stepChecker;
  364. step.ender = stepEnder;
  365. return true;
  366. }
  367. }
  368. }