PrewetLeftSideControl.xaml.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. using Aitex.Core.UI.MVVM;
  2. using Aitex.Core.Utilities;
  3. using MECF.Framework.Common.CommonData.Prewet;
  4. using MECF.Framework.Common.CommonData.SRD;
  5. using MECF.Framework.Common.OperationCenter;
  6. using MECF.Framework.Common.Persistent.Prewet;
  7. using MECF.Framework.Common.Persistent.SRD;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows;
  14. using System.Windows.Controls;
  15. using System.Windows.Data;
  16. using System.Windows.Documents;
  17. using System.Windows.Input;
  18. using System.Windows.Media;
  19. using System.Windows.Media.Imaging;
  20. using System.Windows.Navigation;
  21. using System.Windows.Shapes;
  22. namespace CyberX8_Themes.UserControls
  23. {
  24. /// <summary>
  25. /// PrewetLeftSideControl.xaml 的交互逻辑
  26. /// </summary>
  27. public partial class PrewetLeftSideControl : UserControl
  28. {
  29. public PrewetLeftSideControl()
  30. {
  31. KeyDownCommand = new DelegateCommand<object[]>(KeyDownAction);
  32. InitializeComponent();
  33. }
  34. #region 属性
  35. public static readonly DependencyProperty ModuleNameProperty = DependencyProperty.Register(
  36. "ModuleName", typeof(string), typeof(PrewetLeftSideControl),
  37. new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
  38. /// <summary>
  39. /// 模块名称
  40. /// </summary>
  41. public string ModuleName
  42. {
  43. get
  44. {
  45. return (string)this.GetValue(ModuleNameProperty);
  46. }
  47. set
  48. {
  49. this.SetValue(ModuleNameProperty, value);
  50. }
  51. }
  52. public static readonly DependencyProperty StateMachineProperty = DependencyProperty.Register(
  53. "StateMachine", typeof(string), typeof(PrewetLeftSideControl),
  54. new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
  55. /// <summary>
  56. /// StateMachine
  57. /// </summary>
  58. public string StateMachine
  59. {
  60. get
  61. {
  62. return (string)this.GetValue(StateMachineProperty);
  63. }
  64. set
  65. {
  66. this.SetValue(StateMachineProperty, value);
  67. }
  68. }
  69. public static readonly DependencyProperty StatusValueProperty = DependencyProperty.Register(
  70. "StatusValue", typeof(string), typeof(PrewetLeftSideControl),
  71. new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
  72. /// <summary>
  73. /// StatusValue
  74. /// </summary>
  75. public string StatusValue
  76. {
  77. get
  78. {
  79. return (string)this.GetValue(StatusValueProperty);
  80. }
  81. set
  82. {
  83. this.SetValue(StatusValueProperty, value);
  84. }
  85. }
  86. public static readonly DependencyProperty IsManualProperty = DependencyProperty.Register(
  87. "IsManual", typeof(bool), typeof(PrewetLeftSideControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  88. /// <summary>
  89. /// OperatingMode
  90. /// </summary>
  91. public bool IsManual
  92. {
  93. get
  94. {
  95. return (bool)this.GetValue(IsManualProperty);
  96. }
  97. set
  98. {
  99. this.SetValue(IsManualProperty, value);
  100. }
  101. }
  102. public static readonly DependencyProperty StateProperty = DependencyProperty.Register(
  103. "State", typeof(string), typeof(PrewetLeftSideControl),
  104. new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
  105. /// <summary>
  106. /// State
  107. /// </summary>
  108. public string State
  109. {
  110. get
  111. {
  112. return (string)this.GetValue(StateProperty);
  113. }
  114. set
  115. {
  116. this.SetValue(StateProperty, value);
  117. }
  118. }
  119. public static readonly DependencyProperty PumpDataProperty = DependencyProperty.Register(
  120. "PumpData", typeof(PrewetPumpData), typeof(PrewetLeftSideControl), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
  121. /// <summary>
  122. /// PumpData
  123. /// </summary>
  124. public PrewetPumpData PumpData
  125. {
  126. get
  127. {
  128. return (PrewetPumpData)this.GetValue(PumpDataProperty);
  129. }
  130. set
  131. {
  132. this.SetValue(PumpDataProperty, value);
  133. }
  134. }
  135. public static readonly DependencyProperty InputPumpSpeedProperty = DependencyProperty.Register(
  136. "InputPumpSpeed", typeof(short), typeof(PrewetLeftSideControl), new FrameworkPropertyMetadata((short)300, FrameworkPropertyMetadataOptions.AffectsRender));
  137. /// <summary>
  138. /// InputLowThreshold
  139. /// </summary>
  140. public short InputPumpSpeed
  141. {
  142. get
  143. {
  144. return (short)this.GetValue(InputPumpSpeedProperty);
  145. }
  146. set
  147. {
  148. this.SetValue(InputPumpSpeedProperty, value);
  149. }
  150. }
  151. public static readonly DependencyProperty LinmotPostionProperty = DependencyProperty.Register(
  152. "LinmotPostion", typeof(double), typeof(PrewetLeftSideControl), new FrameworkPropertyMetadata(0.00, FrameworkPropertyMetadataOptions.AffectsRender));
  153. /// <summary>
  154. /// LinmotPostion
  155. /// </summary>
  156. public double LinmotPostion
  157. {
  158. get
  159. {
  160. return (double)this.GetValue(LinmotPostionProperty);
  161. }
  162. set
  163. {
  164. this.SetValue(LinmotPostionProperty, value);
  165. }
  166. }
  167. public static readonly DependencyProperty CurrentScanedCompletedProperty = DependencyProperty.Register(
  168. "CurrentScanedCompleted", typeof(int), typeof(PrewetLeftSideControl), new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender));
  169. /// <summary>
  170. /// ScanedTimes
  171. /// </summary>
  172. public int CurrentScanedCompleted
  173. {
  174. get
  175. {
  176. return (int)this.GetValue(CurrentScanedCompletedProperty);
  177. }
  178. set
  179. {
  180. this.SetValue(CurrentScanedCompletedProperty, value);
  181. }
  182. }
  183. public static readonly DependencyProperty KeepWetLimitProperty = DependencyProperty.Register(
  184. "KeepWetLimit", typeof(int), typeof(PrewetLeftSideControl), new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender));
  185. /// <summary>
  186. /// ScanedTimes
  187. /// </summary>
  188. public int KeepWetLimit
  189. {
  190. get
  191. {
  192. return (int)this.GetValue(KeepWetLimitProperty);
  193. }
  194. set
  195. {
  196. this.SetValue(KeepWetLimitProperty, value);
  197. }
  198. }
  199. public static readonly DependencyProperty PersistentValueProperty = DependencyProperty.Register(
  200. "PersistentValue", typeof(PrewetPersistentValue), typeof(PrewetLeftSideControl), new FrameworkPropertyMetadata(null, new PropertyChangedCallback(OnItemsSourceChanged)));
  201. /// <summary>
  202. /// PersistentValue
  203. /// </summary>
  204. public PrewetPersistentValue PersistentValue
  205. {
  206. get
  207. {
  208. return (PrewetPersistentValue)this.GetValue(PersistentValueProperty);
  209. }
  210. set
  211. {
  212. this.SetValue(PersistentValueProperty, value);
  213. }
  214. }
  215. private static void OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  216. {
  217. if (e.NewValue != null)
  218. {
  219. PrewetPersistentValue data = (PrewetPersistentValue)e.NewValue;
  220. d.SetValue(InputPumpSpeedProperty, data.Speed);
  221. }
  222. }
  223. #endregion
  224. [IgnorePropertyChange]
  225. public ICommand KeyDownCommand
  226. {
  227. get;
  228. private set;
  229. }
  230. private void KeyDownAction(object[] param)
  231. {
  232. if (param.Length >= 1)
  233. {
  234. if (short.TryParse(param[1].ToString(), out short paramValue))
  235. {
  236. if(paramValue < 300 || paramValue > 7300)
  237. {
  238. MessageBox.Show("qualified values 300 ~ 7300", "Invalid Speed Input", MessageBoxButton.OK, MessageBoxImage.Error);
  239. }
  240. else
  241. {
  242. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.PumpSpeedKeyDown", paramValue);
  243. }
  244. }
  245. }
  246. }
  247. #region 按钮事件
  248. private void PreparetoTransfer_Click(object sender, RoutedEventArgs e)
  249. {
  250. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.PrepareToTransfer");
  251. }
  252. private void KeepWet_Click(object sender, RoutedEventArgs e)
  253. {
  254. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.KeepWet");
  255. }
  256. private void PumpOff_Click(object sender, RoutedEventArgs e)
  257. {
  258. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.PumpDisable");
  259. }
  260. private void PumpOn_Click(object sender, RoutedEventArgs e)
  261. {
  262. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.PumpEnable");
  263. }
  264. private void Auto_Click(object sender, RoutedEventArgs e)
  265. {
  266. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.PumpSpeedAuto");
  267. }
  268. private void Manual_Click(object sender, RoutedEventArgs e)
  269. {
  270. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.PumpSpeedManual");
  271. }
  272. private void Close_Click(object sender, RoutedEventArgs e)
  273. {
  274. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.PumpValveOff");
  275. }
  276. private void Open_Click(object sender, RoutedEventArgs e)
  277. {
  278. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.PumpValveOn");
  279. }
  280. #endregion
  281. }
  282. }