MainParameterEditViewModel.cs 28 KB

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