N2PurgeEditViewModel.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. using Aitex.Core.RT.SCCore;
  2. using Caliburn.Micro;
  3. using DocumentFormat.OpenXml.Drawing;
  4. using FurnaceUI.Client.Dialog;
  5. using MECF.Framework.Common.DataCenter;
  6. using MECF.Framework.Common.OperationCenter;
  7. using MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig;
  8. using MECF.Framework.UI.Client.CenterViews.Dialogs;
  9. using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
  10. using MECF.Framework.UI.Client.ClientBase;
  11. using OpenSEMI.ClientBase;
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Collections.ObjectModel;
  15. using System.Globalization;
  16. using System.Linq;
  17. using System.Text;
  18. using System.Threading.Tasks;
  19. using System.Windows;
  20. using System.Windows.Controls;
  21. using System.Windows.Data;
  22. namespace FurnaceUI.Views.Parameter
  23. {
  24. public class N2PurgeEditViewModel : ModuleUiViewModelBase
  25. {
  26. public bool IsPermission { get => this.Permission == 3; }
  27. public string TransferRoomVisibleBackGround { get; set; } = "#FF7DABD4";
  28. public string FOUPOpenVisibleBackGround { get; set; } = "#FF7DABD4";
  29. public string O2DetectorVisibleBackGround { get; set; } = "#FF7DABD4";
  30. public string ClampOFFVisibleBackGround { get; set; } = "#FF7DABD4";
  31. public string FurnaceOpenVisibleBackGround { get; set; } = "#FF7DABD4";
  32. public string OperationCheckVisibleBackGround { get; set; } = "#FF7DABD4";
  33. public string O2DensityQuickDownVisibleBackGround { get; set; } = "#FF7DABD4";
  34. public string FoupEnterVisibleBackGround { get; set; } = "#FF7DABD4";
  35. public string WaferChargeVisibleBackGround { get; set; } = "#FF7DABD4";
  36. public string BoatLoadVisibleBackGround { get; set; } = "#FF7DABD4";
  37. public string FoupInhibitAfterVisibleBackGround { get; set; } = "#FF7DABD4";
  38. public string BoatUnloadVisibleBackGround { get; set; } = "#FF7DABD4";
  39. public string BoatUnloadPreVisibleBackGround { get; set; } = "#FF7DABD4";
  40. public string WaferCoolingVisibleBackGround { get; set; } = "#FF7DABD4";
  41. public string WaferDishargeVisibleBackGround { get; set; } = "#FF7DABD4";
  42. public List<ParamBase> ParameterTree { get; set; } = new List<ParamBase>();
  43. public RecipeDataBase CurrentRecipe { get; set; } = new RecipeDataBase();
  44. public ObservableCollection<TempSetData> HeadLst { get; set; } = new ObservableCollection<TempSetData>();
  45. public ObservableCollection<TempSetData> PIDHeadLst { get; set; } = new ObservableCollection<TempSetData>();
  46. private ConfigNode levelOneNode;
  47. public ConfigNode LevelOneNode
  48. {
  49. get { return levelOneNode; }
  50. set { levelOneNode = value; this.NotifyOfPropertyChange(nameof(LevelOneNode)); }
  51. }
  52. private ConfigNode levelTwoNode;
  53. public ConfigNode LevelTwoNode
  54. {
  55. get { return levelTwoNode; }
  56. set { levelTwoNode = value; this.NotifyOfPropertyChange(nameof(LevelTwoNode)); }
  57. }
  58. private List<ConfigItem> currenItems;
  59. public List<ConfigItem> CurrenItems
  60. {
  61. get { return currenItems; }
  62. set { currenItems = value; this.NotifyOfPropertyChange(nameof(CurrenItems)); }
  63. }
  64. private List<ConfigNode> _ConfigNodes = new List<ConfigNode>();
  65. public List<ConfigNode> ConfigNodes
  66. {
  67. get { return _ConfigNodes; }
  68. set { _ConfigNodes = value; NotifyOfPropertyChange("ConfigNodes"); }
  69. }
  70. private string _defaultUnit = "Pa";
  71. public string DefaultUnit
  72. {
  73. get
  74. {
  75. return _defaultUnit;
  76. }
  77. set
  78. {
  79. _defaultUnit = value;
  80. NotifyOfPropertyChange("DefaultUnit");
  81. }
  82. }
  83. private ConfigNode _rootNode;
  84. private string _CurrentNodeName = string.Empty;
  85. private string path;
  86. private string currentValue;
  87. private ObservableCollection<PageValue> valueList { get; set; } = new ObservableCollection<PageValue>();
  88. protected override void OnInitialize()
  89. {
  90. base.OnInitialize();
  91. this.SystemName = "System";
  92. ConfigNodes = SystemConfigProvider.Instance.GetConfigTree(SystemName).SubNodes;
  93. InitTree();
  94. _rootNode = SystemConfigProvider.Instance.GetConfig(true);
  95. }
  96. protected override void OnActivate()
  97. {
  98. base.OnActivate();
  99. DefaultUnit = (string)QueryDataClient.Instance.Service.GetConfig($"PM1.APC.PressureUnit");
  100. }
  101. private void InitTree()
  102. {
  103. var node = SystemConfigProvider.Instance.GetConfigTree(SystemName).SubNodes;
  104. ParameterTree.Add(new ParamBase() { ID = 1, ParentID = 0, Name = "StepTime", ConfigName = "StepTime" });
  105. ParameterTree.Add(new ParamBase() { ID = 2, ParentID = 0, Name = "Temperature" });
  106. {
  107. ParameterTree.Add(new ParamBase() { ID = 21, ParentID = 2, Name = "TempOffset", ConfigName = "TempOffsetTable" });
  108. ParameterTree.Add(new ParamBase() { ID = 22, ParentID = 2, Name = "TempProfile", ConfigName = "TempProfileTable" });
  109. ParameterTree.Add(new ParamBase() { ID = 23, ParentID = 2, Name = "TempStabilize", ConfigName = "TempStabilizeTable" });
  110. ParameterTree.Add(new ParamBase() { ID = 24, ParentID = 2, Name = "TempSetting", ConfigName = "TempSetting" });
  111. ParameterTree.Add(new ParamBase() { ID = 25, ParentID = 2, Name = "TempPIDTable", ConfigName = "TempPIDTable" });
  112. }
  113. //ParameterTree.Add(new ParamBase() { ID = 3, ParentID = 0, Name = "TempSetting", ConfigName = "TempSetting" });
  114. ParameterTree.Add(new ParamBase() { ID = 4, ParentID = 0, Name = "PressureStabilize", ConfigName = "PressureStabilizeTable" });
  115. ParameterTree.Add(new ParamBase() { ID = 5, ParentID = 0, Name = "AlarmWatchTable" });
  116. {
  117. ParameterTree.Add(new ParamBase() { ID = 51, ParentID = 5, Name = "TempAlarm", ConfigName = "AlarmWatchTable.TempAlarmWatch" });
  118. ParameterTree.Add(new ParamBase() { ID = 52, ParentID = 5, Name = "FlowAlarm", ConfigName = "AlarmWatchTable.FlowAlarmWatch" });
  119. ParameterTree.Add(new ParamBase() { ID = 53, ParentID = 5, Name = "PressureAlarm", ConfigName = "AlarmWatchTable.PressureAlarmWatch" });
  120. }
  121. ParameterTree.Add(new ParamBase() { ID = 6, ParentID = 0, Name = "FlowSetting", ConfigName = "FlowSetting" });
  122. {
  123. var MfcItems = ConfigNodes.Where(x => x.Display == "Parameter").FirstOrDefault().SubNodes.Where(y => y.Name == "MFC").FirstOrDefault().SubNodes;
  124. foreach (var item in MfcItems)
  125. {
  126. var isInstalled = QueryDataClient.Instance.Service.GetConfig($"PM1.MFC.{item.Name}.IsMFCInstalled");
  127. if (!(bool)isInstalled) continue;
  128. ParameterTree.Add(new ParamBase()
  129. {
  130. ID = 61,
  131. ParentID = 6,
  132. Name = SystemConfigProvider.Instance.GetValueByName($"PM1.MFC.{item.Name}.GasName"),
  133. ConfigName = $"FlowSetting.{item.Name}"
  134. });
  135. }
  136. }
  137. ParameterTree.Add(new ParamBase() { ID = 7, ParentID = 0, Name = "APCSetting" });
  138. {
  139. ParameterTree.Add(new ParamBase() { ID = 71, ParentID = 7, Name = "Pressure", ConfigName = "APCSetting.Pressure" });
  140. ParameterTree.Add(new ParamBase() { ID = 72, ParentID = 7, Name = "Position", ConfigName = "APCSetting.Position" });
  141. }
  142. ParameterTree.Add(new ParamBase() { ID = 8, ParentID = 0, Name = "LayoutPitch", ConfigName = "LayoutPitch" });
  143. ParameterTree.Add(new ParamBase() { ID = 9, ParentID = 0, Name = "CoolingTime", ConfigName = "CoolTime" });
  144. ParameterTree = this.LoadTreeView(0);
  145. }
  146. private List<ParamBase> LoadTreeView(int id)
  147. {
  148. List<ParamBase> node = ParameterTree.FindAll(s => s.ParentID.Equals(id));
  149. foreach (var item in node)
  150. {
  151. item.Children = LoadTreeView(item.ID);
  152. }
  153. return node;
  154. }
  155. public void HideAllCanvas()
  156. {
  157. }
  158. public void TreeViewSelectedItemChanged(object obj)
  159. {
  160. valueList.Clear();
  161. LevelOneNode = LevelTwoNode = new ConfigNode();
  162. HideAllCanvas();
  163. var view = GetView() as N2PurgeEditView;
  164. ParamBase para = obj as ParamBase;
  165. string strHeader = "PM1.RecipeEditParameter";
  166. Canvas canvas = null;
  167. LevelOneNode = FindNodeByName(_rootNode, $"{strHeader}.{para.ConfigName}");
  168. LevelTwoNode = LevelOneNode.SubNodes.FirstOrDefault();
  169. if (canvas == null) return;
  170. canvas.Visibility = Visibility.Visible;
  171. this.GetHeaderConfig();
  172. this.GetPIDHeaderConfig();
  173. if (LevelTwoNode == null)
  174. {
  175. InitItemsCurrentValue(LevelOneNode, false);
  176. }
  177. else
  178. {
  179. InitItemsCurrentValue(LevelTwoNode, true);
  180. ConfigNode subNode = LevelTwoNode.SubNodes.FirstOrDefault();
  181. if (subNode != null) InitItemsCurrentValue(subNode, true);
  182. }
  183. }
  184. private void InitItemsCurrentValue(ConfigNode node, bool initSubItems = true)
  185. {
  186. if (node == null) return;
  187. CurrenItems = node.Items;
  188. _CurrentNodeName = string.IsNullOrEmpty(node.Path) ? node.Name : $"{node.Path}.{node.Name}";
  189. if (CurrenItems == null || CurrenItems.Count <= 0)
  190. {
  191. if (!initSubItems) return;
  192. foreach (var item in node.SubNodes)
  193. {
  194. InitItemsCurrentValue(item);
  195. }
  196. }
  197. else
  198. {
  199. GetDataOfConfigItems();
  200. }
  201. }
  202. private void GetDataOfConfigItems()
  203. {
  204. if (CurrenItems == null)
  205. return;
  206. for (int i = 0; i < CurrenItems.Count; i++)
  207. {
  208. var isInstalled = QueryDataClient.Instance.Service.GetConfig($"PM1.MFC.{CurrenItems[i].Name}.IsMFCInstalled");
  209. if (isInstalled != null && !(bool)isInstalled)
  210. CurrenItems[i].Visible = false;
  211. else
  212. CurrenItems[i].Visible = true;
  213. string key = String.Format("{0}{1}{2}", _CurrentNodeName, ".", CurrenItems[i].Name);
  214. CurrenItems[i].CurrentValue = SystemConfigProvider.Instance.GetValueByName(key);
  215. CurrenItems[i].Path = key;
  216. if (CurrenItems[i].Type == DataType.Bool)
  217. {
  218. bool value;
  219. if (bool.TryParse(CurrenItems[i].CurrentValue, out value))
  220. {
  221. CurrenItems[i].BoolValue = value;
  222. CurrenItems[i].CurrentValue = value ? "Yes" : "No";
  223. }
  224. }
  225. else
  226. CurrenItems[i].StringValue = CurrenItems[i].CurrentValue;
  227. }
  228. }
  229. public void MenuCommand(object obj, object menuLevel)
  230. {
  231. RadioButton radioButton = obj as RadioButton;
  232. ConfigNode currentNode = null;
  233. switch (menuLevel.ToString())
  234. {
  235. case "LevelOne":
  236. currentNode = LevelTwoNode = LevelOneNode.SubNodes.Find((x) => x.Name == radioButton.ToolTip.ToString());
  237. break;
  238. case "LevelTwo":
  239. currentNode = LevelTwoNode.SubNodes.Find((x) => x.Name == radioButton.ToolTip.ToString());
  240. break;
  241. }
  242. InitItemsCurrentValue(currentNode);
  243. }
  244. public void SetValue(object obj)
  245. {
  246. var CurrentRecipes = CurrentRecipe;
  247. if (CurrenItems == null || currenItems.Count == 0) return;
  248. ConfigItem item = null;
  249. if (obj is Control)
  250. item = CurrenItems.Find((x) => x.Name == (obj as Control).ToolTip.ToString());
  251. else
  252. item = obj as ConfigItem;
  253. InputDialogViewModel dialog = new InputDialogViewModel();
  254. dialog.Item = item;
  255. dialog.DisplayName = "Set Value";
  256. WindowManager wm = new WindowManager();
  257. bool? bret = wm.ShowDialog(dialog);
  258. if ((bool)bret)
  259. {
  260. item.StringValue = dialog.DialogResult;
  261. //key :System.IsSimulatorMode
  262. //value: true or false 都是字符串
  263. //input check
  264. string value;
  265. if (item.Type == DataType.Bool)
  266. {
  267. if (item.StringValue.Equals("Yes", StringComparison.CurrentCultureIgnoreCase))
  268. item.BoolValue = true;
  269. else if (item.StringValue.Equals("No", StringComparison.CurrentCultureIgnoreCase))
  270. item.BoolValue = false;
  271. else
  272. {
  273. DialogBox.ShowWarning("The Value Should be Yes Or No.");
  274. return;
  275. }
  276. value = item.BoolValue.ToString().ToLower();
  277. }
  278. else
  279. {
  280. if (item.Type == DataType.Int)
  281. {
  282. int iValue;
  283. if (int.TryParse(item.StringValue, out iValue))
  284. {
  285. if (!double.IsNaN(item.Max) && !double.IsNaN(item.Min))
  286. {
  287. if (iValue > item.Max || iValue < item.Min)
  288. {
  289. DialogBox.ShowWarning(string.Format("The value should be between {0} and {1}.", ((int)item.Min).ToString(), ((int)item.Max).ToString()));
  290. return;
  291. }
  292. }
  293. }
  294. else
  295. {
  296. DialogBox.ShowWarning("Please input valid data.");
  297. return;
  298. }
  299. value = item.StringValue;
  300. }
  301. else if (item.Type == DataType.Double)
  302. {
  303. double fValue;
  304. if (double.TryParse(item.StringValue, out fValue))
  305. {
  306. if (!double.IsNaN(item.Max) && !double.IsNaN(item.Min))
  307. {
  308. if (fValue > item.Max || fValue < item.Min)
  309. {
  310. DialogBox.ShowWarning(string.Format("The value should be between {0} and {1}.", item.Min.ToString(), item.Max.ToString()));
  311. return;
  312. }
  313. string[] box = fValue.ToString().Split('.');
  314. if (box.Length > 1 && box[1].Length > 3)
  315. {
  316. DialogBox.ShowWarning(string.Format("The value should be more than three decimal places"));
  317. return;
  318. }
  319. }
  320. }
  321. else
  322. {
  323. DialogBox.ShowWarning("Please input valid data.");
  324. return;
  325. }
  326. value = item.StringValue;
  327. }
  328. else
  329. value = item.StringValue;
  330. }
  331. string key = String.Format("{0}{1}{2}", _CurrentNodeName, ".", item.Name);
  332. if (item.Path.Split('.')[2] == "LayoutPitch")
  333. {
  334. if (item.Path.Split('.')[3] == "StandardPitch")
  335. {
  336. foreach (var current in currenItems.Where(x => x.Description != "StandardPitch"))
  337. {
  338. current.CurrentValue = "No";
  339. InvokeClient.Instance.Service.DoOperation($"{SystemName}.SetConfig", current.Path, "false");
  340. }
  341. }
  342. else if (item.Path.Split('.')[3] == "DoublePitch")
  343. {
  344. foreach (var current in currenItems.Where(x => x.Description != "DoublePitch"))
  345. {
  346. current.CurrentValue = "No";
  347. InvokeClient.Instance.Service.DoOperation($"{SystemName}.SetConfig", current.Path, "false");
  348. }
  349. }
  350. else
  351. {
  352. foreach (var current in currenItems.Where(x => x.Description != "TriplePitch"))
  353. {
  354. current.CurrentValue = "No";
  355. InvokeClient.Instance.Service.DoOperation($"{SystemName}.SetConfig", current.Path, "false");
  356. }
  357. }
  358. }
  359. path = item.Path;
  360. currentValue = value;
  361. valueList.Add(new PageValue() { Path = path, CurrentValue = currentValue });
  362. }
  363. }
  364. public void SaveParameter()
  365. {
  366. foreach (var item in valueList)
  367. {
  368. InvokeClient.Instance.Service.DoOperation($"{SystemName}.SetConfig", item.Path, item.CurrentValue);
  369. }
  370. }
  371. public void GetHeaderConfig()
  372. {
  373. HeadLst.Clear();
  374. for (int i = 0; i < 10; i++)
  375. {
  376. if (i % 2 != 0)
  377. {
  378. var configHeater = (string)QueryDataClient.Instance.Service.GetConfig($"PM1.Heater.Heater{i}.DisplayName");
  379. TempSetData item = new TempSetData(configHeater);
  380. item.SetValue.Value = configHeater;
  381. HeadLst.Add(item);
  382. }
  383. }
  384. }
  385. public void GetPIDHeaderConfig()
  386. {
  387. PIDHeadLst.Clear();
  388. for (int i = 0; i < 10; i++)
  389. {
  390. if (i % 2 != 0)
  391. {
  392. var configHeater = (string)QueryDataClient.Instance.Service.GetConfig($"PM1.Heater.Heater{i}.DisplayName");
  393. TempSetData item1 = new TempSetData(configHeater);
  394. TempSetData item2 = new TempSetData(configHeater);
  395. TempSetData item3 = new TempSetData(configHeater);
  396. item1.SetValue.Value = $"{configHeater} P";
  397. PIDHeadLst.Add(item1);
  398. item2.SetValue.Value = $"{configHeater} I";
  399. PIDHeadLst.Add(item2);
  400. item3.SetValue.Value = $"{configHeater} D";
  401. PIDHeadLst.Add(item3);
  402. }
  403. }
  404. }
  405. private ConfigNode FindNodeByName(ConfigNode parentNode, string strName)
  406. {
  407. string strCates = strName.Split('.')[0];
  408. ConfigNode node = parentNode.SubNodes.Find((x) => x.Name == strCates);
  409. if (node == null)
  410. return parentNode;
  411. else
  412. return FindNodeByName(node, strName.Replace(strCates + ".", ""));
  413. }
  414. public void N2PurgeParaSelect(string ButtonPara)
  415. {
  416. this.GetType().GetProperty($"{ButtonPara}BackGround").SetValue(this, "#FF7DD486");
  417. UpdataProperty();
  418. N2PurgeSelectDialogViewModel dialog = new N2PurgeSelectDialogViewModel(ButtonPara);
  419. WindowManager wm = new WindowManager();
  420. bool? bret = wm.ShowDialog(dialog);
  421. this.GetType().GetProperty($"{ButtonPara}BackGround").SetValue(this, "#FF7DABD4");
  422. UpdataProperty();
  423. if (!(bool)bret)
  424. return;
  425. }
  426. public void UpdataProperty()
  427. {
  428. NotifyOfPropertyChange("TransferRoomVisibleBackGround");
  429. NotifyOfPropertyChange("FOUPOpenVisibleBackGround");
  430. NotifyOfPropertyChange("O2DetectorVisibleBackGround");
  431. NotifyOfPropertyChange("ClampOFFVisibleBackGround");
  432. NotifyOfPropertyChange("OperationCheckVisibleBackGround");
  433. NotifyOfPropertyChange("O2DensityQuickDownVisibleBackGround");
  434. NotifyOfPropertyChange("FoupEnterVisibleBackGround");
  435. NotifyOfPropertyChange("WaferChargeVisibleBackGround");
  436. NotifyOfPropertyChange("BoatLoadVisibleBackGround");
  437. NotifyOfPropertyChange("FoupInhibitAfterVisibleBackGround");
  438. NotifyOfPropertyChange("BoatUnloadVisibleBackGround");
  439. NotifyOfPropertyChange("BoatUnloadPreVisibleBackGround");
  440. NotifyOfPropertyChange("WaferCoolingVisibleBackGround");
  441. NotifyOfPropertyChange("WaferDishargeVisibleBackGround");
  442. }
  443. protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
  444. {
  445. base.InvokeAfterUpdateProperty(data);
  446. NotifyOfPropertyChange("TransferRoomVisibleBackGround");
  447. }
  448. }
  449. }