using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; using Aitex.Core.RT.Device; using Aitex.Core.RT.Device.Unit; using Aitex.Core.RT.IOCore; using Aitex.Core.Util; namespace Aitex.Core.Backend { public partial class PumpView : UserControl { PeriodicJob _thread; private IoPump _pump; public PumpView() { InitializeComponent(); this.Load +=PumpView_Load; } private void PumpView_Load(object sender, EventArgs e) { if (_thread == null) _thread = new PeriodicJob(500, OnTimer, "Pump View Update", false, true); VisibleChanged += (sender1, e1) => { if (Visible) _thread.Start(); else _thread.Pause(); }; _pump = DEVICE.GetDevice("MainPump"); } bool OnTimer() { if (_pump == null) return true; Invoke(new Action(() => { txtWaterFlow.Text = _pump.WaterFlowValue.ToString("F1"); txtWaterWarning.Text = _pump.H2OSensorMassWarningThreshold.ToString("F1"); txtWaterWarningTime.Text = _pump.H2OSensorMassWarningTime.ToString("F1"); txtN2Flow.Text = _pump.N2PurgeFlow.ToString("f1"); txtN2FlowWarning.Text = _pump.N2PurgeFlowWarningThreshold.ToString("F1"); txtN2FlowWarningTime.Text = _pump.N2PurgeFlowWarningTime.ToString("F1"); txtExhaustPressure.Text = _pump.ExhaustPressure.ToString("F1"); txtPressureWarning.Text = _pump.ExhaustPressurePreWarningThreshold.ToString("F1"); txtPressureWarningTime.Text = _pump.ExhaustPressurePreWarningTime.ToString("F1"); })); return true; } private void btnWaterWarning_Click(object sender, EventArgs e) { if (_pump == null) return; float value; if (float.TryParse(txtWaterWarningSet.Text, out value)) _pump.H2OSensorMassWarningThreshold = value; } private void btnWaterWarningTime_Click(object sender, EventArgs e) { if (_pump == null) return; float value; if (float.TryParse(txtWaterWarningTimeSet.Text, out value)) _pump.H2OSensorMassWarningTime = value; } private void btnN2Warning_Click(object sender, EventArgs e) { if (_pump == null) return; float value; if (float.TryParse(txtN2WarningSet.Text, out value)) _pump.N2PurgeFlowWarningThreshold = value; } private void btnN2WarningTime_Click(object sender, EventArgs e) { if (_pump == null) return; float value; if (float.TryParse(txtN2WarningTimeSet.Text, out value)) _pump.N2PurgeFlowWarningTime = value; } private void btnExhaustPressure_Click(object sender, EventArgs e) { if (_pump == null) return; float value; if (float.TryParse(txtPressureWarningSet.Text, out value)) _pump.ExhaustPressurePreWarningThreshold = value; } private void btnExhaustPressureTime_Click(object sender, EventArgs e) { if (_pump == null) return; float value; if (float.TryParse(txtPressureWarningTimeSet.Text, out value)) _pump.ExhaustPressurePreWarningTime = value; } } }