CalibrateControl.xaml.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. using MECF.Framework.Common.CommonData.Reservoir;
  2. using MECF.Framework.Common.OperationCenter;
  3. using MECF.Framework.Common.Persistent.Reservoirs;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Collections.ObjectModel;
  7. using System.Linq;
  8. using System.Reflection;
  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 CyberX8_Themes.UserControls
  21. {
  22. /// <summary>
  23. /// CalibrateControl.xaml 的交互逻辑
  24. /// </summary>
  25. public partial class CalibrateControl : UserControl
  26. {
  27. public CalibrateControl()
  28. {
  29. InitializeComponent();
  30. }
  31. public static readonly DependencyProperty ModuleNameProperty = DependencyProperty.Register(
  32. "ModuleName", typeof(string), typeof(CalibrateControl), new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
  33. /// <summary>
  34. /// 模块名称
  35. /// </summary>
  36. public string ModuleName
  37. {
  38. get
  39. {
  40. return (string)this.GetValue(ModuleNameProperty);
  41. }
  42. set
  43. {
  44. this.SetValue(ModuleNameProperty, value);
  45. }
  46. }
  47. public static readonly DependencyProperty ReplenDatasProperty = DependencyProperty.Register(
  48. "ReplenDatas", typeof(ObservableCollection<ReplenData>), typeof(CalibrateControl), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
  49. /// <summary>
  50. /// ReplenDatas
  51. /// </summary>
  52. public ObservableCollection<ReplenData> ReplenDatas
  53. {
  54. get
  55. {
  56. return (ObservableCollection<ReplenData>)this.GetValue(ReplenDatasProperty);
  57. }
  58. set
  59. {
  60. this.SetValue(ReplenDatasProperty, value);
  61. }
  62. }
  63. public static readonly DependencyProperty ReplenNumProperty = DependencyProperty.Register(
  64. "ReplenNum", typeof(int), typeof(CalibrateControl), new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender));
  65. /// <summary>
  66. /// Replen数量
  67. /// </summary>
  68. public int ReplenNum
  69. {
  70. get
  71. {
  72. return (int)this.GetValue(ReplenNumProperty);
  73. }
  74. set
  75. {
  76. this.SetValue(ReplenNumProperty, value);
  77. }
  78. }
  79. public static readonly DependencyProperty ReplensPersistentCollectionProperty = DependencyProperty.Register(
  80. "ReplensPersistentCollection", typeof(ObservableCollection<ReplenPersistentValue>), typeof(CalibrateControl), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
  81. /// <summary>
  82. /// Replen Persistent数据集合
  83. /// </summary>
  84. public ObservableCollection<ReplenPersistentValue> ReplensPersistentCollection
  85. {
  86. get
  87. {
  88. return (ObservableCollection<ReplenPersistentValue>)this.GetValue(ReplensPersistentCollectionProperty);
  89. }
  90. set
  91. {
  92. this.SetValue(ReplensPersistentCollectionProperty, value);
  93. }
  94. }
  95. private void Calibrate1_Click(object sender, RoutedEventArgs e)
  96. {
  97. if (MeasuredVolumeBox.Text != "" && double.Parse(MeasuredVolumeBox.Text) != 0)
  98. {
  99. double pumpFactor = double.Parse(TargetVolumeBox.Text) / double.Parse(MeasuredVolumeBox.Text);
  100. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.SetPumpFactor", ReplenDatas[0].ReplenName, Math.Round(pumpFactor, 3));
  101. }
  102. else
  103. {
  104. MessageBox.Show("MeasuredVolume can't be set as zero", "Calibrate1", MessageBoxButton.OK, MessageBoxImage.Error);
  105. }
  106. }
  107. private void Calibrate2_Click(object sender, RoutedEventArgs e)
  108. {
  109. if (MeasuredVolumeBox.Text != "" && double.Parse(MeasuredVolumeBox.Text) != 0)
  110. {
  111. double pumpFactor = double.Parse(TargetVolumeBox.Text) / double.Parse(MeasuredVolumeBox.Text);
  112. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.SetPumpFactor", ReplenDatas[1].ReplenName, Math.Round(pumpFactor, 3));
  113. }
  114. else
  115. {
  116. MessageBox.Show("MeasuredVolume can't be set as zero", "Calibrate2", MessageBoxButton.OK, MessageBoxImage.Error);
  117. }
  118. }
  119. private void Calibrate3_Click(object sender, RoutedEventArgs e)
  120. {
  121. if (MeasuredVolumeBox.Text != "" && double.Parse(MeasuredVolumeBox.Text) != 0)
  122. {
  123. double pumpFactor = double.Parse(TargetVolumeBox.Text) / double.Parse(MeasuredVolumeBox.Text);
  124. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.SetPumpFactor", ReplenDatas[2].ReplenName, Math.Round(pumpFactor, 3));
  125. }
  126. else
  127. {
  128. MessageBox.Show("MeasuredVolume can't be set as zero", "Calibrate3", MessageBoxButton.OK, MessageBoxImage.Error);
  129. }
  130. }
  131. private void Calibrate4_Click(object sender, RoutedEventArgs e)
  132. {
  133. if (MeasuredVolumeBox.Text != "" && double.Parse(MeasuredVolumeBox.Text) != 0)
  134. {
  135. double pumpFactor = double.Parse(TargetVolumeBox.Text) / double.Parse(MeasuredVolumeBox.Text);
  136. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.SetPumpFactor", ReplenDatas[3].ReplenName, Math.Round(pumpFactor, 3));
  137. }
  138. else
  139. {
  140. MessageBox.Show("MeasuredVolume can't be set as zero", "Calibrate4", MessageBoxButton.OK, MessageBoxImage.Error);
  141. }
  142. }
  143. }
  144. }