common/Ui/LegacyGenesisControl/ctlGenesisMeterDetails.cs
2026-04-23 17:50:07 +02:00

155 lines
5.0 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Xylem.Common.Hardware.WaterMeter.Genesis;
using Xylem.Common.Hardware.WaterMeter.CommonMeterDefinitions;
namespace Xylem.Common.Ui.Control.LegacyGenesisControl
{
public partial class CtlGenesisMeterDetails : BaseGenesisMeterControl
{
public GenesisMeter meter;
ctlBatch Parent;
public ctlGenesisMeterDetails(ctlBatch parent)
{
InitializeComponent();
Parent = parent;
}
public void UpdateMeterInfo()
{
if (meter == null)
{
lblSerialNr.Text = "None";
lblPcbID.Text = "-";
}
lblSerialNr.Text = meter.SerialNumber;
lblPcbID.Text = meter.Pcbid();
if (meter.ProcessStatus == ProcessState.MeasurementIsActive || meter.ProcessStatus == ProcessState.CalibrationIsActive)
{
foreach (var result in meter.GetIntermediateMeasurementResults())
{
var tmpVolume = result.Value.TotalVolumeQm;
var tmpTime = result.Value.TotalTimeS;
var tmpflowrate = (tmpVolume / (tmpTime / 3600));
var tmpError = ((tmpflowrate - Parent.RefFlowrate) / Parent.RefFlowrate) * 100;
var error = showNumber(tmpError);
var volume = showNumber(tmpVolume);
var time = showNumber(tmpTime);
var flowrate = showNumber(tmpflowrate);
switch (result.Key)
{
case 0:
lblVolume.Text = volume;
lblTestTime.Text = time;
lblFlow.Text = flowrate;
lblError.Text = error;
errorGauge.Value = (float)tmpError;
break;
case 1:
lblVolumelChl1.Text = volume;
lblTestTimeChl1.Text = time;
lblFlowChl1.Text = flowrate;
lblErrorChl1.Text = error;
errorGaugePath1.Value = (float)tmpError;
break;
case 2:
lblVolumelChl2.Text = volume;
lblTestTimeChl2.Text = time;
lblFlowChl2.Text = flowrate;
lblErrorChl2.Text = error;
errorGaugePath2.Value = (float)tmpError;
break;
case 3:
lblVolumelChl3.Text = volume;
lblTestTimeChl3.Text = time;
lblFlowChl3.Text = flowrate;
lblErrorChl3.Text = error;
errorGaugePath3.Value = (float)tmpError;
break;
default:
break;
}
}
}
}
ctlGauge errorGauge = new ctlGauge();
ctlGauge errorGaugePath1 = new ctlGauge();
ctlGauge errorGaugePath2 = new ctlGauge();
ctlGauge errorGaugePath3 = new ctlGauge();
private void CreateGauge(Panel pnl, ctlGauge Gauge)
{
pnl.Controls.Add(Gauge);
Gauge.Location = new System.Drawing.Point(0, 0);
Gauge.Name = "errorGauge";
Gauge.Size = pnlGauge.Size;
Gauge.TabStop = false;
Gauge.Text = "errorGauge";
Gauge.DialColor = this.BackColor;
Gauge.DialText = "Error [%]";
Gauge.MaxValue = 5;
Gauge.MinValue = -5;
Gauge.NoOfDivisions = 10;
Gauge.NoOfSubDivisions = 5;
Gauge.RecommendedValue = 0;
Gauge.ThresholdPercent = 25f;
Gauge.Value = 3.4f;
}
private void GenesisMeter_Load(object sender, EventArgs e)
{
lblSerialNr.Text = meter.SerialNumber;
lblPcbID.Text = meter.GetPcbId();
CreateGauge(pnlGauge, errorGauge);
CreateGauge(pnlGaugePath1, errorGaugePath1);
CreateGauge(pnlGaugePath2, errorGaugePath2);
CreateGauge(pnlGaugePath3, errorGaugePath3);
UpdateMeterInfo();
}
private void pnlGauge_Resize(object sender, EventArgs e)
{
foreach (var item in pnlGauge.Controls)
{
if (item is ctlGauge)
{
((ctlGauge)item).Size = pnlGauge.Size;
}
}
}
private void btnDetails_Click(object sender, EventArgs e)
{
UpdateMeterInfo();
if (true)
{
}
}
}
}