FixedStartAdvanced test method added.
This commit is contained in:
parent
70f38e9352
commit
2acd67707e
@ -0,0 +1,667 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using TBF.Resources;
|
||||
|
||||
namespace TBF.BenchControl.DataEntry.Standard24
|
||||
{
|
||||
public partial class AdvancedFixedStartTestForm : Form, GenericDevices.IHasCompleted
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(AdvancedFixedStartTestForm));
|
||||
|
||||
// Set to 'true' when the form closes
|
||||
public bool Completed { get { return completed; } }
|
||||
bool completed;
|
||||
|
||||
/// <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;
|
||||
|
||||
// To be retrieved after the form closes
|
||||
public readonly string[] WMStartStateStr;
|
||||
|
||||
// To be retrieved after the form closes
|
||||
public float[] WMEndState;
|
||||
|
||||
bool endStates; /// false=start states, true=end states
|
||||
float refVolume;
|
||||
float warningLimLo; /// limit to display exclamation mark, typically 2x errLimLo
|
||||
float warningLimHi; /// limit to display exclamation mark, typically 2x errLimHi
|
||||
|
||||
int TextBoxesCount;
|
||||
///
|
||||
Label[] labels;
|
||||
TextBox[] startTextBoxes;
|
||||
TextBox[] mid1TextBoxes;
|
||||
TextBox[] mid2TextBoxes;
|
||||
TextBox[] endTextBoxes;
|
||||
IList<TextBox> enabledTextBoxes;
|
||||
|
||||
/// <summary>
|
||||
/// Parameterless constructor initializing common part for start and endstate form
|
||||
/// </summary>
|
||||
public AdvancedFixedStartTestForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
TextBoxesCount = 24;
|
||||
|
||||
labels = new Label[]
|
||||
{
|
||||
label1, label2, label3, label4, label5, label6, label7, label8, label9, label10,
|
||||
label11, label12, label13, label14, label15, label16, label17, label18, label19, label20,
|
||||
label21, label22, label23, label24,
|
||||
};
|
||||
startTextBoxes = new TextBox[]
|
||||
{
|
||||
startTextBox1, startTextBox2, startTextBox3, startTextBox4, startTextBox5, startTextBox6,
|
||||
startTextBox7, startTextBox8, startTextBox9, startTextBox10, startTextBox11, startTextBox12,
|
||||
startTextBox13, startTextBox14, startTextBox15, startTextBox16, startTextBox17, startTextBox18,
|
||||
startTextBox19, startTextBox20, startTextBox21, startTextBox22, startTextBox23, startTextBox24,
|
||||
};
|
||||
mid1TextBoxes = new TextBox[]
|
||||
{
|
||||
mid1TextBox1, mid1TextBox2, mid1TextBox3, mid1TextBox4, mid1TextBox5, mid1TextBox6,
|
||||
mid1TextBox7, mid1TextBox8, mid1TextBox9, mid1TextBox10, mid1TextBox11, mid1TextBox12,
|
||||
mid1TextBox13, mid1TextBox14, mid1TextBox15, mid1TextBox16, mid1TextBox17, mid1TextBox18,
|
||||
mid1TextBox19, mid1TextBox20, mid1TextBox21, mid1TextBox22, mid1TextBox23, mid1TextBox24,
|
||||
};
|
||||
mid2TextBoxes = new TextBox[]
|
||||
{
|
||||
mid2TextBox1, mid2TextBox2, mid2TextBox3, mid2TextBox4, mid2TextBox5, mid2TextBox6,
|
||||
mid2TextBox7, mid2TextBox8, mid2TextBox9, mid2TextBox10, mid2TextBox11, mid2TextBox12,
|
||||
mid2TextBox13, mid2TextBox14, mid2TextBox15, mid2TextBox16, mid2TextBox17, mid2TextBox18,
|
||||
mid2TextBox19, mid2TextBox20, mid2TextBox21, mid2TextBox22, mid2TextBox23, mid2TextBox24,
|
||||
};
|
||||
endTextBoxes = new TextBox[]
|
||||
{
|
||||
endTextBox1, endTextBox2, endTextBox3, endTextBox4, endTextBox5, endTextBox6,
|
||||
endTextBox7, endTextBox8, endTextBox9, endTextBox10, endTextBox11, endTextBox12,
|
||||
endTextBox13, endTextBox14, endTextBox15, endTextBox16, endTextBox17, endTextBox18,
|
||||
endTextBox19, endTextBox20, endTextBox21, endTextBox22, endTextBox23, endTextBox24,
|
||||
};
|
||||
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 AdvancedFixedStartTestForm(int waterMetersCount, bool[] disabled)
|
||||
: this()
|
||||
{
|
||||
endStates = false;
|
||||
|
||||
this.WaterMetersCount = waterMetersCount;
|
||||
this.disabled = disabled;
|
||||
|
||||
ShuffleTextBoxes();
|
||||
|
||||
WMStartState = new float[waterMetersCount];
|
||||
WMStartStateStr = 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 AdvancedFixedStartTestForm(int waterMetersCount, string[] wmStartStateStr, bool[] disabled,
|
||||
float refVolume, float errLimLo, float errLimHi)
|
||||
: this()
|
||||
{
|
||||
endStates = true;
|
||||
|
||||
this.WaterMetersCount = waterMetersCount;
|
||||
if (wmStartStateStr == null || wmStartStateStr.Length != waterMetersCount)
|
||||
throw (new Exception("Invalid 'wmStartStateStr' argument"));
|
||||
this.WMStartStateStr = wmStartStateStr;
|
||||
this.disabled = disabled;
|
||||
this.refVolume = refVolume;
|
||||
this.warningLimLo = 2 * errLimLo;
|
||||
this.warningLimHi = 2 * errLimHi;
|
||||
|
||||
ShuffleTextBoxes();
|
||||
|
||||
WMEndState = new float[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()
|
||||
{
|
||||
if (Program.WMsCount < TextBoxesCount)
|
||||
{
|
||||
int nrLines = Program.WMsCount / Program.LineSize;
|
||||
int gap = (TextBoxesCount - Program.WMsCount) / nrLines;
|
||||
|
||||
int dest = 0;
|
||||
for (int l = 0; l < nrLines; l++)
|
||||
{
|
||||
for (int i = 0; i < Program.LineSize; i++)
|
||||
{
|
||||
labels[dest] = labels[l * Program.LineSize + l * gap + i];
|
||||
startTextBoxes[dest] = startTextBoxes[l * Program.LineSize + l * gap + i];
|
||||
mid1TextBoxes[dest] = mid1TextBoxes[l * Program.LineSize + l * gap + i];
|
||||
mid2TextBoxes[dest] = mid2TextBoxes[l * Program.LineSize + l * gap + i];
|
||||
endTextBoxes[dest] = endTextBoxes[l * Program.LineSize + l * gap + i];
|
||||
dest++;
|
||||
}
|
||||
}
|
||||
TextBoxesCount = Program.WMsCount;
|
||||
}
|
||||
}
|
||||
|
||||
private void CycleEndForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
Localize();
|
||||
|
||||
//Height = 115 + 90 * WaterMetersCount;
|
||||
|
||||
for (int i = 0; i < TextBoxesCount; i++)
|
||||
{
|
||||
if (i < WaterMetersCount)
|
||||
{
|
||||
labels[i].Visible = startTextBoxes[i].Visible = mid1TextBoxes[i].Visible = mid2TextBoxes[i].Visible = endTextBoxes[i].Visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (endStates)
|
||||
{
|
||||
for (int i = 0; i < TextBoxesCount; i++)
|
||||
{
|
||||
if (WMStartStateStr != null && i < WMStartStateStr.Length)
|
||||
{
|
||||
startTextBoxes[i].Text = WMStartStateStr[i];
|
||||
}
|
||||
|
||||
if (disabled != null && i < disabled.Length && disabled[i])
|
||||
{
|
||||
endTextBoxes[i].Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
endTextBoxes[i].Enabled = true;
|
||||
enabledTextBoxes.Add(endTextBoxes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < TextBoxesCount; i++)
|
||||
{
|
||||
if (disabled != null && i < disabled.Length && disabled[i])
|
||||
{
|
||||
startTextBoxes[i].Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
startTextBoxes[i].Enabled = true;
|
||||
enabledTextBoxes.Add(startTextBoxes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Localize()
|
||||
{
|
||||
Text = Strings.Water_Meter_States;
|
||||
for (int i = 0; i < TextBoxesCount; i++)
|
||||
{
|
||||
labels[i].Text = Strings.Water_Meter + " " + (i + 1).ToString();
|
||||
}
|
||||
startLabel.Text = Strings.Start;
|
||||
endLabel.Text = Strings.End;
|
||||
okButton.Text = Strings.OkBtnText;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
float err = 0;
|
||||
try
|
||||
{
|
||||
float endState = Utils.ParseUFloat(endTextBox1.Text);
|
||||
float startState = Utils.ParseUFloat(startTextBox1.Text);
|
||||
err = 100.0f * (endState - startState - refVolume) / refVolume;
|
||||
}
|
||||
catch { };
|
||||
exclamation1.Visible = (err < warningLimLo) || (warningLimHi < err);
|
||||
}
|
||||
private void endTextBox2_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
float err = 0;
|
||||
try
|
||||
{
|
||||
float endState = Utils.ParseUFloat(endTextBox2.Text);
|
||||
float startState = Utils.ParseUFloat(startTextBox2.Text);
|
||||
err = 100.0f * (endState - startState - refVolume) / refVolume;
|
||||
}
|
||||
catch { err = 1000.0f; };
|
||||
exclamation2.Visible = (err < warningLimLo) || (warningLimHi < err);
|
||||
}
|
||||
private void endTextBox3_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
float err = 0;
|
||||
try
|
||||
{
|
||||
float endState = Utils.ParseUFloat(endTextBox3.Text);
|
||||
float startState = Utils.ParseUFloat(startTextBox3.Text);
|
||||
err = 100.0f * (endState - startState - refVolume) / refVolume;
|
||||
}
|
||||
catch { err = 1000.0f; };
|
||||
exclamation3.Visible = (err < warningLimLo) || (warningLimHi < err);
|
||||
}
|
||||
private void endTextBox4_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
float err = 0;
|
||||
try
|
||||
{
|
||||
float endState = Utils.ParseUFloat(endTextBox4.Text);
|
||||
float startState = Utils.ParseUFloat(startTextBox4.Text);
|
||||
err = 100.0f * (endState - startState - refVolume) / refVolume;
|
||||
}
|
||||
catch { err = 1000.0f; };
|
||||
exclamation4.Visible = (err < warningLimLo) || (warningLimHi < err);
|
||||
}
|
||||
private void endTextBox5_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
float err = 0;
|
||||
try
|
||||
{
|
||||
float endState = Utils.ParseUFloat(endTextBox5.Text);
|
||||
float startState = Utils.ParseUFloat(startTextBox5.Text);
|
||||
err = 100.0f * (endState - startState - refVolume) / refVolume;
|
||||
}
|
||||
catch { err = 1000.0f; };
|
||||
exclamation5.Visible = (err < warningLimLo) || (warningLimHi < err);
|
||||
}
|
||||
private void endTextBox6_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
float err = 0;
|
||||
try
|
||||
{
|
||||
float endState = Utils.ParseUFloat(endTextBox6.Text);
|
||||
float startState = Utils.ParseUFloat(startTextBox6.Text);
|
||||
err = 100.0f * (endState - startState - refVolume) / refVolume;
|
||||
}
|
||||
catch { err = 1000.0f; };
|
||||
exclamation6.Visible = (err < warningLimLo) || (warningLimHi < err);
|
||||
}
|
||||
private void endTextBox7_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
float err = 0;
|
||||
try
|
||||
{
|
||||
float endState = Utils.ParseUFloat(endTextBox7.Text);
|
||||
float startState = Utils.ParseUFloat(startTextBox7.Text);
|
||||
err = 100.0f * (endState - startState - refVolume) / refVolume;
|
||||
}
|
||||
catch { err = 1000.0f; };
|
||||
exclamation7.Visible = (err < warningLimLo) || (warningLimHi < err);
|
||||
}
|
||||
private void endTextBox8_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
float err = 0;
|
||||
try
|
||||
{
|
||||
float endState = Utils.ParseUFloat(endTextBox8.Text);
|
||||
float startState = Utils.ParseUFloat(startTextBox8.Text);
|
||||
err = 100.0f * (endState - startState - refVolume) / refVolume;
|
||||
}
|
||||
catch { err = 1000.0f; };
|
||||
exclamation8.Visible = (err < warningLimLo) || (warningLimHi < err);
|
||||
}
|
||||
private void endTextBox9_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
float err = 0;
|
||||
try
|
||||
{
|
||||
float endState = Utils.ParseUFloat(endTextBox9.Text);
|
||||
float startState = Utils.ParseUFloat(startTextBox9.Text);
|
||||
err = 100.0f * (endState - startState - refVolume) / refVolume;
|
||||
}
|
||||
catch { err = 1000.0f; };
|
||||
exclamation9.Visible = (err < warningLimLo) || (warningLimHi < err);
|
||||
}
|
||||
|
||||
private void endTextBox10_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
float err = 0;
|
||||
try
|
||||
{
|
||||
float endState = Utils.ParseUFloat(endTextBox10.Text);
|
||||
float startState = Utils.ParseUFloat(startTextBox10.Text);
|
||||
err = 100.0f * (endState - startState - refVolume) / refVolume;
|
||||
}
|
||||
catch { err = 1000.0f; };
|
||||
exclamation10.Visible = (err < warningLimLo) || (warningLimHi < err);
|
||||
}
|
||||
|
||||
private void endTextBox11_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
float err = 0;
|
||||
try
|
||||
{
|
||||
float endState = Utils.ParseUFloat(endTextBox11.Text);
|
||||
float startState = Utils.ParseUFloat(startTextBox11.Text);
|
||||
err = 100.0f * (endState - startState - refVolume) / refVolume;
|
||||
}
|
||||
catch { err = 1000.0f; };
|
||||
exclamation11.Visible = (err < warningLimLo) || (warningLimHi < err);
|
||||
}
|
||||
private void endTextBox12_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
float err = 0;
|
||||
try
|
||||
{
|
||||
float endState = Utils.ParseUFloat(endTextBox12.Text);
|
||||
float startState = Utils.ParseUFloat(startTextBox12.Text);
|
||||
err = 100.0f * (endState - startState - refVolume) / refVolume;
|
||||
}
|
||||
catch { err = 1000.0f; };
|
||||
exclamation12.Visible = (err < warningLimLo) || (warningLimHi < err);
|
||||
}
|
||||
private void endTextBox13_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
float err = 0;
|
||||
try
|
||||
{
|
||||
float endState = Utils.ParseUFloat(endTextBox13.Text);
|
||||
float startState = Utils.ParseUFloat(startTextBox13.Text);
|
||||
err = 100.0f * (endState - startState - refVolume) / refVolume;
|
||||
}
|
||||
catch { err = 1000.0f; };
|
||||
exclamation13.Visible = (err < warningLimLo) || (warningLimHi < err);
|
||||
}
|
||||
private void endTextBox14_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
float err = 0;
|
||||
try
|
||||
{
|
||||
float endState = Utils.ParseUFloat(endTextBox14.Text);
|
||||
float startState = Utils.ParseUFloat(startTextBox14.Text);
|
||||
err = 100.0f * (endState - startState - refVolume) / refVolume;
|
||||
}
|
||||
catch { err = 1000.0f; };
|
||||
exclamation14.Visible = (err < warningLimLo) || (warningLimHi < err);
|
||||
}
|
||||
private void endTextBox15_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
float err = 0;
|
||||
try
|
||||
{
|
||||
float endState = Utils.ParseUFloat(endTextBox15.Text);
|
||||
float startState = Utils.ParseUFloat(startTextBox15.Text);
|
||||
err = 100.0f * (endState - startState - refVolume) / refVolume;
|
||||
}
|
||||
catch { err = 1000.0f; };
|
||||
exclamation15.Visible = (err < warningLimLo) || (warningLimHi < err);
|
||||
}
|
||||
private void endTextBox16_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
float err = 0;
|
||||
try
|
||||
{
|
||||
float endState = Utils.ParseUFloat(endTextBox16.Text);
|
||||
float startState = Utils.ParseUFloat(startTextBox16.Text);
|
||||
err = 100.0f * (endState - startState - refVolume) / refVolume;
|
||||
}
|
||||
catch { err = 1000.0f; };
|
||||
exclamation16.Visible = (err < warningLimLo) || (warningLimHi < err);
|
||||
}
|
||||
private void endTextBox17_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
float err = 0;
|
||||
try
|
||||
{
|
||||
float endState = Utils.ParseUFloat(endTextBox17.Text);
|
||||
float startState = Utils.ParseUFloat(startTextBox17.Text);
|
||||
err = 100.0f * (endState - startState - refVolume) / refVolume;
|
||||
}
|
||||
catch { err = 1000.0f; };
|
||||
exclamation17.Visible = (err < warningLimLo) || (warningLimHi < err);
|
||||
}
|
||||
private void endTextBox18_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
float err = 0;
|
||||
try
|
||||
{
|
||||
float endState = Utils.ParseUFloat(endTextBox18.Text);
|
||||
float startState = Utils.ParseUFloat(startTextBox18.Text);
|
||||
err = 100.0f * (endState - startState - refVolume) / refVolume;
|
||||
}
|
||||
catch { err = 1000.0f; };
|
||||
exclamation18.Visible = (err < warningLimLo) || (warningLimHi < err);
|
||||
}
|
||||
private void endTextBox19_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
float err = 0;
|
||||
try
|
||||
{
|
||||
float endState = Utils.ParseUFloat(endTextBox19.Text);
|
||||
float startState = Utils.ParseUFloat(startTextBox19.Text);
|
||||
err = 100.0f * (endState - startState - refVolume) / refVolume;
|
||||
}
|
||||
catch { err = 1000.0f; };
|
||||
exclamation19.Visible = (err < warningLimLo) || (warningLimHi < err);
|
||||
}
|
||||
private void endTextBox20_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
float err = 0;
|
||||
try
|
||||
{
|
||||
float endState = Utils.ParseUFloat(endTextBox20.Text);
|
||||
float startState = Utils.ParseUFloat(startTextBox20.Text);
|
||||
err = 100.0f * (endState - startState - refVolume) / refVolume;
|
||||
}
|
||||
catch { err = 1000.0f; };
|
||||
exclamation20.Visible = (err < warningLimLo) || (warningLimHi < err);
|
||||
}
|
||||
private void endTextBox21_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
float err = 0;
|
||||
try
|
||||
{
|
||||
float endState = Utils.ParseUFloat(endTextBox21.Text);
|
||||
float startState = Utils.ParseUFloat(startTextBox21.Text);
|
||||
err = 100.0f * (endState - startState - refVolume) / refVolume;
|
||||
}
|
||||
catch { err = 1000.0f; };
|
||||
exclamation21.Visible = (err < warningLimLo) || (warningLimHi < err);
|
||||
}
|
||||
private void endTextBox22_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
float err = 0;
|
||||
try
|
||||
{
|
||||
float endState = Utils.ParseUFloat(endTextBox22.Text);
|
||||
float startState = Utils.ParseUFloat(startTextBox22.Text);
|
||||
err = 100.0f * (endState - startState - refVolume) / refVolume;
|
||||
}
|
||||
catch { err = 1000.0f; };
|
||||
exclamation22.Visible = (err < warningLimLo) || (warningLimHi < err);
|
||||
}
|
||||
private void endTextBox23_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
float err = 0;
|
||||
try
|
||||
{
|
||||
float endState = Utils.ParseUFloat(endTextBox23.Text);
|
||||
float startState = Utils.ParseUFloat(startTextBox23.Text);
|
||||
err = 100.0f * (endState - startState - refVolume) / refVolume;
|
||||
}
|
||||
catch { err = 1000.0f; };
|
||||
exclamation23.Visible = (err < warningLimLo) || (warningLimHi < err);
|
||||
}
|
||||
private void endTextBox24_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
float err = 0;
|
||||
try
|
||||
{
|
||||
float endState = Utils.ParseUFloat(endTextBox24.Text);
|
||||
float startState = Utils.ParseUFloat(startTextBox24.Text);
|
||||
err = 100.0f * (endState - startState - refVolume) / refVolume;
|
||||
}
|
||||
catch { err = 1000.0f; };
|
||||
exclamation24.Visible = (err < warningLimLo) || (warningLimHi < 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 startTextBox7_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox7); }
|
||||
private void startTextBox8_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox8); }
|
||||
private void startTextBox9_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox9); }
|
||||
private void startTextBox10_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox10); }
|
||||
private void startTextBox11_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox11); }
|
||||
private void startTextBox12_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox12); }
|
||||
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 startTextBox19_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox19); }
|
||||
private void startTextBox20_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox20); }
|
||||
private void startTextBox21_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox21); }
|
||||
private void startTextBox22_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox22); }
|
||||
private void startTextBox23_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox23); }
|
||||
private void startTextBox24_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox24); }
|
||||
|
||||
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 endTextBox7_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox7); }
|
||||
private void endTextBox8_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox8); }
|
||||
private void endTextBox9_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox9); }
|
||||
private void endTextBox10_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox10); }
|
||||
private void endTextBox11_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox11); }
|
||||
private void endTextBox12_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox12); }
|
||||
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); }
|
||||
private void endTextBox19_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox19); }
|
||||
private void endTextBox20_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox20); }
|
||||
private void endTextBox21_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox21); }
|
||||
private void endTextBox22_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox22); }
|
||||
private void endTextBox23_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox23); }
|
||||
private void endTextBox24_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox24); }
|
||||
}
|
||||
}
|
||||
2140
TestBenchFramework/BenchControl/DataEntry/Standard24/AdvancedFixedStartTestForm.designer.cs
generated
Normal file
2140
TestBenchFramework/BenchControl/DataEntry/Standard24/AdvancedFixedStartTestForm.designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@ -34,8 +34,9 @@ namespace TBF.BenchControl
|
||||
Factories.Add(new DataEntry.Standard24.EntryFormFactory());
|
||||
Factories.Add(new DataEntry.Standard48.EntryFormFactory());
|
||||
Factories.Add(new Elde.Diverter.DiverterFactory());
|
||||
Factories.Add(new TestMethods.FixedStartAdvanced.TestMethodFactory()); /// FixedStartAdvanced
|
||||
Factories.Add(new TestMethods.FixedStartCombinedMeters.TestMethodFactory());
|
||||
Factories.Add(new TestMethods.FixedStartMassCollection.TestMethodFactory());
|
||||
Factories.Add(new TestMethods.FixedStartMassCollection.TestMethodFactory()); /// FixedStartMassCollection
|
||||
Factories.Add(new Elde.FixedStartRegisterReader.RegisterReaderFactory());
|
||||
Factories.Add(new Elde.FlowMeter.FlowMeterFactory());
|
||||
Factories.Add(new Elde.FlowMeterTwins.FlowMeterFactory());
|
||||
|
||||
@ -0,0 +1,622 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using log4net;
|
||||
using TBF.BenchControl;
|
||||
using TBF.Boxes;
|
||||
using TBF.Resources;
|
||||
using TBF.UiBridge;
|
||||
|
||||
namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
|
||||
{
|
||||
public class FixedStartAdvancedSeq : Sequences.SequenceBase
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(FixedStartAdvancedSeq));
|
||||
|
||||
/// <summary>
|
||||
/// Flying start mass collection method sequence
|
||||
/// </summary>
|
||||
/// <param name="test">Test entity</param>
|
||||
/// <returns>
|
||||
/// Event.Done . . . . . . . OK
|
||||
/// Event.UiCmdStop . . . . Stopped by the user using the on-screen button STOP
|
||||
/// Event.OpArgumentError . Target flow is out of range
|
||||
/// Event.Error . . . . . . Unspecified error
|
||||
/// </returns>
|
||||
public IList<Event> Execute(Entities.Test test)
|
||||
{
|
||||
Elde.ControlBoardDev cBrd = StateMachine.ControlBoard;
|
||||
|
||||
IList<Event> e = new List<Event>(); /// Events from currently running operations
|
||||
Event retVal = Event.Done;
|
||||
checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state
|
||||
|
||||
ltrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h]
|
||||
|
||||
/// Notes:
|
||||
/// float timeHr = volumeLtr / (1000.0f * targetFlow);
|
||||
/// float timeSec = 3600.0f * timeHr;
|
||||
/// int refPulses = (int)(timeSec * (2000.0f * targetFlow / pOut.FlowMeter.NominalFlow));
|
||||
int totalPulses = (int)(test.Volume / ltrPerRefPulse + 0.5f);
|
||||
|
||||
processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this);
|
||||
|
||||
float[] wmBeginStates = new float[Program.WMsCount];
|
||||
float[] wmEndStates = new float[Program.WMsCount];
|
||||
|
||||
int repetitionNr = 1; /// First test: repetitionNr=1
|
||||
|
||||
//====================================
|
||||
// Transition or SetRoute - Start
|
||||
//====================================
|
||||
switch (Transition(transitionBefore, TransitionContext.BeforeTest))
|
||||
{
|
||||
case Event.Error: { retVal = Event.Error; goto stopTest; }
|
||||
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
|
||||
//====================================
|
||||
loop:
|
||||
/// Start the test, initialize test results
|
||||
Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, totalPulses));
|
||||
Entities.TestResult tstRslt = new Entities.TestResult(test, repetitionNr, Entities.MetersKind.Single);
|
||||
|
||||
|
||||
int flowSetTime0 = StateMachine.Time;
|
||||
float estFlowSetTime = 10.0f;
|
||||
|
||||
//------------------------------------------------
|
||||
Bridge.OnActivity(this, Strings.Setting_the_flow);
|
||||
//------------------------------------------------
|
||||
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower);
|
||||
|
||||
State.Create("FixedStartAdvanced : Starting the pump")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(new Operations.TimerOp(5))
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
|
||||
int flowSetTime = StateMachine.Time - flowSetTime0;
|
||||
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
|
||||
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
|
||||
|
||||
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.TimerExpired));
|
||||
|
||||
|
||||
State.Create("FixedStartAdvanced : Starting the pump")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(cBrd.SetValvesOp(inPath.Pump, null))
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
|
||||
int flowSetTime = StateMachine.Time - flowSetTime0;
|
||||
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
|
||||
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
|
||||
|
||||
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.ValvesSet));
|
||||
|
||||
|
||||
if (!test.Emptying) /// If condition met => skip measuring and force emptying
|
||||
{
|
||||
///
|
||||
/// Measure the weight and skip emptying if there is enough room in the tank
|
||||
///
|
||||
State.Create("FixedStartAdvanced : Measuring the mass of water in the tank")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(outPath.Balance.ReadMassOp(ref mass))
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
||||
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.BalanceDone));
|
||||
|
||||
float estimatedEndMass = mass.Val + test.Volume;
|
||||
if (estimatedEndMass < outPath.Balance.Capacity * Constants.TankFullFactor)
|
||||
{
|
||||
goto set_flow; /// Enough room in the tank -> skip emptying
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Empty the water tank
|
||||
///
|
||||
switch (EmptyTheTank(outPath.EmptyTankValve, outPath.Balance))
|
||||
{
|
||||
case Event.Error: { retVal = Event.Error; goto stopTest; }
|
||||
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
|
||||
set_flow:
|
||||
|
||||
//------------------------------------------------
|
||||
Bridge.OnActivity(this, Strings.Setting_the_flow);
|
||||
//------------------------------------------------
|
||||
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower);
|
||||
State.Create("FixedStartAdvanced : Starting the pump")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(cBrd.SetValvesOp(inPath.Pump, null))
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
|
||||
int flowSetTime = StateMachine.Time - flowSetTime0;
|
||||
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
|
||||
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
|
||||
|
||||
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.ValvesSet));
|
||||
|
||||
//--------------------------------
|
||||
State.Create("FixedStartAdvanced : Setting the flow")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, outPath.PidCoef, refFlow, 600)) /// timeout = 10 min.
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
|
||||
int flowSetTime = StateMachine.Time - flowSetTime0;
|
||||
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
|
||||
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
|
||||
|
||||
if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; }
|
||||
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
if (e.Contains(Event.RegulValveTimeOut))
|
||||
{
|
||||
Bridge.OnError(this, Strings.Timeout);
|
||||
retVal = Event.Done;
|
||||
goto stopTest;
|
||||
}
|
||||
if (e.Contains(Event.Next)) goto flow_set;
|
||||
}
|
||||
while (!e.Contains(Event.FlowReached));
|
||||
|
||||
flow_set:
|
||||
|
||||
//------------------------------------------------
|
||||
Bridge.OnActivity(this, Strings.Stopping_flow_for_the_fixed_start);
|
||||
//------------------------------------------------
|
||||
State.Create("FixedStartAdvanced : Closing the start/stop valve before the fixed start test")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, outPath.StartValve))
|
||||
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.ValvesSet));
|
||||
|
||||
|
||||
int time = StateMachine.Time;
|
||||
float currentFlow = refFlow.Val;
|
||||
|
||||
|
||||
/// Extract cameras from the current sensors path, add operations to the detection state
|
||||
IList<IOperation> measureOperations = new List<IOperation>();
|
||||
for (int i = 0; i < sensPath.RegisterReaders.Length; i++)
|
||||
{
|
||||
GenericDevices.ICameraRoi cameraRoi = sensPath.RegisterReaders[i] as GenericDevices.ICameraRoi;
|
||||
if (cameraRoi != null) measureOperations.Add(cameraRoi.MeasureOp());
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Enter watermeter begin states here
|
||||
///
|
||||
GenericDevices.IHasWMStatesForm dataEntryCmpnt =
|
||||
TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IHasWMStatesForm;
|
||||
if (dataEntryCmpnt != null)
|
||||
{
|
||||
Bridge.OnActivity(this, "Enter the water meter data");
|
||||
State.Create("FixedStartAdvanced : Enter begin-state")
|
||||
.AddOperation((dataEntryCmpnt as GenericDevices.IHasWMStatesForm).ShowTestStartFormOp())
|
||||
.AddOperation(checkUiOp)
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.ModelessFormClosed));
|
||||
|
||||
for (int i = 0; i < Program.WMsCount; i++)
|
||||
{
|
||||
tstRslt.Meters[i].VolumeStart = dataEntryCmpnt.WMStartState(i); /// Units: 1 liter
|
||||
|
||||
///-----
|
||||
BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader =
|
||||
sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader;
|
||||
|
||||
if (registerReader != null) registerReader.BeginWMState = dataEntryCmpnt.WMStartState(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------
|
||||
Bridge.OnActivity(this, Strings.Measuring_the_weight);
|
||||
//------------------------------------------------
|
||||
State.Create("FixedStartAdvanced : Measuring the start mass")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(benchPath.TempIn.ReadTempOp(ref tempIn))
|
||||
.AddOperation(benchPath.TempOut.ReadTempOp(ref tempOut))
|
||||
.AddOperation(outPath.TempDiv.ReadTempOp(ref tempDiv))
|
||||
.AddOperation(benchPath.PressIn.ReadPressureOp(ref pressIn))
|
||||
.AddOperation(benchPath.PressOut.ReadPressureOp(ref pressOut))
|
||||
.AddOperation((StateMachine.Ambient != null)
|
||||
? StateMachine.Ambient.ReadAmbientOp(airTemperature, airPressure, airHumidity) : null)
|
||||
.AddOperations(measureOperations)
|
||||
.AddOperation(outPath.Balance.ReadStableMassOp(ref startMass, 5))
|
||||
.AddOperation(cBrd.UpdateTankWeightOp())
|
||||
.AddOperation(processDataLoggingOp)
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
||||
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.BalanceDone));
|
||||
|
||||
tstRslt.TimeStart = DateTime.Now;
|
||||
tstRslt.MassStartRaw = startMass.Val;
|
||||
mass.Val = startMass.Val;
|
||||
|
||||
//------------------------------------------------
|
||||
Bridge.OnActivity(this, Strings.Test_in_progress);
|
||||
//------------------------------------------------
|
||||
State.Create("FixedStartAdvanced : Starting the test")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperations(measureOperations)
|
||||
.AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro,
|
||||
test.Qfrom, test.Qto, 2 * totalPulses, (float)test.TolerRed))
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
||||
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.MeasurementStarted));
|
||||
|
||||
|
||||
State.Create("FixedStartAdvanced : Opening the start/stop valve at the beginning of the fixed start test")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(outPath.StartValve, null))
|
||||
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.ValvesSet));
|
||||
|
||||
|
||||
/// Measurement loop - preparation
|
||||
readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders, ref WMPulses, ref WMRefPulses);
|
||||
queryEnd1 = cBrd.QueryMeasurementEndOp();
|
||||
queryEnd2 = cBrd.QueryMeasurementEndOp();
|
||||
|
||||
bool firstTime = true; /// To reset sums for averaging
|
||||
ResetAveragedData();
|
||||
int estimtdEndTime = StateMachine.Time + (int)test.TstTime;
|
||||
|
||||
/// Measurement loop - begin
|
||||
do
|
||||
{
|
||||
//--------------------------------
|
||||
switch (ReadRegistersTempPressAmbient(measureOperations, true))
|
||||
{
|
||||
case Event.Error: { retVal = Event.Error; goto stopTest; }
|
||||
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
case Event.MeasurementCompleted: goto test_completed;
|
||||
}
|
||||
|
||||
int remainingTime = Math.Max(estimtdEndTime - StateMachine.Time, 0);
|
||||
if (remainingTime > 60)
|
||||
{
|
||||
Bridge.OnActivity(this, string.Format("{0} ... {1} min {2} s", Strings.Test_in_progress, remainingTime / 60, remainingTime % 60));
|
||||
}
|
||||
else
|
||||
{
|
||||
Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime));
|
||||
}
|
||||
|
||||
if (firstTime)
|
||||
{
|
||||
firstTime = false; /// Do the following only once
|
||||
tstRslt.TempInStart = tempIn.Val;
|
||||
tstRslt.TempOutStart = tempOut.Val;
|
||||
tstRslt.TempDivStart = tempDiv.Val;
|
||||
tstRslt.PressInStart = pressIn.Val;
|
||||
tstRslt.PressOutStart = pressOut.Val;
|
||||
}
|
||||
|
||||
tstRslt.TempInEnd = tempIn.Val;
|
||||
tstRslt.TempOutEnd = tempOut.Val;
|
||||
tstRslt.TempDivEnd = tempDiv.Val;
|
||||
tstRslt.PressInEnd = pressIn.Val;
|
||||
tstRslt.PressOutEnd = pressOut.Val;
|
||||
tstRslt.MassEndRaw = mass.Val;
|
||||
|
||||
AccumulateAveragedData();
|
||||
|
||||
refFreq.Val = cBrd.ReferenceFreq;
|
||||
refFlow.Val = cBrd.ReferenceFlow;
|
||||
tstRslt.AmbientTempAve = airTemperature.Val;
|
||||
tstRslt.AmbientPressAve = airPressure.Val;
|
||||
tstRslt.AmbientHumiAve = airHumidity.Val;
|
||||
|
||||
string logstr = string.Format("E={0} f={1} q={2}", cBrd.EtPulses(0), cBrd.ReferenceFreq,
|
||||
cBrd.ReferenceFlow * outPath.FlowMeter.NominalFlow);
|
||||
for (int i = 0; i < Program.WMsCount; i++)
|
||||
{
|
||||
logstr += string.Format(" M{0}=({1},{2})", i + 1, WMRefPulses[i], WMPulses[i]);
|
||||
}
|
||||
log.Debug(logstr);
|
||||
|
||||
|
||||
float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime);
|
||||
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, true, cBrd, cBrd.TTime, progress));
|
||||
}
|
||||
while (cBrd.EtPulses(0) < totalPulses);
|
||||
/// Measurement loop - end
|
||||
|
||||
test_completed:
|
||||
|
||||
State.Create("FixedStartAdvanced : Closing the start/stop valve at the end of the fixed start test")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, outPath.StartValve))
|
||||
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
||||
}
|
||||
while (e.Contains(Event.ValvesBusy));
|
||||
|
||||
|
||||
State.Create("FixedStartAdvanced : Waiting before 2nd mass measurement")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(benchPath.TempIn.ReadTempOp(ref tempIn))
|
||||
.AddOperation(benchPath.TempOut.ReadTempOp(ref tempOut))
|
||||
.AddOperation(outPath.TempDiv.ReadTempOp(ref tempDiv))
|
||||
.AddOperation(benchPath.PressIn.ReadPressureOp(ref pressIn))
|
||||
.AddOperation(benchPath.PressOut.ReadPressureOp(ref pressOut))
|
||||
.AddOperation((StateMachine.Ambient != null)
|
||||
? StateMachine.Ambient.ReadAmbientOp(airTemperature, airPressure, airHumidity) : null)
|
||||
.AddOperation(outPath.Balance.ReadMassOp(ref mass))
|
||||
.AddOperation(cBrd.UpdateTankWeightOp())
|
||||
.AddOperation(processDataLoggingOp)
|
||||
.AddOperation(new Operations.TimerOp(test.TimeStop2Mass))
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
||||
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.TimerExpired));
|
||||
|
||||
|
||||
//------------------------------------------------
|
||||
Bridge.OnActivity(this, Strings.Measuring_the_weight);
|
||||
//------------------------------------------------
|
||||
State.Create("FixedStartAdvanced : Measuring the end mass")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(benchPath.TempIn.ReadTempOp(ref tempIn))
|
||||
.AddOperation(benchPath.TempOut.ReadTempOp(ref tempOut))
|
||||
.AddOperation(outPath.TempDiv.ReadTempOp(ref tempDiv))
|
||||
.AddOperation(benchPath.PressIn.ReadPressureOp(ref pressIn))
|
||||
.AddOperation(benchPath.PressOut.ReadPressureOp(ref pressOut))
|
||||
.AddOperation((StateMachine.Ambient != null)
|
||||
? StateMachine.Ambient.ReadAmbientOp(airTemperature, airPressure, airHumidity) : null)
|
||||
.AddOperation(outPath.Balance.ReadStableMassOp(ref endMass, 5))
|
||||
.AddOperation(cBrd.UpdateTankWeightOp())
|
||||
.AddOperation(processDataLoggingOp)
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
||||
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.BalanceDone));
|
||||
///
|
||||
tstRslt.MassEndRaw = endMass.Val;
|
||||
tstRslt.TimeEnd = DateTime.Now;
|
||||
|
||||
|
||||
State.Create("FixedStartAdvanced : Stopping diverter, gate, etc.")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(cBrd.StopPreviousOp())
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.PreviousStopped));
|
||||
|
||||
|
||||
tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections);
|
||||
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections);
|
||||
tstRslt.MassDiff = tstRslt.MassEnd - tstRslt.MassStart;
|
||||
tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3]
|
||||
tstRslt.VolumeCTV = 1.00103f * 1000.0f * tstRslt.MassDiff / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3]
|
||||
|
||||
///
|
||||
/// Enter watermeter end states here
|
||||
///
|
||||
if (dataEntryCmpnt != null)
|
||||
{
|
||||
Bridge.OnActivity(this, "Enter the water meter data");
|
||||
State.Create("FixedStartAdvanced : Enter end-state")
|
||||
.AddOperation(dataEntryCmpnt.ShowTestEndFormOp(tstRslt.VolumeCTV, tstRslt.ErrLimLo, tstRslt.ErrLimHi))
|
||||
.AddOperation(checkUiOp)
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.ModelessFormClosed));
|
||||
|
||||
|
||||
for (int i = 0; i < Program.WMsCount; i++)
|
||||
{
|
||||
tstRslt.Meters[i].VolumeEnd = dataEntryCmpnt.WMEndState(i);
|
||||
|
||||
///-----
|
||||
BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader =
|
||||
sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader;
|
||||
|
||||
if (registerReader != null) registerReader.EndWMState = dataEntryCmpnt.WMEndState(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------
|
||||
Bridge.OnActivity(this, Strings.Test_completed);
|
||||
//------------------------------------------------
|
||||
|
||||
/// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results
|
||||
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest;
|
||||
|
||||
///
|
||||
/// Populate TestResult data entity with data
|
||||
///
|
||||
UpdateTestRsltWithAveragedData(tstRslt);
|
||||
|
||||
tstRslt.BatchNr = Program.LocalSettings.BatchNr;
|
||||
tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections);
|
||||
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections);
|
||||
tstRslt.MassDiff = tstRslt.MassEnd - tstRslt.MassStart;
|
||||
tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3]
|
||||
tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3]
|
||||
tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3]
|
||||
tstRslt.Time = cBrd.TTime; /// [s] measurement time
|
||||
tstRslt.FlowMass = 3600.0f * tstRslt.MassDiff / tstRslt.Time; /// [kg/h]
|
||||
tstRslt.FlowVolume = 3600.0f * ltrPerRefPulse * cBrd.EtPulses(0) / tstRslt.Time; /// [l/h]
|
||||
tstRslt.VolumeCTV = 1.00103f * 1000.0f * tstRslt.MassDiff / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3]
|
||||
tstRslt.VolumeMaster = ltrPerRefPulse * cBrd.EtPulses(0); /// [l] volume from the master flow meter
|
||||
tstRslt.PulsesMaster = cBrd.EtPulses(0); /// Pulses of the master flow meter (test total)
|
||||
tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter
|
||||
|
||||
if (tstRslt.VolumeCTV <= float.Epsilon)
|
||||
{
|
||||
tstRslt.ErrorMaster = 0.1f;
|
||||
}
|
||||
else
|
||||
{
|
||||
tstRslt.ErrorMaster = 100 * (tstRslt.VolumeMaster - tstRslt.VolumeCTV) / tstRslt.VolumeCTV;
|
||||
}
|
||||
tstRslt.TimeDivStart0 = 0;
|
||||
tstRslt.TimeDivStart1 = 0;
|
||||
tstRslt.TimeDivStart2 = 0;
|
||||
tstRslt.TimeDivStart3 = 0;
|
||||
tstRslt.TimeDivStart4 = 0;
|
||||
tstRslt.TimeDivStart5 = 0;
|
||||
tstRslt.TimeDivEnd0 = 0;
|
||||
tstRslt.TimeDivEnd1 = 0;
|
||||
tstRslt.TimeDivEnd2 = 0;
|
||||
tstRslt.TimeDivEnd3 = 0;
|
||||
tstRslt.TimeDivEnd4 = 0;
|
||||
tstRslt.TimeDivEnd5 = 0;
|
||||
|
||||
for (int i = 0; i < Program.WMsCount; i++)
|
||||
{
|
||||
if ((i < WaterMeters.Count) && !WaterMeters[i].Disabled)
|
||||
{
|
||||
tstRslt.Meters[i].SerialNr = (i < WaterMeters.Count) ? WaterMeters[i].SerialNr : string.Empty;
|
||||
tstRslt.Meters[i].VolumeMeter = tstRslt.Meters[i].VolumeEnd - tstRslt.Meters[i].VolumeStart;
|
||||
tstRslt.Meters[i].VolumeRef = tstRslt.VolumeCTV; /// liter
|
||||
tstRslt.Meters[i].PulsesMeter = 0;
|
||||
tstRslt.Meters[i].PulsesMaster = tstRslt.PulsesMaster;
|
||||
tstRslt.Meters[i].Time = cBrd.TTime;
|
||||
if (tstRslt.Meters[i].VolumeRef > 0)
|
||||
{
|
||||
tstRslt.Meters[i].VolumeErrorPct =
|
||||
100 * (tstRslt.Meters[i].VolumeMeter - tstRslt.Meters[i].VolumeRef) / tstRslt.Meters[i].VolumeRef;
|
||||
/// %
|
||||
}
|
||||
else
|
||||
{
|
||||
tstRslt.Meters[i].VolumeErrorPct = -100;
|
||||
}
|
||||
tstRslt.Meters[i].Passed = (tstRslt.ErrLimLo <= tstRslt.Meters[i].VolumeErrorPct) && (tstRslt.Meters[i].VolumeErrorPct <= tstRslt.ErrLimHi);
|
||||
|
||||
tstRslt.Meters[i].Disabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
tstRslt.Meters[i].Disabled = true;
|
||||
}
|
||||
}
|
||||
/// Add data - end
|
||||
|
||||
AddOrOverwriteResult(tstRslt);
|
||||
|
||||
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(tstRslt));
|
||||
|
||||
/// Append the results to the CSV-file
|
||||
allResults.Info(TestResult2CsvLine(tstRslt));
|
||||
|
||||
|
||||
if (++repetitionNr <= test.Repeats)
|
||||
{
|
||||
goto loop;
|
||||
}
|
||||
|
||||
|
||||
stopTest:
|
||||
|
||||
///----------------------///
|
||||
/// Quit this sequence ///
|
||||
///----------------------///
|
||||
|
||||
State.Create("FixedStartAdvanced : Stopping diverter, gate, etc.")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(cBrd.StopPreviousOp())
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.PreviousStopped));
|
||||
|
||||
/// Transition sequence at the end of test
|
||||
/// Prevent overwriting 'retVal' in case it was set to non-default value earlier
|
||||
switch (Transition(transitionAfter, TransitionContext.AfterTest))
|
||||
{
|
||||
case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; }
|
||||
case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; }
|
||||
}
|
||||
|
||||
/// Create a list with one item 'retVal' (default is Event.Done) and return it
|
||||
IList<Event> retList = new List<Event>(1);
|
||||
retList.Add(retVal);
|
||||
return retList;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using log4net;
|
||||
using TBF.BenchControl;
|
||||
|
||||
namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
|
||||
{
|
||||
public class TestMethod : ComponentBase, GenericDevices.ITestMethod
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod));
|
||||
public override string ToString() { return string.Format("TestMethods.FixedStartAdvanced({0})", Cfg.ToString(1)); }
|
||||
|
||||
public bool Evaluate(Entities.Test test) { return true; }
|
||||
public bool Publish(Entities.Test test) { return true; }
|
||||
public bool CanTest(Entities.MetersKind meters) { return meters == Entities.MetersKind.Single; }
|
||||
|
||||
public TestMethod()
|
||||
{
|
||||
}
|
||||
|
||||
public TestMethod(TestMethodCfg cfg)
|
||||
: base(cfg)
|
||||
{
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
public IList<Event> Execute(Entities.Test test)
|
||||
{
|
||||
return (new FixedStartAdvancedSeq()).Execute(test);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
|
||||
{
|
||||
public class TestMethodCfg : ComponentCfgBase, Generic.IComponentCfg
|
||||
{
|
||||
public IComponent GetComponent(IList<IComponent> components) { return new TestMethod(this); }
|
||||
public IComponentCfgCtrl GetControl() { return new TestMethodCfgCtrl(); }
|
||||
|
||||
/// Private parameterless constructor invoked by all other (public) constructors
|
||||
TestMethodCfg()
|
||||
{
|
||||
Name = "FixedStartAdvanced";
|
||||
ParentName = string.Empty;
|
||||
}
|
||||
|
||||
public TestMethodCfg(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
this.Factory = factory;
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("Name={0}", Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,71 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
|
||||
{
|
||||
public partial class TestMethodCfgCtrl : UserControl, IComponentCfgCtrl
|
||||
{
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(TestMethodCfgCtrl));
|
||||
|
||||
public bool ShowMore { get { return false; } }
|
||||
|
||||
TestMethodCfg config;
|
||||
public IComponentCfg Config
|
||||
{
|
||||
get { return config as IComponentCfg; }
|
||||
set
|
||||
{
|
||||
config = value as TestMethodCfg;
|
||||
Redraw();
|
||||
}
|
||||
}
|
||||
|
||||
public TestMethodCfgCtrl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void EntryFormCfgCtrl_Load(object sender, EventArgs e)
|
||||
{
|
||||
Redraw();
|
||||
}
|
||||
|
||||
public void Closing()
|
||||
{
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
classNameLabel.Text = config.Factory.ClassName;
|
||||
nameTextBox.Text = config.Name;
|
||||
}
|
||||
|
||||
public void Unlock()
|
||||
{
|
||||
nameTextBox.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
||||
return flags;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags UpdateCfg()
|
||||
{
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd;
|
||||
|
||||
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
|
||||
|
||||
config.Name = nameTextBox.Text;
|
||||
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
86
TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/TestMethodCfgCtrl.designer.cs
generated
Normal file
86
TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/TestMethodCfgCtrl.designer.cs
generated
Normal file
@ -0,0 +1,86 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
|
||||
{
|
||||
partial class TestMethodCfgCtrl
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.nameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.nameLabel = new System.Windows.Forms.Label();
|
||||
this.classNameLabel = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// nameTextBox
|
||||
//
|
||||
this.nameTextBox.Enabled = false;
|
||||
this.nameTextBox.Location = new System.Drawing.Point(137, 57);
|
||||
this.nameTextBox.Name = "nameTextBox";
|
||||
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
|
||||
this.nameTextBox.TabIndex = 5;
|
||||
//
|
||||
// nameLabel
|
||||
//
|
||||
this.nameLabel.AutoSize = true;
|
||||
this.nameLabel.Location = new System.Drawing.Point(27, 60);
|
||||
this.nameLabel.Name = "nameLabel";
|
||||
this.nameLabel.Size = new System.Drawing.Size(35, 13);
|
||||
this.nameLabel.TabIndex = 4;
|
||||
this.nameLabel.Text = "Name";
|
||||
//
|
||||
// classNameLabel
|
||||
//
|
||||
this.classNameLabel.AutoSize = true;
|
||||
this.classNameLabel.Location = new System.Drawing.Point(134, 33);
|
||||
this.classNameLabel.Name = "classNameLabel";
|
||||
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
|
||||
this.classNameLabel.TabIndex = 3;
|
||||
this.classNameLabel.Text = "ComonentName";
|
||||
//
|
||||
// BasicPrinterCfgCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.nameTextBox);
|
||||
this.Controls.Add(this.nameLabel);
|
||||
this.Controls.Add(this.classNameLabel);
|
||||
this.Name = "BasicPrinterCfgCtrl";
|
||||
this.Size = new System.Drawing.Size(300, 200);
|
||||
this.Load += new System.EventHandler(this.EntryFormCfgCtrl_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox nameTextBox;
|
||||
private System.Windows.Forms.Label nameLabel;
|
||||
private System.Windows.Forms.Label classNameLabel;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@ -0,0 +1,23 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
|
||||
{
|
||||
public class TestMethodFactory : IComponentFactory
|
||||
{
|
||||
public string ClassName { get { return "FixedStartAdvanced"; } }
|
||||
|
||||
public void ResetStaticProperties() { TestMethod.ResetStaticProperties(); }
|
||||
|
||||
public IComponent DummyComponent() { return new TestMethod(); }
|
||||
|
||||
public IComponentCfg DefaultConfig() { return new TestMethodCfg(this); }
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Entities.Component component)
|
||||
{
|
||||
return ComponentCfgBase.CreateFromDbEntity(typeof(TestMethodCfg), component, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -234,6 +234,12 @@
|
||||
<Compile Include="BenchControl\DataEntry\Standard12\TestStartEndForm.designer.cs">
|
||||
<DependentUpon>TestStartEndForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\DataEntry\Standard24\AdvancedFixedStartTestForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\DataEntry\Standard24\AdvancedFixedStartTestForm.designer.cs">
|
||||
<DependentUpon>AdvancedFixedStartTestForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\DataEntry\Standard24\CycleBeginningForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@ -410,6 +416,16 @@
|
||||
<Compile Include="BenchControl\TestMethods\Adjustment\WMErrorsForm24.designer.cs">
|
||||
<DependentUpon>WMErrorsForm24.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\TestMethods\FixedStartAdvanced\FixedStartAdvancedSeq.cs" />
|
||||
<Compile Include="BenchControl\TestMethods\FixedStartAdvanced\TestMethod.cs" />
|
||||
<Compile Include="BenchControl\TestMethods\FixedStartAdvanced\TestMethodCfg.cs" />
|
||||
<Compile Include="BenchControl\TestMethods\FixedStartAdvanced\TestMethodCfgCtrl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\TestMethods\FixedStartAdvanced\TestMethodCfgCtrl.designer.cs">
|
||||
<DependentUpon>TestMethodCfgCtrl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\TestMethods\FixedStartAdvanced\TestMethodFactory.cs" />
|
||||
<Compile Include="BenchControl\TestMethods\FixedStartCombinedMeters\FixedStartCombinedMetersSeq.cs" />
|
||||
<Compile Include="BenchControl\TestMethods\FixedStartCombinedMeters\TestMethod.cs" />
|
||||
<Compile Include="BenchControl\TestMethods\FixedStartCombinedMeters\TestMethodCfg.cs" />
|
||||
@ -1477,6 +1493,9 @@
|
||||
<EmbeddedResource Include="BenchControl\DataEntry\Standard12\TestStartEndForm.resx">
|
||||
<DependentUpon>TestStartEndForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="BenchControl\DataEntry\Standard24\AdvancedFixedStartTestForm.resx">
|
||||
<DependentUpon>AdvancedFixedStartTestForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="BenchControl\DataEntry\Standard24\CycleBeginningForm.resx">
|
||||
<DependentUpon>CycleBeginningForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
@ -1624,6 +1643,9 @@
|
||||
<EmbeddedResource Include="BenchControl\TestMethods\CombinedWithDetection\TestMethodCfgCtrl.resx">
|
||||
<DependentUpon>TestMethodCfgCtrl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="BenchControl\TestMethods\FixedStartAdvanced\TestMethodCfgCtrl.resx">
|
||||
<DependentUpon>TestMethodCfgCtrl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="BenchControl\TestMethods\FixedStartCombinedMeters\TestMethodCfgCtrl.resx">
|
||||
<DependentUpon>TestMethodCfgCtrl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user