SystemConfigViewModel.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Linq;
  5. using System.Windows;
  6. using Aitex.Core.RT.IOCore;
  7. using Caliburn.Micro;
  8. using Caliburn.Micro.Core;
  9. using MECF.Framework.Common.DataCenter;
  10. using MECF.Framework.Common.IOCore;
  11. using MECF.Framework.Common.OperationCenter;
  12. using MECF.Framework.UI.Client.CenterViews.Dialogs;
  13. using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
  14. using MECF.Framework.UI.Client.CenterViews.Editors.Sequence;
  15. using MECF.Framework.UI.Client.ClientBase;
  16. using OpenSEMI.ClientBase;
  17. using OpenSEMI.ClientBase.Command;
  18. using OpenSEMI.ClientBase.IO;
  19. namespace MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig
  20. {
  21. public class SystemConfigViewModel : UiViewModelBase, ISupportMultipleSystem
  22. {
  23. #region Properties
  24. public bool IsPermission { get => this.Permission == 3; }
  25. private SystemConfigView view1;
  26. private Visibility _isShowShutDown = Visibility.Hidden;
  27. public Visibility IsShowShutDown
  28. {
  29. get => _isShowShutDown;
  30. set
  31. {
  32. _isShowShutDown = value;
  33. NotifyOfPropertyChange(nameof(IsShowShutDown));
  34. }
  35. }
  36. private Visibility _isShowTable = Visibility.Hidden;
  37. public Visibility IsShowTable
  38. {
  39. get => _isShowTable;
  40. set
  41. {
  42. _isShowTable = value;
  43. NotifyOfPropertyChange(nameof(IsShowTable));
  44. }
  45. }
  46. private Visibility _isListData = Visibility.Hidden;
  47. public Visibility IsListData
  48. {
  49. get => _isListData;
  50. set
  51. {
  52. _isListData = value;
  53. NotifyOfPropertyChange(nameof(IsListData));
  54. }
  55. }
  56. private Visibility _isShowData = Visibility.Hidden;
  57. public Visibility IsShowData
  58. {
  59. get => _isShowData;
  60. set
  61. {
  62. _isShowData = value;
  63. NotifyOfPropertyChange(nameof(IsShowData));
  64. }
  65. }
  66. private Visibility _isShowAUX = Visibility.Hidden;
  67. public Visibility IsShowAUX
  68. {
  69. get => _isShowAUX;
  70. set
  71. {
  72. _isShowAUX = value;
  73. NotifyOfPropertyChange(nameof(IsShowAUX));
  74. }
  75. }
  76. private bool _isShowRobotControl = false;
  77. public bool IsShowRobotControl
  78. {
  79. get => _isShowRobotControl;
  80. set
  81. {
  82. _isShowRobotControl = value;
  83. NotifyOfPropertyChange(nameof(IsShowRobotControl));
  84. }
  85. }
  86. private List<ConfigNode> _ConfigNodes = new List<ConfigNode>();
  87. public List<ConfigNode> ConfigNodes
  88. {
  89. get { return _ConfigNodes; }
  90. set { _ConfigNodes = value; NotifyOfPropertyChange("ConfigNodes"); }
  91. }
  92. private ObservableCollection<ConfigItem> _configItems = new ObservableCollection<ConfigItem>();
  93. public ObservableCollection<ConfigItem> ConfigItems
  94. {
  95. get { return _configItems; }
  96. set { _configItems = value; NotifyOfPropertyChange("ConfigItems"); }
  97. }
  98. private ObservableCollection<ConfigItem> _configAUXItems = new ObservableCollection<ConfigItem>();
  99. public ObservableCollection<ConfigItem> ConfigAUXItems
  100. {
  101. get { return _configAUXItems; }
  102. set { _configAUXItems = value; NotifyOfPropertyChange("ConfigAUXItems"); }
  103. }
  104. string _CurrentNodeName = string.Empty;
  105. public BaseCommand<ConfigNode> TreeViewSelectedItemChangedCmd { private set; get; }
  106. private ObservableCollection<PageValue> valueList { get; set; } = new ObservableCollection<PageValue>();
  107. public ObservableCollection<ListName> NameList { get; set; } = new ObservableCollection<ListName>();
  108. public ObservableCollection<AOItemFloat> AOs { get; private set; }
  109. private string _currentCriteria = String.Empty;
  110. public string CurrentCriteria
  111. {
  112. get { return _currentCriteria; }
  113. set
  114. {
  115. if (value == _currentCriteria)
  116. return;
  117. _currentCriteria = value;
  118. NotifyOfPropertyChange("CurrentCriteria");
  119. ApplyFilter();
  120. }
  121. }
  122. public string SystemName { get; set; }
  123. private void ApplyFilter()
  124. {
  125. foreach (var node in ConfigNodes)
  126. node.ApplyCriteria(CurrentCriteria, new Stack<ConfigNode>());
  127. }
  128. #endregion
  129. #region Functions
  130. public SystemConfigViewModel()
  131. {
  132. this.DisplayName = "System Config";
  133. TreeViewSelectedItemChangedCmd = new BaseCommand<ConfigNode>(TreeViewSelectedItemChanged);
  134. }
  135. protected override void OnInitialize()
  136. {
  137. base.OnInitialize();
  138. ConfigNodes = SystemConfigProvider.Instance.GetConfigTree(SystemName).SubNodes;
  139. }
  140. protected override void OnActivate()
  141. {
  142. base.OnActivate();
  143. ConfigNodes = SystemConfigProvider.Instance.GetConfigTree(SystemName).SubNodes;
  144. }
  145. protected override void OnViewLoaded(object view)
  146. {
  147. base.OnViewLoaded(view);
  148. view1 = (SystemConfigView)view;
  149. }
  150. private void SetShowView(string name)
  151. {
  152. switch (name)
  153. {
  154. case "IsShowTable":
  155. IsShowTable = Visibility.Visible;
  156. IsShowData = Visibility.Hidden;
  157. IsListData = Visibility.Hidden;
  158. IsShowAUX = Visibility.Hidden;
  159. IsShowShutDown = Visibility.Hidden;
  160. break;
  161. case "IsShowData":
  162. IsShowTable = Visibility.Hidden;
  163. IsShowData = Visibility.Visible;
  164. IsListData = Visibility.Hidden;
  165. IsShowAUX = Visibility.Hidden;
  166. IsShowShutDown = Visibility.Hidden;
  167. if (view1 != null)
  168. {
  169. view1.ShowAUX.ItemsSource = null;
  170. view1.ShowData.ItemsSource = ConfigItems;
  171. }
  172. break;
  173. case "IsListData":
  174. IsShowTable = Visibility.Hidden;
  175. IsShowData = Visibility.Hidden;
  176. IsListData = Visibility.Visible;
  177. IsShowAUX = Visibility.Hidden;
  178. IsShowShutDown = Visibility.Hidden;
  179. break;
  180. case "IsShowAUX":
  181. IsShowTable = Visibility.Hidden;
  182. IsShowData = Visibility.Hidden;
  183. IsListData = Visibility.Hidden;
  184. IsShowAUX = Visibility.Visible;
  185. IsShowShutDown = Visibility.Hidden;
  186. if (view1 != null)
  187. {
  188. view1.ShowData.ItemsSource = null;
  189. view1.ShowAUX.ItemsSource = ConfigItems;
  190. }
  191. break;
  192. case "IsShowShutDown":
  193. IsShowShutDown = Visibility.Visible;
  194. IsShowTable = Visibility.Hidden;
  195. IsShowData = Visibility.Hidden;
  196. IsListData = Visibility.Hidden;
  197. IsShowAUX = Visibility.Hidden;
  198. break;
  199. default:
  200. break;
  201. }
  202. }
  203. private void TreeViewSelectedItemChanged(ConfigNode node)
  204. {
  205. valueList.Clear();
  206. _CurrentNodeName = string.IsNullOrEmpty(node.Path) ? node.Name : $"{node.Path}.{node.Name}";
  207. ConfigItems.Clear();
  208. node.Items.ForEach(x => ConfigItems.Add(x));
  209. if (_CurrentNodeName.EndsWith("ShutDown"))
  210. {
  211. SetShowView("IsShowShutDown");
  212. IsShowRobotControl = (bool)QueryDataClient.Instance.Service.GetConfig("System.ShutDown.EnableRobotControl");
  213. }
  214. else if (_CurrentNodeName.Contains("WaferCycleTime"))
  215. {
  216. SetShowView("IsShowTable");
  217. }
  218. else if (_CurrentNodeName.Contains("Step Name"))
  219. {
  220. int count = int.Parse(ConfigItems.FirstOrDefault(x => x.Name == "Count").DefaultValue);
  221. string names = ConfigItems.FirstOrDefault(x => x.Name == "Name").StringValue;
  222. NameList.Clear();
  223. int index = 1;
  224. for (int i = 0; i < count; i++)
  225. {
  226. NameList.Add(new ListName()
  227. { No = index, Name = "" });
  228. index++;
  229. }
  230. if (!string.IsNullOrEmpty(names))
  231. {
  232. }
  233. SetShowView("IsListData");
  234. }
  235. else if (_CurrentNodeName.Contains("AUX"))
  236. {
  237. //if (ConfigAUXItems.Count() == 0)
  238. //{
  239. node.Items.ForEach(x => ConfigAUXItems.Add(x));
  240. for (int i = 0; i < ConfigAUXItems.Count; i++)
  241. {
  242. ConfigAUXItems[i].CurrentValueParam.Value = ConfigAUXItems[i].CurrentValue;
  243. ConfigAUXItems[i].Unit = (i + 1).ToString();
  244. }
  245. //}
  246. GetDataOfConfigAUXItems();
  247. SetShowView("IsShowAUX");
  248. return;
  249. }
  250. else
  251. {
  252. SetShowView("IsShowData");
  253. }
  254. GetDataOfConfigItems();
  255. }
  256. private void GetDataOfConfigItems()
  257. {
  258. if (ConfigItems == null || ConfigItems.Count == 0)
  259. return;
  260. for (int i = 0; i < ConfigItems.Count; i++)
  261. {
  262. string key = String.Format("{0}{1}{2}", _CurrentNodeName, ".", ConfigItems[i].Name);
  263. ConfigItems[i].CurrentValue = SystemConfigProvider.Instance.GetValueByName(SystemName, key);
  264. if (ConfigItems[i].Type == DataType.Bool)
  265. {
  266. bool value;
  267. if (bool.TryParse(ConfigItems[i].CurrentValue, out value))
  268. {
  269. ConfigItems[i].BoolValue = value;
  270. ConfigItems[i].CurrentValue = value ? "Yes" : "No";
  271. }
  272. }
  273. else
  274. ConfigItems[i].StringValue = ConfigItems[i].CurrentValue;
  275. }
  276. }
  277. private void GetDataOfConfigAUXItems()
  278. {
  279. if (ConfigAUXItems == null || ConfigAUXItems.Count == 0)
  280. return;
  281. for (int i = 0; i < ConfigAUXItems.Count; i++)
  282. {
  283. string key = String.Format("{0}{1}{2}", _CurrentNodeName, ".", ConfigAUXItems[i].Name);
  284. ConfigAUXItems[i].CurrentValueParam.Value = SystemConfigProvider.Instance.GetValueByName(SystemName, key);
  285. }
  286. }
  287. public void SetValue(ConfigItem item)
  288. {
  289. InputDialogViewModel dialog = new InputDialogViewModel();
  290. RecipeSelectDialogViewModel selectDialog = new RecipeSelectDialogViewModel();
  291. WindowManager wm = new WindowManager();
  292. bool? bret = null;
  293. if (item.Name == "Idle Recipe" || item.Name == "Abort Recipe" || item.Name == "Reset Recipe")
  294. {
  295. selectDialog.DisplayName = "Select Recipe";
  296. var recipeProvider = new RecipeProvider();
  297. string selectRecipeType = "";
  298. if (item.Name == "Idle Recipe")
  299. selectRecipeType = "Idle";
  300. else if (item.Name == "Abort Recipe")
  301. selectRecipeType = "Abort";
  302. else
  303. selectRecipeType = "Reset";
  304. var processType = QueryDataClient.Instance.Service.GetConfig($"System.Recipe.{selectRecipeType}");
  305. if (processType == null)
  306. {
  307. processType = selectRecipeType;
  308. }
  309. var ProcessTypeFileList = new ObservableCollection<ProcessTypeFileItem>();
  310. string[] recipeProcessType = ((string)processType).Split(',');
  311. for (int i = 0; i < recipeProcessType.Length; i++)
  312. {
  313. var type = new ProcessTypeFileItem();
  314. type.ProcessType = recipeProcessType[i];
  315. var prefix = $"Furnace\\{recipeProcessType[i]}";
  316. var recipes = recipeProvider.GetXmlRecipeList(prefix);
  317. type.FileListByProcessType = RecipeSequenceTreeBuilder.BuildFileNode(prefix, "", false, recipes)[0].Files;
  318. ProcessTypeFileList.Add(type);
  319. }
  320. selectDialog.ProcessTypeFileList = ProcessTypeFileList;
  321. bret = wm.ShowDialog(selectDialog);
  322. }
  323. else
  324. {
  325. if (item.Type == DataType.String) dialog.KeyboardType = "FullKeyboard";
  326. dialog.Item = item;
  327. dialog.DisplayName = "Set Value";
  328. bret = wm.ShowDialog(dialog);
  329. }
  330. string strOldValue = item.CurrentValue;
  331. if ((bool)bret)
  332. {
  333. item.StringValue = dialog.DialogResult;
  334. string value = string.Empty;
  335. switch (item.Type)
  336. {
  337. case DataType.Int:
  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. break;
  357. case DataType.Double:
  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. break;
  383. case DataType.Bool:
  384. if (item.StringValue.Equals("Yes", StringComparison.CurrentCultureIgnoreCase))
  385. item.BoolValue = true;
  386. else if (item.StringValue.Equals("No", StringComparison.CurrentCultureIgnoreCase))
  387. item.BoolValue = false;
  388. else
  389. {
  390. DialogBox.ShowWarning("The Value Should be Yes Or No.");
  391. return;
  392. }
  393. value = item.BoolValue.ToString().ToLower();
  394. break;
  395. case DataType.String:
  396. if (item.StringValue != null)
  397. value = item.StringValue;
  398. else
  399. value = selectDialog.DialogResult;
  400. break;
  401. }
  402. if (_CurrentNodeName == "System.ShutDown" && item.StringValue == "ShutDown")
  403. InvokeClient.Instance.Service.DoOperation("System.ShutDown");
  404. //压力单位改变时候,已有设置根据改变进行值转换
  405. if (item.Name == "PressureUnit")
  406. ChangePressureUnit(value);
  407. InvokeClient.Instance.Service.DoOperation($"System.BackUpFileData");
  408. string key = String.Format("{0}{1}{2}", _CurrentNodeName, ".", item.Name);
  409. valueList.Add(new PageValue() { Path = key, CurrentValue = value });
  410. InvokeClient.Instance.Service.DoOperation($"{SystemName}.SetConfig", key, value);
  411. if (item.Name == "Idle Recipe" || item.Name == "Abort Recipe" || item.Name == "Reset Recipe")
  412. {
  413. GetDataOfConfigItems();
  414. }
  415. }
  416. }
  417. private void ChangePressureUnit(string strNewValue)
  418. {
  419. //double dValue = 0;
  420. //if (strNewValue.Equals("Torr"))//从Pa转换成Torr
  421. // dValue = 0.0075006;
  422. //else //从Torr转换成Pa
  423. // dValue = 133.322;
  424. //for (int i = 1; i <= 5; i++)
  425. //{
  426. // string key = $"PM1.RecipeEditParameter.PressureStabilizeTable.Table{i}.MaxScale";
  427. // double newValue = dValue * double.Parse(SystemConfigProvider.Instance.GetValueByName(SystemName, key));
  428. // InvokeClient.Instance.Service.DoOperation($"{SystemName}.SetConfig", key, newValue);
  429. //}
  430. InvokeClient.Instance.Service.DoOperation($"PM1.APC.SetUnit", strNewValue);
  431. }
  432. public void Reload()
  433. {
  434. GetDataOfConfigItems();
  435. }
  436. public void SaveAll()
  437. {
  438. if (ConfigItems == null)
  439. return;
  440. ConfigItems.ToList().ForEach(item => SetValue(item));
  441. }
  442. public void SaveParameter()
  443. {
  444. foreach (var item in valueList)
  445. {
  446. InvokeClient.Instance.Service.DoOperation($"{SystemName}.SetConfig", item.Path, item.CurrentValue);
  447. }
  448. Reload();
  449. }
  450. public void Cancel()
  451. {
  452. valueList.Clear();
  453. Reload();
  454. }
  455. public void CollapseAll()
  456. {
  457. SetExpand(ConfigNodes, false);
  458. }
  459. public void ExpandAll()
  460. {
  461. SetExpand(ConfigNodes, true);
  462. }
  463. public void AllControl()
  464. {
  465. var windowManager = IoC.Get<IWindowManager>();
  466. ShutDonwControlViewModel shutDonwControlViewModel = new ShutDonwControlViewModel();
  467. shutDonwControlViewModel.AllControlVisibility = true;
  468. (windowManager as WindowManager)?.ShowDialogWithTitle(shutDonwControlViewModel, null, "All Control");
  469. }
  470. public void UIControl()
  471. {
  472. var windowManager = IoC.Get<IWindowManager>();
  473. ShutDonwControlViewModel shutDonwControlViewModel = new ShutDonwControlViewModel();
  474. shutDonwControlViewModel.UIControlVisibility = true;
  475. (windowManager as WindowManager)?.ShowDialogWithTitle(shutDonwControlViewModel, null, "UI Control");
  476. }
  477. public void UIAndRTControl()
  478. {
  479. var windowManager = IoC.Get<IWindowManager>();
  480. ShutDonwControlViewModel shutDonwControlViewModel = new ShutDonwControlViewModel();
  481. shutDonwControlViewModel.UIAndRTControlVisibility = true;
  482. (windowManager as WindowManager)?.ShowDialogWithTitle(shutDonwControlViewModel, null, "UI And RT Control");
  483. }
  484. public void ClearFilter()
  485. {
  486. CurrentCriteria = "";
  487. }
  488. public void SetExpand(List<ConfigNode> configs, bool expand)
  489. {
  490. if (configs == null)
  491. return;
  492. foreach (var configNode in configs)
  493. {
  494. configNode.IsExpanded = expand;
  495. if (configNode.SubNodes != null)
  496. SetExpand(configNode.SubNodes, expand);
  497. }
  498. }
  499. #endregion
  500. protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
  501. {
  502. base.InvokeAfterUpdateProperty(data);
  503. string _aoKey = $"{SystemName}.PM1.AOList";
  504. if (data.ContainsKey(_aoKey)&&data[_aoKey] != null && _isReadPLC)
  505. {
  506. List<NotifiableIoItem> lstData = (List<NotifiableIoItem>)data[_aoKey];
  507. for (int i = 0; i < lstData.Count; i++)
  508. {
  509. var findConfigAUX = ConfigAUXItems.FirstOrDefault(x => $"PM1.{x.Name}" == lstData[i].Name);
  510. if (findConfigAUX != null)
  511. {
  512. if (findConfigAUX.CurrentValueParam.Value != lstData[i].FloatValue.ToString())
  513. {
  514. findConfigAUX.CurrentValueParam.SetValue(lstData[i].FloatValue.ToString());
  515. }
  516. }
  517. }
  518. _isReadPLC = false;
  519. }
  520. }
  521. public void AUXSaveClick()
  522. {
  523. SaveValueToSC();
  524. if (DialogBox.Confirm("Save SC Value To PLC?"))
  525. {
  526. SaveValueToPLC(true);
  527. }
  528. }
  529. public void AUXUploadClick()
  530. {
  531. if (DialogBox.Confirm("Upload save PLC data to SC?"))
  532. {
  533. GetPLCToSC();
  534. }
  535. }
  536. public void AUXDownloadClick()
  537. {
  538. if (DialogBox.Confirm("Save SC data and download to PLC?"))
  539. {
  540. SaveValueToSC();
  541. SaveValueToPLC();
  542. }
  543. }
  544. private void SaveValueToSC()
  545. {
  546. foreach (var item in ConfigAUXItems)
  547. {
  548. InvokeClient.Instance.Service.DoOperation($"{SystemName}.SetConfig", $"{item.Path}.{item.Name}", item.CurrentValueParam.Value);
  549. }
  550. }
  551. private void SaveValueToPLC(bool isSaveAll = false)
  552. {
  553. if (isSaveAll)
  554. {
  555. foreach (var item in ConfigAUXItems)
  556. {
  557. float tempValue = 0;
  558. float.TryParse(item.CurrentValueParam.Value, out tempValue);
  559. InvokeClient.Instance.Service.DoOperation("System.SetAoValueFloat", $"PM1.{item.Name}", tempValue);
  560. item.CurrentValueParam.IsSaved = true;
  561. }
  562. }
  563. else
  564. {
  565. foreach (var item in ConfigAUXItems)
  566. {
  567. if (!item.CurrentValueParam.IsSaved)
  568. {
  569. float tempValue = 0;
  570. float.TryParse(item.CurrentValueParam.Value, out tempValue);
  571. InvokeClient.Instance.Service.DoOperation("System.SetAoValueFloat", $"PM1.{item.Name}", tempValue);
  572. item.CurrentValueParam.IsSaved = true;
  573. }
  574. }
  575. }
  576. }
  577. private static bool _isReadPLC = false;
  578. private void GetPLCToSC()
  579. {
  580. _isReadPLC = true;
  581. string _aoKey = $"{SystemName}.PM1.AOItemList";
  582. this.AOs = InitIOData(IOType.AO, _aoKey);
  583. _aoKey = $"{SystemName}.PM1.AOList";
  584. Subscribe(_aoKey);
  585. }
  586. public ObservableCollection<AOItemFloat> InitIOData(IOType type, string dataName)
  587. {
  588. //get the whole informations
  589. ObservableCollection<AOItemFloat> da = new ObservableCollection<AOItemFloat>();
  590. if (type == IOType.AO)
  591. {
  592. var diList = QueryDataClient.Instance.Service.GetData(dataName);
  593. if (diList != null)
  594. {
  595. List<NotifiableIoItem> item = (List<NotifiableIoItem>)diList;
  596. for (int i = 0; i < item.Count; i++)
  597. {
  598. {
  599. da.Add(new AOItemFloat()
  600. {
  601. Index = da.Count,
  602. Name = item[i].Name,
  603. //DisplayName = item[i].Name.Substring(item[i].Name.IndexOf('.') + 1),
  604. DisplayName = item[i].Description,
  605. Value = item[i].FloatValue,
  606. Address = item[i].Address
  607. });
  608. }
  609. }
  610. }
  611. }
  612. return da;
  613. }
  614. }
  615. public class ListName : PropertyChangedBase
  616. {
  617. private int _no;
  618. public int No
  619. {
  620. get => _no;
  621. set
  622. {
  623. _no = value;
  624. NotifyOfPropertyChange(nameof(No));
  625. }
  626. }
  627. private string _name;
  628. public string Name
  629. {
  630. get => _name;
  631. set
  632. {
  633. _name = value;
  634. NotifyOfPropertyChange(nameof(Name));
  635. }
  636. }
  637. }
  638. public class PageValue
  639. {
  640. public string Path { get; set; }
  641. public double Min { get; set; }
  642. public double Max { get; set; }
  643. public DataType Type { get; set; }
  644. public string CurrentValue { get; set; }
  645. public List<string> Parameters { get; set; }
  646. }
  647. }