diff --git a/TestBenchFramework/BenchControl/Elde/RegulValve/SetFlowOp.cs b/TestBenchFramework/BenchControl/Elde/RegulValve/SetFlowOp.cs index 4c5916b57..2b612ac8a 100644 --- a/TestBenchFramework/BenchControl/Elde/RegulValve/SetFlowOp.cs +++ b/TestBenchFramework/BenchControl/Elde/RegulValve/SetFlowOp.cs @@ -154,7 +154,7 @@ namespace TBF.BenchControl.Elde.RegulValve opState = OpState.ValveMoveToFlow; } - expireTime = StateMachine.CurrentTime + timeout; + expireTime = StateMachine.Time + timeout; if (expireTime < 0) expireTime = int.MaxValue; TestMethods tm = 0; @@ -238,7 +238,7 @@ namespace TBF.BenchControl.Elde.RegulValve opState = OpState.FlowReached; return Event.FlowReached; } - else if (StateMachine.CurrentTime > expireTime) + else if (StateMachine.Time > expireTime) { return Event.RegulValveTimeOut; } diff --git a/TestBenchFramework/BenchControl/Elde/RegulValve/SetRegulValvePositionOp.cs b/TestBenchFramework/BenchControl/Elde/RegulValve/SetRegulValvePositionOp.cs index 2421d3c7f..dc4b99f49 100644 --- a/TestBenchFramework/BenchControl/Elde/RegulValve/SetRegulValvePositionOp.cs +++ b/TestBenchFramework/BenchControl/Elde/RegulValve/SetRegulValvePositionOp.cs @@ -67,7 +67,7 @@ namespace TBF.BenchControl.Elde.RegulValve { firstRun = true; positionReached = false; - expireTime = StateMachine.CurrentTime + timeout; + expireTime = StateMachine.Time + timeout; log.InfoFormat("Start(): RV#={0}, reqPosLo={1}%, reqPosHi={2}%", regulValveNr, posLoPct.ToString("F1"), posHiPct.ToString("F1")); } @@ -106,7 +106,7 @@ namespace TBF.BenchControl.Elde.RegulValve positionReached = true; return Event.PositionReached; } - else if (StateMachine.CurrentTime > expireTime) + else if (StateMachine.Time > expireTime) { return Event.RegulValveTimeOut; } diff --git a/TestBenchFramework/BenchControl/Elde/Valve/SetValvesOp.cs b/TestBenchFramework/BenchControl/Elde/Valve/SetValvesOp.cs index a83210ffa..0fb35e8fd 100644 --- a/TestBenchFramework/BenchControl/Elde/Valve/SetValvesOp.cs +++ b/TestBenchFramework/BenchControl/Elde/Valve/SetValvesOp.cs @@ -167,7 +167,7 @@ namespace TBF.BenchControl.Elde.Valve public void Start() { controlBoard.SetValves(switchPoints[0].MasksOpen, switchPoints[0].MasksClose); - swStartTime = StateMachine.CurrentTime; + swStartTime = StateMachine.Time; nextIx = 1; } @@ -179,7 +179,7 @@ namespace TBF.BenchControl.Elde.Valve { if (nextIx >= switchPoints.Count) return Event.ValvesSet; - if (StateMachine.CurrentTime >= swStartTime + switchPoints[nextIx].TimeSec) + if (StateMachine.Time >= swStartTime + switchPoints[nextIx].TimeSec) { controlBoard.SetValves(switchPoints[nextIx].MasksOpen, switchPoints[nextIx].MasksClose); nextIx++; diff --git a/TestBenchFramework/BenchControl/Greco/Ambient.cs b/TestBenchFramework/BenchControl/Greco/Ambient.cs index ca8ebcce5..8321b0fa5 100644 --- a/TestBenchFramework/BenchControl/Greco/Ambient.cs +++ b/TestBenchFramework/BenchControl/Greco/Ambient.cs @@ -64,7 +64,7 @@ namespace TBF.BenchControl.Greco temperature = 20.0f; humidity = 40.0f; pressure = 1.0f; - msrmntTimeStamp = StateMachine.CurrentTime; + msrmntTimeStamp = StateMachine.Time; msrmntState = BenchControl.MsrmntState.Valid; return; } @@ -82,7 +82,7 @@ namespace TBF.BenchControl.Greco { if (ambientCfg.DebugLevel == Entities.DebugMode.Simulate) { - msrmntTimeStamp = StateMachine.CurrentTime; + msrmntTimeStamp = StateMachine.Time; return; } @@ -124,7 +124,7 @@ namespace TBF.BenchControl.Greco temperature = t; humidity = h; pressure = p; - msrmntTimeStamp = StateMachine.CurrentTime; + msrmntTimeStamp = StateMachine.Time; msrmntState = MsrmntState.Valid; log.InfoFormat("Msrmnt OK: time = {0}, temp={1}, humi={2}, pres={3}", msrmntTimeStamp, t, h, p); diff --git a/TestBenchFramework/BenchControl/MettlerToledo/BalanceDev.cs b/TestBenchFramework/BenchControl/MettlerToledo/BalanceDev.cs index 51ba6345c..bd964b5fe 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/BalanceDev.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/BalanceDev.cs @@ -223,7 +223,7 @@ namespace TBF.BenchControl.MettlerToledo mass = GetSimMass(balanceNr); Masses[balanceNr] = mass; msrmntState = MsrmntState.Valid; - msrmntTimeStamp = StateMachine.CurrentTime; + msrmntTimeStamp = StateMachine.Time; return; } @@ -242,7 +242,7 @@ namespace TBF.BenchControl.MettlerToledo int eolPos = currentBuffer.IndexOf("\r\n"); if (eolPos >= 0) { - msrmntTimeStamp = StateMachine.CurrentTime; + msrmntTimeStamp = StateMachine.Time; /// Get part of theh string before EOL string received = currentBuffer.Substring(0, eolPos); diff --git a/TestBenchFramework/BenchControl/MettlerToledo/BalanceNewDev.cs b/TestBenchFramework/BenchControl/MettlerToledo/BalanceNewDev.cs index bbd8021d2..fca67c332 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/BalanceNewDev.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/BalanceNewDev.cs @@ -68,7 +68,7 @@ namespace TBF.BenchControl.MettlerToledo Masses[balanceNr] = mass; serialNumber = "1234567890"; msrmntState = MsrmntState.Valid; - msrmntTimeStamp = StateMachine.CurrentTime; + msrmntTimeStamp = StateMachine.Time; return; } @@ -84,7 +84,7 @@ namespace TBF.BenchControl.MettlerToledo if (stringBuilder.ToString().EndsWith("\r\n")) { - msrmntTimeStamp = StateMachine.CurrentTime; + msrmntTimeStamp = StateMachine.Time; string received = stringBuilder.ToString(); diff --git a/TestBenchFramework/BenchControl/Operations/TimerOp.cs b/TestBenchFramework/BenchControl/Operations/TimerOp.cs index b93ce96f1..adadb5eef 100644 --- a/TestBenchFramework/BenchControl/Operations/TimerOp.cs +++ b/TestBenchFramework/BenchControl/Operations/TimerOp.cs @@ -47,12 +47,12 @@ namespace TBF.BenchControl.Operations { timeExpired = false; timerStarted = true; - expireTime = StateMachine.CurrentTime + timerTime; + expireTime = StateMachine.Time + timerTime; } public Event Run() { - if (timerStarted && !timeExpired && StateMachine.CurrentTime >= expireTime) + if (timerStarted && !timeExpired && StateMachine.Time >= expireTime) { timeExpired = true; return eventExpired; diff --git a/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs b/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs index 9b749cfad..0a287f766 100644 --- a/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs +++ b/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs @@ -98,14 +98,22 @@ namespace TBF.BenchControl.Sequences static SequenceBase() { results = new List(); - } - ///------------------------------------------------------------ - /// Test related (instance) variables. - /// Created when test sequence is open. - /// They persist during all repetitions of the same test - ///------------------------------------------------------------ - protected BenchControl.FeedingPath inPath; + WMVolumes = new FloatBox[Program.WMsCount]; + WMErrors = new FloatBox[Program.WMsCount]; + for (int i = 0; i < Program.WMsCount; i++) + { + WMVolumes[i] = new FloatBox() { Name = string.Format("Volume{0}", i), Format = "F2" }; + WMErrors[i] = new FloatBox() { Name = string.Format("Error{0}", i), Format = "F2" }; + } + } + + ///------------------------------------------------------------ + /// Test related (instance) variables. + /// Created when test sequence is open. + /// They persist during all repetitions of the same test + ///------------------------------------------------------------ + protected BenchControl.FeedingPath inPath; protected BenchControl.BenchPath benchPath; protected BenchControl.OutputPath outPath; protected BenchControl.MetersPath sensPath; @@ -113,18 +121,17 @@ namespace TBF.BenchControl.Sequences protected Entities.TransitionSequence transitionStart; protected Entities.TransitionSequence transitionStop; + #region Temperature_Pressure_Humidity - protected FloatBox tempIn = new FloatBox() { Name = "Temperature In", Format = "F1" }; - protected FloatBox tempOut = new FloatBox() { Name = "Temperature Out", Format = "F1" }; - protected FloatBox tempDiv = new FloatBox() { Name = "Temperature Div", Format = "F1" }; - - protected FloatBox pressIn = new FloatBox() { Name = "Pressure In", Format = "F1" }; - protected FloatBox pressOut = new FloatBox() { Name = "Pressure Out", Format = "F1" }; - - protected FloatBox airTemperature = new FloatBox() { Name = "Ambient Temperature", Format = "F1" }; - protected FloatBox airPressure = new FloatBox() { Name = "Ambient Pressure", Format = "F1" }; - protected FloatBox airHumidity = new FloatBox() { Name = "Ambient Humidity", Format = "F1" }; + protected static FloatBox tempIn = new FloatBox() { Name = "Temperature In", Format = "F1" }; + protected static FloatBox tempOut = new FloatBox() { Name = "Temperature Out", Format = "F1" }; + protected static FloatBox tempDiv = new FloatBox() { Name = "Temperature Div", Format = "F1" }; + protected static FloatBox pressIn = new FloatBox() { Name = "Pressure In", Format = "F3", Factor = 0.01f }; + protected static FloatBox pressOut = new FloatBox() { Name = "Pressure Out", Format = "F3", Factor = 0.01f }; + protected static FloatBox airTemperature = new FloatBox() { Name = "Ambient Temperature", Format = "F1" }; + protected static FloatBox airPressure = new FloatBox() { Name = "Ambient Pressure", Format = "F1" }; + protected static FloatBox airHumidity = new FloatBox() { Name = "Ambient Humidity", Format = "F1" }; /// protected float tempInSum; protected float tempOutSum; @@ -183,10 +190,6 @@ namespace TBF.BenchControl.Sequences #endregion - protected bool ticTac = false; - protected int[] WMPulses = new int[Program.WMsCount]; - protected int[] WMRefPulses = new int[Program.WMsCount]; - protected IOperation readRegisters1; protected IOperation readRegisters2; @@ -195,25 +198,42 @@ namespace TBF.BenchControl.Sequences protected IOperation checkUiOp; - protected IntBox refCount = new IntBox() { Name = "RefCount" }; - protected FloatBox refFreq = new FloatBox() { Name = "RefFreq", Format = "F2" }; - protected FloatBox refFlow = new FloatBox() { Name = "RefFlow", Format = "F2" }; - protected FloatBox mass = new FloatBox() { Name = "Mass", Format = "F1" }; - protected FloatBox startMass = new FloatBox() { Name = "Start Mass", Format = "F1" }; - protected FloatBox endMass = new FloatBox() { Name = "End Mass", Format = "F1" }; + protected bool ticTac = false; + protected int[] WMPulses = new int[Program.WMsCount]; + protected int[] WMRefPulses = new int[Program.WMsCount]; + + protected static FloatBox[] WMVolumes; + protected static FloatBox[] WMErrors; + + protected static IntBox refCount = new IntBox() { Name = "RefCount" }; + protected static FloatBox refFreq = new FloatBox() { Name = "RefFreq", Format = "F2" }; + protected static FloatBox refFlow = new FloatBox() { Name = "RefFlow", Format = "F2" }; + protected static FloatBox mass = new FloatBox() { Name = "Mass", Format = "F1" }; + protected static FloatBox startMass = new FloatBox() { Name = "Start Mass", Format = "F1" }; + protected static FloatBox endMass = new FloatBox() { Name = "End Mass", Format = "F1" }; /// /// To clear process values at the beginning of each test /// protected void ClearProcessValues() { + //if (WMPulses != null) { for (int i = 0; i < WMPulses.Length; i++) WMPulses[i] = 0; } + //if (WMRefPulses != null) { for (int i = 0; i < WMRefPulses.Length; i++) WMPulses[i] = 0; } + + for (int i = 0; i < Program.WMsCount; i++) + { + WMPulses[i] = 0; + WMPulses[i] = 0; + WMVolumes[i].Clear(); + WMErrors[i].Clear(); + } + refCount.Clear(); refFreq.Clear(); refFlow.Clear(); mass.Clear(); startMass.Clear(); endMass.Clear(); - } /// @@ -438,8 +458,7 @@ namespace TBF.BenchControl.Sequences /// Current test time in [s] /// Current progress 0 .. 1.0f /// Data for the UI - protected TestProgressEventArgs GetTestProgressData(Entities.Test test, Entities.TestResult tstRslt, - int currentRefPulses, float time, float progress) + protected TestProgressEventArgs GetTestProgressData(Entities.Test test, Entities.TestResult tstRslt, Elde.ControlBoardDev cBrd, float time, float progress) { TestProgressEventArgs data = new TestProgressEventArgs(); @@ -448,25 +467,30 @@ namespace TBF.BenchControl.Sequences //float ltrPerRefPulse = outPath.FlowMeter.NominalFlow / 7200.0f; /// [ltr/pulse] float refPulsesPerLtr = 7200.0f / outPath.FlowMeter.NominalFlow; /// [pulse/ltr] - data.RefPulses = currentRefPulses; - data.Flow = refFlow.Val; - data.Volume = Formulas.VolumeFromPulses(currentRefPulses, refPulsesPerLtr); + data.RefPulses = cBrd.EtPulses(0); + + refFreq.Val = cBrd.ReferenceFreq; + data.FlowMtrFreq = refFreq; + + data.Flow = refFlow; + data.Volume = new FloatBox() { Name = "Volume", Format = "F1", Val = Formulas.VolumeFromPulses(data.RefPulses, refPulsesPerLtr) }; data.Time = time; - data.Mass = mass.Val; + data.StartMass = startMass; + data.Mass = mass; data.Progress = progress; float estCurrentTime = TimeEstimateBeginRpts + ((float)(tstRslt.RepetitionNr - 1) + progress) * TimeEstimateOneTest; data.OveralProgress = estCurrentTime / TimeEstimateTotal; - data.Tin = tempIn.Val; - data.Tout = tempOut.Val; - data.Tdiv = tempDiv.Val; - data.Pin = pressIn.Val; - data.Pout = pressOut.Val; + data.Tin = tempIn; + data.Tout = tempOut; + data.Tdiv = tempDiv; + data.Pin = pressIn; + data.Pout = pressOut; - data.AmbientTemp = airTemperature.Val; - data.AmbientPressure = airPressure.Val; - data.AmbientHumidity = airHumidity.Val; + data.AmbientTemp = airTemperature; + data.AmbientPressure = airPressure; + data.AmbientHumidity = airHumidity; for (int i = 0; i < Program.WMsCount; i++) { @@ -475,7 +499,7 @@ namespace TBF.BenchControl.Sequences data.WmPulses[i] = WMPulses[i]; data.WmRefPulses[i] = WMRefPulses[i]; data.WmVolume[i] = Formulas.VolumeFromPulses(WMPulses[i], sensPath.RegisterReaders[i].PulsesPerLtr); - data.WmErrPct[i] = Formulas.ErrorFromVolumes(data.WmVolume[i], data.Volume); + if (data.Volume.Valid) { data.WmErrPct[i] = Formulas.ErrorFromVolumes(data.WmVolume[i], data.Volume.Val); } } } diff --git a/TestBenchFramework/BenchControl/StateMachine.cs b/TestBenchFramework/BenchControl/StateMachine.cs index ea23d882b..e1cdce5f7 100644 --- a/TestBenchFramework/BenchControl/StateMachine.cs +++ b/TestBenchFramework/BenchControl/StateMachine.cs @@ -108,7 +108,7 @@ namespace TBF.BenchControl /// /// Current state name /// - public static int CurrentTime { get { return currentTimeSec; } } + public static int Time { get { return currentTimeSec; } } /// /// Constructor diff --git a/TestBenchFramework/BenchControl/TestMethods/CameraRoiDetection/RoiDetectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CameraRoiDetection/RoiDetectionSeq.cs index 4db4ff6ed..96352c865 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CameraRoiDetection/RoiDetectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/CameraRoiDetection/RoiDetectionSeq.cs @@ -104,7 +104,7 @@ namespace TBF.BenchControl.TestMethods.CameraRoiDetection while (!e.Contains(Event.FlowReached)); flow_set: - int time = StateMachine.CurrentTime; + int time = StateMachine.Time; float currentFlow = refFlow.Val; //------------------------------------------------ diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs index 98ad99590..db95eec2d 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs @@ -124,6 +124,9 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters set_flow: + int flowSetTime0 = StateMachine.Time; + float estFlowSetTime = 10.0f; + //------------------------------------------------ Bridge.OnActivity(this, Strings.Setting_the_flow); //------------------------------------------------ @@ -135,6 +138,11 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters do { e = StateMachine.WaitRunDevsRunOps(); + + int flowSetTime = StateMachine.Time - flowSetTime0; + float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime); + Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, flowSetTime, progress)); + if (e.Contains(Event.UiCmdStop)) goto stop; } while (!e.Contains(Event.ValvesSet)); @@ -147,12 +155,17 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters do { e = StateMachine.WaitRunDevsRunOps(); + + int flowSetTime = StateMachine.Time - flowSetTime0; + float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime); + Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, flowSetTime, progress)); + if (e.Contains(Event.UiCmdStop)) goto stop; if (e.Contains(Event.RegulValveTimeOut)) goto error; } while (!e.Contains(Event.FlowReached)); - int time = StateMachine.CurrentTime; + int time = StateMachine.Time; float currentFlow = refFlow.Val; /// Extract cameras from the current sensors path, add operations to the detection state @@ -238,6 +251,8 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters AccumulateAveragedData(); + refFreq.Val = cBrd.ReferenceFreq; + refFlow.Val = cBrd.ReferenceFlow; string logstr = string.Format("E={0} f={1} q={2}", cBrd.EtPulses(0), cBrd.ReferenceFreq, cBrd.ReferenceFlow * outPath.FlowMeter.NominalFlow); @@ -247,11 +262,10 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters } log.Info(logstr); - - float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, 10.0f, test.TstTime); - TestProgressEventArgs data = GetTestProgressData(test, tstRslt, cBrd.EtPulses(0), cBrd.TTime, progress); + float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime); + TestProgressEventArgs data = GetTestProgressData(test, tstRslt, cBrd, cBrd.TTime, progress); data.WmVolume[2] = data.WmVolume[0] + data.WmVolume[1]; - data.WmErrPct[2] = Formulas.ErrorFromVolumes(data.WmVolume[2], data.Volume); + if (data.Volume.Valid) { data.WmErrPct[2] = Formulas.ErrorFromVolumes(data.WmVolume[2], data.Volume.Val); } Bridge.OnTestProgress(this, data); } /// Measurement loop - end diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetTestParams.cs b/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetTestParams.cs index 24f1c776d..b0f0bb76f 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetTestParams.cs +++ b/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetTestParams.cs @@ -14,6 +14,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection public float RelativeQto; /// Tested flow high range related to the detected flow public float RateOfChange; /// Each step is calculated as (TargetQfrom - Qfrom) * RateOfChange, text form is displayed in % (*100) public float DetectionThreshold;/// Drop of frequency for the detection, text form is displayed in % (*100) + public int SupressTrills; string[] paramNames = new string[] { @@ -22,6 +23,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection Strings.RelativeQto, Strings.RateOfChangePct, Strings.DetectionThresholdPct, + Strings.SupressWMTrills, }; public string ParamName(int i) { return paramNames[i]; } @@ -34,6 +36,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection case 2: return RelativeQto.ToString(); case 3: return (100.0f * RateOfChange).ToString(); case 4: return (100.0f * DetectionThreshold).ToString(); + case 5: return SupressTrills.ToString(); default: return string.Empty; } } @@ -47,6 +50,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection case 2: RelativeQto = Utils.ParseSFloat(strValue); return; case 3: RateOfChange = Utils.ParseUFloat(strValue) / 100.0f; return; case 4: DetectionThreshold = Utils.ParseUFloat(strValue) / 100.0f; return; + case 5: SupressTrills = int.Parse(strValue); return; default: return; } } @@ -56,6 +60,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection message = string.Empty; float dummy; + int idummy; switch (i) { case 0: @@ -67,6 +72,9 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection case 2: if (Utils.TryParseSFloat(strValue, out dummy)) return true; break; + case 5: + if (int.TryParse(strValue, out idummy)) return true; + break; default: message = "Invalid index"; return false; diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs index 90f8934a1..3a3873b78 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs @@ -125,6 +125,9 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection switching_flow_detection: + int flowSetTime0 = StateMachine.Time; + float estFlowSetTime = 100.0f; + /// Extract cameras from the current sensors path, add operations to the detection state IList measureOperations = new List(); for (int i = 0; i < sensPath.RegisterReaders.Length; i++) @@ -145,6 +148,11 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection do { e = StateMachine.WaitRunDevsRunOps(); + + int flowSetTime = StateMachine.Time - flowSetTime0; + float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime); + Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, flowSetTime, progress)); + if (e.Contains(Event.UiCmdStop)) goto stop; } while (!e.Contains(Event.ValvesSet)); @@ -158,6 +166,11 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection do { e = StateMachine.WaitRunDevsRunOps(); + + int flowSetTime = StateMachine.Time - flowSetTime0; + float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime); + Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, flowSetTime, progress)); + if (e.Contains(Event.UiCmdStop)) goto stop; if (e.Contains(Event.RegulValveTimeOut)) goto error; } @@ -181,8 +194,8 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection /// Current values flowsForDetection[0] = refFlow.Val; pulseFreqsForDetection[0] = 0.0f; - int startTime = StateMachine.CurrentTime; - int lastTime = StateMachine.CurrentTime; + int startTime = StateMachine.Time; + int lastTime = StateMachine.Time; /// Detection parameters float rvPulse = (testParams.TargetQ > (test.Qfrom + test.Qto) / 2.0f) ? 0.05f : -0.05f; // rise or fall? @@ -203,6 +216,11 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection do { e = StateMachine.WaitRunDevsRunOps(); + + int flowSetTime = StateMachine.Time - flowSetTime0; + float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime); + Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, flowSetTime, progress)); + if (e.Contains(Event.UiCmdStop)) goto stop; } while (!e.Contains(Event.PositionReached)); @@ -223,11 +241,11 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection case Event.UiCmdStop: goto stop; } - int time = StateMachine.CurrentTime; + int time = StateMachine.Time; int diff = WMPulses[1] - lastWMPulses[1]; flowsForDetection[0] = cBrd.ReferenceFreq * outPath.FlowMeter.NominalFlow / 2000.0f; pulseFreqsForDetection[0] = (float)diff / (float)(time - lastTime); - lastTime = StateMachine.CurrentTime; + lastTime = StateMachine.Time; if ((flowsForDetection[0] > 0) && (flowsForDetection[DetectionBufferSize - 1] > 0)) { @@ -313,20 +331,31 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection float Qave_lps = (qfrom_test + qto_test) / 7.2f; tstRslt.TstTime = tstRslt.Volume / Qave_lps; + float relativeQave = (testParams.RelativeQfrom + testParams.RelativeQto) / 2.0f; + bool goBackToInitFlow = ((rvPulse > 0) && (relativeQave < 0)) || + ((rvPulse < 0) && (relativeQave > 0)); - //-------------------------------- - State.Create("CombinedWithDetection : Switching flow detected, going back") - .AddOperation(checkUiOp) - .AddOperations(measureOperations) - .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, refFlow, 600)) /// timeout = 10 min. - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.UiCmdStop)) goto stop; - if (e.Contains(Event.RegulValveTimeOut)) goto error; - } - while (!e.Contains(Event.FlowReached)); + if (goBackToInitFlow) + { + //-------------------------------- + State.Create("CombinedWithDetection : Switching flow detected, going back") + .AddOperation(checkUiOp) + .AddOperations(measureOperations) + .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, refFlow, 600)) /// timeout = 10 min. + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + + int flowSetTime = StateMachine.Time - flowSetTime0; + float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime); + Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, flowSetTime, progress)); + + if (e.Contains(Event.UiCmdStop)) goto stop; + if (e.Contains(Event.RegulValveTimeOut)) goto error; + } + while (!e.Contains(Event.FlowReached)); + } //-------------------------------- State.Create("CombinedWithDetection : Going to the test flow") @@ -339,6 +368,11 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection do { e = StateMachine.WaitRunDevsRunOps(); + + int flowSetTime = StateMachine.Time - flowSetTime0; + float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime); + Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, flowSetTime, progress)); + if (e.Contains(Event.UiCmdStop)) goto stop; //if (e.Contains(Event.FlowTimeOut)) goto do_detection; } @@ -432,10 +466,10 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection log.Info(logstr); - float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, 10.0f, test.TstTime); - TestProgressEventArgs data = GetTestProgressData(test, tstRslt, cBrd.EtPulses(0), cBrd.TTime, progress); + float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime); + TestProgressEventArgs data = GetTestProgressData(test, tstRslt, cBrd, cBrd.TTime, progress); data.WmVolume[2] = data.WmVolume[0] + data.WmVolume[1]; - data.WmErrPct[2] = Formulas.ErrorFromVolumes(data.WmVolume[2], data.Volume); + if (data.Volume.Valid) { data.WmErrPct[2] = Formulas.ErrorFromVolumes(data.WmVolume[2], data.Volume.Val); } Bridge.OnTestProgress(this, data); } /// Measurement loop - end @@ -490,6 +524,15 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection } while (!e.Contains(Event.PreviousStopped)); + /// + /// Optionally supress pulses from the large water meter + /// + if (testParams.SupressTrills > 0) + { + WMPulses[0] = 0; + tstRslt.Meters[0].PulsesMeter = 0; + } + /// /// Populate TestRasult data entity with data /// diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs index 0ed4a5192..19a41b81b 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs @@ -115,6 +115,9 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod set_flow: + int flowSetTime0 = StateMachine.Time; + float estFlowSetTime = 10.0f; + //------------------------------------------------ Bridge.OnActivity(this, Strings.Setting_the_flow); //------------------------------------------------ @@ -126,6 +129,11 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod do { e = StateMachine.WaitRunDevsRunOps(); + + int flowSetTime = StateMachine.Time - flowSetTime0; + float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime); + Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, flowSetTime, progress)); + if (e.Contains(Event.UiCmdStop)) goto stop; } while (!e.Contains(Event.ValvesSet)); @@ -138,6 +146,11 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod do { e = StateMachine.WaitRunDevsRunOps(); + + int flowSetTime = StateMachine.Time - flowSetTime0; + float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime); + Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, flowSetTime, progress)); + if (e.Contains(Event.UiCmdStop)) goto stop; if (e.Contains(Event.RegulValveTimeOut)) goto error; if (e.Contains(Event.Next)) goto flow_set; @@ -145,7 +158,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod while (!e.Contains(Event.FlowReached)); flow_set: - int time = StateMachine.CurrentTime; + int time = StateMachine.Time; float currentFlow = refFlow.Val; /// Extract cameras from the current sensors path, add operations to the detection state @@ -245,8 +258,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod log.Info(logstr); - float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, 10.0f, test.TstTime); - Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd.EtPulses(0), cBrd.TTime, progress)); + float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime); + Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, cBrd.TTime, progress)); } /// Measurement loop - end diff --git a/TestBenchFramework/Resources/Strings.Designer.cs b/TestBenchFramework/Resources/Strings.Designer.cs index addc52895..03079fe94 100644 --- a/TestBenchFramework/Resources/Strings.Designer.cs +++ b/TestBenchFramework/Resources/Strings.Designer.cs @@ -1635,6 +1635,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Supress WM trills. + /// + internal static string SupressWMTrills { + get { + return ResourceManager.GetString("SupressWMTrills", resourceCulture); + } + } + /// /// Looks up a localized string similar to Switching flow detection. /// diff --git a/TestBenchFramework/Resources/Strings.de.resx b/TestBenchFramework/Resources/Strings.de.resx index 1a8b3aaeb..5b28f10cb 100644 --- a/TestBenchFramework/Resources/Strings.de.resx +++ b/TestBenchFramework/Resources/Strings.de.resx @@ -750,4 +750,7 @@ Volumen und Fehlergrenzen + + Supress trills + \ No newline at end of file diff --git a/TestBenchFramework/Resources/Strings.resx b/TestBenchFramework/Resources/Strings.resx index 1cdf7db64..4c9e2d43d 100644 --- a/TestBenchFramework/Resources/Strings.resx +++ b/TestBenchFramework/Resources/Strings.resx @@ -811,4 +811,7 @@ Selected results: + + Supress WM trills + \ No newline at end of file diff --git a/TestBenchFramework/Screens/MeasurementTabPageCtrl.cs b/TestBenchFramework/Screens/MeasurementTabPageCtrl.cs index 603a28c97..30e9783d9 100644 --- a/TestBenchFramework/Screens/MeasurementTabPageCtrl.cs +++ b/TestBenchFramework/Screens/MeasurementTabPageCtrl.cs @@ -157,16 +157,16 @@ namespace TBF.Screens measurementTbl2Col2.SetData(0, data.RefPulses); measurementTbl2Col2.SetData(1, data.Time.ToString("F1")); - measurementTbl2Col2.SetData(3, data.Tin.ToString("F2")); - measurementTbl2Col2.SetData(4, data.Tout.ToString("F2")); - measurementTbl2Col2.SetData(5, data.Tdiv.ToString("F2")); - measurementTbl2Col2.SetData(6, data.Pin); - measurementTbl2Col2.SetData(7, data.Pout); - measurementTbl2Col2.SetData(8, data.Flow.ToString("F3")); + measurementTbl2Col2.SetData(3, data.Tin.ToString()); + measurementTbl2Col2.SetData(4, data.Tout.ToString()); + measurementTbl2Col2.SetData(5, data.Tdiv.ToString()); + measurementTbl2Col2.SetData(6, data.Pin.ToString()); + measurementTbl2Col2.SetData(7, data.Pout.ToString()); + measurementTbl2Col2.SetData(8, data.Flow.ToString()); - measurementTbl3Row2.SetData(0, data.AmbientTemp); - measurementTbl3Row2.SetData(1, data.AmbientPressure); - measurementTbl3Row2.SetData(2, data.AmbientHumidity); + measurementTbl3Row2.SetData(0, data.AmbientTemp.ToString()); + measurementTbl3Row2.SetData(1, data.AmbientPressure.ToString()); + measurementTbl3Row2.SetData(2, data.AmbientHumidity.ToString()); //measurementBar1.FValue = data.Progress; } diff --git a/TestBenchFramework/Screens/ProcessTabPageCtrl.cs b/TestBenchFramework/Screens/ProcessTabPageCtrl.cs index b3fb720ac..48f0b0930 100644 --- a/TestBenchFramework/Screens/ProcessTabPageCtrl.cs +++ b/TestBenchFramework/Screens/ProcessTabPageCtrl.cs @@ -168,17 +168,17 @@ namespace TBF.Screens void OnTestProgress(object sender, TestProgressEventArgs args) { /// Top part - airTempLabel.Text = args.AmbientTemp.ToString("F1"); - airPressLabel.Text = args.AmbientPressure.ToString("F1"); - airHumiLabel.Text = args.AmbientHumidity.ToString("F1"); + airTempLabel.Text = args.AmbientTemp.ToString(); + airPressLabel.Text = args.AmbientPressure.ToString(); + airHumiLabel.Text = args.AmbientHumidity.ToString(); refPulsesLabel.Text = args.RefPulses.ToString(); - refFreqLabel.Text = args.FlowMtrFreq.ToString("F1"); - refFlowLabel.Text = args.Flow.ToString("F2"); - refVolumeLabel.Text = args.Volume.ToString("F2"); + refFreqLabel.Text = args.FlowMtrFreq.ToString(); + refFlowLabel.Text = args.Flow.ToString(); + refVolumeLabel.Text = args.Volume.ToString(); - regValvePosLabel.Text = args.RegValvePos.ToString("F1"); - tDivLabel.Text = args.Tdiv.ToString("F2"); + //regValvePosLabel.Text = args.RegValvePos.ToString(); + tDivLabel.Text = args.Tdiv.ToString(); /// Bottom part pulses1Label.Text = args.WmPulses[0].ToString(); @@ -187,20 +187,24 @@ namespace TBF.Screens refPulses1Label.Text = args.WmRefPulses[0].ToString(); refPulses2Label.Text = args.WmRefPulses[1].ToString(); refPulses3Label.Text = args.WmRefPulses[2].ToString(); - volume1Label.Text = args.WmVolume[0].ToString("F2"); - volume2Label.Text = args.WmVolume[1].ToString("F2"); - volume3Label.Text = args.WmVolume[2].ToString("F2"); - error1Label.Text = args.WmErrPct[0].ToString("F2"); - error2Label.Text = args.WmErrPct[1].ToString("F2"); - error3Label.Text = args.WmErrPct[2].ToString("F2"); + volume1Label.Text = args.WmVolume[0].ToString(); + volume2Label.Text = args.WmVolume[1].ToString(); + volume3Label.Text = args.WmVolume[2].ToString(); + error1Label.Text = args.WmErrPct[0].ToString(); + error2Label.Text = args.WmErrPct[1].ToString(); + error3Label.Text = args.WmErrPct[2].ToString(); - tInLabel.Text = args.Tin.ToString("F2"); - tOutLabel.Text = args.Tout.ToString("F2"); - prInLabel.Text = args.Pin.ToString("F1"); - prOutLabel.Text = args.Pout.ToString("F1"); + tInLabel.Text = args.Tin.ToString(); + tOutLabel.Text = args.Tout.ToString(); + prInLabel.Text = args.Pin.ToString(); + prOutLabel.Text = args.Pout.ToString(); - massLabel.Text = args.Mass.ToString("F1"); - massDiffLabel.Text = (args.Mass - args.TestResult.MassStartRaw).ToString("F1"); + massLabel.Text = args.Mass.ToString(); + + if (args.Mass.Valid && args.StartMass.Valid) + { + massDiffLabel.Text = (args.Mass.Val - args.StartMass.Val).ToString(args.Mass.Format); + } } void OnTestCompleted(object sender, TestCompletedEventArgs args) @@ -232,7 +236,7 @@ namespace TBF.Screens refPulsesLabel.Text = tRes.PulsesMaster.ToString("F0"); //refFreqLabel.Text = tstRslt. - refFlowLabel.Text = tRes.FlowMass.ToString("F2"); + refFlowLabel.Text = (tRes.FlowMass / 1000.0f).ToString("F2"); refVolumeLabel.Text = tRes.VolumeCTV.ToString("F2"); //regValvePosLabel.Text = tstRslt. //massLabel.Text = tstRslt. diff --git a/TestBenchFramework/UiBridge/TestProgressEventArgs.cs b/TestBenchFramework/UiBridge/TestProgressEventArgs.cs index 8f3509400..3cbc06565 100644 --- a/TestBenchFramework/UiBridge/TestProgressEventArgs.cs +++ b/TestBenchFramework/UiBridge/TestProgressEventArgs.cs @@ -1,4 +1,5 @@ using System; +using TBF.Boxes; namespace TBF.UiBridge { @@ -8,21 +9,22 @@ namespace TBF.UiBridge public float OveralProgress; public int RefPulses; - public float RegValvePos; - public float FlowMtrFreq; - public float Flow; - public float Volume; + public FloatBox RegValvePos; + public FloatBox FlowMtrFreq; + public FloatBox Flow; + public FloatBox Volume; public float Time; - public float Mass; + public FloatBox Mass; + public FloatBox StartMass; - public float Tin; - public float Tout; - public float Tdiv; - public float Pin; - public float Pout; - public float AmbientTemp; - public float AmbientPressure; - public float AmbientHumidity; + public FloatBox Tin; + public FloatBox Tout; + public FloatBox Tdiv; + public FloatBox Pin; + public FloatBox Pout; + public FloatBox AmbientTemp; + public FloatBox AmbientPressure; + public FloatBox AmbientHumidity; public int[] WmPulses = new int[Program.WMsCount]; public int[] WmRefPulses = new int[Program.WMsCount];