MainParameterEditViewModel.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. using Aitex.Core.RT.SCCore;
  2. using Caliburn.Micro;
  3. using Caliburn.Micro.Core;
  4. using MECF.Framework.Common.DataCenter;
  5. using MECF.Framework.Common.OperationCenter;
  6. using MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig;
  7. using MECF.Framework.UI.Client.CenterViews.Dialogs;
  8. using MECF.Framework.UI.Client.CenterViews.Editors;
  9. using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
  10. using MECF.Framework.UI.Client.ClientBase;
  11. using OpenSEMI.ClientBase;
  12. using SciChart.Core.Extensions;
  13. using System;
  14. using System.Collections.Generic;
  15. using System.Collections.ObjectModel;
  16. using System.Globalization;
  17. using System.Linq;
  18. using System.Text;
  19. using System.Threading.Tasks;
  20. using System.Windows;
  21. using System.Windows.Controls;
  22. using System.Windows.Data;
  23. using System.Windows.Input;
  24. using System.Windows.Threading;
  25. namespace MECF.Framework.UI.Client.CenterViews.Parameter
  26. {
  27. public class MainParameterEditViewModel : ModuleUiViewModelBase, ISupportMultipleSystem
  28. {
  29. public bool IsPermission { get => this.Permission == 3; }
  30. public List<ParamBase> ParameterTree { get; set; } = new List<ParamBase>();
  31. public ObservableCollection<TempSetData> HeadLst { get; set; } = new ObservableCollection<TempSetData>();
  32. public ObservableCollection<TempSetData> PIDHeadLst { get; set; } = new ObservableCollection<TempSetData>();
  33. public ObservableCollection<ConfigItem> StepNames { get; set; } = new ObservableCollection<ConfigItem>();
  34. private ConfigNode _currentNode;
  35. public ConfigNode CurrentNode
  36. {
  37. get { return _currentNode; }
  38. set { _currentNode = value; this.NotifyOfPropertyChange(nameof(CurrentNode)); }
  39. }
  40. private string _allZoneValue = "0";
  41. public string AllZoneValue
  42. {
  43. get { return _allZoneValue; }
  44. set { _allZoneValue = value; this.NotifyOfPropertyChange(nameof(AllZoneValue)); }
  45. }
  46. private ConfigNode _currentSubNode;
  47. public ConfigNode CurrentSubNode
  48. {
  49. get { return _currentSubNode; }
  50. set { _currentSubNode = value; this.NotifyOfPropertyChange(nameof(CurrentSubNode)); }
  51. }
  52. private ConfigNode _currentTwoSubNode;
  53. public ConfigNode CurrentTwoSubNode
  54. {
  55. get { return _currentTwoSubNode; }
  56. set { _currentTwoSubNode = value; this.NotifyOfPropertyChange(nameof(CurrentTwoSubNode)); }
  57. }
  58. private List<ConfigNode> _ConfigNodes = new List<ConfigNode>();
  59. public List<ConfigNode> ConfigNodes
  60. {
  61. get { return _ConfigNodes; }
  62. set { _ConfigNodes = value; NotifyOfPropertyChange("ConfigNodes"); }
  63. }
  64. private string _defaultUnit = "Pa";
  65. public string DefaultUnit
  66. {
  67. get
  68. {
  69. return _defaultUnit;
  70. }
  71. set
  72. {
  73. _defaultUnit = value;
  74. NotifyOfPropertyChange("DefaultUnit");
  75. }
  76. }
  77. private ConfigNode _rootNode;
  78. private string _CurrentNodeName = string.Empty;
  79. private string path;
  80. private string currentValue;
  81. private ObservableCollection<PageValue> valueList { get; set; } = new ObservableCollection<PageValue>();
  82. private ObservableCollection<PageValue> newValueList { get; set; } = new ObservableCollection<PageValue>();
  83. protected override void OnInitialize()
  84. {
  85. base.OnInitialize();
  86. this.SystemName = "System";
  87. ConfigNodes = SystemConfigProvider.Instance.GetConfigTree(SystemName).SubNodes;
  88. _rootNode = SystemConfigProvider.Instance.GetConfig(true);
  89. InitTree();
  90. }
  91. protected override void OnActivate()
  92. {
  93. base.OnActivate();
  94. }
  95. private void InitTree()
  96. {
  97. var node = SystemConfigProvider.Instance.GetConfigTree(SystemName).SubNodes;
  98. ParameterTree.Add(new ParamBase() { ID = 1, ParentID = 0, Name = "StepName", ConfigName = "StepName" });
  99. ParameterTree.Add(new ParamBase() { ID = 2, ParentID = 0, Name = "StepGroup", ConfigName = "StepGroup" });
  100. //ParameterTree.Add(new ParamBase() { ID = 2, ParentID = 0, Name = "TempSetting", ConfigName = "TempSetting" });
  101. //ParameterTree.Add(new ParamBase() { ID = 3, ParentID = 0, Name = "TempSetting", ConfigName = "TempSetting" });
  102. ParameterTree = this.LoadTreeView(0);
  103. foreach (var item in ParameterTree)
  104. {
  105. InitAllParameterTree(item);
  106. }
  107. var stepNameNode = FindNodeByName(_rootNode, $"{strHeader}.StepName");
  108. if (stepNameNode != null && stepNameNode.Items.Count > 0)
  109. {
  110. stepNameNode.Items.ForEach(x => StepNames.Add(x));
  111. CurrentNode = stepNameNode;
  112. }
  113. this.GetHeaderConfig();
  114. }
  115. string strHeader = "PM1.RecipeEditParameter";
  116. private void InitAllParameterTree(ParamBase para)
  117. {
  118. CurrentNode = new ConfigNode();
  119. CurrentNode = FindNodeByName(_rootNode, $"{strHeader}.{para.ConfigName}");
  120. InitItemsCurrentValue(CurrentNode, true);
  121. if (CurrentNode.SubNodes != null)
  122. {
  123. foreach (var item in CurrentNode.SubNodes)
  124. {
  125. InitItemsCurrentValue(item, true);
  126. }
  127. }
  128. }
  129. private Visibility _stepNameVisibility = Visibility.Visible;
  130. public Visibility StepNameVisibility
  131. {
  132. get => _stepNameVisibility;
  133. set
  134. {
  135. _stepNameVisibility = value;
  136. NotifyOfPropertyChange(nameof(StepNameVisibility));
  137. }
  138. }
  139. private Visibility _stepGroupSettingVisibility = Visibility.Hidden;
  140. public Visibility StepGroupSettingVisibility
  141. {
  142. get => _stepGroupSettingVisibility;
  143. set
  144. {
  145. _stepGroupSettingVisibility = value;
  146. NotifyOfPropertyChange(nameof(StepGroupSettingVisibility));
  147. }
  148. }
  149. private Visibility _tempSettingeVisibility = Visibility.Hidden;
  150. public Visibility TempSettingVisibility
  151. {
  152. get => _tempSettingeVisibility;
  153. set
  154. {
  155. _tempSettingeVisibility = value;
  156. NotifyOfPropertyChange(nameof(TempSettingVisibility));
  157. }
  158. }
  159. private List<ParamBase> LoadTreeView(int id)
  160. {
  161. List<ParamBase> node = ParameterTree.FindAll(s => s.ParentID.Equals(id));
  162. foreach (var item in node)
  163. {
  164. item.Children = LoadTreeView(item.ID);
  165. }
  166. return node;
  167. }
  168. public void HideAllCanvas()
  169. {
  170. StepNameVisibility = Visibility.Hidden;
  171. TempSettingVisibility = Visibility.Hidden;
  172. StepGroupSettingVisibility = Visibility.Hidden;
  173. }
  174. public void TreeViewSelectedItemChanged(object obj)
  175. {
  176. valueList.Clear();
  177. var view = GetView() as MainParameterEditView;
  178. HideAllCanvas();
  179. ParamBase para = obj as ParamBase;
  180. string strHeader = "PM1.RecipeEditParameter";
  181. switch (para.ConfigName)
  182. {
  183. case "StepName":
  184. StepNameVisibility = Visibility.Visible;
  185. break;
  186. case "StepGroup":
  187. CurrentNode = FindNodeByName(_rootNode, $"{strHeader}.{para.ConfigName}");
  188. StepGroupSettingVisibility = Visibility.Visible;
  189. break;
  190. case "TempSetting":
  191. CurrentNode = FindNodeByName(_rootNode, $"{strHeader}.{para.ConfigName}");
  192. TempSettingVisibility = Visibility.Visible;
  193. if (CurrentNode.SubNodes.Where(x => x.StabilizeBoolValue == true).Count() <= 0)
  194. {
  195. CurrentNode.SubNodes[0].StabilizeBoolValue = true;
  196. }
  197. CurrentSubNode = CurrentNode.SubNodes.FirstOrDefault(x => x.StabilizeBoolValue);
  198. break;
  199. }
  200. }
  201. public void StepGroupEdit(string groupName)
  202. {
  203. var windowManager = IoC.Get<IWindowManager>();
  204. var groupList = CurrentNode.Items.Where(a => a.Display != groupName).Select(a => a.Path).ToList();
  205. List<string> hasSelectStepIdList = new List<string>();
  206. foreach (var item in QueryDataClient.Instance.Service.PollConfig(groupList).Values)
  207. {
  208. hasSelectStepIdList.AddRange( item.ToString().Split(',').ToList());
  209. }
  210. StepGroupEditViewModel recipeStepNameViewModel = new StepGroupEditViewModel();
  211. recipeStepNameViewModel.StepGroupName = groupName;
  212. recipeStepNameViewModel.HasSelectStepIds = hasSelectStepIdList;
  213. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeStepNameViewModel, null, "Step Group Edit"))
  214. {
  215. var selectStepId = recipeStepNameViewModel.StepIdList.Where(a => a.IsExpanded).Select(a => a.Name).ToList();
  216. InvokeClient.Instance.Service.DoOperation($"{SystemName}.SetConfig", $"PM1.RecipeEditParameter.StepGroup.{groupName}", string.Join(",", selectStepId.ToArray()));
  217. }
  218. }
  219. private void InitItemsCurrentValue(ConfigNode node, bool initSubItems = true)
  220. {
  221. if (node == null) return;
  222. _CurrentNodeName = string.IsNullOrEmpty(node.Path) ? node.Name : $"{node.Path}.{node.Name}";
  223. if (node.Items == null || node.Items.Count <= 0)
  224. {
  225. if (!initSubItems) return;
  226. foreach (var item in node.SubNodes)
  227. {
  228. InitItemsCurrentValue(item);
  229. }
  230. }
  231. else
  232. {
  233. GetDataOfConfigItems(node);
  234. }
  235. }
  236. private void GetDataOfConfigItems(ConfigNode node)
  237. {
  238. if (node.Items == null)
  239. return;
  240. List<string> allItems = new List<string>();
  241. for (int i = 0; i < node.Items.Count; i++)
  242. {
  243. string key = String.Format("{0}{1}{2}", _CurrentNodeName, ".", node.Items[i].Name);
  244. allItems.Add(key);
  245. }
  246. List<string> newallItems = allItems.Distinct().ToList();
  247. var DictItems = QueryDataClient.Instance.Service.PollConfig(newallItems);
  248. for (int i = 0; i < node.Items.Count; i++)
  249. {
  250. string key = String.Format("{0}{1}{2}", _CurrentNodeName, ".", node.Items[i].Name);
  251. node.Items[i].CurrentValue = DictItems.ContainsKey(key) ? DictItems[key].ToString() : "";
  252. node.Items[i].Path = key;
  253. //if (CurrenItems[i].Path.Contains("PM1.RecipeEditParameter.PressureStabilizeTable"))
  254. // DefaultUnit = CurrenItems[i].Unit;
  255. if (node.Items[i].Type == DataType.Bool)
  256. {
  257. bool value;
  258. if (bool.TryParse(node.Items[i].CurrentValue, out value))
  259. {
  260. node.Items[i].BoolValue = value;
  261. node.Items[i].CurrentValue = value ? "Yes" : "No";
  262. }
  263. }
  264. else
  265. node.Items[i].StringValue = node.Items[i].CurrentValue;
  266. }
  267. }
  268. public void MenuCommand(object obj, object menuLevel)
  269. {
  270. RadioButton radioButton = obj as RadioButton;
  271. switch ((string)menuLevel)
  272. {
  273. case "LevelOne":
  274. CurrentSubNode = CurrentNode.SubNodes.Find((x) => x.Name == radioButton.ToolTip.ToString());
  275. break;
  276. case "LevelTwo":
  277. CurrentTwoSubNode = CurrentSubNode.SubNodes.Find((x) => x.Name == radioButton.ToolTip.ToString());
  278. break;
  279. default:
  280. break;
  281. }
  282. }
  283. public void SetValue(object obj)
  284. {
  285. if (CurrentNode.Items == null || CurrentNode.Items.Count == 0) return;
  286. ConfigItem item = null;
  287. if (obj is Control)
  288. item = CurrentNode.Items.ToList().Find((x) => x.Name == (obj as Control).ToolTip.ToString());
  289. else
  290. item = obj as ConfigItem;
  291. if (item == null) return;
  292. if (item.Type == DataType.String)
  293. {
  294. currentValue = item.CurrentValue;
  295. path = item.Path;
  296. FullKeyboard fullKeyboard = new FullKeyboard("", currentValue);
  297. if ((bool)fullKeyboard.ShowDialog())
  298. {
  299. InvokeClient.Instance.Service.DoOperation($"{SystemName}.SetConfig", path, fullKeyboard.ValueString);
  300. currentValue = fullKeyboard.ValueString;
  301. item.CurrentValue = fullKeyboard.ValueString;
  302. }
  303. valueList.Add(new PageValue() { Path = path, CurrentValue = currentValue });
  304. }
  305. else
  306. {
  307. InputDialogViewModel dialog = new InputDialogViewModel();
  308. dialog.Item = item;
  309. dialog.DisplayName = "Set Value";
  310. WindowManager wm = new WindowManager();
  311. bool? bret = wm.ShowDialog(dialog);
  312. if ((bool)bret)
  313. {
  314. item.StringValue = dialog.DialogResult;
  315. //key :System.IsSimulatorMode
  316. //value: true or false 都是字符串
  317. //input check
  318. string value;
  319. if (item.Type == DataType.Bool)
  320. {
  321. if (item.StringValue.Equals("Yes", StringComparison.CurrentCultureIgnoreCase))
  322. item.BoolValue = true;
  323. else if (item.StringValue.Equals("No", StringComparison.CurrentCultureIgnoreCase))
  324. item.BoolValue = false;
  325. else
  326. {
  327. DialogBox.ShowWarning("The Value Should be Yes Or No.");
  328. return;
  329. }
  330. value = item.BoolValue.ToString().ToLower();
  331. }
  332. else
  333. {
  334. if (item.Type == DataType.Int)
  335. {
  336. int iValue;
  337. if (int.TryParse(item.StringValue, out iValue))
  338. {
  339. if (!double.IsNaN(item.Max) && !double.IsNaN(item.Min))
  340. {
  341. if (iValue > item.Max || iValue < item.Min)
  342. {
  343. DialogBox.ShowWarning(string.Format("The value should be between {0} and {1}.", ((int)item.Min).ToString(), ((int)item.Max).ToString()));
  344. return;
  345. }
  346. }
  347. }
  348. else
  349. {
  350. DialogBox.ShowWarning("Please input valid data.");
  351. return;
  352. }
  353. value = item.StringValue;
  354. }
  355. else if (item.Type == DataType.Double)
  356. {
  357. double fValue;
  358. if (double.TryParse(item.StringValue, out fValue))
  359. {
  360. if (!double.IsNaN(item.Max) && !double.IsNaN(item.Min))
  361. {
  362. if (fValue > item.Max || fValue < item.Min)
  363. {
  364. DialogBox.ShowWarning(string.Format("The value should be between {0} and {1}.", item.Min.ToString(), item.Max.ToString()));
  365. return;
  366. }
  367. string[] box = fValue.ToString().Split('.');
  368. if (box.Length > 1 && box[1].Length > 3)
  369. {
  370. DialogBox.ShowWarning(string.Format("The value should be more than three decimal places"));
  371. return;
  372. }
  373. }
  374. }
  375. else
  376. {
  377. DialogBox.ShowWarning("Please input valid data.");
  378. return;
  379. }
  380. value = item.StringValue;
  381. }
  382. else
  383. value = item.StringValue;
  384. }
  385. string key = String.Format("{0}{1}{2}", _CurrentNodeName, ".", item.Name);
  386. path = item.Path;
  387. currentValue = value;
  388. valueList.Add(new PageValue() { Path = path, CurrentValue = currentValue });
  389. }
  390. }
  391. }
  392. public void AllZoneTextChanged()
  393. {
  394. if (CurrentSubNode.Items == null || CurrentSubNode.Items.Count == 0) return;
  395. newValueList = new ObservableCollection<PageValue>();
  396. valueList = new ObservableCollection<PageValue>();
  397. foreach (var item in CurrentSubNode.Items)
  398. {
  399. item.CurrentValue = AllZoneValue;
  400. newValueList.Add(new PageValue() { Path = item.Path, CurrentValue = AllZoneValue });
  401. }
  402. }
  403. public void SetCurrentSubNodeValue(object obj)
  404. {
  405. if (CurrentSubNode.Items == null || CurrentSubNode.Items.Count == 0) return;
  406. ConfigItem item = null;
  407. if (obj is Control)
  408. item = CurrentSubNode.Items.ToList().Find((x) => x.Name == (obj as Control).ToolTip.ToString());
  409. else
  410. item = obj as ConfigItem;
  411. if (item == null) return;
  412. if (item.Type == DataType.String)
  413. {
  414. currentValue = item.CurrentValue;
  415. path = item.Path;
  416. FullKeyboard fullKeyboard = new FullKeyboard("", currentValue);
  417. if ((bool)fullKeyboard.ShowDialog())
  418. {
  419. InvokeClient.Instance.Service.DoOperation($"{SystemName}.SetConfig", path, fullKeyboard.ValueString);
  420. currentValue = fullKeyboard.ValueString;
  421. item.CurrentValue = fullKeyboard.ValueString;
  422. }
  423. valueList.Add(new PageValue() { Path = path, CurrentValue = currentValue });
  424. }
  425. else
  426. {
  427. InputDialogViewModel dialog = new InputDialogViewModel();
  428. dialog.Item = item;
  429. dialog.DisplayName = "Set Value";
  430. WindowManager wm = new WindowManager();
  431. bool? bret = wm.ShowDialog(dialog);
  432. if ((bool)bret)
  433. {
  434. item.StringValue = dialog.DialogResult;
  435. //key :System.IsSimulatorMode
  436. //value: true or false 都是字符串
  437. //input check
  438. string value;
  439. if (item.Type == DataType.Bool)
  440. {
  441. if (item.StringValue.Equals("Yes", StringComparison.CurrentCultureIgnoreCase))
  442. item.BoolValue = true;
  443. else if (item.StringValue.Equals("No", StringComparison.CurrentCultureIgnoreCase))
  444. item.BoolValue = false;
  445. else
  446. {
  447. DialogBox.ShowWarning("The Value Should be Yes Or No.");
  448. return;
  449. }
  450. value = item.BoolValue.ToString().ToLower();
  451. }
  452. else
  453. {
  454. if (item.Type == DataType.Int)
  455. {
  456. int iValue;
  457. if (int.TryParse(item.StringValue, out iValue))
  458. {
  459. if (!double.IsNaN(item.Max) && !double.IsNaN(item.Min))
  460. {
  461. if (iValue > item.Max || iValue < item.Min)
  462. {
  463. DialogBox.ShowWarning(string.Format("The value should be between {0} and {1}.", ((int)item.Min).ToString(), ((int)item.Max).ToString()));
  464. return;
  465. }
  466. }
  467. }
  468. else
  469. {
  470. DialogBox.ShowWarning("Please input valid data.");
  471. return;
  472. }
  473. value = item.StringValue;
  474. }
  475. else if (item.Type == DataType.Double)
  476. {
  477. double fValue;
  478. if (double.TryParse(item.StringValue, out fValue))
  479. {
  480. if (!double.IsNaN(item.Max) && !double.IsNaN(item.Min))
  481. {
  482. if (fValue > item.Max || fValue < item.Min)
  483. {
  484. DialogBox.ShowWarning(string.Format("The value should be between {0} and {1}.", item.Min.ToString(), item.Max.ToString()));
  485. return;
  486. }
  487. string[] box = fValue.ToString().Split('.');
  488. if (box.Length > 1 && box[1].Length > 3)
  489. {
  490. DialogBox.ShowWarning(string.Format("The value should be more than three decimal places"));
  491. return;
  492. }
  493. }
  494. }
  495. else
  496. {
  497. DialogBox.ShowWarning("Please input valid data.");
  498. return;
  499. }
  500. value = item.StringValue;
  501. }
  502. else
  503. value = item.StringValue;
  504. }
  505. path = item.Path;
  506. currentValue = value;
  507. valueList.Add(new PageValue() { Path = path, CurrentValue = currentValue });
  508. }
  509. }
  510. }
  511. public void SetStepNameValue(object obj, MouseButtonEventArgs e)
  512. {
  513. e.Handled = true;
  514. if (StepNames == null || StepNames.Count == 0) return;
  515. ConfigItem item = null;
  516. if (obj is Control)
  517. item = StepNames.ToList().Find((x) => x.Name == (obj as Control).ToolTip.ToString());
  518. else
  519. item = obj as ConfigItem;
  520. if (item == null) return;
  521. if (item.Type == DataType.String)
  522. {
  523. currentValue = item.CurrentValue;
  524. path = item.Path;
  525. FullKeyboard fullKeyboard = new FullKeyboard("", currentValue);
  526. if ((bool)fullKeyboard.ShowDialog())
  527. {
  528. InvokeClient.Instance.Service.DoOperation($"{SystemName}.SetConfig", path, fullKeyboard.ValueString);
  529. currentValue = fullKeyboard.ValueString;
  530. item.CurrentValue = fullKeyboard.ValueString;
  531. }
  532. valueList.Add(new PageValue() { Path = path, CurrentValue = currentValue });
  533. }
  534. else
  535. {
  536. InputDialogViewModel dialog = new InputDialogViewModel();
  537. dialog.Item = item;
  538. dialog.DisplayName = "Set Value";
  539. WindowManager wm = new WindowManager();
  540. bool? bret = wm.ShowDialog(dialog);
  541. if ((bool)bret)
  542. {
  543. item.StringValue = dialog.DialogResult;
  544. //key :System.IsSimulatorMode
  545. //value: true or false 都是字符串
  546. //input check
  547. string value;
  548. value = item.StringValue;
  549. path = item.Path;
  550. currentValue = value;
  551. valueList.Add(new PageValue() { Path = path, CurrentValue = currentValue });
  552. }
  553. }
  554. }
  555. public void SaveParameter()
  556. {
  557. if (newValueList != null && newValueList.Count > 0)
  558. {
  559. var one = newValueList[0];
  560. if (one.Path.Contains("TempSetting"))
  561. {
  562. foreach (var item in valueList)
  563. {
  564. newValueList.Add(item);
  565. }
  566. valueList.Clear();
  567. valueList = newValueList;
  568. }
  569. }
  570. foreach (var item in valueList)
  571. {
  572. InvokeClient.Instance.Service.DoOperation($"{SystemName}.SetConfig", item.Path, item.CurrentValue);
  573. }
  574. valueList = new ObservableCollection<PageValue>();
  575. newValueList = new ObservableCollection<PageValue>();
  576. }
  577. private string[] HeaterNameList = new string[5] { "HeaterU", "HeaterCU", "HeaterC", "HeaterCL", "HeaterL" };
  578. public void GetHeaderConfig()
  579. {
  580. HeadLst.Clear();
  581. for (int i = 0; i < 5; i++)
  582. {
  583. var configHeater = (string)QueryDataClient.Instance.Service.GetConfig($"PM1.Heater.{HeaterNameList[i]}.DisplayName");
  584. TempSetData item = new TempSetData(configHeater);
  585. item.SetValue.Value = configHeater;
  586. HeadLst.Add(item);
  587. }
  588. }
  589. private ConfigNode FindNodeByName(ConfigNode parentNode, string strName)
  590. {
  591. string strCates = strName.Split('.')[0];
  592. ConfigNode node = parentNode.SubNodes.Find((x) => x.Name == strCates);
  593. if (node == null)
  594. return parentNode;
  595. else
  596. return FindNodeByName(node, strName.Replace(strCates + ".", ""));
  597. }
  598. }
  599. public class ParamBase
  600. {
  601. public int ID { get; set; }
  602. public string Name { get; set; }
  603. public int ParentID { get; set; }
  604. public string ConfigName { get; set; }
  605. public List<ParamBase> Children { get; set; }
  606. public ParamBase()
  607. {
  608. Children = new List<ParamBase>();
  609. }
  610. }
  611. public class ParameterConvert : IValueConverter
  612. {
  613. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  614. {
  615. return value.ToString().Replace("Table", "").Replace("LineNo", "");
  616. }
  617. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  618. {
  619. throw new NotImplementedException();
  620. }
  621. }
  622. }