diff --git a/Results/ItemSpec.cs b/Results/ItemSpec.cs index 90e742696..ccbba5569 100644 --- a/Results/ItemSpec.cs +++ b/Results/ItemSpec.cs @@ -46,7 +46,8 @@ namespace Results /// Safe wrapper which replaces null-s by empty strings 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; } diff --git a/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/FactoryCompound.cs b/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/FactoryCompound.cs index b6db680d3..d53d08925 100644 --- a/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/FactoryCompound.cs +++ b/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/FactoryCompound.cs @@ -17,11 +17,13 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced public IComponent GetComponent(IComponentCfg cfg, IList 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; } } } diff --git a/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/FactoryHeatMeters.cs b/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/FactoryHeatMeters.cs new file mode 100644 index 000000000..9f607c4ee --- /dev/null +++ b/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/FactoryHeatMeters.cs @@ -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 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; + } + } +} diff --git a/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/FactorySingle.cs b/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/FactorySingle.cs index 8429dd8a5..a101701f2 100644 --- a/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/FactorySingle.cs +++ b/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/FactorySingle.cs @@ -17,11 +17,13 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced public IComponent GetComponent(IComponentCfg cfg, IList 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; } } } diff --git a/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/ResultsConfigDlg.cs b/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/ResultsConfigDlg.cs index a5704fece..a5ccd5e91 100644 --- a/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/ResultsConfigDlg.cs +++ b/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/ResultsConfigDlg.cs @@ -14,7 +14,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced public IList AvailableItems; public IList 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(); 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); + } + } } } diff --git a/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/Writer.cs b/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/Writer.cs index ea4709458..b11b6e49d 100644 --- a/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/Writer.cs +++ b/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/Writer.cs @@ -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 diff --git a/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/WriterCfg.cs b/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/WriterCfg.cs index 2c5a2c855..2c2bfec3d 100644 --- a/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/WriterCfg.cs +++ b/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/WriterCfg.cs @@ -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) diff --git a/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/WriterCfgCtrl.cs b/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/WriterCfgCtrl.cs index c7db0177b..3dd01f3d4 100644 --- a/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/WriterCfgCtrl.cs +++ b/TestBenchFramework/BenchControl/Output/FileWriters/Enhanced/WriterCfgCtrl.cs @@ -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(); + ResultsConfigDlg dlg = new ResultsConfigDlg() { MetersKind = config.MetersKind, + SelectedItems = Results.ItemSpec.FromStrArray(testItems), + AvailableItems = new List() }; + foreach (var v in Results.ItemSpec.AllItems) dlg.AvailableItems.Add(v); if (dlg.ShowDialog() == DialogResult.OK) diff --git a/TestBenchFramework/BenchControl/TbfComponents.cs b/TestBenchFramework/BenchControl/TbfComponents.cs index 8510e44a5..26436661e 100644 --- a/TestBenchFramework/BenchControl/TbfComponents.cs +++ b/TestBenchFramework/BenchControl/TbfComponents.cs @@ -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()); diff --git a/TestBenchFramework/TBF.csproj b/TestBenchFramework/TBF.csproj index 9ca9b0f36..fcef1b6ea 100644 --- a/TestBenchFramework/TBF.csproj +++ b/TestBenchFramework/TBF.csproj @@ -488,6 +488,7 @@ + Form