TVSettingDialogViewModel.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. using System;
  2. using System.ComponentModel;
  3. using System.Windows.Input;
  4. using Aitex.Core.Common.DeviceData;
  5. using MECF.Framework.Common.OperationCenter;
  6. using OpenSEMI.ClientBase;
  7. namespace MECF.Framework.UI.Client.Ctrlib.UnitControls
  8. {
  9. public class TVSettingDialogViewModel : DialogViewModel<string>, INotifyPropertyChanged
  10. {
  11. private AITThrottleValveData _data;
  12. public AITThrottleValveData DeviceData
  13. {
  14. get
  15. {
  16. return _data;
  17. }
  18. set
  19. {
  20. _data = value;
  21. NotifyOfPropertyChange(nameof(DeviceData));
  22. NotifyOfPropertyChange(nameof(IsPositionMode));
  23. NotifyOfPropertyChange(nameof(IsPressureMode));
  24. }
  25. }
  26. private string _setPointPosition;
  27. public string InputSetPointPosition
  28. {
  29. get { return _setPointPosition; }
  30. set
  31. {
  32. _setPointPosition = value;
  33. NotifyOfPropertyChange(nameof(InputSetPointPosition));
  34. }
  35. }
  36. private string _setPointPressure;
  37. public string InputSetPointPressure
  38. {
  39. get { return _setPointPressure; }
  40. set
  41. {
  42. _setPointPressure = value;
  43. NotifyOfPropertyChange(nameof(InputSetPointPressure));
  44. }
  45. }
  46. public bool IsPositionMode
  47. {
  48. get
  49. {
  50. return DeviceData != null && DeviceData.Mode == (int)PressureCtrlMode.TVPositionCtrl;
  51. }
  52. set
  53. {
  54. }
  55. }
  56. private bool _isPressureMode;
  57. public bool IsPressureMode
  58. {
  59. get
  60. {
  61. //return _isPressureMode;
  62. return DeviceData != null && DeviceData.Mode == (int)PressureCtrlMode.TVPressureCtrl;
  63. }
  64. set
  65. {
  66. if (value != _isPressureMode)
  67. {
  68. }
  69. _isPressureMode = value;
  70. }
  71. }
  72. private bool _enableOk;
  73. public bool IsEnableOk
  74. {
  75. get
  76. {
  77. return _enableOk;
  78. }
  79. set
  80. {
  81. _enableOk = value;
  82. NotifyOfPropertyChange(nameof(IsEnableOk));
  83. }
  84. }
  85. public ICommand PositionCommand { get; set; }
  86. public TVSettingDialogViewModel(string dialogName = "")
  87. {
  88. this.DisplayName = dialogName;
  89. }
  90. public void Cancel()
  91. {
  92. IsCancel = true;
  93. TryClose(false);
  94. }
  95. protected override void OnViewLoaded(object view)
  96. {
  97. base.OnViewLoaded(view);
  98. }
  99. public void SetPosition()
  100. {
  101. if (IsPositionMode)
  102. return;
  103. InvokeClient.Instance.Service.DoOperation($"{DeviceData.Module}.{DeviceData.DeviceName}.{AITThrottleValveOperation.SetMode}", PressureCtrlMode.TVPositionCtrl.ToString());
  104. }
  105. public void SetPressure()
  106. {
  107. if (IsPressureMode)
  108. return;
  109. InvokeClient.Instance.Service.DoOperation($"{DeviceData.Module}.{DeviceData.DeviceName}.{AITThrottleValveOperation.SetMode}", PressureCtrlMode.TVPressureCtrl.ToString());
  110. }
  111. public void Set()
  112. {
  113. if (IsPressureMode)
  114. SetPressureExecute(Convert.ToDouble(InputSetPointPressure));
  115. else if (IsPositionMode)
  116. SetPositionExecute(Convert.ToDouble(InputSetPointPosition));
  117. }
  118. private void SetPressureExecute(double value)
  119. {
  120. InvokeClient.Instance.Service.DoOperation($"{DeviceData.Module}.{DeviceData.DeviceName}.{AITThrottleValveOperation.SetPressure}", (float)value);
  121. }
  122. private void SetPositionExecute(double value)
  123. {
  124. InvokeClient.Instance.Service.DoOperation($"{DeviceData.Module}.{DeviceData.DeviceName}.{AITThrottleValveOperation.SetPosition}", (float)value);
  125. }
  126. }
  127. }