VPWBoosterPumpControl.xaml.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. using Aitex.Core.UI.MVVM;
  2. using Aitex.Core.Utilities;
  3. using MECF.Framework.Common.CommonData.Prewet;
  4. using MECF.Framework.Common.OperationCenter;
  5. using MECF.Framework.Common.Persistent.Prewet;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows;
  12. using System.Windows.Controls;
  13. using System.Windows.Data;
  14. using System.Windows.Documents;
  15. using System.Windows.Input;
  16. using System.Windows.Media;
  17. using System.Windows.Media.Imaging;
  18. using System.Windows.Navigation;
  19. using System.Windows.Shapes;
  20. namespace PunkHPX8_Themes.UserControls
  21. {
  22. /// <summary>
  23. /// VPWBoosterPumpControl.xaml 的交互逻辑
  24. /// </summary>
  25. public partial class VPWBoosterPumpControl : UserControl
  26. {
  27. public VPWBoosterPumpControl()
  28. {
  29. KeyDownCommand = new DelegateCommand<object[]>(KeyDownAction);
  30. InitializeComponent();
  31. }
  32. #region 属性
  33. public static readonly DependencyProperty ModuleNameProperty = DependencyProperty.Register(
  34. "ModuleName", typeof(string), typeof(VPWBoosterPumpControl),
  35. new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
  36. /// <summary>
  37. /// 模块名称
  38. /// </summary>
  39. public string ModuleName
  40. {
  41. get
  42. {
  43. return (string)this.GetValue(ModuleNameProperty);
  44. }
  45. set
  46. {
  47. this.SetValue(ModuleNameProperty, value);
  48. }
  49. }
  50. public static readonly DependencyProperty StatusValueProperty = DependencyProperty.Register(
  51. "StatusValue", typeof(string), typeof(VPWBoosterPumpControl),
  52. new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
  53. /// <summary>
  54. /// StatusValue
  55. /// </summary>
  56. public string StatusValue
  57. {
  58. get
  59. {
  60. return (string)this.GetValue(StatusValueProperty);
  61. }
  62. set
  63. {
  64. this.SetValue(StatusValueProperty, value);
  65. }
  66. }
  67. public static readonly DependencyProperty InputPumpSpeedProperty = DependencyProperty.Register(
  68. "InputPumpSpeed", typeof(short), typeof(VPWBoosterPumpControl), new FrameworkPropertyMetadata((short)300, FrameworkPropertyMetadataOptions.AffectsRender));
  69. /// <summary>
  70. /// InputLowThreshold
  71. /// </summary>
  72. public short InputPumpSpeed
  73. {
  74. get
  75. {
  76. return (short)this.GetValue(InputPumpSpeedProperty);
  77. }
  78. set
  79. {
  80. this.SetValue(InputPumpSpeedProperty, value);
  81. }
  82. }
  83. public static readonly DependencyProperty PumpEnableProperty = DependencyProperty.Register(
  84. "PumpEnable", typeof(bool), typeof(VPWBoosterPumpControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  85. /// <summary>
  86. /// PumpEnable
  87. /// </summary>
  88. public bool PumpEnable
  89. {
  90. get
  91. {
  92. return (bool)this.GetValue(PumpEnableProperty);
  93. }
  94. set
  95. {
  96. this.SetValue(PumpEnableProperty, value);
  97. }
  98. }
  99. public static readonly DependencyProperty PumpSpeedAutoProperty = DependencyProperty.Register(
  100. "PumpSpeedAuto", typeof(bool), typeof(VPWBoosterPumpControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  101. /// <summary>
  102. /// PumpSpeedAuto
  103. /// </summary>
  104. public bool PumpSpeedAuto
  105. {
  106. get
  107. {
  108. return (bool)this.GetValue(PumpSpeedAutoProperty);
  109. }
  110. set
  111. {
  112. this.SetValue(PumpSpeedAutoProperty, value);
  113. }
  114. }
  115. public static readonly DependencyProperty PressureCurrentProperty = DependencyProperty.Register(
  116. "PressureCurrent", typeof(double), typeof(VPWBoosterPumpControl), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
  117. /// <summary>
  118. /// "PressureCurrent
  119. /// </summary>
  120. public double PressureCurrent
  121. {
  122. get
  123. {
  124. return (double)this.GetValue(PressureCurrentProperty);
  125. }
  126. set
  127. {
  128. this.SetValue(PressureCurrentProperty, value);
  129. }
  130. }
  131. #endregion
  132. [IgnorePropertyChange]
  133. public ICommand KeyDownCommand
  134. {
  135. get;
  136. private set;
  137. }
  138. private void KeyDownAction(object[] param)
  139. {
  140. if (param.Length >= 1)
  141. {
  142. if (short.TryParse(param[1].ToString(), out short paramValue))
  143. {
  144. if (paramValue < 300 || paramValue > 7300)
  145. {
  146. MessageBox.Show("qualified values 300 ~ 7300", "Invalid Speed Input", MessageBoxButton.OK, MessageBoxImage.Error);
  147. }
  148. else
  149. {
  150. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.BoosterPumpSpeed", paramValue);
  151. }
  152. }
  153. }
  154. }
  155. #region 按钮事件
  156. private void PumpOff_Click(object sender, RoutedEventArgs e)
  157. {
  158. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.BoosterPumpDisable");
  159. }
  160. private void PumpOn_Click(object sender, RoutedEventArgs e)
  161. {
  162. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.BoosterPumpEnable");
  163. }
  164. private void Auto_Click(object sender, RoutedEventArgs e)
  165. {
  166. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.BoosterPumpSpeedAuto");
  167. }
  168. private void Manual_Click(object sender, RoutedEventArgs e)
  169. {
  170. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.BoosterPumpSpeedManual");
  171. }
  172. #endregion
  173. }
  174. }