From e5edb90bfd66a734d099c274e7d301b74fc01978 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Mon, 25 May 2020 13:53:24 +0200 Subject: [PATCH] TestMethods.FlowAdjustment, TestMethods.FixedStartMassCollAdvanced, DataEntry24 changes, ver. 3.1.1471 --- .../DataEntry/Combined/EntryForm.cs | 7 +- .../DataEntry/Fewa/EntryFormNoStartEnd.cs | 7 +- .../DataEntry/HeatMeters12/EntryForm.cs | 7 +- .../DataEntry/HeatMeters6/EntryForm.cs | 7 +- .../DataEntry/Munich/EntryForm.cs | 4 +- .../DataEntry/Munich3/EntryForm.cs | 7 +- .../DataEntry/Single/EntryFormNoStartEnd.cs | 7 +- .../Standard12/EntryFormNoStartEnd.cs | 7 +- .../Standard24/EntryFormNoStartEnd.cs | 54 +- .../DataEntry/Standard24/TestStartEndForm.cs | 64 +- .../Standard48/EntryFormNoStartEnd.cs | 7 +- .../Standard6/EntryFormNoStartEnd.cs | 9 +- .../DataEntry/StandardCamera/EntryForm.cs | 7 +- TBF/BenchControl/DataEntry/iPerl/EntryForm.cs | 7 +- .../GenericDevices/IHasCycleEndForm.cs | 2 +- .../GenericDevices/IHasWMStatesForm.cs | 18 +- .../KPackE/DataEntryForRadio/EntryForm.cs | 3 + TBF/BenchControl/Sequences/MainSeq.cs | 2 +- TBF/BenchControl/Sequences/SequenceBase.cs | 1 - TBF/BenchControl/TbfComponents.cs | 4 + .../TestMethods/Adjustment/AdjustmentSeq.cs | 27 +- .../CombinedWithDetectionSeq.cs | 27 +- .../DiverterTest/DiverterTestSeq.cs | 26 +- .../TestMethods/Endurance/EnduranceSeq.cs | 26 +- .../TestMethods/FixedStart/FixedStartSeq.cs | 27 +- .../FixedStartAdvancedSeq.cs | 27 +- .../FixedStartDeferredEvalSeq.cs | 27 +- .../Compound/Component.cs | 39 + .../Compound/Factory.cs | 27 + .../FixedStartMassCollAdvancedSeq.cs | 1113 +++++++++++++++++ .../HeatMeters/Component.cs | 43 + .../HeatMeters/Factory.cs | 26 + .../HeatMeters/TestMethodCfg.cs | 49 + .../HeatMeters/TestMethodCfgCtrl.cs | 69 + .../HeatMeters/TestMethodCfgCtrl.designer.cs | 86 ++ .../HeatMeters/TestMethodCfgCtrl.resx | 120 ++ .../HeatMeters/TestParams.cs | 197 +++ .../Single/Component.cs | 39 + .../Single/Factory.cs | 27 + .../FixedStartMassCollDeferredEvalSeq.cs | 27 +- .../FixedStartMassCollectionSeq.cs | 53 +- .../FixedStartTankCollectionSeq.cs | 27 +- .../TestMethods/FlowAdjustment/Component.cs | 39 + .../TestMethods/FlowAdjustment/Factory.cs | 27 + .../FlowAdjustment/FlowAdjustmentSeq.cs | 453 +++++++ .../FlyingStartFirstRepetWithMassCollSeq.cs | 26 +- .../FlyingStartMassCollComparativeSeq.cs | 26 +- .../FlyingStartMassCollProlongedSeq.cs | 26 +- .../FlyingStartMassCollectionSeq.cs | 26 +- .../FlyingStartTankCollectionSeq.cs | 26 +- .../TestMethods/PulsesTest/PulsesTestSeq.cs | 27 +- .../PulsesTestManual/PulsesTestManualSeq.cs | 27 +- .../RoiDetection/RoiDetectionSeq.cs | 26 +- .../SensitivityTest/SensitivityTestSeq.cs | 26 +- TBF/Properties/AssemblyInfo.cs | 4 +- TBF/TBF.csproj | 21 + 56 files changed, 2807 insertions(+), 333 deletions(-) create mode 100644 TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/Compound/Component.cs create mode 100644 TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/Compound/Factory.cs create mode 100644 TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/FixedStartMassCollAdvancedSeq.cs create mode 100644 TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/Component.cs create mode 100644 TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/Factory.cs create mode 100644 TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/TestMethodCfg.cs create mode 100644 TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/TestMethodCfgCtrl.cs create mode 100644 TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/TestMethodCfgCtrl.designer.cs create mode 100644 TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/TestMethodCfgCtrl.resx create mode 100644 TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/TestParams.cs create mode 100644 TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/Single/Component.cs create mode 100644 TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/Single/Factory.cs create mode 100644 TBF/BenchControl/TestMethods/FlowAdjustment/Component.cs create mode 100644 TBF/BenchControl/TestMethods/FlowAdjustment/Factory.cs create mode 100644 TBF/BenchControl/TestMethods/FlowAdjustment/FlowAdjustmentSeq.cs diff --git a/TBF/BenchControl/DataEntry/Combined/EntryForm.cs b/TBF/BenchControl/DataEntry/Combined/EntryForm.cs index b7f3dd08b..56c91d24e 100644 --- a/TBF/BenchControl/DataEntry/Combined/EntryForm.cs +++ b/TBF/BenchControl/DataEntry/Combined/EntryForm.cs @@ -89,11 +89,11 @@ namespace TBF.BenchControl.DataEntry.Combined } /// Reference to the operation - public IOperation ShowCycleEndFormOp() + public IOperation ShowCycleEndFormOp(IList waterMeters) { if (currentOp != CurrentOp.None) throw new Exception("Sequence error"); currentOp = CurrentOp.ShowFormAtCycleEnd; - this.waterMeters = TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch.WaterMeters; + this.waterMeters = waterMeters; return this; } @@ -106,6 +106,9 @@ namespace TBF.BenchControl.DataEntry.Combined return this; } + /// null (not implemented) + public IOperation ShowAdvancedTestStartFormOp(IRegisterReader[] regReaders, IList waterMeters) { return null; } + /// Reference to the operation public IOperation ShowTestEndFormOp(IRegisterReader[] regReaders, double refVolume, double errLimLo, double errLimHi) { diff --git a/TBF/BenchControl/DataEntry/Fewa/EntryFormNoStartEnd.cs b/TBF/BenchControl/DataEntry/Fewa/EntryFormNoStartEnd.cs index 2825c66e9..bba7bd9e8 100644 --- a/TBF/BenchControl/DataEntry/Fewa/EntryFormNoStartEnd.cs +++ b/TBF/BenchControl/DataEntry/Fewa/EntryFormNoStartEnd.cs @@ -89,11 +89,11 @@ namespace TBF.BenchControl.DataEntry.Fewa } /// Reference to the operation - public IOperation ShowCycleEndFormOp() + public IOperation ShowCycleEndFormOp(IList waterMeters) { if (currentOp != CurrentOp.None) throw new Exception("Sequence error"); currentOp = CurrentOp.ShowFormAtCycleEnd; - this.waterMeters = TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch.WaterMeters; + this.waterMeters = waterMeters; return this; } @@ -106,6 +106,9 @@ namespace TBF.BenchControl.DataEntry.Fewa return this; } + /// null (not implemented) + public IOperation ShowAdvancedTestStartFormOp(IRegisterReader[] regReaders, IList waterMeters) { return null; } + /// Reference to the operation public IOperation ShowTestEndFormOp(IRegisterReader[] regReaders, double refVolume, double errLimLo, double errLimHi) { diff --git a/TBF/BenchControl/DataEntry/HeatMeters12/EntryForm.cs b/TBF/BenchControl/DataEntry/HeatMeters12/EntryForm.cs index d0a2ad2db..e9025b17c 100644 --- a/TBF/BenchControl/DataEntry/HeatMeters12/EntryForm.cs +++ b/TBF/BenchControl/DataEntry/HeatMeters12/EntryForm.cs @@ -107,11 +107,11 @@ namespace TBF.BenchControl.DataEntry.HeatMeters12 } /// Reference to the operation - public IOperation ShowCycleEndFormOp() + public IOperation ShowCycleEndFormOp(IList waterMeters) { if (currentOp != CurrentOp.None) throw new Exception("Sequence error"); currentOp = CurrentOp.ShowFormAtCycleEnd; - this.waterMeters = TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch.WaterMeters; + this.waterMeters = waterMeters; return this; } @@ -124,6 +124,9 @@ namespace TBF.BenchControl.DataEntry.HeatMeters12 return this; } + /// null (not implemented) + public IOperation ShowAdvancedTestStartFormOp(IRegisterReader[] regReaders, IList waterMeters) { return null; } + /// Reference to the operation public IOperation ShowTestEndFormOp(IRegisterReader[] regReaders, double refVolume, double errLimLo, double errLimHi) { diff --git a/TBF/BenchControl/DataEntry/HeatMeters6/EntryForm.cs b/TBF/BenchControl/DataEntry/HeatMeters6/EntryForm.cs index 4a6b7b49e..974d70f86 100644 --- a/TBF/BenchControl/DataEntry/HeatMeters6/EntryForm.cs +++ b/TBF/BenchControl/DataEntry/HeatMeters6/EntryForm.cs @@ -107,11 +107,11 @@ namespace TBF.BenchControl.DataEntry.HeatMeters6 } /// Reference to the operation - public IOperation ShowCycleEndFormOp() + public IOperation ShowCycleEndFormOp(IList waterMeters) { if (currentOp != CurrentOp.None) throw new Exception("Sequence error"); currentOp = CurrentOp.ShowFormAtCycleEnd; - this.waterMeters = TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch.WaterMeters; + this.waterMeters = waterMeters; return this; } @@ -124,6 +124,9 @@ namespace TBF.BenchControl.DataEntry.HeatMeters6 return this; } + /// null (not implemented) + public IOperation ShowAdvancedTestStartFormOp(IRegisterReader[] regReaders, IList waterMeters) { return null; } + /// Reference to the operation public IOperation ShowTestEndFormOp(IRegisterReader[] regReaders, double refVolume, double errLimLo, double errLimHi) { diff --git a/TBF/BenchControl/DataEntry/Munich/EntryForm.cs b/TBF/BenchControl/DataEntry/Munich/EntryForm.cs index 0c3942b58..9710d03ea 100644 --- a/TBF/BenchControl/DataEntry/Munich/EntryForm.cs +++ b/TBF/BenchControl/DataEntry/Munich/EntryForm.cs @@ -81,11 +81,11 @@ namespace TBF.BenchControl.DataEntry.Munich } /// Reference to the operation - public IOperation ShowCycleEndFormOp() + public IOperation ShowCycleEndFormOp(IList waterMeters) { if (currentOp != CurrentOp.None) throw new Exception("Sequence error"); currentOp = CurrentOp.ShowFormAtCycleEnd; - this.wMeters = TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch.WaterMeters; + this.wMeters = waterMeters; return this; } diff --git a/TBF/BenchControl/DataEntry/Munich3/EntryForm.cs b/TBF/BenchControl/DataEntry/Munich3/EntryForm.cs index 0e367f648..ebe44acd0 100644 --- a/TBF/BenchControl/DataEntry/Munich3/EntryForm.cs +++ b/TBF/BenchControl/DataEntry/Munich3/EntryForm.cs @@ -94,11 +94,11 @@ namespace TBF.BenchControl.DataEntry.Munich3 } /// Reference to the operation - public IOperation ShowCycleEndFormOp() + public IOperation ShowCycleEndFormOp(IList waterMeters) { if (currentOp != CurrentOp.None) throw new Exception("Sequence error"); currentOp = CurrentOp.ShowFormAtCycleEnd; - this.waterMeters = TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch.WaterMeters; + this.waterMeters = waterMeters; return this; } @@ -111,6 +111,9 @@ namespace TBF.BenchControl.DataEntry.Munich3 return this; } + /// null (not implemented) + public IOperation ShowAdvancedTestStartFormOp(IRegisterReader[] regReaders, IList waterMeters) { return null; } + /// Reference to the operation public IOperation ShowTestEndFormOp(IRegisterReader[] regReaders, double refVolume, double errLimLo, double errLimHi) { diff --git a/TBF/BenchControl/DataEntry/Single/EntryFormNoStartEnd.cs b/TBF/BenchControl/DataEntry/Single/EntryFormNoStartEnd.cs index e91a2573f..55a3e7bd1 100644 --- a/TBF/BenchControl/DataEntry/Single/EntryFormNoStartEnd.cs +++ b/TBF/BenchControl/DataEntry/Single/EntryFormNoStartEnd.cs @@ -89,11 +89,11 @@ namespace TBF.BenchControl.DataEntry.Single } /// Reference to the operation - public IOperation ShowCycleEndFormOp() + public IOperation ShowCycleEndFormOp(IList waterMeters) { if (currentOp != CurrentOp.None) throw new Exception("Sequence error"); currentOp = CurrentOp.ShowFormAtCycleEnd; - this.waterMeters = TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch.WaterMeters; + this.waterMeters = waterMeters; return this; } @@ -106,6 +106,9 @@ namespace TBF.BenchControl.DataEntry.Single return this; } + /// null (not implemented) + public IOperation ShowAdvancedTestStartFormOp(IRegisterReader[] regReaders, IList waterMeters) { return null; } + /// Reference to the operation public IOperation ShowTestEndFormOp(IRegisterReader[] regReaders, double refVolume, double errLimLo, double errLimHi) { diff --git a/TBF/BenchControl/DataEntry/Standard12/EntryFormNoStartEnd.cs b/TBF/BenchControl/DataEntry/Standard12/EntryFormNoStartEnd.cs index 064a1d1a7..c09a4dabc 100644 --- a/TBF/BenchControl/DataEntry/Standard12/EntryFormNoStartEnd.cs +++ b/TBF/BenchControl/DataEntry/Standard12/EntryFormNoStartEnd.cs @@ -89,11 +89,11 @@ namespace TBF.BenchControl.DataEntry.Standard12 } /// Reference to the operation - public IOperation ShowCycleEndFormOp() + public IOperation ShowCycleEndFormOp(IList waterMeters) { if (currentOp != CurrentOp.None) throw new Exception("Sequence error"); currentOp = CurrentOp.ShowFormAtCycleEnd; - this.waterMeters = TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch.WaterMeters; + this.waterMeters = waterMeters; return this; } @@ -106,6 +106,9 @@ namespace TBF.BenchControl.DataEntry.Standard12 return this; } + /// null (not implemented) + public IOperation ShowAdvancedTestStartFormOp(IRegisterReader[] regReaders, IList waterMeters) { return null; } + /// Reference to the operation public IOperation ShowTestEndFormOp(IRegisterReader[] regReaders, double refVolume, double errLimLo, double errLimHi) { diff --git a/TBF/BenchControl/DataEntry/Standard24/EntryFormNoStartEnd.cs b/TBF/BenchControl/DataEntry/Standard24/EntryFormNoStartEnd.cs index fd1830e8d..334e16d6a 100644 --- a/TBF/BenchControl/DataEntry/Standard24/EntryFormNoStartEnd.cs +++ b/TBF/BenchControl/DataEntry/Standard24/EntryFormNoStartEnd.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2015-2018 Sensus Slovensko a.s. +/// Copyright (c) 2015-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; @@ -25,16 +25,14 @@ namespace TBF.BenchControl.DataEntry.Standard24 /// bool[] disabled; /// This array is shared between forms - string[] wmCycleEndState; - public string WMCycleEndState(int wmNr) { return (wmNr >= 0 && wmNr < wmCycleEndState.Length) ? wmCycleEndState[wmNr] : string.Empty; } - double[] wmStartState; public double WMStartState(int wmNr) { return (wmNr >= 0 && wmNr < wmStartState.Length) ? wmStartState[wmNr] : 0; } + string[] wmStartStateStr; double[] wmEndState; public double WMEndState(int wmNr) { return (wmNr >= 0 && wmNr < wmEndState.Length) ? wmEndState[wmNr] : 0; } - - string[] wmStartStateStr; + string[] wmEndStateStr; + public string WMEndStateStr(int wmNr) { return (wmNr >= 0 && wmNr < wmEndStateStr.Length) ? wmEndStateStr[wmNr] : string.Empty; } System.Windows.Forms.Form modelessDlg; @@ -54,7 +52,8 @@ namespace TBF.BenchControl.DataEntry.Standard24 ShowFormAtCycleBeginning, ShowFormAtCycleEnd, EnterTestStartStates, - EnterTestEndStates, + EnterAdvancedTestStartStates, + EnterTestEndStates, } CurrentOp currentOp; @@ -73,7 +72,7 @@ namespace TBF.BenchControl.DataEntry.Standard24 wmStartState = new double[Config.Data.WMsCount]; wmStartStateStr = new string[Config.Data.WMsCount]; wmEndState = new double[Config.Data.WMsCount]; - wmCycleEndState = new string[Config.Data.WMsCount]; + wmEndStateStr = new string[Config.Data.WMsCount]; currentOp = CurrentOp.None; log.Debug(this.ToString()); @@ -89,11 +88,11 @@ namespace TBF.BenchControl.DataEntry.Standard24 } /// Reference to the operation - public IOperation ShowCycleEndFormOp() + public IOperation ShowCycleEndFormOp(IList waterMeters) { if (currentOp != CurrentOp.None) throw new Exception("Sequence error"); currentOp = CurrentOp.ShowFormAtCycleEnd; - this.waterMeters = TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch.WaterMeters; + this.waterMeters = waterMeters; return this; } @@ -106,6 +105,16 @@ namespace TBF.BenchControl.DataEntry.Standard24 return this; } + /// Reference to the operation + public IOperation ShowAdvancedTestStartFormOp(IRegisterReader[] regReaders, IList waterMeters) + { + if (currentOp != CurrentOp.None) throw new Exception("Sequence error"); + currentOp = CurrentOp.EnterAdvancedTestStartStates; + this.regReaders = regReaders; + this.waterMeters = waterMeters; + return this; + } + /// Reference to the operation public IOperation ShowTestEndFormOp(IRegisterReader[] regReaders, double refVolume, double errLimLo, double errLimHi) { @@ -137,7 +146,17 @@ namespace TBF.BenchControl.DataEntry.Standard24 myRef.modelessDlg = new TestStartEndForm(Config.Data.WMsCount, myRef.regReaders, myRef.disabled); modelessDlg.Show(); } - /// + /// + void OpenAdvancedTestStartStatesDlg(EntryFormNoStartEnd myRef) + { + if (wmEndStateStr.Length == waterMeters.Count) + { + for (int i = 0; i < waterMeters.Count; i++) wmEndStateStr[i] = waterMeters[i].EndState; + } + myRef.modelessDlg = new TestStartEndForm(Config.Data.WMsCount, myRef.regReaders, wmEndStateStr, myRef.disabled); + modelessDlg.Show(); + } + /// void OpenTestEndStatesDlg(EntryFormNoStartEnd myRef) { myRef.modelessDlg = new TestStartEndForm(Config.Data.WMsCount, myRef.regReaders, wmStartStateStr, disabled, refVolume, errLimLo, errLimHi); @@ -169,7 +188,10 @@ namespace TBF.BenchControl.DataEntry.Standard24 case CurrentOp.EnterTestStartStates: Program.MainWnd.Invoke(new EntryFormDlgt(OpenTestStartStatesDlg), this); break; - case CurrentOp.EnterTestEndStates: + case CurrentOp.EnterAdvancedTestStartStates: + Program.MainWnd.Invoke(new EntryFormDlgt(OpenAdvancedTestStartStatesDlg), this); + break; + case CurrentOp.EnterTestEndStates: Program.MainWnd.Invoke(new EntryFormDlgt(OpenTestEndStatesDlg), this); break; } @@ -214,11 +236,12 @@ namespace TBF.BenchControl.DataEntry.Standard24 if (waterMeters[i] != null) { /// In case entryFormCfg.ShowCycleEndForm == false dlg would be null, values would be string.Empty - wmCycleEndState[i] = waterMeters[i].EndState = (dlg != null) ? dlg.EndStateText[i] : string.Empty; + wmEndStateStr[i] = waterMeters[i].EndState = (dlg != null) ? dlg.EndStateText[i] : string.Empty; } } } - else if (modelessDlg is TestStartEndForm && currentOp == CurrentOp.EnterTestStartStates) + else if (modelessDlg is TestStartEndForm && + (currentOp == CurrentOp.EnterTestStartStates || currentOp == CurrentOp.EnterAdvancedTestStartStates)) { /// Fixed start test - start TestStartEndForm dlg = (modelessDlg as TestStartEndForm); @@ -245,7 +268,8 @@ namespace TBF.BenchControl.DataEntry.Standard24 if (!(((i < disabled.Length) && disabled[i]) || ((i < regReaders.Length) && (regReaders[i] == null)))) { wmEndState[i] = dlg.WMEndState[i]; - } + waterMeters[i].EndState = wmEndStateStr[i] = dlg.WMEndStateStr[i]; + } } } } diff --git a/TBF/BenchControl/DataEntry/Standard24/TestStartEndForm.cs b/TBF/BenchControl/DataEntry/Standard24/TestStartEndForm.cs index 9b624aaec..958ed1bd4 100644 --- a/TBF/BenchControl/DataEntry/Standard24/TestStartEndForm.cs +++ b/TBF/BenchControl/DataEntry/Standard24/TestStartEndForm.cs @@ -12,6 +12,15 @@ namespace TBF.BenchControl.DataEntry.Standard24 { public partial class TestStartEndForm : Form, GenericDevices.IHasCompleted { + enum Kind + { + Undefined, + Start, + AdvancedStart, + End, + } + + private static readonly ILog log = LogManager.GetLogger(typeof(TestStartEndForm)); // Set to 'true' when the form closes @@ -32,7 +41,10 @@ namespace TBF.BenchControl.DataEntry.Standard24 // To be retrieved after the form closes public double[] WMEndState; - bool endStates; /// false=start states, true=end states + // To be retrieved after the form closes + public readonly string[] WMEndStateStr; + + Kind kind; /// false=start states, true=end states double refVolume; double warningLimLo; /// limit to display exclamation mark, typically 2x errLimLo double warningLimHi; /// limit to display exclamation mark, typically 2x errLimHi @@ -101,7 +113,7 @@ namespace TBF.BenchControl.DataEntry.Standard24 public TestStartEndForm(int waterMetersCount, IRegisterReader[] regReaders, bool[] disabled) : this() { - endStates = false; + kind = Kind.Start; this.WaterMetersCount = waterMetersCount; this.regReaders = regReaders; @@ -111,7 +123,30 @@ namespace TBF.BenchControl.DataEntry.Standard24 WMStartState = new double[waterMetersCount]; WMStartStateStr = new string[waterMetersCount]; - } + } + + /// + /// Constructor to fill in start states + /// + /// Number of water meters + /// Information from CycleBeginningForm about availability of water meters + public TestStartEndForm(int waterMetersCount, IRegisterReader[] regReaders, string[] wmEndStateStr, bool[] disabled) + : this() + { + kind = Kind.AdvancedStart; + + this.WaterMetersCount = waterMetersCount; + this.regReaders = regReaders; + if (wmEndStateStr == null || wmEndStateStr.Length != waterMetersCount) + throw (new Exception("Invalid 'wmStartStateStr' argument")); + this.WMEndStateStr = wmEndStateStr; + this.disabled = disabled; + + ShuffleTextBoxes(); + + WMStartState = new double[waterMetersCount]; + WMStartStateStr = new string[waterMetersCount]; + } /// /// Constructor to fill in end states @@ -126,7 +161,7 @@ namespace TBF.BenchControl.DataEntry.Standard24 double refVolume, double errLimLo, double errLimHi) : this() { - endStates = true; + kind = Kind.End; this.WaterMetersCount = waterMetersCount; this.regReaders = regReaders; @@ -142,7 +177,8 @@ namespace TBF.BenchControl.DataEntry.Standard24 ShuffleTextBoxes(); WMEndState = new double[waterMetersCount]; - } + WMEndStateStr = new string[waterMetersCount]; + } /// /// Make sure the layout of labels/text boxes on the screen @@ -185,7 +221,7 @@ namespace TBF.BenchControl.DataEntry.Standard24 } } - if (endStates) + if (kind == Kind.End) { /// End of test for (int i = 0; i < TextBoxesCount; i++) @@ -207,7 +243,7 @@ namespace TBF.BenchControl.DataEntry.Standard24 } } } - else + else if (kind == Kind.Start || kind == Kind.AdvancedStart) { /// Start of test for (int i = 0; i < TextBoxesCount; i++) @@ -221,8 +257,13 @@ namespace TBF.BenchControl.DataEntry.Standard24 startTextBoxes[i].Enabled = true; activeTextBoxes.Add(startTextBoxes[i]); activeWmNrs.Add(i); + + if ((kind == Kind.AdvancedStart) && (WMEndStateStr != null) && (i < WMEndStateStr.Length) && (!string.IsNullOrEmpty(WMEndStateStr[i]))) + { + startTextBoxes[i].Text = WMEndStateStr[i]; + } } - } + } } if ((activeTextBoxes.Count > 0) && (activeWmNrs.Count > 0)) @@ -248,14 +289,15 @@ namespace TBF.BenchControl.DataEntry.Standard24 { try { - if (endStates) + if (kind == Kind.End) { for (int i = 0; i < Math.Min(WaterMetersCount, TextBoxesCount); i++) { if (endTextBoxes[i].Visible && endTextBoxes[i].Enabled) { - WMEndState[i] = Utils.ParseUDouble(endTextBoxes[i].Text); - } + WMEndStateStr[i] = endTextBoxes[i].Text; + WMEndState[i] = Utils.ParseUDouble(endTextBoxes[i].Text); + } } } else diff --git a/TBF/BenchControl/DataEntry/Standard48/EntryFormNoStartEnd.cs b/TBF/BenchControl/DataEntry/Standard48/EntryFormNoStartEnd.cs index c9b730af1..4ee8f11b2 100644 --- a/TBF/BenchControl/DataEntry/Standard48/EntryFormNoStartEnd.cs +++ b/TBF/BenchControl/DataEntry/Standard48/EntryFormNoStartEnd.cs @@ -89,11 +89,11 @@ namespace TBF.BenchControl.DataEntry.Standard48 } /// Reference to the operation - public IOperation ShowCycleEndFormOp() + public IOperation ShowCycleEndFormOp(IList waterMeters) { if (currentOp != CurrentOp.None) throw new Exception("Sequence error"); currentOp = CurrentOp.ShowFormAtCycleEnd; - this.waterMeters = TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch.WaterMeters; + this.waterMeters = waterMeters; return this; } @@ -106,6 +106,9 @@ namespace TBF.BenchControl.DataEntry.Standard48 return this; } + /// null (not implemented) + public IOperation ShowAdvancedTestStartFormOp(IRegisterReader[] regReaders, IList waterMeters) { return null; } + /// Reference to the operation public IOperation ShowTestEndFormOp(IRegisterReader[] regReaders, double refVolume, double errLimLo, double errLimHi) { diff --git a/TBF/BenchControl/DataEntry/Standard6/EntryFormNoStartEnd.cs b/TBF/BenchControl/DataEntry/Standard6/EntryFormNoStartEnd.cs index fb2355bc9..39bd6f10c 100644 --- a/TBF/BenchControl/DataEntry/Standard6/EntryFormNoStartEnd.cs +++ b/TBF/BenchControl/DataEntry/Standard6/EntryFormNoStartEnd.cs @@ -85,11 +85,11 @@ namespace TBF.BenchControl.DataEntry.Standard6 } /// Reference to the operation - public IOperation ShowCycleEndFormOp() + public IOperation ShowCycleEndFormOp(IList waterMeters) { if (currentOp != CurrentOp.None) throw new Exception("Sequence error"); currentOp = CurrentOp.ShowFormAtCycleEnd; - this.waterMeters = TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch.WaterMeters; + this.waterMeters = waterMeters; return this; } @@ -102,7 +102,10 @@ namespace TBF.BenchControl.DataEntry.Standard6 return this; } - /// Reference to the operation + /// null (not implemented) + public IOperation ShowAdvancedTestStartFormOp(IRegisterReader[] regReaders, IList waterMeters) { return null; } + + /// Reference to the operation public IOperation ShowTestEndFormOp(IRegisterReader[] regReaders, double refVolume, double errLimLo, double errLimHi) { if (currentOp != CurrentOp.None) throw new Exception("Sequence error"); diff --git a/TBF/BenchControl/DataEntry/StandardCamera/EntryForm.cs b/TBF/BenchControl/DataEntry/StandardCamera/EntryForm.cs index 931df6127..91064dfd4 100644 --- a/TBF/BenchControl/DataEntry/StandardCamera/EntryForm.cs +++ b/TBF/BenchControl/DataEntry/StandardCamera/EntryForm.cs @@ -139,11 +139,11 @@ namespace TBF.BenchControl.DataEntry.StandardCamera } /// Reference to the operation - public IOperation ShowCycleEndFormOp() + public IOperation ShowCycleEndFormOp(IList waterMeters) { if (currentOp != CurrentOp.None) throw new Exception("Sequence error"); currentOp = CurrentOp.ShowFormAtCycleEnd; - this.waterMeters = TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch.WaterMeters; + this.waterMeters = waterMeters; return this; } @@ -156,6 +156,9 @@ namespace TBF.BenchControl.DataEntry.StandardCamera return this; } + /// null (not implemented) + public IOperation ShowAdvancedTestStartFormOp(IRegisterReader[] regReaders, IList waterMeters) { return null; } + /// Reference to the operation public IOperation ShowTestEndFormOp(IRegisterReader[] regReaders, double refVolume, double errLimLo, double errLimHi) { diff --git a/TBF/BenchControl/DataEntry/iPerl/EntryForm.cs b/TBF/BenchControl/DataEntry/iPerl/EntryForm.cs index b63f3f115..00a7aedb6 100644 --- a/TBF/BenchControl/DataEntry/iPerl/EntryForm.cs +++ b/TBF/BenchControl/DataEntry/iPerl/EntryForm.cs @@ -89,11 +89,11 @@ namespace TBF.BenchControl.DataEntry.iPerl } /// Reference to the operation - public IOperation ShowCycleEndFormOp() + public IOperation ShowCycleEndFormOp(IList waterMeters) { if (currentOp != CurrentOp.None) throw new Exception("Sequence error"); currentOp = CurrentOp.ShowFormAtCycleEnd; - this.waterMeters = TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch.WaterMeters; + this.waterMeters = waterMeters; return this; } @@ -106,6 +106,9 @@ namespace TBF.BenchControl.DataEntry.iPerl return this; } + /// null (not implemented) + public IOperation ShowAdvancedTestStartFormOp(IRegisterReader[] regReaders, IList waterMeters) { return null; } + /// Reference to the operation public IOperation ShowTestEndFormOp(IRegisterReader[] regReaders, double refVolume, double errLimLo, double errLimHi) { diff --git a/TBF/BenchControl/GenericDevices/IHasCycleEndForm.cs b/TBF/BenchControl/GenericDevices/IHasCycleEndForm.cs index 82d8b4808..8c56f0f26 100644 --- a/TBF/BenchControl/GenericDevices/IHasCycleEndForm.cs +++ b/TBF/BenchControl/GenericDevices/IHasCycleEndForm.cs @@ -11,6 +11,6 @@ namespace TBF.BenchControl.GenericDevices /// Displays form at the end of the cycle (usually to enter the end state). /// /// Operation to be used in the sequence - IOperation ShowCycleEndFormOp(); + IOperation ShowCycleEndFormOp(IList waterMeters); } } diff --git a/TBF/BenchControl/GenericDevices/IHasWMStatesForm.cs b/TBF/BenchControl/GenericDevices/IHasWMStatesForm.cs index 56fd7d912..dd7d9c212 100644 --- a/TBF/BenchControl/GenericDevices/IHasWMStatesForm.cs +++ b/TBF/BenchControl/GenericDevices/IHasWMStatesForm.cs @@ -1,6 +1,10 @@ /// /// Copyright (c) 2013-2015 Sensus Metering Systems /// +using System; +using System.Collections.Generic; +using Results.Entities; + namespace TBF.BenchControl.GenericDevices { public interface IHasWMStatesForm @@ -8,12 +12,16 @@ namespace TBF.BenchControl.GenericDevices /// /// Water meter states on start of test /// - double WMStartState(int wmNr); + /// Zero based water meter number + /// Water meter state in liters + double WMStartState(int wmNr0); /// /// Water meter states at the end of test /// - double WMEndState(int wmNr); + /// Zero based water meter number + /// Water meter state in liters + double WMEndState(int wmNr0); /// /// Displays form at the beginning of the test to enter water meter start start. @@ -21,6 +29,12 @@ namespace TBF.BenchControl.GenericDevices /// Operation to be used in the sequence IOperation ShowTestStartFormOp(IRegisterReader[] regReaders); + /// + /// Displays form at the beginning of the test to enter water meter start start. + /// + /// Operation to be used in the sequence + IOperation ShowAdvancedTestStartFormOp(IRegisterReader[] regReaders, IList waterMeters); + /// /// Displays form at the end of the test to enter water meter start start. /// diff --git a/TBF/BenchControl/RegisterReaders/KPackE/DataEntryForRadio/EntryForm.cs b/TBF/BenchControl/RegisterReaders/KPackE/DataEntryForRadio/EntryForm.cs index 4a3d58680..64946be85 100644 --- a/TBF/BenchControl/RegisterReaders/KPackE/DataEntryForRadio/EntryForm.cs +++ b/TBF/BenchControl/RegisterReaders/KPackE/DataEntryForRadio/EntryForm.cs @@ -103,6 +103,9 @@ namespace TBF.BenchControl.RegisterReaders.KPackE.DataEntryForRadio return this; } + /// null (not implemented) + public IOperation ShowAdvancedTestStartFormOp(IRegisterReader[] regReaders, IList waterMeters) { return null; } + /// Reference to the operation public IOperation ShowTestEndFormOp(IRegisterReader[] regReaders, double refVolume, double errLimLo, double errLimHi) { diff --git a/TBF/BenchControl/Sequences/MainSeq.cs b/TBF/BenchControl/Sequences/MainSeq.cs index 3840d38b7..8b0791eb0 100644 --- a/TBF/BenchControl/Sequences/MainSeq.cs +++ b/TBF/BenchControl/Sequences/MainSeq.cs @@ -1196,7 +1196,7 @@ namespace TBF.BenchControl.Sequences { /// Open the modeless form for the end of the cycle State.Create("MainSeq : Enter end data") - .AddOperation((dataEntryCmpnt as GenericDevices.IHasCycleEndForm).ShowCycleEndFormOp()) + .AddOperation((dataEntryCmpnt as GenericDevices.IHasCycleEndForm).ShowCycleEndFormOp(TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch.WaterMeters)) .AddOperation(checkUiOp) .EnterState(); do diff --git a/TBF/BenchControl/Sequences/SequenceBase.cs b/TBF/BenchControl/Sequences/SequenceBase.cs index 8b1e2949b..fd1b7da0e 100644 --- a/TBF/BenchControl/Sequences/SequenceBase.cs +++ b/TBF/BenchControl/Sequences/SequenceBase.cs @@ -84,7 +84,6 @@ namespace TBF.BenchControl.Sequences protected IOperation readRegistersOp; protected IOperation queryEnd1; - protected IOperation queryEnd2; protected IOperation checkUiOp; protected IOperation processDataLoggingOp; diff --git a/TBF/BenchControl/TbfComponents.cs b/TBF/BenchControl/TbfComponents.cs index 128768c4b..36d407da0 100644 --- a/TBF/BenchControl/TbfComponents.cs +++ b/TBF/BenchControl/TbfComponents.cs @@ -72,11 +72,15 @@ namespace TBF.BenchControl Factories.Add(new TestMethods.FixedStartMassCollection.Single.Factory()); Factories.Add(new TestMethods.FixedStartMassCollection.Compound.Factory()); Factories.Add(new TestMethods.FixedStartMassCollection.HeatMeters.Factory()); + Factories.Add(new TestMethods.FixedStartMassCollAdvanced.Single.Factory()); + Factories.Add(new TestMethods.FixedStartMassCollAdvanced.Compound.Factory()); + Factories.Add(new TestMethods.FixedStartMassCollAdvanced.HeatMeters.Factory()); Factories.Add(new TestMethods.FixedStartMassCollDeferredEval.Single.Factory()); Factories.Add(new TestMethods.FixedStartMassCollDeferredEval.Compound.Factory()); Factories.Add(new TestMethods.FixedStartMassCollDeferredEval.HeatMeters.Factory()); Factories.Add(new TestMethods.FixedStartTankCollection.Single.Factory()); Factories.Add(new TestMethods.FixedStartTankCollection.Compound.Factory()); + Factories.Add(new TestMethods.FlowAdjustment.Factory()); Factories.Add(new TestMethods.FlyingStart.Single.Factory()); Factories.Add(new TestMethods.FlyingStart.Compound.Factory()); Factories.Add(new TestMethods.FlyingStart.HeatMeters.Factory()); diff --git a/TBF/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs b/TBF/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs index ffc363f51..c20f5ef1b 100644 --- a/TBF/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs +++ b/TBF/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs @@ -123,21 +123,21 @@ namespace TBF.BenchControl.TestMethods.Adjustment checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false); - int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - if (sensPath != null && sensPath.RegisterReaders != null) - { - foreach (var rr in sensPath.RegisterReaders) - { - TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; - if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) - { - filters[eldeRR.Position - 1] = eldeRR.Filter; - } - } - } - if (cBrd is ControlBoard.Legacy.ControlBoardDev) { + int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + if (sensPath != null && sensPath.RegisterReaders != null) + { + foreach (var rr in sensPath.RegisterReaders) + { + TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; + if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) + { + filters[eldeRR.Position - 1] = eldeRR.Filter; + } + } + } + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); } @@ -390,7 +390,6 @@ namespace TBF.BenchControl.TestMethods.Adjustment /// Measurement loop - preparation readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders); queryEnd1 = cBrd.QueryMeasurementEndOp(); - queryEnd2 = cBrd.QueryMeasurementEndOp(); StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, 0); diff --git a/TBF/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs b/TBF/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs index 8bd7e2dde..27c2c1ffd 100644 --- a/TBF/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs +++ b/TBF/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs @@ -118,21 +118,21 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false); - int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - if (sensPath != null && sensPath.RegisterReaders != null) - { - foreach (var rr in sensPath.RegisterReaders) - { - TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; - if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) - { - filters[eldeRR.Position - 1] = eldeRR.Filter; - } - } - } - if (cBrd is ControlBoard.Legacy.ControlBoardDev) { + int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + if (sensPath != null && sensPath.RegisterReaders != null) + { + foreach (var rr in sensPath.RegisterReaders) + { + TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; + if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) + { + filters[eldeRR.Position - 1] = eldeRR.Filter; + } + } + } + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); } @@ -583,7 +583,6 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection /// Measurement loop - preparation /// queryEnd1 = cBrd.QueryMeasurementEndOp(); - queryEnd2 = cBrd.QueryMeasurementEndOp(); StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, 0); int estimtdEndTime = StateMachine.Time + (int)test.TstTime; diff --git a/TBF/BenchControl/TestMethods/DiverterTest/DiverterTestSeq.cs b/TBF/BenchControl/TestMethods/DiverterTest/DiverterTestSeq.cs index 548bdb65a..5737f6c27 100644 --- a/TBF/BenchControl/TestMethods/DiverterTest/DiverterTestSeq.cs +++ b/TBF/BenchControl/TestMethods/DiverterTest/DiverterTestSeq.cs @@ -116,21 +116,21 @@ namespace TBF.BenchControl.TestMethods.DiverterTest processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this); - int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - if (sensPath != null && sensPath.RegisterReaders != null) - { - foreach (var rr in sensPath.RegisterReaders) - { - TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; - if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) - { - filters[eldeRR.Position - 1] = eldeRR.Filter; - } - } - } - if (cBrd is ControlBoard.Legacy.ControlBoardDev) { + int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + if (sensPath != null && sensPath.RegisterReaders != null) + { + foreach (var rr in sensPath.RegisterReaders) + { + TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; + if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) + { + filters[eldeRR.Position - 1] = eldeRR.Filter; + } + } + } + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); } diff --git a/TBF/BenchControl/TestMethods/Endurance/EnduranceSeq.cs b/TBF/BenchControl/TestMethods/Endurance/EnduranceSeq.cs index e9ee1d047..272319a77 100644 --- a/TBF/BenchControl/TestMethods/Endurance/EnduranceSeq.cs +++ b/TBF/BenchControl/TestMethods/Endurance/EnduranceSeq.cs @@ -93,21 +93,21 @@ namespace TBF.BenchControl.TestMethods.Endurance processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false); - int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - if (sensPath != null && sensPath.RegisterReaders != null) - { - foreach (var rr in sensPath.RegisterReaders) - { - TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; - if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) - { - filters[eldeRR.Position - 1] = eldeRR.Filter; - } - } - } - if (cBrd is ControlBoard.Legacy.ControlBoardDev) { + int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + if (sensPath != null && sensPath.RegisterReaders != null) + { + foreach (var rr in sensPath.RegisterReaders) + { + TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; + if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) + { + filters[eldeRR.Position - 1] = eldeRR.Filter; + } + } + } + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); } diff --git a/TBF/BenchControl/TestMethods/FixedStart/FixedStartSeq.cs b/TBF/BenchControl/TestMethods/FixedStart/FixedStartSeq.cs index ea1102314..20a463700 100644 --- a/TBF/BenchControl/TestMethods/FixedStart/FixedStartSeq.cs +++ b/TBF/BenchControl/TestMethods/FixedStart/FixedStartSeq.cs @@ -92,21 +92,21 @@ namespace TBF.BenchControl.TestMethods.FixedStart processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, heatMetersTestParams != null); - int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - if (sensPath != null && sensPath.RegisterReaders != null) - { - foreach (var rr in sensPath.RegisterReaders) - { - TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; - if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) - { - filters[eldeRR.Position - 1] = eldeRR.Filter; - } - } - } - if (cBrd is ControlBoard.Legacy.ControlBoardDev) { + int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + if (sensPath != null && sensPath.RegisterReaders != null) + { + foreach (var rr in sensPath.RegisterReaders) + { + TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; + if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) + { + filters[eldeRR.Position - 1] = eldeRR.Filter; + } + } + } + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); } @@ -561,7 +561,6 @@ namespace TBF.BenchControl.TestMethods.FixedStart /// Measurement loop - preparation readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders); queryEnd1 = cBrd.QueryMeasurementEndOp(); - queryEnd2 = cBrd.QueryMeasurementEndOp(); StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, Math.Max((int)(test.TstTime / 10), 5)); int estimtdEndTime = StateMachine.Time + (int)test.TstTime; diff --git a/TBF/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs b/TBF/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs index 3a4ebe580..6ef0254ed 100644 --- a/TBF/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs +++ b/TBF/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs @@ -100,21 +100,21 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false); - int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - if (sensPath != null && sensPath.RegisterReaders != null) - { - foreach (var rr in sensPath.RegisterReaders) - { - TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; - if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) - { - filters[eldeRR.Position - 1] = eldeRR.Filter; - } - } - } - if (cBrd is ControlBoard.Legacy.ControlBoardDev) { + int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + if (sensPath != null && sensPath.RegisterReaders != null) + { + foreach (var rr in sensPath.RegisterReaders) + { + TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; + if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) + { + filters[eldeRR.Position - 1] = eldeRR.Filter; + } + } + } + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); } @@ -427,7 +427,6 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced /// Measurement loop - preparation readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders); queryEnd1 = cBrd.QueryMeasurementEndOp(); - queryEnd2 = cBrd.QueryMeasurementEndOp(); StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, Math.Max((int)(test.TstTime / 10), 5)); int estimtdEndTime = StateMachine.Time + (int)test.TstTime; diff --git a/TBF/BenchControl/TestMethods/FixedStartDeferredEval/FixedStartDeferredEvalSeq.cs b/TBF/BenchControl/TestMethods/FixedStartDeferredEval/FixedStartDeferredEvalSeq.cs index e2060c193..84fee0d06 100644 --- a/TBF/BenchControl/TestMethods/FixedStartDeferredEval/FixedStartDeferredEvalSeq.cs +++ b/TBF/BenchControl/TestMethods/FixedStartDeferredEval/FixedStartDeferredEvalSeq.cs @@ -110,21 +110,21 @@ namespace TBF.BenchControl.TestMethods.FixedStartDeferredEval processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, heatMetersTestParams != null); - int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - if (sensPath != null && sensPath.RegisterReaders != null) - { - foreach (var rr in sensPath.RegisterReaders) - { - TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; - if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) - { - filters[eldeRR.Position - 1] = eldeRR.Filter; - } - } - } - if (cBrd is ControlBoard.Legacy.ControlBoardDev) { + int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + if (sensPath != null && sensPath.RegisterReaders != null) + { + foreach (var rr in sensPath.RegisterReaders) + { + TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; + if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) + { + filters[eldeRR.Position - 1] = eldeRR.Filter; + } + } + } + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); } @@ -588,7 +588,6 @@ namespace TBF.BenchControl.TestMethods.FixedStartDeferredEval /// Measurement loop - preparation readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders); queryEnd1 = cBrd.QueryMeasurementEndOp(); - queryEnd2 = cBrd.QueryMeasurementEndOp(); StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, Math.Max((int)(test.TstTime / 10), 5)); int estimtdEndTime = StateMachine.Time + (int)test.TstTime; diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/Compound/Component.cs b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/Compound/Component.cs new file mode 100644 index 000000000..f386be0b0 --- /dev/null +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/Compound/Component.cs @@ -0,0 +1,39 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using log4net; +using Config.Entities; + +namespace TBF.BenchControl.TestMethods.FixedStartMassCollAdvanced.Compound +{ + public class Component : ComponentBase, GenericDevices.ITestMethod + { + private static readonly ILog log = LogManager.GetLogger(typeof(Component)); + public override string ToString() + { + return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1)); + } + + public bool CanTest(MetersKind meters) { return meters == MetersKind.Combined; } + public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FixedStartMassCollAdvancedSeq.CheckDeviceCaps(test, devices, out message); + } + + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) + : base(cfg) + { + log.Debug(this.ToString()); + } + + public IList Execute(Test test, int repetNr, bool isLastRepetition) + { + return (new FixedStartMassCollAdvancedSeq()).Execute(test, repetNr, isLastRepetition, true, null, DebugLevel); + } + } +} diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/Compound/Factory.cs b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/Compound/Factory.cs new file mode 100644 index 000000000..81b957cc8 --- /dev/null +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/Compound/Factory.cs @@ -0,0 +1,27 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System.Collections.Generic; +using TBF.BenchControl.Generic; +using TBF.BenchControl.Configs.NameOnly; + +namespace TBF.BenchControl.TestMethods.FixedStartMassCollAdvanced.Compound +{ + public class Factory : IComponentFactory + { + public string ClassName { get { return this.GetType().Namespace.Substring(17); } } + + public void ResetStaticProperties() { Component.ResetStaticProperties(); } + + public IComponent DummyComponent() { return new Component(); } + + public IComponent GetComponent(IComponentCfg cfg, IList components) { return new Component(cfg); } + + public IComponentCfg DefaultConfig() { return new TestMethodCfg(this.GetType().Namespace.Substring(29), this); } + + public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) + { + return ComponentCfgBase.CreateFromDbEntity(TestMethodCfg.Serializer, component, this); + } + } +} diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/FixedStartMassCollAdvancedSeq.cs b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/FixedStartMassCollAdvancedSeq.cs new file mode 100644 index 000000000..b1febc0b0 --- /dev/null +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/FixedStartMassCollAdvancedSeq.cs @@ -0,0 +1,1113 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using System.IO; +using log4net; +using TBF.Resources; +using TBF.UiBridge; +using TBF.BenchControl.GenericDevices; + +namespace TBF.BenchControl.TestMethods.FixedStartMassCollAdvanced +{ + public class FixedStartMassCollAdvancedSeq : Sequences.SequenceBase + { + private static readonly ILog log = LogManager.GetLogger(typeof(FixedStartMassCollAdvancedSeq)); + + /// + /// Check capabilities of devces in the output path required for this test method + /// + /// Devices + /// true when capabilities of devices are OK + public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) + { + if (!(StateMachine.ControlBoard is ControlBoard.Legacy.ControlBoardDev) && + !(StateMachine.ControlBoard is ControlBoard.Papouch.CBoard) && + !(StateMachine.ControlBoard is ControlBoard.New.CBoard)) + { + /// Control board does not support this method + message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); + return false; + } + + if (!(devices.Scale is IScale)) + { + /// Scale is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_scale); + return false; + } + + if (test.Volume > devices.Scale.Capacity * Constants.TankFullFactor) + { + /// Scale capacity is not sufficient + message = string.Format("{0}: {1}", test.Name, Strings.Test_volume_exceeds_the_scale_capacity); + return false; + } + + if (!(devices.FlowMeter is IFlowMeter)) + { + /// Flow meter is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_flow_meter); + return false; + } + + if (!(devices.RegulValve is GenericDevices.IRegulValve)) + { + /// Regulation valve is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_regulation_valve); + return false; + } + + message = string.Empty; + return true; + } + + /// + /// Fixed start mass collection method sequence + /// + /// Test entity + /// + /// Event.Done . . . . . . . OK + /// Event.MakeSecondPass . . OK, 2nd pass (=evaluation) required + /// Event.UiCmdStop . . . . Stopped by the user using the on-screen button STOP + /// Event.OpArgumentError . Target flow is out of range + /// Event.Error . . . . . . Unspecified error + /// + public IList Execute(Config.Entities.Test test, int repetitionNr, bool isLastRepetition, + bool compound, + HeatMeters.TestParams heatMetersTestParams, + Config.Entities.DebugMode debugLevel) + { + ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; + IScale scale = cBrd.Devices.Scale as IScale; + + int rangeIx = 0; /// Default range, used for non-Elde flowmeters + if (outPath.FlowMeter is Elde.FlowMeter.FlowMeter) + { + Elde.FlowMeter.FlowMeter eldeFM = outPath.FlowMeter as Elde.FlowMeter.FlowMeter; + rangeIx = -1; /// Indicates invalid range + for (int r = 0; r <= 5; r++) + { + if (eldeFM.RangeEnabled(r) && eldeFM.GetTempLo(r) <= test.TempLimLo + && eldeFM.GetTempHi(r) >= test.TempLimHi) + { + rangeIx = r; + } + } + + if (rangeIx == -1) + { + Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); + new List { Event.ConfigurationError }; + } + } + + IList e; /// Events from currently running operations + int tMass1 = 0; + int tMass2 = 0; + checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state + processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, heatMetersTestParams != null); + + + if (cBrd is ControlBoard.Legacy.ControlBoardDev) + { + int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + if (sensPath != null && sensPath.RegisterReaders != null) + { + foreach (var rr in sensPath.RegisterReaders) + { + TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; + if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) + { + filters[eldeRR.Position - 1] = eldeRR.Filter; + } + } + } + + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + } + + IList readTempPressOps = new List(); + if (benchPath.TempMtrUp != null) readTempPressOps.Add(benchPath.TempMtrUp.ReadTempOp(ref TempUp)); + if (benchPath.TempMtrDown != null) readTempPressOps.Add(benchPath.TempMtrDown.ReadTempOp(ref TempDown)); + if (outPath.TempDiv != null) readTempPressOps.Add(outPath.TempDiv.ReadTempOp(ref TempDiv)); + if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp)); + if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown)); + if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta)); + if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1)); + if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2)); + if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1)); + if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)); + + Event retVal = Event.Done; + + float switchTimeStart = 0.001f; /// in seconds, original vale is 1 ms + float switchTimeEnd = 0.001f; /// in seconds, original vale is 1 ms + + LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h] + + /// Notes: + /// float timeHr = volumeLtr / (1000.0f * targetFlow); + /// float timeSec = 3600.0f * timeHr; + /// int refPulses = (int)(timeSec * (2000.0f * targetFlow / pOut.FlowMeter.NominalFlow)); + int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f); + + + //==================================== + loop: + /// Read pressure and temperature once before calling Bridge.OnTestSelected(...) + State.Create(string.Format("{0}({1}) : Measuring process data", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(readTempPressOps) + .EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (e.Contains(Event.Busy)); + + /// Start the test, initialize test results + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); + string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); + + /// + /// Optionally display prompt to emerge temperature meters to appropriate baths for heat meters test + /// + IOperation heatMetersPromptOp = null; + if (heatMetersTestParams != null && !string.IsNullOrEmpty(heatMetersTestParams.Prompt)) + { + /// Make sure the CycleBeginForm is closed + if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest; + + heatMetersPromptOp = new Operations.MessageBoxOp(heatMetersTestParams.Prompt); + } + + + #region Make sure there is enough space in the tank + + if (!test.DoDraining) + { + /// + /// Measure the weight in case there is no unconditional draining + /// + State.Create(string.Format("{0}({1}) : Measuring mass of water in the tank", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(readTempPressOps) + .AddOperation(scale.ReadMassOp(ref Mass)) + .AddOperation(heatMetersPromptOp) + .EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.JustStarted)); + + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.BalanceDone)); + } + /// + /// Skip draining in case there is enough room in the tank + /// + if (test.DoDraining || (Mass.Val + test.Volume >= scale.Capacity * Constants.TankFullFactor)) + { + /// + /// Drain the water tank + /// + IList ops = new List(readTempPressOps); + ops.Add(heatMetersPromptOp); + switch (DrainTheTank(scale, ops)) + { + case Event.Error: { retVal = Event.Error; goto stopTest; } + case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } + } + } + /// + /// Make sure the drain valve is closed + /// + State.Create(string.Format("{0}({1}) : Make sure the drain valve is closed", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(readTempPressOps) + .AddOperation(scale.ReadMassOp(ref Mass)) + .AddOperation(heatMetersPromptOp) + .AddOperation(cBrd.SetValvesOp(null, scale.DrainValve)) + .EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.JustStarted)); + + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.ValvesSet) || !e.Contains(Event.BalanceDone)); + + #endregion + + #region Measure the start mass + + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Measuring_the_weight); + //------------------------------------------------ + + if (test.TimeFlow2Mass > 0) + { + State.Create(string.Format("{0}({1}) : Waiting before 1st mass measurement", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(readTempPressOps) + .AddOperation(new Operations.TimerOp(test.TimeFlow2Mass)) + .EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.TimerExpired)); + } + + + LogProcessDataTestInfo(processDataLogger, test.Procedure.Name, test.Name); + + if (heatMetersPath == null) LogProcessDataHeader(processDataLogger, "Start mass"); + else LogProcessDataHeaderHeatMeters(processDataLogger, "Start mass"); + + State.Create(string.Format("{0}({1}) : Measuring the start mass", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(readTempPressOps) + .AddOperation(scale.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod)) + .AddOperation(new Operations.TimerOp(StableMassMsrmntTimeoutSec)) + .AddOperation(processDataLoggingOp) + .EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + if (e.Contains(Event.TimerExpired)) + { + Bridge.OnError(this, Strings.Mass_measurement_timeout); + retVal = Event.RecoverableError; + goto stopTest; + } + } + while (!e.Contains(Event.BalanceDone)); + /// + Mass.Val = StartMass.Val; + tMass1 = StateMachine.Time; + + #endregion + + #region Enter water meter START states + + GenericDevices.IHasWMStatesForm dataEntryCmpnt = TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IHasWMStatesForm; + + if (dataEntryCmpnt != null) + { + string fileName = string.Format("{0}-start.bmp", test.Name); + + if (dataEntryCmpnt is GenericDevices.IDataEntryForCamera) + { + string[] startImages = new string[sensPath.RegisterReaders.Length]; + + State state2 = State.Create(string.Format("{0}({1}) : Grabbing images", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(readTempPressOps); + + for (int i = 0; i < sensPath.RegisterReaders.Length; i++) + { + GenericDevices.IRoiForFixedStart roi = sensPath.RegisterReaders[i] as GenericDevices.IRoiForFixedStart; + if (roi != null) + { + string directory = Path.Combine(Program.TempImagesDir, BatchRslts.Batch.BatchNr.ToString(), (i + 1).ToString()); + Directory.CreateDirectory(directory); + startImages[i] = Path.Combine(directory, fileName); + state2.AddOperation(roi.GrabImageOp(startImages[i])); + } + } + state2.EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); + + if (e.Contains(Event.Error)) { retVal = Event.Error; break; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; break; } + } + while (e.Contains(Event.CameraBusy)); + + (dataEntryCmpnt as GenericDevices.IDataEntryForCamera).StartImages = startImages; + } + + Bridge.OnActivity(this, Strings.Enter_water_meter_data); + State.Create(string.Format("{0}({1}) : Entering begin-state", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(readTempPressOps) + .AddOperation(scale.ReadMassOp(ref Mass)) + .AddOperation((dataEntryCmpnt as GenericDevices.IHasWMStatesForm).ShowAdvancedTestStartFormOp(sensPath.RegisterReaders, BatchRslts.Batch.WaterMeters)) + .EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.ModelessFormClosed)); + + if (heatMetersTestParams != null) + { + for (int i = 0; i < Config.Data.HeatMetersCount; i++) + { + BenchControl.RegisterReaders.StandingStartStop.RegisterReader volumeRegisterReader = + sensPath.RegisterReaders[2 * i] as BenchControl.RegisterReaders.StandingStartStop.RegisterReader; + + BenchControl.RegisterReaders.StandingStartStop.RegisterReader energyRegisterReader = + sensPath.RegisterReaders[2 * i + 1] as BenchControl.RegisterReaders.StandingStartStop.RegisterReader; + + if (volumeRegisterReader != null) volumeRegisterReader.BeginWMState = dataEntryCmpnt.WMStartState(i); + if (energyRegisterReader != null && dataEntryCmpnt is GenericDevices.IHasHeatMtrStatesForm) + { + energyRegisterReader.BeginWMState = (float)(dataEntryCmpnt as GenericDevices.IHasHeatMtrStatesForm).EnergyStartState(i); + } + } + } + else + { + for (int i = 0; i < Config.Data.WMsCount; i++) + { + GenericDevices.IRegisterReader rr = sensPath.RegisterReaders[i]; + + if (rr is BenchControl.RegisterReaders.StandingStartStop.RegisterReader) + (rr as BenchControl.RegisterReaders.StandingStartStop.RegisterReader).BeginWMState = dataEntryCmpnt.WMStartState(i); + + if (rr is BenchControl.Network.Camera.RoiForFixedStart.Roi) + (rr as BenchControl.Network.Camera.RoiForFixedStart.Roi).BeginWMState = dataEntryCmpnt.WMStartState(i); + } + } + + if (dataEntryCmpnt is GenericDevices.IDataEntryForCamera && (dataEntryCmpnt as GenericDevices.IDataEntryForCamera).SaveImages) + { + /// SaveImages==true ... copy images to the directory that will be archived at the end of the cycle + for (int i = 0; i < sensPath.RegisterReaders.Length; i++) + { + GenericDevices.IRoiForFixedStart roi = sensPath.RegisterReaders[i] as GenericDevices.IRoiForFixedStart; + if (roi != null) + { + string srcDir = Path.Combine(Program.TempImagesDir, BatchRslts.Batch.BatchNr.ToString(), (i + 1).ToString()); + string destDir = Path.Combine(Program.ImagesDir, BatchRslts.Batch.BatchNr.ToString(), (i + 1).ToString()); + try + { + if (File.Exists(Path.Combine(srcDir, fileName))) + { + Directory.CreateDirectory(destDir); + File.Copy(Path.Combine(srcDir, fileName), Path.Combine(destDir, fileName), true); + } + } + catch (Exception exc) + { + log.ErrorFormat("Failed to copy image {0} to {1}: {2}", fileName, destDir, exc.Message); + } + } + } + } + } + + #endregion + + #region Start the pump + + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Starting_the_pump); + //------------------------------------------------ + + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); + int flowSetTime0 = StateMachine.Time; + + if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower); + /// + State.Create(string.Format("{0}({1}) : Starting the pump", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(readTempPressOps) + //.AddOperation(new Operations.SetAllRegulValvesOp(inPath.RegulValves, inPath.RegulValvesPct, 60)) + .AddOperation(heatMetersPromptOp) + .AddOperation(inPath.Pump != null ? cBrd.SetValvesOp(inPath.Pump, null) : null) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); + + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + + } + while (e.Contains(Event.ValvesBusy) /* || !e.Contains(Event.AllPositionsReached)*/); + + + if (test.TimePump2StartV > 0) + { + State.Create(string.Format("{0}({1}) : Waiting after the pump started", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(readTempPressOps) + .AddOperation(new Operations.TimerOp(test.TimePump2StartV)) + .AddOperation(heatMetersPromptOp) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); + + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.TimerExpired)); + } + + + if (benchPath.StopBFValve != null) + { + State.Create(string.Format("{0}({1}) : Opening the stop backflow valve", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(readTempPressOps) + .AddOperation(cBrd.SetValvesOp(benchPath.StopBFValve, null)) + .AddOperation(heatMetersPromptOp) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + } + while (!e.Contains(Event.ValvesSet)); + } + + #endregion + + + if (heatMetersPath == null) LogProcessDataHeader(processDataLogger, "Measurement"); + else LogProcessDataHeaderHeatMeters(processDataLogger, "Measurement"); + + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Test_in_progress); + //------------------------------------------------ + StartTime = (double)StateMachine.Time; + TestStartTime = DateTime.Now; + + State.Create(string.Format("{0}({1}) : Start the test, open the start/stop valve", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(readTempPressOps) + .AddOperation(scale.ReadMassOp(ref Mass)) + .AddOperation(cBrd.StartTestOp(test)) + .AddOperation(cBrd.OpenStartValveOp()) + .EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.ValvesSet) && !e.Contains(Event.MeasurementStarted)); + + switchTimeStart = 0.001f * cBrd.ValveOpenCloseTime; + log.WarnFormat("Start valve switch time on test start = {0} ms", cBrd.ValveOpenCloseTime); + + /// Measurement loop - preparation + readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders); + queryEnd1 = cBrd.QueryMeasurementEndOp(); + + StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, Math.Max((int)(test.TstTime / 10), 5)); + int estimtdEndTime = StateMachine.Time + (int)test.TstTime; + + /// Measurement loop - begin + do + { + //-------------------------------- + switch (ReadRegistersTempPressAmbient(null, true)) + { + case Event.Error: + retVal = Event.Error; + goto stopTest; + + case Event.UiCmdStop: + retVal = Event.UiCmdStop; + goto stopTest; + + case Event.MeasurementCompleted: + goto test_completed; + } + + int remainingTime = Math.Max(estimtdEndTime - StateMachine.Time, 0); + if (remainingTime > 60) + { + Bridge.OnActivity(this, string.Format("{0} ... {1} {2} {3} {4}", Strings.Test_in_progress, remainingTime / 60, "min", remainingTime % 60, Strings.sec)); + } + else + { + Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime)); + } + + RefFrequency.Val = cBrd.RefFrequency; + RefFlow.Val = cBrd.RefFlow; + + UpdateAllStatistics(StateMachine.Time); + + if (heatMetersTestParams != null) + { + if (lastEnergyUpdateTime == 0) + { + lastEnergyUpdateTime = StateMachine.Time; + } + else + { + //double deltaTime = (double)(StateMachine.Time - lastEnergyUpdateTime); + double T_in = (TempRefHi1.Val + TempRefHi2.Val) / 2; /// [°C] + double T_out = (TempRefLo1.Val + TempRefLo2.Val) / 2; /// [°C] + double deltaVolume = LtrPerRefPulse * RefPulsesDelta; /// [l] + double deltaEnergy = (0.001 * deltaVolume) * (T_in - T_out) * Config.Formulas.HeatCoefficientWater(16, T_in, T_out, heatMetersTestParams.FlowMeasuredAtHiTempPipe); /// [J] = [m3] * [K] * [J/(m3 K)] + Energy.Update(deltaEnergy); + VolumeForEnergy.Update(deltaVolume); + lastEnergyUpdateTime = StateMachine.Time; + } + } + + if (compound) + { + /// TODO: Reimplement for combined meters + //for (int i = 0; i < Config.Data.CompoundWMsCount; i++) + //{ + // data.TestResult.CombinedMeters[i].VolumeMeter = data.TestResult.Meters[2 * i].VolumeMeter + // + data.TestResult.Meters[2 * i + 1].VolumeMeter; + // if (data.Volume.Valid) + // { + // data.TestResult.CombinedMeters[i].VolumeErrorPct = + // Formulas.ErrorFromVolumes(data.TestResult.CombinedMeters[i].VolumeMeter, data.Volume.Val); + // } + //} + } + + Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); + } + while (cBrd.RefPulses < totalPulses); + /// Measurement loop - end + + test_completed: + + StopRecordingStatistics(); + + EndTime = (double)StateMachine.Time; + TestEndTime = DateTime.Now; + + State.Create(string.Format("{0}({1}) : Closing the start/stop valve at the end of the fixed start test", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(readTempPressOps) + .AddOperation(scale.ReadMassOp(ref Mass)) + .AddOperation(cBrd.CloseStartValveOp()) + .EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + } + while (e.Contains(Event.ValvesBusy)); + + + State.Create(string.Format("{0}({1}) : Stopping flow regulation", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(readTempPressOps) + .AddOperation(scale.ReadMassOp(ref Mass)) + .AddOperation(cBrd.StopFlowRegulationOp()) + .EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.FlowRegulationStopped)); + + + switchTimeEnd = 0.001f * cBrd.ValveOpenCloseTime; + log.WarnFormat("Start valve switch time on test end = {0} ms", cBrd.ValveOpenCloseTime); + + State.Create(string.Format("{0}({1}) : Waiting before 2nd mass measurement", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(readTempPressOps) + .AddOperation(scale.ReadMassOp(ref Mass)) + .AddOperation(new Operations.TimerOp(test.TimeStop2Mass)) + .AddOperation(processDataLoggingOp) + .EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.TimerExpired)); + + + if (heatMetersPath == null) LogProcessDataHeader(processDataLogger, "End mass"); + else LogProcessDataHeaderHeatMeters(processDataLogger, "End mass"); + + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Measuring_the_weight); + //------------------------------------------------ + State.Create(string.Format("{0}({1}) : Measuring the end mass", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(readTempPressOps) + .AddOperation(scale.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod)) + .AddOperation(new Operations.TimerOp(StableMassMsrmntTimeoutSec)) + .AddOperation(processDataLoggingOp) + .EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + if (e.Contains(Event.TimerExpired)) + { + Bridge.OnError(this, Strings.Mass_measurement_timeout); + retVal = Event.RecoverableError; + goto stopTest; + } + } + while (!e.Contains(Event.BalanceDone)); + /// + tMass2 = StateMachine.Time; + + if (test.DoDrainingAfter) + { + State.Create(string.Format("{0}({1}) : Open the drain valve", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperation(cBrd.SetValvesOp(scale.DrainValve, null)) + .AddOperations(readTempPressOps) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + } + while (e.Contains(Event.ValvesBusy)); + } + + + State.Create(string.Format("{0}({1}) : Stopping diverter, gate, etc.", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(readTempPressOps) + .AddOperation(cBrd.StopPreviousOp()) + .EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.PreviousStopped)); + + + double massStart = Config.Formulas.CorrectedValue(StartMass.Val, scale.Corrections); + double massEnd = Config.Formulas.CorrectedValue(EndMass.Val, scale.Corrections); + double densityOut = Config.Formulas.WaterDensityFromTempPress((TempUpStat.Average + TempDownStat.Average) / 2, + (PressUpStat.Average + PressDownStat.Average) / 2); + double buoyancy = Config.Formulas.Buoyancy(); + double massOfEvaporatedWater = (double)(tMass2 - tMass1) * outPath.Scale.EvaporationRate(TempDivStat.Average); + double volumeCTV = 1000.0 * buoyancy * (massEnd - massStart + massOfEvaporatedWater) / densityOut; + if (debugLevel == Config.Entities.DebugMode.Simulate) volumeCTV = test.Volume; + + double refEnergy = Energy.Sum * volumeCTV / VolumeForEnergy.Sum; /// [J]=[J]*[l]/[l] + + /// + /// Enter watermeter end states here + /// + if (dataEntryCmpnt != null) + { + string fileName = string.Format("{0}-end.bmp", test.Name); + + if (dataEntryCmpnt is GenericDevices.IDataEntryForCamera) + { + string[] endImages = new string[sensPath.RegisterReaders.Length]; + + State state2 = State.Create(string.Format("{0}({1}) : Grabbing images", test.Method, test.Name)) + .AddOperation(checkUiOp); + for (int i = 0; i < sensPath.RegisterReaders.Length; i++) + { + GenericDevices.IRoiForFixedStart roi = sensPath.RegisterReaders[i] as GenericDevices.IRoiForFixedStart; + if (roi != null) + { + string directory = Path.Combine(Program.TempImagesDir, BatchRslts.Batch.BatchNr.ToString(), (i + 1).ToString()); + Directory.CreateDirectory(directory); + endImages[i] = Path.Combine(directory, fileName); + state2.AddOperation(roi.GrabImageOp(endImages[i])); + } + } + state2.EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); + + if (e.Contains(Event.Error)) { retVal = Event.Error; break; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; break; } + } + while (e.Contains(Event.CameraBusy)); + + (dataEntryCmpnt as GenericDevices.IDataEntryForCamera).EndImages = endImages; + } + + Bridge.OnActivity(this, Strings.Enter_water_meter_data); + State state = State.Create(string.Format("{0}({1}) : Entering the end-state", test.Method, test.Name)); + if (heatMetersTestParams != null && dataEntryCmpnt is GenericDevices.IHasHeatMtrStatesForm) + { + state.AddOperation((dataEntryCmpnt as GenericDevices.IHasHeatMtrStatesForm). + ShowTestEndFormOp(sensPath.RegisterReaders, + volumeCTV, test.ErrLimLo + test.Uncertainty, test.ErrLimHi - test.Uncertainty, + refEnergy, test.ErrLimLo + test.Uncertainty, test.ErrLimHi - test.Uncertainty)); + } + else + { + state.AddOperation(dataEntryCmpnt.ShowTestEndFormOp(sensPath.RegisterReaders, + volumeCTV, test.ErrLimLo + test.Uncertainty, test.ErrLimHi - test.Uncertainty)); + } + state.AddOperation(checkUiOp) + .AddOperations(readTempPressOps) + .EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.ModelessFormClosed)); + + + if (heatMetersTestParams != null) + { + for (int i = 0; i < Config.Data.HeatMetersCount; i++) + { + BenchControl.RegisterReaders.StandingStartStop.RegisterReader volumeRegisterReader = + sensPath.RegisterReaders[2 * i] as BenchControl.RegisterReaders.StandingStartStop.RegisterReader; + + BenchControl.RegisterReaders.StandingStartStop.RegisterReader energyRegisterReader = + sensPath.RegisterReaders[2 * i + 1] as BenchControl.RegisterReaders.StandingStartStop.RegisterReader; + + if (volumeRegisterReader != null) volumeRegisterReader.EndWMState = dataEntryCmpnt.WMEndState(i); + if (energyRegisterReader != null && dataEntryCmpnt is GenericDevices.IHasHeatMtrStatesForm) + { + energyRegisterReader.EndWMState = (float)(dataEntryCmpnt as GenericDevices.IHasHeatMtrStatesForm).EnergyEndState(i); + } + } + } + else + { + for (int i = 0; i < Config.Data.WMsCount; i++) + { + GenericDevices.IRegisterReader rr = sensPath.RegisterReaders[i]; + + if (rr is BenchControl.RegisterReaders.StandingStartStop.RegisterReader) + (rr as BenchControl.RegisterReaders.StandingStartStop.RegisterReader).EndWMState = dataEntryCmpnt.WMEndState(i); + + if (rr is BenchControl.Network.Camera.RoiForFixedStart.Roi) + (rr as BenchControl.Network.Camera.RoiForFixedStart.Roi).EndWMState = dataEntryCmpnt.WMEndState(i); + } + } + + if (dataEntryCmpnt is GenericDevices.IDataEntryForCamera && (dataEntryCmpnt as GenericDevices.IDataEntryForCamera).SaveImages) + { + /// SaveImages==true ... copy images to the directory that will be archived at the end of the cycle + for (int i = 0; i < sensPath.RegisterReaders.Length; i++) + { + GenericDevices.IRoiForFixedStart roi = sensPath.RegisterReaders[i] as GenericDevices.IRoiForFixedStart; + if (roi != null) + { + string srcDir = Path.Combine(Program.TempImagesDir, BatchRslts.Batch.BatchNr.ToString(), (i + 1).ToString()); + string destDir = Path.Combine(Program.ImagesDir, BatchRslts.Batch.BatchNr.ToString(), (i + 1).ToString()); + try + { + if (File.Exists(Path.Combine(srcDir, fileName))) + { + Directory.CreateDirectory(destDir); + File.Copy(Path.Combine(srcDir, fileName), Path.Combine(destDir, fileName), true); + } + } + catch (Exception exc) + { + log.ErrorFormat("Failed to copy image {0} to {1}: {2}", fileName, destDir, exc.Message); + } + } + } + } + } + + + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Test_completed); + //------------------------------------------------ + + /// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results + if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest; + + /// + /// Populate TestResult data entity with data + /// + Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part); + + if (tstRslt != null) + { + Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters); + UpdateTempPressDensAmb(tstRslt); + + /// Main results + tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; + tstRslt.StartTime = TestStartTime; + tstRslt.EndTime = TestEndTime; + tstRslt.FlowSetTime = 0; + TimeSpan duration = TestEndTime - TestStartTime; + tstRslt.TestTime = duration.TotalSeconds; /// [s] measurement time, at least 1 to prevent division by zero + tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1; + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) + tstRslt.MassStartRaw = StartMass.Val; + tstRslt.MassStart = massStart; + tstRslt.MassEndRaw = EndMass.Val; + tstRslt.MassEnd = massEnd; + tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart + massOfEvaporatedWater) / tstRslt.TestTime; /// [kg/h] + tstRslt.Buoyancy = buoyancy; + tstRslt.VolumeCTV = volumeCTV; /// [l] 1000.0f is because density is in [kg/m3] + + if (cBrd is ControlBoard.Papouch.CBoard) + { + /// Test bench with Papouch control board without reference flow meter + tstRslt.VolumeMaster = volumeCTV; /// [l] volume from the master flow meter + tstRslt.FlowVolume = 3.6 * tstRslt.VolumeMaster / tstRslt.TestTime; /// [m3/h] + tstRslt.ConstMasterRaw = 1; /// Uncorrected master flowmeter coefficient + tstRslt.ConstMasterCorr = 1; /// Corrected master pulses per liter + tstRslt.ConstMaster = 1; + } + else + { + /// Test bench with ELDE control board and reference flow meter + tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h] + tstRslt.VolumeMaster = LtrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter + tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient + tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(tstRslt.FlowVolume, rangeIx); /// Corrected master pulses per liter + tstRslt.ConstMaster = (tstRslt.VolumeMaster == 0) ? tstRslt.ConstMasterCorr : (LtrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster); + } + /// Calculated master pulses per liter + tstRslt.ErrorMaster = Config.Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV); + + tstRslt.FlowMean = (float)RefFlowStat.Average; + tstRslt.FlowStart = (float)RefFlowStat.First; + tstRslt.FlowEnd = (float)RefFlowStat.Last; + tstRslt.FlowMin = (float)RefFlowStat.Min; + tstRslt.FlowMax = (float)RefFlowStat.Max; + + tstRslt.DiverterStart = switchTimeStart; + tstRslt.DiverterEnd = switchTimeEnd; + long infoFlags = 0; + tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(tstRslt, false, true, switchTimeStart, switchTimeEnd, out infoFlags) : 0; + tstRslt.InfoFlags = infoFlags; + + if (compound) + { + /// + /// Compound meters + /// + for (int i = 0; i < BatchRslts.WMPositionsCount; i++) + { + if (!test.IsPartCompatible(Utils.PartNr(i + 1, BatchRslts.Batch.Compound))) continue; + + Results.Entities.MeterTestRslt mainMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundMain); + Results.Entities.MeterTestRslt auxMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundAux); + + for (int isAux = 0; isAux <= 1; isAux++) /// 0=main, 1=aux + { + Results.Entities.MeterTestRslt meterRslt = (isAux == 0) ? mainMeterRslt : auxMeterRslt; + GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[2 * i + isAux]; + + if (meterRslt != null && regReader != null) + { + meterRslt.RegReaderType = (int)regReader.RegisterReaderType; + meterRslt.PulsesPerLiter = regReader.PulsesPerLtr; + meterRslt.VolumeStart = regReader.BeginWMState; /// [l] + meterRslt.VolumeEnd = regReader.EndWMState; /// [l] + meterRslt.VolumeMeter = meterRslt.VolumeEnd - meterRslt.VolumeStart; /// [l] + meterRslt.VolumeRef = tstRslt.VolumeCTV; /// [l] + meterRslt.PulsesMeter = meterRslt.VolumeMeter; + meterRslt.PulsesMaster = tstRslt.PulsesMaster; + meterRslt.TestTime = tstRslt.TestTime; + meterRslt.Error = Config.Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); /// Not used for evaluation + } + } + + Results.Entities.MeterTestRslt compoundMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Compound); + + if (compoundMeterRslt != null && mainMeterRslt != null && auxMeterRslt != null) + { + compoundMeterRslt.VolumeRef = tstRslt.VolumeCTV; /// [l] must be calculated before main & aux. meter error + compoundMeterRslt.VolumeMeter = mainMeterRslt.VolumeMeter + auxMeterRslt.VolumeMeter; + compoundMeterRslt.PulsesMaster = tstRslt.PulsesMaster; + compoundMeterRslt.TestTime = tstRslt.TestTime; + compoundMeterRslt.Error = Config.Formulas.ErrorFromVolumes(compoundMeterRslt.VolumeMeter, compoundMeterRslt.VolumeRef); + compoundMeterRslt.Passed = (compoundMeterRslt.Error >= test.GetErrLimLo(tstRslt.VolumeCTV, tstRslt.TestTime) + test.Uncertainty) + && (compoundMeterRslt.Error <= test.GetErrLimHi(tstRslt.VolumeCTV, tstRslt.TestTime) - test.Uncertainty) + && (tstRslt.ErrorFlags == 0); + mainMeterRslt.Passed = auxMeterRslt.Passed = compoundMeterRslt.Passed; + mainMeterRslt.TestDone = auxMeterRslt.TestDone = compoundMeterRslt.TestDone = true; + tstRslt.TestDone = true; + } + } + } + else if (heatMetersTestParams != null) + { + /// + /// Heat meters + /// + tstRslt.RefEnergy = Energy.Sum * tstRslt.VolumeCTV / VolumeForEnergy.Sum; /// [J] = [J] * [l] / [l] + + tstRslt.Custom1 = (float)TempRefHiStat.Average; + tstRslt.Custom2 = (float)TempRefHiStat.First; + tstRslt.Custom3 = (float)TempRefHiStat.Last; + tstRslt.Custom4 = (float)TempRefHiStat.Min; + tstRslt.Custom5 = (float)TempRefHiStat.Max; + tstRslt.Custom6 = (float)TempRefLoStat.Average; + tstRslt.Custom7 = (float)TempRefLoStat.First; + tstRslt.Custom8 = (float)TempRefLoStat.Last; + tstRslt.Custom9 = (float)TempRefLoStat.Min; + tstRslt.Custom10 = (float)TempRefLoStat.Max; + + for (int i = 0; i < BatchRslts.WMPositionsCount; i++) + { + if (!test.IsPartCompatible(Utils.PartNr(i + 1, BatchRslts.Batch.Compound))) continue; + + Results.Entities.MeterTestRslt volumeRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.HeatMeterVolume); + Results.Entities.MeterTestRslt energyRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.HeatMeterEnergy); + + GenericDevices.IRegisterReader volumeRegReader = + (sensPath.RegisterReaders.Length > 2 * i) ? sensPath.RegisterReaders[2 * i] : null; + + GenericDevices.IRegisterReader energyRegReader = + (sensPath.RegisterReaders.Length > 2 * i + 1) ? sensPath.RegisterReaders[2 * i + 1] : null; + + if (volumeRslt != null && volumeRegReader != null) + { + volumeRslt.PulsesPerLiter = volumeRegReader.PulsesPerLtr; + volumeRslt.VolumeStart = volumeRegReader.BeginWMState; + volumeRslt.VolumeEnd = volumeRegReader.EndWMState; + volumeRslt.VolumeMeter = volumeRslt.VolumeEnd - volumeRslt.VolumeStart; + volumeRslt.VolumeRef = tstRslt.VolumeCTV; + volumeRslt.PulsesMeter = volumeRslt.VolumeMeter; + volumeRslt.PulsesMaster = tstRslt.PulsesMaster; /// <----------------- ??? + volumeRslt.TestTime = tstRslt.TestTime; + + volumeRslt.Error = Config.Formulas.ErrorFromVolumes(volumeRslt.VolumeMeter, volumeRslt.VolumeRef); + volumeRslt.Passed = !heatMetersTestParams.EvaluateVolume || + ((volumeRslt.Error >= test.GetErrLimLo(tstRslt.VolumeCTV, tstRslt.TestTime) + test.Uncertainty) && + (volumeRslt.Error <= test.GetErrLimHi(tstRslt.VolumeCTV, tstRslt.TestTime) - test.Uncertainty) && + (tstRslt.ErrorFlags == 0)); + volumeRslt.TestDone = true; + tstRslt.TestDone = true; + } + + if (energyRslt != null && energyRegReader != null && dataEntryCmpnt is GenericDevices.IHasHeatMtrStatesForm) + { + volumeRslt.PulsesPerLiter = energyRegReader.PulsesPerLtr; + energyRslt.VolumeStart = (dataEntryCmpnt as GenericDevices.IHasHeatMtrStatesForm).EnergyStartState(i); + energyRslt.VolumeEnd = (dataEntryCmpnt as GenericDevices.IHasHeatMtrStatesForm).EnergyEndState(i); + energyRslt.VolumeMeter = energyRslt.VolumeEnd - energyRslt.VolumeStart; + energyRslt.VolumeRef = tstRslt.RefEnergy; + energyRslt.PulsesMeter = energyRslt.VolumeMeter; + energyRslt.PulsesMaster = tstRslt.PulsesMaster; /// <----------------- ??? + + energyRslt.Error = Config.Formulas.ErrorFromVolumes(energyRslt.VolumeMeter, energyRslt.VolumeRef); + energyRslt.Passed = (energyRslt.Error >= heatMetersTestParams.ErrorLimitLo) + && (energyRslt.Error <= heatMetersTestParams.ErrorLimitHi) + && (tstRslt.ErrorFlags == 0); + energyRslt.TestDone = true; + tstRslt.TestDone = true; + } + } + } + else + { + /// + /// Single meters + /// + for (int i = 0; i < BatchRslts.WMPositionsCount; i++) + { + if (!test.IsPartCompatible(Utils.PartNr(i + 1, BatchRslts.Batch.Compound))) continue; + + Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single); + GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[i]; + + if (meterRslt != null && regReader != null) + { + meterRslt.RegReaderType = (int)regReader.RegisterReaderType; + meterRslt.PulsesPerLiter = regReader.PulsesPerLtr; + meterRslt.VolumeStart = regReader.BeginWMState; + meterRslt.VolumeEnd = regReader.EndWMState; + meterRslt.VolumeMeter = meterRslt.VolumeEnd - meterRslt.VolumeStart; + meterRslt.VolumeRef = tstRslt.VolumeCTV; /// liter + meterRslt.PulsesMeter = meterRslt.VolumeMeter; + meterRslt.PulsesMaster = tstRslt.PulsesMaster; + meterRslt.TestTime = tstRslt.TestTime; + meterRslt.Error = Config.Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); + meterRslt.Passed = (meterRslt.Error >= test.GetErrLimLo(tstRslt.VolumeCTV, tstRslt.TestTime) + test.Uncertainty) + && (meterRslt.Error <= test.GetErrLimHi(tstRslt.VolumeCTV, tstRslt.TestTime) - test.Uncertainty) + && (tstRslt.ErrorFlags == 0); + meterRslt.TestDone = true; + tstRslt.TestDone = true; + } + } + } + + tstRslt.Components = Results.Entities.Components + .UpdateList(BatchRslts.ComponentsList, + new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1, + (BenchInfo != null) ? BenchInfo.TestBenchName : "testbench", + inPath.Pump != null ? inPath.Pump.Name : string.Empty, + outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty, + scale != null ? scale.Name : string.Empty, + outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty, + outPath.Diverter != null ? outPath.Diverter.Name : string.Empty)); + + /// Update water meter error flags + if (ErrorFlagsComp != null) + { + if (BatchRslts.Batch != null && BatchRslts.Batch.WaterMeters != null) + { + for (int i = 0; i < BatchRslts.WMPositionsCount; i++) + { + if (BatchRslts.Batch.WaterMeters[i] != null && !BatchRslts.Batch.WaterMeters[i].Disabled) + { + long wmInfoFlags; + BatchRslts.Batch.WaterMeters[i].ErrorFlags = ErrorFlagsComp.GetWMtrErrorFlags(BatchRslts.Batch.WaterMeters[i].MeterTestRslts, out wmInfoFlags); + BatchRslts.Batch.WaterMeters[i].InfoFlags = wmInfoFlags; + } + } + } + } + + /// Update results + Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName, tstRslt)); + } + + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.TransitionAfter)); + + /// Append the results to the CSV-file + allResults.Info(TestResult2CsvLine(testName, test.Part)); + + + stopTest: + + StopRecordingStatistics(); + + /// + /// Quit this sequence + /// + if (isLastRepetition || retVal == Event.UiCmdStop || retVal == Event.OpArgumentError + || retVal == Event.Error || retVal == Event.ConfigurationError) + { + State.Create(string.Format("{0}({1}) : Stopping diverter, gate, etc.", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperation(cBrd.StopPreviousOp()) + .EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; break; } + } + while (!e.Contains(Event.PreviousStopped)); + } + + stopTestWOTransitionAfter: + + return new List { retVal }; + } + } +} diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/Component.cs b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/Component.cs new file mode 100644 index 000000000..3b74aa330 --- /dev/null +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/Component.cs @@ -0,0 +1,43 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using log4net; +using Config.Entities; + +namespace TBF.BenchControl.TestMethods.FixedStartMassCollAdvanced.HeatMeters +{ + public class Component : ComponentBase, GenericDevices.ITestMethod + { + private static readonly ILog log = LogManager.GetLogger(typeof(Component)); + public override string ToString() + { + return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1)); + } + + public bool CanTest(MetersKind meters) { return meters == MetersKind.HeatMeter; } + public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FixedStartMassCollAdvancedSeq.CheckDeviceCaps(test, devices, out message); + } + + + readonly TestMethodCfg testMethodCfg; + + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) + : base(cfg) + { + testMethodCfg = cfg as TestMethodCfg; + log.Debug(this.ToString()); + } + + public IList Execute(Test test, int repetNr, bool isLastRepetition) + { + return (new FixedStartMassCollAdvancedSeq()).Execute(test, repetNr, isLastRepetition, false, testMethodCfg.TestParams, DebugLevel); + } + } +} diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/Factory.cs b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/Factory.cs new file mode 100644 index 000000000..914e8692e --- /dev/null +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/Factory.cs @@ -0,0 +1,26 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System.Collections.Generic; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.FixedStartMassCollAdvanced.HeatMeters +{ + public class Factory : IComponentFactory + { + public string ClassName { get { return this.GetType().Namespace.Substring(17); } } + + public void ResetStaticProperties() { Component.ResetStaticProperties(); } + + public IComponent DummyComponent() { return new Component(); } + + public IComponent GetComponent(IComponentCfg cfg, IList components) { return new Component(cfg); } + + public IComponentCfg DefaultConfig() { return new TestMethodCfg(this.GetType().Namespace.Substring(29), this); } + + public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) + { + return ComponentCfgBase.CreateFromDbEntity(TestMethodCfg.Serializer, component, this); + } + } +} diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/TestMethodCfg.cs b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/TestMethodCfg.cs new file mode 100644 index 000000000..e39c59898 --- /dev/null +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/TestMethodCfg.cs @@ -0,0 +1,49 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml.Serialization; +using Config.Entities; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.FixedStartMassCollAdvanced.HeatMeters +{ + public class TestMethodCfg : ComponentCfgBase, Generic.IComponentCfg + { + public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TestMethodCfg) })[0]; + public override XmlSerializer GetSerializer() { return Serializer; } + + public IComponentCfgCtrl GetControl() { return new TestMethodCfgCtrl(); } + + /// Test parameters + [XmlIgnore] + public TestParams TestParams; + public override IParamsProvider GetRuntimeTestParamsProvider() { return TestParams; } + public override IParamsProvider CreateTestParamsProvider() { return new TestParams(true); } + public override IParamsProvider GetUITestParamsProvider(Test test) + { + return (test.Method == Name) ? base.GetUITestParamsProvider(test) : null; + } + + /// Private parameterless constructor invoked by all other (public) constructors + TestMethodCfg() + { + TestParams = new TestParams(true); + } + + public TestMethodCfg(string name, IComponentFactory factory) + : this() + { + Name = name; + Factory = factory; + ParentName = string.Empty; + } + + public string ToString(int i) + { + return string.Format("Name={0}", Name); + } + } +} diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/TestMethodCfgCtrl.cs b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/TestMethodCfgCtrl.cs new file mode 100644 index 000000000..c11c761c6 --- /dev/null +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/TestMethodCfgCtrl.cs @@ -0,0 +1,69 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System; +using System.Windows.Forms; +using Config.Entities; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.FixedStartMassCollAdvanced.HeatMeters +{ + public partial class TestMethodCfgCtrl : UserControl, IComponentCfgCtrl + { + public bool ShowMore { get { return false; } } + + TestMethodCfg config; + public IComponentCfg Config + { + get { return config as IComponentCfg; } + set + { + config = value as TestMethodCfg; + Redraw(); + } + } + + public TestMethodCfgCtrl() + { + InitializeComponent(); + } + + private void EntryFormCfgCtrl_Load(object sender, EventArgs e) + { + Redraw(); + } + + public void Closing() + { + } + + void Redraw() + { + if (config == null) return; /// Control was not loaded, settings were not changed + classNameLabel.Text = config.Factory.ClassName; + nameTextBox.Text = config.Name; + } + + public void Unlock() + { + nameTextBox.Enabled = true; + } + + public CfgUpdateFlags VerifyCfg(ref string message) + { + CfgUpdateFlags flags = CfgUpdateFlags.None; + return flags; + } + + public CfgUpdateFlags UpdateCfg() + { + CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd; + + if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed + + config.Name = nameTextBox.Text; + + return flags; + } + } +} diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/TestMethodCfgCtrl.designer.cs b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/TestMethodCfgCtrl.designer.cs new file mode 100644 index 000000000..86fe50c2d --- /dev/null +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/TestMethodCfgCtrl.designer.cs @@ -0,0 +1,86 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +namespace TBF.BenchControl.TestMethods.FixedStartMassCollAdvanced.HeatMeters +{ + partial class TestMethodCfgCtrl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.nameTextBox = new System.Windows.Forms.TextBox(); + this.nameLabel = new System.Windows.Forms.Label(); + this.classNameLabel = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // nameTextBox + // + this.nameTextBox.Enabled = false; + this.nameTextBox.Location = new System.Drawing.Point(137, 57); + this.nameTextBox.Name = "nameTextBox"; + this.nameTextBox.Size = new System.Drawing.Size(130, 20); + this.nameTextBox.TabIndex = 5; + // + // nameLabel + // + this.nameLabel.AutoSize = true; + this.nameLabel.Location = new System.Drawing.Point(27, 60); + this.nameLabel.Name = "nameLabel"; + this.nameLabel.Size = new System.Drawing.Size(35, 13); + this.nameLabel.TabIndex = 4; + this.nameLabel.Text = "Name"; + // + // classNameLabel + // + this.classNameLabel.AutoSize = true; + this.classNameLabel.Location = new System.Drawing.Point(134, 33); + this.classNameLabel.Name = "classNameLabel"; + this.classNameLabel.Size = new System.Drawing.Size(83, 13); + this.classNameLabel.TabIndex = 3; + this.classNameLabel.Text = "ComonentName"; + // + // BasicPrinterCfgCtrl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.nameTextBox); + this.Controls.Add(this.nameLabel); + this.Controls.Add(this.classNameLabel); + this.Name = "BasicPrinterCfgCtrl"; + this.Size = new System.Drawing.Size(300, 200); + this.Load += new System.EventHandler(this.EntryFormCfgCtrl_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox nameTextBox; + private System.Windows.Forms.Label nameLabel; + private System.Windows.Forms.Label classNameLabel; + } +} diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/TestMethodCfgCtrl.resx b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/TestMethodCfgCtrl.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/TestMethodCfgCtrl.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/TestParams.cs b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/TestParams.cs new file mode 100644 index 000000000..3ce97fbbf --- /dev/null +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/HeatMeters/TestParams.cs @@ -0,0 +1,197 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System; +using System.IO; +using System.Text; +using System.Xml.Serialization; +using Config.Entities; +using TBF.BenchControl.Generic; +using TBF.Resources; + +namespace TBF.BenchControl.TestMethods.FixedStartMassCollAdvanced.HeatMeters +{ + public class TestParams : TestParamsBase, IParamsProvider, ITestParams + { + public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TestParams) })[0]; + public override XmlSerializer GetSerializer() { return Serializer; } + + public float ErrorLimitLo; /// [%] + public float ErrorLimitHi; /// [%] + public bool EvaluateVolume; /// true = evaluate also the volume, false = evaluate only energy + public float TempWarmLo; /// Low limit for warm temperature [°C] + public float TempWarmHi; /// High limit for warm temperature [°C] + public float TempColdLo; /// Low limit for cold temperature [°C] + public float TempColdHi; /// High limit for cold temperature [°C] + public bool FlowMeasuredAtHiTempPipe; /// true = flow measured at high temp. pipe, false = flow measured at low temp. pipe + public float DeltaTempWarm; + public float DeltaTempCold; + public float ChangeInTimeWarm; + public float ChangeInTimeCold; + public string Prompt; + + public override void InitializeAll() + { + FlowMeasuredAtHiTempPipe = false; + } + + + string[] paramNames = new string[] + { + Strings.Err_limit_neg_pct_chdr, + Strings.Err_limit_pos_pct_chdr, + Strings.Evaluate_volume, + "T hi min", + "T hi max", + "T lo min", + "T lo max", + "Flow measured at high temp.pipe", + "Delta T warm", + "Delta T cold", + "Change in time T warm", + "Change in time T cold", + Strings.Prompt, + }; + public override string ParamName(int i) { return paramNames[i]; } + public override int ParamsCount() { return paramNames.Length; } + + public override string ToString(int i) + { + switch (i) + { + case 0: return ErrorLimitLo.ToString(); + case 1: return ErrorLimitHi.ToString(); + case 2: return (EvaluateVolume ? Strings.yes : Strings.no); + case 3: return TempWarmLo.ToString(); + case 4: return TempWarmHi.ToString(); + case 5: return TempColdLo.ToString(); + case 6: return TempColdHi.ToString(); + case 7: return (FlowMeasuredAtHiTempPipe ? Strings.yes : Strings.no); + case 8: return DeltaTempWarm.ToString(); + case 9: return DeltaTempCold.ToString(); + case 10: return ChangeInTimeWarm.ToString(); + case 11: return ChangeInTimeCold.ToString(); + case 12: return Prompt; + default: return string.Empty; + } + } + + public CfgUpdateFlags UpdateParam(int i, string strValue) + { + switch (i) + { + case 0: ErrorLimitLo = Utils.ParseSFloat(strValue); return CfgUpdateFlags.None; + case 1: ErrorLimitHi = Utils.ParseSFloat(strValue); return CfgUpdateFlags.None; + case 2: EvaluateVolume = strValue.Equals(Strings.yes); return CfgUpdateFlags.None; + case 3: TempWarmLo = Utils.ParseSFloat(strValue); return CfgUpdateFlags.None; + case 4: TempWarmHi = Utils.ParseSFloat(strValue); return CfgUpdateFlags.None; + case 5: TempColdLo = Utils.ParseSFloat(strValue); return CfgUpdateFlags.None; + case 6: TempColdHi = Utils.ParseSFloat(strValue); return CfgUpdateFlags.None; + case 7: FlowMeasuredAtHiTempPipe = strValue.Equals(Strings.yes); return CfgUpdateFlags.None; + case 8: DeltaTempWarm = Utils.ParseUFloat(strValue); return CfgUpdateFlags.None; + case 9: DeltaTempCold = Utils.ParseUFloat(strValue); return CfgUpdateFlags.None; + case 10: ChangeInTimeWarm = Utils.ParseUFloat(strValue); return CfgUpdateFlags.None; + case 11: ChangeInTimeCold = Utils.ParseUFloat(strValue); return CfgUpdateFlags.None; + case 12: Prompt = strValue; return CfgUpdateFlags.None; + default: return CfgUpdateFlags.None; + } + } + + public bool ValidateParam(int i, string strValue, out string message) + { + message = string.Empty; + float dummy; + + switch (i) + { + case 0: + case 1: + case 3: + case 4: + case 5: + case 6: + if (Utils.TryParseSFloat(strValue, out dummy)) return true; + break; + case 2: + case 7: + if (strValue.Equals(Strings.yes) || strValue.Equals(Strings.no)) return true; + break; + case 8: + case 9: + case 10: + case 11: + if (Utils.TryParseUFloat(strValue, out dummy)) return true; + break; + case 12: + return true; + default: + message = "Invalid index"; + return false; + } + + message = ParamName(i) + " is invalid"; + return false; + } + + void CopyContentTo(TestParams prms) + { + prms.ErrorLimitLo = ErrorLimitLo; + prms.ErrorLimitHi = ErrorLimitHi; + prms.EvaluateVolume = EvaluateVolume; + prms.TempWarmLo = TempWarmLo; + prms.TempWarmHi = TempWarmHi; + prms.TempColdLo = TempColdLo; + prms.TempColdHi = TempColdHi; + prms.FlowMeasuredAtHiTempPipe = FlowMeasuredAtHiTempPipe; + prms.DeltaTempWarm = DeltaTempWarm; + prms.DeltaTempCold = DeltaTempCold; + prms.ChangeInTimeWarm = ChangeInTimeWarm; + prms.ChangeInTimeCold = ChangeInTimeCold; + prms.Prompt = Prompt; + } + + public IParamsProvider Clone() + { + TestParams pars = new TestParams(); + CopyContentTo(pars); + return pars; + } + + public override void UpdateFromDbEntity(ComponentTest dbEntity) + { + if (dbEntity == null) return; + try + { + TestParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as TestParams; + + testParamsEntity = dbEntity; + componentName = dbEntity.CmpntName; + test = dbEntity.Test; + + if (tmp != null) tmp.CopyContentTo(this); + } + catch + { + } + } + + /// + /// Parameterless constructor initializes the parameters + /// + public TestParams() + { + } + + public TestParams(bool initialize) + { + if (initialize) InitializeAll(); + } + + public TestParams(ComponentTest testParamsEntity, string componentName, Test test) + { + this.testParamsEntity = testParamsEntity; + this.componentName = componentName; + this.test = test; + } + } +} diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/Single/Component.cs b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/Single/Component.cs new file mode 100644 index 000000000..bfd996d8a --- /dev/null +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/Single/Component.cs @@ -0,0 +1,39 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using log4net; +using Config.Entities; + +namespace TBF.BenchControl.TestMethods.FixedStartMassCollAdvanced.Single +{ + public class Component : ComponentBase, GenericDevices.ITestMethod + { + private static readonly ILog log = LogManager.GetLogger(typeof(Component)); + public override string ToString() + { + return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1)); + } + + public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } + public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FixedStartMassCollAdvancedSeq.CheckDeviceCaps(test, devices, out message); + } + + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) + : base(cfg) + { + log.Debug(this.ToString()); + } + + public IList Execute(Test test, int repetNr, bool isLastRepetition) + { + return (new FixedStartMassCollAdvancedSeq()).Execute(test, repetNr, isLastRepetition, false, null, DebugLevel); + } + } +} diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/Single/Factory.cs b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/Single/Factory.cs new file mode 100644 index 000000000..e0fe7e047 --- /dev/null +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/Single/Factory.cs @@ -0,0 +1,27 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System.Collections.Generic; +using TBF.BenchControl.Generic; +using TBF.BenchControl.Configs.NameOnly; + +namespace TBF.BenchControl.TestMethods.FixedStartMassCollAdvanced.Single +{ + public class Factory : IComponentFactory + { + public string ClassName { get { return this.GetType().Namespace.Substring(17); } } + + public void ResetStaticProperties() { Component.ResetStaticProperties(); } + + public IComponent DummyComponent() { return new Component(); } + + public IComponent GetComponent(IComponentCfg cfg, IList components) { return new Component(cfg); } + + public IComponentCfg DefaultConfig() { return new TestMethodCfg(this.GetType().Namespace.Substring(29).Replace(".Single", ""), this); } + + public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) + { + return ComponentCfgBase.CreateFromDbEntity(TestMethodCfg.Serializer, component, this); + } + } +} diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollDeferredEval/FixedStartMassCollDeferredEvalSeq.cs b/TBF/BenchControl/TestMethods/FixedStartMassCollDeferredEval/FixedStartMassCollDeferredEvalSeq.cs index 32b7bbc97..2b68d8113 100644 --- a/TBF/BenchControl/TestMethods/FixedStartMassCollDeferredEval/FixedStartMassCollDeferredEvalSeq.cs +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollDeferredEval/FixedStartMassCollDeferredEvalSeq.cs @@ -134,21 +134,21 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollDeferredEval processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, heatMetersTestParams != null); - int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - if (sensPath != null && sensPath.RegisterReaders != null) - { - foreach (var rr in sensPath.RegisterReaders) - { - TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; - if (eldeRR != null && eldeRR.Position >= 1 && eldeRR.Position <= 8) - { - filters[eldeRR.Position - 1] = eldeRR.Filter; - } - } - } - if (cBrd is ControlBoard.Legacy.ControlBoardDev) { + int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + if (sensPath != null && sensPath.RegisterReaders != null) + { + foreach (var rr in sensPath.RegisterReaders) + { + TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; + if (eldeRR != null && eldeRR.Position >= 1 && eldeRR.Position <= 8) + { + filters[eldeRR.Position - 1] = eldeRR.Filter; + } + } + } + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); } @@ -699,7 +699,6 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollDeferredEval /// Measurement loop - preparation readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders); queryEnd1 = cBrd.QueryMeasurementEndOp(); - queryEnd2 = cBrd.QueryMeasurementEndOp(); StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, Math.Max((int)(test.TstTime / 10), 5)); int estimtdEndTime = StateMachine.Time + (int)test.TstTime; diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs b/TBF/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs index 1e8f007a2..b770ccf98 100644 --- a/TBF/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs @@ -110,21 +110,21 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, heatMetersTestParams != null); - int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - if (sensPath != null && sensPath.RegisterReaders != null) - { - foreach (var rr in sensPath.RegisterReaders) - { - TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; - if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) - { - filters[eldeRR.Position - 1] = eldeRR.Filter; - } - } - } - if (cBrd is ControlBoard.Legacy.ControlBoardDev) { + int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + if (sensPath != null && sensPath.RegisterReaders != null) + { + foreach (var rr in sensPath.RegisterReaders) + { + TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; + if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) + { + filters[eldeRR.Position - 1] = eldeRR.Filter; + } + } + } + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); } @@ -653,33 +653,23 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection //------------------------------------------------ Bridge.OnActivity(this, Strings.Test_in_progress); //------------------------------------------------ - State.Create(string.Format("{0}({1}) : Starting the test", test.Method, test.Name)) + StartTime = (double)StateMachine.Time; + TestStartTime = DateTime.Now; + + State.Create(string.Format("{0}({1}) : Start the test, open the start/stop valve", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) .AddOperation(scale.ReadMassOp(ref Mass)) .AddOperation(cBrd.StartTestOp(test)) + .AddOperation(cBrd.OpenStartValveOp()) .EnterState(); - do { + do + { e = StateMachine.WaitRunDevsRunOps(); if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } } - while (!e.Contains(Event.MeasurementStarted)); - - StartTime = (double)StateMachine.Time; - TestStartTime = DateTime.Now; - - State.Create(string.Format("{0}({1}) : Opening the start/stop valve at the beginning of the fixed start test", test.Method, test.Name)) - .AddOperation(checkUiOp) - .AddOperations(readTempPressOps) - .AddOperation(scale.ReadMassOp(ref Mass)) - .AddOperation(cBrd.OpenStartValveOp()) - .EnterState(); - do { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } - } - while (!e.Contains(Event.ValvesSet)); + while (!e.Contains(Event.ValvesSet) && !e.Contains(Event.MeasurementStarted)); switchTimeStart = 0.001f * cBrd.ValveOpenCloseTime; log.WarnFormat("Start valve switch time on test start = {0} ms", cBrd.ValveOpenCloseTime); @@ -687,7 +677,6 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection /// Measurement loop - preparation readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders); queryEnd1 = cBrd.QueryMeasurementEndOp(); - queryEnd2 = cBrd.QueryMeasurementEndOp(); StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, Math.Max((int)(test.TstTime / 10), 5)); int estimtdEndTime = StateMachine.Time + (int)test.TstTime; diff --git a/TBF/BenchControl/TestMethods/FixedStartTankCollection/FixedStartTankCollectionSeq.cs b/TBF/BenchControl/TestMethods/FixedStartTankCollection/FixedStartTankCollectionSeq.cs index d986ab7c2..d46e00436 100644 --- a/TBF/BenchControl/TestMethods/FixedStartTankCollection/FixedStartTankCollectionSeq.cs +++ b/TBF/BenchControl/TestMethods/FixedStartTankCollection/FixedStartTankCollectionSeq.cs @@ -115,21 +115,21 @@ namespace TBF.BenchControl.TestMethods.FixedStartTankCollection processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false); - int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - if (sensPath != null && sensPath.RegisterReaders != null) - { - foreach (var rr in sensPath.RegisterReaders) - { - TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; - if (eldeRR != null && eldeRR.Position >= 1 && eldeRR.Position <= 8) - { - filters[eldeRR.Position - 1] = eldeRR.Filter; - } - } - } - if (cBrd is ControlBoard.Legacy.ControlBoardDev) { + int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + if (sensPath != null && sensPath.RegisterReaders != null) + { + foreach (var rr in sensPath.RegisterReaders) + { + TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; + if (eldeRR != null && eldeRR.Position >= 1 && eldeRR.Position <= 8) + { + filters[eldeRR.Position - 1] = eldeRR.Filter; + } + } + } + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); } @@ -514,7 +514,6 @@ namespace TBF.BenchControl.TestMethods.FixedStartTankCollection /// Measurement loop - preparation readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders); queryEnd1 = cBrd.QueryMeasurementEndOp(); - queryEnd2 = cBrd.QueryMeasurementEndOp(); StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, Math.Max((int)(test.TstTime / 10), 5)); int estimtdEndTime = StateMachine.Time + (int)test.TstTime; diff --git a/TBF/BenchControl/TestMethods/FlowAdjustment/Component.cs b/TBF/BenchControl/TestMethods/FlowAdjustment/Component.cs new file mode 100644 index 000000000..7c9a870ad --- /dev/null +++ b/TBF/BenchControl/TestMethods/FlowAdjustment/Component.cs @@ -0,0 +1,39 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using log4net; +using Config.Entities; + +namespace TBF.BenchControl.TestMethods.FlowAdjustment +{ + public class Component : ComponentBase, GenericDevices.ITestMethod + { + private static readonly ILog log = LogManager.GetLogger(typeof(Component)); + public override string ToString() + { + return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1)); + } + + public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } + public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FlowAdjustmentSeq.CheckDeviceCaps(test, devices, out message); + } + + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) + : base(cfg) + { + log.Debug(this.ToString()); + } + + public IList Execute(Test test, int repetNr, bool isLastRepetition) + { + return (new FlowAdjustmentSeq()).Execute(test, repetNr, isLastRepetition, DebugLevel); + } + } +} diff --git a/TBF/BenchControl/TestMethods/FlowAdjustment/Factory.cs b/TBF/BenchControl/TestMethods/FlowAdjustment/Factory.cs new file mode 100644 index 000000000..dacc082a7 --- /dev/null +++ b/TBF/BenchControl/TestMethods/FlowAdjustment/Factory.cs @@ -0,0 +1,27 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System.Collections.Generic; +using TBF.BenchControl.Generic; +using TBF.BenchControl.Configs.NameOnly; + +namespace TBF.BenchControl.TestMethods.FlowAdjustment +{ + public class Factory : IComponentFactory + { + public string ClassName { get { return this.GetType().Namespace.Substring(17); } } + + public void ResetStaticProperties() { Component.ResetStaticProperties(); } + + public IComponent DummyComponent() { return new Component(); } + + public IComponent GetComponent(IComponentCfg cfg, IList components) { return new Component(cfg); } + + public IComponentCfg DefaultConfig() { return new TestMethodCfg(this.GetType().Namespace.Substring(29), this); } + + public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) + { + return ComponentCfgBase.CreateFromDbEntity(TestMethodCfg.Serializer, component, this); + } + } +} diff --git a/TBF/BenchControl/TestMethods/FlowAdjustment/FlowAdjustmentSeq.cs b/TBF/BenchControl/TestMethods/FlowAdjustment/FlowAdjustmentSeq.cs new file mode 100644 index 000000000..90dafaa50 --- /dev/null +++ b/TBF/BenchControl/TestMethods/FlowAdjustment/FlowAdjustmentSeq.cs @@ -0,0 +1,453 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using System.Text; +using log4net; +using TBF.BenchControl; +using TBF.Boxes; +using TBF.Resources; +using TBF.UiBridge; + +namespace TBF.BenchControl.TestMethods.FlowAdjustment +{ + public class FlowAdjustmentSeq : Sequences.SequenceBase + { + private static readonly ILog log = LogManager.GetLogger(typeof(FlowAdjustmentSeq)); + + /// + /// Check capabilities of devces in the output path required for this test method + /// + /// Devices + /// true when capabilities of devices are OK + public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) + { + if (!(StateMachine.ControlBoard is ControlBoard.Legacy.ControlBoardDev) && + !(StateMachine.ControlBoard is ControlBoard.Papouch.CBoard) && + !(StateMachine.ControlBoard is ControlBoard.New.CBoard)) + { + /// Control board does not support this method + message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); + return false; + } + + if (!(devices.FlowMeter is TBF.BenchControl.GenericDevices.IFlowMeter)) + { + /// Flow meter is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_flow_meter); + return false; + } + + if (!(devices.RegulValve is GenericDevices.IRegulValve)) + { + /// Regulation valve is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_regulation_valve); + return false; + } + + message = string.Empty; + return true; + } + + /// + /// Flying start mass collection method sequence + /// + /// Test entity + /// + /// Event.Done . . . . . . . OK + /// Event.UiCmdStop . . . . Stopped by the user using the on-screen button STOP + /// Event.OpArgumentError . Target flow is out of range + /// Event.Error . . . . . . Unspecified error + /// + public IList Execute(Config.Entities.Test test, int repetitionNr, bool isLastRepetition, Config.Entities.DebugMode debugLevel) + { + if (debugLevel == Config.Entities.DebugMode.Simulate) + { + return Simulate(test, repetitionNr, isLastRepetition, debugLevel); + } + + ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; + + int rangeIx = 0; /// Default range, used for non-Elde flowmeters + if (outPath.FlowMeter is Elde.FlowMeter.FlowMeter) + { + Elde.FlowMeter.FlowMeter eldeFM = outPath.FlowMeter as Elde.FlowMeter.FlowMeter; + rangeIx = -1; /// Indicates invalid range + for (int r = 0; r <= 5; r++) + { + if (eldeFM.RangeEnabled(r) && eldeFM.GetTempLo(r) <= test.TempLimLo + && eldeFM.GetTempHi(r) >= test.TempLimHi) + { + rangeIx = r; + } + } + + if (rangeIx == -1) + { + Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); + return new List { Event.ConfigurationError }; + } + } + + + IList e; /// Events from currently running operations + Event retVal = Event.Done; + checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state + processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false); + + + if (cBrd is ControlBoard.Legacy.ControlBoardDev) + { + int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + + if (sensPath != null && sensPath.RegisterReaders != null) + { + foreach (var rr in sensPath.RegisterReaders) + { + TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; + if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) + { + filters[eldeRR.Position - 1] = eldeRR.Filter; + } + } + } + + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + } + + IList readTempPressOps = new List(); + if (benchPath.TempMtrUp != null) readTempPressOps.Add(benchPath.TempMtrUp.ReadTempOp(ref TempUp)); + if (benchPath.TempMtrDown != null) readTempPressOps.Add(benchPath.TempMtrDown.ReadTempOp(ref TempDown)); + if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp)); + if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown)); + if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta)); + if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1)); + if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2)); + if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1)); + if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)); + + LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h] + int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f); + + //==================================== + loop: + /// Read pressure and temperature once before calling Bridge.OnTestSelected(...) + State.Create(string.Format("{0}({1}) : Measuring process data", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(readTempPressOps) + .EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (e.Contains(Event.Busy)); + + /// Start the test, initialize test results + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); + string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); + TestStartTime = DateTime.Now; + + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Starting_the_pump); + //------------------------------------------------ + if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower); + /// + State.Create(string.Format("{0}({1}) : Starting the pump", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(readTempPressOps) + //.AddOperation(new Operations.SetAllRegulValvesOp(inPath.RegulValves, inPath.RegulValvesPct, 60)) + .AddOperation(inPath.Pump != null ? cBrd.SetValvesOp(inPath.Pump, null) : null) + .EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); + + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + } + while (e.Contains(Event.ValvesBusy) /* || !e.Contains(Event.AllPositionsReached)*/); + + + if (test.TimePump2StartV > 0) + { + State.Create(string.Format("{0}({1}) : Waiting after the pump started", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(readTempPressOps) + .AddOperation(new Operations.TimerOp(test.TimePump2StartV)) + .EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); + + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.TimerExpired)); + } + + + if (benchPath.StopBFValve != null) + { + State.Create(string.Format("{0}({1}) : Opening the stop backflow valve", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(readTempPressOps) + .AddOperation(cBrd.SetValvesOp(benchPath.StopBFValve, null)) + .EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + } + while (!e.Contains(Event.ValvesSet)); + } + + + if (test.TimeBeforeFlow > 0) + { + State.Create(string.Format("{0}({1}) : Waiting before flow setting process starts", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(readTempPressOps) + .AddOperation(new Operations.TimerOp(test.TimeBeforeFlow)) + .EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); + + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.TimerExpired)); + } + + + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Setting_the_flow); + //------------------------------------------------ + TestStartTime = DateTime.Now; + State.Create(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(readTempPressOps) + .AddOperation(cBrd.SetFlowOp(test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) + .EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); + + if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; } + if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } + if (e.Contains(Event.RegulValveTimeOut)) + { + Bridge.OnError(this, Strings.Flow_adjustment_failed); + retVal = Event.RecoverableError; + goto stopTest; + } + if (e.Contains(Event.Next)) goto flow_set; + } + while (!e.Contains(Event.FlowReached)); + + flow_set: + + TestEndTime = DateTime.Now; + double currentFlow = RefFlow.Val; + + if (test.DoControlWaterTemp && benchPath.TempMtrUp != null && benchPath.TempMtrDown != null) + { + //--------------------------------------------------- + Bridge.OnActivity(this, Strings.Setting_temperature); + //--------------------------------------------------- + + State.Create(string.Format("{0}({1}) : Wait until the water temperature is within limits", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(readTempPressOps) + .EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + if (e.Contains(Event.Next)) goto temperature_set; + + if ((test.TempLimLo <= TempUp.Val) && (TempUp.Val <= test.TempLimHi) && + (test.TempLimLo <= TempDown.Val) && (TempDown.Val <= test.TempLimHi)) + { + goto temperature_set; + } + } + while (true); + } + + temperature_set: + + StopRecordingStatistics(); + + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Test_completed); + //------------------------------------------------ + + /// + /// Populate TestResult data entity with data + /// + Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part); + + if (tstRslt != null) + { + Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters); + UpdateTempPressDensAmb(tstRslt); + + /// Main results + tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; + tstRslt.StartTime = TestStartTime; + tstRslt.EndTime = TestEndTime; + TimeSpan duration = TestEndTime - TestStartTime; + tstRslt.TestTime = duration.TotalSeconds; + tstRslt.FlowSetTime = Convert.ToInt32(Math.Round(tstRslt.TestTime)); /// [s] test time = flow set time + tstRslt.PulsesMaster = 0; + tstRslt.MassStartRaw = 0; + tstRslt.MassStart = 0; + tstRslt.MassEndRaw = 0; + tstRslt.MassEnd = 0; + tstRslt.FlowMass = 0; + tstRslt.FlowVolume = 0; + tstRslt.Buoyancy = Config.Formulas.Buoyancy(); + tstRslt.VolumeMaster = LtrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter + tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient + tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(tstRslt.FlowVolume, rangeIx); /// Corrected master pulses per liter + tstRslt.ConstMaster = tstRslt.ConstMasterCorr; + tstRslt.VolumeCTV = tstRslt.ConstMaster * tstRslt.PulsesMaster; /// [l] 1000.0f is because density is in [kg/m3] + tstRslt.ErrorMaster = 0.0; /// Cannot be determined without a mass measurement + + tstRslt.FlowMean = (float)RefFlowStat.Average; + tstRslt.FlowStart = (float)RefFlowStat.First; + tstRslt.FlowEnd = (float)RefFlowStat.Last; + tstRslt.FlowMin = (float)RefFlowStat.Min; + tstRslt.FlowMax = (float)RefFlowStat.Max; + + tstRslt.DiverterStart = 0; + tstRslt.DiverterEnd = 0; + long infoFlags = 0; + tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(tstRslt, false, false, 0, 0, out infoFlags) : 0; + tstRslt.InfoFlags = infoFlags; + + /// + /// Single meters + /// + for (int i = 0; i < BatchRslts.WMPositionsCount; i++) + { + if (!test.IsPartCompatible(Utils.PartNr(i + 1, BatchRslts.Batch.Compound))) continue; + + Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single); + + if (meterRslt != null) + { + meterRslt.Passed = true; + meterRslt.TestDone = true; + tstRslt.TestDone = true; + } + } + + tstRslt.Components = Results.Entities.Components + .UpdateList(BatchRslts.ComponentsList, + new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1, + (BenchInfo != null) ? BenchInfo.TestBenchName : "testbench", + inPath.Pump != null ? inPath.Pump.Name : string.Empty, + outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty, + string.Empty, + outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty, + outPath.Diverter != null ? outPath.Diverter.Name : string.Empty)); + + /// Update water meter error flags + if (ErrorFlagsComp != null) + { + if (BatchRslts.Batch != null && BatchRslts.Batch.WaterMeters != null) + { + for (int i = 0; i < BatchRslts.WMPositionsCount; i++) + { + if (BatchRslts.Batch.WaterMeters[i] != null && !BatchRslts.Batch.WaterMeters[i].Disabled) + { + long wmInfoFlags; + BatchRslts.Batch.WaterMeters[i].ErrorFlags = ErrorFlagsComp.GetWMtrErrorFlags(BatchRslts.Batch.WaterMeters[i].MeterTestRslts, out wmInfoFlags); + BatchRslts.Batch.WaterMeters[i].InfoFlags = wmInfoFlags; + } + } + } + } + + /// Update results + Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName, tstRslt)); + } + + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.TransitionAfter)); + + /// Append the results to the CSV-file + allResults.Info(TestResult2CsvLine(testName, test.Part)); + + + stopTest: + + StopRecordingStatistics(); + + State.Create(string.Format("{0}({1}) : Stopping flow regulation", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(readTempPressOps) + .AddOperation(cBrd.StopFlowRegulationOp()) + .EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.Error)) { retVal = Event.Error; break; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; break; } + } + while (!e.Contains(Event.FlowRegulationStopped)); + + /// + /// Quit this sequence + /// + if (isLastRepetition || retVal == Event.UiCmdStop || retVal == Event.OpArgumentError + || retVal == Event.Error || retVal == Event.ConfigurationError) + { + State.Create(string.Format("{0}({1}) : Stopping diverter, gate, etc.", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperation(cBrd.StopPreviousOp()) + .EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + if (TestAndLogUiCmdStop(test, e)) { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; } + } + while (!e.Contains(Event.PreviousStopped)); + } + + stopTestWOStoppingDivGateEtc: + + return new List { retVal }; + } + + + IList Simulate(Config.Entities.Test test, int repetitionNr, bool isLastRepetition, Config.Entities.DebugMode debugLevel) + { + /// + /// Test method simulation + /// + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); + if (test.Name.ToLower().Contains("q3")) MakeSimulated(test, 1, 0, -0.5f); + else if (test.Name.ToLower().Contains("q2")) MakeSimulated(test, 1, 0, 0.5f); + else if (test.Name.ToLower().Contains("q1")) MakeSimulated(test, 1, 0, -5.1f); + else MakeSimulated(test, 1, 0, 0.9f); + + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Completed)); + Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name, BatchRslts.GetTestRslt(Results.Utils.GetTestName(test.Name, 1, 1), 0))); + allResults.Info(TestResult2CsvLine(test.Name, 0)); /// Append the results to the CSV-file + + //------------------------------------------------------------------ + Bridge.OnActivity(this, string.Format("{0} simulation", test.Name)); + //------------------------------------------------------------------ + + State.Create(string.Format("{0}({1}) : Simulating {0}", test.Method, test.Name)) + .AddOperation(checkUiOp) + .EnterState(); + IList e = StateMachine.WaitRunDevsRunOps(); + + return new List { TestAndLogUiCmdStop(test, e) ? Event.UiCmdStop : Event.Done }; + } + } +} diff --git a/TBF/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/FlyingStartFirstRepetWithMassCollSeq.cs b/TBF/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/FlyingStartFirstRepetWithMassCollSeq.cs index e30de316e..800891a09 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/FlyingStartFirstRepetWithMassCollSeq.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/FlyingStartFirstRepetWithMassCollSeq.cs @@ -131,21 +131,21 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, heatMetersTestParams != null); - int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - if (sensPath != null && sensPath.RegisterReaders != null) - { - foreach (var rr in sensPath.RegisterReaders) - { - TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; - if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) - { - filters[eldeRR.Position - 1] = eldeRR.Filter; - } - } - } - if (cBrd is ControlBoard.Legacy.ControlBoardDev) { + int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + if (sensPath != null && sensPath.RegisterReaders != null) + { + foreach (var rr in sensPath.RegisterReaders) + { + TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; + if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) + { + filters[eldeRR.Position - 1] = eldeRR.Filter; + } + } + } + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); } diff --git a/TBF/BenchControl/TestMethods/FlyingStartMassCollComparative/FlyingStartMassCollComparativeSeq.cs b/TBF/BenchControl/TestMethods/FlyingStartMassCollComparative/FlyingStartMassCollComparativeSeq.cs index b03e220e4..11bf9e80c 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartMassCollComparative/FlyingStartMassCollComparativeSeq.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartMassCollComparative/FlyingStartMassCollComparativeSeq.cs @@ -151,21 +151,21 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, heatMetersTestParams != null); - int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - if (sensPath != null && sensPath.RegisterReaders != null) - { - foreach (var rr in sensPath.RegisterReaders) - { - TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; - if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) - { - filters[eldeRR.Position - 1] = eldeRR.Filter; - } - } - } - if (cBrd is ControlBoard.Legacy.ControlBoardDev) { + int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + if (sensPath != null && sensPath.RegisterReaders != null) + { + foreach (var rr in sensPath.RegisterReaders) + { + TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; + if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) + { + filters[eldeRR.Position - 1] = eldeRR.Filter; + } + } + } + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); } diff --git a/TBF/BenchControl/TestMethods/FlyingStartMassCollProlonged/FlyingStartMassCollProlongedSeq.cs b/TBF/BenchControl/TestMethods/FlyingStartMassCollProlonged/FlyingStartMassCollProlongedSeq.cs index e87b817a6..3aea067d3 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartMassCollProlonged/FlyingStartMassCollProlongedSeq.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartMassCollProlonged/FlyingStartMassCollProlongedSeq.cs @@ -126,23 +126,23 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged int tMass2 = 0; checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, heatMetersTestParams != null); - - int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - if (sensPath != null && sensPath.RegisterReaders != null) - { - foreach (var rr in sensPath.RegisterReaders) - { - TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; - if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) - { - filters[eldeRR.Position - 1] = eldeRR.Filter; - } - } - } if (cBrd is ControlBoard.Legacy.ControlBoardDev) { + int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + if (sensPath != null && sensPath.RegisterReaders != null) + { + foreach (var rr in sensPath.RegisterReaders) + { + TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; + if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) + { + filters[eldeRR.Position - 1] = eldeRR.Filter; + } + } + } + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); } diff --git a/TBF/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs b/TBF/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs index 146a7fb8c..1c359fdc0 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs @@ -127,21 +127,21 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, heatMetersTestParams != null); - int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - if (sensPath != null && sensPath.RegisterReaders != null) - { - foreach (var rr in sensPath.RegisterReaders) - { - TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; - if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) - { - filters[eldeRR.Position - 1] = eldeRR.Filter; - } - } - } - if (cBrd is ControlBoard.Legacy.ControlBoardDev) { + int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + if (sensPath != null && sensPath.RegisterReaders != null) + { + foreach (var rr in sensPath.RegisterReaders) + { + TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; + if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) + { + filters[eldeRR.Position - 1] = eldeRR.Filter; + } + } + } + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); } diff --git a/TBF/BenchControl/TestMethods/FlyingStartTankCollection/FlyingStartTankCollectionSeq.cs b/TBF/BenchControl/TestMethods/FlyingStartTankCollection/FlyingStartTankCollectionSeq.cs index a7631949b..575dd3543 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartTankCollection/FlyingStartTankCollectionSeq.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartTankCollection/FlyingStartTankCollectionSeq.cs @@ -134,21 +134,21 @@ namespace TBF.BenchControl.TestMethods.FlyingStartTankCollection processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false); - int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - if (sensPath != null && sensPath.RegisterReaders != null) - { - foreach (var rr in sensPath.RegisterReaders) - { - TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; - if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) - { - filters[eldeRR.Position - 1] = eldeRR.Filter; - } - } - } - if (cBrd is ControlBoard.Legacy.ControlBoardDev) { + int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + if (sensPath != null && sensPath.RegisterReaders != null) + { + foreach (var rr in sensPath.RegisterReaders) + { + TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; + if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) + { + filters[eldeRR.Position - 1] = eldeRR.Filter; + } + } + } + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); } diff --git a/TBF/BenchControl/TestMethods/PulsesTest/PulsesTestSeq.cs b/TBF/BenchControl/TestMethods/PulsesTest/PulsesTestSeq.cs index 3c03e4fd6..1ad1a4915 100644 --- a/TBF/BenchControl/TestMethods/PulsesTest/PulsesTestSeq.cs +++ b/TBF/BenchControl/TestMethods/PulsesTest/PulsesTestSeq.cs @@ -85,21 +85,21 @@ namespace TBF.BenchControl.TestMethods.PulsesTest processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false); - int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - if (sensPath != null && sensPath.RegisterReaders != null) - { - foreach (var rr in sensPath.RegisterReaders) - { - TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; - if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) - { - filters[eldeRR.Position - 1] = eldeRR.Filter; - } - } - } - if (cBrd is ControlBoard.Legacy.ControlBoardDev) { + int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + if (sensPath != null && sensPath.RegisterReaders != null) + { + foreach (var rr in sensPath.RegisterReaders) + { + TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; + if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) + { + filters[eldeRR.Position - 1] = eldeRR.Filter; + } + } + } + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); } @@ -352,7 +352,6 @@ namespace TBF.BenchControl.TestMethods.PulsesTest /// Measurement loop - preparation readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders); queryEnd1 = cBrd.QueryMeasurementEndOp(); - queryEnd2 = cBrd.QueryMeasurementEndOp(); StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, 0); diff --git a/TBF/BenchControl/TestMethods/PulsesTestManual/PulsesTestManualSeq.cs b/TBF/BenchControl/TestMethods/PulsesTestManual/PulsesTestManualSeq.cs index 896133a7a..688d4f6e5 100644 --- a/TBF/BenchControl/TestMethods/PulsesTestManual/PulsesTestManualSeq.cs +++ b/TBF/BenchControl/TestMethods/PulsesTestManual/PulsesTestManualSeq.cs @@ -86,21 +86,21 @@ namespace TBF.BenchControl.TestMethods.PulsesTestManual processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false); - int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - if (sensPath != null && sensPath.RegisterReaders != null) - { - foreach (var rr in sensPath.RegisterReaders) - { - TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; - if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) - { - filters[eldeRR.Position - 1] = eldeRR.Filter; - } - } - } - if (cBrd is ControlBoard.Legacy.ControlBoardDev) { + int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + if (sensPath != null && sensPath.RegisterReaders != null) + { + foreach (var rr in sensPath.RegisterReaders) + { + TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; + if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) + { + filters[eldeRR.Position - 1] = eldeRR.Filter; + } + } + } + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); } @@ -354,7 +354,6 @@ namespace TBF.BenchControl.TestMethods.PulsesTestManual /// Measurement loop - preparation readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders); queryEnd1 = cBrd.QueryMeasurementEndOp(); - queryEnd2 = cBrd.QueryMeasurementEndOp(); StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, 0); diff --git a/TBF/BenchControl/TestMethods/RoiDetection/RoiDetectionSeq.cs b/TBF/BenchControl/TestMethods/RoiDetection/RoiDetectionSeq.cs index 8f9935a82..f90d8f46d 100644 --- a/TBF/BenchControl/TestMethods/RoiDetection/RoiDetectionSeq.cs +++ b/TBF/BenchControl/TestMethods/RoiDetection/RoiDetectionSeq.cs @@ -26,21 +26,21 @@ namespace TBF.BenchControl.TestMethods.RoiDetection processDataLoggingOp = null; - int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - if (sensPath != null && sensPath.RegisterReaders != null) - { - foreach (var rr in sensPath.RegisterReaders) - { - TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; - if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) - { - filters[eldeRR.Position - 1] = eldeRR.Filter; - } - } - } - if (cBrd is ControlBoard.Legacy.ControlBoardDev) { + int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + if (sensPath != null && sensPath.RegisterReaders != null) + { + foreach (var rr in sensPath.RegisterReaders) + { + TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; + if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) + { + filters[eldeRR.Position - 1] = eldeRR.Filter; + } + } + } + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); } diff --git a/TBF/BenchControl/TestMethods/SensitivityTest/SensitivityTestSeq.cs b/TBF/BenchControl/TestMethods/SensitivityTest/SensitivityTestSeq.cs index b75170bd7..2684731ec 100644 --- a/TBF/BenchControl/TestMethods/SensitivityTest/SensitivityTestSeq.cs +++ b/TBF/BenchControl/TestMethods/SensitivityTest/SensitivityTestSeq.cs @@ -65,21 +65,21 @@ namespace TBF.BenchControl.TestMethods.SensitivityTest processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false); - int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - if (sensPath != null && sensPath.RegisterReaders != null) - { - foreach (var rr in sensPath.RegisterReaders) - { - TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; - if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) - { - filters[eldeRR.Position - 1] = eldeRR.Filter; - } - } - } - if (cBrd is ControlBoard.Legacy.ControlBoardDev) { + int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + if (sensPath != null && sensPath.RegisterReaders != null) + { + foreach (var rr in sensPath.RegisterReaders) + { + TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; + if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) + { + filters[eldeRR.Position - 1] = eldeRR.Filter; + } + } + } + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); } diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index 53eba57bc..a1171b949 100644 --- a/TBF/Properties/AssemblyInfo.cs +++ b/TBF/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("3.1.1470.0")] -[assembly: AssemblyFileVersion("3.1.1470.0")] +[assembly: AssemblyVersion("3.1.1471.0")] +[assembly: AssemblyFileVersion("3.1.1471.0")] diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj index c3bedcf45..11942df57 100644 --- a/TBF/TBF.csproj +++ b/TBF/TBF.csproj @@ -1303,6 +1303,21 @@ + + + + + + + + UserControl + + + TestMethodCfgCtrl.cs + + + + @@ -1369,6 +1384,9 @@ + + + @@ -3064,6 +3082,9 @@ TestMethodCfgCtrl.cs + + TestMethodCfgCtrl.cs + TestMethodCfgCtrl.cs