GasXmlViewModel.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. using Aitex.Core.Common.DeviceData;
  2. using Aitex.Core.Util;
  3. using DocumentFormat.OpenXml;
  4. using DocumentFormat.OpenXml.Drawing;
  5. using DocumentFormat.OpenXml.Wordprocessing;
  6. using FurnaceGasPanelUI.Models;
  7. using MECF.Framework.Common;
  8. using MECF.Framework.Common.DataCenter;
  9. using MECF.Framework.Common.OperationCenter;
  10. using MECF.Framework.UI.Client.ClientBase;
  11. using MECF.Framework.UI.Core.Control;
  12. using MECF.Framework.UI.Core.ExtendedControls;
  13. using OpenSEMI.ClientBase;
  14. using System;
  15. using System.Collections.Generic;
  16. using System.Linq;
  17. using System.ServiceModel.Channels;
  18. using System.Text;
  19. using System.Threading.Tasks;
  20. using System.Windows;
  21. using MECF.Framework.UI.Core.DxfScript;
  22. using Aitex.Core.UI.Control;
  23. using DocumentFormat.OpenXml.Spreadsheet;
  24. using MECF.Framework.Common.Equipment;
  25. namespace FurnaceGasPanelUI.Views.Maintenances
  26. {
  27. public class GasXmlViewModel : ThermalGasPanelUIViewModelBase, MECF.Framework.Common.IUserFunctions
  28. {
  29. #region
  30. private string _PM = $"{ModuleName.PM1.ToString()}.";
  31. [Subscription("System.NameKeyDict")]
  32. public Dictionary<string, List<string>> NameKeyDict { get; set; }
  33. public Window WinOwner { get; set; }
  34. private GasPanelStateType _selectedGasStateType = GasPanelStateType.Monitor;
  35. public GasPanelStateType SelectedGasStateType
  36. {
  37. get
  38. {
  39. return _selectedGasStateType;
  40. }
  41. set
  42. {
  43. _selectedGasStateType = value;
  44. NotifyOfPropertyChange(nameof(SelectedGasStateType));
  45. }
  46. }
  47. #endregion
  48. public GasXmlViewModel()
  49. {
  50. UserFunctionsEvents.ClearAll();
  51. UserFunctionsEvents.RegisterEvent<Dictionary<string, object>>("SwichValue", SwichValue);
  52. UserFunctionsEvents.RegisterEvent<Dictionary<string, object>>("ValveTouchUp", ValveTouchUp);
  53. UserFunctionsEvents.RegisterEvent<Dictionary<string, object>>("MfcFlowTouchUp", MfcFlowTouchUp);
  54. }
  55. protected override void OnViewLoaded(object view)
  56. {
  57. base.OnViewLoaded(view);
  58. SwitchKey();
  59. }
  60. protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
  61. {
  62. base.InvokeAfterUpdateProperty(data);
  63. GasMapProvider.GasMap.ModifyDrag();
  64. }
  65. public void SelectedGasStateTypeCmd(string cmd)
  66. {
  67. switch (cmd)
  68. {
  69. case "Manual":
  70. SelectedGasStateType = GasPanelStateType.Manual;
  71. break;
  72. case "Monitor":
  73. SelectedGasStateType = GasPanelStateType.Monitor;
  74. break;
  75. case "Recipe":
  76. SelectedGasStateType = GasPanelStateType.Recipe;
  77. break;
  78. default:
  79. break;
  80. }
  81. SwitchKey(SelectedGasStateType == GasPanelStateType.Monitor);
  82. }
  83. /// <summary>
  84. /// 切换Key
  85. /// </summary>
  86. /// <param name="isMonitor"></param>
  87. public void SwitchKey(bool isMonitor = true)
  88. {
  89. foreach (var item in GasMapProvider.GasMap.Valves)
  90. {
  91. var realKey = $"{ModuleName.PM1.ToString()}.{item.Name}.Feedback";
  92. var recipeKey = $"{ModuleName.PM1.ToString()}.{item.Name}.VirtualStatus";
  93. item.Key = isMonitor ? realKey : recipeKey;
  94. }
  95. foreach (var item in GasMapProvider.GasMap.Buttons)
  96. {
  97. bool isExextue = item.BoolCondition != null;
  98. var realKey = $"{ModuleName.PM1}.{item.InnerText.Text}Enable";
  99. if (isExextue)
  100. {
  101. item.BoolCondition.Execute();
  102. realKey = item.BoolCondition.ReadBoolValue().Item1;
  103. }
  104. item.DataKey = isMonitor ? realKey : realKey;
  105. }
  106. foreach (var item in GasMapProvider.GasMap.Analogs)
  107. {
  108. item.Brush = GasMapProvider.InitMFCColor;
  109. var realKey = $"{ModuleName.PM1}.{item.Name}.Feedback";
  110. var recipeKey = $"{ModuleName.PM1}.{item.Name}.SetPoint";
  111. item.ValueKey = isMonitor ? realKey : recipeKey;
  112. }
  113. foreach (var item in GasMapProvider.GasMap.Circles)
  114. {
  115. bool isExextue = item.ClickCondition == null && item.BoolCondition != null && item.StringCondition == null;
  116. if (isExextue)
  117. {
  118. item.BoolCondition.Execute();
  119. item.Key = item.BoolCondition.ReadBoolValue().Item1;
  120. continue;
  121. }
  122. }
  123. }
  124. public void SetEnable(Dictionary<string, object> parameter)
  125. {
  126. }
  127. public void SwichValue(Dictionary<string, object> parameter)
  128. {
  129. }
  130. public void ValveTouchUp(Dictionary<string, object> parameter)
  131. {
  132. }
  133. public void MfcFlowTouchUp(Dictionary<string, object> parameter)
  134. {
  135. }
  136. }
  137. }