PumpView.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Aitex.Core.RT.Device;
  10. using Aitex.Core.RT.Device.Unit;
  11. using Aitex.Core.RT.IOCore;
  12. using Aitex.Core.Util;
  13. namespace Aitex.Core.Backend
  14. {
  15. public partial class PumpView : UserControl
  16. {
  17. PeriodicJob _thread;
  18. private IoPump _pump;
  19. public PumpView()
  20. {
  21. InitializeComponent();
  22. this.Load +=PumpView_Load;
  23. }
  24. private void PumpView_Load(object sender, EventArgs e)
  25. {
  26. if (_thread == null)
  27. _thread = new PeriodicJob(500, OnTimer, "Pump View Update", false, true);
  28. VisibleChanged += (sender1, e1) =>
  29. {
  30. if (Visible)
  31. _thread.Start();
  32. else
  33. _thread.Pause();
  34. };
  35. _pump = DEVICE.GetDevice<IoPump>("MainPump");
  36. }
  37. bool OnTimer()
  38. {
  39. if (_pump == null)
  40. return true;
  41. Invoke(new Action(() =>
  42. {
  43. txtWaterFlow.Text = _pump.WaterFlowValue.ToString("F1");
  44. txtWaterWarning.Text = _pump.H2OSensorMassWarningThreshold.ToString("F1");
  45. txtWaterWarningTime.Text = _pump.H2OSensorMassWarningTime.ToString("F1");
  46. txtN2Flow.Text = _pump.N2PurgeFlow.ToString("f1");
  47. txtN2FlowWarning.Text = _pump.N2PurgeFlowWarningThreshold.ToString("F1");
  48. txtN2FlowWarningTime.Text = _pump.N2PurgeFlowWarningTime.ToString("F1");
  49. txtExhaustPressure.Text = _pump.ExhaustPressure.ToString("F1");
  50. txtPressureWarning.Text = _pump.ExhaustPressurePreWarningThreshold.ToString("F1");
  51. txtPressureWarningTime.Text = _pump.ExhaustPressurePreWarningTime.ToString("F1");
  52. }));
  53. return true;
  54. }
  55. private void btnWaterWarning_Click(object sender, EventArgs e)
  56. {
  57. if (_pump == null)
  58. return;
  59. float value;
  60. if (float.TryParse(txtWaterWarningSet.Text, out value))
  61. _pump.H2OSensorMassWarningThreshold = value;
  62. }
  63. private void btnWaterWarningTime_Click(object sender, EventArgs e)
  64. {
  65. if (_pump == null)
  66. return;
  67. float value;
  68. if (float.TryParse(txtWaterWarningTimeSet.Text, out value))
  69. _pump.H2OSensorMassWarningTime = value;
  70. }
  71. private void btnN2Warning_Click(object sender, EventArgs e)
  72. {
  73. if (_pump == null)
  74. return;
  75. float value;
  76. if (float.TryParse(txtN2WarningSet.Text, out value))
  77. _pump.N2PurgeFlowWarningThreshold = value;
  78. }
  79. private void btnN2WarningTime_Click(object sender, EventArgs e)
  80. {
  81. if (_pump == null)
  82. return;
  83. float value;
  84. if (float.TryParse(txtN2WarningTimeSet.Text, out value))
  85. _pump.N2PurgeFlowWarningTime = value;
  86. }
  87. private void btnExhaustPressure_Click(object sender, EventArgs e)
  88. {
  89. if (_pump == null)
  90. return;
  91. float value;
  92. if (float.TryParse(txtPressureWarningSet.Text, out value))
  93. _pump.ExhaustPressurePreWarningThreshold = value;
  94. }
  95. private void btnExhaustPressureTime_Click(object sender, EventArgs e)
  96. {
  97. if (_pump == null)
  98. return;
  99. float value;
  100. if (float.TryParse(txtPressureWarningTimeSet.Text, out value))
  101. _pump.ExhaustPressurePreWarningTime = value;
  102. }
  103. }
  104. }