using SA_LTT;
|
using System;
|
using System.Drawing;
|
using System.Threading;
|
using System.Windows.Forms;
|
|
namespace SA_LTT_UI.Viewer
|
{
|
public partial class EnergyMeterViewer : Form
|
{
|
MainFrame _mainFrame;
|
Thread t_UIUpdate;
|
bool updateCheck;
|
|
protected override CreateParams CreateParams
|
{
|
get
|
{
|
CreateParams MyCp = base.CreateParams;
|
MyCp.ExStyle |= 0x02000000;
|
|
return MyCp;
|
}
|
}
|
|
public EnergyMeterViewer(MainFrame mainFrame)
|
{
|
InitializeComponent();
|
|
_mainFrame = mainFrame;
|
|
t_UIUpdate = new Thread(UIUpdateTh);
|
t_UIUpdate.Start();
|
}
|
|
private void UIUpdateTh()
|
{
|
while (_mainFrame.equipment.IsDisposed == false)
|
{
|
Thread.Sleep(10);
|
|
if (updateCheck == false)
|
{
|
updateCheck = true;
|
UIUpdate();
|
}
|
}
|
}
|
|
private void UIUpdate()
|
{
|
if (InvokeRequired)
|
{
|
BeginInvoke(new UIUpdateDelegate(UIUpdate));
|
return;
|
}
|
else
|
{
|
try
|
{
|
lb_PortName.Text = _mainFrame.equipment.powerMeter.PortName;
|
lb_PortName.BackColor = _mainFrame.equipment.powerMeter.IsOpen ? Color.Lime : Color.Red;
|
|
tb_CurrentMeasurementMode.Text = _mainFrame.equipment.powerMeter.CurrentMeasurementMode.ToString();
|
tb_Flag.Text = _mainFrame.equipment.powerMeter.Flag.ToString();
|
tb_OriginalEnergy.Text = _mainFrame.equipment.powerMeter.Energy.ToString();
|
tb_Energy.Text = _mainFrame.equipment.powerMeter.EnergyPerUnitArea.ToString();
|
tb_Count.Text = _mainFrame.equipment.powerMeter.MeasurementsEnergyPerUnitArea.Count.ToString();
|
tb_Average.Text = $"{_mainFrame.equipment.powerMeter.MeasurementAverageEnergyPerUnitArea:F4}";
|
tb_Max.Text = $"{_mainFrame.equipment.powerMeter.MeasurementMaxEnergyPerUnitArea:F4}";
|
tb_Min.Text = $"{_mainFrame.equipment.powerMeter.MeasurementMinEnergyPerUnitArea:F4}";
|
|
if (_mainFrame.equipment.powerMeter.CurrentMeasurementMode == SA_LTT.Module.PowerMeter.MeasurementMode.Energy)
|
{
|
lb_PowerMeterMode.Text = "J/cm²";
|
}
|
else
|
{
|
lb_PowerMeterMode.Text = "W";
|
}
|
}
|
catch (Exception e)
|
{
|
EquipmentLogManager.Instance.WriteExceptionLog(e.StackTrace);
|
}
|
finally
|
{
|
updateCheck = false;
|
}
|
}
|
}
|
|
private void PowerMeterViewer_FormClosing(object sender, FormClosingEventArgs e)
|
{
|
e.Cancel = true;
|
|
this.Hide();
|
}
|
}
|
}
|