MainParameterEditViewModel.cs 28 KB

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