diff --git a/Results/BatchResults.cs b/Results/BatchResults.cs new file mode 100644 index 000000000..73ab1e039 --- /dev/null +++ b/Results/BatchResults.cs @@ -0,0 +1,170 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Results.Entities; + +namespace Results +{ + public class BatchResults + { + public IList TestDataList; + public IList ComponentsList; + public IList WaterMeterDataList; + + public IDictionary TestRsltsMap; + public IDictionary[] MeterTestRsltsMap; + public IDictionary[] MainMeterTestRsltsMap; + public IDictionary[] AuxMeterTestRsltsMap; + + private BatchResults() + { + TestDataList = new List(); + ComponentsList = new List(); + WaterMeterDataList = new List(); + + TestRsltsMap = new Dictionary(); + } + + + + public int WMPositionsCount; + + public Batch Batch; + public WaterMeter[] WaterMeters; + public IList TestRslts; + public IList MeterTestRslts; + + public static BatchResults NewFromProcedure(int batchNr, + int benchId, + string user, + string programVer, + Config.Entities.Procedure procedure, + WaterMeterData[] waterMeterDatas, + int[] waterMeterParts) + { + BatchResults d = new BatchResults(); + + d.WMPositionsCount = waterMeterDatas.Length; + /// + d.MeterTestRsltsMap = new Dictionary[d.WMPositionsCount]; + d.MainMeterTestRsltsMap = new Dictionary[d.WMPositionsCount]; + d.AuxMeterTestRsltsMap = new Dictionary[d.WMPositionsCount]; + for (int wmnr = 0; wmnr < d.WMPositionsCount; wmnr++) + { + d.MeterTestRsltsMap[wmnr] = new Dictionary(); + d.MainMeterTestRsltsMap[wmnr] = new Dictionary(); + d.AuxMeterTestRsltsMap[wmnr] = new Dictionary(); + } + + /// Create new batch + d.Batch = new Batch() + { + TestBenchId = benchId, + BatchNr = batchNr, + ProgramVersion = programVer, + UserName = user, + ProcedureName = procedure.Name, + ProcedureRevision = procedure.Revision, + StartTime = DateTime.Now, + }; + + /// + /// Add watermeter to an array, array index is WM position. + /// AddWaterMetersToBatch() has to be used before saving results. + /// + d.WaterMeters = new WaterMeter[d.WMPositionsCount]; + for (int i = 0; i < d.WMPositionsCount; i++) + { + if (waterMeterDatas[i] == null) continue; + WaterMeterData wmd = WaterMeterData.UpdateList(d.WaterMeterDataList, waterMeterDatas[i]); + d.WaterMeters[i] = new WaterMeter() { Batch = d.Batch, WaterMeterData = wmd, WMPosition = i + 1 }; + } + + + foreach (var t in procedure.Tests) + { + if (t.Publish) + { + TestData td = TestData.UpdateList(d.TestDataList, new TestData(t)); + + for (int rnr = 1; rnr <= t.Repeats; rnr++) + { + /// Create an empty test result and add it to the list + TestRslt tr = new TestRslt(d.Batch, td, t.Part, rnr); + d.TestRslts.Add(tr); + d.TestRsltsMap.Add(tr.Name(), tr); + + for (int i = 0; i < d.WMPositionsCount; i++) + { + if (d.WaterMeters[i] == null) continue; + + if (t.Part != 0 && waterMeterParts[i] != 0 && t.Part != waterMeterParts[i]) continue; + + /// Create empty watermeter test results and add them to the list and to dictionaries + if (procedure.MetersKind == Config.Entities.MetersKind.Single) + { + MeterTestRslt mtr = new MeterTestRslt(d.WaterMeters[i], tr, Config.Entities.CompoundMeterId.Single); + d.WaterMeters[i].MeterTestRslts.Add(mtr); + d.MeterTestRsltsMap[i].Add(tr.Name(), mtr); + } + else + { + MeterTestRslt mainMTR = new MeterTestRslt(d.WaterMeters[i], tr, Config.Entities.CompoundMeterId.CompoundMain); + d.WaterMeters[i].MeterTestRslts.Add(mainMTR); + d.MainMeterTestRsltsMap[i].Add(tr.Name(), mainMTR); + + MeterTestRslt auxMTR = new MeterTestRslt(d.WaterMeters[i], tr, Config.Entities.CompoundMeterId.CompoundAux); + d.WaterMeters[i].MeterTestRslts.Add(auxMTR); + d.MainMeterTestRsltsMap[i].Add(tr.Name(), auxMTR); + + MeterTestRslt cmpdMTR = new MeterTestRslt(d.WaterMeters[i], tr, Config.Entities.CompoundMeterId.Compound); + d.WaterMeters[i].MeterTestRslts.Add(cmpdMTR); + d.MainMeterTestRsltsMap[i].Add(tr.Name(), cmpdMTR); + } + } + } + } + } + + return d; + } + + + public TestRslt GetTestRslt(string name, int part) + { + foreach (var tr in TestRslts) + { + if (part == tr.Part && name.Equals(tr.Name())) return tr; + } + return null; + } + + + public MeterTestRslt GetMeterTestRslt(string name, int wmnr0, Config.Entities.CompoundMeterId meterId) + { + if (WaterMeters[wmnr0] != null) + { + foreach (var mtr in WaterMeters[wmnr0].MeterTestRslts) + { + if (mtr.CompoundMeterId == (byte)meterId && name.Equals(mtr.Name())) return mtr; + } + } + return null; + } + + + /// + /// Adds non-null water meters from an array to a Batch water meters list. + /// This method should be used when results are prepared and + /// all disabled water meters are deleted. + /// + public void AddWaterMetersToBatch() + { + for (int i = 0; i < WMPositionsCount; i++) + { + if (WaterMeters[i] != null) Batch.WaterMeters.Add(WaterMeters[i]); + } + } + } +} diff --git a/Results/Data.cs b/Results/Data.cs deleted file mode 100644 index aaa1a26ee..000000000 --- a/Results/Data.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Results.Entities; - -namespace Results -{ - public class Data - { - public int WMPositionsCount; - - public Batch Batch; - public IList TestRslts; - public IList MeterTestRslts; - - public WaterMeter[] WaterMeters; - - public IDictionary TestRsltsMap; - public IDictionary MeterTestRsltsMap; - - public Data() - { - TestRsltsMap = new Dictionary(); - MeterTestRsltsMap = new Dictionary(); - } - - public static Data NewFromProcedure(Config.Entities.Procedure procedure, - WaterMeterData[] waterMeterDatas, - int batchNr, - int benchId, - string programVer, - string user) - { - Data d = new Data(); - - d.WMPositionsCount = waterMeterDatas.Length; - d.Batch = new Batch() - { - BenchId = benchId, - BatchNr = batchNr, - ProgramVersion = programVer, - UserName = user, - ProcedureName = procedure.Name, - ProcedureRevision = procedure.Revision, - StartTime = DateTime.Now - }; - foreach (var t in procedure.Tests) - { - } - - d.WaterMeters = new WaterMeter[d.WMPositionsCount]; - for (int i = 0; i < d.WMPositionsCount; i++) - { - if (waterMeterDatas[i] != null) - { - d.WaterMeters[i] = new WaterMeter(d.Batch, waterMeterDatas[i]); - } - } - - foreach (var t in procedure.Tests) - { - if (t.Publish) - { - d.Batch.Tests.Add(new TestData(t)); - - for (int i = 0; i < d.WMPositionsCount; i++) - { - if (d.WaterMeters[i] != null) - { - if (procedure.MetersKind == Config.Entities.MetersKind.Single) - { - //d.WaterMeters[i].MeterTestRslts.Add( - } - //else - //{ - //} - } - } - } - } - return d; - } - - /// - /// Adds non-null water meters from the array to a Batch water meters list. - /// This method should be used when results are prepared and - /// all disabled water meters are deleted. - /// - public void AddWaterMetersToBatch() - { - for (int i = 0; i < WMPositionsCount; i++) - { - if (WaterMeters[i] != null) Batch.WaterMeters.Add(WaterMeters[i]); - } - } - } -} diff --git a/Results/Entities/Batch.cs b/Results/Entities/Batch.cs index b8d3de596..8b84dabbc 100644 --- a/Results/Entities/Batch.cs +++ b/Results/Entities/Batch.cs @@ -9,8 +9,8 @@ namespace Results.Entities public class Batch { public virtual int Id { get; protected set; } - public virtual int BenchId { get; set; } public virtual int BatchNr { get; set; } + public virtual int TestBenchId { get; set; } public virtual string ProgramVersion { get; set; } public virtual string UserName { get; set; } public virtual string ProcedureName { get; set; } diff --git a/Results/Entities/Components.cs b/Results/Entities/Components.cs index f999bc203..de3f5d0a3 100644 --- a/Results/Entities/Components.cs +++ b/Results/Entities/Components.cs @@ -3,14 +3,15 @@ /// using System; using System.Collections.Generic; +using System.Linq; namespace Results.Entities { public class Components { public virtual int Id { get; protected set; } - public virtual int BenchId { get; set; } - public virtual string BenchName { get; set; } + public virtual int TestBenchId { get; set; } + public virtual string TestBenchName { get; set; } public virtual string Pump { get; set; } public virtual string RegValve { get; set; } public virtual string Flowmeter { get; set; } @@ -22,8 +23,8 @@ namespace Results.Entities protected Components() { - BenchId = 0; - BenchName = string.Empty; + TestBenchId = 0; + TestBenchName = string.Empty; Pump = string.Empty; RegValve = string.Empty; Flowmeter = string.Empty; @@ -37,8 +38,8 @@ namespace Results.Entities public Components(int benchId, string benchName, string pump, string flowmeter, string scale, string regValve, string diverter) { - BenchId = benchId; - BenchName = benchName; + TestBenchId = benchId; + TestBenchName = benchName; Pump = pump; RegValve = regValve; Flowmeter = flowmeter; @@ -49,10 +50,16 @@ namespace Results.Entities Custom3 = string.Empty; } + + /// + /// Method to compare the content of two entities + /// + /// Second entity to compare with + /// first = two entities are equal (except of Id) public virtual bool Equals(Components bc) { - if (BenchId != bc.BenchId) return false; - if (!BenchName.Equals(bc.BenchName)) return false; + if (TestBenchId != bc.TestBenchId) return false; + if (!TestBenchName.Equals(bc.TestBenchName)) return false; if (!Pump.Equals(bc.Pump)) return false; if (!RegValve.Equals(bc.RegValve)) return false; if (!Flowmeter.Equals(bc.Flowmeter)) return false; @@ -64,5 +71,22 @@ namespace Results.Entities return true; } + + + /// + /// Adds an item to the list if it does not occur there + /// + /// List of items + /// Item to add to the list or find there + /// Item from the list (existing or added) + public static Components UpdateList(IList list, Components item) + { + Components found = list.FirstOrDefault(x => x.Equals(item)); + + if (found != null) return found; + + list.Add(item); + return item; + } } } diff --git a/Results/Entities/MeterTestRslt.cs b/Results/Entities/MeterTestRslt.cs index 15a602c60..a0fe2e78d 100644 --- a/Results/Entities/MeterTestRslt.cs +++ b/Results/Entities/MeterTestRslt.cs @@ -20,7 +20,8 @@ namespace Results.Entities public virtual double TimestampEnd { get; set; } /// sec. public virtual double TestTime { get; set; } /// sec. public virtual double Error { get; set; } /// % - public virtual bool Passed { get; set; } /// true=test passed - Not mapped to DB !!! + public virtual bool TestDone { get; set; } /// true = test was completed + public virtual bool Passed { get; set; } /// true = test passed, water meter is OK public virtual WaterMeter WaterMeter { get; set; } /// reference to the TestData entity public virtual TestRslt TestRslt { get; set; } /// reference to the TestData entity @@ -48,15 +49,18 @@ namespace Results.Entities public virtual double Uncertainty() { return TestData().Uncertainty; } - protected MeterTestRslt() + public MeterTestRslt() { + TestDone = false; + Passed = false; } - public MeterTestRslt(WaterMeter waterMeterRslt, TestRslt testRslt) + public MeterTestRslt(WaterMeter waterMeterRslt, TestRslt testRslt, Config.Entities.CompoundMeterId compoundMeterId) : this() { WaterMeter = waterMeterRslt; TestRslt = testRslt; - } + CompoundMeterId = (byte)compoundMeterId; + } } } diff --git a/Results/Entities/TestData.cs b/Results/Entities/TestData.cs index 08ca0005d..bb20bee5c 100644 --- a/Results/Entities/TestData.cs +++ b/Results/Entities/TestData.cs @@ -1,8 +1,9 @@ /// -/// Copyright (c) 2015 Sensus Metering Systems +/// Copyright (c) 2016 Sensus Metering Systems /// using System; using System.Collections.Generic; +using System.Linq; namespace Results.Entities { @@ -47,6 +48,12 @@ namespace Results.Entities Evaluate = test.Evaluate; } + + /// + /// Method to compare the content of two entities + /// + /// Second entity to compare with + /// first = two entities are equal (except of Id) public virtual bool Equals(TestData td) { if (!Name.Equals(td.Name)) return false; @@ -63,5 +70,22 @@ namespace Results.Entities return true; } + + + /// + /// Adds an item to the list if it does not occur there + /// + /// List of items + /// Item to add to the list or find there + /// Item from the list (existing or added) + public static TestData UpdateList(IList list, TestData item) + { + TestData found = list.FirstOrDefault(x => x.Equals(item)); + + if (found != null) return found; + + list.Add(item); + return item; + } } } diff --git a/Results/Entities/WaterMeter.cs b/Results/Entities/WaterMeter.cs index f12556896..348a8e5df 100644 --- a/Results/Entities/WaterMeter.cs +++ b/Results/Entities/WaterMeter.cs @@ -21,6 +21,7 @@ namespace Results.Entities public virtual int SerialNrEx { get; set; } /// iPerl : This is the serial number assigned later public virtual double OrigCalibFactor { get; set; } /// iPerl calibration factor used during the test - Not mapped to DB !!! public virtual double CalibFactor { get; set; } /// iPerl calibration factor used during the test - Not mapped to DB !!! + public virtual bool Q2CorrectionDone { get; set; } /// true = iPerl Q2 correction was done public virtual double Q2Correction { get; set; } /// iPerl Q2 correction used during the test - Not mapped to DB !!! #endif @@ -43,7 +44,7 @@ namespace Results.Entities public virtual bool Compound() { return WaterMeterData.Compound; } public virtual int BatchNr() { return Batch.BatchNr; } - public virtual int BenchId() { return Batch.BenchId; } + public virtual int BenchId() { return Batch.TestBenchId; } public virtual string ProcedureName() { return Batch.ProcedureName; } public virtual int ProcedureRevision() { return Batch.ProcedureRevision; } public virtual DateTime StartTime() { return Batch.StartTime; } @@ -67,31 +68,13 @@ namespace Results.Entities /// - /// Private constructor, initializes a list, used as a base + /// Constructor, initializes a list, used as a base for other constructors /// - protected WaterMeter() + public WaterMeter() { MeterTestRslts = new List(); } - /// - /// Constructor used to construct WaterMeterResults from the first meter test result - /// - public WaterMeter(Batch batch, WaterMeterData waterMeterData) - : this() - { - Batch = batch; - WaterMeterData = waterMeterData; - } - - /// - /// Function to append result to a list of results and update start/end dates - /// - public virtual void Append(MeterTestResult meterTestResult) - { - /// TODO - } - public override string ToString() { diff --git a/Results/Entities/WaterMeterData.cs b/Results/Entities/WaterMeterData.cs index f7da3c47e..04180fcbc 100644 --- a/Results/Entities/WaterMeterData.cs +++ b/Results/Entities/WaterMeterData.cs @@ -1,8 +1,9 @@ /// -/// Copyright (c) 2015 Sensus Metering Systems +/// Copyright (c) 2016 Sensus Metering Systems /// using System; using System.Collections.Generic; +using System.Linq; namespace Results.Entities { @@ -27,5 +28,44 @@ namespace Results.Entities public WaterMeterData() { } + + + /// + /// Method to compare the content of two entities + /// + /// Second entity to compare with + /// first = two entities are equal (except of Id) + public virtual bool Equals(WaterMeterData wmd) + { + if (!ProductName.Equals(wmd.ProductName)) return false; + if (!Producer.Equals(wmd.Producer)) return false; + if (!MetrologicalClass.Equals(wmd.MetrologicalClass)) return false; + if (!ApprovalInfo.Equals(wmd.ApprovalInfo)) return false; + if (Q4_Qmax != wmd.Q4_Qmax) return false; + if (Qn != wmd.Qn) return false; + if (Q3 != wmd.Q3) return false; + if (Q2_Qt != wmd.Q2_Qt) return false; + if (Q1_Qmin != wmd.Q1_Qmin) return false; + if (Compound != wmd.Compound) return false; + + return true; + } + + + /// + /// Adds an item to the list if it does not occur there + /// + /// List of items + /// Item to add to the list or find there + /// Item from the list (existing or added) + public static WaterMeterData UpdateList(IList list, WaterMeterData item) + { + WaterMeterData found = list.FirstOrDefault(x => x.Equals(item)); + + if (found != null) return found; + + list.Add(item); + return item; + } } } diff --git a/Results/Mappings/BatchMap.cs b/Results/Mappings/BatchMap.cs index 9cc796f50..ee890de32 100644 --- a/Results/Mappings/BatchMap.cs +++ b/Results/Mappings/BatchMap.cs @@ -11,8 +11,8 @@ namespace Results.Mappings public BatchMap() { Id(x => x.Id); - Map(x => x.BenchId); Map(x => x.BatchNr); + Map(x => x.TestBenchId); Map(x => x.ProgramVersion); Map(x => x.UserName); Map(x => x.ProcedureName); diff --git a/Results/Mappings/ComponentsMap.cs b/Results/Mappings/ComponentsMap.cs index c574ad3e5..245c2ef13 100644 --- a/Results/Mappings/ComponentsMap.cs +++ b/Results/Mappings/ComponentsMap.cs @@ -11,8 +11,8 @@ namespace Results.Mappings public ComponentsMap() { Id(x => x.Id); - Map(x => x.BenchId); - Map(x => x.BenchName); + Map(x => x.TestBenchId); + Map(x => x.TestBenchName); Map(x => x.Pump); Map(x => x.RegValve); Map(x => x.Flowmeter); diff --git a/Results/Mappings/MeterTestRsltMap.cs b/Results/Mappings/MeterTestRsltMap.cs index cb9cde648..d343e6c16 100644 --- a/Results/Mappings/MeterTestRsltMap.cs +++ b/Results/Mappings/MeterTestRsltMap.cs @@ -22,6 +22,7 @@ namespace Results.Mappings Map(x => x.TimestampEnd); Map(x => x.TestTime); Map(x => x.Error); + Map(x => x.TestDone); Map(x => x.Passed); References(x => x.WaterMeter); diff --git a/Results/Mappings/WaterMeterMap.cs b/Results/Mappings/WaterMeterMap.cs index 8d7376061..7bc0d386f 100644 --- a/Results/Mappings/WaterMeterMap.cs +++ b/Results/Mappings/WaterMeterMap.cs @@ -23,6 +23,7 @@ namespace Results.Mappings Map(x => x.SerialNrEx); Map(x => x.OrigCalibFactor); Map(x => x.CalibFactor); + Map(x =? x.Q2CorrectionDone); Map(x => x.Q2Correction); #endif References(x => x.WaterMeterData); diff --git a/Results/Results.csproj b/Results/Results.csproj index 1620303a6..9e6c4d1e4 100644 --- a/Results/Results.csproj +++ b/Results/Results.csproj @@ -56,7 +56,7 @@ - + diff --git a/ResultsBrowser/DataDeposit.cs b/ResultsBrowser/DataDeposit.cs index cbe8c2249..de7a2d7e7 100644 --- a/ResultsBrowser/DataDeposit.cs +++ b/ResultsBrowser/DataDeposit.cs @@ -78,7 +78,8 @@ namespace ResultsBrowser { for (int i = 0; i < Math.Min(tr.Meters.Count, wmResults.Count); i++) { - wmResults[i].Append(tr.Meters[i]); + // TODO: Rewrite + //wmResults[i].MeterTestResults(tr.Meters[i]); } } } diff --git a/TestBenchFramework/BenchControl/BenchInfo/Munich/Component.cs b/TestBenchFramework/BenchControl/BenchInfo/Munich/Component.cs index 52aa0e809..c42c09d81 100644 --- a/TestBenchFramework/BenchControl/BenchInfo/Munich/Component.cs +++ b/TestBenchFramework/BenchControl/BenchInfo/Munich/Component.cs @@ -22,7 +22,8 @@ namespace TBF.BenchControl.BenchInfo.Munich readonly ComponentCfg benchInfoCfg; - public string TestBenchId { get { return benchInfoCfg.TestBenchId; } } + public string TestBenchName { get { return benchInfoCfg.TestBenchName; } } + public int TestBenchId { get { return benchInfoCfg.TestBenchId; } } public Component() { diff --git a/TestBenchFramework/BenchControl/BenchInfo/Munich/ComponentCfg.cs b/TestBenchFramework/BenchControl/BenchInfo/Munich/ComponentCfg.cs index 5152bcdd1..098c5c84b 100644 --- a/TestBenchFramework/BenchControl/BenchInfo/Munich/ComponentCfg.cs +++ b/TestBenchFramework/BenchControl/BenchInfo/Munich/ComponentCfg.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2016 Sensus Metering Systems /// Author: Milan Hanajík /// using System; @@ -20,15 +20,17 @@ namespace TBF.BenchControl.BenchInfo.Munich /// /// Serialized parameters /// - public string TestBenchId; + public string TestBenchName; + public int TestBenchId; /// Private parameterless constructor invoked by all other (public) constructors ComponentCfg() { Name = "BenchInfo"; ParentName = string.Empty; - TestBenchId = "1"; - } + TestBenchName = "1"; + TestBenchId = 1; + } public ComponentCfg(IComponentFactory factory) : this() @@ -38,7 +40,7 @@ namespace TBF.BenchControl.BenchInfo.Munich public string ToString(int i) { - return string.Format("Name={0}, TestBenchId={1}", Name, TestBenchId); + return string.Format("Name={0}, Bench name={1}, Bench Id={2}", Name, TestBenchName, TestBenchId); } } } diff --git a/TestBenchFramework/BenchControl/BenchInfo/Munich/ComponentCfgCtrl.cs b/TestBenchFramework/BenchControl/BenchInfo/Munich/ComponentCfgCtrl.cs index 2d816b1a7..d628fca46 100644 --- a/TestBenchFramework/BenchControl/BenchInfo/Munich/ComponentCfgCtrl.cs +++ b/TestBenchFramework/BenchControl/BenchInfo/Munich/ComponentCfgCtrl.cs @@ -35,7 +35,8 @@ namespace TBF.BenchControl.BenchInfo.Munich private void EntryFormCfgCtrl_Load(object sender, EventArgs e) { nameLabel.Text = Strings.Name; - numberLabel.Text = Strings.Test_bench_number; + benchNameLabel.Text = Strings.Test_bench_name; + benchIdLabel.Text = Strings.Test_bench_number; Redraw(); } @@ -46,20 +47,30 @@ namespace TBF.BenchControl.BenchInfo.Munich void Redraw() { if (config == null) return; /// Control was not loaded, settings were not changed + classNameLabel.Text = config.Factory.ClassName; nameTextBox.Text = config.Name; - numberTextBox.Text = config.TestBenchId; + benchNameTextBox.Text = config.TestBenchName; + benchIdTextBox.Text = config.TestBenchId.ToString(); } public void Unlock() { nameTextBox.Enabled = true; - numberTextBox.Enabled = true; + benchNameTextBox.Enabled = true; + benchIdTextBox.Enabled = true; } public CfgUpdateFlags VerifyCfg(ref string message) { CfgUpdateFlags flags = CfgUpdateFlags.None; + + int dummy; + if (!int.TryParse(benchIdTextBox.Text, out dummy) || dummy < 0) + { + flags = CfgUpdateFlags.Error; + message = string.Format("Invalid {0} parameter", Strings.Test_bench_number); + } return flags; } @@ -70,7 +81,8 @@ namespace TBF.BenchControl.BenchInfo.Munich if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed /// config.Name = nameTextBox.Text; - config.TestBenchId = numberTextBox.Text; + config.TestBenchName = benchNameTextBox.Text; + config.TestBenchId = int.Parse(benchIdTextBox.Text); return flags; } diff --git a/TestBenchFramework/BenchControl/BenchInfo/Munich/ComponentCfgCtrl.designer.cs b/TestBenchFramework/BenchControl/BenchInfo/Munich/ComponentCfgCtrl.designer.cs index 65b7d40e2..d714ecd60 100644 --- a/TestBenchFramework/BenchControl/BenchInfo/Munich/ComponentCfgCtrl.designer.cs +++ b/TestBenchFramework/BenchControl/BenchInfo/Munich/ComponentCfgCtrl.designer.cs @@ -34,14 +34,16 @@ namespace TBF.BenchControl.BenchInfo.Munich this.nameTextBox = new System.Windows.Forms.TextBox(); this.nameLabel = new System.Windows.Forms.Label(); this.classNameLabel = new System.Windows.Forms.Label(); - this.numberLabel = new System.Windows.Forms.Label(); - this.numberTextBox = new System.Windows.Forms.TextBox(); + this.benchNameLabel = new System.Windows.Forms.Label(); + this.benchNameTextBox = new System.Windows.Forms.TextBox(); + this.benchIdTextBox = new System.Windows.Forms.TextBox(); + this.benchIdLabel = new System.Windows.Forms.Label(); this.SuspendLayout(); // // nameTextBox // this.nameTextBox.Enabled = false; - this.nameTextBox.Location = new System.Drawing.Point(135, 55); + this.nameTextBox.Location = new System.Drawing.Point(140, 55); this.nameTextBox.Name = "nameTextBox"; this.nameTextBox.Size = new System.Drawing.Size(130, 20); this.nameTextBox.TabIndex = 5; @@ -58,35 +60,54 @@ namespace TBF.BenchControl.BenchInfo.Munich // classNameLabel // this.classNameLabel.AutoSize = true; - this.classNameLabel.Location = new System.Drawing.Point(132, 31); + this.classNameLabel.Location = new System.Drawing.Point(137, 31); this.classNameLabel.Name = "classNameLabel"; this.classNameLabel.Size = new System.Drawing.Size(60, 13); this.classNameLabel.TabIndex = 3; this.classNameLabel.Text = "ClassName"; // - // numberLabel + // benchNameLabel // - this.numberLabel.AutoSize = true; - this.numberLabel.Location = new System.Drawing.Point(25, 86); - this.numberLabel.Name = "numberLabel"; - this.numberLabel.Size = new System.Drawing.Size(44, 13); - this.numberLabel.TabIndex = 6; - this.numberLabel.Text = "Number"; + this.benchNameLabel.AutoSize = true; + this.benchNameLabel.Location = new System.Drawing.Point(25, 84); + this.benchNameLabel.Name = "benchNameLabel"; + this.benchNameLabel.Size = new System.Drawing.Size(90, 13); + this.benchNameLabel.TabIndex = 6; + this.benchNameLabel.Text = "Test bench name"; // - // numberTextBox + // benchNameTextBox // - this.numberTextBox.Enabled = false; - this.numberTextBox.Location = new System.Drawing.Point(135, 83); - this.numberTextBox.Name = "numberTextBox"; - this.numberTextBox.Size = new System.Drawing.Size(57, 20); - this.numberTextBox.TabIndex = 7; + this.benchNameTextBox.Enabled = false; + this.benchNameTextBox.Location = new System.Drawing.Point(140, 81); + this.benchNameTextBox.Name = "benchNameTextBox"; + this.benchNameTextBox.Size = new System.Drawing.Size(67, 20); + this.benchNameTextBox.TabIndex = 7; + // + // benchIdTextBox + // + this.benchIdTextBox.Enabled = false; + this.benchIdTextBox.Location = new System.Drawing.Point(140, 107); + this.benchIdTextBox.Name = "benchIdTextBox"; + this.benchIdTextBox.Size = new System.Drawing.Size(67, 20); + this.benchIdTextBox.TabIndex = 9; + // + // benchIdLabel + // + this.benchIdLabel.AutoSize = true; + this.benchIdLabel.Location = new System.Drawing.Point(25, 110); + this.benchIdLabel.Name = "benchIdLabel"; + this.benchIdLabel.Size = new System.Drawing.Size(99, 13); + this.benchIdLabel.TabIndex = 8; + this.benchIdLabel.Text = "Test bench number"; // // ComponentCfgCtrl // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.numberTextBox); - this.Controls.Add(this.numberLabel); + this.Controls.Add(this.benchIdTextBox); + this.Controls.Add(this.benchIdLabel); + this.Controls.Add(this.benchNameTextBox); + this.Controls.Add(this.benchNameLabel); this.Controls.Add(this.nameTextBox); this.Controls.Add(this.nameLabel); this.Controls.Add(this.classNameLabel); @@ -103,7 +124,9 @@ namespace TBF.BenchControl.BenchInfo.Munich private System.Windows.Forms.TextBox nameTextBox; private System.Windows.Forms.Label nameLabel; private System.Windows.Forms.Label classNameLabel; - private System.Windows.Forms.Label numberLabel; - private System.Windows.Forms.TextBox numberTextBox; + private System.Windows.Forms.Label benchNameLabel; + private System.Windows.Forms.TextBox benchNameTextBox; + private System.Windows.Forms.TextBox benchIdTextBox; + private System.Windows.Forms.Label benchIdLabel; } } diff --git a/TestBenchFramework/BenchControl/BenchInfo/Polska/Component.cs b/TestBenchFramework/BenchControl/BenchInfo/Polska/Component.cs index f7d8185e8..15026736f 100644 --- a/TestBenchFramework/BenchControl/BenchInfo/Polska/Component.cs +++ b/TestBenchFramework/BenchControl/BenchInfo/Polska/Component.cs @@ -22,7 +22,8 @@ namespace TBF.BenchControl.BenchInfo.Polska readonly ComponentCfg benchInfoCfg; - public string TestBenchId { get { return benchInfoCfg.TestBenchId; } } + public string TestBenchName { get { return benchInfoCfg.TestBenchName; } } + public int TestBenchId { get { return benchInfoCfg.TestBenchId; } } public Component() { diff --git a/TestBenchFramework/BenchControl/BenchInfo/Polska/ComponentCfg.cs b/TestBenchFramework/BenchControl/BenchInfo/Polska/ComponentCfg.cs index 79ed88556..aa0f87601 100644 --- a/TestBenchFramework/BenchControl/BenchInfo/Polska/ComponentCfg.cs +++ b/TestBenchFramework/BenchControl/BenchInfo/Polska/ComponentCfg.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2015 Sensus Metering Systems +/// Copyright (c) 2015-2016 Sensus Metering Systems /// Author: Milan Hanajík /// using System; @@ -20,7 +20,8 @@ namespace TBF.BenchControl.BenchInfo.Polska /// /// Serialized parameters /// - public string TestBenchId; + public string TestBenchName; + public int TestBenchId; public string Address1; public string Address2; public string Address3; @@ -35,7 +36,8 @@ namespace TBF.BenchControl.BenchInfo.Polska { Name = "BenchInfo"; ParentName = string.Empty; - TestBenchId = "1"; + TestBenchName = "1"; + TestBenchId = 1; Address1 = string.Empty; Address2 = string.Empty; @@ -56,7 +58,7 @@ namespace TBF.BenchControl.BenchInfo.Polska public string ToString(int i) { - return string.Format("Name={0}, TestBenchId={1}", Name, TestBenchId); + return string.Format("Name={0}, Bench name={1}, Bench Id={2}", Name, TestBenchName, TestBenchId); } } } diff --git a/TestBenchFramework/BenchControl/BenchInfo/Polska/ComponentCfgCtrl.cs b/TestBenchFramework/BenchControl/BenchInfo/Polska/ComponentCfgCtrl.cs index 575e7ca6a..cbfc07ce0 100644 --- a/TestBenchFramework/BenchControl/BenchInfo/Polska/ComponentCfgCtrl.cs +++ b/TestBenchFramework/BenchControl/BenchInfo/Polska/ComponentCfgCtrl.cs @@ -35,6 +35,7 @@ namespace TBF.BenchControl.BenchInfo.Polska private void EntryFormCfgCtrl_Load(object sender, EventArgs e) { nameLabel.Text = Strings.Name; + benchNameLabel.Text = Strings.Test_bench_name; benchIdLabel.Text = Strings.Test_bench_number; address1Label.Text = Strings.Address + " 1"; @@ -56,10 +57,11 @@ namespace TBF.BenchControl.BenchInfo.Polska void Redraw() { if (config == null) return; /// Control was not loaded, settings were not changed - /// + classNameLabel.Text = config.Factory.ClassName; nameTextBox.Text = config.Name; - benchIdTextBox.Text = config.TestBenchId; + benchNameTextBox.Text = config.TestBenchName; + benchIdTextBox.Text = config.TestBenchId.ToString(); address1TextBox.Text = config.Address1; address2TextBox.Text = config.Address2; @@ -75,6 +77,7 @@ namespace TBF.BenchControl.BenchInfo.Polska public void Unlock() { nameTextBox.Enabled = true; + benchNameTextBox.Enabled = true; benchIdTextBox.Enabled = true; address1TextBox.Enabled = true; @@ -91,6 +94,13 @@ namespace TBF.BenchControl.BenchInfo.Polska public CfgUpdateFlags VerifyCfg(ref string message) { CfgUpdateFlags flags = CfgUpdateFlags.None; + + int dummy; + if (!int.TryParse(benchIdTextBox.Text, out dummy) || dummy < 0) + { + flags = CfgUpdateFlags.Error; + message = string.Format("Invalid {0} parameter", Strings.Test_bench_number); + } return flags; } @@ -101,7 +111,8 @@ namespace TBF.BenchControl.BenchInfo.Polska if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed /// config.Name = nameTextBox.Text; - config.TestBenchId = benchIdTextBox.Text; + config.TestBenchName = benchNameTextBox.Text; + config.TestBenchId = int.Parse(benchIdTextBox.Text); config.Address1 = address1TextBox.Text; config.Address2 = address2TextBox.Text; diff --git a/TestBenchFramework/BenchControl/BenchInfo/Polska/ComponentCfgCtrl.designer.cs b/TestBenchFramework/BenchControl/BenchInfo/Polska/ComponentCfgCtrl.designer.cs index dca950a17..d2fb5adf5 100644 --- a/TestBenchFramework/BenchControl/BenchInfo/Polska/ComponentCfgCtrl.designer.cs +++ b/TestBenchFramework/BenchControl/BenchInfo/Polska/ComponentCfgCtrl.designer.cs @@ -52,23 +52,25 @@ namespace TBF.BenchControl.BenchInfo.Polska this.approvalDateLabel = new System.Windows.Forms.Label(); this.approvalIdTextBox = new System.Windows.Forms.TextBox(); this.approvalIdLabel = new System.Windows.Forms.Label(); + this.benchNameTextBox = new System.Windows.Forms.TextBox(); + this.benchNameLabel = new System.Windows.Forms.Label(); this.SuspendLayout(); // // nameTextBox // this.nameTextBox.Enabled = false; - this.nameTextBox.Location = new System.Drawing.Point(113, 26); + this.nameTextBox.Location = new System.Drawing.Point(113, 24); this.nameTextBox.Name = "nameTextBox"; this.nameTextBox.Size = new System.Drawing.Size(88, 20); - this.nameTextBox.TabIndex = 5; + this.nameTextBox.TabIndex = 2; // // nameLabel // this.nameLabel.AutoSize = true; - this.nameLabel.Location = new System.Drawing.Point(6, 29); + this.nameLabel.Location = new System.Drawing.Point(6, 27); this.nameLabel.Name = "nameLabel"; this.nameLabel.Size = new System.Drawing.Size(35, 13); - this.nameLabel.TabIndex = 4; + this.nameLabel.TabIndex = 1; this.nameLabel.Text = "Name"; // // classNameLabel @@ -77,109 +79,109 @@ namespace TBF.BenchControl.BenchInfo.Polska this.classNameLabel.Location = new System.Drawing.Point(110, 6); this.classNameLabel.Name = "classNameLabel"; this.classNameLabel.Size = new System.Drawing.Size(60, 13); - this.classNameLabel.TabIndex = 3; + this.classNameLabel.TabIndex = 0; this.classNameLabel.Text = "ClassName"; // // benchIdLabel // this.benchIdLabel.AutoSize = true; - this.benchIdLabel.Location = new System.Drawing.Point(6, 50); + this.benchIdLabel.Location = new System.Drawing.Point(6, 66); this.benchIdLabel.Name = "benchIdLabel"; - this.benchIdLabel.Size = new System.Drawing.Size(52, 13); - this.benchIdLabel.TabIndex = 6; - this.benchIdLabel.Text = "Bench ID"; + this.benchIdLabel.Size = new System.Drawing.Size(99, 13); + this.benchIdLabel.TabIndex = 5; + this.benchIdLabel.Text = "Test bench number"; // // benchIdTextBox // this.benchIdTextBox.Enabled = false; - this.benchIdTextBox.Location = new System.Drawing.Point(113, 47); + this.benchIdTextBox.Location = new System.Drawing.Point(113, 64); this.benchIdTextBox.Name = "benchIdTextBox"; this.benchIdTextBox.Size = new System.Drawing.Size(57, 20); - this.benchIdTextBox.TabIndex = 7; + this.benchIdTextBox.TabIndex = 6; // // address1TextBox // this.address1TextBox.Enabled = false; - this.address1TextBox.Location = new System.Drawing.Point(73, 75); + this.address1TextBox.Location = new System.Drawing.Point(73, 86); this.address1TextBox.Name = "address1TextBox"; this.address1TextBox.Size = new System.Drawing.Size(220, 20); - this.address1TextBox.TabIndex = 9; + this.address1TextBox.TabIndex = 8; // // address1Label // this.address1Label.AutoSize = true; - this.address1Label.Location = new System.Drawing.Point(6, 78); + this.address1Label.Location = new System.Drawing.Point(6, 89); this.address1Label.Name = "address1Label"; this.address1Label.Size = new System.Drawing.Size(54, 13); - this.address1Label.TabIndex = 8; + this.address1Label.TabIndex = 7; this.address1Label.Text = "Address 1"; // // address2TextBox // this.address2TextBox.Enabled = false; - this.address2TextBox.Location = new System.Drawing.Point(73, 95); + this.address2TextBox.Location = new System.Drawing.Point(73, 106); this.address2TextBox.Name = "address2TextBox"; this.address2TextBox.Size = new System.Drawing.Size(220, 20); - this.address2TextBox.TabIndex = 11; + this.address2TextBox.TabIndex = 10; // // address2Label // this.address2Label.AutoSize = true; - this.address2Label.Location = new System.Drawing.Point(6, 98); + this.address2Label.Location = new System.Drawing.Point(6, 109); this.address2Label.Name = "address2Label"; this.address2Label.Size = new System.Drawing.Size(54, 13); - this.address2Label.TabIndex = 10; + this.address2Label.TabIndex = 9; this.address2Label.Text = "Address 2"; // // address3TextBox // this.address3TextBox.Enabled = false; - this.address3TextBox.Location = new System.Drawing.Point(73, 115); + this.address3TextBox.Location = new System.Drawing.Point(73, 126); this.address3TextBox.Name = "address3TextBox"; this.address3TextBox.Size = new System.Drawing.Size(220, 20); - this.address3TextBox.TabIndex = 13; + this.address3TextBox.TabIndex = 12; // // address3Label // this.address3Label.AutoSize = true; - this.address3Label.Location = new System.Drawing.Point(6, 118); + this.address3Label.Location = new System.Drawing.Point(6, 129); this.address3Label.Name = "address3Label"; this.address3Label.Size = new System.Drawing.Size(54, 13); - this.address3Label.TabIndex = 12; + this.address3Label.TabIndex = 11; this.address3Label.Text = "Address 3"; // // address4TextBox // this.address4TextBox.Enabled = false; - this.address4TextBox.Location = new System.Drawing.Point(73, 136); + this.address4TextBox.Location = new System.Drawing.Point(73, 146); this.address4TextBox.Name = "address4TextBox"; this.address4TextBox.Size = new System.Drawing.Size(220, 20); - this.address4TextBox.TabIndex = 15; + this.address4TextBox.TabIndex = 14; // // address4Label // this.address4Label.AutoSize = true; - this.address4Label.Location = new System.Drawing.Point(6, 139); + this.address4Label.Location = new System.Drawing.Point(6, 149); this.address4Label.Name = "address4Label"; this.address4Label.Size = new System.Drawing.Size(54, 13); - this.address4Label.TabIndex = 14; + this.address4Label.TabIndex = 13; this.address4Label.Text = "Address 4"; // // address5TextBox // this.address5TextBox.Enabled = false; - this.address5TextBox.Location = new System.Drawing.Point(73, 157); + this.address5TextBox.Location = new System.Drawing.Point(73, 166); this.address5TextBox.Name = "address5TextBox"; this.address5TextBox.Size = new System.Drawing.Size(220, 20); - this.address5TextBox.TabIndex = 17; + this.address5TextBox.TabIndex = 16; // // address5Label // this.address5Label.AutoSize = true; - this.address5Label.Location = new System.Drawing.Point(6, 160); + this.address5Label.Location = new System.Drawing.Point(6, 169); this.address5Label.Name = "address5Label"; this.address5Label.Size = new System.Drawing.Size(54, 13); - this.address5Label.TabIndex = 16; + this.address5Label.TabIndex = 15; this.address5Label.Text = "Address 5"; // // approvedByTextBox @@ -188,7 +190,7 @@ namespace TBF.BenchControl.BenchInfo.Polska this.approvedByTextBox.Location = new System.Drawing.Point(113, 227); this.approvedByTextBox.Name = "approvedByTextBox"; this.approvedByTextBox.Size = new System.Drawing.Size(180, 20); - this.approvedByTextBox.TabIndex = 23; + this.approvedByTextBox.TabIndex = 22; // // approvedByLabel // @@ -196,47 +198,66 @@ namespace TBF.BenchControl.BenchInfo.Polska this.approvedByLabel.Location = new System.Drawing.Point(6, 230); this.approvedByLabel.Name = "approvedByLabel"; this.approvedByLabel.Size = new System.Drawing.Size(67, 13); - this.approvedByLabel.TabIndex = 22; + this.approvedByLabel.TabIndex = 21; this.approvedByLabel.Text = "Approved by"; // // approvalDateTextBox // this.approvalDateTextBox.Enabled = false; - this.approvalDateTextBox.Location = new System.Drawing.Point(113, 206); + this.approvalDateTextBox.Location = new System.Drawing.Point(113, 207); this.approvalDateTextBox.Name = "approvalDateTextBox"; this.approvalDateTextBox.Size = new System.Drawing.Size(180, 20); - this.approvalDateTextBox.TabIndex = 21; + this.approvalDateTextBox.TabIndex = 20; // // approvalDateLabel // this.approvalDateLabel.AutoSize = true; - this.approvalDateLabel.Location = new System.Drawing.Point(6, 209); + this.approvalDateLabel.Location = new System.Drawing.Point(6, 210); this.approvalDateLabel.Name = "approvalDateLabel"; this.approvalDateLabel.Size = new System.Drawing.Size(73, 13); - this.approvalDateLabel.TabIndex = 20; + this.approvalDateLabel.TabIndex = 19; this.approvalDateLabel.Text = "Approval date"; // // approvalIdTextBox // this.approvalIdTextBox.Enabled = false; - this.approvalIdTextBox.Location = new System.Drawing.Point(113, 185); + this.approvalIdTextBox.Location = new System.Drawing.Point(113, 187); this.approvalIdTextBox.Name = "approvalIdTextBox"; this.approvalIdTextBox.Size = new System.Drawing.Size(180, 20); - this.approvalIdTextBox.TabIndex = 19; + this.approvalIdTextBox.TabIndex = 18; // // approvalIdLabel // this.approvalIdLabel.AutoSize = true; - this.approvalIdLabel.Location = new System.Drawing.Point(6, 188); + this.approvalIdLabel.Location = new System.Drawing.Point(6, 190); this.approvalIdLabel.Name = "approvalIdLabel"; this.approvalIdLabel.Size = new System.Drawing.Size(61, 13); - this.approvalIdLabel.TabIndex = 18; + this.approvalIdLabel.TabIndex = 17; this.approvalIdLabel.Text = "Approval Id"; // + // benchNameTextBox + // + this.benchNameTextBox.Enabled = false; + this.benchNameTextBox.Location = new System.Drawing.Point(113, 44); + this.benchNameTextBox.Name = "benchNameTextBox"; + this.benchNameTextBox.Size = new System.Drawing.Size(57, 20); + this.benchNameTextBox.TabIndex = 4; + // + // benchNameLabel + // + this.benchNameLabel.AutoSize = true; + this.benchNameLabel.Location = new System.Drawing.Point(6, 46); + this.benchNameLabel.Name = "benchNameLabel"; + this.benchNameLabel.Size = new System.Drawing.Size(90, 13); + this.benchNameLabel.TabIndex = 3; + this.benchNameLabel.Text = "Test bench name"; + // // ComponentCfgCtrl // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.benchNameTextBox); + this.Controls.Add(this.benchNameLabel); this.Controls.Add(this.approvedByTextBox); this.Controls.Add(this.approvedByLabel); this.Controls.Add(this.approvalDateTextBox); @@ -289,5 +310,7 @@ namespace TBF.BenchControl.BenchInfo.Polska private System.Windows.Forms.Label approvalDateLabel; private System.Windows.Forms.TextBox approvalIdTextBox; private System.Windows.Forms.Label approvalIdLabel; + private System.Windows.Forms.TextBox benchNameTextBox; + private System.Windows.Forms.Label benchNameLabel; } } diff --git a/TestBenchFramework/BenchControl/GenericDevices/IBenchInfo.cs b/TestBenchFramework/BenchControl/GenericDevices/IBenchInfo.cs index ee1254890..385c3d76b 100644 --- a/TestBenchFramework/BenchControl/GenericDevices/IBenchInfo.cs +++ b/TestBenchFramework/BenchControl/GenericDevices/IBenchInfo.cs @@ -11,6 +11,7 @@ namespace TBF.BenchControl.GenericDevices /// public interface IBenchInfo : IComponent { - string TestBenchId { get; } + string TestBenchName { get; } + int TestBenchId { get; } } } diff --git a/TestBenchFramework/BenchControl/ResultsPrinters/Munich/MunichPrintDocument.cs b/TestBenchFramework/BenchControl/ResultsPrinters/Munich/MunichPrintDocument.cs index 00078a315..8236cbdac 100644 --- a/TestBenchFramework/BenchControl/ResultsPrinters/Munich/MunichPrintDocument.cs +++ b/TestBenchFramework/BenchControl/ResultsPrinters/Munich/MunichPrintDocument.cs @@ -128,7 +128,7 @@ namespace TBF.BenchControl.ResultsPrinters.Munich PrintAt(e, Tab1, lineNr * SpacingOne, prn.Version); lineNr++; PrintBoldAt(e, Tab1, lineNr * SpacingOne, "Prüfstand Nr :"); - PrintBoldAt(e, Tab2, lineNr * SpacingOne, (prn.BenchId != null) ? prn.BenchId.TestBenchId : ""); + PrintBoldAt(e, Tab2, lineNr * SpacingOne, (prn.BenchId != null) ? prn.BenchId.TestBenchName : ""); PrintBoldAt(e, Tab3, lineNr * SpacingOne, "Datum :"); PrintBoldAt(e, Tab4, lineNr * SpacingOne, DateTime.Now.Date.ToString("d")); lineNr++; diff --git a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs index a4f731917..c69d1f091 100644 --- a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs +++ b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs @@ -230,7 +230,34 @@ namespace TBF.BenchControl.Sequences /// /// Procedure selected at this point, a new batch was started /// - StateMachine.CycleStartTimeStamp = DateTime.Now; + + /// Prepare new water meters + bool compound = (StateMachine.Procedure.MetersKind == MetersKind.Combined); + int nrWMs = Math.Min(WaterMeters.Count, compound ? Config.Data.CompoundWMsCount : Config.Data.WMsCount); + /// + Results.Entities.WaterMeterData[] waterMeterData = new Results.Entities.WaterMeterData[nrWMs]; + /// + int[] waterMeterParts = new int[nrWMs]; + for (int i = 0; i < nrWMs; i++) + { + waterMeterParts[i] = Utils.PartNr(i + 1, compound); + waterMeterData[i] = new Results.Entities.WaterMeterData() + { + ProductName = StateMachine.Procedure.Name, + Producer = WaterMeters[i].Producer, + MetrologicalClass = WaterMeters[i].MetrologicalClass, + ApprovalInfo = WaterMeters[i].ApprovalInfo, + Qn = WaterMeters[i].Qn, + Compound = compound, + }; + } + + /// Prepare empty results + BatchRslts = Results.BatchResults.NewFromProcedure(Program.LocalSettings.BatchNr, BenchInfo.TestBenchId, + User.CurrentUser.Name, Program.Version, + StateMachine.Procedure, waterMeterData, waterMeterParts); + + StateMachine.CycleStartTimeStamp = BatchRslts.Batch.StartTime; foreach (var wm in WaterMeters) wm.ClearData(); /// Clean water meter data ResetResults(); @@ -482,7 +509,7 @@ namespace TBF.BenchControl.Sequences { foreach (var rr in sensPath.RegisterReaders) if (rr is WaterMeters.iPerl.WaterMeter) - (rr as WaterMeters.iPerl.WaterMeter).BenchName = BenchInfo.TestBenchId; + (rr as WaterMeters.iPerl.WaterMeter).BenchName = BenchInfo.TestBenchName; } e = testMethodSequence.Execute(test); @@ -539,7 +566,7 @@ namespace TBF.BenchControl.Sequences { foreach (var rr in sensPath.RegisterReaders) if (rr is WaterMeters.iPerl.WaterMeter) - (rr as WaterMeters.iPerl.WaterMeter).BenchName = BenchInfo.TestBenchId; + (rr as WaterMeters.iPerl.WaterMeter).BenchName = BenchInfo.TestBenchName; } e = testMethodSequence.Execute(test); @@ -618,7 +645,7 @@ namespace TBF.BenchControl.Sequences State savingAndPrintingRslts = State.Create("MainSeq : Saving and printing results"); if (writer != null) { - savingAndPrintingRslts.AddOperation(writer.WriteResultsOp((BenchInfo != null) ? BenchInfo.TestBenchId : string.Empty, + savingAndPrintingRslts.AddOperation(writer.WriteResultsOp((BenchInfo != null) ? BenchInfo.TestBenchName : string.Empty, StateMachine.Procedure, WaterMeters, results)); } if (printer != null && !printer.SupressPrinting) diff --git a/TestBenchFramework/BenchControl/Sequences/ProcessData.cs b/TestBenchFramework/BenchControl/Sequences/ProcessData.cs index e660e08b1..055cc2022 100644 --- a/TestBenchFramework/BenchControl/Sequences/ProcessData.cs +++ b/TestBenchFramework/BenchControl/Sequences/ProcessData.cs @@ -21,5 +21,7 @@ namespace TBF.BenchControl.Sequences public static FloatBox RefFreq = new FloatBox() { Name = "RefFreq", Format = "F2" }; public static FloatBox RefFlow = new FloatBox() { Name = "RefFlow", Format = "F2" }; /// [m3/h] public static FloatBox Mass = new FloatBox() { Name = "Mass", Format = "F3" }; /// [kg] + + public static Results.BatchResults BatchRslts; } }