iPerl parameters FactorLimitLo, FactorLimitHi moved to iPerlCommunication (arguments in the activity string), version 1.5.131.

This commit is contained in:
Milan Hanajik 2015-10-16 11:24:03 +02:00
parent 1301db3af4
commit 5a77c5f660
6 changed files with 47 additions and 102 deletions

View File

@ -906,22 +906,37 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
CommErr error = CommErr.Write;
UInt16 newCalibFactor = 2600; /// Default value
///
/// Parse calibration factor (1 argument) or calibration factor limits (2 arguments)
UInt16 newCalibFactor = 0;
if (multiTestParams[currentActivityStep].Activity.Length > WriteCalibrationFactorStr.Length)
{
{
UInt16 factorLimitLo;
UInt16 factorLimitHi;
UInt16 val;
string calibFactrorStr = multiTestParams[currentActivityStep].Activity.Substring(WriteCalibrationFactorStr.Length + 1);
UInt16 val;
if (UInt16.TryParse(calibFactrorStr, out val) && val > 0)
{
newCalibFactor = val; /// Update with specified value
}
}
else
{
/// Write the calculated calibration factor
newCalibFactor = wm.CalculateNewCalibFactor(wm.CalibrationFactor);
}
string[] arguments = calibFactrorStr.Split(new char[] { ' ' });
if (arguments.Length >= 2 &&
UInt16.TryParse(arguments[0], out factorLimitLo) && factorLimitLo > 0 &&
UInt16.TryParse(arguments[1], out factorLimitHi) && factorLimitHi > 0)
{
newCalibFactor = wm.CalculateNewCalibFactor(wm.CalibrationFactor, factorLimitLo, factorLimitHi);
}
else if (arguments.Length == 1 && UInt16.TryParse(arguments[0], out val) && val > 0)
{
newCalibFactor = val; /// Update with specified value
}
else
{
newCalibFactor = 2710; /// Default calibration factor for DN15
}
}
else
{
newCalibFactor = wm.CalculateNewCalibFactor(wm.CalibrationFactor, 2400, 2700); /// Default factor limits for DN15
}
byte[] data = new byte[2] { (byte)(newCalibFactor & 0x00FF), (byte)((newCalibFactor >> 8) & 0x00FF) };
for (int j = 0; j < cfg.MaxCommRetries; j++)

View File

@ -113,7 +113,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
/// </summary>
/// <param name="originalCalibrationFactor">Original calibration factor</param>
/// <returns>New calibration factor</returns>
public UInt16 CalculateNewCalibFactor(UInt16 originalCalibrationFactor)
public UInt16 CalculateNewCalibFactor(UInt16 originalCalibrationFactor, UInt16 FactorLimitLo, UInt16 FactorLimitHi)
{
double volumeMeter = Math.Abs(VolumeLtrEnd - VolumeLtrStart);
if (volumeMeter > 1E-2)
@ -124,8 +124,8 @@ namespace TBF.BenchControl.WaterMeters.iPerl
VolumeLtrStart.ToString("F3"), VolumeLtrEnd.ToString("F3"), volumeMeter.ToString("F3"),
VolumeLtrRef.ToString("F3"));
if (newFactor < iPerlCfg.CalibrationMin) newFactor = iPerlCfg.CalibrationMin;
if (newFactor > iPerlCfg.CalibrationMax) newFactor = iPerlCfg.CalibrationMax;
if (newFactor < FactorLimitLo) newFactor = FactorLimitLo;
if (newFactor > FactorLimitHi) newFactor = FactorLimitHi;
return newFactor;
}

View File

@ -20,8 +20,6 @@ namespace TBF.BenchControl.WaterMeters.iPerl
/// Serialized parameters
///
public MeterType MeterType;
public UInt16 CalibrationMin;
public UInt16 CalibrationMax;
public int OptoComPortNr;
public int MuxBoardNr; /// Multiplexer board number 1 .. 4
public int Group; /// Number written to QuidoRS to connct the watermeter to RfidComPort
@ -43,8 +41,6 @@ namespace TBF.BenchControl.WaterMeters.iPerl
Name = "iPerl";
ParentName = string.Empty;
OptoComPortNr = 10;
CalibrationMin = 2400;
CalibrationMax = 2700;
ProcParams = new ProcParams();
}
@ -56,11 +52,9 @@ namespace TBF.BenchControl.WaterMeters.iPerl
public string ToString(int i)
{
return string.Format("Name={0}, Type={1}, CalibMin={2}, CalibMax={3}, Opto=COM{4}, MuxBoard#={5}, Group={6}",
return string.Format("Name={0}, Type={1}, Opto=COM{4}, MuxBoard#={5}, Group={6}",
Name,
MeterType,
CalibrationMin,
CalibrationMax,
OptoComPortNr,
MuxBoardNr,
Group);

View File

@ -49,8 +49,6 @@ namespace TBF.BenchControl.WaterMeters.iPerl
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
meterTypeComboBox.Text = config.MeterType.ToString();
calibFactorMinTextBox.Text = config.CalibrationMin.ToString();
calibFactorMaxTextBox.Text = config.CalibrationMax.ToString();
optoPortNrTextBox.Text = config.OptoComPortNr.ToString();
muxBoardNrTextBox.Text = config.MuxBoardNr.ToString();
groupTextBox.Text = config.Group.ToString();
@ -60,8 +58,6 @@ namespace TBF.BenchControl.WaterMeters.iPerl
{
nameTextBox.Enabled = true;
meterTypeComboBox.Enabled = true;
calibFactorMinTextBox.Enabled = true;
calibFactorMaxTextBox.Enabled = true;
optoPortNrTextBox.Enabled = true;
muxBoardNrTextBox.Enabled = true;
groupTextBox.Enabled = true;
@ -77,18 +73,6 @@ namespace TBF.BenchControl.WaterMeters.iPerl
message += Environment.NewLine + "Meter type is not valid";
}
UInt16 calibFactor;
if (!UInt16.TryParse(calibFactorMinTextBox.Text, out calibFactor) || calibFactor < 1 || calibFactor > 5000)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Calib. factor limit low' is not valid";
}
if (!UInt16.TryParse(calibFactorMaxTextBox.Text, out calibFactor) || calibFactor < 1 || calibFactor > 5000)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Calib. factor limit high' is not valid";
}
int dummy;
if (!int.TryParse(optoPortNrTextBox.Text, out dummy) || dummy < 1 || dummy > 999)
{
@ -117,8 +101,6 @@ namespace TBF.BenchControl.WaterMeters.iPerl
config.Name = nameTextBox.Text;
config.MeterType = (MeterType)meterTypeComboBox.SelectedIndex;
config.CalibrationMin = UInt16.Parse(calibFactorMinTextBox.Text);
config.CalibrationMax = UInt16.Parse(calibFactorMaxTextBox.Text);
config.OptoComPortNr = int.Parse(optoPortNrTextBox.Text);
config.MuxBoardNr = int.Parse(muxBoardNrTextBox.Text);
config.Group = int.Parse(groupTextBox.Text);

View File

@ -43,16 +43,12 @@ namespace TBF.BenchControl.WaterMeters.iPerl
this.groupLabel = new System.Windows.Forms.Label();
this.meterTypeLabel = new System.Windows.Forms.Label();
this.meterTypeComboBox = new System.Windows.Forms.ComboBox();
this.calibFactorMinTextBox = new System.Windows.Forms.TextBox();
this.calibFactorMinLabel = new System.Windows.Forms.Label();
this.calibFactorMaxTextBox = new System.Windows.Forms.TextBox();
this.calibFactorMaxLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(135, 36);
this.nameTextBox.Location = new System.Drawing.Point(135, 39);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(121, 20);
this.nameTextBox.TabIndex = 2;
@ -60,7 +56,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(25, 39);
this.nameLabel.Location = new System.Drawing.Point(25, 42);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
@ -69,7 +65,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(132, 15);
this.classNameLabel.Location = new System.Drawing.Point(132, 18);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(60, 13);
this.classNameLabel.TabIndex = 0;
@ -78,7 +74,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
// optoPortNrTextBox
//
this.optoPortNrTextBox.Enabled = false;
this.optoPortNrTextBox.Location = new System.Drawing.Point(135, 125);
this.optoPortNrTextBox.Location = new System.Drawing.Point(135, 84);
this.optoPortNrTextBox.Name = "optoPortNrTextBox";
this.optoPortNrTextBox.Size = new System.Drawing.Size(34, 20);
this.optoPortNrTextBox.TabIndex = 10;
@ -86,7 +82,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
// optoPortNrLabel
//
this.optoPortNrLabel.AutoSize = true;
this.optoPortNrLabel.Location = new System.Drawing.Point(25, 128);
this.optoPortNrLabel.Location = new System.Drawing.Point(25, 87);
this.optoPortNrLabel.Name = "optoPortNrLabel";
this.optoPortNrLabel.Size = new System.Drawing.Size(96, 13);
this.optoPortNrLabel.TabIndex = 9;
@ -95,7 +91,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
// muxBoardNrTextBox
//
this.muxBoardNrTextBox.Enabled = false;
this.muxBoardNrTextBox.Location = new System.Drawing.Point(135, 147);
this.muxBoardNrTextBox.Location = new System.Drawing.Point(135, 106);
this.muxBoardNrTextBox.Name = "muxBoardNrTextBox";
this.muxBoardNrTextBox.Size = new System.Drawing.Size(34, 20);
this.muxBoardNrTextBox.TabIndex = 12;
@ -103,7 +99,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
// muxBoardNrLabel
//
this.muxBoardNrLabel.AutoSize = true;
this.muxBoardNrLabel.Location = new System.Drawing.Point(25, 150);
this.muxBoardNrLabel.Location = new System.Drawing.Point(25, 109);
this.muxBoardNrLabel.Name = "muxBoardNrLabel";
this.muxBoardNrLabel.Size = new System.Drawing.Size(78, 13);
this.muxBoardNrLabel.TabIndex = 11;
@ -112,7 +108,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
// groupTextBox
//
this.groupTextBox.Enabled = false;
this.groupTextBox.Location = new System.Drawing.Point(135, 169);
this.groupTextBox.Location = new System.Drawing.Point(135, 128);
this.groupTextBox.Name = "groupTextBox";
this.groupTextBox.Size = new System.Drawing.Size(34, 20);
this.groupTextBox.TabIndex = 14;
@ -120,7 +116,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
// groupLabel
//
this.groupLabel.AutoSize = true;
this.groupLabel.Location = new System.Drawing.Point(25, 172);
this.groupLabel.Location = new System.Drawing.Point(25, 131);
this.groupLabel.Name = "groupLabel";
this.groupLabel.Size = new System.Drawing.Size(39, 13);
this.groupLabel.TabIndex = 13;
@ -129,7 +125,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
// meterTypeLabel
//
this.meterTypeLabel.AutoSize = true;
this.meterTypeLabel.Location = new System.Drawing.Point(25, 61);
this.meterTypeLabel.Location = new System.Drawing.Point(25, 64);
this.meterTypeLabel.Name = "meterTypeLabel";
this.meterTypeLabel.Size = new System.Drawing.Size(57, 13);
this.meterTypeLabel.TabIndex = 3;
@ -139,53 +135,15 @@ namespace TBF.BenchControl.WaterMeters.iPerl
//
this.meterTypeComboBox.Enabled = false;
this.meterTypeComboBox.FormattingEnabled = true;
this.meterTypeComboBox.Location = new System.Drawing.Point(135, 58);
this.meterTypeComboBox.Location = new System.Drawing.Point(135, 61);
this.meterTypeComboBox.Name = "meterTypeComboBox";
this.meterTypeComboBox.Size = new System.Drawing.Size(121, 21);
this.meterTypeComboBox.TabIndex = 4;
//
// calibFactorMinTextBox
//
this.calibFactorMinTextBox.Enabled = false;
this.calibFactorMinTextBox.Location = new System.Drawing.Point(135, 81);
this.calibFactorMinTextBox.Name = "calibFactorMinTextBox";
this.calibFactorMinTextBox.Size = new System.Drawing.Size(57, 20);
this.calibFactorMinTextBox.TabIndex = 6;
//
// calibFactorMinLabel
//
this.calibFactorMinLabel.AutoSize = true;
this.calibFactorMinLabel.Location = new System.Drawing.Point(25, 84);
this.calibFactorMinLabel.Name = "calibFactorMinLabel";
this.calibFactorMinLabel.Size = new System.Drawing.Size(105, 13);
this.calibFactorMinLabel.TabIndex = 5;
this.calibFactorMinLabel.Text = "Calib. factor limit low:";
//
// calibFactorMaxTextBox
//
this.calibFactorMaxTextBox.Enabled = false;
this.calibFactorMaxTextBox.Location = new System.Drawing.Point(135, 103);
this.calibFactorMaxTextBox.Name = "calibFactorMaxTextBox";
this.calibFactorMaxTextBox.Size = new System.Drawing.Size(57, 20);
this.calibFactorMaxTextBox.TabIndex = 8;
//
// calibFactorMaxLabel
//
this.calibFactorMaxLabel.AutoSize = true;
this.calibFactorMaxLabel.Location = new System.Drawing.Point(25, 106);
this.calibFactorMaxLabel.Name = "calibFactorMaxLabel";
this.calibFactorMaxLabel.Size = new System.Drawing.Size(109, 13);
this.calibFactorMaxLabel.TabIndex = 7;
this.calibFactorMaxLabel.Text = "Calib. factor limit high:";
//
// WaterMeterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.calibFactorMaxTextBox);
this.Controls.Add(this.calibFactorMaxLabel);
this.Controls.Add(this.calibFactorMinTextBox);
this.Controls.Add(this.calibFactorMinLabel);
this.Controls.Add(this.meterTypeComboBox);
this.Controls.Add(this.meterTypeLabel);
this.Controls.Add(this.groupTextBox);
@ -217,10 +175,6 @@ namespace TBF.BenchControl.WaterMeters.iPerl
private System.Windows.Forms.TextBox groupTextBox;
private System.Windows.Forms.Label groupLabel;
private System.Windows.Forms.Label meterTypeLabel;
private System.Windows.Forms.ComboBox meterTypeComboBox;
private System.Windows.Forms.TextBox calibFactorMinTextBox;
private System.Windows.Forms.Label calibFactorMinLabel;
private System.Windows.Forms.TextBox calibFactorMaxTextBox;
private System.Windows.Forms.Label calibFactorMaxLabel;
private System.Windows.Forms.ComboBox meterTypeComboBox;
}
}

View File

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.5.130.1")]
[assembly: AssemblyFileVersion("1.5.130.1")]
[assembly: AssemblyVersion("1.5.131.1")]
[assembly: AssemblyFileVersion("1.5.131.1")]