iPerlSpecial: Changes done on the system while testing Output.FileWriters.Enhanced protocol, ver.2.7.296

This commit is contained in:
Milan Hanajik
2016-05-26 17:14:55 +02:00
parent 6e418b1fc4
commit 5c93b55f58
13 changed files with 113 additions and 87 deletions
@@ -148,7 +148,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
}
catch
{
return string.Format("{0}{1:yyMMdd}-{1:hhss}.txt", directory, time);
return string.Format("{0}{1:yyMMdd-HHmm}.txt", directory, time);
}
}
@@ -187,16 +187,20 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
}
/// <summary>Start this operation</summary>
public void Start()
{
if (writer == null) return;
public void Start()
{
if (writer != null) WriteRslts(writer);
if (writer2 != null) WriteRslts(writer2);
}
void WriteRslts(StreamWriter wr)
{
///----------
/// Header
///----------
if (!string.IsNullOrEmpty(writerCfg.Header)) writer.Write(writerCfg.Header);
writer.WriteLine(batch.ProtocolTitle);
writer.WriteLine(string.Empty);
if (!string.IsNullOrEmpty(writerCfg.Header)) wr.Write(header);
wr.WriteLine(batch.ProtocolTitle);
wr.WriteLine(string.Empty);
///----------------
/// Common items
@@ -207,7 +211,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
int cnt = 0;
foreach (var v in commonItems)
{
leftColumn[cnt] = v.Caption + ": ";
leftColumn[cnt] = v.Caption;
rightColumn[cnt] = v.Print(batch.WaterMeters[0]);
cnt++;
}
@@ -219,30 +223,44 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
/// Write aligned columns
for (int i = 0; i < Math.Min(leftColumn.Length, rightColumn.Length); i++)
{
writer.Write(leftColumn[i]);
writer.Write(new string(' ', maxLen - leftColumn[i].Length + 3));
writer.WriteLine(rightColumn[i]);
wr.Write(leftColumn[i]);
wr.Write(new string(' ', maxLen - leftColumn[i].Length + 3));
wr.WriteLine(rightColumn[i]);
}
writer.WriteLine(string.Empty);
///--------
/// Body
///--------
foreach (var wm in batch.WaterMeters) WriteWM(wm);
foreach (var wm in batch.WaterMeters) WriteWM(wr, wm);
///----------
/// Footer
///----------
if (!string.IsNullOrEmpty(writerCfg.Footer)) writer.Write(writerCfg.Footer);
if (!string.IsNullOrEmpty(writerCfg.Footer)) wr.Write(footer);
}
/// <summary>
/// Write one water meter results
/// </summary>
/// <param name="wmNr">Water meter number (0-based)</param>
void WriteWM(Results.Entities.WaterMeter wm)
void WriteWM(StreamWriter wr, Results.Entities.WaterMeter wm)
{
/// Determine column widths
wr.WriteLine(string.Empty);
/// Write water meter number and s/n
wr.Write(string.Format(Strings.Water_Meter_nr, wm.WMPosition));
if (!wm.Compound())
{
if (!string.IsNullOrEmpty(wm.SerialNr)) wr.Write(string.Format(", {0} {1}", Strings.SerialNr, wm.SerialNr));
}
else
{
if (!string.IsNullOrEmpty(wm.SerialNr)) wr.Write(string.Format(", {0} {1}", Strings.Main_WM_SerialNr, wm.SerialNr));
if (!string.IsNullOrEmpty(wm.SerialNrAux)) wr.Write(string.Format(", {0} {1}", Strings.Aux_WM_SerialNr, wm.SerialNrAux));
}
wr.WriteLine(string.Empty);
/// Determine column widths
int[] columnWidths = new int[testItems.Count];
int totalWidth = 0;
for (int i = 0; i < testItems.Count; i++)
@@ -282,45 +300,31 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
}
totalWidth += 3 * (testItems.Count - 1);
if (totalWidth < 0) totalWidth = 0;
/// Write water meter number and s/n
writer.Write(string.Format("Water meter {0}", wm.WMPosition));
if (!wm.Compound())
{
if (!string.IsNullOrEmpty(wm.SerialNr)) writer.Write(string.Format(", s/n: {0}", wm.SerialNr));
}
else
{
if (!string.IsNullOrEmpty(wm.SerialNr)) writer.Write(string.Format(", Main s/n: {0}", wm.SerialNr));
if (!string.IsNullOrEmpty(wm.SerialNrAux)) writer.Write(string.Format(", Aux s/n: {0}", wm.SerialNrAux));
}
writer.WriteLine(string.Empty);
writer.WriteLine(new String('-', totalWidth)); /// Horizontal line above the header
wr.WriteLine(new String('-', totalWidth)); /// Horizontal line above the header
/// Write column headers
for (int i = 0; i < testItems.Count; i++)
{
writer.Write(ElSpaces(testItems[i].ClmnHeaderText));
wr.Write(ElSpaces(testItems[i].ClmnHeaderText));
if (i < testItems.Count - 1)
{
if (!writerCfg.EliminateSpaces)
{
writer.Write(new string(' ', columnWidths[i] - testItems[i].ClmnHeaderText.Length + 3));
wr.Write(new string(' ', columnWidths[i] - testItems[i].ClmnHeaderText.Length + 3));
}
writer.Write(separatorStr);
wr.Write(separatorStr);
}
else
{
writer.WriteLine(string.Empty);
wr.WriteLine(string.Empty);
}
}
writer.WriteLine(new String('-', totalWidth)); /// Horizontal line between the header and the body
wr.WriteLine(new String('-', totalWidth)); /// Horizontal line between the header and the body
/// Write table data
@@ -357,27 +361,25 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
string[] texts = itemText.Split(new char[] { '|' });
if (texts.Length == 2) { itemText = texts[0]; } /// Strip color information
writer.Write(ElSpaces(itemText));
wr.Write(ElSpaces(itemText));
if (i < testItems.Count - 1)
{
if (!writerCfg.EliminateSpaces)
{
writer.Write(new string(' ', columnWidths[i] - itemText.Length + 3));
wr.Write(new string(' ', columnWidths[i] - itemText.Length + 3));
}
writer.Write(separatorStr);
wr.Write(separatorStr);
}
else
{
writer.WriteLine(string.Empty);
wr.WriteLine(string.Empty);
}
}
}
}
writer.WriteLine(new String('-', totalWidth)); /// Horizontal line below the body
writer.WriteLine(string.Empty);
wr.WriteLine(new String('-', totalWidth)); /// Horizontal line below the body
}
@@ -392,8 +394,8 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
/// <summary>Stop this operation</summary>
public void Stop()
{
if (writer != null) writer.Close();
writer = null;
if (writer != null) writer.Close();
if (writer2 != null) writer2.Close();
}
}
}
@@ -73,7 +73,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
YearFolders = YearFolders.FourDigit;
MonthFolders = MonthFolders.Digit;
DayFolders = DayFolders.Digit;
FileNameFormat = "{0:yyMMdd}-{0:hhss}.txt";
FileNameFormat = "{0:yyMMdd-HHmm}.txt";
Separator = Separator.None;
EliminateSpaces = false;
Header = string.Empty;