diff --git a/Config/Entities/MeasurementCorrection.cs b/Config/Entities/MeasurementCorrection.cs
index f1aa3fe78..a652cd3cd 100644
--- a/Config/Entities/MeasurementCorrection.cs
+++ b/Config/Entities/MeasurementCorrection.cs
@@ -13,6 +13,7 @@ namespace Config.Entities
public virtual double Measurement { get; set; }
public virtual double Correction { get; set; }
public virtual double Uncertainty { get; set; }
+ public virtual double Readability { get; set; }
public MeasurementCorrection()
{
@@ -85,7 +86,7 @@ namespace Config.Entities
public override string ToString()
{
- return string.Format("{0} {1} ({2}) {3}", Measurement, Correction, RangeIx, Uncertainty);
+ return string.Format("{0} {1} ({2}) {3} {4}", Measurement, Correction, RangeIx, Uncertainty, Readability);
}
}
}
diff --git a/Config/Mappings/MeasurementCorrectionMap.cs b/Config/Mappings/MeasurementCorrectionMap.cs
index fed3b2c55..54ab52cde 100644
--- a/Config/Mappings/MeasurementCorrectionMap.cs
+++ b/Config/Mappings/MeasurementCorrectionMap.cs
@@ -15,6 +15,7 @@ namespace Config.Mappings
Map(x => x.Measurement);
Map(x => x.Correction);
Map(x => x.Uncertainty);
+ Map(x => x.Readability);
}
}
}
diff --git a/Results/Results.csproj b/Results/Results.csproj
index 13c24546b..5a956df96 100644
--- a/Results/Results.csproj
+++ b/Results/Results.csproj
@@ -239,11 +239,13 @@
+
+
diff --git a/Results/Uncertainty/CommonExcell.cs b/Results/Uncertainty/CommonExcell.cs
index 2462cd2d1..6eb0755a9 100644
--- a/Results/Uncertainty/CommonExcell.cs
+++ b/Results/Uncertainty/CommonExcell.cs
@@ -1,6 +1,10 @@
using System;
using System.Collections.Generic;
using ClosedXML.Excel;
+using Common;
+using Config.Entities;
+using log4net;
+using NHibernate;
using Results.Resources;
namespace Results.Uncertainty
@@ -17,6 +21,9 @@ namespace Results.Uncertainty
private static Dictionary bloks = null;
+ static readonly ILog log = LogManager.GetLogger(typeof(CommonExcell));
+
+ private static IList cmpntEntities;
public static Dictionary GetBolocs() {
if (bloks == null)
@@ -35,8 +42,13 @@ namespace Results.Uncertainty
return bloks;
}
-
+ ///
+ /// Inserts a line of process data into a specified row of the Excel document.
+ ///
+ /// An instance of the class representing the rig uncertainty and its associated data.
+ /// The row index in the Excel worksheet where the process data will be inserted.
+ /// An instance of the class containing the process data to be added to the row.
public static void InsertValueLineProcessData(RigUncertainty _rigUncertainty, int iRowI, ProcessDataLine processDataLine)
{
if (!_rigUncertainty.IsOpenedDocument)
@@ -157,6 +169,15 @@ namespace Results.Uncertainty
}
}
+ ///
+ /// Populates a range of cells in an Excel worksheet with meter process data starting from a specified column and row.
+ ///
+ /// The Excel worksheet where data will be inserted.
+ /// The starting column in the worksheet for inserting the meter process data.
+ /// The row index in the worksheet where the data will be inserted.
+ /// An instance of the class containing the meter process data to insert.
+ /// An optional parameter specifying the distance for additional columns to leave empty after data insertion. Defaults to 0.
+ /// The next available column string after the last column used during data insertion.
private static string MeterCellData(IXLWorksheet worksheet, string column, int iRowI, ProcessDataMeterLine data, int distance = 0)
{
int iIndex = 0;
@@ -197,39 +218,10 @@ namespace Results.Uncertainty
return nextColumn;
}
-
- /*private static string MeterCellDataOld(IXLWorksheet worksheet, string column, int iRowI, ProcessDataMeterLine data, int distance = 0)
- {
- CellData(worksheet, column, iRowI, data.SerNo , formatStr);//Position - Ser.No. - CE
- string nextColumn = NextColumn(column); CellData(worksheet,nextColumn, iRowI, data.VolMtSt , formatInt);//Vol.Mt.st - CF
- nextColumn = NextColumn(nextColumn); CellData(worksheet,nextColumn, iRowI, data.VolMtEn , formatInt);//Vol.Mt.en - CG
- nextColumn = NextColumn(nextColumn); CellData(worksheet,nextColumn, iRowI, data.VolMt , formatD7);//Vol.Mt. - CH
- nextColumn = NextColumn(nextColumn); CellData(worksheet,nextColumn, iRowI, data.VolRm, formatD7);//Vol.rm - CI
- nextColumn = NextColumn(nextColumn); CellData(worksheet,nextColumn, iRowI, data.ERel , formatD6); // E rel. - CJ
- nextColumn = NextColumn(nextColumn); CellData(worksheet,nextColumn, iRowI, data.IPerlCalibrationFactor , formatInt); // U - CK
- nextColumn = NextColumn(nextColumn); CellData(worksheet,nextColumn, iRowI, data.Pulses , formatInt); //Pulses() -
- nextColumn = NextColumn(nextColumn); CellData(worksheet,nextColumn, iRowI, data.RefPulsesNi , formatInt); //Ref pulses_ni()
- nextColumn = NextColumn(nextColumn); CellData(worksheet,nextColumn, iRowI, data.T , formatD4); //T(s)()_ni
- nextColumn = NextColumn(nextColumn); CellData(worksheet,nextColumn, iRowI, data.Evaluation , formatStr);//evaluation
- nextColumn = NextColumn(nextColumn); CellData(worksheet,nextColumn, iRowI, data.PulsesL , formatD4);//Pulses/l - CP
- nextColumn = NextColumn(nextColumn); CellData(worksheet,nextColumn, iRowI, data.ImpL , formatInt);//imp/l
- nextColumn = NextColumn(nextColumn); CellData(worksheet,nextColumn, iRowI, data.Div , formatInt);//div
- nextColumn = NextColumn(nextColumn); CellData(worksheet,nextColumn, iRowI, data.VEnd , formatInt);//Vend
- nextColumn = NextColumn(nextColumn); CellData(worksheet,nextColumn, iRowI, data.TEnd , formatInt);//T end
- if (distance > 0)
- {
- string lastColumn = CommonExcell.GetExcelColumnByDistance(column, distance);
- int columnDistance = CommonExcell.GetColumnDistance(nextColumn, lastColumn);
- for (int i = 1; i < columnDistance; i++)
- {
- nextColumn = NextColumn(nextColumn); CellData(worksheet,nextColumn, iRowI, 0 , formatInt);
- }
- }
-
- return nextColumn;
- }*/
+
+
public static void CellData(IXLWorksheet worksheet, string column, int iRowI, XLCellValue value, string format = null)
{
worksheet.Cell($"{column}{iRowI}").Value = value;
diff --git a/Results/Uncertainty/CommonTable/Cell.cs b/Results/Uncertainty/CommonTable/Cell.cs
new file mode 100644
index 000000000..cbe113160
--- /dev/null
+++ b/Results/Uncertainty/CommonTable/Cell.cs
@@ -0,0 +1,43 @@
+using ClosedXML.Excel;
+
+namespace Results.Uncertainty.CommonTable
+{
+ public class Cell
+ {
+ public int IRow { get; }
+ public int IColumn { get; }
+ public XLCellValue Value { get; set; }
+
+ // The names (if any) of the row/column
+ public string ColumnName { get; }
+ public string RowName { get; }
+
+ ///
+ /// Excel‐style address, e.g. “B3”.
+ ///
+ public string Address => $"{ToLetter(IColumn + 1)}{IRow + 1}";
+
+ public Cell(int col, int row, XLCellValue value,
+ string colName = null, string rowName = null)
+ {
+ IColumn = col;
+ IRow = row;
+ Value = value;
+ ColumnName = colName;
+ RowName = rowName;
+ }
+
+ // Convert 1-based column number into letters
+ private static string ToLetter(int col)
+ {
+ var s = "";
+ while (col > 0)
+ {
+ int m = (col - 1) % 26;
+ s = (char)('A' + m) + s;
+ col = (col - m - 1) / 26;
+ }
+ return s;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Results/Uncertainty/CommonTable/Table.cs b/Results/Uncertainty/CommonTable/Table.cs
new file mode 100644
index 000000000..2386d0660
--- /dev/null
+++ b/Results/Uncertainty/CommonTable/Table.cs
@@ -0,0 +1,232 @@
+using System.Collections.Generic;
+using ClosedXML.Excel;
+
+
+using System;
+using System.Collections.Generic;
+using ClosedXML.Excel;
+
+namespace Results.Uncertainty.CommonTable
+{
+ public class Table
+ {
+ private int iOffsetRows = 0;
+ private int iOffsetColumns = 0;
+
+ public int IOffsetRows
+ {
+ get => iOffsetRows;
+ set => iOffsetRows = value;
+ }
+
+ public int IOffsetColumns
+ {
+ get => iOffsetColumns;
+ set => iOffsetColumns = value;
+ }
+
+ // The grid of cells
+ public IList> Cells { get; private set; }
+ = new List>();
+
+ // Optional names for columns and rows
+ public IList ColumnNames { get; private set; }
+ = new List();
+ public IList RowNames { get; private set; }
+ = new List();
+
+ public Table() { }
+
+
+
+ public void AddColumnExcel(string nameStart, string nameEnd)
+ {
+ int distance = CommonExcell.GetColumnDistance(nameStart, nameEnd);
+ int iStart = CommonExcell.ColumnToNumber(nameStart);
+ AddColumn(nameStart);
+ for (int i = 0; i < distance; i++)
+ {
+ AddColumn(CommonExcell.GetExcelColumnByDistance(nameStart, i+1));
+ }
+ }
+
+ public void GenerateTable_RowsColumns_Excel(string nameStart, string nameEnd, int iRowsCount)
+ {
+ AddColumnExcel(nameStart, nameEnd);
+
+ for (int i = 0; i < iRowsCount; i++)
+ {
+ AddRow(i.ToString());
+ }
+ }
+
+ ///
+ /// Adds a new column (with optional name) and returns its index.
+ ///
+ public int AddColumn(string name = null)
+ {
+ int colIndex = ColumnNames.Count;
+ ColumnNames.Add(name);
+
+ // Grow every existing row by one
+ for (int r = 0; r < Cells.Count; r++)
+ {
+ Cells[r].Add(new Cell(colIndex, r, new XLCellValue(), name, RowNames[r]));
+ }
+
+ return colIndex;
+ }
+
+ ///
+ /// Adds a new row (with optional name) and returns its index.
+ ///
+ public int AddRow(string name = null)
+ {
+ int rowIndex = Cells.Count;
+ RowNames.Add(name);
+
+ var newRow = new List(ColumnNames.Count);
+ // Initialize with empty cells
+ for (int c = 0; c < ColumnNames.Count; c++)
+ {
+ newRow.Add(new Cell(c, rowIndex, new XLCellValue(), ColumnNames[c], name));
+ }
+
+ Cells.Add(newRow);
+ return rowIndex;
+ }
+
+ ///
+ /// Ensures the given [row,col] exists, creating rows/columns as needed.
+ ///
+ private void EnsurePosition(int rowIndex, int colIndex)
+ {
+ while (Cells.Count <= rowIndex)
+ AddRow();
+
+ var row = Cells[rowIndex];
+ while (row.Count <= colIndex)
+ AddColumn();
+ }
+
+ ///
+ /// Sets the value of the cell at [rowIndex, colIndex].
+ ///
+ public void AddCell(int rowIndex, int colIndex, XLCellValue value)
+ {
+ EnsurePosition(rowIndex, colIndex);
+ Cells[rowIndex][colIndex].Value = value;
+ }
+
+ ///
+ /// Sets the value of the cell at [rowIndex, columnName].
+ /// If the columnName doesn’t exist yet, it’s created.
+ ///
+ public void AddCell(int rowIndex, string columnName, XLCellValue value)
+ {
+ int colIndex = ColumnNames.IndexOf(columnName);
+ if (colIndex < 0)
+ colIndex = AddColumn(columnName);
+
+ AddCell(rowIndex, colIndex, value);
+ }
+
+ ///
+ /// Retrieves a cell by numeric coordinates.
+ ///
+ public Cell GetCell(int rowIndex, int colIndex)
+ => Cells[rowIndex][colIndex];
+
+ ///
+ /// Retrieves a cell by rowIndex and columnName.
+ ///
+ public Cell GetCell(int rowIndex, string columnName)
+ {
+ int colIndex = ColumnNames.IndexOf(columnName);
+ if (colIndex < 0)
+ throw new ArgumentException($"Column '{columnName}' not found.");
+ return GetCell(rowIndex, colIndex);
+ }
+
+ ///
+ /// Writes the entire table into the given worksheet,
+ /// optionally including the header row of column names.
+ ///
+ public void ToWorksheet(IXLWorksheet ws, bool includeHeaders = true)
+ {
+ int startRow = 1;
+ if (includeHeaders)
+ {
+ for (int c = 0; c < ColumnNames.Count; c++)
+ ws.Cell(1, c + 1).Value = ColumnNames[c] ?? string.Empty;
+ startRow = 2;
+ }
+
+ for (int r = 0; r < Cells.Count; r++)
+ {
+ for (int c = 0; c < Cells[r].Count; c++)
+ {
+ ws.Cell(r + startRow, c + 1).Value = Cells[r][c].Value;
+ }
+ }
+ }
+
+ ///
+ /// Writes the entire table into the given worksheet,
+ /// optionally including the header row of column names.
+ ///
+ public void ToWorksheetWithOffset(IXLWorksheet ws, int rowsOffset = 1, int columnsOffset = 0, bool includeHeaders = true)
+ {
+
+
+ int startRow = rowsOffset;
+ if (includeHeaders)
+ {
+ for (int c = 0; c < ColumnNames.Count; c++)
+ ws.Cell(1, c + 1).Value = ColumnNames[c] ?? string.Empty;
+ startRow = 2;
+ }
+
+ for (int r = 0; r < Cells.Count; r++)
+ {
+ for (int c = 0; c < Cells[r].Count; c++)
+ {
+ if(!(Cells[r][c].Value.IsBlank || Cells[r][c].Value.Type == XLDataType.Blank))
+ {
+ ws.Cell(r + startRow, c + 1 + columnsOffset).Value = Cells[r][c].Value;
+ }
+ }
+ }
+ }
+
+ ///
+ /// Returns all cells in the given row (by zero‐based index).
+ ///
+ public IList GetRow(int rowIndex)
+ {
+ if (rowIndex < 0 || rowIndex >= Cells.Count)
+ throw new IndexOutOfRangeException($"Row {rowIndex} does not exist.");
+ return Cells[rowIndex];
+ }
+
+ ///
+ /// Returns all cells in the given column (by zero‐based index).
+ ///
+ public IList GetColumn(int colIndex)
+ {
+ if (colIndex < 0 || colIndex >= ColumnNames.Count)
+ throw new IndexOutOfRangeException($"Column {colIndex} does not exist.");
+ var list = new List();
+ for (int r = 0; r < Cells.Count; r++)
+ {
+ // skip if that row hasn’t grown that far yet
+ if (Cells[r].Count > colIndex)
+ list.Add(Cells[r][colIndex]);
+ }
+ return list;
+ }
+
+ }
+
+
+}
diff --git a/TBF.sln.DotSettings.user b/TBF.sln.DotSettings.user
index bc944c2fb..6bcbfb805 100644
--- a/TBF.sln.DotSettings.user
+++ b/TBF.sln.DotSettings.user
@@ -1,9 +1,15 @@
ForceIncluded
ForceIncluded
+ ForceIncluded
+ ForceIncluded
ForceIncluded
ForceIncluded
+ ForceIncluded
+ ForceIncluded
ForceIncluded
+ ForceIncluded
+ ForceIncluded
ForceIncluded
<AssemblyExplorer>
<Assembly Path="C:\Users\micha\git\tbf\packages\FluentNHibernate.2.0.3.0\lib\net40\FluentNHibernate.dll" />
@@ -15,7 +21,7 @@
77EB589F-C670-4489-AAD6-2A3C02061FD1
77EB589F-C670-4489-AAD6-2A3C02061FD1
d6790ab7-33c2-4425-b2c9-51480cd1a852
- <SessionState ContinuousTestingMode="0" IsActive="True" Name="GetCorrection" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
+ <SessionState ContinuousTestingMode="0" Name="GetCorrection" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
<TestAncestor>
<TestId>MSTest::77EB589F-C670-4489-AAD6-2A3C02061FD1::.NETFramework,Version=v4.7.2::TBFTests.Entities.MeasurementCorrectionTest.GetCorrection</TestId>
<TestId>MSTest::77EB589F-C670-4489-AAD6-2A3C02061FD1::.NETFramework,Version=v4.7.2::TBFTests.Rig.Modbus.Meret.AdjustableScale.AdjustableMeterTest.GetCorrection</TestId>
@@ -25,10 +31,11 @@
<TestId>MSTest::77EB589F-C670-4489-AAD6-2A3C02061FD1::.NETFramework,Version=v4.7.2::TBFTests.Uncertainty.Calculation.MathTest.AritmeticMeanTest</TestId>
<TestId>MSTest::77EB589F-C670-4489-AAD6-2A3C02061FD1::.NETFramework,Version=v4.7.2::TBFTests.Uncertainty.Calculation.BatchProcessTableTest</TestId>
<TestId>MSTest::77EB589F-C670-4489-AAD6-2A3C02061FD1::.NETFramework,Version=v4.7.2::TBFTests.Uncertainty.Calculation.CalculationTableTest</TestId>
+ <TestId>MSTest::77EB589F-C670-4489-AAD6-2A3C02061FD1::.NETFramework,Version=v4.7.2::TBFTests.Uncertainty.CommonTable.TableTest.CrateTableTest</TestId>
</TestAncestor>
</SessionState>
- <SessionState ContinuousTestingMode="0" Name="Initialize" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
+ <SessionState ContinuousTestingMode="0" IsActive="True" Name="Initialize" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
<TestAncestor>
<TestId>MSTest::77EB589F-C670-4489-AAD6-2A3C02061FD1::.NETFramework,Version=v4.7.2::TBFTests.Rig.Network.Camera.KeyenceIV3G120.CameraTest.Initialize</TestId>
<TestId>MSTest::77EB589F-C670-4489-AAD6-2A3C02061FD1::.NETFramework,Version=v4.7.2::TBFTests.RigUncertaintyTest.OpenDocument_SuccessfullyOpensDocument_RaisesNoExceptions</TestId>
@@ -37,6 +44,8 @@
<TestId>MSTest::77EB589F-C670-4489-AAD6-2A3C02061FD1::.NETFramework,Version=v4.7.2::TBFTests.RigUncertaintyTest.ExcelColumnsTools</TestId>
<TestId>MSTest::77EB589F-C670-4489-AAD6-2A3C02061FD1::.NETFramework,Version=v4.7.2::TBFTests.RigUncertaintyTest</TestId>
<TestId>MSTest::77EB589F-C670-4489-AAD6-2A3C02061FD1::.NETFramework,Version=v4.7.2::TBFTests.Uncertainty.Calculation.MathTest</TestId>
+ <TestId>MSTest::77EB589F-C670-4489-AAD6-2A3C02061FD1::.NETFramework,Version=v4.7.2::TBFTests.Uncertainty.CommonTable.TableTest.CrateTableTest</TestId>
+ <TestId>MSTest::77EB589F-C670-4489-AAD6-2A3C02061FD1::.NETFramework,Version=v4.7.2::TBFTests.Uncertainty.CommonTable.TableTest.CrateTableOnPositionTest</TestId>
</TestAncestor>
</SessionState>
False
@@ -44,7 +53,7 @@
False
- False
+ True
False
False
False
@@ -58,8 +67,8 @@
True
False
- True
- False
+ False
+ True
False
False
False
diff --git a/TBF/ReadMe.md b/TBF/ReadMe.md
index 68b4bdd02..17b38ef2b 100644
--- a/TBF/ReadMe.md
+++ b/TBF/ReadMe.md
@@ -8,5 +8,7 @@ Document start on version `3.9.2144.1`
### v3.9.2144 Uncertainty
#### Database update
```
+use wrc2swindon298;
alter table measurementcorrection add Uncertainty float null;
+alter table measurementcorrection add Readability float null;
```
\ No newline at end of file
diff --git a/TBF/Resources/Strings.Designer.cs b/TBF/Resources/Strings.Designer.cs
index 2fb34f8b2..3dc8fe6a9 100644
--- a/TBF/Resources/Strings.Designer.cs
+++ b/TBF/Resources/Strings.Designer.cs
@@ -4622,6 +4622,15 @@ namespace TBF.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Readability.
+ ///
+ internal static string Readability {
+ get {
+ return ResourceManager.GetString("Readability", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Reading from the production tracing DB failed.
///
diff --git a/TBF/Resources/Strings.resx b/TBF/Resources/Strings.resx
index ecbc4fb1f..8edff7ff9 100644
--- a/TBF/Resources/Strings.resx
+++ b/TBF/Resources/Strings.resx
@@ -2050,6 +2050,9 @@
Uncertainty
+
+ Readability
+
No info available
diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj
index bca1dfdbc..ade422785 100644
--- a/TBF/TBF.csproj
+++ b/TBF/TBF.csproj
@@ -104,6 +104,21 @@
..\packages\Castle.Core.5.1.1\lib\net462\Castle.Core.dll
+
+ ..\packages\ClosedXML.0.105.0-rc\lib\netstandard2.0\ClosedXML.dll
+
+
+ ..\packages\ClosedXML.Parser.2.0.0-preview1\lib\netstandard2.0\ClosedXML.Parser.dll
+
+
+ ..\packages\DocumentFormat.OpenXml.3.1.1\lib\net46\DocumentFormat.OpenXml.dll
+
+
+ ..\packages\DocumentFormat.OpenXml.Framework.3.1.1\lib\net46\DocumentFormat.OpenXml.Framework.dll
+
+
+ ..\packages\ExcelNumberFormat.1.1.0\lib\net20\ExcelNumberFormat.dll
+
..\packages\FluentNHibernate.2.0.3.0\lib\net40\FluentNHibernate.dll
@@ -113,6 +128,9 @@
..\packages\log4net.2.0.15\lib\net45\log4net.dll
+
+ ..\packages\Microsoft.Bcl.HashCode.1.1.1\lib\net461\Microsoft.Bcl.HashCode.dll
+
..\packages\MySql.Data.6.6.5\lib\net40\MySql.Data.dll
@@ -131,9 +149,15 @@
..\packages\Oracle.ManagedDataAccess.19.11.0\lib\net40\Oracle.ManagedDataAccess.dll
True
+
+ ..\packages\RBush.Signed.4.0.0\lib\net47\RBush.dll
+
..\packages\Renci.SshNet\Renci.SshNet.dll
+
+ ..\packages\SixLabors.Fonts.1.0.0\lib\netstandard2.0\SixLabors.Fonts.dll
+
..\packages\System.Buffers.4.6.1\lib\net462\System.Buffers.dll
@@ -162,6 +186,7 @@
+
diff --git a/TBF/UI/Bench/Metrology/CalibCertificateExtendedCtrl.Designer.cs b/TBF/UI/Bench/Metrology/CalibCertificateExtendedCtrl.Designer.cs
index 46cc35ca2..31461a495 100644
--- a/TBF/UI/Bench/Metrology/CalibCertificateExtendedCtrl.Designer.cs
+++ b/TBF/UI/Bench/Metrology/CalibCertificateExtendedCtrl.Designer.cs
@@ -29,6 +29,10 @@
private void InitializeComponent()
{
this.groupBox = new System.Windows.Forms.GroupBox();
+ this.textBox_SerialNo = new System.Windows.Forms.TextBox();
+ this.label_SerialNo = new System.Windows.Forms.Label();
+ this.textBox_Type = new System.Windows.Forms.TextBox();
+ this.label_Type = new System.Windows.Forms.Label();
this.certIdLabel = new System.Windows.Forms.Label();
this.openCertificateButton = new System.Windows.Forms.Button();
this.showCertificateButton = new System.Windows.Forms.Button();
@@ -37,10 +41,6 @@
this.calibValidDateLabel = new System.Windows.Forms.Label();
this.calibDateLabel = new System.Windows.Forms.Label();
this.calibCertificateNrTextBox = new System.Windows.Forms.TextBox();
- this.textBox_SerialNo = new System.Windows.Forms.TextBox();
- this.label_SerialNo = new System.Windows.Forms.Label();
- this.textBox_Type = new System.Windows.Forms.TextBox();
- this.label_Type = new System.Windows.Forms.Label();
this.groupBox.SuspendLayout();
this.SuspendLayout();
//
@@ -68,6 +68,38 @@
this.groupBox.TabStop = false;
this.groupBox.Text = "Calibration certificate";
//
+ // textBox_SerialNo
+ //
+ this.textBox_SerialNo.Enabled = false;
+ this.textBox_SerialNo.Location = new System.Drawing.Point(111, 178);
+ this.textBox_SerialNo.Name = "textBox_SerialNo";
+ this.textBox_SerialNo.Size = new System.Drawing.Size(239, 26);
+ this.textBox_SerialNo.TabIndex = 33;
+ //
+ // label_SerialNo
+ //
+ this.label_SerialNo.Location = new System.Drawing.Point(14, 181);
+ this.label_SerialNo.Name = "label_SerialNo";
+ this.label_SerialNo.Size = new System.Drawing.Size(81, 23);
+ this.label_SerialNo.TabIndex = 32;
+ this.label_SerialNo.Text = "Serial. No";
+ //
+ // textBox_Type
+ //
+ this.textBox_Type.Enabled = false;
+ this.textBox_Type.Location = new System.Drawing.Point(111, 137);
+ this.textBox_Type.Name = "textBox_Type";
+ this.textBox_Type.Size = new System.Drawing.Size(239, 26);
+ this.textBox_Type.TabIndex = 31;
+ //
+ // label_Type
+ //
+ this.label_Type.Location = new System.Drawing.Point(14, 140);
+ this.label_Type.Name = "label_Type";
+ this.label_Type.Size = new System.Drawing.Size(81, 23);
+ this.label_Type.TabIndex = 30;
+ this.label_Type.Text = "Type";
+ //
// certIdLabel
//
this.certIdLabel.AutoSize = true;
@@ -152,43 +184,13 @@
this.calibCertificateNrTextBox.Size = new System.Drawing.Size(144, 26);
this.calibCertificateNrTextBox.TabIndex = 22;
//
- // textBox_SerialNo
- //
- this.textBox_SerialNo.Location = new System.Drawing.Point(111, 178);
- this.textBox_SerialNo.Name = "textBox_SerialNo";
- this.textBox_SerialNo.Size = new System.Drawing.Size(239, 26);
- this.textBox_SerialNo.TabIndex = 33;
- //
- // label_SerialNo
- //
- this.label_SerialNo.Location = new System.Drawing.Point(14, 181);
- this.label_SerialNo.Name = "label_SerialNo";
- this.label_SerialNo.Size = new System.Drawing.Size(81, 23);
- this.label_SerialNo.TabIndex = 32;
- this.label_SerialNo.Text = "Serial. No";
- //
- // textBox_Type
- //
- this.textBox_Type.Location = new System.Drawing.Point(111, 137);
- this.textBox_Type.Name = "textBox_Type";
- this.textBox_Type.Size = new System.Drawing.Size(239, 26);
- this.textBox_Type.TabIndex = 31;
- //
- // label_Type
- //
- this.label_Type.Location = new System.Drawing.Point(14, 140);
- this.label_Type.Name = "label_Type";
- this.label_Type.Size = new System.Drawing.Size(81, 23);
- this.label_Type.TabIndex = 30;
- this.label_Type.Text = "Type";
- //
- // CalibCertificateCtrl
+ // CalibCertificateExtendedCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.groupBox);
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
- this.Name = "CalibCertificateCtrl";
+ this.Name = "CalibCertificateExtendedCtrl";
this.Size = new System.Drawing.Size(360, 218);
this.groupBox.ResumeLayout(false);
this.groupBox.PerformLayout();
diff --git a/TBF/UI/Bench/Metrology/MetrologyDlgAdjustableScaleTab.cs b/TBF/UI/Bench/Metrology/MetrologyDlgAdjustableScaleTab.cs
index d1bf4e241..c1b68b25e 100644
--- a/TBF/UI/Bench/Metrology/MetrologyDlgAdjustableScaleTab.cs
+++ b/TBF/UI/Bench/Metrology/MetrologyDlgAdjustableScaleTab.cs
@@ -53,6 +53,7 @@ namespace TBF.UI.Bench.Metrology
Control correctionTextBox;
Control errorTextBox;
Control uncertaintyTextBox;
+ Control readabilityTextBox;
Unit currentUnit;
@@ -83,6 +84,7 @@ namespace TBF.UI.Bench.Metrology
this.Controls.Add(correctionTextBox = new TextBox());
this.Controls.Add(errorTextBox = new TextBox());
this.Controls.Add(uncertaintyTextBox = new TextBox());
+ this.Controls.Add(readabilityTextBox = new TextBox());
currentUnit = TBF.Rig.Sequences.ProcessData.ElectricUnit;
unitComboBox.Text = currentUnit.ToDescription();
@@ -102,6 +104,7 @@ namespace TBF.UI.Bench.Metrology
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [{1}]", Strings.Correction, unit.ToDescription()), Width = 100 });
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [%]", Strings.Error), Width = 100 });
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [%]", Strings.Uncertainty), Width = 100 });
+ lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [%]", Strings.Readability), Width = 100 });
measuredLabel.Text = string.Format("{0} [{1}]:", Strings.Measured, unit.ToDescription());
correctedLabel.Text = string.Format("{0} [{1}]:", Strings.Corrected, unit.ToDescription());
@@ -148,6 +151,7 @@ namespace TBF.UI.Bench.Metrology
//uncertainty
lvi.SubItems.Add(Common.Utils.ToNiceString(corr.Uncertainty, SignifDigits));
+ lvi.SubItems.Add(Common.Utils.ToNiceString(corr.Readability, SignifDigits));
listViewEx.Items.Add(lvi);
@@ -170,6 +174,10 @@ namespace TBF.UI.Bench.Metrology
else if (unlocked && e.SubItem == 4)
{
listViewEx.StartEditing(uncertaintyTextBox, e.Item, e.SubItem);
+ }
+ else if (unlocked && e.SubItem == 5)
+ {
+ listViewEx.StartEditing(readabilityTextBox, e.Item, e.SubItem);
}
}
@@ -194,6 +202,7 @@ namespace TBF.UI.Bench.Metrology
double correction; /// Correction in default unit
double error = 0;
double uncertainty = 0;
+ double readability = 0;
if (subItem == 1 && Utils.TryParseEDouble(strValue, out oriMeasurement) && (measurement = Units.ConvertFrom(currentUnit, oriMeasurement)) >= 0)
{
@@ -274,6 +283,19 @@ namespace TBF.UI.Bench.Metrology
return true;
}
+ else if (subItem == 5 && ((strValue == Strings.NaN) || Utils.TryParseEDouble(strValue, out readability)))
+ {
+ if (strValue == Strings.NaN)
+ {
+ }
+ else
+ {
+ (item.Tag as MeasurementCorrection).Readability = readability;
+ item.SubItems[4].Text = Common.Utils.ToNiceString(readability, SignifDigits);
+ }
+
+ return true;
+ }
else
{
return false;
diff --git a/TBF/UI/Bench/Metrology/MetrologyDlgDiverterTab.cs b/TBF/UI/Bench/Metrology/MetrologyDlgDiverterTab.cs
index 703c8086c..30ccc401e 100644
--- a/TBF/UI/Bench/Metrology/MetrologyDlgDiverterTab.cs
+++ b/TBF/UI/Bench/Metrology/MetrologyDlgDiverterTab.cs
@@ -49,6 +49,7 @@ namespace TBF.UI.Bench.Metrology
Control measurementTextBox;
Control correctionTextBox;
Control uncertaintyTextBox;
+ Control readabilityTextBox;
public MetrologyDlgDiverterTab()
@@ -78,9 +79,11 @@ namespace TBF.UI.Bench.Metrology
measurementTextBox = new TextBox();
correctionTextBox = new TextBox();
uncertaintyTextBox = new TextBox();
+ readabilityTextBox = new TextBox();
this.Controls.Add(measurementTextBox);
this.Controls.Add(correctionTextBox);
this.Controls.Add(uncertaintyTextBox);
+ this.Controls.Add(readabilityTextBox);
listViewEx.SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked);
listViewEx.SubItemRightClicked += new SubItemEventHandler(listViewEx_SubItemRightClicked);
@@ -90,6 +93,7 @@ namespace TBF.UI.Bench.Metrology
listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [m3/h]", Strings.Flow), Width = 100 });
listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [ms]", Strings.Correction), Width = 100 });
listViewEx.Columns.Add(new ColumnHeader() {Text = string.Format("{0} [%]", Strings.Uncertainty), Width = 100});
+ listViewEx.Columns.Add(new ColumnHeader() {Text = string.Format("{0} [%]", Strings.Readability), Width = 100});
RefreshAll();
}
@@ -124,6 +128,7 @@ namespace TBF.UI.Bench.Metrology
lvi.SubItems.Add(corr.Measurement.ToString());
lvi.SubItems.Add((1000 * corr.Correction).ToString());
lvi.SubItems.Add(corr.Uncertainty.ToString());
+ lvi.SubItems.Add(corr.Readability.ToString());
lvi.Tag = corr;
listViewEx.Items.Add(lvi);
}
@@ -142,6 +147,10 @@ namespace TBF.UI.Bench.Metrology
{
listViewEx.StartEditing(uncertaintyTextBox, e.Item, e.SubItem);
}
+ else if (unlocked && e.SubItem == 4)
+ {
+ listViewEx.StartEditing(readabilityTextBox, e.Item, e.SubItem);
+ }
}
void listViewEx_SubItemRightClicked(object sender, SubItemEventArgs e)
@@ -203,7 +212,12 @@ namespace TBF.UI.Bench.Metrology
(item.Tag as MeasurementCorrection).Uncertainty = fvalue ;
return true;
}
-
+ else if (subItem == 4 && Utils.TryParseEFloat(value, out fvalue))
+ {
+ (item.Tag as MeasurementCorrection).Readability = fvalue ;
+ return true;
+ }
+
else
{
return false;
diff --git a/TBF/UI/Bench/Metrology/MetrologyDlgEvaporationTab.cs b/TBF/UI/Bench/Metrology/MetrologyDlgEvaporationTab.cs
index b953c1896..38163451b 100644
--- a/TBF/UI/Bench/Metrology/MetrologyDlgEvaporationTab.cs
+++ b/TBF/UI/Bench/Metrology/MetrologyDlgEvaporationTab.cs
@@ -49,6 +49,7 @@ namespace TBF.UI.Bench.Metrology
Control measurementTextBox;
Control correctionTextBox;
Control uncertaintyTextBox;
+ Control readabilityTextBox;
public MetrologyDlgEvaporationTab()
@@ -78,9 +79,11 @@ namespace TBF.UI.Bench.Metrology
measurementTextBox = new TextBox();
correctionTextBox = new TextBox();
uncertaintyTextBox = new TextBox();
+ readabilityTextBox = new TextBox();
this.Controls.Add(measurementTextBox);
this.Controls.Add(correctionTextBox);
this.Controls.Add(uncertaintyTextBox);
+ this.Controls.Add(readabilityTextBox);
listViewEx.SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked);
listViewEx.SubItemRightClicked += new SubItemEventHandler(listViewEx_SubItemRightClicked);
@@ -90,6 +93,7 @@ namespace TBF.UI.Bench.Metrology
listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [°C]", Strings.Temperature), Width = 100 });
listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [g/hour]", Strings.Evaporation), Width = 100 });
listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [%]", Strings.Uncertainty), Width = 100 });
+ listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [%]", Strings.Readability), Width = 100 });
RefreshAll();
}
@@ -121,6 +125,7 @@ namespace TBF.UI.Bench.Metrology
lvi.SubItems.Add(corr.Measurement.ToString());
lvi.SubItems.Add((1000 * corr.Correction).ToString());
lvi.SubItems.Add(corr.Uncertainty.ToString());
+ lvi.SubItems.Add(corr.Readability.ToString());
lvi.Tag = corr;
listViewEx.Items.Add(lvi);
}
@@ -139,6 +144,10 @@ namespace TBF.UI.Bench.Metrology
{
listViewEx.StartEditing(uncertaintyTextBox, e.Item, e.SubItem);
}
+ else if (unlocked && e.SubItem == 4)
+ {
+ listViewEx.StartEditing(readabilityTextBox, e.Item, e.SubItem);
+ }
}
void listViewEx_SubItemRightClicked(object sender, SubItemEventArgs e)
@@ -200,6 +209,11 @@ namespace TBF.UI.Bench.Metrology
(item.Tag as MeasurementCorrection).Uncertainty = fvalue;
return true;
}
+ else if (subItem == 4 && Utils.TryParseEFloat(value, out fvalue))
+ {
+ (item.Tag as MeasurementCorrection).Readability = fvalue;
+ return true;
+ }
else
{
return false;
diff --git a/TBF/UI/Bench/Metrology/MetrologyDlgFlowMeterTab.cs b/TBF/UI/Bench/Metrology/MetrologyDlgFlowMeterTab.cs
index dcf29c870..39bdff10e 100644
--- a/TBF/UI/Bench/Metrology/MetrologyDlgFlowMeterTab.cs
+++ b/TBF/UI/Bench/Metrology/MetrologyDlgFlowMeterTab.cs
@@ -53,6 +53,7 @@ namespace TBF.UI.Bench.Metrology
Control correctionTextBox;
Control errorTextBox;
Control uncertaintyTextBox;
+ Control readabilityTextBox;
readonly int rangeIx; /// 0 (no range) or 1..5 (range #)
readonly bool isLastFlowMeterRange; /// true when this is the last range of this flow meter.
/// This is to prevent double saving of the meter entity to a DB
@@ -98,6 +99,7 @@ namespace TBF.UI.Bench.Metrology
this.Controls.Add(correctionTextBox = new TextBox());
this.Controls.Add(errorTextBox = new TextBox());
this.Controls.Add(uncertaintyTextBox = new TextBox());
+ this.Controls.Add(readabilityTextBox = new TextBox());
currentUnit = TBF.Rig.Sequences.ProcessData.FlowUnit;
unitComboBox.Text = currentUnit.ToDescription();
@@ -117,6 +119,7 @@ namespace TBF.UI.Bench.Metrology
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [{1}]", Strings.Correction, unit.ToDescription()), Width = 150 });
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [%]", Strings.Error), Width = 100 });
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [%]", Strings.Uncertainty), Width = 100 });
+ lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [%]", Strings.Readability), Width = 100 });
measuredLabel.Text = string.Format("{0} [{1}]:", Strings.Measured, unit.ToDescription());
correctedLabel.Text = string.Format("{0} [{1}]:", Strings.Corrected, unit.ToDescription());
@@ -167,6 +170,7 @@ namespace TBF.UI.Bench.Metrology
}
lvi.SubItems.Add(corr.Uncertainty.ToString());
+ lvi.SubItems.Add(corr.Readability.ToString());
listViewEx.Items.Add(lvi);
}
@@ -188,6 +192,10 @@ namespace TBF.UI.Bench.Metrology
else if (unlocked && e.SubItem == 4)
{
listViewEx.StartEditing(uncertaintyTextBox, e.Item, e.SubItem);
+ }
+ else if (unlocked && e.SubItem == 5)
+ {
+ listViewEx.StartEditing(readabilityTextBox, e.Item, e.SubItem);
}
}
@@ -212,6 +220,7 @@ namespace TBF.UI.Bench.Metrology
double correction; /// Correction in default unit
double error = 0;
double uncertainty;
+ double readibility;
if (subItem == 1 && Utils.TryParseEDouble(strValue, out oriMeasurement) && (measurement = Units.ConvertFrom(currentUnit, oriMeasurement)) >= 0)
{
@@ -294,6 +303,21 @@ namespace TBF.UI.Bench.Metrology
return true;
}
+ if (subItem == 5 && Utils.TryParseEDouble(strValue, out readibility))
+ {
+ (item.Tag as MeasurementCorrection).Readability = readibility;
+
+ if (readibility == 0.0f)
+ {
+ item.SubItems[3].Text = Strings.NaN;
+ }
+ else
+ {
+ item.SubItems[3].Text = Common.Utils.ToNiceString(readibility, SignifDigits);
+ }
+
+ return true;
+ }
else
{
return false;
diff --git a/TBF/UI/Bench/Metrology/MetrologyDlgLevelMeterTab.cs b/TBF/UI/Bench/Metrology/MetrologyDlgLevelMeterTab.cs
index a0abbe3c6..ac752fe2f 100644
--- a/TBF/UI/Bench/Metrology/MetrologyDlgLevelMeterTab.cs
+++ b/TBF/UI/Bench/Metrology/MetrologyDlgLevelMeterTab.cs
@@ -49,6 +49,7 @@ namespace TBF.UI.Bench.Metrology
Control measurementTextBox;
Control correctionTextBox;
Control uncertaintyTextBox;
+ Control readabilityTextBox;
public MetrologyDlgLevelMeterTab()
@@ -78,9 +79,11 @@ namespace TBF.UI.Bench.Metrology
measurementTextBox = new TextBox();
correctionTextBox = new TextBox();
uncertaintyTextBox = new TextBox();
+ readabilityTextBox = new TextBox();
this.Controls.Add(measurementTextBox);
this.Controls.Add(correctionTextBox);
this.Controls.Add(uncertaintyTextBox);
+ this.Controls.Add(readabilityTextBox);
listViewEx.SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked);
listViewEx.SubItemRightClicked += new SubItemEventHandler(listViewEx_SubItemRightClicked);
@@ -90,6 +93,7 @@ namespace TBF.UI.Bench.Metrology
listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [mm]", Strings.Level), Width = 100 });
listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [mm]", Strings.Correction), Width = 100 });
listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [%]", Strings.Uncertainty), Width = 100 });
+ listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [%]", Strings.Readability), Width = 100 });
RefreshAll();
}
@@ -121,6 +125,7 @@ namespace TBF.UI.Bench.Metrology
lvi.SubItems.Add(corr.Measurement.ToString());
lvi.SubItems.Add((corr.Correction).ToString());
lvi.SubItems.Add((corr.Uncertainty).ToString());
+ lvi.SubItems.Add((corr.Readability).ToString());
lvi.Tag = corr;
listViewEx.Items.Add(lvi);
}
@@ -196,6 +201,11 @@ namespace TBF.UI.Bench.Metrology
(item.Tag as MeasurementCorrection).Uncertainty = fvalue;
return true;
}
+ else if (subItem == 4 && Utils.TryParseEFloat(value, out fvalue))
+ {
+ (item.Tag as MeasurementCorrection).Readability = fvalue;
+ return true;
+ }
else
{
return false;
diff --git a/TBF/UI/Bench/Metrology/MetrologyDlgPressMeterTab.cs b/TBF/UI/Bench/Metrology/MetrologyDlgPressMeterTab.cs
index 6d234bb45..146d5573b 100644
--- a/TBF/UI/Bench/Metrology/MetrologyDlgPressMeterTab.cs
+++ b/TBF/UI/Bench/Metrology/MetrologyDlgPressMeterTab.cs
@@ -53,6 +53,7 @@ namespace TBF.UI.Bench.Metrology
Control correctionTextBox;
Control errorTextBox;
Control uncertaintyTextBox;
+ Control readabilityTextBox;
Unit currentUnit;
@@ -83,6 +84,7 @@ namespace TBF.UI.Bench.Metrology
this.Controls.Add(correctionTextBox = new TextBox());
this.Controls.Add(errorTextBox = new TextBox());
this.Controls.Add(uncertaintyTextBox = new TextBox());
+ this.Controls.Add(readabilityTextBox = new TextBox());
currentUnit = TBF.Rig.Sequences.ProcessData.PressUnit;
unitComboBox.Text = currentUnit.ToDescription();
@@ -102,6 +104,7 @@ namespace TBF.UI.Bench.Metrology
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [{1}]", Strings.Correction, unit.ToDescription()), Width = 100 });
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [%]", Strings.Error), Width = 100 });
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [%]", Strings.Uncertainty), Width = 100 });
+ lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [%]", Strings.Readability), Width = 100 });
measuredLabel.Text = string.Format("{0} [{1}]:", Strings.Measured, unit.ToDescription());
correctedLabel.Text = string.Format("{0} [{1}]:", Strings.Corrected, unit.ToDescription());
@@ -149,6 +152,8 @@ namespace TBF.UI.Bench.Metrology
//uncertainty
lvi.SubItems.Add(Common.Utils.ToNiceString(corr.Uncertainty, SignifDigits));
+ //Readability
+ lvi.SubItems.Add(Common.Utils.ToNiceString(corr.Readability, SignifDigits));
listViewEx.Items.Add(lvi);
}
@@ -170,6 +175,10 @@ namespace TBF.UI.Bench.Metrology
else if (unlocked && e.SubItem == 4)
{
listViewEx.StartEditing(uncertaintyTextBox, e.Item, e.SubItem);
+ }
+ else if (unlocked && e.SubItem == 5)
+ {
+ listViewEx.StartEditing(readabilityTextBox, e.Item, e.SubItem);
}
}
@@ -194,6 +203,7 @@ namespace TBF.UI.Bench.Metrology
double correction; /// Correction in default unit
double error = 0;
double uncertaitity;
+ double readability;
if (subItem == 1 && Utils.TryParseEDouble(strValue, out oriMeasurement) && (measurement = Units.ConvertFrom(currentUnit, oriMeasurement)) >= 0)
{
@@ -274,6 +284,19 @@ namespace TBF.UI.Bench.Metrology
return true;
}
+ else if (subItem == 5 && (Utils.TryParseEDouble(strValue, out readability)))
+ {
+ if (strValue == Strings.NaN)
+ {
+ }
+ else
+ {
+ (item.Tag as MeasurementCorrection).Readability = readability;
+ item.SubItems[5].Text = Common.Utils.ToNiceString(readability, SignifDigits);
+ }
+
+ return true;
+ }
else
{
return false;
diff --git a/TBF/UI/Bench/Metrology/MetrologyDlgScaleTab.cs b/TBF/UI/Bench/Metrology/MetrologyDlgScaleTab.cs
index c852985fa..849f260f7 100644
--- a/TBF/UI/Bench/Metrology/MetrologyDlgScaleTab.cs
+++ b/TBF/UI/Bench/Metrology/MetrologyDlgScaleTab.cs
@@ -4,15 +4,15 @@
using System;
using System.Collections.Generic;
using System.Globalization;
-using System.IO;
using System.Windows.Forms;
using log4net;
using Common;
using Common.Forms;
using Config.Entities;
using TBF.Resources;
+using TBF.Rig.GenericDevices;
+using TBF.Rig.MettlerToledo.Standard;
using TBF.UI.Shared;
-using static System.Net.Mime.MediaTypeNames;
namespace TBF.UI.Bench.Metrology
{
@@ -54,6 +54,7 @@ namespace TBF.UI.Bench.Metrology
Control correctionTextBox;
Control errorTextBox;
Control uncertaintyTextBox;
+ Control readabilityTextBox;
Unit currentUnit;
@@ -84,6 +85,7 @@ namespace TBF.UI.Bench.Metrology
this.Controls.Add(correctionTextBox = new TextBox());
this.Controls.Add(errorTextBox = new TextBox());
this.Controls.Add(uncertaintyTextBox = new TextBox());
+ this.Controls.Add(readabilityTextBox = new TextBox());
currentUnit = TBF.Rig.Sequences.ProcessData.MassUnit;
unitComboBox.Text = currentUnit.ToDescription();
@@ -103,6 +105,7 @@ namespace TBF.UI.Bench.Metrology
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [{1}]", Strings.Correction, unit.ToDescription()), Width = 150 });
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [%]", Strings.Error), Width = 100 });
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [%]", Strings.Uncertainty), Width = 100 });
+ lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [%]", Strings.Readability), Width = 100 });
measuredLabel.Text = string.Format("{0} [{1}]:", Strings.Measured, unit.ToDescription());
correctedLabel.Text = string.Format("{0} [{1}]:", Strings.Corrected, unit.ToDescription());
@@ -130,7 +133,7 @@ namespace TBF.UI.Bench.Metrology
buoyancyTempTextBox.Text = BalanceCfg.BuoyancyTemp.ToString("F2");
buoyancyPressTextBox.Text = BalanceCfg.BuoyancyPress.ToString("F4");
buoyancyHumiTextBox.Text = BalanceCfg.BuoyancyHumi.ToString("F1");
- /// airDensityTextBox.Text = //calculate air density
+ airDensityTextBox.Text = CalculateAirDetsity(BalanceCfg).ToString("F4");
weightStandardDensityTextBox.Text = BalanceCfg.WeightStandardDensity.ToString("F1");
}
@@ -138,6 +141,27 @@ namespace TBF.UI.Bench.Metrology
foreach (var corr in MeterEntity.Corrections) AddOneLVI(corr);
}
+
+
+ double CalculateAirDetsity(IScaleCfg scaleCfg)//, double temperature, double pressure, double humidity)
+ {
+ double temperature = scaleCfg.BuoyancyTemp;
+ double humidity = scaleCfg.BuoyancyHumi;
+ double pressure = Units.ConvertTo(Unit.mbar, scaleCfg.BuoyancyPress);
+
+ double t = 273.15 + temperature;
+ double F6 =
+ (1.2811805 / 100000) * Math.Pow(t, 2)
+ - (1.950987 / 100) * t
+ + 34.04926034
+ - (6.353631 * 1000) / t;
+ double G6 = Math.Exp(F6);
+ double H6 = scaleCfg.BuoyancyHumi/100*G6/pressure;
+ double airDensityE = (((3.48353 / 1000) * pressure * (1 - (0.378 * H6))) / t )/ 1000;
+
+ return (airDensityE * 1000);
+ }
+
void AddOneLVI(MeasurementCorrection corr)
{
int nr = listViewEx.Items.Count + 1;
@@ -161,6 +185,7 @@ namespace TBF.UI.Bench.Metrology
}
lvi.SubItems.Add(corr.Uncertainty.ToString());
+ lvi.SubItems.Add(corr.Readability.ToString());
listViewEx.Items.Add(lvi);
}
@@ -182,6 +207,10 @@ namespace TBF.UI.Bench.Metrology
else if (unlocked && e.SubItem == 4)
{
listViewEx.StartEditing(uncertaintyTextBox, e.Item, e.SubItem);
+ }
+ else if (unlocked && e.SubItem == 5)
+ {
+ listViewEx.StartEditing(readabilityTextBox, e.Item, e.SubItem);
}
}
@@ -206,9 +235,11 @@ namespace TBF.UI.Bench.Metrology
double correction; /// Correction in default unit
double error = 0;
double uncertainty;
+ double readability = 0;
- if (subItem == 1 && Utils.TryParseEDouble(strValue, out oriMeasurement) && (measurement = Units.ConvertFrom(currentUnit, oriMeasurement)) >= 0)
+ if (subItem == 1 && Utils.TryParseEDouble(strValue, out oriMeasurement))
{
+ measurement = Units.ConvertFrom(currentUnit, oriMeasurement);
(item.Tag as MeasurementCorrection).Measurement = measurement;
/// Update error (if possible)
@@ -279,11 +310,25 @@ namespace TBF.UI.Bench.Metrology
if (uncertainty != 0)
{
- item.SubItems[3].Text = Common.Utils.ToNiceString(uncertainty, SignifDigits);
+ item.SubItems[4].Text = Common.Utils.ToNiceString(uncertainty, SignifDigits);
}
else
{
- item.SubItems[3].Text = Strings.NaN;
+ item.SubItems[4].Text = Strings.NaN;
+ }
+ return true;
+ }
+ else if (subItem == 5 && Utils.TryParseEDouble(strValue, out readability))
+ {
+ (item.Tag as MeasurementCorrection).Readability = readability;
+
+ if (readability != 0)
+ {
+ item.SubItems[5].Text = Common.Utils.ToNiceString(readability, SignifDigits);
+ }
+ else
+ {
+ item.SubItems[5].Text = Strings.NaN;
}
return true;
}
@@ -463,5 +508,31 @@ namespace TBF.UI.Bench.Metrology
InitializeColumns(listViewEx, currentUnit);
RefreshAll();
}
- }
+
+ private void buoyancy_TextChanged(object sender, EventArgs e)
+ {
+ var cfg = new BalanceCfg(null);
+ cfg.BuoyancyTemp = Utils.ParseSFloat(buoyancyTempTextBox.Text);
+ cfg.BuoyancyPress =Utils.ParseUFloat(buoyancyPressTextBox.Text);
+ cfg.BuoyancyHumi = Utils.ParseUFloat(buoyancyHumiTextBox.Text);
+
+ airDensityTextBox.Text = CalculateAirDetsity(cfg).ToString("F4");
+ }
+
+
+ private void buoyancyHumiTextBox_TextChanged(object sender, EventArgs e)
+ {
+ buoyancy_TextChanged(sender, e);
+ }
+
+ private void buoyancyPressTextBox_TextChanged(object sender, EventArgs e)
+ {
+ buoyancy_TextChanged(sender, e);
+ }
+
+ private void buoyancyTempTextBox_TextChanged(object sender, EventArgs e)
+ {
+ buoyancy_TextChanged(sender, e);
+ }
+ }
}
diff --git a/TBF/UI/Bench/Metrology/MetrologyDlgScaleTab.designer.cs b/TBF/UI/Bench/Metrology/MetrologyDlgScaleTab.designer.cs
index bbe566e1e..94fd95ea4 100644
--- a/TBF/UI/Bench/Metrology/MetrologyDlgScaleTab.designer.cs
+++ b/TBF/UI/Bench/Metrology/MetrologyDlgScaleTab.designer.cs
@@ -194,6 +194,7 @@ namespace TBF.UI.Bench.Metrology
this.buoyancyHumiTextBox.Name = "buoyancyHumiTextBox";
this.buoyancyHumiTextBox.Size = new System.Drawing.Size(121, 26);
this.buoyancyHumiTextBox.TabIndex = 5;
+ this.buoyancyHumiTextBox.TextChanged += new System.EventHandler(this.buoyancyHumiTextBox_TextChanged);
//
// buoyancyPressTextBox
//
@@ -203,6 +204,7 @@ namespace TBF.UI.Bench.Metrology
this.buoyancyPressTextBox.Name = "buoyancyPressTextBox";
this.buoyancyPressTextBox.Size = new System.Drawing.Size(121, 26);
this.buoyancyPressTextBox.TabIndex = 4;
+ this.buoyancyPressTextBox.TextChanged += new System.EventHandler(this.buoyancyPressTextBox_TextChanged);
//
// buoyancyTempTextBox
//
@@ -212,6 +214,7 @@ namespace TBF.UI.Bench.Metrology
this.buoyancyTempTextBox.Name = "buoyancyTempTextBox";
this.buoyancyTempTextBox.Size = new System.Drawing.Size(121, 26);
this.buoyancyTempTextBox.TabIndex = 3;
+ this.buoyancyTempTextBox.TextChanged += new System.EventHandler(this.buoyancyTempTextBox_TextChanged);
//
// buoyancyHumiLabel
//
diff --git a/TBF/UI/Bench/Metrology/MetrologyDlgTempMeterTab.Designer.cs b/TBF/UI/Bench/Metrology/MetrologyDlgTempMeterTab.Designer.cs
index b5839f162..c6545b1a2 100644
--- a/TBF/UI/Bench/Metrology/MetrologyDlgTempMeterTab.Designer.cs
+++ b/TBF/UI/Bench/Metrology/MetrologyDlgTempMeterTab.Designer.cs
@@ -72,7 +72,7 @@ namespace TBF.UI.Bench.Metrology
//
this.splitContainer1.Panel2.Controls.Add(this.listViewEx);
this.splitContainer1.Size = new System.Drawing.Size(975, 462);
- this.splitContainer1.SplitterDistance = 157;
+ this.splitContainer1.SplitterDistance = 146;
this.splitContainer1.SplitterWidth = 6;
this.splitContainer1.TabIndex = 2;
//
@@ -187,7 +187,7 @@ namespace TBF.UI.Bench.Metrology
this.listViewEx.Location = new System.Drawing.Point(0, 0);
this.listViewEx.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.listViewEx.Name = "listViewEx";
- this.listViewEx.Size = new System.Drawing.Size(975, 299);
+ this.listViewEx.Size = new System.Drawing.Size(975, 310);
this.listViewEx.TabIndex = 0;
this.listViewEx.UseCompatibleStateImageBehavior = false;
this.listViewEx.View = System.Windows.Forms.View.Details;
diff --git a/TBF/UI/Bench/Metrology/MetrologyDlgTempMeterTab.cs b/TBF/UI/Bench/Metrology/MetrologyDlgTempMeterTab.cs
index fb57e84ab..b35a59496 100644
--- a/TBF/UI/Bench/Metrology/MetrologyDlgTempMeterTab.cs
+++ b/TBF/UI/Bench/Metrology/MetrologyDlgTempMeterTab.cs
@@ -53,6 +53,7 @@ namespace TBF.UI.Bench.Metrology
Control correctionTextBox;
Control errorTextBox;
Control uncertaintyTextBox;
+ Control readabilityTextBox;
Unit currentUnit;
@@ -83,6 +84,7 @@ namespace TBF.UI.Bench.Metrology
this.Controls.Add(correctionTextBox = new TextBox());
this.Controls.Add(errorTextBox = new TextBox());
this.Controls.Add(uncertaintyTextBox = new TextBox());
+ this.Controls.Add(readabilityTextBox = new TextBox());
currentUnit = TBF.Rig.Sequences.ProcessData.TempUnit;
unitComboBox.Text = currentUnit.ToDescription();
@@ -102,6 +104,7 @@ namespace TBF.UI.Bench.Metrology
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [{1}]", Strings.Correction, unit.ToDescription()), Width = 150 });
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [%]", Strings.Error), Width = 100 });
lv.Columns.Add(new ColumnHeader() {Text = string.Format("{0} [%]", Strings.Uncertainty), Width = 100 });
+ lv.Columns.Add(new ColumnHeader() {Text = string.Format("{0} [%]", Strings.Readability), Width = 100 });
measuredLabel.Text = string.Format("{0} [{1}]:", Strings.Measured, unit.ToDescription());
correctedLabel.Text = string.Format("{0} [{1}]:", Strings.Corrected, unit.ToDescription());
@@ -148,6 +151,7 @@ namespace TBF.UI.Bench.Metrology
lvi.SubItems.Add(Common.Utils.ToNiceString(error, SignifDigits));
}
lvi.SubItems.Add(corr.Uncertainty.ToString());
+ lvi.SubItems.Add(corr.Readability.ToString());
listViewEx.Items.Add(lvi);
}
@@ -169,6 +173,10 @@ namespace TBF.UI.Bench.Metrology
else if (unlocked && e.SubItem == 4)
{
listViewEx.StartEditing(uncertaintyTextBox, e.Item, e.SubItem);
+ }
+ else if (unlocked && e.SubItem == 5)
+ {
+ listViewEx.StartEditing(readabilityTextBox, e.Item, e.SubItem);
}
}
@@ -193,6 +201,7 @@ namespace TBF.UI.Bench.Metrology
double correction; /// Correction in default unit
double error = 0;
double uncertainty;
+ double readability;
if (subItem == 1 && Utils.TryParseEDouble(strValue, out oriMeasurement) && (measurement = Units.ConvertFrom(currentUnit, oriMeasurement)) >= 0)
{
@@ -260,7 +269,7 @@ namespace TBF.UI.Bench.Metrology
return true;
}
- if (subItem == 4 && Utils.TryParseEDouble(strValue, out uncertainty))
+ else if (subItem == 4 && Utils.TryParseEDouble(strValue, out uncertainty))
{
(item.Tag as MeasurementCorrection).Uncertainty = uncertainty;
@@ -269,7 +278,21 @@ namespace TBF.UI.Bench.Metrology
}
else
{
- item.SubItems[2].Text = Common.Utils.ToNiceString(uncertainty, SignifDigits);
+ item.SubItems[4].Text = Common.Utils.ToNiceString(uncertainty, SignifDigits);
+ }
+
+ return true;
+ }
+ else if (subItem == 5 && Utils.TryParseEDouble(strValue, out readability))
+ {
+ (item.Tag as MeasurementCorrection).Readability = readability;
+
+ if (strValue == Strings.NaN)
+ {
+ }
+ else
+ {
+ item.SubItems[5].Text = Common.Utils.ToNiceString(readability, SignifDigits);
}
return true;
diff --git a/TBF/UI/ResultsMI/PreviousResultsDlgUncertainty.cs b/TBF/UI/ResultsMI/PreviousResultsDlgUncertainty.cs
index 1dff66422..1952c11a2 100644
--- a/TBF/UI/ResultsMI/PreviousResultsDlgUncertainty.cs
+++ b/TBF/UI/ResultsMI/PreviousResultsDlgUncertainty.cs
@@ -1,10 +1,12 @@
///
/// Copyright (c) 2016-2021 Sensus Slovensko a.s.
///
+
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
+using ClosedXML.Excel;
using log4net;
using NHibernate;
#if MANAGED
@@ -13,65 +15,88 @@ using Oracle.ManagedDataAccess.Client;
using Oracle.DataAccess.Client;
#endif
using Common;
+using Config.Entities;
using Results;
using Results.Entities;
using Results.Uncertainty;
+using Results.Uncertainty.CommonTable;
+using TBF.Rig;
using TBF.Rig.Generic;
using TBF.Rig.GenericDevices;
+using TBF.Rig.Keithley.TempMeter;
using TBF.Rig.Output.DB.SensusOracle;
using TBF.Rig.Sequences;
using Strings = TBF.Resources.Strings;
namespace TBF.UI.ResultsMI
{
- public partial class PreviousResultsDlgUncertainty : Form, IPreviousResultDlg
- {
- static readonly ILog log = LogManager.GetLogger(typeof(PreviousResultsDlgUncertainty));
+ public partial class PreviousResultsDlgUncertainty : Form, IPreviousResultDlg
+ {
+ static readonly ILog log = LogManager.GetLogger(typeof(PreviousResultsDlgUncertainty));
- ISession session;
- int currentBatchNr;
+ ISession session;
+ ISession sessionDBConfig;
+ private static IList cmpntEntities;
- IList batches; /// A list of batches selected from all batches using criteria entered in UI
- IList serialNrs; /// Display only watermeters with these serial numbers (null = display all)
- int lastDisplayedIx; /// Index of the last displayed batch from the list 'batches'
- const int LinesCount = 25; /// Number of batches displayed on one screen
-
+ int currentBatchNr;
+
+ IList batches;
+
+ /// A list of batches selected from all batches using criteria entered in UI
+ IList serialNrs;
+
+ /// Display only watermeters with these serial numbers (null = display all)
+ int lastDisplayedIx;
+
+ /// Index of the last displayed batch from the list 'batches'
+ const int LinesCount = 25;
+
+ /// Number of batches displayed on one screen
PreviousResultsMode mode;
public PreviousResultsDlgUncertainty(PreviousResultsMode mode)
- {
- InitializeComponent();
- this.mode = mode;
- currentBatchNr = Program.LocalSettings.BatchNr;
+ {
+ InitializeComponent();
+ this.mode = mode;
+ currentBatchNr = Program.LocalSettings.BatchNr;
PrintHandler += delegate(object sndr, PreviousResultIdEventArgs args)
{
- if (InvokeRequired) { Invoke(new EventHandler(DoAddListUncertainty), sndr, args); }
+ if (InvokeRequired)
+ {
+ Invoke(new EventHandler(DoAddListUncertainty), sndr, args);
+ }
else DoAddListUncertainty(sndr, args);
};
- SendAgainHandler += delegate(object sndr, PreviousResultIdEventArgs args)
- {
- if (InvokeRequired) { Invoke(new EventHandler(DoSendAgain), sndr, args); }
- else DoSendAgain(sndr, args);
- };
+ SendAgainHandler += delegate(object sndr, PreviousResultIdEventArgs args)
+ {
+ if (InvokeRequired)
+ {
+ Invoke(new EventHandler(DoSendAgain), sndr, args);
+ }
+ else DoSendAgain(sndr, args);
+ };
ShowResultsHandler += delegate(object sndr, PreviousResultIdEventArgs args)
{
- if (InvokeRequired) { Invoke(new EventHandler(DoShowResults), sndr, args); }
+ if (InvokeRequired)
+ {
+ Invoke(new EventHandler(DoShowResults), sndr, args);
+ }
else DoShowResults(sndr, args);
};
}
- public PreviousResultsDlgUncertainty()
+ public PreviousResultsDlgUncertainty()
: this(PreviousResultsMode.Show)
- {
- }
+ {
+ }
- private void PreviousResultsDlgUncertainty_Load(object sender, EventArgs e)
- {
- Localize();
+ private void PreviousResultsDlgUncertainty_Load(object sender, EventArgs e)
+ {
+ Localize();
fromDateTimePicker.MinDate = Constants.MinDate;
fromDateTimePicker.MaxDate = DateTime.Today;
@@ -98,12 +123,12 @@ namespace TBF.UI.ResultsMI
batches = GetFilteredBatches(out lastDisplayedIx, out serialNrs);
UpdateButtons();
Redraw();
- }
+ }
- void Localize()
- {
- Text = Strings.Previous_results;
- closeButton.Text = TBF.Resources.Strings.CloseBtnText;
+ void Localize()
+ {
+ Text = Strings.Previous_results;
+ closeButton.Text = TBF.Resources.Strings.CloseBtnText;
previousButton.Text = TBF.Resources.Strings.Previous;
nextButton.Text = TBF.Resources.Strings.Next;
fromLabel.Text = Strings.from;
@@ -111,7 +136,7 @@ namespace TBF.UI.ResultsMI
procedureLabel.Text = Strings.Procedure;
listView1.Columns[0].Text = Strings.Nr;
listView1.Columns[1].Text = Strings.Name;
- }
+ }
///
/// Returns a list of batches selected using criteria entered in UI
@@ -126,40 +151,40 @@ namespace TBF.UI.ResultsMI
if (string.IsNullOrEmpty(procedureTextBox.Text) && string.IsNullOrEmpty(snTextBox.Text))
{
rslt = session.QueryOver()
- .Where(x => (x.StartTime >= fromDateTimePicker.Value))
- .And(x => (x.StartTime < toDateTimePicker.Value.AddDays(1)))
- .OrderBy(x => x.BatchNr).Asc
- .List();
+ .Where(x => (x.StartTime >= fromDateTimePicker.Value))
+ .And(x => (x.StartTime < toDateTimePicker.Value.AddDays(1)))
+ .OrderBy(x => x.BatchNr).Asc
+ .List();
}
else if (string.IsNullOrEmpty(snTextBox.Text))
{
rslt = session.QueryOver()
- .Where(x => (x.StartTime >= fromDateTimePicker.Value))
- .And(x => (x.StartTime < toDateTimePicker.Value.AddDays(1)))
- .And(x => (x.ProcedureName == procedureTextBox.Text))
- .OrderBy(x => x.BatchNr).Asc
- .List();
+ .Where(x => (x.StartTime >= fromDateTimePicker.Value))
+ .And(x => (x.StartTime < toDateTimePicker.Value.AddDays(1)))
+ .And(x => (x.ProcedureName == procedureTextBox.Text))
+ .OrderBy(x => x.BatchNr).Asc
+ .List();
}
else if (string.IsNullOrEmpty(procedureTextBox.Text))
{
rslt = session.QueryOver()
- .Where(x => (x.StartTime >= fromDateTimePicker.Value))
- .And(x => (x.StartTime < toDateTimePicker.Value.AddDays(1)))
- .OrderBy(x => x.BatchNr).Asc
- .JoinQueryOver(b => b.WaterMeters)
- .Where(wm => (wm.SerialNr == snTextBox.Text))
- .List();
+ .Where(x => (x.StartTime >= fromDateTimePicker.Value))
+ .And(x => (x.StartTime < toDateTimePicker.Value.AddDays(1)))
+ .OrderBy(x => x.BatchNr).Asc
+ .JoinQueryOver(b => b.WaterMeters)
+ .Where(wm => (wm.SerialNr == snTextBox.Text))
+ .List();
}
else
{
rslt = session.QueryOver()
- .Where(x => (x.StartTime >= fromDateTimePicker.Value))
- .And(x => (x.StartTime < toDateTimePicker.Value.AddDays(1)))
- .And(x => (x.ProcedureName == procedureTextBox.Text))
- .OrderBy(x => x.BatchNr).Asc
- .JoinQueryOver(b => b.WaterMeters)
- .Where(wm => (wm.SerialNr == snTextBox.Text))
- .List();
+ .Where(x => (x.StartTime >= fromDateTimePicker.Value))
+ .And(x => (x.StartTime < toDateTimePicker.Value.AddDays(1)))
+ .And(x => (x.ProcedureName == procedureTextBox.Text))
+ .OrderBy(x => x.BatchNr).Asc
+ .JoinQueryOver(b => b.WaterMeters)
+ .Where(wm => (wm.SerialNr == snTextBox.Text))
+ .List();
}
}
catch (Exception exc)
@@ -174,31 +199,31 @@ namespace TBF.UI.ResultsMI
return rslt;
}
- public void OnReload(object sender, PreviousResultIdEventArgs data)
- {
- foreach (var batch in batches)
- {
- if (batch.BatchNr == data.BatchNr)
- {
- TBF.UiBridge.Bridge.BatchNr = batch.BatchNr;
+ public void OnReload(object sender, PreviousResultIdEventArgs data)
+ {
+ foreach (var batch in batches)
+ {
+ if (batch.BatchNr == data.BatchNr)
+ {
+ TBF.UiBridge.Bridge.BatchNr = batch.BatchNr;
- Program.MainWnd.ReloadProcedureComboBoxItems(batch.ProcedureName);
- TBF.UiBridge.Bridge.Ui2Bench(TBF.UiBridge.UI2BenchCmd.ReloadBatch);
- break;
- }
- }
+ Program.MainWnd.ReloadProcedureComboBoxItems(batch.ProcedureName);
+ TBF.UiBridge.Bridge.Ui2Bench(TBF.UiBridge.UI2BenchCmd.ReloadBatch);
+ break;
+ }
+ }
- DialogResult = DialogResult.Cancel;
- Close();
- }
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
- public string getSendReloadButtonText()
- {
- return Strings.Add;
- }
+ public string getSendReloadButtonText()
+ {
+ return Strings.Add;
+ }
- public void OnReloadAndFix(object sender, PreviousResultIdEventArgs data)
+ public void OnReloadAndFix(object sender, PreviousResultIdEventArgs data)
{
foreach (var batch in batches)
{
@@ -217,8 +242,7 @@ namespace TBF.UI.ResultsMI
}
-
- public event EventHandler PrintHandler;
+ public event EventHandler PrintHandler;
///
/// Called from PreviousResultCtrl when 'Print' button pressed.
@@ -242,10 +266,10 @@ namespace TBF.UI.ResultsMI
{
if (b.BatchNr == data.BatchNr)
{
- ListViewItem item1 = new ListViewItem(data.BatchNr.ToString());
- item1.SubItems.Add(b.ProcedureName);
- listView1.Items.Add(item1);
- break;
+ ListViewItem item1 = new ListViewItem(data.BatchNr.ToString());
+ item1.SubItems.Add(b.ProcedureName);
+ listView1.Items.Add(item1);
+ break;
}
}
}
@@ -254,27 +278,27 @@ namespace TBF.UI.ResultsMI
public event EventHandler SendAgainHandler;
///
- /// Called from PreviousResultCtrl when 'Send again' button pressed.
- ///
- public void OnSendAgain(object sender, PreviousResultIdEventArgs data)
- {
- if (SendAgainHandler == null) return;
- try
- {
- SendAgainHandler(sender, data);
- }
- catch (Exception e)
- {
- log.Error("SendAgainHandler(...) failed", e);
- }
- }
+ /// Called from PreviousResultCtrl when 'Send again' button pressed.
+ ///
+ public void OnSendAgain(object sender, PreviousResultIdEventArgs data)
+ {
+ if (SendAgainHandler == null) return;
+ try
+ {
+ SendAgainHandler(sender, data);
+ }
+ catch (Exception e)
+ {
+ log.Error("SendAgainHandler(...) failed", e);
+ }
+ }
- public void DoSendAgain(object sender, PreviousResultIdEventArgs data)
- {
- foreach (var b in batches)
- {
- if (b.BatchNr == data.BatchNr)
- {
+ public void DoSendAgain(object sender, PreviousResultIdEventArgs data)
+ {
+ foreach (var b in batches)
+ {
+ if (b.BatchNr == data.BatchNr)
+ {
#if ORACLE_DB
if (ProcessData.OracleDB == null)
{
@@ -304,21 +328,27 @@ namespace TBF.UI.ResultsMI
}
#endif
}
- }
- }
+ }
+ }
- public event EventHandler ShowResultsHandler;
+ public event EventHandler ShowResultsHandler;
- ///
- /// Called from PreviousResultCtrl when 'Show' button pressed.
- ///
- public void OnShowResults(object sender, PreviousResultIdEventArgs data)
- {
+ ///
+ /// Called from PreviousResultCtrl when 'Show' button pressed.
+ ///
+ public void OnShowResults(object sender, PreviousResultIdEventArgs data)
+ {
if (ShowResultsHandler == null) return;
- try { ShowResultsHandler(sender, data); }
- catch (Exception e) { log.Error("ShowResultsHandler(...) failed", e); }
- }
+ try
+ {
+ ShowResultsHandler(sender, data);
+ }
+ catch (Exception e)
+ {
+ log.Error("ShowResultsHandler(...) failed", e);
+ }
+ }
public void DoShowResults(object sender, PreviousResultIdEventArgs data)
{
@@ -328,7 +358,7 @@ namespace TBF.UI.ResultsMI
{
if (b.WaterMeters == null || b.WaterMeters.Count == 0)
{
- return; /// No water meters in the selected batch
+ return; /// No water meters in the selected batch
}
/// Prepare result items
@@ -339,7 +369,8 @@ namespace TBF.UI.ResultsMI
{
if (wm.WaterMeterData.Compound)
{
- items = WMeterRsltItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_CombinedWM);
+ items = WMeterRsltItemSpec.FromStrArray(Program.LocalSettings
+ .RsltItems_Screen_CombinedWM);
}
else if (wm.WaterMeterData.HeatMeter)
{
@@ -347,32 +378,35 @@ namespace TBF.UI.ResultsMI
}
else
{
- items = WMeterRsltItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_SingleWM);
+ items = WMeterRsltItemSpec.FromStrArray(Program.LocalSettings
+ .RsltItems_Screen_SingleWM);
}
+
break;
}
}
+
if (items == null) items = new List();
/// Show dialog with results
Results.Forms.BatchResultsDlg dlg = new Results.Forms.BatchResultsDlg
- {
- Text = string.Format(Strings.Results_of_batch_0, b.BatchNr),
- Results = BatchResults.FromBatch(b),
- Items = items,
- PopupResultsLeft = Program.LocalSettings.PopupResultsLeft,
- PopupResultsTop = Program.LocalSettings.PopupResultsTop,
- PopupResultsWidth = Program.LocalSettings.PopupResultsWidth,
- PopupResultsHeight = Program.LocalSettings.PopupResultsHeight,
- MetersArrangement = Program.LocalSettings.ResultsConfigMeters,
- TestsArrangement = Program.LocalSettings.ResultsConfigTests,
- NrMetersInOneGroup = Math.Max(1, Program.LocalSettings.ResultsConfigMetersInOneGroup),
- ShowDisabledPositions = Program.LocalSettings.ShowDisabledPositions,
- MinWidth = Program.LocalSettings.ResultsConfigMinWidth,
- MinHeight = Program.LocalSettings.ResultsConfigMinHeight,
- RsltsClmnWidths = Program.LocalSettings.RsltsClmnWidths,
- SerialNrs = data.SerialNrs,
- };
+ {
+ Text = string.Format(Strings.Results_of_batch_0, b.BatchNr),
+ Results = BatchResults.FromBatch(b),
+ Items = items,
+ PopupResultsLeft = Program.LocalSettings.PopupResultsLeft,
+ PopupResultsTop = Program.LocalSettings.PopupResultsTop,
+ PopupResultsWidth = Program.LocalSettings.PopupResultsWidth,
+ PopupResultsHeight = Program.LocalSettings.PopupResultsHeight,
+ MetersArrangement = Program.LocalSettings.ResultsConfigMeters,
+ TestsArrangement = Program.LocalSettings.ResultsConfigTests,
+ NrMetersInOneGroup = Math.Max(1, Program.LocalSettings.ResultsConfigMetersInOneGroup),
+ ShowDisabledPositions = Program.LocalSettings.ShowDisabledPositions,
+ MinWidth = Program.LocalSettings.ResultsConfigMinWidth,
+ MinHeight = Program.LocalSettings.ResultsConfigMinHeight,
+ RsltsClmnWidths = Program.LocalSettings.RsltsClmnWidths,
+ SerialNrs = data.SerialNrs,
+ };
dlg.Show();
@@ -385,14 +419,14 @@ namespace TBF.UI.ResultsMI
/// Redraws list of batches.
/// Uses member variables 'batches' and 'lastDisplayedIx'
///
- void Redraw()
- {
- SuspendLayout();
+ void Redraw()
+ {
+ SuspendLayout();
- flowLayoutPanel1.FlowDirection = FlowDirection.TopDown;
- flowLayoutPanel1.Controls.Clear();
+ flowLayoutPanel1.FlowDirection = FlowDirection.TopDown;
+ flowLayoutPanel1.Controls.Clear();
- if (batches == null || batches.Count == 0) return;
+ if (batches == null || batches.Count == 0) return;
for (int i = Math.Max(0, lastDisplayedIx - LinesCount + 1); i <= lastDisplayedIx; i++)
{
@@ -401,34 +435,41 @@ namespace TBF.UI.ResultsMI
int failedCount = 0;
foreach (var wm in b.WaterMeters)
{
- if ((wm != null) && wm.Passed) { passedCount++; } else { failedCount++; }
+ if ((wm != null) && wm.Passed)
+ {
+ passedCount++;
+ }
+ else
+ {
+ failedCount++;
+ }
}
if (passedCount + failedCount == 0) continue;
flowLayoutPanel1.Controls.Add(new PreviousResultCtrl(this,
- b.BatchNr,
- b.StartTime,
- b.EndTime,
- b.ProgramVersion,
- b.ProcedureName,
- b.WaterMeters[0].PurchaseOrder,
- passedCount,
- failedCount,
- b.RsltsSent,
- mode,
- serialNrs));
+ b.BatchNr,
+ b.StartTime,
+ b.EndTime,
+ b.ProgramVersion,
+ b.ProcedureName,
+ b.WaterMeters[0].PurchaseOrder,
+ passedCount,
+ failedCount,
+ b.RsltsSent,
+ mode,
+ serialNrs));
}
- ResumeLayout();
- }
+ ResumeLayout();
+ }
- private void closeButton_Click(object sender, EventArgs e)
- {
+ private void closeButton_Click(object sender, EventArgs e)
+ {
if (session != null) session.Close();
- DialogResult = DialogResult.Cancel;
- Close();
- }
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
private void previousButton_Click(object sender, EventArgs e)
{
@@ -462,116 +503,463 @@ namespace TBF.UI.ResultsMI
if (CurrentUser.Restore(this)) Program.MainWnd.UpdateUser();
}
+ public class Pair
+ {
+ int offsetRows;
+
+ public int OffsetRows
+ {
+ get => offsetRows;
+ set => offsetRows = value;
+ }
+
+ public int OffsetColumns
+ {
+ get => offsetColumns;
+ set => offsetColumns = value;
+ }
+
+ int offsetColumns;
+ public Pair(int offsetRows, int offsetColumns)
+ {
+ this.offsetRows = offsetRows;
+ this.offsetColumns = offsetColumns;
+ }
+ }
+
+ Pair GetTableCC_WT_Offsets(int iTable)
+ {
+ switch (iTable)
+ {
+ case 0: return new Pair(0, 0);
+ case 1: return new Pair(20, 0);
+ case 2: return new Pair(40, 0);
+ case 3: return new Pair(56, 0);
+ default: return new Pair(0, 0);
+ }
+ }
+
+ Pair GetTableCC_Tempers_Offsets(int iTable)
+ {
+ switch (iTable)
+ {
+ case 0: return new Pair(56, 0);
+ case 1: return new Pair(76, 0);
+ case 2: return new Pair(96, 0);
+ case 3: return new Pair(116, 0);
+ case 4: return new Pair(206, 0);
+ case 5: return new Pair(226, 0);
+ case 6: return new Pair(246, 0);
+ case 7: return new Pair(266, 0);
+ case 8: return new Pair(286, 0);
+ default: return new Pair(56, 0);
+ }
+ }
+ Pair GetTableCC_Press_Offsets(int iTable)
+ {
+ switch (iTable)
+ {
+ case 0: return new Pair(326, 0);
+ case 1: return new Pair(346, 0);
+ case 2: return new Pair(366, 0);
+ default: return new Pair(326, 0);
+ }
+ }
+ Pair GetTableCC_Diverter_Offsets(int iTable)
+ {
+ switch (iTable)
+ {
+ case 0: return new Pair(146, 0);
+ case 1: return new Pair(158, 0);
+ case 2: return new Pair(170, 0);
+ case 3: return new Pair(182, 0);
+ case 4: return new Pair(194, 0);
+ default: return new Pair(146, 0);
+ }
+ }
private void uncertainty_button_Click(object sender, EventArgs data)
{
- //get list
- if (listView1.Items.Count < 1)
- {
- MessageBox.Show("No selected results to calculate uncertainty!");
- return;
- }
+ //get list
+ if (listView1.Items.Count < 1)
+ {
+ MessageBox.Show("No selected results to calculate uncertainty!");
+ return;
+ }
- IList selectedBatches = new List();
-
- foreach (ListViewItem item in listView1.Items)
- {
- int iBatch = Int32.Parse(item.Text);
- foreach (Batch b in batches)
- {
- if (b.BatchNr == iBatch)
- {
- selectedBatches.Add(b);
- break;
- }
- }
- }
+ IList selectedBatches = new List();
- if (selectedBatches.Count == 0)
- {
- MessageBox.Show("Selected results no fit with results to calculate uncertainty!");
- return;
- }
+ foreach (ListViewItem item in listView1.Items)
+ {
+ int iBatch = Int32.Parse(item.Text);
+ foreach (Batch b in batches)
+ {
+ if (b.BatchNr == iBatch)
+ {
+ selectedBatches.Add(b);
+ break;
+ }
+ }
+ }
- RigUncertainty rigUncertainty = null;
- try
- {
- string pathToTemplateExcel = Path.Combine("C:\\Users\\micha\\Downloads", "Uncertainty_template.xlsx");
- string pathToTestExcel = Path.Combine("C:\\Users\\micha\\Downloads", "Uncertainty_generated.xlsx");
- CopyTemplate(pathToTemplateExcel, pathToTestExcel);
- rigUncertainty = new RigUncertainty(pathToTestExcel);
- rigUncertainty.OpenDocument();
+ if (selectedBatches.Count == 0)
+ {
+ MessageBox.Show("Selected results no fit with results to calculate uncertainty!");
+ return;
+ }
- if (!rigUncertainty.IsOpenedDocument)
- {
- throw new Exception("Problem with open document!");
- }
+ RigUncertainty rigUncertainty = null;
+ try
+ {
+ string pathToTemplateExcel = Path.Combine("C:\\Users\\micha\\Downloads", "Uncertainty_template.xlsx");
+ string pathToTestExcel = Path.Combine("C:\\Users\\micha\\Downloads", "Uncertainty_generated.xlsx");
+ CopyTemplate(pathToTemplateExcel, pathToTestExcel);
+ rigUncertainty = new RigUncertainty(pathToTestExcel);
+ rigUncertainty.OpenDocument();
- int iBlock = 0;
- foreach (Batch b in selectedBatches)
- {
- int iRow = 0;
- int iStart = CommonExcell.GetBolocs()[iBlock];
- //calculate
- foreach (TestRslt testRslt in b.TestRslts)
- {
- if (!testRslt.TestDone)
- {
- continue;
- }
-
- ProcessDataLine processDataLine = new ProcessDataLine();
- processDataLine.Init(testRslt);
- CommonExcell.InsertValueLineProcessData(rigUncertainty, iStart + iRow, processDataLine);
- iRow++;
- if (iRow > 16) // Max count
- {
- break;
- }
- }
+ if (!rigUncertainty.IsOpenedDocument)
+ {
+ throw new Exception("Problem with open document!");
+ }
- iBlock++;
- }
- }
- catch (Exception e)
- {
- MessageBox.Show("Proble in process calculate uncertainty! Detail: " + e.Message);
- return;
- }
- finally
- {
- if (rigUncertainty != null)
- {
- rigUncertainty.SaveChangesToDocument();
- rigUncertainty.CloaseDocument();
- MessageBox.Show("Uncertainty document generated!");
- }
- }
+ //Insert Data to worksheet Excel
+ int iBlock = 0;
+ foreach (Batch b in selectedBatches)
+ {
+ int iRow = 0;
+ int iStart = CommonExcell.GetBolocs()[iBlock];
+ //calculate
+ foreach (TestRslt testRslt in b.TestRslts)
+ {
+ if (!testRslt.TestDone)
+ {
+ continue;
+ }
+
+ ProcessDataLine processDataLine = new ProcessDataLine();
+ processDataLine.Init(testRslt);
+ CommonExcell.InsertValueLineProcessData(rigUncertainty, iStart + iRow, processDataLine);
+ iRow++;
+ if (iRow > 16) // Max count
+ {
+ break;
+ }
+ }
+
+ iBlock++;
+ }
+
+ //Insert Metrology Data to worksheet Excel
+ //Get r.Batch => s.BatchPaths
+ sessionDBConfig = TBF.DB.CreateSession(DBKind.Config);
+
+ cmpntEntities = sessionDBConfig.QueryOver()
+ .OrderBy(x => x.ItemNr).Asc
+ .List();
+
+ IList tables = new List();
+ int iTable_WT = 0;
+ int tempMetersCount = 0;
+ int divertersCount = 0;
+ foreach (var cmpnt in cmpntEntities)
+ {
+ Rig.Generic.IComponentFactory factory = TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName);
+ /// Tab-pages for scales
+ if (factory is Rig.Scales.MettlerToledo.Factory ||
+ factory is Rig.MettlerToledo.Standard.BalanceFactory ||
+ factory is Rig.MettlerToledo.Standard.BalanceOldFactory ||
+ factory is Rig.MettlerToledo.Standard.BalanceNewFactory)
+ {
+ IScaleCfg BalanceCfg =
+ factory.CmpntCfgFromCmpntEntity(cmpnt) as IScaleCfg;
+ Pair pair = GetTableCC_WT_Offsets(iTable_WT);
+ tables.Add(InsertMetrologyDataWT(BalanceCfg,pair));
+ iTable_WT++;
+ }
+ /// Tab-pages for temperature meters
+ else if (factory is Rig.Modbus.TempMeter.Groch.Factory ||
+ factory is Rig.Modbus.TempMeter.Meret.Factory ||
+ factory is Rig.Keithley.TempMeter.Factory)
+ {
+ ICalibInfoCfg calibInfoCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as ICalibInfoCfg;
+ Pair pair = GetTableCC_Tempers_Offsets(tempMetersCount);
+ tables.Add(InsertMetrologyDataTemper(calibInfoCfg,pair));
+ tempMetersCount++;
+ }
+ /// Tab-pages for diverters
+ else if (factory is Rig.Uni.Diverter.Factory)
+ {
+ ICalibInfoCfg calibInfoCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as Rig.GenericDevices.ICalibInfoCfg;
+ Pair pair = GetTableCC_Diverter_Offsets(divertersCount);
+ tables.Add(InsertMetrologyDataDiverter(calibInfoCfg,pair));
+ divertersCount++;
+ }
+ }
+
+ IXLWorksheet worksheet = rigUncertainty.GetWorksheet(DocumentSheets.CC);
+ foreach (Table table in tables)
+ {
+ table.ToWorksheetWithOffset(worksheet, table.IOffsetRows, table.IOffsetColumns,false);
+ }
+
+
+ sessionDBConfig.Close();
+ }
+ catch (Exception e)
+ {
+ MessageBox.Show("Proble in process calculate uncertainty! Detail: " + e.Message);
+ return;
+ }
+ finally
+ {
+ if (rigUncertainty != null)
+ {
+ rigUncertainty.SaveChangesToDocument();
+ rigUncertainty.CloaseDocument();
+ MessageBox.Show("Uncertainty document generated!");
+ }
+ }
}
+
+
private void CopyTemplate(string pathToTemplateExcel, string pathToTestExcel)
{
- try
- {
- File.Copy(pathToTemplateExcel, pathToTestExcel, true);
- log.Info("Template File copied.");
- }
- catch (IOException ex)
- {
- log.Error("IO error: " + ex.Message);
- }
- catch (UnauthorizedAccessException ex)
- {
- log.Error("Access denied: " + ex.Message);
- }
+ try
+ {
+ File.Copy(pathToTemplateExcel, pathToTestExcel, true);
+ log.Info("Template File copied.");
+ }
+ catch (IOException ex)
+ {
+ log.Error("IO error: " + ex.Message);
+ }
+ catch (UnauthorizedAccessException ex)
+ {
+ log.Error("Access denied: " + ex.Message);
+ }
}
private void uncertainty_clear_button_Click(object sender, EventArgs e)
{
- listView1.Items.Clear();
+ listView1.Items.Clear();
}
- }
-}
+
+ ///
+ /// Inserts metrology data into a specified row of the Excel document.
+ ///
+ /// An instance of the class representing the rig uncertainty and the associated document.
+ ///
+ /// The row index in the Excel worksheet where the data will be inserted.
+ /// An instance of the class containing the metrology data to be inserted.
+ public static Results.Uncertainty.CommonTable.Table InsertMetrologyDataWT(IScaleCfg balanceCfg, Pair offsetPair)
+ {
+ //Define Scale meters 3x
+ var table = new Results.Uncertainty.CommonTable.Table();
+ table.IOffsetRows = offsetPair.OffsetRows;
+ table.IOffsetColumns = offsetPair.OffsetColumns;
+
+ string Column = "A";
+ table.AddColumn(Column);
+ for (int i = 0; i < 12; i++) //generate B - M Columns
+ {
+ Column = CommonExcell.NextColumn(Column);
+ table.AddColumn(Column);
+ }
+
+ for (int i = 0; i < 14; i++) //generate 14 rows
+ {
+ table.AddRow((i + 1).ToString());
+ }
+
+ //Set cell values
+ table.AddCell(1, "B", "C"); // Uncertainty type
+ table.AddCell(1, "D", balanceCfg.MeterType); //"ISNJ"); //Type
+ table.AddCell(1, "F", balanceCfg.MeterSerialNo); //Serial Nr
+ table.AddCell(1, "J", 3000); //balanceCfg.); //J - range [kg]
+
+ //Set cell values
+ table.AddCell(2, "B", balanceCfg.Name); // Scale Name
+ table.AddCell(2, "D", balanceCfg.CalibCertificateNr); //Cal. Cert
+ table.AddCell(2, "F", balanceCfg.CalibCertificateNr); //Nr
+ table.AddCell(2, "I", balanceCfg.BuoyancyTemp); //I - Amb.T
+ table.AddCell(2, "K", balanceCfg.BuoyancyHumi); //I - Amb.H
+ table.AddCell(2, "M", balanceCfg.BuoyancyPress); //I - Amb.P
+
+ //Set cell values
+ table.AddCell(3, "C", balanceCfg.CalibDate); // Date - datetime - format
+
+
+ //Load, Error, Readability, Uncertainty
+ //Set cell values
+ string columnName = "B";
+ foreach (var correction in balanceCfg.Corrections)
+ {
+ if (correction != null)
+ {
+ table.AddCell(4, columnName, correction.Measurement); // Load
+ double error = Formulas.ErrorFromVolumes(correction.Measurement,
+ correction.Measurement + correction.Correction);
+ table.AddCell(5, columnName, error); // ERROR
+ table.AddCell(7, columnName, correction.Readability); // Readability
+ table.AddCell(8, columnName, correction.Uncertainty); // Uncertainty
+ columnName = CommonExcell.NextColumn(columnName);
+ }
+
+ if (columnName == "L") // maximum column
+ {
+ break;
+ }
+ }
+
+
+ return table;
+ }
+
+ ///
+ /// Inserts metrology data into a specified row of the Excel document.
+ ///
+ /// An instance of the class representing the rig uncertainty and the associated document.
+ ///
+ /// The row index in the Excel worksheet where the data will be inserted.
+ /// An instance of the class containing the metrology data to be inserted.
+ public static Results.Uncertainty.CommonTable.Table InsertMetrologyDataTemper(ICalibInfoCfg calibInfoCfg, Pair offsetPair)
+ {
+
+ //Define Temper meter table
+ var table = new Results.Uncertainty.CommonTable.Table();
+ table.IOffsetRows = offsetPair.OffsetRows;
+ table.IOffsetColumns = offsetPair.OffsetColumns;
+
+ string Column = "A";
+ table.AddColumn(Column);
+ for (int i = 0; i < 12; i++) //generate B - M Columns
+ {
+ Column = CommonExcell.NextColumn(Column);
+ table.AddColumn(Column);
+ }
+
+ for (int i = 0; i < 14; i++) //generate 14 rows
+ {
+ table.AddRow((i + 1).ToString());
+ }
+
+ //Set cell values
+ table.AddCell(1, "B", "N"); // Uncertainty type
+ table.AddCell(1, "D", calibInfoCfg.MeterType); //"ISNJ"); //Type
+ table.AddCell(1, "F", calibInfoCfg.MeterSerialNo); //Serial Nr
+
+ try
+ {
+ if (calibInfoCfg is TBF.Rig.Keithley.TempMeter.TempMeterCfg)
+ {
+ table.AddCell(1, "G", string.Format("Ch{0}",
+ (calibInfoCfg as TBF.Rig.Keithley.TempMeter.TempMeterCfg)
+ .Channel)); //J -chanel
+ }
+ else if (calibInfoCfg is TBF.Rig.Modbus.TempMeter.Groch.TempMeterCfg)
+ {
+ table.AddCell(1, "G", string.Format("Ch{0}",
+ (calibInfoCfg as TBF.Rig.Modbus.TempMeter.Groch.TempMeterCfg)
+ .Channel)); //J -chanel
+ }
+ else if (calibInfoCfg is TBF.Rig.Modbus.TempMeter.Meret.TempMeterCfg)
+ {
+ table.AddCell(1, "G", string.Format("Addr{0}",
+ (calibInfoCfg as TBF.Rig.Modbus.TempMeter.Meret.TempMeterCfg)
+ .ModbusAddress)); //balanceCfg.); //J -chanel
+ }
+ }
+ catch (Exception e)
+ {
+ log.Error("Chanel info failed! Detail: " + e.Message);
+ return null;
+ }
+
+
+ //Set cell values
+ table.AddCell(2, "A", calibInfoCfg.Name); // Scale Name
+ table.AddCell(2, "C", calibInfoCfg.CalibDate); // Date - datetime - format
+ table.AddCell(2, "F", calibInfoCfg.CalibCertificateNr); //Cal. Cert
+
+
+
+ //Load, Error, Readability, Uncertainty
+ //Set cell values
+ string columnName = "B";
+ foreach (var correction in calibInfoCfg.Corrections)
+ {
+ if (correction != null)
+ {
+ table.AddCell(4, columnName, correction.Measurement); // Load
+ double error = Formulas.ErrorFromVolumes(correction.Measurement,
+ correction.Measurement + correction.Correction);
+ table.AddCell(5, columnName, error); // ERROR
+ table.AddCell(7, columnName, correction.Readability); // Readability
+ table.AddCell(8, columnName, correction.Uncertainty); // Uncertainty
+ columnName = CommonExcell.NextColumn(columnName);
+ }
+
+ if (columnName == "L") // maximum column
+ {
+ break;
+ }
+ }
+
+
+ return table;
+ }
+
+ public static Results.Uncertainty.CommonTable.Table InsertMetrologyDataDiverter(ICalibInfoCfg calibInfoCfg, Pair offsetPair)
+ {
+
+ //Define Temper meter table
+ var table = new Results.Uncertainty.CommonTable.Table();
+ table.IOffsetRows = offsetPair.OffsetRows;
+ table.IOffsetColumns = offsetPair.OffsetColumns;
+
+ string Column = "A";
+ table.AddColumn(Column);
+ for (int i = 0; i < 6; i++) //generate B - F Columns
+ {
+ Column = CommonExcell.NextColumn(Column);
+ table.AddColumn(Column);
+ }
+
+ for (int i = 0; i < 2; i++) //generate 2 rows
+ {
+ table.AddRow((i + 1).ToString());
+ }
+
+
+
+ //Load, Error, Readability, Uncertainty
+ //Set cell values
+ string columnName = "B";
+ foreach (var correction in calibInfoCfg.Corrections)
+ {
+ if (correction != null)
+ {
+ table.AddCell(1, columnName, correction.Measurement); // Load
+ double error = Formulas.ErrorFromVolumes(correction.Measurement,
+ correction.Measurement + correction.Correction);
+ table.AddCell(2, columnName, error); // ERROR
+ //table.AddCell(7, columnName, correction.Readability); // Readability
+ //table.AddCell(8, columnName, correction.Uncertainty); // Uncertainty
+ columnName = CommonExcell.NextColumn(columnName);
+ }
+
+ if (columnName == "L") // maximum column
+ {
+ break;
+ }
+ }
+
+
+ return table;
+ }
+ }
+}
\ No newline at end of file
diff --git a/TBF/UI/ResultsMI/PreviousResultsDlgUncertainty.resx b/TBF/UI/ResultsMI/PreviousResultsDlgUncertainty.resx
index 1af7de150..d5a483d6f 100644
--- a/TBF/UI/ResultsMI/PreviousResultsDlgUncertainty.resx
+++ b/TBF/UI/ResultsMI/PreviousResultsDlgUncertainty.resx
@@ -1,120 +1,125 @@
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral,
+ PublicKeyToken=b77a5c561934e089
+
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral,
+ PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/TBF/packages.config b/TBF/packages.config
index ee65a1cde..e28fad99b 100644
--- a/TBF/packages.config
+++ b/TBF/packages.config
@@ -1,12 +1,20 @@
+
+
+
+
+
+
+
+
diff --git a/TBFTests/TBFTests.csproj b/TBFTests/TBFTests.csproj
index 7577ee14e..1e766e224 100644
--- a/TBFTests/TBFTests.csproj
+++ b/TBFTests/TBFTests.csproj
@@ -92,6 +92,7 @@
..\packages\System.Buffers.4.6.1\lib\net462\System.Buffers.dll
+
..\packages\System.Memory.4.6.2\lib\net462\System.Memory.dll
@@ -129,6 +130,7 @@
+
diff --git a/TBFTests/Uncertainty/CommonTable/TableTest.cs b/TBFTests/Uncertainty/CommonTable/TableTest.cs
new file mode 100644
index 000000000..6e3c95467
--- /dev/null
+++ b/TBFTests/Uncertainty/CommonTable/TableTest.cs
@@ -0,0 +1,108 @@
+using ClosedXML.Excel;
+using JetBrains.Annotations;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Results.Uncertainty;
+using Results.Uncertainty.CommonTable;
+
+namespace TBFTests.Uncertainty.CommonTable
+{
+ [TestClass]
+ [TestSubject(typeof(Table))]
+ public class TableTest
+ {
+
+ [TestMethod]
+ public void CrateTableTest()
+ {
+ var wb = new XLWorkbook();
+ var ws = wb.AddWorksheet("Demo");
+
+ var table = new Table();
+
+// name your columns up front (optional)
+ table.AddColumn("Product");
+ table.AddColumn("Price");
+
+// add a row
+ int row0 = table.AddRow();
+ table.AddCell(row0, "Product", "Widget");
+ table.AddCell(row0, "Price", 9.99);
+
+// another row
+ int row1 = table.AddRow("Second row");
+ table.AddCell(row1, 0, "Gadget"); // by index
+ table.AddCell(row1, 1, 19.49);
+
+// dump into sheet (with headers)
+ table.ToWorksheet(ws, includeHeaders: true);
+
+
+ // sheet check:
+ ws.Cell(2, 1).Value.Equals(table.GetCell(row0,0).Value); // A2
+ ws.Cell(3, 2).Value.Equals(table.GetCell(row1,1).Value); // B2
+
+ }
+
+
+
+ [TestMethod]
+ public void CrateTableOnPositionTest()
+ {
+ var wb = new XLWorkbook();
+ var ws = wb.AddWorksheet("Demo");
+
+ var table = new Table();
+
+// name your columns up front (optional)
+ string Column = "A";
+ table.AddColumn(Column);
+ Column = CommonExcell.NextColumn(Column);
+ table.AddColumn(Column);
+ Column = CommonExcell.NextColumn(Column);
+ table.AddColumn(Column);
+
+// add a row
+ int row0 = table.AddRow();
+ table.AddCell(row0, "A", "Widget");
+ table.AddCell(row0, "B", 9.99);
+ table.AddCell(row0, "C", 89.93);
+// add a row
+ int row1 = table.AddRow();
+ table.AddCell(row0, "A", "Temp");
+ table.AddCell(row0, "B", 169.99);
+ table.AddCell(row0, "C", 88.01);
+
+// another row by index
+ int row2 = table.AddRow("Another row");
+ table.AddCell(row1, 0, "Gadget"); // by index
+ table.AddCell(row1, 1, 19.49);
+ table.AddCell(row1, 2, 21.49);
+
+// dump into sheet (with headers)
+ table.ToWorksheet(ws, includeHeaders: true);
+
+
+ // sheet check:
+ ws.Cell(2, 1).Value.Equals(table.GetCell(row0,0).Value); // A2
+ ws.Cell(3, 2).Value.Equals(table.GetCell(row1,1).Value); // B3
+ ws.Cell(4, 3).Value.Equals(table.GetCell(row2,2).Value); // C4
+
+ table.ToWorksheet(ws, includeHeaders: false);
+
+ // sheet check:
+ ws.Cell(1, 1).Value.Equals(table.GetCell(row0,0).Value); // A2
+ ws.Cell(2, 2).Value.Equals(table.GetCell(row1,1).Value); // B3
+ ws.Cell(3, 3).Value.Equals(table.GetCell(row2,2).Value); // C4
+
+ int iOffsetRow = 10;
+ int iOffsetCol = 2;
+ table.ToWorksheetWithOffset(ws, iOffsetRow, iOffsetCol, includeHeaders: false);
+
+ // sheet check:
+ ws.Cell(1 + iOffsetRow, 1 + iOffsetCol).Value.Equals(table.GetCell(row0,0).Value); // A2 + offset
+ ws.Cell(2 + iOffsetRow, 2 + iOffsetCol).Value.Equals(table.GetCell(row1,1).Value); // B3 + offset
+ ws.Cell(3 + iOffsetRow, 3 + iOffsetCol).Value.Equals(table.GetCell(row2,2).Value); // C4 + offset
+
+ }
+ }
+}
\ No newline at end of file
| | | |