2016-10-11 11:05:40 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Copyright (c) 2016 Sensus Metering Systems
|
|
|
|
|
|
///
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
using log4net;
|
|
|
|
|
|
using TBF.Resources;
|
|
|
|
|
|
|
|
|
|
|
|
namespace TBF.BenchControl.DataEntry.HeatMeters6
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class TestStartEndForm : Form, GenericDevices.IHasCompleted
|
|
|
|
|
|
{
|
|
|
|
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(TestStartEndForm));
|
|
|
|
|
|
|
|
|
|
|
|
// Set to 'true' when the form closes
|
|
|
|
|
|
public bool Completed { get { return completed; } }
|
|
|
|
|
|
bool completed;
|
|
|
|
|
|
|
|
|
|
|
|
readonly EntryFormCfg entryFormCfg;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> Number of text boxes for serial numbers </summary>
|
|
|
|
|
|
public readonly int WaterMetersCount;
|
|
|
|
|
|
|
|
|
|
|
|
readonly bool[] disabled;
|
|
|
|
|
|
|
|
|
|
|
|
// To be retrieved after the form closes
|
|
|
|
|
|
public float[] WMStartState;
|
|
|
|
|
|
public readonly string[] WMStartStateStr;
|
|
|
|
|
|
public float[] WMEndState;
|
|
|
|
|
|
|
|
|
|
|
|
// To be retrieved after the form closes
|
|
|
|
|
|
public double[] EnergyStartState;
|
|
|
|
|
|
public readonly string[] EnergyStartStateStr;
|
|
|
|
|
|
public double[] EnergyEndState;
|
|
|
|
|
|
|
|
|
|
|
|
bool endStates; /// false=start states, true=end states
|
|
|
|
|
|
|
|
|
|
|
|
double refVolume;
|
|
|
|
|
|
double warningLimLo; /// limit to display exclamation mark, typically 2x errLimLo
|
|
|
|
|
|
double warningLimHi; /// limit to display exclamation mark, typically 2x errLimHi
|
|
|
|
|
|
|
|
|
|
|
|
double refEnergy;
|
|
|
|
|
|
double energyWarningLimLo; /// limit to display exclamation mark, typically 2x energyErrLimLo
|
|
|
|
|
|
double energyWarningLimHi; /// limit to display exclamation mark, typically 2x energyErrLimHi
|
|
|
|
|
|
|
|
|
|
|
|
int TextBoxesCount;
|
|
|
|
|
|
///
|
|
|
|
|
|
Label[] labels;
|
|
|
|
|
|
TextBox[] startTextBoxes;
|
|
|
|
|
|
TextBox[] endTextBoxes;
|
|
|
|
|
|
Label[] energyLabels;
|
|
|
|
|
|
TextBox[] energyStartTextBoxes;
|
|
|
|
|
|
TextBox[] energyEndTextBoxes;
|
|
|
|
|
|
IList<TextBox> enabledTextBoxes;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Parameterless constructor initializing common part for start and endstate form
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public TestStartEndForm()
|
|
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
2016-10-28 16:45:43 +00:00
|
|
|
|
TextBoxesCount = 6;
|
2016-10-11 11:05:40 +00:00
|
|
|
|
|
|
|
|
|
|
labels = new Label[]
|
|
|
|
|
|
{
|
|
|
|
|
|
label1, label2, label3, label4, label5, label6,
|
|
|
|
|
|
};
|
|
|
|
|
|
startTextBoxes = new TextBox[]
|
|
|
|
|
|
{
|
|
|
|
|
|
startTextBox1, startTextBox2, startTextBox3, startTextBox4, startTextBox5, startTextBox6,
|
|
|
|
|
|
};
|
|
|
|
|
|
endTextBoxes = new TextBox[]
|
|
|
|
|
|
{
|
|
|
|
|
|
endTextBox1, endTextBox2, endTextBox3, endTextBox4, endTextBox5, endTextBox6,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
energyLabels = new Label[]
|
|
|
|
|
|
{
|
|
|
|
|
|
label13, label14, label15, label16, label17, label18,
|
|
|
|
|
|
};
|
|
|
|
|
|
energyStartTextBoxes = new TextBox[]
|
|
|
|
|
|
{
|
|
|
|
|
|
startTextBox13, startTextBox14, startTextBox15, startTextBox16, startTextBox17, startTextBox18,
|
|
|
|
|
|
};
|
|
|
|
|
|
energyEndTextBoxes = new TextBox[]
|
|
|
|
|
|
{
|
|
|
|
|
|
endTextBox13, endTextBox14, endTextBox15, endTextBox16, endTextBox17, endTextBox18,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enabledTextBoxes = new List<TextBox>();
|
|
|
|
|
|
|
|
|
|
|
|
completed = false;
|
|
|
|
|
|
StartForceCloseHandler();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Constructor to fill in start states
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="waterMetersCount">Number of water meters</param>
|
|
|
|
|
|
/// <param name="disabled">Information from CycleBeginningForm about availability of water meters</param>
|
|
|
|
|
|
public TestStartEndForm(EntryFormCfg cfg, int waterMetersCount, bool[] disabled)
|
|
|
|
|
|
: this()
|
|
|
|
|
|
{
|
|
|
|
|
|
endStates = false;
|
|
|
|
|
|
|
|
|
|
|
|
entryFormCfg = cfg;
|
|
|
|
|
|
|
|
|
|
|
|
this.WaterMetersCount = waterMetersCount;
|
|
|
|
|
|
this.disabled = disabled;
|
|
|
|
|
|
|
|
|
|
|
|
ShuffleTextBoxes();
|
|
|
|
|
|
|
|
|
|
|
|
WMStartState = new float[waterMetersCount];
|
|
|
|
|
|
WMStartStateStr = new string[waterMetersCount];
|
|
|
|
|
|
|
|
|
|
|
|
EnergyStartState = new double[waterMetersCount];
|
|
|
|
|
|
EnergyStartStateStr = new string[waterMetersCount];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Constructor to fill in end states
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="waterMetersCount">Number of water meters</param>
|
|
|
|
|
|
/// <param name="wmStartStateStr">Information entered on test start</param>
|
|
|
|
|
|
/// <param name="disabled">Information from CycleBeginningForm about availability of water meters</param>
|
|
|
|
|
|
/// <param name="refVolume">Reference volume, it is used to verify the end state, show/hide exclamation if necessary</param>
|
|
|
|
|
|
/// <param name="errLimLo">Error limit low, it is used to verify the end state, show/hide exclamation if necessary</param>
|
|
|
|
|
|
/// <param name="errLimHi">Error limit high, it is used to verify the end state, show/hide exclamation if necessary</param>
|
|
|
|
|
|
public TestStartEndForm(EntryFormCfg cfg, int waterMetersCount, string[] wmStartStateStr, string[] energyStartStateStr,
|
|
|
|
|
|
bool[] disabled, double refVolume, double errLimLo, double errLimHi,
|
|
|
|
|
|
double refEnergy, double energyErrLimLo, double energyErrLimHi)
|
|
|
|
|
|
: this()
|
|
|
|
|
|
{
|
|
|
|
|
|
endStates = true;
|
|
|
|
|
|
|
|
|
|
|
|
entryFormCfg = cfg;
|
|
|
|
|
|
|
|
|
|
|
|
this.WaterMetersCount = waterMetersCount;
|
|
|
|
|
|
|
|
|
|
|
|
if (wmStartStateStr == null || wmStartStateStr.Length != waterMetersCount)
|
|
|
|
|
|
throw (new Exception("Invalid 'wmStartStateStr' argument"));
|
|
|
|
|
|
this.WMStartStateStr = wmStartStateStr;
|
|
|
|
|
|
|
|
|
|
|
|
if (energyStartStateStr == null || energyStartStateStr.Length != waterMetersCount)
|
|
|
|
|
|
throw (new Exception("Invalid 'energyStartStateStr' argument"));
|
|
|
|
|
|
this.EnergyStartStateStr = energyStartStateStr;
|
|
|
|
|
|
|
|
|
|
|
|
this.disabled = disabled;
|
|
|
|
|
|
|
|
|
|
|
|
this.refVolume = refVolume;
|
|
|
|
|
|
this.warningLimLo = 2 * errLimLo;
|
|
|
|
|
|
this.warningLimHi = 2 * errLimHi;
|
|
|
|
|
|
|
|
|
|
|
|
this.refEnergy = refEnergy;
|
|
|
|
|
|
this.energyWarningLimLo = 2 * energyErrLimLo;
|
|
|
|
|
|
this.energyWarningLimHi = 2 * energyErrLimHi;
|
|
|
|
|
|
|
|
|
|
|
|
ShuffleTextBoxes();
|
|
|
|
|
|
|
|
|
|
|
|
WMEndState = new float[waterMetersCount];
|
|
|
|
|
|
EnergyEndState = new double[waterMetersCount];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Make sure the layout of labels/text boxes on the screen
|
|
|
|
|
|
/// corresponds to the layout of watermeters of the test bench.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
void ShuffleTextBoxes()
|
|
|
|
|
|
{
|
2016-10-28 16:45:43 +00:00
|
|
|
|
if (Config.Data.HeatMetersCount < TextBoxesCount)
|
2016-10-11 11:05:40 +00:00
|
|
|
|
{
|
2016-10-29 18:31:08 +00:00
|
|
|
|
int nrLines = Math.Max(1, Config.Data.HeatMetersCount / Config.Data.LineSize);
|
2016-10-28 16:45:43 +00:00
|
|
|
|
int gap = (TextBoxesCount - Config.Data.HeatMetersCount) / nrLines;
|
2016-10-11 11:05:40 +00:00
|
|
|
|
|
|
|
|
|
|
int dest = 0;
|
|
|
|
|
|
for (int l = 0; l < nrLines; l++)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < Config.Data.LineSize; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
labels[dest] = labels[l * Config.Data.LineSize + l * gap + i];
|
|
|
|
|
|
startTextBoxes[dest] = startTextBoxes[l * Config.Data.LineSize + l * gap + i];
|
|
|
|
|
|
endTextBoxes[dest] = endTextBoxes[l * Config.Data.LineSize + l * gap + i];
|
|
|
|
|
|
energyLabels[dest] = energyLabels[l * Config.Data.LineSize + l * gap + i];
|
|
|
|
|
|
energyStartTextBoxes[dest] = energyStartTextBoxes[l * Config.Data.LineSize + l * gap + i];
|
|
|
|
|
|
energyEndTextBoxes[dest] = energyEndTextBoxes[l * Config.Data.LineSize + l * gap + i];
|
|
|
|
|
|
dest++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-10-28 16:45:43 +00:00
|
|
|
|
TextBoxesCount = Config.Data.HeatMetersCount;
|
2016-10-11 11:05:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void TestStartEndForm_Load(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
Localize();
|
|
|
|
|
|
|
|
|
|
|
|
for (Config.Unit units = 0; units < Config.Unit.Count; units++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Config.Units.IsEnergy(units)) unitsComboBox.Items.Add(units.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
unitsComboBox.Text = entryFormCfg.Units.ToString();
|
|
|
|
|
|
|
|
|
|
|
|
//Height = 115 + 90 * WaterMetersCount;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < TextBoxesCount; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (i < WaterMetersCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
labels[i].Visible = startTextBoxes[i].Visible = endTextBoxes[i].Visible = true;
|
|
|
|
|
|
energyLabels[i].Visible = energyStartTextBoxes[i].Visible = energyEndTextBoxes[i].Visible = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (endStates)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < TextBoxesCount; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (WMStartStateStr != null && i < WMStartStateStr.Length)
|
|
|
|
|
|
{
|
|
|
|
|
|
startTextBoxes[i].Text = WMStartStateStr[i];
|
|
|
|
|
|
}
|
|
|
|
|
|
if (EnergyStartStateStr != null && i < EnergyStartStateStr.Length)
|
|
|
|
|
|
{
|
|
|
|
|
|
energyStartTextBoxes[i].Text = EnergyStartStateStr[i];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (disabled != null && i < disabled.Length && disabled[i])
|
|
|
|
|
|
{
|
|
|
|
|
|
endTextBoxes[i].Enabled = false;
|
|
|
|
|
|
energyEndTextBoxes[i].Enabled = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
endTextBoxes[i].Enabled = true;
|
|
|
|
|
|
energyEndTextBoxes[i].Enabled = true;
|
|
|
|
|
|
enabledTextBoxes.Add(endTextBoxes[i]);
|
|
|
|
|
|
enabledTextBoxes.Add(energyEndTextBoxes[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < TextBoxesCount; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (disabled != null && i < disabled.Length && disabled[i])
|
|
|
|
|
|
{
|
|
|
|
|
|
startTextBoxes[i].Enabled = false;
|
|
|
|
|
|
energyStartTextBoxes[i].Enabled = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
startTextBoxes[i].Enabled = true;
|
|
|
|
|
|
energyStartTextBoxes[i].Enabled = true;
|
|
|
|
|
|
enabledTextBoxes.Add(startTextBoxes[i]);
|
|
|
|
|
|
enabledTextBoxes.Add(energyStartTextBoxes[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Localize()
|
|
|
|
|
|
{
|
|
|
|
|
|
Text = Strings.Water_Meter_States;
|
|
|
|
|
|
for (int i = 0; i < TextBoxesCount; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
labels[i].Text = string.Format("{0} {1} [l]", Strings.Volume + " ", i + 1);
|
|
|
|
|
|
energyLabels[i].Text = string.Format("{0} {1}", Strings.Energy + " ", i + 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
startLabel.Text = Strings.Start;
|
|
|
|
|
|
endLabel.Text = Strings.End;
|
|
|
|
|
|
okButton.Text = Strings.OkBtnText;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void unitsComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (Config.Unit u = 0; u < Config.Unit.Count; u++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (u.ToString() == unitsComboBox.Text)
|
|
|
|
|
|
{
|
|
|
|
|
|
entryFormCfg.Units = u;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void okButton_Click(object sender, EventArgs eArgs)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
if (endStates)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < Math.Min(WaterMetersCount, TextBoxesCount); i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (endTextBoxes[i].Visible && endTextBoxes[i].Enabled)
|
|
|
|
|
|
{
|
|
|
|
|
|
WMEndState[i] = Utils.ParseUFloat(endTextBoxes[i].Text);
|
|
|
|
|
|
EnergyEndState[i] = Config.Units.ConvertFrom(entryFormCfg.Units, Utils.ParseUFloat(energyEndTextBoxes[i].Text));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < Math.Min(WaterMetersCount, TextBoxesCount); i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (startTextBoxes[i].Visible && startTextBoxes[i].Enabled)
|
|
|
|
|
|
{
|
|
|
|
|
|
WMStartStateStr[i] = startTextBoxes[i].Text;
|
|
|
|
|
|
WMStartState[i] = Utils.ParseUFloat(startTextBoxes[i].Text);
|
|
|
|
|
|
EnergyStartStateStr[i] = energyStartTextBoxes[i].Text;
|
|
|
|
|
|
EnergyStartState[i] = Config.Units.ConvertFrom(entryFormCfg.Units, Utils.ParseUFloat(energyStartTextBoxes[i].Text));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch(Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
log.ErrorFormat("Exception: {0}", e.Message);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
completed = true;
|
|
|
|
|
|
Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region Forced close handling
|
|
|
|
|
|
|
|
|
|
|
|
public void StartForceCloseHandler()
|
|
|
|
|
|
{
|
|
|
|
|
|
UiBridge.Bridge.CloseModelessFormHandler += delegate(object sender, EventArgs args)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnForceClose), sender, args); }
|
|
|
|
|
|
else OnForceClose(sender, args);
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OnForceClose(object sender, EventArgs args)
|
|
|
|
|
|
{
|
|
|
|
|
|
DialogResult = DialogResult.Cancel;
|
|
|
|
|
|
Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Calculate the approximate error and verify whether it is within limits.
|
|
|
|
|
|
/// Make an exclamation mark visible if out of range.
|
|
|
|
|
|
/// Similar event handler is implemented for all endTextBoxes (1..24).
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void endTextBox1_TextChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
double err = 0;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
float endState = Utils.ParseUFloat(endTextBox1.Text);
|
|
|
|
|
|
float startState = Utils.ParseUFloat(startTextBox1.Text);
|
|
|
|
|
|
err = 100.0 * (endState - startState - refVolume) / refVolume;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { };
|
|
|
|
|
|
exclamation1.Visible = (err < warningLimLo) || (warningLimHi < err);
|
|
|
|
|
|
}
|
|
|
|
|
|
private void endTextBox2_TextChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
double err = 0;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
float endState = Utils.ParseUFloat(endTextBox2.Text);
|
|
|
|
|
|
float startState = Utils.ParseUFloat(startTextBox2.Text);
|
|
|
|
|
|
err = 100.0 * (endState - startState - refVolume) / refVolume;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { err = 1000.0f; };
|
|
|
|
|
|
exclamation2.Visible = (err < warningLimLo) || (warningLimHi < err);
|
|
|
|
|
|
}
|
|
|
|
|
|
private void endTextBox3_TextChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
double err = 0;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
float endState = Utils.ParseUFloat(endTextBox3.Text);
|
|
|
|
|
|
float startState = Utils.ParseUFloat(startTextBox3.Text);
|
|
|
|
|
|
err = 100.0 * (endState - startState - refVolume) / refVolume;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { err = 1000.0f; };
|
|
|
|
|
|
exclamation3.Visible = (err < warningLimLo) || (warningLimHi < err);
|
|
|
|
|
|
}
|
|
|
|
|
|
private void endTextBox4_TextChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
double err = 0;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
float endState = Utils.ParseUFloat(endTextBox4.Text);
|
|
|
|
|
|
float startState = Utils.ParseUFloat(startTextBox4.Text);
|
|
|
|
|
|
err = 100.0 * (endState - startState - refVolume) / refVolume;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { err = 1000.0f; };
|
|
|
|
|
|
exclamation4.Visible = (err < warningLimLo) || (warningLimHi < err);
|
|
|
|
|
|
}
|
|
|
|
|
|
private void endTextBox5_TextChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
double err = 0;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
float endState = Utils.ParseUFloat(endTextBox5.Text);
|
|
|
|
|
|
float startState = Utils.ParseUFloat(startTextBox5.Text);
|
|
|
|
|
|
err = 100.0 * (endState - startState - refVolume) / refVolume;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { err = 1000.0f; };
|
|
|
|
|
|
exclamation5.Visible = (err < warningLimLo) || (warningLimHi < err);
|
|
|
|
|
|
}
|
|
|
|
|
|
private void endTextBox6_TextChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
double err = 0;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
float endState = Utils.ParseUFloat(endTextBox6.Text);
|
|
|
|
|
|
float startState = Utils.ParseUFloat(startTextBox6.Text);
|
|
|
|
|
|
err = 100.0 * (endState - startState - refVolume) / refVolume;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { err = 1000.0f; };
|
|
|
|
|
|
exclamation6.Visible = (err < warningLimLo) || (warningLimHi < err);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void endTextBox13_TextChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
double err = 0;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
double endState = Config.Units.ConvertFrom(entryFormCfg.Units, Utils.ParseUFloat(endTextBox13.Text));
|
|
|
|
|
|
double startState = Config.Units.ConvertFrom(entryFormCfg.Units, Utils.ParseUFloat(startTextBox13.Text));
|
|
|
|
|
|
err = 100.0 * (endState - startState - refEnergy) / refEnergy;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { err = 1000.0f; };
|
|
|
|
|
|
exclamation13.Visible = (err < energyWarningLimLo) || (energyWarningLimHi < err);
|
|
|
|
|
|
}
|
|
|
|
|
|
private void endTextBox14_TextChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
double err = 0;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
double endState = Config.Units.ConvertFrom(entryFormCfg.Units, Utils.ParseUFloat(endTextBox14.Text));
|
|
|
|
|
|
double startState = Config.Units.ConvertFrom(entryFormCfg.Units, Utils.ParseUFloat(startTextBox14.Text));
|
|
|
|
|
|
err = 100.0 * (endState - startState - refEnergy) / refEnergy;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { err = 1000.0f; };
|
|
|
|
|
|
exclamation14.Visible = (err < energyWarningLimLo) || (energyWarningLimHi < err);
|
|
|
|
|
|
}
|
|
|
|
|
|
private void endTextBox15_TextChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
double err = 0;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
double endState = Config.Units.ConvertFrom(entryFormCfg.Units, Utils.ParseUFloat(endTextBox15.Text));
|
|
|
|
|
|
double startState = Config.Units.ConvertFrom(entryFormCfg.Units, Utils.ParseUFloat(startTextBox15.Text));
|
|
|
|
|
|
err = 100.0 * (endState - startState - refEnergy) / refEnergy;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { err = 1000.0f; };
|
|
|
|
|
|
exclamation15.Visible = (err < energyWarningLimLo) || (energyWarningLimHi < err);
|
|
|
|
|
|
}
|
|
|
|
|
|
private void endTextBox16_TextChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
double err = 0;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
double endState = Config.Units.ConvertFrom(entryFormCfg.Units, Utils.ParseUFloat(endTextBox16.Text));
|
|
|
|
|
|
double startState = Config.Units.ConvertFrom(entryFormCfg.Units, Utils.ParseUFloat(startTextBox16.Text));
|
|
|
|
|
|
err = 100.0 * (endState - startState - refEnergy) / refEnergy;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { err = 1000.0f; };
|
|
|
|
|
|
exclamation16.Visible = (err < energyWarningLimLo) || (energyWarningLimHi < err);
|
|
|
|
|
|
}
|
|
|
|
|
|
private void endTextBox17_TextChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
double err = 0;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
double endState = Config.Units.ConvertFrom(entryFormCfg.Units, Utils.ParseUFloat(endTextBox17.Text));
|
|
|
|
|
|
double startState = Config.Units.ConvertFrom(entryFormCfg.Units, Utils.ParseUFloat(startTextBox17.Text));
|
|
|
|
|
|
err = 100.0 * (endState - startState - refEnergy) / refEnergy;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { err = 1000.0f; };
|
|
|
|
|
|
exclamation17.Visible = (err < energyWarningLimLo) || (energyWarningLimHi < err);
|
|
|
|
|
|
}
|
|
|
|
|
|
private void endTextBox18_TextChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
double err = 0;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
double endState = Config.Units.ConvertFrom(entryFormCfg.Units, Utils.ParseUFloat(endTextBox18.Text));
|
|
|
|
|
|
double startState = Config.Units.ConvertFrom(entryFormCfg.Units, Utils.ParseUFloat(startTextBox18.Text));
|
|
|
|
|
|
err = 100.0 * (endState - startState - refEnergy) / refEnergy;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { err = 1000.0f; };
|
|
|
|
|
|
exclamation18.Visible = (err < energyWarningLimLo) || (energyWarningLimHi < err);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Process a key press within any enabled text boxe
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
/// <param name="currentFocusOwner">TextBox control which received the event</param>
|
|
|
|
|
|
private void ProcKeyPress(object sender, KeyPressEventArgs e, TextBox currentFocusOwner)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.KeyChar == '+')
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Process '+' key ..... Form completed
|
|
|
|
|
|
okButton_Click(sender, e);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (e.KeyChar == '\r')
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Process <enter> key ..... Next text field
|
|
|
|
|
|
if (enabledTextBoxes.Count < 2) return; /// There is just one enabled textbox
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < enabledTextBoxes.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (enabledTextBoxes[i] == currentFocusOwner)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Change focus to the next enabled text box
|
|
|
|
|
|
enabledTextBoxes[(i + 1) % enabledTextBoxes.Count].Focus();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void startTextBox1_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox1); }
|
|
|
|
|
|
private void startTextBox2_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox2); }
|
|
|
|
|
|
private void startTextBox3_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox3); }
|
|
|
|
|
|
private void startTextBox4_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox4); }
|
|
|
|
|
|
private void startTextBox5_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox5); }
|
|
|
|
|
|
private void startTextBox6_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox6); }
|
|
|
|
|
|
private void startTextBox13_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox13); }
|
|
|
|
|
|
private void startTextBox14_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox14); }
|
|
|
|
|
|
private void startTextBox15_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox15); }
|
|
|
|
|
|
private void startTextBox16_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox16); }
|
|
|
|
|
|
private void startTextBox17_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox17); }
|
|
|
|
|
|
private void startTextBox18_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox18); }
|
|
|
|
|
|
|
|
|
|
|
|
private void endTextBox1_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox1); }
|
|
|
|
|
|
private void endTextBox2_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox2); }
|
|
|
|
|
|
private void endTextBox3_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox3); }
|
|
|
|
|
|
private void endTextBox4_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox4); }
|
|
|
|
|
|
private void endTextBox5_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox5); }
|
|
|
|
|
|
private void endTextBox6_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox6); }
|
|
|
|
|
|
private void endTextBox13_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox13); }
|
|
|
|
|
|
private void endTextBox14_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox14); }
|
|
|
|
|
|
private void endTextBox15_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox15); }
|
|
|
|
|
|
private void endTextBox16_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox16); }
|
|
|
|
|
|
private void endTextBox17_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox17); }
|
|
|
|
|
|
private void endTextBox18_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox18); }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|