PreProcess.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. using System;
  2. using System.Collections.Generic;
  3. using Aitex.Core.Common.DeviceData;
  4. using Aitex.Core.RT.Job;
  5. using Aitex.Core.RT.SCCore;
  6. using Aitex.RT.Properties;
  7. using Aitex.Triton160.Common;
  8. using Aitex.Core.RT.Log;
  9. using Aitex.Core.RT.Event;
  10. using Aitex.Core.Util;
  11. using Aitex.Triton160.RT.Device;
  12. using Aitex.Triton160.RT.Module;
  13. using Aitex.Platform;
  14. using Aitex.Core.RT.Routine;
  15. using Aitex.Core.RT.RecipeCenter;
  16. using Aitex.Core.RT.Device.Unit;
  17. using System.Drawing;
  18. namespace Aitex.Triton160.RT.Routine.Process
  19. {
  20. public class PreProcess : CommonRoutine
  21. {
  22. public enum Routine
  23. {
  24. DelayForTest,
  25. CheckDoor,
  26. CheckDryPump,
  27. CloseAllVavle,
  28. OpenPumpingValve,
  29. CheckVAC,
  30. SetRfMatchMode,
  31. SetElectrodeTemp,
  32. End,
  33. }
  34. //Recipe
  35. public string CurrentRecipeBaseName { get; private set; }
  36. public string CurrentRecipeRunningName { get; private set; }
  37. public string CurrentRecipeContent { get; private set; }
  38. public string CurrentLotName
  39. {
  40. get; set;
  41. }
  42. public string CurrentJobName
  43. {
  44. get; set;
  45. }
  46. public string CurrentUserId
  47. {
  48. get; set;
  49. }
  50. public List<RecipeStep> CurrentRecipeStepList
  51. {
  52. get; set;
  53. }
  54. public RecipeHead CurrentRecipeHead
  55. {
  56. get; set;
  57. }
  58. private double BasePressure
  59. {
  60. get
  61. {
  62. if (CurrentRecipeHead!= null)
  63. {
  64. if (!string.IsNullOrEmpty(CurrentRecipeHead.BasePressure))
  65. {
  66. double setpoint = Convert.ToDouble(CurrentRecipeHead.BasePressure);
  67. if (setpoint > 0 && setpoint < 750000)
  68. return setpoint;
  69. }
  70. }
  71. return SC.GetValue<double>(SCName.System_PumpBasePressure);
  72. }
  73. }
  74. private double PumpDownLimit
  75. {
  76. get
  77. {
  78. if (CurrentRecipeHead != null)
  79. {
  80. if (!string.IsNullOrEmpty(CurrentRecipeHead.PumpDownLimit))
  81. {
  82. double setpoint = Convert.ToDouble(CurrentRecipeHead.PumpDownLimit);
  83. if (setpoint > 0 && setpoint < 600)
  84. return setpoint;
  85. }
  86. }
  87. return SC.GetValue<double>(SCName.System_PumpTimeLimit);
  88. }
  89. }
  90. //Recipe
  91. //private int _rfMatchModeDuringProcess;
  92. public PreProcess(string module, string name)
  93. {
  94. Module = module;
  95. Name = name;
  96. Display = "Pre Process";
  97. }
  98. public bool Initialize()
  99. {
  100. InitCommon();
  101. return true;
  102. }
  103. public void Terminate()
  104. {
  105. }
  106. public Result LoadRecipe(params object[] param)
  107. {
  108. CurrentRecipeBaseName = (string)param[0];
  109. CurrentRecipeContent = (string)param[1];
  110. CurrentLotName = (string) param[2];
  111. CurrentJobName = param.Length > 3 ? (string) param[3] : "";
  112. CurrentUserId = param.Length > 4 ? (string)param[4] : "";
  113. CurrentRecipeRunningName = string.Format("{0}-{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), CurrentRecipeBaseName);
  114. List<RecipeStep> recipeSteps = null;
  115. RecipeHead recipeHead = null;
  116. if (!Recipe.Parse(CurrentRecipeContent, out recipeHead, out recipeSteps))
  117. {
  118. Stop(string.Format(Resources.PreProcess_LoadRecipe_LoadRecipe0Failed, CurrentRecipeRunningName));
  119. return Result.FAIL;
  120. }
  121. CurrentRecipeStepList = recipeSteps;
  122. CurrentRecipeHead = recipeHead;
  123. return Result.DONE;
  124. }
  125. public Result Start(params object[] param)
  126. {
  127. try
  128. {
  129. if (BasePressure <=0 || BasePressure >= 760000)
  130. {
  131. Stop(string.Format(Resources.PreProcess_Start_BasePressure0NotValid, BasePressure));
  132. return Result.FAIL;
  133. }
  134. if (PumpDownLimit <= 0.01 || PumpDownLimit >= 600)
  135. {
  136. Stop(string.Format(Resources.PreProcess_Start_PumpDownLimit0NotValid, PumpDownLimit));
  137. return Result.FAIL;
  138. }
  139. if (DeviceModel.StatisticsPumpOnTime != null && DeviceModel.StatisticsPumpOnTime.IsPMNeeded && DeviceModel.StatisticsPumpOnTime.EnableAlarm)
  140. {
  141. Stop(string.Format(Resources.PreProcess_Start_CanNotRunRecipeBecausePumpPMNeeded));
  142. return Result.FAIL;
  143. }
  144. if (DeviceModel.StatisticsRfOnTime != null && DeviceModel.StatisticsRfOnTime.IsPMNeeded && DeviceModel.StatisticsRfOnTime.EnableAlarm)
  145. {
  146. Stop(string.Format(Resources.PreProcess_Start_CanNotRunRecipeBecauseRFPMNeeded));
  147. return Result.FAIL;
  148. }
  149. //每个Process Run 都对应唯一的Guid
  150. JobInfo job = JobManager.Instance.StartJob();
  151. job.RecipeBaseName = CurrentRecipeBaseName;
  152. job.RecipeRunningName = CurrentRecipeRunningName;
  153. job.JobResult = JobStatus.Preprocessing;
  154. job.ProcessModuleName = ModuleName.System.ToString();
  155. job.ProcessStartTime = DateTime.Now;
  156. job.LotId = CurrentLotName;
  157. Singleton<PMEntity>.Instance.CurrentRunningJob = job;
  158. Reset();
  159. UpdateSCValue();
  160. //_rfMatchModeDuringProcess = SC.GetValue<int>(SCName.System_RfMatchModeDuringProcess );
  161. //if (_rfMatchModeDuringProcess == (int)TritonRfMatchMode.Auto)
  162. //{
  163. // EV.PostMessage(Module, EventEnum.ProcessRFMatchModeSetToAuto);
  164. //}
  165. //依据工艺部门的要求,工艺处理开始时间从Recipe Header开始运行就进行计时
  166. Singleton<ProcessRecorder>.Instance.BeginNewProcess(job);
  167. RecipeFileManager.Instance.SaveRecipeHistory(ModuleName.System.ToString(), CurrentRecipeRunningName, CurrentRecipeContent);
  168. }
  169. catch (Exception ex)
  170. {
  171. LOG.Write(ex, String.Format("Preprocess Start has exception"));
  172. throw (ex);
  173. }
  174. return Result.RUN;
  175. }
  176. public Result Monitor()
  177. {
  178. try
  179. {
  180. //检查Door
  181. CheckDoor((int)Routine.CheckDoor, Resources.PumpDownRoutine_Monitor_CheckDoorStatus, Notify, Stop);
  182. //检查 Dry Pump
  183. CheckDryPump((int)Routine.CheckDryPump, Resources.PumpDownRoutine_Monitor_CheckPumpStatus, Notify, Stop);
  184. //关闭所有阀门
  185. CloseAllValve((int)Routine.CloseAllVavle, Resources.PumpDownRoutine_Monitor_CloseAllTheValves, 10, Notify, Stop);
  186. //打开
  187. OpenPumpingValve((int)Routine.OpenPumpingValve, Resources.PumpDownRoutine_Monitor_OpenPumpingValve, 10, Notify, Stop);
  188. //检查VAC
  189. CheckVAC((int)Routine.CheckVAC, Resources.PreProcess_Monitor_CheckChamberPressure, BasePressure, (int)PumpDownLimit, Notify, Stop);
  190. //设置RF Match Mode
  191. //SetRfMatchMode((int)Routine.SetRfMatchMode, string.Format(Resources.PreProcess_Monitor_SetRFMatchMode, _rfMatchModeDuringProcess==(int)TritonRfMatchMode.Manual ? "Manual" : "Auto"), _rfMatchModeDuringProcess);
  192. End((int)Routine.End, Resources.PreProcess_Monitor_PreprocessFinished, Notify, Stop);
  193. }
  194. catch (RoutineBreakException)
  195. {
  196. return Result.RUN;
  197. }
  198. catch (RoutineFaildException)
  199. {
  200. return Result.FAIL;
  201. }
  202. catch (Exception ex)
  203. {
  204. LOG.Write(ex, String.Format("Preprocess Monitor has exception"));
  205. throw (ex);
  206. }
  207. return Result.DONE;
  208. }
  209. public void Exit()
  210. {
  211. //string reason;
  212. //update processing end time
  213. // Singleton<ProcessRecorder>.Instance.EndRecipeProcess(Singleton<PMEntity>.Instance.CurrentRecipeRunGuid, SusceptorStatus.Processed);
  214. //恢复特殊Recipe的运行标志
  215. }
  216. private new void Notify(string message)
  217. {
  218. Singleton<ProcessRecorder>.Instance.AddRecord(Singleton<PMEntity>.Instance.CurrentRunningJob.RecipeRunId, CarrierDataType.PreProcessStep, "", "Prepare running recipe:" + message);
  219. EV.PostMessage(Module, EventEnum.PreProcessInfo, Module, message);
  220. }
  221. private new void Stop(string message)
  222. {
  223. //ProcessRecorder.AddRecord(Reactor.CurrentRecipeRunGuid, CarrierDataType.PreProcessErrorEnd, "", "工艺程序前准备:异常结束," + failReason);
  224. if (Singleton<PMEntity>.Instance.CurrentRunningJob != null)
  225. Singleton<ProcessRecorder>.Instance.AddRecord(Singleton<PMEntity>.Instance.CurrentRunningJob.RecipeRunId, CarrierDataType.PreProcessErrorEnd, "", "Prepare running recipe:stopped for exception," + message);
  226. EV.PostMessage(Module, EventEnum.PrepareProcessErr, Module, message);
  227. EV.PostPopDialogMessage(EventLevel.Alarm, string.Format("{0} running failed", Module),
  228. string.Format(Resources.PreProcess_Stop_Recipe0RNFailedReason1, CurrentRecipeRunningName, message));
  229. }
  230. public new Result Abort()
  231. {
  232. base.Abort();
  233. string reason;
  234. IoValve valve = DeviceModel.ValveChamberPumping;
  235. if (valve != null && !valve.TurnValve(false, out reason))
  236. {
  237. LOG.Write(string.Format("can not close valve {0}, {1}", valve.Name, reason));
  238. }
  239. return Result.DONE;
  240. }
  241. }
  242. }