diff --git a/Results/Entities/WaterMeter.cs b/Results/Entities/WaterMeter.cs
index aacb422fc..f5cae7c8c 100644
--- a/Results/Entities/WaterMeter.cs
+++ b/Results/Entities/WaterMeter.cs
@@ -63,6 +63,19 @@ namespace Results.Entities
#if IPERL
public virtual double OrigCalibFactor { get; set; } /// Original iPerl calibration factor used during the test
public virtual double CalibFactor { get; set; } /// iPerl calibration factor used during the test
+ public virtual double CalibFactorNominal { get; set; } /// Raw calibration factor representing 100 % for this test result
+ public virtual double CalibFactorPercentage
+ {
+ get
+ {
+ double nominalCalibFactor = CalibFactorNominal > 0.0 ? CalibFactorNominal : 4096.0;
+ return CalibFactor * 100.0 / nominalCalibFactor;
+ }
+ }
+ public virtual double CalibFactorCorrectionPercentage
+ {
+ get { return CalibFactorPercentage - 100.0; }
+ }
public virtual double OrigCalibFactorLNA{ get; set; } /// Original iPerl LNA calibration factor used during the test
public virtual double CalibFactorLNA { get; set; } /// iPerl LNA calibration factor used during the test
public virtual double Q2ErrWOCorrection { get; set; }
@@ -519,6 +532,7 @@ namespace Results.Entities
#if IPERL
OrigCalibFactor = src.OrigCalibFactor;
CalibFactor = src.CalibFactor;
+ CalibFactorNominal = src.CalibFactorNominal;
OrigCalibFactorLNA = src.OrigCalibFactorLNA;
CalibFactorLNA = src.CalibFactorLNA;
Q2ErrWOCorrection = src.Q2ErrWOCorrection;
diff --git a/Results/Entities/helpers/DatabaseMigrationHelper.cs b/Results/Entities/helpers/DatabaseMigrationHelper.cs
index 655eeb1b7..1b85685f7 100644
--- a/Results/Entities/helpers/DatabaseMigrationHelper.cs
+++ b/Results/Entities/helpers/DatabaseMigrationHelper.cs
@@ -43,6 +43,42 @@ namespace Results.Entities.helpers
EnsureColumnMySql(conn, "TestRslt", "ConductMax", "FLOAT NOT NULL DEFAULT 0");
EnsureColumnMySql(conn, "MeterTestRslt", "FlipMode", "INT NULL");
+ EnsureColumnMySql(conn, "WaterMeter", "CalibFactorNominal", "DOUBLE NOT NULL DEFAULT 4096");
+ // Nepouzitelne pre teraz - nechavam kod pre buducnost
+ //EnsureColumnMySql(conn, "MeterTestRslt", "CalibFactor", "FLOAT NOT NULL DEFAULT 0");
+ //EnsureColumnTypeMySql(conn, "MeterTestRslt", "CalibFactor", "float", "FLOAT NOT NULL DEFAULT 0");
+ }
+ }
+
+ private static void EnsureColumnTypeMySql(
+ MySqlConnection conn,
+ string tableName,
+ string columnName,
+ string expectedDataType,
+ string columnDefinition)
+ {
+ using (var cmd = conn.CreateCommand())
+ {
+ cmd.CommandText = @"
+ SELECT DATA_TYPE
+ FROM INFORMATION_SCHEMA.COLUMNS
+ WHERE TABLE_SCHEMA = DATABASE()
+ AND TABLE_NAME = @tableName
+ AND COLUMN_NAME = @columnName";
+
+ cmd.Parameters.AddWithValue("@tableName", tableName);
+ cmd.Parameters.AddWithValue("@columnName", columnName);
+
+ string currentDataType = cmd.ExecuteScalar() as string;
+ if (string.Equals(currentDataType, expectedDataType, StringComparison.OrdinalIgnoreCase))
+ return;
+ }
+
+ using (var alter = conn.CreateCommand())
+ {
+ alter.CommandText = "ALTER TABLE `" + tableName + "` MODIFY COLUMN `" +
+ columnName + "` " + columnDefinition;
+ alter.ExecuteNonQuery();
}
}
@@ -107,6 +143,7 @@ namespace Results.Entities.helpers
// EnsureColumnSQLite(conn, "MeterTestRslt", "Q3Channel", "INTEGER NOT NULL DEFAULT 0");
EnsureColumnSQLite(conn, "MeterTestRslt", "FlipMode", "INTEGER NULL");
+ EnsureColumnSQLite(conn, "WaterMeter", "CalibFactorNominal", "REAL NOT NULL DEFAULT 4096");
}
}
diff --git a/Results/ItemID.cs b/Results/ItemID.cs
index 62840ffad..87df542f3 100644
--- a/Results/ItemID.cs
+++ b/Results/ItemID.cs
@@ -362,6 +362,8 @@ namespace Results
Pulses_per_unit, /// 306
FlipMode, /// 307 iPerl mode used for this meter test result
+ CalibFactorPercentage, /// 308 iPerl calibration factor represented as a percentage
+ CalibFactorCorrectionPercentage,/// 309 iPerl calibration correction represented as a percentage
Count,
}
}
diff --git a/Results/Mappings/WaterMeterMap.cs b/Results/Mappings/WaterMeterMap.cs
index d95887032..f6719ada9 100644
--- a/Results/Mappings/WaterMeterMap.cs
+++ b/Results/Mappings/WaterMeterMap.cs
@@ -32,6 +32,7 @@ namespace Results.Mappings
#if IPERL
Map(x => x.OrigCalibFactor);
Map(x => x.CalibFactor);
+ Map(x => x.CalibFactorNominal);
Map(x => x.OrigCalibFactorLNA);
Map(x => x.CalibFactorLNA);
Map(x => x.Q2ErrWOCorrection);
diff --git a/Results/WMeterRsltItemSpec.cs b/Results/WMeterRsltItemSpec.cs
index 5086829c9..c6f2a99f5 100644
--- a/Results/WMeterRsltItemSpec.cs
+++ b/Results/WMeterRsltItemSpec.cs
@@ -457,6 +457,8 @@ namespace Results
#if IPERL
AllItems.Add(new WMeterRsltItemSpec(ItemID.OrigCalibFactor, "iPerl OrigCalibFactor", Quantity.Number, ItemCategory.MeterResult, (w,t,u,f,p) => FormatDbl(u, f, p, "V3", w.OrigCalibFactor)));
AllItems.Add(new WMeterRsltItemSpec(ItemID.CalibFactor, "iPerl CalibFactor", Quantity.Number, ItemCategory.MeterResult, (w,t,u,f,p) => FormatDbl(u, f, p, "V3", w.CalibFactor)));
+ AllItems.Add(new WMeterRsltItemSpec(ItemID.CalibFactorPercentage, "iPerl CalibFactor (%)", Quantity.Number, ItemCategory.MeterResult, (w,t,u,f,p) => FormatDbl(u, f, p, "F4", w.CalibFactorPercentage)));
+ AllItems.Add(new WMeterRsltItemSpec(ItemID.CalibFactorCorrectionPercentage, "iPerl Calibration correction (%)", Quantity.Number, ItemCategory.MeterResult, (w,t,u,f,p) => FormatDbl(u, f, p, "F4", w.CalibFactorCorrectionPercentage)));
AllItems.Add(new WMeterRsltItemSpec(ItemID.OrigCalibFactorLNA,"iPerl OrigCalibFactorLNA",Quantity.Number, ItemCategory.MeterResult, (w,t,u,f,p) => FormatDbl(u, f, p, "V3", w.OrigCalibFactorLNA)));
AllItems.Add(new WMeterRsltItemSpec(ItemID.CalibFactorLNA, "iPerl CalibFactorLNA", Quantity.Number, ItemCategory.MeterResult, (w,t,u,f,p) => FormatDbl(u, f, p, "V3", w.CalibFactorLNA)));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Q2ErrWOCorrection, "iPerl Q2ErrWOCorrection", Quantity.Error, ItemCategory.MeterResult, (w,t,u,f,p) => FormatDbl(u, f, p, "V3", w.Q2ErrWOCorrection)));
diff --git a/TBF/Resources/Strings.cs.resx b/TBF/Resources/Strings.cs.resx
index 384fd755d..7484fdbaa 100644
--- a/TBF/Resources/Strings.cs.resx
+++ b/TBF/Resources/Strings.cs.resx
@@ -1770,4 +1770,10 @@
Načítání
Simulace
Nenačteno
+
+ Výchozí kalibrační faktor:
+
+
+ Nominální surový kalibrační faktor odpovídající 100 %. Tato hodnota se používá pro výpočet položky „iPerl CalibFactor (%)“ v konfiguraci výsledků.
+
diff --git a/TBF/Resources/Strings.de.resx b/TBF/Resources/Strings.de.resx
index 4036991fb..5d5c1890b 100644
--- a/TBF/Resources/Strings.de.resx
+++ b/TBF/Resources/Strings.de.resx
@@ -2232,4 +2232,10 @@
Laden
Simuliert
Nicht geladen
+
+ Standard-Kalibrierfaktor:
+
+
+ Roher Kalibrierfaktor, der 100 % entspricht. Dieser Wert wird zur Berechnung von „iPerl CalibFactor (%)“ in der Ergebnis-Konfiguration verwendet.
+
diff --git a/TBF/Resources/Strings.es.resx b/TBF/Resources/Strings.es.resx
index 550138cfa..fab0ac8b5 100644
--- a/TBF/Resources/Strings.es.resx
+++ b/TBF/Resources/Strings.es.resx
@@ -141,4 +141,10 @@
Cargando
Simulado
No cargado
+
+ Factor de calibración predeterminado:
+
+
+ Factor de calibración bruto que representa el 100 %. Este valor se utiliza para calcular «iPerl CalibFactor (%)» en la configuración de resultados.
+
diff --git a/TBF/Resources/Strings.fr.resx b/TBF/Resources/Strings.fr.resx
index f02bb973b..97633022e 100644
--- a/TBF/Resources/Strings.fr.resx
+++ b/TBF/Resources/Strings.fr.resx
@@ -2031,4 +2031,10 @@
Chargement
Simulé
Non chargé
+
+ Facteur d’étalonnage par défaut :
+
+
+ Facteur d’étalonnage brut représentant 100 %. Cette valeur est utilisée pour calculer « iPerl CalibFactor (%) » dans la configuration des résultats.
+
diff --git a/TBF/Resources/Strings.it.resx b/TBF/Resources/Strings.it.resx
index 63af18898..55b70a5bf 100644
--- a/TBF/Resources/Strings.it.resx
+++ b/TBF/Resources/Strings.it.resx
@@ -1803,4 +1803,10 @@
Caricamento
Simulato
Non caricato
+
+ Fattore di calibrazione predefinito:
+
+
+ Fattore di calibrazione grezzo corrispondente al 100 %. Questo valore viene usato per calcolare «iPerl CalibFactor (%)» nella configurazione dei risultati.
+
diff --git a/TBF/Resources/Strings.pl.resx b/TBF/Resources/Strings.pl.resx
index 6bc23debc..d178a6e98 100644
--- a/TBF/Resources/Strings.pl.resx
+++ b/TBF/Resources/Strings.pl.resx
@@ -1707,4 +1707,10 @@
Ładowanie
Symulacja
Nie wczytano
+
+ Domyślny współczynnik kalibracji:
+
+
+ Surowy współczynnik kalibracji odpowiadający 100 %. Ta wartość służy do obliczania „iPerl CalibFactor (%)” w konfiguracji wyników.
+
diff --git a/TBF/Resources/Strings.resx b/TBF/Resources/Strings.resx
index fffff6ce9..00390d4d5 100644
--- a/TBF/Resources/Strings.resx
+++ b/TBF/Resources/Strings.resx
@@ -2503,4 +2503,10 @@
Not loaded
+
+ Default calibration factor:
+
+
+ Raw calibration factor representing 100 %. This value is used to calculate 'iPerl CalibFactor (%)' in the results configuration.
+
diff --git a/TBF/Resources/Strings.ro.resx b/TBF/Resources/Strings.ro.resx
index d8e9c562d..a8a49ca68 100644
--- a/TBF/Resources/Strings.ro.resx
+++ b/TBF/Resources/Strings.ro.resx
@@ -855,4 +855,10 @@
Se încarcă
Simulat
Neîncărcat
+
+ Factor de calibrare implicit:
+
+
+ Factorul brut de calibrare care reprezintă 100 %. Această valoare este utilizată pentru calculul „iPerl CalibFactor (%)” în configurarea rezultatelor.
+
diff --git a/TBF/Resources/Strings.ru.resx b/TBF/Resources/Strings.ru.resx
index f113dfafd..219dc2cea 100644
--- a/TBF/Resources/Strings.ru.resx
+++ b/TBF/Resources/Strings.ru.resx
@@ -1620,4 +1620,10 @@
Загрузка
Симуляция
Не загружено
+
+ Номинальный коэффициент калибровки:
+
+
+ Необработанный коэффициент калибровки, соответствующий 100 %. Это значение используется для вычисления «iPerl CalibFactor (%)» в конфигурации результатов.
+
diff --git a/TBF/Resources/Strings.sk.resx b/TBF/Resources/Strings.sk.resx
index e298a08d7..3050ff8c6 100644
--- a/TBF/Resources/Strings.sk.resx
+++ b/TBF/Resources/Strings.sk.resx
@@ -268,4 +268,10 @@
Načítavanie
Simulácia
Nenačítané
+
+ Predvolený kalibračný faktor:
+
+
+ Nominálny surový kalibračný faktor zodpovedajúci 100 %. Táto hodnota sa používa na výpočet položky „iPerl CalibFactor (%)“ v konfigurácii výsledkov.
+
diff --git a/TBF/Resources/Strings.zh-CN.resx b/TBF/Resources/Strings.zh-CN.resx
index 96903027d..8b8237585 100644
--- a/TBF/Resources/Strings.zh-CN.resx
+++ b/TBF/Resources/Strings.zh-CN.resx
@@ -1209,4 +1209,10 @@
正在加载
模拟
未加载
+
+ 默认校准系数:
+
+
+ 表示 100% 的原始校准系数。该值用于在结果配置中计算“iPerl CalibFactor (%)”。
+
diff --git a/TBF/Rig/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs b/TBF/Rig/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs
index 6655064f3..91ff5bfbc 100644
--- a/TBF/Rig/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs
+++ b/TBF/Rig/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs
@@ -1179,6 +1179,7 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollection
}
#if IPERL
meterRslt.WaterMeter.CalibFactor = iPerl.CalibFactor;
+ meterRslt.WaterMeter.CalibFactorNominal = iPerl.CalibFactorNominal;
meterRslt.FlipMode = iPerl.ConfigStruct != null && iPerl.ConfigStruct.FlipMode.HasValue
? (int?)iPerl.ConfigStruct.FlipMode.Value
: null;
diff --git a/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHead.cs b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHead.cs
index c45844914..4844261b0 100644
--- a/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHead.cs
+++ b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHead.cs
@@ -48,6 +48,8 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
public const int EndOptoDataCount = OptoDataBufferSize - StartOptoDataCount;
public const int StartEndFilterSamplesCount2 = 1; //20 /// StartEndFilterSamplesCount = 2 * StartEndFilterSamplesCount2 + 1
public const int FeatureVectorSize = 9;
+ /// Default raw ViewCalibration value which represents 100 % according to the iPerl ASIC protocol.
+ public const double DefaultCalibFactorNominal = 4096.0;
private const int StartSampleDelaySec = 5;
private const int EndSampleDelayCount = 2;
@@ -94,6 +96,15 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
public string QuantityUnits { get; set; }
public double CalibTarget { get { return iperlHeadCfg.ProcParams.CalibTarget; } }
+ public double CalibFactorNominal
+ {
+ get
+ {
+ return iperlHeadCfg != null && iperlHeadCfg.CalibFactorNominal > 0.0
+ ? iperlHeadCfg.CalibFactorNominal
+ : DefaultCalibFactorNominal;
+ }
+ }
public ushort FactorLimitLo { get { return (ushort)iperlHeadCfg.ProcParams.FactorLimitLo; } }
public ushort FactorLimitHi { get { return (ushort)iperlHeadCfg.ProcParams.FactorLimitHi; } }
public Counting InitFlowDir { get { return (iperlHeadCfg != null && iperlHeadCfg.ProcParams != null) ? iperlHeadCfg.ProcParams.Counting : Counting.Arbitrary; } }
@@ -157,6 +168,27 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
}
}
+ /// Converts the raw two-byte ViewCalibration factor to its percentage representation.
+ public static double CalculateCalibFactorPercentage(ushort rawCalibFactor)
+ {
+ return CalculateCalibFactorPercentage(rawCalibFactor, DefaultCalibFactorNominal);
+ }
+
+ public static double CalculateCalibFactorPercentage(ushort rawCalibFactor, double nominalCalibFactor)
+ {
+ return nominalCalibFactor > 0.0 ? rawCalibFactor * 100.0 / nominalCalibFactor : 0.0;
+ }
+
+ public double CalibFactorPercentage
+ {
+ get { return CalculateCalibFactorPercentage(CalibFactor, CalibFactorNominal); }
+ }
+
+ public double CalibFactorCorrectionPercentage
+ {
+ get { return CalibFactorPercentage - 100.0; }
+ }
+
public ushort OrigCalibFactorLNA;
public ushort CalibFactorLNA { get { return (CalibrationStructV4 != null) ? CalibrationStructV4.CalibrationLNA : (ushort)0; } }
diff --git a/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadCfg.cs b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadCfg.cs
index 1cea9fee0..ac3508818 100644
--- a/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadCfg.cs
+++ b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadCfg.cs
@@ -27,6 +27,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
public int MuxBoardNr; /// 0 = use RfidComPort(Nr), otherwise mux. board nr. 1 .. 4
public int Group; /// Number written to QuidoRS to connct the watermeter to RfidComPort, 1 .. 10
public CommunicationInterface CommunicationInterface; /// Communication Interface: RFID or NFC
+ public double CalibFactorNominal; /// Raw calibration factor representing 100 % in the results calculation
/// Procedure parameters
[XmlIgnore]
@@ -49,6 +50,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
ProcParams = CreateProcParamsProvider() as ProcParams;
CommunicationInterface = CommunicationInterface.RFID;
HeadCommunicationComPortNr = 0;
+ CalibFactorNominal = IperlHead.DefaultCalibFactorNominal;
}
public IperlHeadCfg(IComponentFactory factory)
diff --git a/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadCfgCtrl.cs b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadCfgCtrl.cs
index 20992b2a6..9f1be0a88 100644
--- a/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadCfgCtrl.cs
+++ b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadCfgCtrl.cs
@@ -2,6 +2,7 @@
/// Copyright (c) 2015-2017 Sensus Metering Systems
///
using System;
+using System.Globalization;
using System.Net;
using System.Windows.Forms;
using Common;
@@ -33,6 +34,10 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
private void WaterMeterCfgCtrl_Load(object sender, EventArgs e)
{
nameLabel.Text = Strings.Name;
+ calibFactorNominalLabel.Text = GetLocalizedString("IperlCalibFactorNominal", "Default calibration factor:");
+ string calibFactorNominalTooltip = GetLocalizedString("IperlCalibFactorNominalTooltip", "Raw calibration factor representing 100 %. This value is used to calculate 'iPerl CalibFactor (%)' in the results configuration.");
+ calibFactorNominalToolTip.SetToolTip(calibFactorNominalLabel, calibFactorNominalTooltip);
+ calibFactorNominalToolTip.SetToolTip(calibFactorNominalTextBox, calibFactorNominalTooltip);
classNameLabel.Text = config.Factory.ClassName;
Redraw();
}
@@ -55,6 +60,10 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
muxBoardNrTextBox.Text = config.MuxBoardNr.ToString();
groupTextBox.Text = config.Group.ToString();
comboBoxCommunicationInterface.SelectedItem = config.CommunicationInterface.ToString();
+ double nominalCalibFactor = config.CalibFactorNominal > 0.0
+ ? config.CalibFactorNominal
+ : IperlHead.DefaultCalibFactorNominal;
+ calibFactorNominalTextBox.Text = nominalCalibFactor.ToString(CultureInfo.CurrentCulture);
tabPage2.Controls.Add(new IperlHeadTestCtrl(config));
}
@@ -71,6 +80,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
muxBoardNrTextBox.Enabled = true;
groupTextBox.Enabled = true;
comboBoxCommunicationInterface.Enabled = true;
+ calibFactorNominalTextBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
@@ -127,6 +137,13 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
message += Environment.NewLine + string.Format(Strings.Invalid_0, groupLabel.Text);
}
+ double nominalCalibFactor;
+ if (!TryParseDouble(calibFactorNominalTextBox.Text, out nominalCalibFactor) || nominalCalibFactor <= 0.0)
+ {
+ flags |= CfgUpdateFlags.Error;
+ message += Environment.NewLine + string.Format(Strings.Invalid_0, calibFactorNominalLabel.Text);
+ }
+
return flags;
}
@@ -155,8 +172,22 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
config.Group = int.Parse(groupTextBox.Text);
config.CommunicationInterface = (CommunicationInterface)comboBoxCommunicationInterface.SelectedIndex;
config.HeadCommunicationComPortNr = int.Parse(headPortNrTextBox.Text);
+ double nominalCalibFactor;
+ if (TryParseDouble(calibFactorNominalTextBox.Text, out nominalCalibFactor))
+ config.CalibFactorNominal = nominalCalibFactor;
return flags;
}
+
+ private static bool TryParseDouble(string value, out double result)
+ {
+ return double.TryParse(value, NumberStyles.Float, CultureInfo.CurrentCulture, out result) ||
+ double.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out result);
+ }
+
+ private static string GetLocalizedString(string resourceName, string fallback)
+ {
+ return Strings.ResourceManager.GetString(resourceName, Strings.Culture) ?? fallback;
+ }
}
}
diff --git a/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadCfgCtrl.designer.cs b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadCfgCtrl.designer.cs
index 7c8ab0de8..b5dbed4fa 100644
--- a/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadCfgCtrl.designer.cs
+++ b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadCfgCtrl.designer.cs
@@ -31,6 +31,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
///
private void InitializeComponent()
{
+ this.components = new System.ComponentModel.Container();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.label4 = new System.Windows.Forms.Label();
@@ -60,6 +61,9 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.label2 = new System.Windows.Forms.Label();
this.headPortNrTextBox = new System.Windows.Forms.TextBox();
+ this.calibFactorNominalLabel = new System.Windows.Forms.Label();
+ this.calibFactorNominalTextBox = new System.Windows.Forms.TextBox();
+ this.calibFactorNominalToolTip = new System.Windows.Forms.ToolTip(this.components);
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.groupBox1.SuspendLayout();
@@ -80,6 +84,8 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
// tabPage1
//
this.tabPage1.Controls.Add(this.groupBox2);
+ this.tabPage1.Controls.Add(this.calibFactorNominalTextBox);
+ this.tabPage1.Controls.Add(this.calibFactorNominalLabel);
this.tabPage1.Controls.Add(this.label4);
this.tabPage1.Controls.Add(this.label3);
this.tabPage1.Controls.Add(this.groupBox1);
@@ -364,6 +370,23 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
this.groupBox2.TabIndex = 26;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Head Communication";
+ //
+ // calibFactorNominalLabel
+ //
+ this.calibFactorNominalLabel.AutoSize = true;
+ this.calibFactorNominalLabel.Location = new System.Drawing.Point(290, 76);
+ this.calibFactorNominalLabel.Name = "calibFactorNominalLabel";
+ this.calibFactorNominalLabel.Size = new System.Drawing.Size(142, 16);
+ this.calibFactorNominalLabel.TabIndex = 27;
+ this.calibFactorNominalLabel.Text = "Default calibration factor:";
+ //
+ // calibFactorNominalTextBox
+ //
+ this.calibFactorNominalTextBox.Enabled = false;
+ this.calibFactorNominalTextBox.Location = new System.Drawing.Point(290, 96);
+ this.calibFactorNominalTextBox.Name = "calibFactorNominalTextBox";
+ this.calibFactorNominalTextBox.Size = new System.Drawing.Size(92, 22);
+ this.calibFactorNominalTextBox.TabIndex = 28;
//
// label2
//
@@ -437,5 +460,8 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.TextBox headPortNrTextBox;
private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.Label calibFactorNominalLabel;
+ private System.Windows.Forms.TextBox calibFactorNominalTextBox;
+ private System.Windows.Forms.ToolTip calibFactorNominalToolTip;
}
}
diff --git a/TBFTests/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadCalibrationTest.cs b/TBFTests/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadCalibrationTest.cs
new file mode 100644
index 000000000..f4eb7db3c
--- /dev/null
+++ b/TBFTests/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadCalibrationTest.cs
@@ -0,0 +1,50 @@
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Results.Entities;
+using TBF.Rig.TestMethods.iPerlCommunication.iPerlHead;
+
+namespace TBFTests.Rig.TestMethods.iPerlCommunication.iPerlHead
+{
+ [TestClass]
+ public class IperlHeadCalibrationTest
+ {
+ [TestMethod]
+ public void CalculateCalibFactorPercentage_UsesProtocolNominalFactor()
+ {
+ Assert.AreEqual(100.0,
+ IperlHead.CalculateCalibFactorPercentage(4096), 0.000000001);
+ Assert.AreEqual(93.310546875,
+ IperlHead.CalculateCalibFactorPercentage(3822), 0.000000001);
+ }
+
+ [TestMethod]
+ public void CalculateCalibFactorPercentage_UsesConfiguredNominalFactor()
+ {
+ Assert.AreEqual(76.44,
+ IperlHead.CalculateCalibFactorPercentage(3822, 5000.0), 0.000000001);
+ }
+
+ [TestMethod]
+ public void WaterMeterCalibFactorPercentage_UsesSavedNominalFactor()
+ {
+ var waterMeter = new WaterMeter
+ {
+ CalibFactor = 3822,
+ CalibFactorNominal = 5000.0
+ };
+
+ Assert.AreEqual(76.44, waterMeter.CalibFactorPercentage, 0.000000001);
+ }
+
+ [TestMethod]
+ public void WaterMeterCalibFactorCorrectionPercentage_IsPercentageMinusOneHundred()
+ {
+ var waterMeter = new WaterMeter
+ {
+ CalibFactor = 3822,
+ CalibFactorNominal = 4096.0
+ };
+
+ Assert.AreEqual(-6.689453125, waterMeter.CalibFactorCorrectionPercentage, 0.000000001);
+ }
+ }
+}
diff --git a/TBFTests/TBFTests.csproj b/TBFTests/TBFTests.csproj
index cbefac8ed..acad0b64e 100644
--- a/TBFTests/TBFTests.csproj
+++ b/TBFTests/TBFTests.csproj
@@ -155,6 +155,7 @@
+