VPWMainVacuumPumpControl.xaml.cs 6.5 KB

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