RecipeParser.cs 64 KB

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