RecipeParser.cs 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Xml;
  4. using System.Reflection;
  5. using Aitex.Common.Util;
  6. using Aitex.Core.Common.DeviceData;
  7. using Aitex.Core.RT.Log;
  8. using Aitex.Core.RT.RecipeCenter;
  9. using Aitex.Core.RT.SCCore;
  10. using MECF.Framework.Common.Equipment;
  11. using System.IO;
  12. namespace FurnaceRT.Equipments.PMs.RecipeExecutions
  13. {
  14. public class RecipeParser
  15. {
  16. public static bool Parse(string recipeFile, string module, out RecipeHead recipeHead, out List<RecipeStep> recipeData, out string reason, string recipeType, int tableID = 1, RecipeHead mainHead = null)
  17. {
  18. reason = string.Empty;
  19. if (mainHead != null)
  20. recipeHead = mainHead;
  21. else
  22. recipeHead = new RecipeHead();
  23. recipeData = new List<RecipeStep>();
  24. string content = string.Empty;
  25. if (recipeType != "Process" && recipeType != "Idle" && recipeType != "Reset")
  26. {
  27. if (!File.Exists($"{PathManager.GetRecipeDir()}\\{SC.GetStringValue("System.Recipe.SupportedChamberType")}\\{SC.GetStringValue($"System.Recipe.Supported{recipeType}Type")}\\{recipeFile}.rcp"))
  28. return true;
  29. }
  30. content = RecipeFileManager.Instance.LoadRecipe($"{SC.GetStringValue("System.Recipe.SupportedChamberType")}\\{SC.GetStringValue($"System.Recipe.Supported{recipeType}Type")}", recipeFile, false);
  31. if (string.IsNullOrEmpty(content))
  32. {
  33. reason = $"{recipeFile} is not a valid recipe file";
  34. return false;
  35. }
  36. try
  37. {
  38. //获取工艺程序文件中允许的命令字符串列表
  39. //目的:如果工艺程序文件中含有规定之外的命令,则被禁止执行
  40. HashSet<string> recipeAllowedCommands = new HashSet<string>();
  41. XmlDocument rcpFormatDoc = new XmlDocument();
  42. string recipeSchema = PathManager.GetCfgDir() + $@"\Recipe\Furnace\Process\{SC.GetStringValue("System.SetUp.ToolType")}\RecipeFormat.xml";
  43. rcpFormatDoc.Load(recipeSchema);
  44. XmlNodeList rcpItemNodeList = rcpFormatDoc.SelectNodes("/Aitex/TableRecipeFormat/Catalog/Group/Step");
  45. foreach (XmlElement item in rcpItemNodeList)
  46. recipeAllowedCommands.Add(item.Attributes["ControlName"].Value);
  47. recipeAllowedCommands.Add("Temperature.ControlMode");
  48. recipeAllowedCommands.Add("Temperature.Correct");
  49. recipeAllowedCommands.Add("Temperature.PID");
  50. recipeAllowedCommands.Add("ConditionCheck");
  51. recipeAllowedCommands.Add("EventSetting");
  52. recipeAllowedCommands.Add("FilmThickFormula");
  53. recipeAllowedCommands.Add("FilmThickCoefficientA");
  54. recipeAllowedCommands.Add("FilmThickCoefficientB");
  55. recipeAllowedCommands.Add("AlarmTableIndex");
  56. recipeAllowedCommands.Add("RFSwitch");
  57. recipeAllowedCommands.Add("RFSetpoint");
  58. recipeAllowedCommands.Add("ForwardPowerAlarmWatchTable");
  59. recipeAllowedCommands.Add("PrAlarmWatchTable");
  60. recipeAllowedCommands.Add("PIAlarmWatchTable");
  61. recipeAllowedCommands.Add("C1Setpoint");
  62. recipeAllowedCommands.Add("C2Setpoint");
  63. recipeAllowedCommands.Add("C1AlarmWatchTable");
  64. recipeAllowedCommands.Add("C2AlarmWatchTable");
  65. recipeAllowedCommands.Add("VppAlarmWatchTable");
  66. recipeAllowedCommands.Add("VdcAlarmWatchTable");
  67. recipeAllowedCommands.Add("PressureSonserValue");
  68. recipeAllowedCommands.Add("PressureValveAngle");
  69. recipeAllowedCommands.Add("PressureSettingVG");
  70. recipeAllowedCommands.Add("PressCommand");
  71. recipeAllowedCommands.Add("PressValue");
  72. recipeAllowedCommands.Add("PressureAlarmTableNo");
  73. recipeAllowedCommands.Add("AbortRecipeTableIndex");
  74. recipeAllowedCommands.Add("AlarmConditionTable");
  75. recipeAllowedCommands.Add("LoaderCommand");
  76. recipeAllowedCommands.Add("LoaderValue");
  77. for (int i = 1; i < 11; i++)
  78. {
  79. recipeAllowedCommands.Add($"AlarmAction.{i}");
  80. recipeAllowedCommands.Add($"AlarmDetails.{i}");
  81. }
  82. for (int i = 1; i < 60; i++)
  83. {
  84. recipeAllowedCommands.Add($"MFC{i}.Flow.Set");
  85. recipeAllowedCommands.Add($"MFC{i}.Flow.SetUnit");
  86. recipeAllowedCommands.Add($"MFC{i}.Flow.Ramprate");
  87. recipeAllowedCommands.Add($"MFC{i}.Flow.RamprateUnit");
  88. recipeAllowedCommands.Add($"MFC{i}.Flow.Check");
  89. recipeAllowedCommands.Add($"MFC{i}.Flow.High");
  90. recipeAllowedCommands.Add($"MFC{i}.Flow.Low");
  91. recipeAllowedCommands.Add($"MFC{i}.Flow.Unit");
  92. }
  93. for (int i = 1; i < 200; i++)
  94. {
  95. recipeAllowedCommands.Add($"AUX.{i}.Set");
  96. recipeAllowedCommands.Add($"AUX.{i}.Check");
  97. recipeAllowedCommands.Add($"AUX.{i}.High");
  98. recipeAllowedCommands.Add($"AUX.{i}.Low");
  99. recipeAllowedCommands.Add($"AUX.{i}.CheckUnit");
  100. }
  101. recipeAllowedCommands.Add("HeaterU.ZoneName");
  102. recipeAllowedCommands.Add("HeaterU.Set");
  103. recipeAllowedCommands.Add("HeaterU.SetUnit");
  104. recipeAllowedCommands.Add("HeaterU.Ramprate");
  105. recipeAllowedCommands.Add("HeaterU.RamprateUnit");
  106. recipeAllowedCommands.Add("HeaterU.Check");
  107. recipeAllowedCommands.Add("HeaterU.High");
  108. recipeAllowedCommands.Add("HeaterU.Low");
  109. recipeAllowedCommands.Add("HeaterU.Unit");
  110. recipeAllowedCommands.Add("HeaterCU.ZoneName");
  111. recipeAllowedCommands.Add("HeaterCU.Set");
  112. recipeAllowedCommands.Add("HeaterCU.SetUnit");
  113. recipeAllowedCommands.Add("HeaterCU.Ramprate");
  114. recipeAllowedCommands.Add("HeaterCU.RamprateUnit");
  115. recipeAllowedCommands.Add("HeaterCU.Check");
  116. recipeAllowedCommands.Add("HeaterCU.High");
  117. recipeAllowedCommands.Add("HeaterCU.Low");
  118. recipeAllowedCommands.Add("HeaterCU.Unit");
  119. recipeAllowedCommands.Add("HeaterC.ZoneName");
  120. recipeAllowedCommands.Add("HeaterC.Set");
  121. recipeAllowedCommands.Add("HeaterC.SetUnit");
  122. recipeAllowedCommands.Add("HeaterC.Ramprate");
  123. recipeAllowedCommands.Add("HeaterC.RamprateUnit");
  124. recipeAllowedCommands.Add("HeaterC.Check");
  125. recipeAllowedCommands.Add("HeaterC.High");
  126. recipeAllowedCommands.Add("HeaterC.Low");
  127. recipeAllowedCommands.Add("HeaterC.Unit");
  128. recipeAllowedCommands.Add("HeaterCL.ZoneName");
  129. recipeAllowedCommands.Add("HeaterCL.Set");
  130. recipeAllowedCommands.Add("HeaterCL.SetUnit");
  131. recipeAllowedCommands.Add("HeaterCL.Ramprate");
  132. recipeAllowedCommands.Add("HeaterCL.RamprateUnit");
  133. recipeAllowedCommands.Add("HeaterCL.Check");
  134. recipeAllowedCommands.Add("HeaterCL.High");
  135. recipeAllowedCommands.Add("HeaterCL.Low");
  136. recipeAllowedCommands.Add("HeaterCL.Unit");
  137. recipeAllowedCommands.Add("HeaterL.ZoneName");
  138. recipeAllowedCommands.Add("HeaterL.Set");
  139. recipeAllowedCommands.Add("HeaterL.SetUnit");
  140. recipeAllowedCommands.Add("HeaterL.Ramprate");
  141. recipeAllowedCommands.Add("HeaterL.RamprateUnit");
  142. recipeAllowedCommands.Add("HeaterL.Check");
  143. recipeAllowedCommands.Add("HeaterL.High");
  144. recipeAllowedCommands.Add("HeaterL.Low");
  145. recipeAllowedCommands.Add("HeaterL.Unit");
  146. recipeAllowedCommands.Add("Loader.Command");
  147. recipeAllowedCommands.Add("Loader.Speed1");
  148. recipeAllowedCommands.Add("Loader.Speed2");
  149. recipeAllowedCommands.Add("Loader.Speed3");
  150. recipeAllowedCommands.Add("Loader.RPM");
  151. recipeAllowedCommands.Add("Press.Command");
  152. recipeAllowedCommands.Add("Press.PID");
  153. recipeAllowedCommands.Add("Press.Set");
  154. recipeAllowedCommands.Add("Press.SlowVacSet");
  155. recipeAllowedCommands.Add("Press.ValveAngleSet");
  156. recipeAllowedCommands.Add("Press.IsWait");
  157. recipeAllowedCommands.Add("Press.LowWait");
  158. recipeAllowedCommands.Add("Press.HighWait");
  159. recipeAllowedCommands.Add("Press.WaitUnit");
  160. recipeAllowedCommands.Add("Press.WaitPress");
  161. //获取工艺程序文件中所有步的内容
  162. XmlDocument rcpDataDoc = new XmlDocument();
  163. rcpDataDoc.LoadXml(content);
  164. XmlNode nodeModule = null;
  165. if (recipeType == "Process" || recipeType == "Idle" || recipeType == "Reset")
  166. nodeModule = rcpDataDoc.SelectSingleNode($"/Aitex/TableRecipeData/Module[@Name='{module}']");
  167. else
  168. nodeModule = rcpDataDoc.SelectSingleNode($"/Aitex/TableRecipeData/Tables/Table[@Index='{tableID}']");
  169. if (nodeModule == null)
  170. {
  171. reason = $"Recipe file does not contains step content for {module}";
  172. return false;
  173. }
  174. XmlElement nodeConfig = nodeModule.SelectSingleNode($"Config") as XmlElement;
  175. if (nodeConfig != null)
  176. {
  177. if (mainHead == null)
  178. {
  179. recipeHead.SubRecipe = nodeConfig.HasAttribute("Combination.SubRecipe") ? nodeConfig.Attributes["Combination.SubRecipe"].Value : "";
  180. recipeHead.AlarmRecipe = nodeConfig.HasAttribute("Combination.AlarmRecipe") ? nodeConfig.Attributes["Combination.AlarmRecipe"].Value : "";
  181. recipeHead.AlarmCondition = nodeConfig.HasAttribute("Combination.AlarmCondition") ? nodeConfig.Attributes["Combination.AlarmCondition"].Value : "";
  182. recipeHead.LeakCheck = nodeConfig.HasAttribute("Combination.LeakCheck") ? nodeConfig.Attributes["Combination.LeakCheck"].Value : "";
  183. recipeHead.AbortRecipe = nodeConfig.HasAttribute("Combination.AbortRecipe") ? nodeConfig.Attributes["Combination.AbortRecipe"].Value : "";
  184. recipeHead.PressApcPID = nodeConfig.HasAttribute("Combination.PressAPCPID") ? nodeConfig.Attributes["Combination.PressAPCPID"].Value : "";
  185. recipeHead.TempCorrect = nodeConfig.HasAttribute("Combination.TempCorrection") ? nodeConfig.Attributes["Combination.TempCorrection"].Value : "";
  186. recipeHead.TempPID = nodeConfig.HasAttribute("Combination.TempPID") ? nodeConfig.Attributes["Combination.TempPID"].Value : "";
  187. recipeHead.ProfileCondition = nodeConfig.HasAttribute("Combination.ProfileCondition") ? nodeConfig.Attributes["Combination.ProfileCondition"].Value : "";
  188. if(nodeConfig.HasAttribute("N2PurgeMode"))
  189. {
  190. recipeHead.IsN2PurgeMode = nodeConfig.Attributes["N2PurgeMode"].Value.Replace(" ", "").ToLower() == "n2purge";
  191. recipeHead.N2PurgeModeStr = nodeConfig.Attributes["N2PurgeMode"].Value;
  192. }
  193. else
  194. {
  195. recipeHead.IsN2PurgeMode = false;
  196. }
  197. if (string.IsNullOrEmpty(recipeHead.AbortRecipe))
  198. recipeHead.AbortRecipe = SC.GetStringValue("System.Recipe.Abort Recipe");
  199. }
  200. }
  201. else
  202. {
  203. if (mainHead == null)
  204. {
  205. recipeHead.SubRecipe = "";
  206. recipeHead.AlarmRecipe = "";
  207. recipeHead.AlarmCondition = "";
  208. recipeHead.LeakCheck = "";
  209. recipeHead.AbortRecipe = "";
  210. recipeHead.PressApcPID = "";
  211. recipeHead.TempCorrect = "";
  212. recipeHead.TempPID = "";
  213. recipeHead.ProfileCondition = "";
  214. if (recipeType == "Sub")
  215. recipeHead.AbortRecipe = SC.GetStringValue("System.Recipe.Abort Recipe");
  216. }
  217. }
  218. XmlNodeList stepNodeList = nodeModule.SelectNodes($"Step");
  219. string strLoopEndStep, strJumpStep;
  220. strLoopEndStep = strJumpStep = string.Empty;
  221. for (int i = 0; i < stepNodeList.Count; i++)
  222. {
  223. var recipeStep = new RecipeStep();
  224. recipeStep.RecipeType = recipeType;
  225. recipeData.Add(recipeStep);
  226. XmlElement stepNode = stepNodeList[i] as XmlElement;
  227. Dictionary<string, string> dic = new Dictionary<string, string>();
  228. //遍历Step节点
  229. foreach (XmlAttribute att in stepNode.Attributes)
  230. {
  231. if (recipeAllowedCommands.Contains(att.Name))
  232. {
  233. dic.Add(att.Name, att.Value);
  234. }
  235. }
  236. //遍历Step子节点中所有的attribute属性节点
  237. foreach (XmlElement subStepNode in stepNode.ChildNodes)
  238. {
  239. foreach (XmlAttribute att in subStepNode.Attributes)
  240. {
  241. if (recipeAllowedCommands.Contains(att.Name))
  242. {
  243. dic.Add(att.Name, att.Value);
  244. }
  245. }
  246. //遍历Step子节点的子节点中所有的attribute属性节点
  247. foreach (XmlElement subsubStepNode in subStepNode.ChildNodes)
  248. {
  249. foreach (XmlAttribute att in subsubStepNode.Attributes)
  250. {
  251. if (recipeAllowedCommands.Contains(att.Name))
  252. {
  253. dic.Add(att.Name, att.Value);
  254. }
  255. }
  256. }
  257. }
  258. recipeStep.StepName = dic["Name"];
  259. if (dic["Name"] == strLoopEndStep)
  260. {
  261. recipeStep.IsLoopEndStep = true;
  262. strLoopEndStep = string.Empty;
  263. }
  264. recipeStep.IsJumpStep = false;
  265. if (dic.ContainsKey("Command"))
  266. {
  267. string commandStr = dic["Command"];
  268. if (commandStr.Contains("CallSystemRecipe"))
  269. {
  270. }
  271. else if (commandStr.ToUpper().StartsWith("CALL"))
  272. {
  273. int subTableID = 0;
  274. var subPara = commandStr.Replace("CALL", "").Replace("[", "").Replace("]", "").Split('*');
  275. if (subPara != null && subPara.Length > 1)
  276. {
  277. int.TryParse(subPara[0], out int loopCount);
  278. var tablePara = subPara[1].Split(':');
  279. if (tablePara != null && tablePara.Length > 1)
  280. {
  281. int.TryParse(tablePara[0], out subTableID);
  282. if (subTableID > 0)
  283. {
  284. recipeStep.IsCallSubStep = true;
  285. recipeStep.SubRecipeLoopCount = loopCount;
  286. }
  287. }
  288. recipeStep.SubRecipeTableInfo = subPara[1];
  289. }
  290. //sub需要修改table id
  291. List<RecipeStep> subRecipeData = null;
  292. if (recipeStep.IsCallSubStep && !Parse(recipeHead.SubRecipe, module, out var head, out subRecipeData, out reason, "Sub", subTableID, recipeHead))
  293. {
  294. return false;
  295. }
  296. if (subRecipeData == null || subRecipeData.Count == 0)
  297. {
  298. reason = $"Sub Recipe {commandStr.Replace("CallSubRecipe:", string.Empty)} is empty";
  299. return false;
  300. }
  301. recipeStep.SubRecipeSteps = subRecipeData;
  302. }
  303. else if (commandStr.ToUpper().StartsWith("LOOP"))
  304. {
  305. recipeStep.IsLoopEndStep = true;
  306. var loopPara = commandStr.Replace("LOOP", "").Replace("[", "").Replace("]", "").Split('*');
  307. if (loopPara != null && loopPara.Length > 1)
  308. {
  309. int.TryParse(loopPara[0], out int loopCount);
  310. recipeStep.LoopCount = loopCount + 1;//加1是因为第一次从正常的start-》end的执行算是一次循环,所以要额外加1
  311. int loopStartStep = -1;
  312. for (int index = 0; index < recipeData.Count; index++)
  313. {
  314. if (recipeData[index].StepName == loopPara[1])
  315. {
  316. loopStartStep = index;
  317. break;
  318. }
  319. }
  320. if (loopStartStep < 0)
  321. {
  322. reason = $"Recipe file does not contains LOOP step {loopPara[1]}";
  323. return false;
  324. }
  325. if (loopPara[1] != null)
  326. {
  327. if (loopStartStep < 0 ||
  328. (recipeType == "Process" && loopStartStep == 0))//Process recipe的standby不参与循环
  329. recipeStep.IsLoopEndStep = false;
  330. else
  331. {
  332. recipeStep.LoopStartStep = loopStartStep;
  333. if (recipeData.Count > loopStartStep)
  334. {
  335. recipeData[loopStartStep].IsLoopStartStep = true;
  336. recipeData[loopStartStep].LoopCount = loopCount + 1;
  337. recipeStep.LoopEndStep = recipeType == "Process" ? i + 1 : i;//Process recipe包含standby,从0开始;其他recipe不包含standby
  338. }
  339. }
  340. }
  341. }
  342. }
  343. else if (commandStr.ToUpper().StartsWith("JUMP"))
  344. {
  345. var jumpPara = commandStr.Replace("Jump:", string.Empty).Replace("[", "").Replace("]", "");//JumpStepNo
  346. if (jumpPara != null)
  347. {
  348. //int.TryParse(jumpPara[0], out int jumpStepNo);
  349. //recipeStep.JumpStepNo = recipeType == "Process" ? jumpStepNo : jumpStepNo - 1;//Process recipe包含standby,从0开始;其他recipe不包含standby
  350. recipeStep.IsJumpStep = true;
  351. recipeStep.JumpStepName = jumpPara;
  352. }
  353. }
  354. }
  355. if (dic.ContainsKey("AbortRecipeTableIndex"))
  356. {
  357. if (dic["AbortRecipeTableIndex"].ToLower() != "none")
  358. {
  359. //格式 1:name
  360. var abortPara = dic["AbortRecipeTableIndex"].Split(':');
  361. int abortTableID = 0;
  362. if (abortPara.Length > 1)
  363. {
  364. int.TryParse(abortPara[0], out abortTableID);
  365. List<RecipeStep> abortRecipeData = null;
  366. if (!Parse(recipeHead.AbortRecipe, module, out var head, out abortRecipeData, out reason, "Abort", abortTableID))
  367. {
  368. return false;
  369. }
  370. if (abortRecipeData == null || abortRecipeData.Count == 0)
  371. {
  372. reason = $"Abort Recipe {recipeHead.AbortRecipe}--{dic["AbortRecipeTableIndex"]} is empty";
  373. return false;
  374. }
  375. recipeStep.AbortRecipeSteps = abortRecipeData;
  376. recipeStep.AbortRecipeTableInfo = dic["AbortRecipeTableIndex"];
  377. }
  378. }
  379. else
  380. {
  381. recipeStep.AbortRecipeSteps = null;
  382. }
  383. }
  384. if (dic.ContainsKey("EventSetting"))
  385. {
  386. string eventSettingStr = dic["EventSetting"];
  387. if (eventSettingStr.ToLower() == "start")
  388. {
  389. recipeStep.IsTimeMeasurementStartStep = true;
  390. }
  391. else if (eventSettingStr.ToLower() == "stop")
  392. {
  393. recipeStep.IsTimeMeasurementStopStep = true;
  394. }
  395. }
  396. if (dic.ContainsKey("FilmThickFormula"))
  397. {
  398. recipeStep.FilmThickFormula = dic["FilmThickFormula"];
  399. }
  400. if (dic.ContainsKey("FilmThickCoefficientA"))
  401. {
  402. recipeStep.FilmThickCoefficientA = float.Parse(dic["FilmThickCoefficientA"]);
  403. }
  404. if (dic.ContainsKey("FilmThickCoefficientB"))
  405. {
  406. recipeStep.FilmThickCoefficientB = float.Parse(dic["FilmThickCoefficientB"]);
  407. }
  408. if (dic.ContainsKey("AlarmConditionTable"))
  409. {
  410. recipeStep.AlarmConditionTable = dic["AlarmConditionTable"];
  411. }
  412. for (int j = 1; j < 11; j++)
  413. {
  414. string tempType = "Ignore Alarm";
  415. string tempDetails = "";
  416. if (dic.ContainsKey($"AlarmAction.{j}"))
  417. {
  418. tempType = dic[$"AlarmAction.{j}"];
  419. }
  420. if (dic.ContainsKey($"AlarmDetails.{j}"))
  421. {
  422. tempDetails = dic[$"AlarmDetails.{j}"];
  423. }
  424. recipeStep.AlarmActionSets.Add(j, new AlarmActions()
  425. {
  426. ProcessingType = tempType,
  427. ProcessingDetails = tempDetails
  428. });
  429. }
  430. //if(dic.ContainsKey("Loop"))
  431. //{
  432. // string loopStr = dic["Loop"];
  433. // recipeStep.IsLoopStartStep = System.Text.RegularExpressions.Regex.Match(loopStr, @"Loop\x20\d+\s*$").Success;
  434. // recipeStep.IsLoopEndStep = System.Text.RegularExpressions.Regex.Match(loopStr, @"Loop End$").Success;
  435. // if (recipeStep.IsLoopStartStep)
  436. // recipeStep.LoopCount = Convert.ToInt32(loopStr.Replace("Loop", string.Empty));
  437. // else
  438. // recipeStep.LoopCount = 0;
  439. //}
  440. //recipe time
  441. if (dic["Name"].ToLower() == "standby")
  442. {
  443. if (DateTime.TryParse(dic["Time"], out DateTime time))
  444. {
  445. recipeStep.StepTime = time.Second + time.Minute * 60 + time.Hour * 3600 + time.Millisecond / 1000.0;
  446. }
  447. else if (float.TryParse(dic["Time"], out float timeInSec))
  448. {
  449. recipeStep.StepTime = timeInSec;
  450. recipeStep.EndBy = EnumEndByCondition.ByTime;
  451. }
  452. else
  453. {
  454. recipeStep.StepTime = 0;
  455. recipeStep.EndBy = EnumEndByCondition.ByStandbyFactor;
  456. }
  457. }
  458. else
  459. {
  460. if (System.Text.RegularExpressions.Regex.Match(dic["Time"], @"[a-zA-Z]").Success)
  461. {
  462. if (SC.ContainsItem($"{module}.RecipeEditParameter.StepTime.{dic["Time"]}"))
  463. {
  464. var time = DateTime.Parse(SC.GetStringValue($"{module}.RecipeEditParameter.StepTime.{dic["Time"]}"));
  465. recipeStep.StepTime = time.Second + time.Minute * 60 + time.Hour * 3600;
  466. }
  467. else
  468. {
  469. reason = $"Configuration does not contains step time config {dic["Time"]}";
  470. return false;
  471. }
  472. }
  473. else
  474. {
  475. if (DateTime.TryParse(dic["Time"], out DateTime time))
  476. {
  477. recipeStep.StepTime = time.Second + time.Minute * 60 + time.Hour * 3600 + time.Millisecond / 1000.0;
  478. }
  479. else if (float.TryParse(dic["Time"], out float timeInSec))
  480. {
  481. recipeStep.StepTime = timeInSec;
  482. }
  483. else
  484. {
  485. reason = $"Step time {dic["Time"]} is invalid";
  486. return false;
  487. }
  488. }
  489. if (dic["ConditionCheck"].ToLower() == "none")
  490. {
  491. recipeStep.EndBy = EnumEndByCondition.ByTime;
  492. }
  493. else
  494. {
  495. recipeStep.EndBy = EnumEndByCondition.ByStandbyFactor;
  496. }
  497. }
  498. //ReplaceControlName(ref dic, "GasLineMFC1.Flow", "MFC1.SetParameters");
  499. //ReplaceControlName(ref dic, "GasLineMFC2.Flow", "MFC2.SetParameters");
  500. //ReplaceControlName(ref dic, "GasLineMFC3.Flow", "MFC3.SetParameters");
  501. //ReplaceControlName(ref dic, "GasLineMFC4.Flow", "MFC4.SetParameters");
  502. //ReplaceControlName(ref dic, "GasLineMFC5.Flow", "MFC5.SetParameters");
  503. //ReplaceControlName(ref dic, "GasLineMFC6.Flow", "MFC6.SetParameters");
  504. //ReplaceControlName(ref dic, "GasLineMFC7.Flow", "MFC7.SetParameters");
  505. //ReplaceControlName(ref dic, "GasLineMFC8.Flow", "MFC8.SetParameters");
  506. //ReplaceControlName(ref dic, "GasLineMFC9.Flow", "MFC9.SetParameters");
  507. //ReplaceControlName(ref dic, "GasLineMFC10.Flow", "MFC10.SetParameters");
  508. //ReplaceControlName(ref dic, "GasLineMFC11.Flow", "MFC11.SetParameters");
  509. //ReplaceControlName(ref dic, "GasLineMFC12.Flow", "MFC12.SetParameters");
  510. //ReplaceControlName(ref dic, "GasLineMFC51.Flow", "MFC51.SetParameters");
  511. AddParameter(ref dic, "MFC1.SetParameters", new string[8] { "MFC1.Flow.Set", "MFC1.Flow.Ramprate", "MFC1.Flow.SetUnit", "MFC1.Flow.RamprateUnit", "MFC1.Flow.Check", "MFC1.Flow.High", "MFC1.Flow.Low", "MFC1.Flow.Unit" });
  512. AddParameter(ref dic, "MFC2.SetParameters", new string[8] { "MFC2.Flow.Set", "MFC2.Flow.Ramprate", "MFC2.Flow.SetUnit", "MFC2.Flow.RamprateUnit", "MFC2.Flow.Check", "MFC2.Flow.High", "MFC2.Flow.Low", "MFC2.Flow.Unit" });
  513. AddParameter(ref dic, "MFC3.SetParameters", new string[8] { "MFC3.Flow.Set", "MFC3.Flow.Ramprate", "MFC3.Flow.SetUnit", "MFC3.Flow.RamprateUnit", "MFC3.Flow.Check", "MFC3.Flow.High", "MFC3.Flow.Low", "MFC3.Flow.Unit" });
  514. AddParameter(ref dic, "MFC4.SetParameters", new string[8] { "MFC4.Flow.Set", "MFC4.Flow.Ramprate", "MFC4.Flow.SetUnit", "MFC4.Flow.RamprateUnit", "MFC4.Flow.Check", "MFC4.Flow.High", "MFC4.Flow.Low", "MFC4.Flow.Unit" });
  515. AddParameter(ref dic, "MFC5.SetParameters", new string[8] { "MFC5.Flow.Set", "MFC5.Flow.Ramprate", "MFC5.Flow.SetUnit", "MFC5.Flow.RamprateUnit", "MFC5.Flow.Check", "MFC5.Flow.High", "MFC5.Flow.Low", "MFC5.Flow.Unit" });
  516. AddParameter(ref dic, "MFC6.SetParameters", new string[8] { "MFC6.Flow.Set", "MFC6.Flow.Ramprate", "MFC6.Flow.SetUnit", "MFC6.Flow.RamprateUnit", "MFC6.Flow.Check", "MFC6.Flow.High", "MFC6.Flow.Low", "MFC6.Flow.Unit" });
  517. AddParameter(ref dic, "MFC7.SetParameters", new string[8] { "MFC7.Flow.Set", "MFC7.Flow.Ramprate", "MFC7.Flow.SetUnit", "MFC7.Flow.RamprateUnit", "MFC7.Flow.Check", "MFC7.Flow.High", "MFC7.Flow.Low", "MFC7.Flow.Unit" });
  518. AddParameter(ref dic, "MFC8.SetParameters", new string[8] { "MFC8.Flow.Set", "MFC8.Flow.Ramprate", "MFC8.Flow.SetUnit", "MFC8.Flow.RamprateUnit", "MFC8.Flow.Check", "MFC8.Flow.High", "MFC8.Flow.Low", "MFC8.Flow.Unit" });
  519. AddParameter(ref dic, "MFC9.SetParameters", new string[8] { "MFC9.Flow.Set", "MFC9.Flow.Ramprate", "MFC9.Flow.SetUnit", "MFC9.Flow.RamprateUnit", "MFC9.Flow.Check", "MFC9.Flow.High", "MFC9.Flow.Low", "MFC9.Flow.Unit" });
  520. AddParameter(ref dic, "MFC10.SetParameters", new string[8] { "MFC10.Flow.Set", "MFC10.Flow.Ramprate", "MFC10.Flow.SetUnit", "MFC10.Flow.RamprateUnit", "MFC10.Flow.Check", "MFC10.Flow.High", "MFC10.Flow.Low", "MFC10.Flow.Unit" });
  521. AddParameter(ref dic, "MFC11.SetParameters", new string[8] { "MFC11.Flow.Set", "MFC11.Flow.Ramprate", "MFC11.Flow.SetUnit", "MFC11.Flow.RamprateUnit", "MFC11.Flow.Check", "MFC11.Flow.High", "MFC11.Flow.Low", "MFC11.Flow.Unit" });
  522. AddParameter(ref dic, "MFC12.SetParameters", new string[8] { "MFC12.Flow.Set", "MFC12.Flow.Ramprate", "MFC12.Flow.SetUnit", "MFC12.Flow.RamprateUnit", "MFC12.Flow.Check", "MFC12.Flow.High", "MFC12.Flow.Low", "MFC12.Flow.Unit" });
  523. AddParameter(ref dic, "MFC13.SetParameters", new string[8] { "MFC13.Flow.Set", "MFC13.Flow.Ramprate", "MFC13.Flow.SetUnit", "MFC13.Flow.RamprateUnit", "MFC13.Flow.Check", "MFC13.Flow.High", "MFC13.Flow.Low", "MFC13.Flow.Unit" });
  524. AddParameter(ref dic, "MFC14.SetParameters", new string[8] { "MFC14.Flow.Set", "MFC14.Flow.Ramprate", "MFC14.Flow.SetUnit", "MFC14.Flow.RamprateUnit", "MFC14.Flow.Check", "MFC14.Flow.High", "MFC14.Flow.Low", "MFC14.Flow.Unit" });
  525. AddParameter(ref dic, "MFC15.SetParameters", new string[8] { "MFC15.Flow.Set", "MFC15.Flow.Ramprate", "MFC15.Flow.SetUnit", "MFC15.Flow.RamprateUnit", "MFC15.Flow.Check", "MFC15.Flow.High", "MFC15.Flow.Low", "MFC15.Flow.Unit" });
  526. AddParameter(ref dic, "MFC16.SetParameters", new string[8] { "MFC16.Flow.Set", "MFC16.Flow.Ramprate", "MFC16.Flow.SetUnit", "MFC16.Flow.RamprateUnit", "MFC16.Flow.Check", "MFC16.Flow.High", "MFC16.Flow.Low", "MFC16.Flow.Unit" });
  527. AddParameter(ref dic, "MFC17.SetParameters", new string[8] { "MFC17.Flow.Set", "MFC17.Flow.Ramprate", "MFC17.Flow.SetUnit", "MFC17.Flow.RamprateUnit", "MFC17.Flow.Check", "MFC17.Flow.High", "MFC17.Flow.Low", "MFC17.Flow.Unit" });
  528. AddParameter(ref dic, "MFC31.SetParameters", new string[8] { "MFC31.Flow.Set", "MFC31.Flow.Ramprate", "MFC31.Flow.SetUnit", "MFC31.Flow.RamprateUnit", "MFC31.Flow.Check", "MFC31.Flow.High", "MFC31.Flow.Low", "MFC31.Flow.Unit" });
  529. AddParameter(ref dic, "MFC32.SetParameters", new string[8] { "MFC32.Flow.Set", "MFC32.Flow.Ramprate", "MFC32.Flow.SetUnit", "MFC32.Flow.RamprateUnit", "MFC32.Flow.Check", "MFC32.Flow.High", "MFC32.Flow.Low", "MFC32.Flow.Unit" });
  530. //AddParameter(ref dic, "MFC51.SetParameters", new string[8] { "MFC51.Flow.Set", "MFC51.Flow.Ramprate", "MFC51.Flow.SetUnit", "MFC51.Flow.RamprateUnit", "MFC51.Flow.Check", "MFC51.Flow.High", "MFC51.Flow.Low", "MFC51.Flow.Unit" });
  531. ReplaceControlName(ref dic, "MFM57Flow", "MFM57.SetParameters");
  532. ReplaceControlName(ref dic, "MFM1Flow", "MFM1.SetParameters");
  533. ReplaceControlName(ref dic, "MFM6Flow", "MFM6.SetParameters");
  534. ReplaceControlName(ref dic, "MFM7Flow", "MFM7.SetParameters");
  535. ReplaceControlName(ref dic, "MFM8Flow", "MFM8.SetParameters");
  536. ReplaceControlName(ref dic, "MFM9Flow", "MFM9.SetParameters");
  537. ReplaceControlName(ref dic, "MFM11Flow", "MFM11.SetParameters");
  538. ReplaceControlName(ref dic, "MFM12Flow", "MFM12.SetParameters");
  539. ReplaceControlName(ref dic, "MFM13Flow", "MFM13.SetParameters");
  540. ReplaceControlName(ref dic, "MFM16Flow", "MFM16.SetParameters");
  541. ReplaceControlName(ref dic, "ConditionCheck", "SetConditionCheck");
  542. ReplaceControlName(ref dic, "Command", "SetCommand");
  543. if (dic.ContainsKey("AlarmConditionTable"))
  544. ReplaceControlName(ref dic, "AlarmConditionTable", "SetAlarmConditionTable");
  545. //ReplaceControlName(ref dic, "Heater2", "ZoneU.SetParameters");
  546. //ReplaceControlName(ref dic, "Heater4", "ZoneCU.SetParameters");
  547. //ReplaceControlName(ref dic, "Heater6", "ZoneC.SetParameters");
  548. //ReplaceControlName(ref dic, "Heater8", "ZoneCL.SetParameters");
  549. //ReplaceControlName(ref dic, "Heater10", "ZoneL.SetParameters");
  550. var controlMode = dic["Temperature.ControlMode"];
  551. var correct = dic["Temperature.Correct"];
  552. var PID = dic["Temperature.PID"];
  553. //AddParameter(ref dic, "ZoneU.SetParameters", controlMode, correct, PID);
  554. //AddParameter(ref dic, "ZoneCU.SetParameters", controlMode, correct, PID);
  555. //AddParameter(ref dic, "ZoneC.SetParameters", controlMode, correct, PID);
  556. //AddParameter(ref dic, "ZoneCL.SetParameters", controlMode, correct, PID);
  557. //AddParameter(ref dic, "ZoneL.SetParameters", controlMode, correct, PID);
  558. AddParameter(ref dic, "HeaterU.SetParameters", new string[9] { "HeaterU.ZoneName", "HeaterU.Set", "HeaterU.SetUnit", "HeaterU.Ramprate", "HeaterU.RamprateUnit", "HeaterU.Check", "HeaterU.High", "HeaterU.Low", "HeaterU.Unit" });
  559. AddParameterValue(ref dic, "HeaterU.SetParameters", new string[8] { controlMode, correct, PID, recipeHead.TempCorrect, recipeHead.TempPID, recipeHead.ProfileCondition, dic["ValveAV91"], dic["BWR"] });
  560. AddParameter(ref dic, "HeaterCU.SetParameters", new string[9] { "HeaterCU.ZoneName", "HeaterCU.Set", "HeaterCU.SetUnit", "HeaterCU.Ramprate", "HeaterCU.RamprateUnit", "HeaterCU.Check", "HeaterCU.High", "HeaterCU.Low", "HeaterCU.Unit" });
  561. AddParameterValue(ref dic, "HeaterCU.SetParameters", new string[8] { controlMode, correct, PID, recipeHead.TempCorrect, recipeHead.TempPID, recipeHead.ProfileCondition, dic["ValveAV91"], dic["BWR"] });
  562. AddParameter(ref dic, "HeaterC.SetParameters", new string[9] { "HeaterC.ZoneName", "HeaterC.Set", "HeaterC.SetUnit", "HeaterC.Ramprate", "HeaterC.RamprateUnit", "HeaterC.Check", "HeaterC.High", "HeaterC.Low", "HeaterC.Unit" });
  563. AddParameterValue(ref dic, "HeaterC.SetParameters", new string[8] { controlMode, correct, PID, recipeHead.TempCorrect, recipeHead.TempPID, recipeHead.ProfileCondition, dic["ValveAV91"], dic["BWR"] });
  564. AddParameter(ref dic, "HeaterCL.SetParameters", new string[9] { "HeaterCL.ZoneName", "HeaterCL.Set", "HeaterCL.SetUnit", "HeaterCL.Ramprate", "HeaterCL.RamprateUnit", "HeaterCL.Check", "HeaterCL.High", "HeaterCL.Low", "HeaterCL.Unit" });
  565. AddParameterValue(ref dic, "HeaterCL.SetParameters", new string[8] { controlMode, correct, PID, recipeHead.TempCorrect, recipeHead.TempPID, recipeHead.ProfileCondition, dic["ValveAV91"], dic["BWR"] });
  566. AddParameter(ref dic, "HeaterL.SetParameters", new string[9] { "HeaterL.ZoneName", "HeaterL.Set", "HeaterL.SetUnit", "HeaterL.Ramprate", "HeaterL.RamprateUnit", "HeaterL.Check", "HeaterL.High", "HeaterL.Low", "HeaterL.Unit" });
  567. AddParameterValue(ref dic, "HeaterL.SetParameters", new string[8] { controlMode, correct, PID, recipeHead.TempCorrect, recipeHead.TempPID, recipeHead.ProfileCondition, dic["ValveAV91"], dic["BWR"] });
  568. AddParameter(ref dic, "APC.SetParameters", new string[10] { "Press.Command", "Press.PID", "Press.Set", "Press.SlowVacSet", "Press.ValveAngleSet", "Press.IsWait", "Press.LowWait", "Press.HighWait", "Press.WaitUnit", "Press.WaitPress" });//APC
  569. AddParameterValue(ref dic, "APC.SetParameters", new string[2] { recipeHead.PressApcPID, dic["ValveAV71"] });//APC
  570. AddParameter(ref dic, "SetBoatMotion", new string[5] { "Loader.Command", "Loader.Speed1", "Loader.Speed2", "Loader.Speed3", "Loader.RPM" });//Boat
  571. List<string> auxCommands = new List<string>();
  572. for (int k = 1; k < 200; k++)
  573. {
  574. if (!dic.ContainsKey($"AUX.{k}.Set"))
  575. continue;
  576. auxCommands.Add($"{k},{dic[$"AUX.{k}.Set"]},{dic[$"AUX.{k}.Check"]},{dic[$"AUX.{k}.High"]},{dic[$"AUX.{k}.Low"]},{dic[$"AUX.{k}.CheckUnit"]}");
  577. dic.Remove($"AUX.{k}.Set");
  578. dic.Remove($"AUX.{k}.Check");
  579. dic.Remove($"AUX.{k}.High");
  580. dic.Remove($"AUX.{k}.Low");
  581. dic.Remove($"AUX.{k}.CheckUnit");
  582. }
  583. dic.Add("AUX.SetParameters", string.Join(";", auxCommands));
  584. //ReplaceControlName(ref dic, "RFSwitch", "RfPower.SetParameters");
  585. //AddParameter(ref dic, "RfPower.SetParameters", dic["RFSetpoint"], dic["ForwardPowerAlarmWatchTable"], dic["PrAlarmWatchTable"], dic["PIAlarmWatchTable"]);
  586. //ReplaceControlName(ref dic, "C1Setpoint", "RfMatch.SetParameters");
  587. //AddParameter(ref dic, "RfMatch.SetParameters", dic["C2Setpoint"], dic["C1AlarmWatchTable"], dic["C2AlarmWatchTable"], dic["VppAlarmWatchTable"]);
  588. AddValveParameter(ref dic, "SetValves", new string[159] {
  589. "ValveAV1",
  590. "ValveAV2",
  591. "ValveAV3",
  592. "ValveAV4",
  593. "ValveAV5",
  594. "ValveAV6",
  595. "ValveAV7",
  596. "ValveAV8",
  597. "ValveAV9",
  598. "ValveAV10",
  599. "ValveAV11",
  600. "ValveAV12",
  601. "ValveAV13",
  602. "ValveAV14",
  603. "ValveAV15",
  604. "ValveAV16",
  605. "ValveAV17",
  606. "ValveAV18",
  607. "ValveAV19",
  608. "ValveAV20",
  609. "ValveAV21",
  610. "ValveAV22",
  611. "ValveAV23",
  612. "ValveAV24",
  613. "ValveAV25",
  614. "ValveAV26",
  615. "ValveAV27",
  616. "ValveAV28",
  617. "ValveAV29",
  618. "ValveAV30",
  619. "ValveAV31",
  620. "ValveAV32",
  621. "ValveAV33",
  622. "ValveAV34",
  623. "ValveAV35",
  624. "ValveAV36",
  625. "ValveAV37",
  626. "ValveAV38",
  627. "ValveAV39",
  628. "ValveAV40",
  629. "ValveAV41",
  630. "ValveAV42",
  631. "ValveAV43",
  632. "ValveAV44",
  633. "ValveAV45",
  634. "ValveAV46",
  635. "ValveAV47",
  636. "ValveAV48",
  637. "ValveAV49",
  638. "ValveAV50",
  639. "ValveAV51",
  640. "ValveAV52",
  641. "ValveAV53",
  642. "ValveAV54",
  643. "ValveAV55",
  644. "ValveAV56",
  645. "ValveAV57",
  646. "ValveAV58",
  647. "ValveAV59",
  648. "ValveAV60",
  649. "ValveAV61",
  650. "ValveAV62",
  651. "ValveAV63",
  652. "ValveAV64",
  653. "ValveAV65",
  654. "ValveAV66",
  655. "ValveAV67",
  656. "ValveAV68",
  657. "ValveAV69",
  658. "ValveAV70",
  659. "ValveAV71",
  660. "ValveAV72",
  661. "ValveAV73",
  662. "ValveAV74",
  663. "ValveAV75",
  664. "ValveAV76",
  665. "ValveAV77",
  666. "ValveAV78",
  667. "ValveAV79",
  668. "ValveAV80",
  669. "ValveAV81",
  670. "ValveAV82",
  671. "ValveAV83",
  672. "ValveAV84",
  673. "ValveAV85",
  674. "ValveAV86",
  675. "ValveAV87",
  676. "ValveAV88",
  677. "ValveAV89",
  678. "ValveAV90",
  679. "ValveAV91",
  680. "ValveAV92",
  681. "ValveAV93",
  682. "ValveAV94",
  683. "ValveAV95",
  684. "ValveAV96",
  685. "ValveAV97",
  686. "ValveAV98",
  687. "ValveAV99",
  688. "ValveAV100",
  689. "ValveAV101",
  690. "ValveAV102",
  691. "ValveAV103",
  692. "ValveAV104",
  693. "ValveAV105",
  694. "ValveAV106",
  695. "ValveAV107",
  696. "ValveAV108",
  697. "ValveAV109",
  698. "ValveAV110",
  699. "ValveAV111",
  700. "ValveAV112",
  701. "ValveAV113",
  702. "ValveAV114",
  703. "ValveAV115",
  704. "ValveAV116",
  705. "ValveAV117",
  706. "ValveAV118",
  707. "ValveAV119",
  708. "ValveAV120",
  709. "ValveAV121",
  710. "ValveAV122",
  711. "ValveAV123",
  712. "ValveAV124",
  713. "ValveAV125",
  714. "ValveAV126",
  715. "ValveAV127",
  716. "ValveAV128",
  717. "ValveAV129",
  718. "ValveAV130",
  719. "ValveAV131",
  720. "ValveAV132",
  721. "ValveAV133",
  722. "ValveAV134",
  723. "ValveAV135",
  724. "ValveAV136",
  725. "DPR",
  726. "AGV",
  727. "AGV2",
  728. "MBP",
  729. "MBP1",
  730. "MBP2",
  731. "DP",
  732. "BWR",
  733. "F2Cln",
  734. "HFCln",
  735. "CEXH",
  736. "DEPO",
  737. "HTR1",
  738. "HTR2",
  739. "HTR3",
  740. "DP1",
  741. "DP2",
  742. "HMNT",
  743. "CMNT",
  744. "HREF",
  745. "CREF",
  746. "HZERO",
  747. "CZERO"
  748. });
  749. //dic.Remove("SetValves");
  750. //dic.Remove("HeaterU.SetParameters");
  751. //dic.Remove("HeaterCU.SetParameters");
  752. //dic.Remove("HeaterC.SetParameters");
  753. //dic.Remove("HeaterCL.SetParameters");
  754. //dic.Remove("HeaterL.SetParameters");
  755. //dic.Remove("MFC1.SetParameters");
  756. //dic.Remove("MFC2.SetParameters");
  757. //dic.Remove("MFC3.SetParameters");
  758. //dic.Remove("MFC4.SetParameters");
  759. //dic.Remove("MFC5.SetParameters");
  760. //dic.Remove("MFC6.SetParameters");
  761. //dic.Remove("MFC7.SetParameters");
  762. //dic.Remove("MFC8.SetParameters");
  763. //dic.Remove("MFC9.SetParameters");
  764. //dic.Remove("MFC10.SetParameters");
  765. //dic.Remove("MFC11.SetParameters");
  766. //dic.Remove("MFC12.SetParameters");
  767. //ReplaceControlNameForValve(ref dic, "ValveAV1");
  768. //ReplaceControlNameForValve(ref dic, "ValveAV2");
  769. //ReplaceControlNameForValve(ref dic, "ValveAV3");
  770. //ReplaceControlNameForValve(ref dic, "ValveAV4");
  771. //ReplaceControlNameForValve(ref dic, "ValveAV5");
  772. //ReplaceControlNameForValve(ref dic, "ValveAV6");
  773. //ReplaceControlNameForValve(ref dic, "ValveAV7");
  774. //ReplaceControlNameForValve(ref dic, "ValveAV8");
  775. //ReplaceControlNameForValve(ref dic, "ValveAV9");
  776. //ReplaceControlNameForValve(ref dic, "ValveAV10");
  777. //ReplaceControlNameForValve(ref dic, "ValveAV11");
  778. //ReplaceControlNameForValve(ref dic, "ValveAV12");
  779. //ReplaceControlNameForValve(ref dic, "ValveAV13");
  780. //ReplaceControlNameForValve(ref dic, "ValveAV14");
  781. //ReplaceControlNameForValve(ref dic, "ValveAV15");
  782. //ReplaceControlNameForValve(ref dic, "ValveAV16");
  783. //ReplaceControlNameForValve(ref dic, "ValveAV17");
  784. //ReplaceControlNameForValve(ref dic, "ValveAV18");
  785. //ReplaceControlNameForValve(ref dic, "ValveAV19");
  786. //ReplaceControlNameForValve(ref dic, "ValveAV20");
  787. //ReplaceControlNameForValve(ref dic, "ValveAV21");
  788. //ReplaceControlNameForValve(ref dic, "ValveAV22");
  789. //ReplaceControlNameForValve(ref dic, "ValveAV23");
  790. //ReplaceControlNameForValve(ref dic, "ValveAV24");
  791. //ReplaceControlNameForValve(ref dic, "ValveAV25");
  792. //ReplaceControlNameForValve(ref dic, "ValveAV26");
  793. //ReplaceControlNameForValve(ref dic, "ValveAV27");
  794. //ReplaceControlNameForValve(ref dic, "ValveAV28");
  795. //ReplaceControlNameForValve(ref dic, "ValveAV29");
  796. //ReplaceControlNameForValve(ref dic, "ValveAV30");
  797. //ReplaceControlNameForValve(ref dic, "ValveAV31");
  798. //ReplaceControlNameForValve(ref dic, "ValveAV32");
  799. //ReplaceControlNameForValve(ref dic, "ValveAV33");
  800. //ReplaceControlNameForValve(ref dic, "ValveAV34");
  801. //ReplaceControlNameForValve(ref dic, "ValveAV35");
  802. //ReplaceControlNameForValve(ref dic, "ValveAV36");
  803. //ReplaceControlNameForValve(ref dic, "ValveAV37");
  804. //ReplaceControlNameForValve(ref dic, "ValveAV38");
  805. //ReplaceControlNameForValve(ref dic, "ValveAV39");
  806. //ReplaceControlNameForValve(ref dic, "ValveAV52");
  807. ////ReplaceControlNameForValve(ref dic, "ValveAV54");
  808. ////ReplaceControlNameForValve(ref dic, "ValveAV56");
  809. ////ReplaceControlNameForValve(ref dic, "ValveAV57");
  810. ////ReplaceControlNameForValve(ref dic, "ValveAV58");
  811. ////ReplaceControlNameForValve(ref dic, "ValveAV59");
  812. //ReplaceControlNameForValve(ref dic, "ValveAV60");
  813. ////ReplaceControlNameForValve(ref dic, "ValveAV65");
  814. ////ReplaceControlNameForValve(ref dic, "ValveAV66");
  815. ////ReplaceControlNameForValve(ref dic, "ValveAV68");
  816. //ReplaceControlNameForValve(ref dic, "ValveAV71");
  817. //ReplaceControlNameForValve(ref dic, "ValveAV72");
  818. //ReplaceControlNameForValve(ref dic, "ValveAV73");
  819. //ReplaceControlNameForValve(ref dic, "ValveAV74");
  820. //ReplaceControlNameForValve(ref dic, "ValveAV75");
  821. //ReplaceControlNameForValve(ref dic, "ValveAV77");
  822. //ReplaceControlNameForValve(ref dic, "ValveAV81");
  823. //ReplaceControlNameForValve(ref dic, "ValveAV82");
  824. //ReplaceControlNameForValve(ref dic, "ValveAV83");
  825. //ReplaceControlNameForValve(ref dic, "ValveAV91");
  826. dic.Remove("StepNo");
  827. dic.Remove("Name");
  828. dic.Remove("EndBy");
  829. dic.Remove("Time");
  830. dic.Remove("ZAxisPosition");
  831. dic.Remove("ZAxisSpeed");
  832. dic.Remove("RotatePosition");
  833. dic.Remove("RotateSpeed");
  834. dic.Remove("RotateDirection");
  835. dic.Remove("Heater1");
  836. dic.Remove("Heater2");
  837. dic.Remove("Heater3");
  838. dic.Remove("Heater4");
  839. dic.Remove("Heater5");
  840. dic.Remove("ValveAV54");
  841. dic.Remove("ValveAV56");
  842. dic.Remove("ValveAV57");
  843. dic.Remove("ValveAV58");
  844. dic.Remove("ValveAV59");
  845. dic.Remove("ValveAV65");
  846. dic.Remove("ValveAV66");
  847. dic.Remove("ValveAV68");
  848. dic.Remove("ExternalOn");
  849. dic.Remove("ExternalOff");
  850. dic.Remove("ExternalSensor");
  851. dic.Remove("TempStabilize");
  852. dic.Remove("FinishAutoProfile");
  853. dic.Remove("ReachTempWait");
  854. dic.Remove("ReachTemp");
  855. dic.Remove("TempUpper");
  856. dic.Remove("TempLower");
  857. dic.Remove("ReachPressureWait");
  858. dic.Remove("ReachPressure");
  859. dic.Remove("PressureUpper");
  860. dic.Remove("PressureLower");
  861. dic.Remove("PressureStabilize");
  862. dic.Remove("External.Out1");
  863. dic.Remove("External.Out2");
  864. dic.Remove("External.Out3");
  865. dic.Remove("External.Out4");
  866. dic.Remove("External.Out5");
  867. dic.Remove("External.Out6");
  868. dic.Remove("RFSwitch");
  869. dic.Remove("RFSetpoint");
  870. dic.Remove("ForwardPowerAlarmWatchTable");
  871. dic.Remove("PrAlarmWatchTable");
  872. dic.Remove("PIAlarmWatchTable");
  873. dic.Remove("C1Setpoint");
  874. dic.Remove("C2Setpoint");
  875. dic.Remove("C1AlarmWatchTable");
  876. dic.Remove("C2AlarmWatchTable");
  877. dic.Remove("VppAlarmWatchTable");
  878. dic.Remove("VdcAlarmWatchTable");
  879. dic.Remove("AbortRecipeTableIndex");
  880. dic.Remove("Temperature.ControlMode");
  881. dic.Remove("Temperature.Correct");
  882. dic.Remove("Temperature.PID");
  883. dic.Remove("Temperature.Profile");
  884. dic.Remove("Temperature.Stabilize");
  885. dic.Remove("Temperature.TempReadyCond");
  886. dic.Remove("FilmThickFormula");
  887. dic.Remove("FilmThickCoefficientA");
  888. dic.Remove("FilmThickCoefficientB");
  889. dic.Remove("APC.SetPressure");
  890. dic.Remove("PressureSettingVG");
  891. dic.Remove("PressureSonserValue");
  892. dic.Remove("PressureValveAngle");
  893. dic.Remove("PressureAlarmTableNo");
  894. dic.Remove("EventSetting");
  895. dic.Remove("AlarmTableIndex");
  896. dic.Remove("AlarmDetails.1");
  897. dic.Remove("AlarmAction.1");
  898. dic.Remove("AlarmDetails.2");
  899. dic.Remove("AlarmAction.2");
  900. dic.Remove("AlarmDetails.3");
  901. dic.Remove("AlarmAction.3");
  902. dic.Remove("AlarmDetails.4");
  903. dic.Remove("AlarmAction.4");
  904. dic.Remove("AlarmDetails.5");
  905. dic.Remove("AlarmAction.5");
  906. dic.Remove("AlarmDetails.6");
  907. dic.Remove("AlarmAction.6");
  908. dic.Remove("AlarmDetails.7");
  909. dic.Remove("AlarmAction.7");
  910. dic.Remove("AlarmDetails.8");
  911. dic.Remove("AlarmAction.8");
  912. dic.Remove("AlarmDetails.9");
  913. dic.Remove("AlarmAction.9");
  914. dic.Remove("AlarmDetails.10");
  915. dic.Remove("AlarmAction.10");
  916. //List<string> mfcCheckInstall = new List<string>()
  917. //{
  918. // "MfcN1",
  919. // "MfcN2",
  920. // "MfcN3",
  921. // "MfcH1",
  922. // "MfcJ1",
  923. // "MfcXN1",
  924. //};
  925. //foreach(var mfc in mfcCheckInstall)
  926. //{
  927. // if (!SC.GetValue<bool>($"PM1.MFC.{mfc}.IsMFCInstalled"))
  928. // dic.Remove($"{mfc}.SetParameters");
  929. //}
  930. foreach (string key in dic.Keys)
  931. recipeStep.RecipeCommands.Add(key, dic[key]);
  932. }
  933. for (int i = 0; i < recipeData.Count; i++)
  934. {
  935. if (recipeData[i].IsJumpStep)
  936. {
  937. bool findJumpStep = false;
  938. for (int j = 0; j < recipeData.Count; j++)
  939. {
  940. if (recipeData[j].StepName == recipeData[i].JumpStepName)
  941. {
  942. recipeData[i].JumpStepNo = j;
  943. findJumpStep = true;
  944. break;
  945. }
  946. }
  947. if (!findJumpStep)
  948. {
  949. reason = $"Recipe file does not contains jump step {recipeData[i].JumpStepName}";
  950. return false;
  951. }
  952. }
  953. }
  954. }
  955. catch (Exception ex)
  956. {
  957. LOG.Write(ex);
  958. reason = $"Recipe file content not valid, {recipeFile}, {ex.Message}";
  959. return false;
  960. }
  961. return true;
  962. }
  963. public static bool LayoutRecipeParse(string recipeFile, string module, out RecipeLayoutEntityNormal layoutRecipeDataNormal, out RecipeLayoutEntityExpert layoutRecipeDataExpert, out string reason)
  964. {
  965. reason = string.Empty;
  966. layoutRecipeDataNormal = new RecipeLayoutEntityNormal();
  967. layoutRecipeDataExpert = new RecipeLayoutEntityExpert();
  968. string content = RecipeFileManager.Instance.LoadRecipe($"{SC.GetStringValue("System.Recipe.SupportedChamberType")}\\{SC.GetStringValue("System.Recipe.SupportedLayoutType")}", recipeFile, false);
  969. if (string.IsNullOrEmpty(content))
  970. {
  971. reason = $"{recipeFile} is not a valid recipe file";
  972. return false;
  973. }
  974. try
  975. {
  976. XmlDocument rcpDataDoc = new XmlDocument();
  977. rcpDataDoc.LoadXml(content);
  978. XmlNode nodeModule;
  979. nodeModule = rcpDataDoc.SelectSingleNode("/Aitex/TableRecipeData/Module/Step[@Name='Normal']");
  980. if (nodeModule == null)
  981. {
  982. //reason = "Recipe file does not contains step content for Normal";
  983. return false;
  984. }
  985. else
  986. {
  987. Type t = layoutRecipeDataNormal.GetType();
  988. foreach (FieldInfo pi in t.GetFields())
  989. {
  990. XmlElement stepNode = nodeModule as XmlElement;
  991. //遍历Step节点
  992. foreach (XmlAttribute att in stepNode.Attributes)
  993. {
  994. if (pi.Name == att.Name)
  995. {
  996. pi.SetValue(layoutRecipeDataNormal, att.Value);
  997. }
  998. }
  999. }
  1000. }
  1001. nodeModule = rcpDataDoc.SelectSingleNode("/Aitex/TableRecipeData/Module/Step[@Name='Expert']");
  1002. if (nodeModule == null)
  1003. {
  1004. //reason = "Recipe file does not contains step content for Expert";
  1005. return false;
  1006. }
  1007. else
  1008. {
  1009. XmlElement stepNode = nodeModule as XmlElement;
  1010. string strName = "";
  1011. //遍历Step节点
  1012. foreach (XmlAttribute att in stepNode.Attributes)
  1013. {
  1014. if (att.Name != "Name")
  1015. {
  1016. layoutRecipeDataExpert.Items.Add(att.Value);
  1017. }
  1018. else
  1019. {
  1020. strName = att.Value;
  1021. }
  1022. }
  1023. layoutRecipeDataExpert.Name = strName;
  1024. }
  1025. }
  1026. catch (Exception ex)
  1027. {
  1028. LOG.Write(ex);
  1029. reason = $"Recipe file content not valid, {recipeFile}, {ex.Message}";
  1030. return false;
  1031. }
  1032. return true;
  1033. }
  1034. private static void ReplaceControlName(ref Dictionary<string, string> dic, string from, string to)
  1035. {
  1036. if (dic.ContainsKey(from))
  1037. {
  1038. dic.Add(to, dic[from]);
  1039. dic.Remove(from);
  1040. }
  1041. }
  1042. private static void ReplaceControlName(ref Dictionary<string, string> dic, string from, string to1, string to2)
  1043. {
  1044. dic.Add(to1, dic[from]);
  1045. dic.Add(to2, dic[from]);
  1046. dic.Remove(from);
  1047. }
  1048. private static void ReplaceControlNameForValve(ref Dictionary<string, string> dic, string key)
  1049. {
  1050. switch (dic[key].ToLower())
  1051. {
  1052. case "open":
  1053. dic[key] = "true";
  1054. break;
  1055. case "close":
  1056. dic[key] = "false";
  1057. break;
  1058. case "continue":
  1059. dic[key] = "Continue";
  1060. break;
  1061. }
  1062. //dic[key] = dic[key].ToLower() == "open" ? "true" : "false";
  1063. }
  1064. private static void AddValveParameter(ref Dictionary<string, string> dic, string to, string[] param)
  1065. {
  1066. if (param != null && param.Length > 0)
  1067. {
  1068. foreach (var item in param)
  1069. {
  1070. if (!string.IsNullOrEmpty(item) && dic.ContainsKey(item))
  1071. {
  1072. if (!dic.ContainsKey(to))
  1073. dic.Add(to, "");
  1074. var set = "";
  1075. switch (dic[item].ToLower())
  1076. {
  1077. case "open":
  1078. set = "true";
  1079. break;
  1080. case "close":
  1081. set = "false";
  1082. break;
  1083. case "continue":
  1084. set = "Continue";
  1085. break;
  1086. }
  1087. var value = $"{dic[to]};{item},{set}";
  1088. dic[to] = string.IsNullOrEmpty(dic[to]) ? $"{item},{set}" : value;
  1089. dic.Remove(item);
  1090. }
  1091. }
  1092. }
  1093. }
  1094. private static void AddParameter(ref Dictionary<string, string> dic, string to, string from1, string from2, string from3, string from4 = null)
  1095. {
  1096. var value = $"{dic[to]};{from1};{from2};{from3}";
  1097. if (!string.IsNullOrEmpty(from4))
  1098. value = $"{value};{from4}";
  1099. dic[to] = value;
  1100. }
  1101. private static void AddParameter(ref Dictionary<string, string> dic, string to, string[] param)
  1102. {
  1103. if (param != null && param.Length > 0)
  1104. {
  1105. foreach (var item in param)
  1106. {
  1107. if (!string.IsNullOrEmpty(item) && dic.ContainsKey(item))
  1108. {
  1109. if (!dic.ContainsKey(to))
  1110. dic.Add(to, "");
  1111. var value = $"{dic[to]};{dic[item]}";
  1112. dic[to] = string.IsNullOrEmpty(dic[to]) ? dic[item] : value;
  1113. dic.Remove(item);
  1114. }
  1115. }
  1116. }
  1117. }
  1118. private static void AddParameterValue(ref Dictionary<string, string> dic, string to, string[] param)
  1119. {
  1120. if (!dic.ContainsKey(to))
  1121. dic.Add(to, "");
  1122. if (param != null && param.Length > 0)
  1123. {
  1124. foreach (var item in param)
  1125. {
  1126. var value = $"{dic[to]};{item}";
  1127. dic[to] = string.IsNullOrEmpty(dic[to]) ? item : value;
  1128. }
  1129. }
  1130. }
  1131. }
  1132. }