|
|
|
@@ -3,6 +3,8 @@
|
|
|
|
|
///
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Linq.Expressions;
|
|
|
|
|
using Config;
|
|
|
|
|
using Config.Entities;
|
|
|
|
|
using Results.Entities;
|
|
|
|
@@ -153,27 +155,27 @@ namespace Results
|
|
|
|
|
///
|
|
|
|
|
/// Volume
|
|
|
|
|
///
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Test_volume, Strings.Test_vol + "()", Quantity.Volume, ItemCategory.TestData, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V2", w.GetTestRslt(t).TargetVolume())));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.VolumeCTV, string.Format("{0} CTV ()", Strings.VName_Vol), Quantity.Volume, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V4", w.GetTestRslt(t).VolumeCTV)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Volume, string.Format("{0} Mt. ()", Strings.VName_Vol), Strings.Tooltip_Vol_Mt, Quantity.Volume, ItemCategory.MeterResult, (w, t, u, f, p) => (w.GetMeterTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V4", w.GetMeterTestRslt(t).VolumeMeter)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Reference_volume, string.Format("{0} rm ()", Strings.VName_Vol), Strings.Tooltip_Vol_rm, Quantity.Volume, ItemCategory.MeterResult, (w, t, u, f, p) => (w.GetMeterTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V4", w.GetMeterTestRslt(t).VolumeRef)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Volume_main, string.Format("{0} {1} ()", Strings.VName_Vol, Strings.main), Quantity.Volume, ItemCategory.MeterResult, (w, t, u, f, p) => (w.GetMeterTestRslt(t, CompoundMeterId.CompoundMain) == null) ? "" : FormatDbl(u, f, p, "V4", w.GetMeterTestRslt(t).VolumeMeter)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Volume_aux, string.Format("{0} {1} ()", Strings.VName_Vol, Strings.aux), Quantity.Volume, ItemCategory.MeterResult, (w, t, u, f, p) => (w.GetMeterTestRslt(t, CompoundMeterId.CompoundAux) == null) ? "" : FormatDbl(u, f, p, "V4", w.GetMeterTestRslt(t).VolumeMeter)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Start_volume, Strings.Start_volume + "()", Quantity.Volume, ItemCategory.MeterResult, (w, t, u, f, p) => (w.GetMeterTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V4", w.GetMeterTestRslt(t).VolumeStart)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Start_volume_main, Strings.Start_volume_main + "()", Quantity.Volume, ItemCategory.MeterResult, (w, t, u, f, p) => (w.GetMeterTestRslt(t, CompoundMeterId.CompoundMain) == null) ? "" : FormatDbl(u, f, p, "V4", w.GetMeterTestRslt(t).VolumeStart)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Start_volume_aux, Strings.Start_volume_aux + "()", Quantity.Volume, ItemCategory.MeterResult, (w, t, u, f, p) => (w.GetMeterTestRslt(t, CompoundMeterId.CompoundAux) == null) ? "" : FormatDbl(u, f, p, "V4", w.GetMeterTestRslt(t).VolumeStart)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.End_volume, Strings.End_volume + "()", Quantity.Volume, ItemCategory.MeterResult, (w, t, u, f, p) => (w.GetMeterTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V4", w.GetMeterTestRslt(t).VolumeEnd)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.End_volume_main, Strings.End_volume_main + "()", Quantity.Volume, ItemCategory.MeterResult, (w, t, u, f, p) => (w.GetMeterTestRslt(t, CompoundMeterId.CompoundMain) == null) ? "" : FormatDbl(u, f, p, "V4", w.GetMeterTestRslt(t).VolumeEnd)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.End_volume_aux, Strings.End_volume_aux + "()", Quantity.Volume, ItemCategory.MeterResult, (w, t, u, f, p) => (w.GetMeterTestRslt(t, CompoundMeterId.CompoundAux) == null) ? "" : FormatDbl(u, f, p, "V4", w.GetMeterTestRslt(t).VolumeEnd)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Test_volume, Strings.Test_vol + "()", Quantity.Volume, ItemCategory.TestData, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "", w.GetTestRslt(t).TargetVolume())));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.VolumeCTV, string.Format("{0} CTV ()", Strings.VName_Vol), Quantity.Volume, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "", w.GetTestRslt(t).VolumeCTV)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Volume, string.Format("{0} Mt. ()", Strings.VName_Vol), Strings.Tooltip_Vol_Mt, Quantity.Volume, ItemCategory.MeterResult, (w, t, u, f, p) => (w.GetMeterTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "", w.GetMeterTestRslt(t).VolumeMeter)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Reference_volume, string.Format("{0} rm ()", Strings.VName_Vol), Strings.Tooltip_Vol_rm, Quantity.Volume, ItemCategory.MeterResult, (w, t, u, f, p) => (w.GetMeterTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "", w.GetMeterTestRslt(t).VolumeRef)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Volume_main, string.Format("{0} {1} ()", Strings.VName_Vol, Strings.main), Quantity.Volume, ItemCategory.MeterResult, (w, t, u, f, p) => (w.GetMeterTestRslt(t, CompoundMeterId.CompoundMain) == null) ? "" : FormatDbl(u, f, p, "", w.GetMeterTestRslt(t).VolumeMeter)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Volume_aux, string.Format("{0} {1} ()", Strings.VName_Vol, Strings.aux), Quantity.Volume, ItemCategory.MeterResult, (w, t, u, f, p) => (w.GetMeterTestRslt(t, CompoundMeterId.CompoundAux) == null) ? "" : FormatDbl(u, f, p, "", w.GetMeterTestRslt(t).VolumeMeter)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Start_volume, Strings.Start_volume + "()", Quantity.Volume, ItemCategory.MeterResult, (w, t, u, f, p) => (w.GetMeterTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "", w.GetMeterTestRslt(t).VolumeStart)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Start_volume_main, Strings.Start_volume_main + "()", Quantity.Volume, ItemCategory.MeterResult, (w, t, u, f, p) => (w.GetMeterTestRslt(t, CompoundMeterId.CompoundMain) == null) ? "" : FormatDbl(u, f, p, "", w.GetMeterTestRslt(t).VolumeStart)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Start_volume_aux, Strings.Start_volume_aux + "()", Quantity.Volume, ItemCategory.MeterResult, (w, t, u, f, p) => (w.GetMeterTestRslt(t, CompoundMeterId.CompoundAux) == null) ? "" : FormatDbl(u, f, p, "", w.GetMeterTestRslt(t).VolumeStart)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.End_volume, Strings.End_volume + "()", Quantity.Volume, ItemCategory.MeterResult, (w, t, u, f, p) => (w.GetMeterTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "", w.GetMeterTestRslt(t).VolumeEnd)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.End_volume_main, Strings.End_volume_main + "()", Quantity.Volume, ItemCategory.MeterResult, (w, t, u, f, p) => (w.GetMeterTestRslt(t, CompoundMeterId.CompoundMain) == null) ? "" : FormatDbl(u, f, p, "", w.GetMeterTestRslt(t).VolumeEnd)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.End_volume_aux, Strings.End_volume_aux + "()", Quantity.Volume, ItemCategory.MeterResult, (w, t, u, f, p) => (w.GetMeterTestRslt(t, CompoundMeterId.CompoundAux) == null) ? "" : FormatDbl(u, f, p, "", w.GetMeterTestRslt(t).VolumeEnd)));
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
/// Mass
|
|
|
|
|
///
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Mass_start_raw, string.Format("{0} ST raw ()", Strings.VName_Mass), Quantity.Mass, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V4", w.GetTestRslt(t).MassStartRaw)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Mass_start, string.Format("{0} ST ()", Strings.VName_Mass), Quantity.Mass, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V4", w.GetTestRslt(t).MassStart)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Mass_end_raw, string.Format("{0} EN raw ()", Strings.VName_Mass), Quantity.Mass, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V4", w.GetTestRslt(t).MassEndRaw)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Mass_end, string.Format("{0} EN ()", Strings.VName_Mass), Quantity.Mass, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V4", w.GetTestRslt(t).MassEnd)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Mass, string.Format("{0} ()", Strings.VName_Mass), Quantity.Mass, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V4", w.GetTestRslt(t).MassEnd - w.GetTestRslt(t).MassStart)));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Mass_start_raw, string.Format("{0} ST raw ()", Strings.VName_Mass), Quantity.Mass, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "", w.GetTestRslt(t).MassStartRaw, GetDeviceId(w.GetTestRslt(t), x => x.Scale))));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Mass_start, string.Format("{0} ST ()", Strings.VName_Mass), Quantity.Mass, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "", w.GetTestRslt(t).MassStart, GetDeviceId(w.GetTestRslt(t), x => x.Scale))));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Mass_end_raw, string.Format("{0} EN raw ()", Strings.VName_Mass), Quantity.Mass, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "", w.GetTestRslt(t).MassEndRaw, GetDeviceId(w.GetTestRslt(t), x => x.Scale))));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Mass_end, string.Format("{0} EN ()", Strings.VName_Mass), Quantity.Mass, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "", w.GetTestRslt(t).MassEnd, GetDeviceId(w.GetTestRslt(t), x => x.Scale))));
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.Mass, string.Format("{0} ()", Strings.VName_Mass), Quantity.Mass, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "", w.GetTestRslt(t).MassEnd - w.GetTestRslt(t).MassStart, GetDeviceId(w.GetTestRslt(t), x => x.Scale))));
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
/// Density
|
|
|
|
@@ -453,6 +455,26 @@ namespace Results
|
|
|
|
|
AllItems.Add(new WMeterRsltItemSpec(ItemID.WMRemark, string.Format("{0} {1}", Strings.Water_Meter, Strings.Remark), Quantity.String, ItemCategory.MeterResult, (w, t, u, f, p) => FormatStr(f, w.Remark)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Obtaing a nonzero device Id from a testRslt.Components entity is if exists.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="testRslt">Test result</param>
|
|
|
|
|
/// <param name="mapping">Mapping from Components entity to device string</param>
|
|
|
|
|
/// <returns>Nonzero device Id or 0</returns>
|
|
|
|
|
static int GetDeviceId(TestRslt testRslt, Func<Components, string> mapping)
|
|
|
|
|
{
|
|
|
|
|
if (testRslt.Components == null) return 0;
|
|
|
|
|
|
|
|
|
|
string device = mapping(testRslt.Components);
|
|
|
|
|
if (string.IsNullOrEmpty(device)) return 0;
|
|
|
|
|
|
|
|
|
|
string deviceDigits = new String(device.Where(c => char.IsDigit(c)).ToArray());
|
|
|
|
|
int deviceNo;
|
|
|
|
|
if (int.TryParse(deviceDigits, out deviceNo)) return deviceNo;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// To be updated by Output.FileWriter or Output.Printer
|
|
|
|
|
public static int TableRowNr;
|
|
|
|
|
public static int TableColumnNr;
|
|
|
|
@@ -481,8 +503,17 @@ namespace Results
|
|
|
|
|
return string.IsNullOrEmpty(format) ? value.ToString() : string.Format(format, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string FormatDbl(Config.Unit units, string format, string precisionOrEmpty, string dfltPrecision, double v)
|
|
|
|
|
public static string FormatDbl(Config.Unit units, string format, string precisionOrEmpty, string dfltPrecision, double v, int precisionIdx = 0)
|
|
|
|
|
{
|
|
|
|
|
if (precisionIdx > 0 && !string.IsNullOrEmpty(precisionOrEmpty) && precisionOrEmpty.Contains('/'))
|
|
|
|
|
{
|
|
|
|
|
string[] precisions = precisionOrEmpty.Split(new char[] { '/' });
|
|
|
|
|
if (precisions.Length > precisionIdx - 1)
|
|
|
|
|
{
|
|
|
|
|
return FormatDbl(units, format, precisions[precisionIdx - 1], dfltPrecision, v, CultureInfo.CurrentCulture);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FormatDbl(units, format, precisionOrEmpty, dfltPrecision, v, CultureInfo.CurrentCulture);
|
|
|
|
|
}
|
|
|
|
|
///
|
|
|
|
|