(1) Ref.flowmeter, Test method Elde (string) added to result items (2) FileWriters.Elde.Writer (3) New DEWA300 component (3.5.2019), ver. 2.18.1209

This commit is contained in:
Milan Hanajik 2019-05-03 16:04:04 +02:00
parent 5936efcad2
commit 32a13ecf49
8 changed files with 179 additions and 162 deletions

View File

@ -10,7 +10,7 @@ namespace Results.Entities
public virtual int Id { get; protected set; } public virtual int Id { get; protected set; }
public virtual byte CompoundMeterId { get; set; } /// 0=single, 1=compound/main, 2=compound/aux., 3=compound/overal, 4=heat meter volume, 5=heat meter energy public virtual byte CompoundMeterId { get; set; } /// 0=single, 1=compound/main, 2=compound/aux., 3=compound/overal, 4=heat meter volume, 5=heat meter energy
public virtual int RegReaderType { get; set; } /// Not mapped to the DB, does not depent on localisation and customer public virtual int RegReaderType { get; set; } /// Not mapped to the DB, does not depend on localization and customer
public virtual double PulsesMeter { get; set; } /// # of water meter or heat meter pulses public virtual double PulsesMeter { get; set; } /// # of water meter or heat meter pulses
public virtual double PulsesMaster { get; set; } /// # of reference flowmeter pulses (gated by this water meter pulses) public virtual double PulsesMaster { get; set; } /// # of reference flowmeter pulses (gated by this water meter pulses)

View File

@ -132,11 +132,25 @@ namespace Results.Entities
public virtual double TargetVolume() { return TestData.TargetVolume; } public virtual double TargetVolume() { return TestData.TargetVolume; }
public virtual double TargetTime() { return TestData.TargetTime; } public virtual double TargetTime() { return TestData.TargetTime; }
public virtual string Method() { return TestData.Method; } public virtual string Method() { return TestData.Method; }
public virtual string RefFlowmeter() { return (Components != null) ? Components.Flowmeter : string.Empty; }
public virtual bool IsRelErrTest() { return (MethodClass != null) ? (MethodClass.Contains("FixedStart") || MethodClass.Contains("FlyingStart") || MethodClass.Contains("CombinedWithDetection")) : true; } public virtual bool IsRelErrTest() { return (MethodClass != null) ? (MethodClass.Contains("FixedStart") || MethodClass.Contains("FlyingStart") || MethodClass.Contains("CombinedWithDetection")) : true; }
public virtual bool IsPMaxTest() { return (MethodClass != null) ? (MethodClass.Contains("PMaxTest") || MethodClass.Contains("LeakTest")) : true; } public virtual bool IsPMaxTest() { return (MethodClass != null) ? (MethodClass.Contains("PMaxTest") || MethodClass.Contains("LeakTest")) : true; }
public virtual bool IsStartStop() { return (MethodClass != null) ? MethodClass.Contains("FixedStart") : true; } public virtual bool IsStartStop() { return (MethodClass != null) ? MethodClass.Contains("FixedStart") : true; }
public virtual bool IsDiverter() { return (MethodClass != null) ? (MethodClass.Contains("FlyingStart") && MethodClass.Contains("MassColl")) : true; } public virtual bool IsDiverter() { return (MethodClass != null) ? (MethodClass.Contains("FlyingStart") && MethodClass.Contains("MassColl")) : true; }
public virtual string MethodElde()
{
if (MethodClass == null) return string.Empty;
else if (MethodClass.Contains("TestMethods.FlyingStartMassCollection.")) return "MS";
else if (MethodClass.Contains("TestMethods.FlyingStartMassCollectionProlonged.")) return "MS";
else if (MethodClass.Contains("TestMethods.FlyingStartMassCollectionComparative.")) return "MS";
else if (MethodClass.Contains("TestMethods.FlyingStart.")) return "VS";
else if (MethodClass.Contains("TestMethods.FixedStartMassCollection.")) return "MP";
else if (MethodClass.Contains("TestMethods.FixedStartTankCollection.")) return "VP";
else if (MethodClass.Contains("TestMethods.FixedStart.")) return "VP";
else return string.Empty;
}
public virtual double ErrLimLo() public virtual double ErrLimLo()
{ {
if (TestData.ErrLimLo <= TestData.ErrLimHi) if (TestData.ErrLimLo <= TestData.ErrLimHi)

View File

@ -300,6 +300,9 @@ namespace Results
E27, /// 255 E27, /// 255
E28, /// 256 E28, /// 256
RefFlowmeter, /// 257
Test_Method_Elde, /// 258
Count, Count,
} }
} }

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.18.1208.0")] [assembly: AssemblyVersion("2.18.1209.0")]
[assembly: AssemblyFileVersion("2.18.1208.0")] [assembly: AssemblyFileVersion("2.18.1209.0")]

View File

@ -149,6 +149,7 @@ namespace Results
AllItems.Add(new WMeterRsltItemSpec(ItemID.Proc_description, Strings.Procedure_description, Quantity.String, ItemCategory.Other, (w, t, u, f, p) => FormatStr(f, w.Batch.ProcedureDescription))); AllItems.Add(new WMeterRsltItemSpec(ItemID.Proc_description, Strings.Procedure_description, Quantity.String, ItemCategory.Other, (w, t, u, f, p) => FormatStr(f, w.Batch.ProcedureDescription)));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Batch_number, Strings.Batch_nr, Quantity.Number, ItemCategory.Other, (w, t, u, f, p) => FormatInt(f, w.BatchNr()))); AllItems.Add(new WMeterRsltItemSpec(ItemID.Batch_number, Strings.Batch_nr, Quantity.Number, ItemCategory.Other, (w, t, u, f, p) => FormatInt(f, w.BatchNr())));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Test_method, Strings.Test_method + "()", Quantity.String, ItemCategory.TestData, (w, t, u, f, p) => FormatStr(f, (w.GetTestRslt(t) == null) ? "" : w.GetTestRslt(t).Method()))); AllItems.Add(new WMeterRsltItemSpec(ItemID.Test_method, Strings.Test_method + "()", Quantity.String, ItemCategory.TestData, (w, t, u, f, p) => FormatStr(f, (w.GetTestRslt(t) == null) ? "" : w.GetTestRslt(t).Method())));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Test_Method_Elde, Strings.Test_method + " Elde ()", Quantity.String, ItemCategory.TestData, (w, t, u, f, p) => FormatStr(f, (w.GetTestRslt(t) == null) ? "" : w.GetTestRslt(t).MethodElde())));
/// ///
/// Volume /// Volume
@ -320,7 +321,8 @@ namespace Results
AllItems.Add(new WMeterRsltItemSpec(ItemID.Passed, Strings.Result, Quantity.Boolean, ItemCategory.MeterResult, (w, t, u, f, p) => string.IsNullOrEmpty(t) ? w.PassedColorStr(f) AllItems.Add(new WMeterRsltItemSpec(ItemID.Passed, Strings.Result, Quantity.Boolean, ItemCategory.MeterResult, (w, t, u, f, p) => string.IsNullOrEmpty(t) ? w.PassedColorStr(f)
: ((w.GetMeterTestRslt(t) == null) ? "" : w.GetMeterTestRslt(t).PassedColorStr(f)))); : ((w.GetMeterTestRslt(t) == null) ? "" : w.GetMeterTestRslt(t).PassedColorStr(f))));
AllItems.Add(new WMeterRsltItemSpec(ItemID.ResultOrErrorFlags, "Winiki lub E", Quantity.String, ItemCategory.MeterResult, (w, t, u, f, p) => FormatStr(f, w.PassedOrErrorFlagsStr()))); /// PL specific result AllItems.Add(new WMeterRsltItemSpec(ItemID.RefFlowmeter, "Ref. flowmeter", Quantity.String, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null) ? FormatStr(f, w.GetTestRslt(t).RefFlowmeter()) : string.Empty));
AllItems.Add(new WMeterRsltItemSpec(ItemID.ResultOrErrorFlags, "Winiki lub E", Quantity.String, ItemCategory.MeterResult, (w, t, u, f, p) => FormatStr(f, w.PassedOrErrorFlagsStr()))); /// PL specific result
/// ///
/// Water meter info /// Water meter info

View File

@ -56,11 +56,26 @@ namespace TBF.BenchControl.Output.FileWriters.Elde
header = string.IsNullOrEmpty(writerCfg.Header) ? string.Empty : writerCfg.Header.Replace("~", Environment.NewLine); header = string.IsNullOrEmpty(writerCfg.Header) ? string.Empty : writerCfg.Header.Replace("~", Environment.NewLine);
commonItems = Results.WMeterRsltItemSpec.FromStrArray(new string[] { commonItems = Results.WMeterRsltItemSpec.FromStrArray(new string[] {
"72~Date / Time~~None~: {0:yyyy/MM/dd} / {0:HH:mm}~~0~Left", "72~Date / Time~~None~: {0:yyyy/MM/dd} / {0:HH:mm} Page : 1/1~~0~Left",
"221~Watermeter Type~~None~: {0}~~0~Left", "50~Watermeter Type~~None~: {0}~~0~Left",
"0~Device No~~None~: 1~~0~Left", "64~Device No~~None~: {0}~~0~Left",
"66~Personal~~None~: {0}~~0~Left" } ); "66~Personal~~None~: {0}~~0~Left",
testItems = Results.WMeterRsltItemSpec.FromStrArray(writerCfg.SelectedItems); /// TestID info will be overwritten later on } );
testItems = Results.WMeterRsltItemSpec.FromStrArray(new string[] {
"1~Test~~None~~~0~Left",
"258~Met. t.~~None~~~0~Left",
"257~Fl.~~None~~~0~Left",
"25~Dev. [%]~~Pct~~~0~Left",
"202~Flow [m3/h]~~m3ph~~F6~0~Left",
"14~Test time [s]~~s~~F1~0~Left",
"16~T1 [°C]~~C~~F1~0~Left",
"17~T2 [°C]~~C~~F1~0~Left",
"5~Density [kg/m3]~~kgpm3~~F3~0~Left",
"131~Mass [kg]~~kg~~F3~0~Left",
"19~Pressure [MPa]~~MPa~~F2~0~Left",
"229~Volume [L]~~l~~F4~0~Left",
} );
footer = string.IsNullOrEmpty(writerCfg.Footer) ? string.Empty : writerCfg.Footer.Replace("~", Environment.NewLine); footer = string.IsNullOrEmpty(writerCfg.Footer) ? string.Empty : writerCfg.Footer.Replace("~", Environment.NewLine);
} }
@ -269,6 +284,22 @@ namespace TBF.BenchControl.Output.FileWriters.Elde
void WriteRsltsEx(Results.Entities.Batch batch, StreamWriter wrtr) void WriteRsltsEx(Results.Entities.Batch batch, StreamWriter wrtr)
{ {
string toPrint;
///
/// Get a sample water meter (to save common and test items)
///
Results.Entities.WaterMeter sampleWM = null;
foreach (var wm in batch.WaterMeters)
{
if (wm != null)
{
sampleWM = wm;
break;
}
}
if (sampleWM == null) return; /// No water meters
///---------- ///----------
/// Header /// Header
///---------- ///----------
@ -282,10 +313,10 @@ namespace TBF.BenchControl.Output.FileWriters.Elde
string[] rightColumn = new string[commonItems.Count]; string[] rightColumn = new string[commonItems.Count];
int cnt = 0; int cnt = 0;
foreach (var v in commonItems) foreach (var item in commonItems)
{ {
leftColumn[cnt] = v.Caption; leftColumn[cnt] = item.Caption;
rightColumn[cnt] = (batch.WaterMeters.Count > 0) ? v.Print(batch.WaterMeters[0]) : string.Empty; rightColumn[cnt] = item.Print(sampleWM);
cnt++; cnt++;
} }
@ -309,164 +340,131 @@ namespace TBF.BenchControl.Output.FileWriters.Elde
wrtr.WriteLine(rightColumn[i]); wrtr.WriteLine(rightColumn[i]);
} }
///-------- ///---------
/// Body /// Tests
///-------- ///---------
foreach (var wm in batch.WaterMeters) wrtr.WriteLine();
wrtr.WriteLine("Test Met. Fl. Dev. Flow Test time T1 T2 Density Mass Pressure Volume");
wrtr.WriteLine(" t. [%] [m3/h] [s] [°C] [°C] [kg/m3] [kg] [MPa] [L]");
wrtr.WriteLine("------------------------------------------------------------------------------------------------------------------");
int emptyTestsLeft = 5;
int[] widths = new int[] { 11, 5, 6, 9, 12, 12, 8, 11, 10, 15, 8, 1 }; /// Widths of columns
foreach (var testRslt in batch.TestRslts)
{ {
if (!writerCfg.SaveGoodOnly || wm.Passed) if (testRslt.Publish() == Config.Entities.Publish.Always)
{ {
if (abort) return; for (int i = 0; i < Math.Min(testItems.Count, widths.Length); i++)
WriteWM(wrtr, wm); {
wrtr.Write(toPrint = testItems[i].Print(sampleWM, testRslt.Name()));
for (int j = 0; j < Math.Max(1, widths[i] - toPrint.Length); j++) wrtr.Write(' ');
}
wrtr.WriteLine();
wrtr.WriteLine();
if (emptyTestsLeft > 0) emptyTestsLeft--;
} }
} }
///----------------
/// Water meters
///----------------
wrtr.WriteLine();
wrtr.WriteLine();
wrtr.WriteLine("------------------------------------------------------------------------------------------------------------------------------------------------");
wrtr.WriteLine("No | Prod. No | Initial Volume [L] | End Volume [L] | Deviation [%] |Sen| Result.");
wrtr.WriteLine("------------------------------------------------------------------------------------------------------------------------------------------------");
wrtr.Write(" ");
for (int i = 0; i < 3; i++)
{
foreach (var testRslt in batch.TestRslts)
{
if (testRslt.Publish() == Config.Entities.Publish.Always)
{
wrtr.Write(toPrint = testRslt.Name());
for (int j = 0; j < Math.Max(1, (i<2 ? 8 : 7) - toPrint.Length); j++) wrtr.Write(' ');
}
}
for (int k = 0; k < emptyTestsLeft; k++) wrtr.Write("- ");
}
wrtr.WriteLine();
wrtr.WriteLine("------------------------------------------------------------------------------------------------------------------------------------------------");
foreach (var wm in batch.WaterMeters)
{
if (wm != null)
{
wrtr.Write(' ');
wrtr.Write(toPrint = wm.WMPosition.ToString());
for (int j = 0; j < Math.Max(1, 3 - toPrint.Length); j++) wrtr.Write(' ');
wrtr.Write(toPrint = wm.SerialNr);
for (int j = 0; j < Math.Max(1, 14 - toPrint.Length); j++) wrtr.Write(' ');
/// Volume start
foreach (var mtr in wm.MeterTestRslts)
{
if (mtr.Publish() == Config.Entities.Publish.Always)
{
wrtr.Write(toPrint = mtr.VolumeStart.ToString("F2"));
for (int j = 0; j < Math.Max(1, 8 - toPrint.Length); j++) wrtr.Write(' ');
}
}
for (int k = 0; k < emptyTestsLeft; k++) wrtr.Write(" ");
/// Volume end
foreach (var mtr in wm.MeterTestRslts)
{
if (mtr.Publish() == Config.Entities.Publish.Always)
{
wrtr.Write(toPrint = mtr.VolumeEnd.ToString("F2"));
for (int j = 0; j < Math.Max(1, 8 - toPrint.Length); j++) wrtr.Write(' ');
}
}
for (int k = 0; k < emptyTestsLeft; k++) wrtr.Write(" ");
/// Error
foreach (var mtr in wm.MeterTestRslts)
{
if (mtr.Publish() == Config.Entities.Publish.Always)
{
wrtr.Write(toPrint = mtr.Error.ToString("F2"));
for (int j = 0; j < Math.Max(1, 7 - toPrint.Length); j++) wrtr.Write(' ');
}
}
for (int k = 0; k < emptyTestsLeft; k++) wrtr.Write(" ");
wrtr.Write(" ");
wrtr.Write(wm.Passed ? "OK" : "Not suitable");
wrtr.WriteLine();
}
}
wrtr.WriteLine("------------------------------------------------------------------------------------------------------------------------------------------------");
wrtr.WriteLine();
wrtr.Write("Producer: ");
wrtr.Write(toPrint = sampleWM.WaterMeterData.Producer);
for (int j = 0; j < Math.Max(1, 30 - toPrint.Length); j++) wrtr.Write(' ');
wrtr.WriteLine("Explanation :");
wrtr.WriteLine(" M - Mass Method");
wrtr.WriteLine(" V - Volumetric Method");
wrtr.WriteLine(" P - Start / Stop");
wrtr.WriteLine(" F - Flow start");
wrtr.WriteLine(" S - Synchro");
wrtr.WriteLine(" C - Count imp.");
wrtr.WriteLine();
wrtr.WriteLine("-------------------------------------------------------------------------");
///---------- ///----------
/// Footer /// Footer
///---------- ///----------
if (!string.IsNullOrEmpty(writerCfg.Footer)) wrtr.Write(footer); if (!string.IsNullOrEmpty(writerCfg.Footer)) wrtr.Write(footer);
}
/// <summary> wrtr.Write('\f'); /// Form feed
/// Write one water meter results
/// </summary>
/// <param name="wmNr">Water meter number (0-based)</param>
void WriteWM(StreamWriter wr, Results.Entities.WaterMeter wm)
{
wr.WriteLine();
/// Write water meter number and s/n
#if BADGER_MALA_TRAT || BADGER_STREDNA_TRAT || BADGER_VELKA_TRAT
wr.Write(string.Format("Water meter {0} s/n: {1}", wm.WMPosition, wm.SerialNr));
#else
wr.Write(string.Format("{0} {1}", Strings.Water_Meter, 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));
}
}
#endif
wr.WriteLine();
/// Determine column widths
int[] columnWidths = new int[testItems.Count];
int totalWidth = 0;
for (int i = 0; i < testItems.Count; i++)
{
if (abort) return;
columnWidths[i] = ElSpaces(testItems[i].Caption).Length;
foreach (var mtr in wm.MeterTestRslts)
{
if ((mtr != null) && (mtr.Publish() == Config.Entities.Publish.Always))
{
string itemText = testItems[i].Print(wm, mtr.Name());
/// 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 * (testItems.Count - 1);
if (totalWidth < 0) totalWidth = 0;
string horizontalLine = new String('-', totalWidth);
if (!writerCfg.EliminateSpaces)
{
wr.WriteLine(horizontalLine); /// Horizontal line above the header
}
/// Write column headers
for (int i = 0; i < testItems.Count; i++)
{
if (abort) return;
string caption = ElSpaces(testItems[i].Caption);
wr.Write(caption);
if (i < testItems.Count - 1)
{
if (!writerCfg.EliminateSpaces)
{
wr.Write(new string(' ', columnWidths[i] - testItems[i].Caption.Length + 3));
}
wr.Write(separatorStr);
}
else
{
wr.WriteLine();
}
}
if (!writerCfg.EliminateSpaces)
{
wr.WriteLine(horizontalLine); /// Horizontal line between the header and the body
}
/// Write table data
int rowsCount = 0;
foreach (var mtr in wm.MeterTestRslts)
{
if (abort) return;
if (mtr != null && mtr.IsPilotRslt() && mtr.Publish() == Config.Entities.Publish.Always)
{
Results.WMeterRsltItemSpec.TableRowNr = ++rowsCount;
for (int i = 0; i < testItems.Count; i++)
{
Results.WMeterRsltItemSpec.TableColumnNr = i + 1;
/// Fetch the item
string itemText = testItems[i].Print(wm, mtr.Name());
/// Strip color information
string[] texts = itemText.Split(new char[] { '|' });
if (texts.Length == 2) { itemText = texts[0]; }
/// Print the item
string itemText2 = ElSpaces(itemText);
wr.Write(itemText2);
if (i < testItems.Count - 1)
{
if (!writerCfg.EliminateSpaces)
{
wr.Write(new string(' ', columnWidths[i] - itemText.Length + 3));
}
wr.Write(separatorStr);
}
else
{
wr.WriteLine();
}
}
}
}
if (!writerCfg.EliminateSpaces)
{
wr.WriteLine(horizontalLine); /// Horizontal line below the body
}
} }
} }
} }

View File

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number // Build Number
// Revision // Revision
// //
[assembly: AssemblyVersion("2.18.1208.0")] [assembly: AssemblyVersion("2.18.1209.0")]
[assembly: AssemblyFileVersion("2.18.1208.0")] [assembly: AssemblyFileVersion("2.18.1209.0")]