Output.FileWriters.Enhanced.HeatMeters
This commit is contained in:
parent
38d6016aec
commit
f866f5fb2c
@ -46,7 +46,8 @@ namespace Results
|
||||
/// <summary> Safe wrapper which replaces null-s by empty strings </summary>
|
||||
public string Print(MeterTestRslt meterTestRslt)
|
||||
{
|
||||
string str = printDlgt(meterTestRslt);
|
||||
string str = null;
|
||||
if (printDlgt != null) str = printDlgt(meterTestRslt);
|
||||
return (str == null) ? string.Empty : str;
|
||||
}
|
||||
|
||||
@ -55,7 +56,8 @@ namespace Results
|
||||
MeterTestRslt auxMtrTestResult,
|
||||
MeterTestRslt compoundMtrTestResult)
|
||||
{
|
||||
string str = printCompoundDlgt(mainMtrTestResult, auxMtrTestResult, compoundMtrTestResult);
|
||||
string str = null;
|
||||
if (printCompoundDlgt != null) str = printCompoundDlgt(mainMtrTestResult, auxMtrTestResult, compoundMtrTestResult);
|
||||
return (str == null) ? string.Empty : str;
|
||||
}
|
||||
|
||||
@ -63,7 +65,8 @@ namespace Results
|
||||
public string PrintHeatMeter(MeterTestRslt volumeTestResult,
|
||||
MeterTestRslt energyTestResult)
|
||||
{
|
||||
string str = printHeatMeterDlgt(volumeTestResult, energyTestResult);
|
||||
string str = null;
|
||||
if (printHeatMeterDlgt != null) str = printHeatMeterDlgt(volumeTestResult, energyTestResult);
|
||||
return (str == null) ? string.Empty : str;
|
||||
}
|
||||
|
||||
|
||||
@ -17,11 +17,13 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
|
||||
|
||||
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Writer(cfg); }
|
||||
|
||||
public IComponentCfg DefaultConfig() { return new WriterCfg(this); }
|
||||
public IComponentCfg DefaultConfig() { return new WriterCfg("FileWriter.Enhanced.Compound", this, Config.Entities.MetersKind.Combined); }
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
|
||||
{
|
||||
return ComponentCfgBase.CreateFromDbEntity(typeof(WriterCfg), component, this);
|
||||
IComponentCfg cfg = ComponentCfgBase.CreateFromDbEntity(typeof(WriterCfg), component, this);
|
||||
(cfg as WriterCfg).MetersKind = Config.Entities.MetersKind.Combined;
|
||||
return cfg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
///
|
||||
/// Copyright (c) 2016 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.Output.FileWriters.Enhanced
|
||||
{
|
||||
public class FactoryHeatMeters : IComponentFactory
|
||||
{
|
||||
public string ClassName { get { return this.GetType().Namespace.Substring(17) + ".HeatMeters"; } }
|
||||
|
||||
public void ResetStaticProperties() { Writer.ResetStaticProperties(); }
|
||||
|
||||
public IComponent DummyComponent() { return new Writer(); }
|
||||
|
||||
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Writer(cfg); }
|
||||
|
||||
public IComponentCfg DefaultConfig() { return new WriterCfg("FileWriter.Enhanced.HeatMeters", this, Config.Entities.MetersKind.HeatMeter); }
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
|
||||
{
|
||||
IComponentCfg cfg = ComponentCfgBase.CreateFromDbEntity(typeof(WriterCfg), component, this);
|
||||
(cfg as WriterCfg).MetersKind = Config.Entities.MetersKind.HeatMeter;
|
||||
return cfg;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -17,11 +17,13 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
|
||||
|
||||
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Writer(cfg); }
|
||||
|
||||
public IComponentCfg DefaultConfig() { return new WriterCfg(this); }
|
||||
public IComponentCfg DefaultConfig() { return new WriterCfg("FileWriter.Enhanced.Single", this, Config.Entities.MetersKind.Single); }
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
|
||||
{
|
||||
return ComponentCfgBase.CreateFromDbEntity(typeof(WriterCfg), component, this);
|
||||
IComponentCfg cfg = ComponentCfgBase.CreateFromDbEntity(typeof(WriterCfg), component, this);
|
||||
(cfg as WriterCfg).MetersKind = Config.Entities.MetersKind.Single;
|
||||
return cfg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
|
||||
public IList<Results.ItemSpec> AvailableItems;
|
||||
public IList<Results.ItemSpec> SelectedItems;
|
||||
|
||||
public bool Compound; /// false = single meter items, true = combined meter items
|
||||
public MetersKind MetersKind;
|
||||
|
||||
public ResultsConfigDlg()
|
||||
{
|
||||
@ -49,11 +49,16 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
|
||||
AvailableItems = new List<Results.ItemSpec>();
|
||||
foreach (var item in Results.ItemSpec.AllItems)
|
||||
{
|
||||
if (!SelectedItems.Contains(item) && (Compound ? item.CanPrintCompoundMeter : item.CanPrintSingle))
|
||||
{
|
||||
AvailableItems.Add(item);
|
||||
availableResultsListBox.Items.Add(item.Name);
|
||||
}
|
||||
if (((MetersKind == MetersKind.Single) && item.CanPrintSingle) ||
|
||||
((MetersKind == MetersKind.Combined) && item.CanPrintCompoundMeter) ||
|
||||
((MetersKind == MetersKind.HeatMeter) && item.CanPrintHeatMeter))
|
||||
{
|
||||
if (!SelectedItems.Contains(item))
|
||||
{
|
||||
AvailableItems.Add(item);
|
||||
availableResultsListBox.Items.Add(item.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -272,21 +272,25 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
|
||||
{
|
||||
string itemText;
|
||||
|
||||
if (!wm.Compound())
|
||||
{
|
||||
/// Single water meter
|
||||
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 = testItems[i].PrintCombined(mainMtr, auxMtr, mtr);
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (wm.Compound())
|
||||
{
|
||||
if (mtr.CompoundMeterId != (byte)CompoundMeterId.Compound) continue;
|
||||
|
||||
Results.Entities.MeterTestRslt mainMtr = wm.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundMain);
|
||||
Results.Entities.MeterTestRslt auxMtr = wm.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundAux);
|
||||
itemText = testItems[i].PrintCombined(mainMtr, auxMtr, mtr);
|
||||
}
|
||||
else if (wm.HeatMeter())
|
||||
{
|
||||
if (mtr.CompoundMeterId != (byte)CompoundMeterId.HeatMeterEnergy) continue;
|
||||
|
||||
Results.Entities.MeterTestRslt volumeMtr = wm.GetMeterTestRslt(mtr.Name(), CompoundMeterId.HeatMeterVolume);
|
||||
itemText = testItems[i].PrintHeatMeter(volumeMtr, mtr);
|
||||
}
|
||||
else /// Single water meter
|
||||
{
|
||||
itemText = testItems[i].Print(mtr);
|
||||
}
|
||||
|
||||
/// Strip color information
|
||||
string[] texts = itemText.Split(new char[] { '|' });
|
||||
@ -339,21 +343,25 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
|
||||
///
|
||||
/// Fetch an item
|
||||
///
|
||||
if (!wm.Compound())
|
||||
{
|
||||
/// Single water meter
|
||||
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 = testItems[i].PrintCombined(mainMtr, auxMtr, mtr);
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (wm.Compound() && 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 = testItems[i].PrintCombined(mainMtr, auxMtr, mtr);
|
||||
}
|
||||
else if (wm.HeatMeter() && mtr.CompoundMeterId == (byte)CompoundMeterId.HeatMeterEnergy)
|
||||
{
|
||||
Results.Entities.MeterTestRslt volumeMtr = wm.GetMeterTestRslt(mtr.Name(), CompoundMeterId.HeatMeterVolume);
|
||||
itemText = testItems[i].PrintHeatMeter(volumeMtr, mtr);
|
||||
}
|
||||
else if (!wm.Compound() && !wm.HeatMeter() && mtr.CompoundMeterId == (byte)CompoundMeterId.Single) /// Single water meter
|
||||
{
|
||||
itemText = testItems[i].Print(mtr);
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
///
|
||||
/// Print the item
|
||||
|
||||
@ -61,28 +61,32 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
|
||||
public string Header;
|
||||
public string Footer;
|
||||
|
||||
[XmlIgnore]
|
||||
public Config.Entities.MetersKind MetersKind;
|
||||
|
||||
/// Private parameterless constructor invoked by all other (public) constructors
|
||||
WriterCfg()
|
||||
{
|
||||
Name = "FileWriter";
|
||||
}
|
||||
|
||||
public WriterCfg(string name, IComponentFactory factory, Config.Entities.MetersKind metersKind)
|
||||
: this()
|
||||
{
|
||||
Name = name;
|
||||
Factory = factory;
|
||||
MetersKind = metersKind;
|
||||
|
||||
ParentName = string.Empty;
|
||||
DestinationPath = Program.HomeDir + "Results\\";
|
||||
DestinationPath = Program.HomeDir + "Results\\";
|
||||
DestinationPath2 = string.Empty;
|
||||
YearFolders = YearFolders.FourDigit;
|
||||
MonthFolders = MonthFolders.Digit;
|
||||
DayFolders = DayFolders.Digit;
|
||||
FileNameFormat = "{0:yyMMdd-HHmm}.txt";
|
||||
Separator = Separator.None;
|
||||
EliminateSpaces = false;
|
||||
EliminateSpaces = false;
|
||||
Header = string.Empty;
|
||||
Footer = string.Empty;
|
||||
}
|
||||
|
||||
public WriterCfg(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
this.Factory = factory;
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
|
||||
@ -277,10 +277,10 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
|
||||
|
||||
private void testItemsButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
ResultsConfigDlg dlg = new ResultsConfigDlg();
|
||||
dlg.Compound = config.Factory.ClassName.Contains("Compound");
|
||||
dlg.SelectedItems = Results.ItemSpec.FromStrArray(testItems);
|
||||
dlg.AvailableItems = new List<Results.ItemSpec>();
|
||||
ResultsConfigDlg dlg = new ResultsConfigDlg() { MetersKind = config.MetersKind,
|
||||
SelectedItems = Results.ItemSpec.FromStrArray(testItems),
|
||||
AvailableItems = new List<Results.ItemSpec>() };
|
||||
|
||||
foreach (var v in Results.ItemSpec.AllItems) dlg.AvailableItems.Add(v);
|
||||
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
|
||||
@ -69,7 +69,8 @@ namespace TBF.BenchControl
|
||||
Factories.Add(new Output.FileWriters.Basic.FactoryCompound()); /// Output.FileWriters.Basic.Compound
|
||||
Factories.Add(new Output.FileWriters.Enhanced.FactorySingle()); /// Output.FileWriters.Basic.Single
|
||||
Factories.Add(new Output.FileWriters.Enhanced.FactoryCompound()); /// Output.FileWriters.Basic.Compound
|
||||
Factories.Add(new Elde.PressureMeter.PressureMeterFactory());
|
||||
Factories.Add(new Output.FileWriters.Enhanced.FactoryHeatMeters()); /// Output.FileWriters.Basic.HeatMeters
|
||||
Factories.Add(new Elde.PressureMeter.PressureMeterFactory());
|
||||
Factories.Add(new Elde.PressureMeterInternal.PressureMeterFactory());
|
||||
Factories.Add(new Elde.Pump.PumpFactory());
|
||||
Factories.Add(new Danfoss.VLT2800.PumpFactory());
|
||||
|
||||
@ -488,6 +488,7 @@
|
||||
<Compile Include="BenchControl\Output\FileWriters\Basic\FactoryCompound.cs" />
|
||||
<Compile Include="BenchControl\Output\FileWriters\Basic\FactorySingle.cs" />
|
||||
<Compile Include="BenchControl\Output\FileWriters\Enhanced\FactoryCompound.cs" />
|
||||
<Compile Include="BenchControl\Output\FileWriters\Enhanced\FactoryHeatMeters.cs" />
|
||||
<Compile Include="BenchControl\Output\FileWriters\Enhanced\FactorySingle.cs" />
|
||||
<Compile Include="BenchControl\Output\FileWriters\Enhanced\HeaderFooterDlg.cs">
|
||||
<SubType>Form</SubType>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user