141 lines
5.6 KiB
C#
141 lines
5.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using TBF.BenchControl;
|
|
|
|
namespace TBF.BenchControl.ResultsWriters.Basic
|
|
{
|
|
public class Writer : Generic.IComponent, IOperation, GenericDevices.IResultsWriter
|
|
{
|
|
readonly WriterCfg writerCfg;
|
|
public Generic.IComponentCfg Cfg { get { return writerCfg; } }
|
|
|
|
public static void ResetStaticProperties() { }
|
|
|
|
public string Name { get { return writerCfg.Name; } }
|
|
|
|
/// <summary>
|
|
/// Results to print
|
|
/// </summary>
|
|
IList<Entities.TestResult> results;
|
|
DateTime now;
|
|
Stream stream;
|
|
StreamWriter writer;
|
|
|
|
public Writer(WriterCfg cfg)
|
|
{
|
|
if (cfg == null) throw new ArgumentNullException("cfg");
|
|
this.writerCfg = cfg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Writes the test cycle results into a file, Events: Event.ResultsWritten
|
|
/// </summary>
|
|
/// <param name="results">Results to write into the file</param>
|
|
/// <returns>Reference to the operation</returns>
|
|
public IOperation WriteResultsOp(IList<Entities.TestResult> results)
|
|
{
|
|
this.results = results;
|
|
this.now = DateTime.Now;
|
|
this.stream = System.IO.File.Create(string.Format("{0}Results\\{1}-{2}-{3}\\{4}-{5}.txt",
|
|
Program.HomeDir,
|
|
now.Year, now.Month, now.Date,
|
|
now.Hour, now.Minute));
|
|
this.writer = new StreamWriter(stream);
|
|
|
|
return this;
|
|
}
|
|
|
|
/// <summary>Start this operation</summary>
|
|
public void Start()
|
|
{
|
|
writer.WriteLine("Staatlich anerkante Prüfstelle für Meßgeräte für Wasser WB2");
|
|
writer.WriteLine("");
|
|
writer.WriteLine(string.Format(" PROTOKOLL Nummer {0}", 0));
|
|
writer.WriteLine("");
|
|
writer.WriteLine("Ver. 3/13");
|
|
writer.WriteLine(string.Format("Datum / Zeit : {0}.{1}.{2} / {3}:{4} Seite : 1/ 1 / 1",
|
|
now.Date, now.Month, now.Year, now.Hour, now.Minute));
|
|
writer.WriteLine("Wasserzähler Type : 110338");
|
|
writer.WriteLine("Gerät Nr. : 1");
|
|
writer.WriteLine("Benutzer : Bauer");
|
|
writer.WriteLine("Impulsrate : 1 67.422 1");
|
|
writer.WriteLine("Bereich : 22,9 °C 947 mbar 43 %");
|
|
writer.WriteLine("");
|
|
writer.WriteLine("Test Metode MIDFehler Durchfluss Test Zeit T1 T2 Dichte Masse Druck Volume Bor");
|
|
writer.WriteLine(" [%] [m3/h] [s] [°C] [°C] [kg/m3] [kg] [MPa] [L] [m3/h]");
|
|
writer.WriteLine("---------------------------------------------------------------------------------------------------------------------------------------");
|
|
|
|
foreach (var tr in results)
|
|
{
|
|
if (tr.MetersKind == Entities.MetersKind.Single)
|
|
{
|
|
writer.WriteLine(string.Format("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} {11}"),
|
|
tr.Name,
|
|
tr.Method,
|
|
tr.Meters[0].VolumeErrorPct,
|
|
tr.FlowMass,
|
|
tr.Time,
|
|
tr.TempInAvrg,
|
|
tr.TempDivAvrg,
|
|
tr.DensityOut,
|
|
tr.MassDiff,
|
|
tr.PressInAvrg,
|
|
tr.PressOutAvrg,
|
|
tr.VolumeCTV);
|
|
}
|
|
else if (tr.MetersKind == Entities.MetersKind.Combined)
|
|
{
|
|
writer.WriteLine(string.Format("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} {11}"),
|
|
tr.Name,
|
|
tr.Method,
|
|
tr.CombinedMeters[0].VolumeErrorPct,
|
|
tr.FlowMass,
|
|
tr.Time,
|
|
tr.TempInAvrg,
|
|
tr.TempDivAvrg,
|
|
tr.DensityOut,
|
|
tr.MassDiff,
|
|
tr.PressInAvrg,
|
|
tr.PressOutAvrg,
|
|
tr.VolumeCTV);
|
|
}
|
|
}
|
|
|
|
writer.WriteLine("---------------------------------------------------------------------------------------------------------------------------------------");
|
|
writer.WriteLine("No| Zähler Nr| Test. Volume [L] | Zählerabweichung [%] | Messunsicherheit k=2 |Prüfergebnis");
|
|
writer.WriteLine("---------------------------------------------------------------------------------------------------------------------------------------");
|
|
writer.WriteLine(" Qmin Qt Qmax Qmin Qt Qmax Qmin Qt Qmax");
|
|
writer.WriteLine("---------------------------------------------------------------------------------------------------------------------------------------");
|
|
}
|
|
|
|
/// <summary>Run this operation</summary>
|
|
/// <returns>Event.ResultsWritten</returns>
|
|
public Event Run()
|
|
{
|
|
|
|
return Event.ResultsWritten;
|
|
}
|
|
|
|
/// <summary>Stop this operation</summary>
|
|
public void Stop()
|
|
{
|
|
writer.WriteLine("---------------------------------------------------------------------------------------------------------------------------------------");
|
|
writer.WriteLine("");
|
|
writer.WriteLine("Hersteller : Bemerkung : M - Prüfung gegen Waage");
|
|
writer.WriteLine(" V - Prüfung gegen MID");
|
|
writer.WriteLine(" P - Start / Stopp");
|
|
writer.WriteLine(" F - Fliegender Start");
|
|
writer.WriteLine(" S - Impulskompensation");
|
|
writer.WriteLine(" C - Impulszählung");
|
|
writer.WriteLine("");
|
|
writer.WriteLine("---------------------------------------------------------------------------------------------------------------------------------------");
|
|
|
|
if (writer != null) writer.Close();
|
|
if (stream != null) stream.Close();
|
|
writer = null;
|
|
stream = null;
|
|
}
|
|
}
|
|
}
|