diff --git a/TestBenchFramework/BenchControl/DB/SensusOracle/Database.cs b/TestBenchFramework/BenchControl/DB/SensusOracle/Database.cs
index 057ebaec2..48827b379 100644
--- a/TestBenchFramework/BenchControl/DB/SensusOracle/Database.cs
+++ b/TestBenchFramework/BenchControl/DB/SensusOracle/Database.cs
@@ -27,30 +27,26 @@ namespace TBF.BenchControl.DB.SensusOracle
const int Anbid_StaraTura = 4;
readonly DatabaseCfg dbCfg;
- OracleConnection conn; /// Oracle database connection
+ string separatorStr;
+
+ OracleConnection conn; /// Oracle database connection
///
/// Result items to print
///
- IList resultItems;
- bool combined;
+ IList rsltItems;
///
/// Results to print
///
- Procedure procedure;
- IList waterMeters;
- IList unsortedResults;
- DateTime dateTime;
+ Results.Entities.Batch batch;
+
StreamWriter writer;
bool batchDataSaved; /// This is to save batch data (VT_PRUEFREIHE_PD) only once
- string separatorStr;
- public Database()
- {
- }
+ public Database() {}
public Database(DatabaseCfg cfg)
: base(cfg)
@@ -187,31 +183,22 @@ namespace TBF.BenchControl.DB.SensusOracle
/// Procedure to print the results of
/// Results to write into the file
/// Reference to the operation
- public IOperation WriteResultsOp(string TestBenchId, Procedure procedure, IList waterMeters, IList unsortedResults)
+ public IOperation WriteResultsOp(Results.Entities.Batch batch)
{
- if ((procedure == null) || (unsortedResults == null) || (unsortedResults.Count < 1))
- {
- return null;
- }
+ this.batch = batch;
- this.procedure = procedure;
- this.waterMeters = waterMeters;
- this.unsortedResults = unsortedResults;
-
- combined = (procedure.MetersKind == MetersKind.Combined);
- if (combined)
+ if (batch.WaterMeters.Count > 0 && !batch.WaterMeters[0].Compound())
{
- resultItems = Config.ResultItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Disk_CombinedWM);
+ rsltItems = Results.ItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Printer_SingleWM);
}
else
{
- resultItems = Config.ResultItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Disk_SingleWM);
+ rsltItems = Results.ItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Printer_CombinedWM);
}
try
{
- dateTime = DateTime.Now;
- writer = new StreamWriter(System.IO.File.Create(GetFilename(dateTime)));
+ writer = new StreamWriter(System.IO.File.Create(GetFilename(batch.EndTime)));
}
catch
{
@@ -259,7 +246,7 @@ namespace TBF.BenchControl.DB.SensusOracle
///----------
/// Header
///----------
- writer.WriteLine(unsortedResults[0].ProtocolTitle);
+ writer.WriteLine(batch.ProtocolTitle);
writer.WriteLine(string.Empty);
string[] leftColumn = new string[]
@@ -275,18 +262,18 @@ namespace TBF.BenchControl.DB.SensusOracle
string[] rightColumn = new string[]
{
- unsortedResults[0].BatchNr.ToString(),
- //dateTime.ToShortDateString() + " " + dateTime.ToShortTimeString(),
- string.Format("{0}.{1}.{2} {3}:{4}", dateTime.Year.ToString("D4"),
- dateTime.Month.ToString("D2"),
- dateTime.Day.ToString("D2"),
- dateTime.Hour.ToString("D2"),
- dateTime.Minute.ToString("D2")),
- procedure.Name,
- User.CurrentUser.Name,
- unsortedResults[0].AmbientTempAve.ToString("F1") + " °C",
- unsortedResults[0].AmbientPressAve.ToString("F0") + " mbar",
- unsortedResults[0].AmbientHumiAve.ToString("F0") + " %",
+ batch.BatchNr.ToString(),
+ //batch.EndTime.ToShortDateString() + " " + batch.EndTime.ToShortTimeString(),
+ string.Format("{0}.{1}.{2} {3}:{4}", batch.EndTime.Year.ToString("D4"),
+ batch.EndTime.Month.ToString("D2"),
+ batch.EndTime.Day.ToString("D2"),
+ batch.EndTime.Hour.ToString("D2"),
+ batch.EndTime.Minute.ToString("D2")),
+ batch.ProcedureName,
+ batch.UserName,
+ batch.AmbientTempAve().ToString("F1") + " °C",
+ batch.AmbientPressAve().ToString("F0") + " mbar",
+ batch.AmbientHumiAve().ToString("F0") + " %",
};
/// Determine max. left column width in characters
@@ -302,22 +289,11 @@ namespace TBF.BenchControl.DB.SensusOracle
}
writer.WriteLine(string.Empty);
- /// Write text body to a disk file
- if (combined)
- {
- for (int wmNr = 0; wmNr < Config.Data.CompoundWMsCount; wmNr++) WriteCombinedWM(wmNr + 1); /// wmNr is 0-based
- }
- else
- {
- for (int wmNr = 0; wmNr < Config.Data.WMsCount; wmNr++) /// wmNr is 0-based
- {
- if (!unsortedResults[0].Meters[wmNr].Disabled)
- {
- IList results = Utils.GetSortedTestResults(procedure, unsortedResults, Utils.PartNr(wmNr + 1, combined));
- WriteSingleWM(wmNr, wmNr + 1, results);
- }
- }
- }
+
+ ///--------
+ /// Body
+ ///--------
+ foreach (var wm in batch.WaterMeters) WriteWM(wm);
/// Close the file
writer.Close();
@@ -333,6 +309,141 @@ namespace TBF.BenchControl.DB.SensusOracle
}
+ ///
+ /// Write one water meter results
+ ///
+ /// Water meter number (0-based)
+ void WriteWM(Results.Entities.WaterMeter wm)
+ {
+ /// Determine column widths
+ int[] columnWidths = new int[rsltItems.Count];
+ int totalWidth = 0;
+ for (int i = 0; i < rsltItems.Count; i++)
+ {
+ columnWidths[i] = ElSpaces(rsltItems[i].ClmnHeaderText).Length;
+ foreach (var mtr in wm.MeterTestRslts)
+ {
+ string itemText;
+
+ if (!wm.Compound())
+ {
+ /// Single water meter
+ itemText = rsltItems[i].Print(mtr);
+ }
+ else if (mtr.CompoundMeterId == (byte)CompoundMeterId.Compound)
+ {
+ Results.Entities.MeterTestRslt mainMtr = wm.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundMain);
+ Results.Entities.MeterTestRslt auxMtr = wm.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundAux);
+ itemText = rsltItems[i].PrintCombined(mainMtr, auxMtr, mtr);
+ }
+ else
+ {
+ continue;
+ }
+
+ /// Strip color information
+ string[] texts = itemText.Split(new char[] { '|' });
+ if (texts.Length == 2) { itemText = texts[0]; }
+
+ int len = ElSpaces(itemText).Length;
+ if (len > columnWidths[i]) columnWidths[i] = len;
+ }
+ totalWidth += columnWidths[i];
+ }
+ totalWidth += 3 * (rsltItems.Count - 1);
+ if (totalWidth < 0) totalWidth = 0;
+
+
+ /// Write water meter number and s/n
+ writer.Write(string.Format("Water meter {0}", wm.WMPosition));
+ if (!string.IsNullOrEmpty(wm.SerialNr)) writer.Write(string.Format(" s/n: {0}", wm.SerialNr));
+ writer.WriteLine(string.Empty);
+
+
+ writer.WriteLine(new String('-', totalWidth)); /// Horizontal line above the header
+
+
+ /// Write column headers
+ for (int i = 0; i < rsltItems.Count; i++)
+ {
+ writer.Write(ElSpaces(rsltItems[i].ClmnHeaderText));
+
+ if (i < rsltItems.Count - 1)
+ {
+ if (!dbCfg.EliminateSpaces)
+ {
+ writer.Write(new string(' ', columnWidths[i] - rsltItems[i].ClmnHeaderText.Length + 3));
+ }
+ writer.Write(separatorStr);
+ }
+ else
+ {
+ writer.WriteLine(string.Empty);
+ }
+ }
+
+
+ writer.WriteLine(new String('-', totalWidth)); /// Horizontal line between the header and the body
+
+
+ /// Write table data
+ foreach (var mtr in wm.MeterTestRslts)
+ {
+ if (mtr != null)
+ {
+ for (int i = 0; i < rsltItems.Count; i++)
+ {
+ string itemText;
+
+ ///
+ /// Fetch an item
+ ///
+ if (!wm.Compound())
+ {
+ /// Single water meter
+ itemText = rsltItems[i].Print(mtr);
+ }
+ else if (mtr.CompoundMeterId == (byte)CompoundMeterId.Compound)
+ {
+ Results.Entities.MeterTestRslt mainMtr = wm.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundMain);
+ Results.Entities.MeterTestRslt auxMtr = wm.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundAux);
+ itemText = rsltItems[i].PrintCombined(mainMtr, auxMtr, mtr);
+ }
+ else
+ {
+ continue;
+ }
+
+ ///
+ /// Print the item
+ ///
+ string[] texts = itemText.Split(new char[] { '|' });
+ if (texts.Length == 2) { itemText = texts[0]; } /// Strip color information
+
+ writer.Write(ElSpaces(itemText));
+
+ if (i < rsltItems.Count - 1)
+ {
+ if (!dbCfg.EliminateSpaces)
+ {
+ writer.Write(new string(' ', columnWidths[i] - itemText.Length + 3));
+ }
+ writer.Write(separatorStr);
+ }
+ else
+ {
+ writer.WriteLine(string.Empty);
+ }
+ }
+ }
+ }
+
+ writer.WriteLine(new String('-', totalWidth)); /// Horizontal line below the body
+
+ writer.WriteLine(string.Empty);
+ }
+
+
Retv WriteResultsToDatabase()
{
batchDataSaved = false;
@@ -637,210 +748,5 @@ namespace TBF.BenchControl.DB.SensusOracle
transaction.Rollback();
}
}
-
-
- ///
- /// Write one water meter results into a file
- ///
- /// Water meter number (0-based)
- void WriteSingleWM(int wmNr, int printedWMNr, IList results)
- {
- /// Determine column widths
- int[] columnWidths = new int[resultItems.Count];
- int totalWidth = 0;
- for (int i = 0; i < resultItems.Count; i++)
- {
- columnWidths[i] = ElSpaces(resultItems[i].ClmnHeaderText).Length;
- foreach (var tr in results)
- {
- if (tr != null)
- {
- string text = resultItems[i].Print(tr.Meters[wmNr]);
-
- /// Get rid of the color information
- string[] texts = text.Split(new char[] { '|' });
- if (texts.Length == 2) { text = texts[0]; }
-
- int len = ElSpaces(text).Length;
- if (len > columnWidths[i]) columnWidths[i] = len;
- }
- }
- totalWidth += columnWidths[i];
- }
- totalWidth += 3 * (resultItems.Count - 1);
-
-
- /// Write water meter number and s/n
- writer.Write(string.Format("Water meter {0}", printedWMNr));
- if (!string.IsNullOrEmpty(unsortedResults[0].Meters[wmNr].SerialNr))
- {
- writer.Write(string.Format(" s/n: {0}", unsortedResults[0].Meters[wmNr].SerialNr));
- }
- writer.WriteLine(string.Empty);
-
-
- writer.WriteLine(new String('-', totalWidth)); /// Horizontal line above the header
-
-
- /// Write column headers
- for (int i = 0; i < resultItems.Count; i++)
- {
- writer.Write(ElSpaces(resultItems[i].ClmnHeaderText));
-
- if (i < resultItems.Count - 1)
- {
- if (!dbCfg.EliminateSpaces)
- {
- writer.Write(new string(' ', columnWidths[i] - resultItems[i].ClmnHeaderText.Length + 3));
- }
- writer.Write(separatorStr);
- }
- else
- {
- writer.WriteLine(string.Empty);
- }
- }
-
-
- writer.WriteLine(new String('-', totalWidth)); /// Horizontal line between the header and the body
-
-
- /// Write table data
- foreach (var tr in results)
- {
- if (tr != null)
- {
- for (int i = 0; i < resultItems.Count; i++)
- {
- string text = resultItems[i].Print(tr.Meters[wmNr]);
-
- /// Get rid of the color information
- string[] texts = text.Split(new char[] { '|' });
- if (texts.Length == 2) { text = texts[0]; }
-
- writer.Write(ElSpaces(text));
-
- if (i < resultItems.Count - 1)
- {
- if (!dbCfg.EliminateSpaces)
- {
- writer.Write(new string(' ', columnWidths[i] - text.Length + 3));
- }
- writer.Write(separatorStr);
- }
- else
- {
- writer.WriteLine(string.Empty);
- }
- }
- }
- }
-
-
- writer.WriteLine(new String('-', totalWidth)); /// Horizontal line below the body
-
- writer.WriteLine(string.Empty);
- }
-
- ///
- /// Write one combined water meter results
- ///
- /// Combined water meter number (1-based)
- void WriteCombinedWM(int wmNr1)
- {
- IList results = Utils.GetSortedTestResults(procedure, unsortedResults, Utils.PartNr(wmNr1, combined));
-
- /// Determin column widths
- int[] columnWidths = new int[resultItems.Count];
- int totalWidth = 0;
- for (int i = 0; i < resultItems.Count; i++)
- {
- columnWidths[i] = ElSpaces(resultItems[i].ClmnHeaderText).Length;
- foreach (var tr in results)
- {
- if (tr != null)
- {
- string text = resultItems[i].PrintCombined(tr.Meters[2 * wmNr1 - 2], tr.Meters[2 * wmNr1 - 1], tr.CombinedMeters[wmNr1 - 1]);
- int len = ElSpaces(text).Length;
- if (len > columnWidths[i]) columnWidths[i] = len;
- }
- }
- totalWidth += columnWidths[i];
- }
- totalWidth += 3 * (resultItems.Count - 1);
-
-
- /// Write water meter number and two s/n-s
- writer.Write(string.Format("Water meter {0}", wmNr1));
- if (!string.IsNullOrEmpty(unsortedResults[0].Meters[2 * wmNr1 - 2].SerialNr))
- {
- writer.Write(string.Format(", Main s/n: {0}", unsortedResults[0].Meters[2 * wmNr1 - 2].SerialNr));
- }
- if (!string.IsNullOrEmpty(unsortedResults[0].Meters[2 * wmNr1 - 1].SerialNr))
- {
- writer.Write(string.Format(", Aux. s/n:{0}", unsortedResults[0].Meters[2 * wmNr1 - 1].SerialNr));
- }
- writer.WriteLine(string.Empty);
-
-
- writer.WriteLine(new String('-', totalWidth)); /// Horizontal line above the header
-
-
- for (int i = 0; i < resultItems.Count; i++)
- {
- writer.Write(ElSpaces(resultItems[i].ClmnHeaderText));
-
- if (i < resultItems.Count - 1)
- {
- if (!dbCfg.EliminateSpaces)
- {
- writer.Write(new string(' ', columnWidths[i] - resultItems[i].ClmnHeaderText.Length + 3));
- }
- writer.Write(separatorStr);
- }
- else
- {
- writer.WriteLine(string.Empty);
- }
- }
-
-
- writer.WriteLine(new String('-', totalWidth)); /// Horizontal line between the header and the body
-
-
- foreach (var tr in results)
- {
- if (tr != null)
- {
- for (int i = 0; i < resultItems.Count; i++)
- {
- string text = resultItems[i].PrintCombined(tr.Meters[2 * wmNr1 - 2], tr.Meters[2 * wmNr1 - 1], tr.CombinedMeters[wmNr1 - 1]);
-
- /// Get rid of the color information
- string[] texts = text.Split(new char[] { '|' });
- if (texts.Length == 2) { text = texts[0]; }
-
- writer.Write(ElSpaces(text));
-
- if (i < resultItems.Count - 1)
- {
- if (!dbCfg.EliminateSpaces)
- {
- writer.Write(new string(' ', columnWidths[i] - text.Length + 3));
- }
- writer.Write(separatorStr);
- }
- else
- {
- writer.WriteLine(string.Empty);
- }
- }
- }
- }
-
- writer.WriteLine(new String('-', totalWidth)); /// Horizontal line below the body
-
- writer.WriteLine(string.Empty);
- }
}
}
diff --git a/TestBenchFramework/BenchControl/DataEntry/Standard24/EntryForm.cs b/TestBenchFramework/BenchControl/DataEntry/Standard24/EntryForm.cs
index 90777542f..4548f8add 100644
--- a/TestBenchFramework/BenchControl/DataEntry/Standard24/EntryForm.cs
+++ b/TestBenchFramework/BenchControl/DataEntry/Standard24/EntryForm.cs
@@ -188,7 +188,7 @@ namespace TBF.BenchControl.DataEntry.Standard24
{
purchaseOrder = dlg.PurchaseOrder;
- for (int i = 0; i < Math.Min(dlg.WaterMetersCount, waterMeters.Count); i++)
+ for (int i = 0; i < Math.Min(dlg.WaterMetersCount, waterMeters.Length); i++)
{
if (waterMeters[i] != null)
{
diff --git a/TestBenchFramework/BenchControl/DataEntry/iPerl/EntryForm.cs b/TestBenchFramework/BenchControl/DataEntry/iPerl/EntryForm.cs
index 27bdaeb17..f811706df 100644
--- a/TestBenchFramework/BenchControl/DataEntry/iPerl/EntryForm.cs
+++ b/TestBenchFramework/BenchControl/DataEntry/iPerl/EntryForm.cs
@@ -221,13 +221,11 @@ namespace TBF.BenchControl.DataEntry.iPerl
///
/// Watermetes with information entered in the forms
/// Test results to be updated with the information
- public void UpdateTestResults(Results.BatchResults results)
+ public void UpdateTestResults(Results.BatchResults batchResults)
{
- foreach (var testRslt in testResults)
+ foreach (var wm in batchResults.WaterMeters)
{
- if (testRslt.MetersKind != MetersKind.Single) continue;
-
- testRslt.PurchaseOrder = PurchaseOrder;
+ if (wm != null) wm.PurchaseOrder = PurchaseOrder;
}
}
}
diff --git a/TestBenchFramework/BenchControl/ResultsWriters/Basic/Writer.cs b/TestBenchFramework/BenchControl/ResultsWriters/Basic/Writer.cs
index 7ca253579..33a5a9bc4 100644
--- a/TestBenchFramework/BenchControl/ResultsWriters/Basic/Writer.cs
+++ b/TestBenchFramework/BenchControl/ResultsWriters/Basic/Writer.cs
@@ -29,13 +29,10 @@ namespace TBF.BenchControl.ResultsWriters.Basic
///
Results.Entities.Batch batch;
- DateTime dateTime;
StreamWriter writer;
- public Writer()
- {
- }
+ public Writer() {}
public Writer(WriterCfg cfg)
: base(cfg)
@@ -151,8 +148,7 @@ namespace TBF.BenchControl.ResultsWriters.Basic
try
{
- dateTime = batch.EndTime;
- writer = new StreamWriter(System.IO.File.Create(GetFilename(dateTime)));
+ writer = new StreamWriter(System.IO.File.Create(GetFilename(batch.EndTime)));
}
catch
{
@@ -187,12 +183,12 @@ namespace TBF.BenchControl.ResultsWriters.Basic
string[] rightColumn = new string[]
{
batch.BatchNr.ToString(),
- //dateTime.ToShortDateString() + " " + dateTime.ToShortTimeString(),
- string.Format("{0}.{1}.{2} {3}:{4}", dateTime.Year.ToString("D4"),
- dateTime.Month.ToString("D2"),
- dateTime.Day.ToString("D2"),
- dateTime.Hour.ToString("D2"),
- dateTime.Minute.ToString("D2")),
+ //batch.EndTime.ToShortDateString() + " " + batch.EndTime.ToShortTimeString(),
+ string.Format("{0}.{1}.{2} {3}:{4}", batch.EndTime.Year.ToString("D4"),
+ batch.EndTime.Month.ToString("D2"),
+ batch.EndTime.Day.ToString("D2"),
+ batch.EndTime.Hour.ToString("D2"),
+ batch.EndTime.Minute.ToString("D2")),
batch.ProcedureName,
batch.UserName,
batch.AmbientTempAve().ToString("F1") + " °C",
@@ -349,7 +345,6 @@ namespace TBF.BenchControl.ResultsWriters.Basic
}
}
-
writer.WriteLine(new String('-', totalWidth)); /// Horizontal line below the body
writer.WriteLine(string.Empty);
diff --git a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs
index bf7c2d68d..2e1ac27cd 100644
--- a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs
+++ b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs
@@ -620,7 +620,7 @@ namespace TBF.BenchControl.Sequences
{
/// Open the modeless form for the end of the cycle
State.Create("MainSeq : Enter end data")
- .AddOperation((dataEntryCmpnt as GenericDevices.IHasCycleEndForm).ShowCycleEndFormOp(WaterMeters))
+ .AddOperation((dataEntryCmpnt as GenericDevices.IHasCycleEndForm).ShowCycleEndFormOp())
.AddOperation(checkUiOp)
.EnterState();
do
@@ -639,6 +639,7 @@ namespace TBF.BenchControl.Sequences
dataEntryCmpnt.UpdateTestResults(BatchRslts);
}
+ ProcessData.BatchRslts.Batch.EndTime = DateTime.Now;
ProcessData.BatchRslts.AddWaterMetersToBatch();
//------------------------------------------------------