Output.FileWrites.Enhanced uses a list of commonItems, etc. (localization).
This commit is contained in:
@@ -19,14 +19,18 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
|
||||
readonly WriterCfg writerCfg;
|
||||
readonly string separatorStr;
|
||||
|
||||
/// <summary>
|
||||
/// Result items to print
|
||||
/// </summary>
|
||||
IList<Results.ItemSpec> rsltItems;
|
||||
readonly string header;
|
||||
readonly string footer;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Items to print
|
||||
///
|
||||
readonly IList<Results.WMeterRsltItemSpec> commonItems;
|
||||
readonly IList<Results.ItemSpec> testItems;
|
||||
|
||||
///
|
||||
/// Results to print
|
||||
/// </summary>
|
||||
///
|
||||
Results.Entities.Batch batch;
|
||||
|
||||
StreamWriter writer;
|
||||
@@ -50,7 +54,12 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
|
||||
case Separator.Semicolon: separatorStr = ";"; break;
|
||||
}
|
||||
|
||||
log.Debug(this.ToString());
|
||||
header = writerCfg.Header.Replace("~", "\r\n");
|
||||
commonItems = Results.WMeterRsltItemSpec.FromStrArray(writerCfg.CommonItems);
|
||||
testItems = Results.ItemSpec.FromStrArray(writerCfg.SelectedItems);
|
||||
footer = writerCfg.Footer.Replace("~", "\r\n");
|
||||
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
|
||||
@@ -160,8 +169,6 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
|
||||
return this;
|
||||
}
|
||||
|
||||
rsltItems = Results.ItemSpec.FromStrArray(writerCfg.SelectedItems);
|
||||
|
||||
writer = null;
|
||||
if (!string.IsNullOrEmpty(writerCfg.DestinationPath))
|
||||
{
|
||||
@@ -191,27 +198,19 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
|
||||
writer.WriteLine(batch.ProtocolTitle);
|
||||
writer.WriteLine(string.Empty);
|
||||
|
||||
string[] leftColumn = new string[]
|
||||
{
|
||||
// "Batch number: ",
|
||||
Strings.Date_and_time_ + " ",
|
||||
Strings.Procedure_ + " ",
|
||||
Strings.User_ + " ",
|
||||
Strings.Ambient_temperature_ + " ",
|
||||
Strings.Ambient_pressure_ + " ",
|
||||
Strings.Ambient_humidity_ + " ",
|
||||
};
|
||||
///----------------
|
||||
/// Common items
|
||||
///----------------
|
||||
string[] leftColumn = new string[commonItems.Count];
|
||||
string[] rightColumn = new string[commonItems.Count];
|
||||
|
||||
string[] rightColumn = new string[]
|
||||
{
|
||||
// batch.BatchNr.ToString(),
|
||||
string.Format("{0:yyyy.MM.dd hh:mm}", batch.EndTime),
|
||||
batch.ProcedureName,
|
||||
batch.UserName,
|
||||
batch.AmbientTempAve().ToString("F1") + " °C",
|
||||
batch.AmbientPressAve().ToString("F0") + " mbar",
|
||||
batch.AmbientHumiAve().ToString("F0") + " %",
|
||||
};
|
||||
int cnt = 0;
|
||||
foreach (var v in commonItems)
|
||||
{
|
||||
leftColumn[cnt] = v.Caption + ": ";
|
||||
rightColumn[cnt] = v.Print(batch.WaterMeters[0]);
|
||||
cnt++;
|
||||
}
|
||||
|
||||
/// Determine max. left column width in characters
|
||||
int maxLen = 0;
|
||||
@@ -226,7 +225,6 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
|
||||
}
|
||||
writer.WriteLine(string.Empty);
|
||||
|
||||
|
||||
///--------
|
||||
/// Body
|
||||
///--------
|
||||
@@ -245,11 +243,11 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
|
||||
void WriteWM(Results.Entities.WaterMeter wm)
|
||||
{
|
||||
/// Determine column widths
|
||||
int[] columnWidths = new int[rsltItems.Count];
|
||||
int[] columnWidths = new int[testItems.Count];
|
||||
int totalWidth = 0;
|
||||
for (int i = 0; i < rsltItems.Count; i++)
|
||||
for (int i = 0; i < testItems.Count; i++)
|
||||
{
|
||||
columnWidths[i] = ElSpaces(rsltItems[i].ClmnHeaderText).Length;
|
||||
columnWidths[i] = ElSpaces(testItems[i].ClmnHeaderText).Length;
|
||||
foreach (var mtr in wm.MeterTestRslts)
|
||||
{
|
||||
if ((mtr != null) && (mtr.Publish() == Config.Entities.Publish.Always))
|
||||
@@ -259,13 +257,13 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
|
||||
if (!wm.Compound())
|
||||
{
|
||||
/// Single water meter
|
||||
itemText = rsltItems[i].Print(mtr);
|
||||
itemText = testItems[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);
|
||||
itemText = testItems[i].PrintCombined(mainMtr, auxMtr, mtr);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -282,7 +280,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
|
||||
}
|
||||
totalWidth += columnWidths[i];
|
||||
}
|
||||
totalWidth += 3 * (rsltItems.Count - 1);
|
||||
totalWidth += 3 * (testItems.Count - 1);
|
||||
if (totalWidth < 0) totalWidth = 0;
|
||||
|
||||
/// Write water meter number and s/n
|
||||
@@ -303,15 +301,15 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
|
||||
|
||||
|
||||
/// Write column headers
|
||||
for (int i = 0; i < rsltItems.Count; i++)
|
||||
for (int i = 0; i < testItems.Count; i++)
|
||||
{
|
||||
writer.Write(ElSpaces(rsltItems[i].ClmnHeaderText));
|
||||
writer.Write(ElSpaces(testItems[i].ClmnHeaderText));
|
||||
|
||||
if (i < rsltItems.Count - 1)
|
||||
if (i < testItems.Count - 1)
|
||||
{
|
||||
if (!writerCfg.EliminateSpaces)
|
||||
{
|
||||
writer.Write(new string(' ', columnWidths[i] - rsltItems[i].ClmnHeaderText.Length + 3));
|
||||
writer.Write(new string(' ', columnWidths[i] - testItems[i].ClmnHeaderText.Length + 3));
|
||||
}
|
||||
writer.Write(separatorStr);
|
||||
}
|
||||
@@ -330,7 +328,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
|
||||
{
|
||||
if ((mtr != null) && (mtr.Publish() == Config.Entities.Publish.Always))
|
||||
{
|
||||
for (int i = 0; i < rsltItems.Count; i++)
|
||||
for (int i = 0; i < testItems.Count; i++)
|
||||
{
|
||||
string itemText;
|
||||
|
||||
@@ -340,13 +338,13 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
|
||||
if (!wm.Compound())
|
||||
{
|
||||
/// Single water meter
|
||||
itemText = rsltItems[i].Print(mtr);
|
||||
itemText = testItems[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);
|
||||
itemText = testItems[i].PrintCombined(mainMtr, auxMtr, mtr);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -361,7 +359,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
|
||||
|
||||
writer.Write(ElSpaces(itemText));
|
||||
|
||||
if (i < rsltItems.Count - 1)
|
||||
if (i < testItems.Count - 1)
|
||||
{
|
||||
if (!writerCfg.EliminateSpaces)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user