LeakCheckConditionParameterData.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. using Aitex.Core.RT.Log;
  2. using Aitex.Core.RT.ParameterCenter;
  3. using Caliburn.Micro.Core;
  4. using MECF.Framework.Common.ParameterCenter;
  5. using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
  6. using RecipeEditorLib.RecipeModel.Params;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Collections.ObjectModel;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows;
  14. using System.Xml;
  15. namespace MECF.Framework.UI.Client.CenterViews.Parameter
  16. {
  17. public class LeakCheckConditionParameterData : ParameterDataBase
  18. {
  19. private ParameterProvider _parameterProvider = new ParameterProvider();
  20. private ParameterFormatBuilder _columnBuilder = new ParameterFormatBuilder();
  21. private Dictionary<string, ObservableCollection<ParameterTemplateColumnBase>> ParameterTemplate;
  22. public LeakCheckConditionParameterData() : base()
  23. {
  24. string vars = _parameterProvider.GetParameterFormatXml($"Parameter\\LeakCheckCondition");
  25. _columnBuilder.Build($"Parameter\\LeakCheckCondition");
  26. ParameterTemplate = _parameterProvider.GetGroupParameterTemplate();
  27. TableNumber = _columnBuilder.TableNumber;
  28. Version = _columnBuilder.Version;
  29. for (int i = 1; i < TableNumber+1; i++)
  30. {
  31. Steps.Add(CreateStep());
  32. }
  33. }
  34. public override ParameterTable CreateStep(XmlNode stepNode = null)
  35. {
  36. ParameterTable table = new LeakCheckConditionTable();
  37. var step = table as LeakCheckConditionTable;
  38. if (stepNode != null)
  39. {
  40. if (stepNode.Attributes["StepNo"] != null)
  41. step.StepNo = int.Parse(stepNode.Attributes["StepNo"].Value);
  42. if (stepNode.Attributes["Name"] != null)
  43. step.Name = stepNode.Attributes["Name"].Value;
  44. }
  45. else
  46. {
  47. step.StepNo = StepNo;
  48. step.Name = "Name" + StepNo.ToString();
  49. //step.UseTemp = "0";
  50. StepNo++;
  51. }
  52. foreach (var item in ParameterTemplate)
  53. {
  54. if (item.Key != "Parameter Information")
  55. {
  56. var pHHighLimitcom = item.Value.Where(x => x.ControlName == "PHHighLimit").FirstOrDefault();
  57. if (pHHighLimitcom != null)
  58. {
  59. DoubleParam pHHighLimitParam = new DoubleParam()
  60. {
  61. Name = pHHighLimitcom.ControlName,
  62. Value = pHHighLimitcom.Value.ToString(),
  63. DisplayName = pHHighLimitcom.DisplayName,
  64. Minimun = pHHighLimitcom.Minimun,
  65. Maximun = pHHighLimitcom.Maximun,
  66. Resolution = 0
  67. };
  68. step.PHHighLimit= pHHighLimitParam;
  69. }
  70. var pLLowLimitcom = item.Value.Where(x => x.ControlName == "PLLowLimit").FirstOrDefault();
  71. if (pLLowLimitcom != null)
  72. {
  73. DoubleParam pLLowLimitParam = new DoubleParam()
  74. {
  75. Name = pLLowLimitcom.ControlName,
  76. Value = pLLowLimitcom.Value.ToString(),
  77. DisplayName = pLLowLimitcom.DisplayName,
  78. Minimun = pLLowLimitcom.Minimun,
  79. Maximun = pLLowLimitcom.Maximun,
  80. Resolution = 0
  81. };
  82. step.PLLowLimit = pLLowLimitParam;
  83. }
  84. var bPLimitcom = item.Value.Where(x => x.ControlName == "BPLimit").FirstOrDefault();
  85. if (bPLimitcom != null)
  86. {
  87. DoubleParam bPLimitParam = new DoubleParam()
  88. {
  89. Name = bPLimitcom.ControlName,
  90. Value = bPLimitcom.Value.ToString(),
  91. DisplayName = bPLimitcom.DisplayName,
  92. Minimun = bPLimitcom.Minimun,
  93. Maximun = bPLimitcom.Maximun,
  94. Resolution = 0
  95. };
  96. step.BPLimit = bPLimitParam;
  97. }
  98. var leakLimitcom = item.Value.Where(x => x.ControlName == "LeakLimit").FirstOrDefault();
  99. if (leakLimitcom != null)
  100. {
  101. DoubleParam leakLimitParam = new DoubleParam()
  102. {
  103. Name = leakLimitcom.ControlName,
  104. Value = leakLimitcom.Value.ToString(),
  105. DisplayName = leakLimitcom.DisplayName,
  106. Minimun = leakLimitcom.Minimun,
  107. Maximun = leakLimitcom.Maximun,
  108. Resolution = 0
  109. };
  110. step.LeakLimit = leakLimitParam;
  111. }
  112. var retryLimitcom = item.Value.Where(x => x.ControlName == "RetryLimit").FirstOrDefault();
  113. if (leakLimitcom != null)
  114. {
  115. NumParam retryLimitParam = new NumParam()
  116. {
  117. Name = leakLimitcom.ControlName,
  118. Value = (int)leakLimitcom.Value,
  119. DisplayName = leakLimitcom.DisplayName,
  120. Minimun = leakLimitcom.Minimun,
  121. Maximun = leakLimitcom.Maximun
  122. };
  123. step.RetryLimit = retryLimitParam;
  124. }
  125. }
  126. }
  127. if (stepNode != null)
  128. {
  129. if (stepNode.Attributes["PressSensor"] != null)
  130. step.PressSensor = stepNode.Attributes["PressSensor"].Value;
  131. if (stepNode.Attributes["PHHighLimit"] != null)
  132. step.PHHighLimit.Value = stepNode.Attributes["PHHighLimit"].Value;
  133. if (stepNode.Attributes["PLLowLimit"] != null)
  134. step.PLLowLimit.Value = stepNode.Attributes["PLLowLimit"].Value;
  135. if (stepNode.Attributes["BPLimit"] != null)
  136. step.BPLimit.Value = stepNode.Attributes["BPLimit"].Value;
  137. if (stepNode.Attributes["DelayTime"] != null)
  138. step.DelayTime = stepNode.Attributes["DelayTime"].Value;
  139. if (stepNode.Attributes["CheckTime"] != null)
  140. step.CheckTime = stepNode.Attributes["CheckTime"].Value;
  141. if (stepNode.Attributes["LeakLimit"] != null)
  142. step.LeakLimit.Value = stepNode.Attributes["LeakLimit"].Value;
  143. if (stepNode.Attributes["RetryLimit"] != null)
  144. step.RetryLimit.Value =Convert.ToInt32(stepNode.Attributes["RetryLimit"].Value);
  145. if (stepNode.Attributes["HightLimitCommand"] != null)
  146. step.HightLimitCommand = stepNode.Attributes["HightLimitCommand"].Value;
  147. if (stepNode.Attributes["LowLimitCommand"] != null)
  148. step.LowLimitCommand = stepNode.Attributes["LowLimitCommand"].Value;
  149. if (stepNode.Attributes["BasePressureLimitCommand"] != null)
  150. step.BasePressureLimitCommand = stepNode.Attributes["BasePressureLimitCommand"].Value;
  151. if (stepNode.Attributes["ErrorCommand"] != null)
  152. step.ErrorCommand = stepNode.Attributes["ErrorCommand"].Value;
  153. if (stepNode.Attributes["RetryOverCommand"] != null)
  154. step.RetryOverCommand = stepNode.Attributes["RetryOverCommand"].Value;
  155. }
  156. return step;
  157. }
  158. public override string GetXmlString()
  159. {
  160. XmlElement nodeData = _doc.SelectSingleNode($"Aitex/TableParameterData") as XmlElement;
  161. nodeData.SetAttribute("CreatedBy", Creator);
  162. nodeData.SetAttribute("CreationTime", CreateTime.ToString("yyyy-MM-dd HH:mm:ss"));
  163. nodeData.SetAttribute("LastRevisedBy", Revisor);
  164. nodeData.SetAttribute("LastRevisionTime", ReviseTime.ToString("yyyy-MM-dd HH:mm:ss"));
  165. nodeData.SetAttribute("Description", Description);
  166. nodeData.SetAttribute("ParameterChamberType", ChamberType);
  167. nodeData.SetAttribute("Version", Version);
  168. nodeData.SetAttribute("TableNumber", TableNumber.ToString());
  169. nodeData.SetAttribute("Permission", Permission);
  170. nodeData.SetAttribute("ParameterLevel", Level);
  171. XmlNode nodeModule = _doc.SelectSingleNode($"Aitex/TableParameterData/Module[@Name='{_module}']");
  172. if (nodeModule == null)
  173. {
  174. nodeModule = _doc.CreateElement("Module");
  175. nodeData.AppendChild(nodeModule);
  176. }
  177. nodeModule.RemoveAll();
  178. (nodeModule as XmlElement).SetAttribute("Name", _module);
  179. int i = 0;
  180. foreach (LeakCheckConditionTable parameter in Steps)
  181. {
  182. XmlElement nodeStep = _doc.CreateElement("Step");
  183. nodeStep.SetAttribute("StepNo", parameter.StepNo.ToString());
  184. nodeStep.SetAttribute("Name", parameter.Name);
  185. // nodeStep.SetAttribute("UseTemp", parameter.UseTemp);
  186. nodeStep.SetAttribute("PressSensor", parameter.PressSensor);
  187. nodeStep.SetAttribute("PHHighLimit", parameter.PHHighLimit.Value.ToString());
  188. nodeStep.SetAttribute("PLLowLimit", parameter.PLLowLimit.Value.ToString());
  189. nodeStep.SetAttribute("BPLimit", parameter.BPLimit.Value.ToString());
  190. nodeStep.SetAttribute("DelayTime", parameter.DelayTime);
  191. nodeStep.SetAttribute("CheckTime", parameter.CheckTime);
  192. nodeStep.SetAttribute("LeakLimit", parameter.LeakLimit.Value.ToString());
  193. nodeStep.SetAttribute("RetryLimit", parameter.RetryLimit.Value.ToString());
  194. nodeStep.SetAttribute("HightLimitCommand", parameter.HightLimitCommand);
  195. nodeStep.SetAttribute("LowLimitCommand", parameter.LowLimitCommand);
  196. nodeStep.SetAttribute("BasePressureLimitCommand", parameter.BasePressureLimitCommand);
  197. nodeStep.SetAttribute("ErrorCommand", parameter.ErrorCommand);
  198. nodeStep.SetAttribute("RetryOverCommand", parameter.RetryOverCommand);
  199. nodeModule.AppendChild(nodeStep);
  200. i++;
  201. }
  202. return _doc.OuterXml;
  203. }
  204. public override void InitData(string prefixPath, string recipeName, string recipeContent, string module)
  205. {
  206. IsCompatibleWithCurrentFormat = false;
  207. _module = module;
  208. Name = recipeName;
  209. PrefixPath = prefixPath;
  210. try
  211. {
  212. _doc = new XmlDocument();
  213. _doc.LoadXml(recipeContent);
  214. if (!LoadHeader(_doc.SelectSingleNode("Aitex/TableParameterData")))
  215. return;
  216. XmlNodeList nodeSteps = _doc.SelectNodes($"Aitex/TableParameterData/Module[@Name='{module}']/Step");
  217. if (nodeSteps == null)
  218. nodeSteps = _doc.SelectNodes($"Aitex/TableParameterData/Step");
  219. LoadSteps(nodeSteps);
  220. var index = 1;
  221. foreach (ParameterTable parameters in Steps)
  222. {
  223. parameters.Value = index.ToString();
  224. index++;
  225. }
  226. // ValidLoopData();
  227. XmlNode nodeConfig =
  228. _doc.SelectSingleNode($"Aitex/TableParameterData/Module[@Name='{module}']/Config");
  229. if (nodeSteps == null)
  230. nodeConfig = _doc.SelectSingleNode($"Aitex/TableParameterData/Config");
  231. IsCompatibleWithCurrentFormat = true;
  232. }
  233. catch (Exception ex)
  234. {
  235. LOG.Write(ex);
  236. }
  237. }
  238. public override void LoadSteps(XmlNodeList steps)
  239. {
  240. Steps.Clear();
  241. PopSettingSteps.Clear();
  242. StepTolerances.Clear();
  243. StepNos.Clear();
  244. int index = 1;
  245. foreach (XmlNode nodeStep in steps)
  246. {
  247. ParameterTable stepTable = this.CreateStep(nodeStep);
  248. StepNos.Add(stepTable.StepNo);
  249. Steps.Add(stepTable);
  250. index++;
  251. }
  252. }
  253. }
  254. }