From 0f7790e5384c74702ddbf979ead902a818999918 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Mon, 22 Aug 2016 16:00:48 +0200 Subject: [PATCH] Prompt message box at the beginning of each heat meters test. --- .../FixedStartMassCollectionSeq.cs | 1011 +++++++++-------- .../HeatMeters/TestParams.cs | 10 +- .../Resources/Strings.Designer.cs | 9 + TestBenchFramework/Resources/Strings.resx | 3 + 4 files changed, 530 insertions(+), 503 deletions(-) diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs index b0e9befec..a7b219d15 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs @@ -27,8 +27,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection /// Event.Error . . . . . . Unspecified error /// public IList Execute(Config.Entities.Test test, bool compound, HeatMeters.TestParams heatMetersTestParams) - { - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; + { + Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; IList e = new List(); /// Events from currently running operations Event retVal = Event.Done; @@ -40,89 +40,104 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection /// 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); + int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f); processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this); float[] wmBeginStates = new float[Config.Data.WMsCount]; float[] wmEndStates = new float[Config.Data.WMsCount]; - + int repetitionNr = 1; /// First test: repetitionNr=1 - //==================================== - // Transition or SetRoute - Start - //==================================== - switch (Transition(transitionBefore, TransitionContext.BeforeTest)) - { - case Event.Error: { retVal = Event.Error; goto stopTest; } - case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } - } + //==================================== + // Transition or SetRoute - Start + //==================================== + switch (Transition(transitionBefore, TransitionContext.BeforeTest)) + { + case Event.Error: { retVal = Event.Error; goto stopTest; } + case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } + } - //==================================== + //==================================== loop: - /// Start the test, initialize test results - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, totalPulses)); - string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); - TestStartTime = DateTime.Now; - TestProgressEventArgs.SetEstimatedTimes(new int[] { 1, 1, 1, 30, Convert.ToInt32(test.TstTime) + 15, 0, 0 }); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.JustStarted)); + /// Start the test, initialize test results + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, totalPulses)); + string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); + TestStartTime = DateTime.Now; + TestProgressEventArgs.SetEstimatedTimes(new int[] { 1, 1, 1, 30, Convert.ToInt32(test.TstTime) + 15, 0, 0 }); + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.JustStarted)); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - int flowSetTime0 = StateMachine.Time; + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); + int flowSetTime0 = StateMachine.Time; - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Setting_the_flow); - //------------------------------------------------ - if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower); + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Setting_the_flow); + //------------------------------------------------ + if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower); - State.Create("FixedStartMassCollection : Starting the pump") - .AddOperation(checkUiOp) - .AddOperation(new Operations.TimerOp(5)) - .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)); + State.Create("FixedStartMassCollection : Starting the pump") + .AddOperation(checkUiOp) + .AddOperation(new Operations.TimerOp(5)) + .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 (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.TimerExpired)); - State.Create("FixedStartMassCollection : Starting the pump") - .AddOperation(checkUiOp) - .AddOperation(cBrd.SetValvesOp(inPath.Pump, 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)); + State.Create("FixedStartMassCollection : Starting the pump") + .AddOperation(checkUiOp) + .AddOperation(cBrd.SetValvesOp(inPath.Pump, 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; } - } - while (!e.Contains(Event.ValvesSet)); + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.ValvesSet)); + + + if (heatMetersTestParams != null && !string.IsNullOrEmpty(heatMetersTestParams.Prompt)) + { + State.Create("FixedStartMassCollection : Show heat meters prompt (exchange temperature meters)") + .AddOperation(checkUiOp) + .AddOperation(new Operations.MessageBoxOp(heatMetersTestParams.Prompt)) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.OK)); + } if (!test.Emptying) /// If condition met => skip measuring and force emptying { - /// + /// /// Measure the weight and skip emptying if there is enough room in the tank - /// - State.Create("FixedStartMassCollection : Measuring the mass of water in the tank") + /// + State.Create("FixedStartMassCollection : Measuring the mass of water in the tank") .AddOperation(checkUiOp) .AddOperation(outPath.Balance.ReadMassOp(ref Mass)) .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.Error)) { retVal = Event.Error; goto stopTest; } - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } + 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.Error)) { retVal = Event.Error; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } } while (!e.Contains(Event.BalanceDone)); @@ -133,127 +148,127 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection } } - /// - /// Empty the water tank - /// - switch (EmptyTheTank(outPath.EmptyTankValve, outPath.Balance)) - { - case Event.Error: { retVal = Event.Error; goto stopTest; } - case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } - } + /// + /// Empty the water tank + /// + switch (EmptyTheTank(outPath.EmptyTankValve, outPath.Balance)) + { + case Event.Error: { retVal = Event.Error; goto stopTest; } + case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } + } set_flow: //------------------------------------------------ Bridge.OnActivity(this, Strings.Setting_the_flow); //------------------------------------------------ - if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower); - State.Create("FixedStartMassCollection : Starting the pump") + if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower); + State.Create("FixedStartMassCollection : Starting the pump") .AddOperation(checkUiOp) - .AddOperation(cBrd.SetValvesOp(inPath.Pump, null)) + .AddOperation(cBrd.SetValvesOp(inPath.Pump, 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)); + 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 (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } } while (!e.Contains(Event.ValvesSet)); //-------------------------------- - State.Create("FixedStartMassCollection : Setting the flow") - .AddOperation(checkUiOp) - .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, outPath.PidCoef, RefFlow, 600)) /// timeout = 10 min. - .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)); + State.Create("FixedStartMassCollection : Setting the flow") + .AddOperation(checkUiOp) + .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, outPath.PidCoef, RefFlow, 600)) /// timeout = 10 min. + .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.Timeout); - retVal = Event.Done; - goto stopTest; - } - if (e.Contains(Event.Next)) goto flow_set; - } - while (!e.Contains(Event.FlowReached)); + 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.Timeout); + retVal = Event.Done; + goto stopTest; + } + if (e.Contains(Event.Next)) goto flow_set; + } + while (!e.Contains(Event.FlowReached)); flow_set: - int flowSetTime = StateMachine.Time - flowSetTime0; + int flowSetTime = StateMachine.Time - flowSetTime0; - if (heatMetersTestParams != null && heatMetersPath != null) - { - //--------------------------------------------------- - Bridge.OnActivity(this, Strings.Setting_temperature); - //--------------------------------------------------- + if (heatMetersTestParams != null && heatMetersPath != null) + { + //--------------------------------------------------- + Bridge.OnActivity(this, Strings.Setting_temperature); + //--------------------------------------------------- - int lastTimeSec = StateMachine.Time; - float Tw_last = 0; - float Tc_last = 0; - FloatBox Tw1 = new FloatBox(); - FloatBox Tw2 = new FloatBox(); - FloatBox Tc1 = new FloatBox(); - FloatBox Tc2 = new FloatBox(); + int lastTimeSec = StateMachine.Time; + float Tw_last = 0; + float Tc_last = 0; + FloatBox Tw1 = new FloatBox(); + FloatBox Tw2 = new FloatBox(); + FloatBox Tc1 = new FloatBox(); + FloatBox Tc2 = new FloatBox(); - State.Create("FixedStartMassCollection : Check temperature stabilized.") - .AddOperation(checkUiOp) - .AddOperation(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref Tw1)) - .AddOperation(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref Tw2)) - .AddOperation(heatMetersPath.TMeterRefCold1.ReadTempOp(ref Tc1)) - .AddOperation(heatMetersPath.TMeterRefCold2.ReadTempOp(ref Tc2)) - .EnterState(); - do - { + State.Create("FixedStartMassCollection : Check temperature stabilized.") + .AddOperation(checkUiOp) + .AddOperation(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref Tw1)) + .AddOperation(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref Tw2)) + .AddOperation(heatMetersPath.TMeterRefCold1.ReadTempOp(ref Tc1)) + .AddOperation(heatMetersPath.TMeterRefCold2.ReadTempOp(ref Tc2)) + .EnterState(); + do + { e = StateMachine.WaitRunDevsRunOps(); if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } - if (e.Contains(Event.Next)) goto temperature_set; + if (e.Contains(Event.Next)) goto temperature_set; - if (StateMachine.Time - lastTimeSec > 10 || StateMachine.Time - lastTimeSec < 0) - { - float Tw = (Tw1.Val + Tw2.Val) / 2.0f; - float Tc = (Tc1.Val + Tc2.Val) / 2.0f; - if (heatMetersTestParams.TempWarmLo <= Tw && Tw <= heatMetersTestParams.TempWarmHi && - heatMetersTestParams.TempColdLo <= Tc && Tc <= heatMetersTestParams.TempColdHi && - Math.Abs(Tw - Tw_last) <= heatMetersTestParams.ChangeInTimeWarm && - Math.Abs(Tc - Tc_last) <= heatMetersTestParams.ChangeInTimeCold && - Math.Abs(Tw1.Val - Tw2.Val) <= heatMetersTestParams.DeltaTempWarm && - Math.Abs(Tc1.Val - Tc2.Val) <= heatMetersTestParams.DeltaTempCold) - { - goto temperature_set; - } + if (StateMachine.Time - lastTimeSec > 10 || StateMachine.Time - lastTimeSec < 0) + { + float Tw = (Tw1.Val + Tw2.Val) / 2.0f; + float Tc = (Tc1.Val + Tc2.Val) / 2.0f; + if (heatMetersTestParams.TempWarmLo <= Tw && Tw <= heatMetersTestParams.TempWarmHi && + heatMetersTestParams.TempColdLo <= Tc && Tc <= heatMetersTestParams.TempColdHi && + Math.Abs(Tw - Tw_last) <= heatMetersTestParams.ChangeInTimeWarm && + Math.Abs(Tc - Tc_last) <= heatMetersTestParams.ChangeInTimeCold && + Math.Abs(Tw1.Val - Tw2.Val) <= heatMetersTestParams.DeltaTempWarm && + Math.Abs(Tc1.Val - Tc2.Val) <= heatMetersTestParams.DeltaTempCold) + { + goto temperature_set; + } - lastTimeSec = StateMachine.Time; - Tw_last = Tw; - Tc_last = Tc; - } - } - while (true); - } + lastTimeSec = StateMachine.Time; + Tw_last = Tw; + Tc_last = Tc; + } + } + while (true); + } - temperature_set: + temperature_set: //------------------------------------------------ Bridge.OnActivity(this, Strings.Stopping_flow_for_the_fixed_start); //------------------------------------------------ State.Create("FixedStartMassCollection : Closing the start/stop valve before the fixed start test") .AddOperation(checkUiOp) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, outPath.StartValve)) - .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); + .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, outPath.StartValve)) + .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) + .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)); int time = StateMachine.Time; @@ -272,11 +287,11 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection /// /// Enter watermeter begin states here /// - GenericDevices.IHasWMStatesForm dataEntryCmpnt = - TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IHasWMStatesForm; + GenericDevices.IHasWMStatesForm dataEntryCmpnt = + TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IHasWMStatesForm; if (dataEntryCmpnt != null) { - Bridge.OnActivity(this, Strings.Enter_water_meter_data); + Bridge.OnActivity(this, Strings.Enter_water_meter_data); State.Create("FixedStartMassCollection : Enter begin-state") .AddOperation((dataEntryCmpnt as GenericDevices.IHasWMStatesForm).ShowTestStartFormOp()) .AddOperation(checkUiOp) @@ -284,16 +299,16 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection do { e = StateMachine.WaitRunDevsRunOps(); - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } } while (!e.Contains(Event.ModelessFormClosed)); for (int i = 0; i < Config.Data.WMsCount; i++) { - BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader = + BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader = sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; - if (registerReader != null) registerReader.BeginWMState = dataEntryCmpnt.WMStartState(i); + if (registerReader != null) registerReader.BeginWMState = dataEntryCmpnt.WMStartState(i); } } @@ -301,8 +316,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection //------------------------------------------------ Bridge.OnActivity(this, Strings.Measuring_the_weight); //------------------------------------------------ - State.Create("FixedStartMassCollection : Measuring the start mass") - .AddOperation(checkUiOp) + State.Create("FixedStartMassCollection : Measuring the start mass") + .AddOperation(checkUiOp) .AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn)) .AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut)) .AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv)) @@ -315,32 +330,32 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection .AddOperation(cBrd.UpdateTankWeightOp()) .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.BalanceDone)); + 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.BalanceDone)); Mass.Val = StartMass.Val; //------------------------------------------------ Bridge.OnActivity(this, Strings.Test_in_progress); //------------------------------------------------ - State.Create("FixedStartMassCollection : Starting the test") - .AddOperation(checkUiOp) + State.Create("FixedStartMassCollection : Starting the test") + .AddOperation(checkUiOp) .AddOperations(measureOperations) .AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro, - test.Qfrom, test.Qto, 2 * totalPulses, (float)test.TolerRed)) - .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.MeasurementStarted)); + test.Qfrom, test.Qto, 2 * totalPulses, (float)test.TolerRed)) + .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.MeasurementStarted)); State.Create("FixedStartMassCollection : Opening the start/stop valve at the beginning of the fixed start test") @@ -356,13 +371,13 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection while (!e.Contains(Event.ValvesSet)); - /// Measurement loop - preparation + /// Measurement loop - preparation readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders); queryEnd1 = cBrd.QueryMeasurementEndOp(); - queryEnd2 = cBrd.QueryMeasurementEndOp(); + queryEnd2 = cBrd.QueryMeasurementEndOp(); ClearAllStatistics(); - int estimtdEndTime = StateMachine.Time + (int)test.TstTime; + int estimtdEndTime = StateMachine.Time + (int)test.TstTime; /// Measurement loop - begin do @@ -382,60 +397,60 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection 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)); - } + 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)); + } - RefFreq.Val = cBrd.ReferenceFreq; - RefFlow.Val = cBrd.ReferenceFlow; + RefFreq.Val = cBrd.ReferenceFreq; + RefFlow.Val = cBrd.ReferenceFlow; - UpdateAllStatistics(); - if (heatMetersTestParams != null) - { - if (lastEnergyUpdateTime == 0) - { - lastEnergyUpdateTime = StateMachine.Time; - } - else - { - //double deltaTime = (double)(StateMachine.Time - lastEnergyUpdateTime); - float T_in = (heatMetersPath.TMeterRefWarm1.ReadTemperature() + heatMetersPath.TMeterRefWarm2.ReadTemperature()) / 2; /// [°C] - float T_out = (heatMetersPath.TMeterRefCold1.ReadTemperature() + heatMetersPath.TMeterRefCold2.ReadTemperature()) / 2; /// [°C] - double deltaVolume = LtrPerRefPulse * RefPulsesDelta; /// [l] + UpdateAllStatistics(); + if (heatMetersTestParams != null) + { + if (lastEnergyUpdateTime == 0) + { + lastEnergyUpdateTime = StateMachine.Time; + } + else + { + //double deltaTime = (double)(StateMachine.Time - lastEnergyUpdateTime); + float T_in = (heatMetersPath.TMeterRefWarm1.ReadTemperature() + heatMetersPath.TMeterRefWarm2.ReadTemperature()) / 2; /// [°C] + float T_out = (heatMetersPath.TMeterRefCold1.ReadTemperature() + heatMetersPath.TMeterRefCold2.ReadTemperature()) / 2; /// [°C] + double deltaVolume = LtrPerRefPulse * RefPulsesDelta; /// [l] double deltaEnergy = 0.001 * deltaVolume * (T_in - T_out) * Formulas.HeatCoefficientWater(16, T_in, T_out, heatMetersTestParams.FlowMeasuredAtHiTempPipe); /// [J] = [m3] * [K] * [J/(m3 K)] - Energy.Update(deltaEnergy); - VolumeForEnergy.Update(deltaVolume); - lastEnergyUpdateTime = StateMachine.Time; - } - } + 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); - // } - //} - } + 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)); - } + Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); + } while (cBrd.EtPulses(0) < totalPulses); - /// Measurement loop - end + /// Measurement loop - end test_completed: @@ -452,72 +467,72 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection while (e.Contains(Event.ValvesBusy)); - State.Create("FixedStartMassCollection : Waiting before 2nd mass measurement") - .AddOperation(checkUiOp) - .AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn)) - .AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut)) - .AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv)) - .AddOperation(benchPath.PressIn.ReadPressureOp(ref PressureUp)) - .AddOperation(benchPath.PressOut.ReadPressureOp(ref PressureDown)) - .AddOperation((StateMachine.Ambient != null) - ? StateMachine.Ambient.ReadAmbientOp(AmbientTemp, AmbientPressure, AmbientHumidity) : null) - .AddOperation(outPath.Balance.ReadMassOp(ref Mass)) - .AddOperation(cBrd.UpdateTankWeightOp()) - .AddOperation(processDataLoggingOp) - .AddOperation(new Operations.TimerOp(test.TimeStop2Mass)) - .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)); + State.Create("FixedStartMassCollection : Waiting before 2nd mass measurement") + .AddOperation(checkUiOp) + .AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn)) + .AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut)) + .AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv)) + .AddOperation(benchPath.PressIn.ReadPressureOp(ref PressureUp)) + .AddOperation(benchPath.PressOut.ReadPressureOp(ref PressureDown)) + .AddOperation((StateMachine.Ambient != null) + ? StateMachine.Ambient.ReadAmbientOp(AmbientTemp, AmbientPressure, AmbientHumidity) : null) + .AddOperation(outPath.Balance.ReadMassOp(ref Mass)) + .AddOperation(cBrd.UpdateTankWeightOp()) + .AddOperation(processDataLoggingOp) + .AddOperation(new Operations.TimerOp(test.TimeStop2Mass)) + .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)); - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Measuring_the_weight); - //------------------------------------------------ - State.Create("FixedStartMassCollection : Measuring the end mass") - .AddOperation(checkUiOp) - .AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn)) - .AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut)) - .AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv)) - .AddOperation(benchPath.PressIn.ReadPressureOp(ref PressureUp)) - .AddOperation(benchPath.PressOut.ReadPressureOp(ref PressureDown)) - .AddOperation((StateMachine.Ambient != null) - ? StateMachine.Ambient.ReadAmbientOp(AmbientTemp, AmbientPressure, AmbientHumidity) : null) + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Measuring_the_weight); + //------------------------------------------------ + State.Create("FixedStartMassCollection : Measuring the end mass") + .AddOperation(checkUiOp) + .AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn)) + .AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut)) + .AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv)) + .AddOperation(benchPath.PressIn.ReadPressureOp(ref PressureUp)) + .AddOperation(benchPath.PressOut.ReadPressureOp(ref PressureDown)) + .AddOperation((StateMachine.Ambient != null) + ? StateMachine.Ambient.ReadAmbientOp(AmbientTemp, AmbientPressure, AmbientHumidity) : null) .AddOperation(outPath.Balance.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod)) - .AddOperation(cBrd.UpdateTankWeightOp()) - .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.BalanceDone)); - /// - TestEndTime = DateTime.Now; + .AddOperation(cBrd.UpdateTankWeightOp()) + .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.BalanceDone)); + /// + TestEndTime = DateTime.Now; - State.Create("FixedStartMassCollection : Stopping diverter, gate, etc.") + State.Create("FixedStartMassCollection : Stopping diverter, gate, etc.") .AddOperation(checkUiOp) .AddOperation(cBrd.StopPreviousOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } } while (!e.Contains(Event.PreviousStopped)); - double massStart = Formulas.CorrectedValue(StartMass.Val, outPath.Balance.Corrections); - double massEnd = Formulas.CorrectedValue(EndMass.Val, outPath.Balance.Corrections); - double densityOut = Formulas.WaterDensityFromTemp(TempOutStat.Average); /// [kg/m3] - double volumeCTV = 1001.03 * (massEnd - massStart) / densityOut; + double massStart = Formulas.CorrectedValue(StartMass.Val, outPath.Balance.Corrections); + double massEnd = Formulas.CorrectedValue(EndMass.Val, outPath.Balance.Corrections); + double densityOut = Formulas.WaterDensityFromTemp(TempOutStat.Average); /// [kg/m3] + double volumeCTV = 1001.03 * (massEnd - massStart) / densityOut; double refEnergy = Energy.Sum * volumeCTV / VolumeForEnergy.Sum; /// [J]=[J]*[l]/[l] /// @@ -525,7 +540,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection /// if (dataEntryCmpnt != null) { - Bridge.OnActivity(this, Strings.Enter_water_meter_data); + Bridge.OnActivity(this, Strings.Enter_water_meter_data); State state = State.Create("FixedStartMassCollection : Enter end-state"); if (heatMetersTestParams != null && dataEntryCmpnt is GenericDevices.IHasHeatMtrStatesForm) { @@ -536,282 +551,282 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection else { state.AddOperation(dataEntryCmpnt.ShowTestEndFormOp(volumeCTV, test.ErrLimLo + test.Uncertainty, - test.ErrLimHi - test.Uncertainty)); + test.ErrLimHi - test.Uncertainty)); } state.AddOperation(checkUiOp); state.EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } } while (!e.Contains(Event.ModelessFormClosed)); for (int i = 0; i < Config.Data.WMsCount; i++) { - BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader = + BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader = sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; - if (registerReader != null) registerReader.EndWMState = dataEntryCmpnt.WMEndState(i); + if (registerReader != null) registerReader.EndWMState = dataEntryCmpnt.WMEndState(i); } } - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Test_completed); - //------------------------------------------------ + //------------------------------------------------ + 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; + if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest; - /// - /// Populate TestResult data entity with data - /// - Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part); + /// + /// Populate TestResult data entity with data + /// + Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part); - if (tstRslt != null) - { - /// Auxiliary results - tstRslt.AmbientTempAve = AmbientTempStat.Average; - tstRslt.AmbTempStart = AmbientTempStat.First; - tstRslt.AmbTempEnd = AmbientTempStat.Last; - tstRslt.AmbTempMin = AmbientTempStat.Min; - tstRslt.AmbTempMax = AmbientTempStat.Max; - tstRslt.AmbientPressAve = AmbientPressureStat.Average; - tstRslt.AmbPressStart = AmbientPressureStat.First; - tstRslt.AmbPressEnd = AmbientPressureStat.Last; - tstRslt.AmbPressMin = AmbientPressureStat.Min; - tstRslt.AmbPressMax = AmbientPressureStat.Max; - tstRslt.AmbientHumiAve = AmbientHumidityStat.Average; - tstRslt.AmbHumiStart = AmbientHumidityStat.First; - tstRslt.AmbHumiEnd = AmbientHumidityStat.Last; - tstRslt.AmbHumiMin = AmbientHumidityStat.Min; - tstRslt.AmbHumiMax = AmbientHumidityStat.Max; - tstRslt.PressUpAvrg = PressureUpStat.Average; - tstRslt.PressUpStart = PressureUpStat.First; - tstRslt.PressUpEnd = PressureUpStat.Last; - tstRslt.PressUpMin = PressureUpStat.Min; - tstRslt.PressUpMax = PressureUpStat.Max; - tstRslt.PressDownAvrg = PressureDownStat.Average; - tstRslt.PressDownStart = PressureDownStat.First; - tstRslt.PressDownEnd = PressureDownStat.Last; - tstRslt.PressDownMin = PressureDownStat.Min; - tstRslt.PressDownMax = PressureDownStat.Max; - tstRslt.TempInAvrg = TempInStat.Average; - tstRslt.TempInStart = TempInStat.First; - tstRslt.TempInEnd = TempInStat.Last; - tstRslt.TempInMin = TempInStat.Min; - tstRslt.TempInMax = TempInStat.Max; - tstRslt.TempOutAvrg = TempOutStat.Average; - tstRslt.TempOutStart = TempOutStat.First; - tstRslt.TempOutEnd = TempOutStat.Last; - tstRslt.TempOutMin = TempOutStat.Min; - tstRslt.TempOutMax = TempOutStat.Max; - tstRslt.TempDivAvrg = TempDivStat.Average; - tstRslt.TempDivStart = TempDivStat.First; - tstRslt.TempDivEnd = TempDivStat.Last; - tstRslt.TempDivMin = TempDivStat.Min; - tstRslt.TempDivMax = TempDivStat.Max; - tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3] - tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3] - tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3] + if (tstRslt != null) + { + /// Auxiliary results + tstRslt.AmbientTempAve = AmbientTempStat.Average; + tstRslt.AmbTempStart = AmbientTempStat.First; + tstRslt.AmbTempEnd = AmbientTempStat.Last; + tstRslt.AmbTempMin = AmbientTempStat.Min; + tstRslt.AmbTempMax = AmbientTempStat.Max; + tstRslt.AmbientPressAve = AmbientPressureStat.Average; + tstRslt.AmbPressStart = AmbientPressureStat.First; + tstRslt.AmbPressEnd = AmbientPressureStat.Last; + tstRslt.AmbPressMin = AmbientPressureStat.Min; + tstRslt.AmbPressMax = AmbientPressureStat.Max; + tstRslt.AmbientHumiAve = AmbientHumidityStat.Average; + tstRslt.AmbHumiStart = AmbientHumidityStat.First; + tstRslt.AmbHumiEnd = AmbientHumidityStat.Last; + tstRslt.AmbHumiMin = AmbientHumidityStat.Min; + tstRslt.AmbHumiMax = AmbientHumidityStat.Max; + tstRslt.PressUpAvrg = PressureUpStat.Average; + tstRslt.PressUpStart = PressureUpStat.First; + tstRslt.PressUpEnd = PressureUpStat.Last; + tstRslt.PressUpMin = PressureUpStat.Min; + tstRslt.PressUpMax = PressureUpStat.Max; + tstRslt.PressDownAvrg = PressureDownStat.Average; + tstRslt.PressDownStart = PressureDownStat.First; + tstRslt.PressDownEnd = PressureDownStat.Last; + tstRslt.PressDownMin = PressureDownStat.Min; + tstRslt.PressDownMax = PressureDownStat.Max; + tstRslt.TempInAvrg = TempInStat.Average; + tstRslt.TempInStart = TempInStat.First; + tstRslt.TempInEnd = TempInStat.Last; + tstRslt.TempInMin = TempInStat.Min; + tstRslt.TempInMax = TempInStat.Max; + tstRslt.TempOutAvrg = TempOutStat.Average; + tstRslt.TempOutStart = TempOutStat.First; + tstRslt.TempOutEnd = TempOutStat.Last; + tstRslt.TempOutMin = TempOutStat.Min; + tstRslt.TempOutMax = TempOutStat.Max; + tstRslt.TempDivAvrg = TempDivStat.Average; + tstRslt.TempDivStart = TempDivStat.First; + tstRslt.TempDivEnd = TempDivStat.Last; + tstRslt.TempDivMin = TempDivStat.Min; + tstRslt.TempDivMax = TempDivStat.Max; + tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3] + tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3] + tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3] - /// Main results - tstRslt.StartTime = TestStartTime; - tstRslt.EndTime = TestEndTime; - tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TTime; /// [s] measurement time - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// 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) / tstRslt.TestTime; /// [kg/h] - tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h] - tstRslt.VolumeMaster = LtrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter - tstRslt.VolumeCTV = volumeCTV; /// [l] 1000.0f is because density is in [kg/m3] - tstRslt.ConstMaster = LtrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter - tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV); + /// Main results + tstRslt.StartTime = TestStartTime; + tstRslt.EndTime = TestEndTime; + tstRslt.FlowSetTime = flowSetTime; + tstRslt.TestTime = cBrd.TTime; /// [s] measurement time + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// 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) / tstRslt.TestTime; /// [kg/h] + tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h] + tstRslt.VolumeMaster = LtrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter + tstRslt.VolumeCTV = volumeCTV; /// [l] 1000.0f is because density is in [kg/m3] + tstRslt.ConstMaster = LtrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter + tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV); tstRslt.FlowMin = (tstRslt.VolumeMaster != 0) ? (float)(RefFlowStat.Min * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : RefFlowStat.Min; tstRslt.FlowMax = (tstRslt.VolumeMaster != 0) ? (float)(RefFlowStat.Max * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : RefFlowStat.Max; - if (compound) - { - /// - /// Compound meters - /// - for (int i = 0; i < BatchRslts.WMPositionsCount; i++) - { - if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue; + if (compound) + { + /// + /// Compound meters + /// + for (int i = 0; i < BatchRslts.WMPositionsCount; i++) + { + if (test.Part != 0 && test.Part != 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); + 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; - BenchControl.Elde.FixedStartRegisterReader.RegisterReader regReader = - sensPath.RegisterReaders[2 * i + isAux] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; + for (int isAux = 0; isAux <= 1; isAux++) /// 0=main, 1=aux + { + Results.Entities.MeterTestRslt meterRslt = (isAux == 0) ? mainMeterRslt : auxMeterRslt; + BenchControl.Elde.FixedStartRegisterReader.RegisterReader regReader = + sensPath.RegisterReaders[2 * i + isAux] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; - if (meterRslt != null && regReader != null) - { - meterRslt.PulsesPerLiter = 1.0f; - 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 = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); /// Not used for evaluation - } - } + if (meterRslt != null && regReader != null) + { + meterRslt.PulsesPerLiter = 1.0f; + 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 = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); /// Not used for evaluation + } + } - Results.Entities.MeterTestRslt compoundMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Compound); + 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 = Formulas.ErrorFromVolumes(compoundMeterRslt.VolumeMeter, compoundMeterRslt.VolumeRef); - compoundMeterRslt.Passed = (compoundMeterRslt.Error >= test.ErrLimLo + test.Uncertainty) - && (compoundMeterRslt.Error <= test.ErrLimHi - test.Uncertainty); - mainMeterRslt.Passed = auxMeterRslt.Passed = compoundMeterRslt.Passed; - mainMeterRslt.TestDone = auxMeterRslt.TestDone = compoundMeterRslt.TestDone = true; - } - } - } - else if (heatMetersTestParams != null) - { - tstRslt.RefEnergy = Energy.Sum * tstRslt.VolumeCTV / VolumeForEnergy.Sum; /// [J] = [J] * [l] / [l] + 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 = Formulas.ErrorFromVolumes(compoundMeterRslt.VolumeMeter, compoundMeterRslt.VolumeRef); + compoundMeterRslt.Passed = (compoundMeterRslt.Error >= test.ErrLimLo + test.Uncertainty) + && (compoundMeterRslt.Error <= test.ErrLimHi - test.Uncertainty); + mainMeterRslt.Passed = auxMeterRslt.Passed = compoundMeterRslt.Passed; + mainMeterRslt.TestDone = auxMeterRslt.TestDone = compoundMeterRslt.TestDone = true; + } + } + } + else if (heatMetersTestParams != null) + { + tstRslt.RefEnergy = Energy.Sum * tstRslt.VolumeCTV / VolumeForEnergy.Sum; /// [J]=[J]*[l]/[l] - /// - /// Heat meters - /// - for (int i = 0; i < BatchRslts.WMPositionsCount; i++) - { - if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue; + /// + /// Heat meters + /// + for (int i = 0; i < BatchRslts.WMPositionsCount; i++) + { + if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue; - Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single); - BenchControl.Elde.FixedStartRegisterReader.RegisterReader regReader = - sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; + Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single); + BenchControl.Elde.FixedStartRegisterReader.RegisterReader regReader = + sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; - if (meterRslt != null && regReader != null) - { - meterRslt.PulsesPerLiter = 1.0f; - 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; - if (dataEntryCmpnt is GenericDevices.IHasHeatMtrStatesForm) - { - meterRslt.EnergyStart = (dataEntryCmpnt as GenericDevices.IHasHeatMtrStatesForm).EnergyStartState(i); - meterRslt.EnergyEnd = (dataEntryCmpnt as GenericDevices.IHasHeatMtrStatesForm).EnergyEndState(i); - meterRslt.Energy = meterRslt.EnergyEnd - meterRslt.EnergyStart; - } - meterRslt.RefEnergy = tstRslt.RefEnergy; + if (meterRslt != null && regReader != null) + { + meterRslt.PulsesPerLiter = 1.0f; + 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; + if (dataEntryCmpnt is GenericDevices.IHasHeatMtrStatesForm) + { + meterRslt.EnergyStart = (dataEntryCmpnt as GenericDevices.IHasHeatMtrStatesForm).EnergyStartState(i); + meterRslt.EnergyEnd = (dataEntryCmpnt as GenericDevices.IHasHeatMtrStatesForm).EnergyEndState(i); + meterRslt.Energy = meterRslt.EnergyEnd - meterRslt.EnergyStart; + } + meterRslt.RefEnergy = tstRslt.RefEnergy; - meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.Energy, meterRslt.RefEnergy); - meterRslt.Passed = (meterRslt.Error >= test.ErrLimLo + test.Uncertainty) - && (meterRslt.Error <= test.ErrLimHi - test.Uncertainty); - meterRslt.TestDone = true; - } - } - } - else - { - /// - /// Single meters - /// - for (int i = 0; i < BatchRslts.WMPositionsCount; i++) - { - if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue; + meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.Energy, meterRslt.RefEnergy); + meterRslt.Passed = (meterRslt.Error >= test.ErrLimLo + test.Uncertainty) + && (meterRslt.Error <= test.ErrLimHi - test.Uncertainty); + meterRslt.TestDone = true; + } + } + } + else + { + /// + /// Single meters + /// + for (int i = 0; i < BatchRslts.WMPositionsCount; i++) + { + if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue; - Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single); - BenchControl.Elde.FixedStartRegisterReader.RegisterReader regReader = - sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; + Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single); + BenchControl.Elde.FixedStartRegisterReader.RegisterReader regReader = + sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; - if (meterRslt != null && regReader != null) - { - meterRslt.PulsesPerLiter = 1.0f; - 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 = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); - meterRslt.Passed = (meterRslt.Error >= test.ErrLimLo + test.Uncertainty) - && (meterRslt.Error <= test.ErrLimHi - test.Uncertainty); - meterRslt.TestDone = true; - } - } - } + if (meterRslt != null && regReader != null) + { + meterRslt.PulsesPerLiter = 1.0f; + 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 = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); + meterRslt.Passed = (meterRslt.Error >= test.ErrLimLo + test.Uncertainty) + && (meterRslt.Error <= test.ErrLimHi - test.Uncertainty); + meterRslt.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, - outPath.Balance != null ? outPath.Balance.Name : string.Empty, - outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty, - outPath.Diverter != null ? outPath.Diverter.Name : string.Empty)); + 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, + outPath.Balance != null ? outPath.Balance.Name : string.Empty, + outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty, + outPath.Diverter != null ? outPath.Diverter.Name : string.Empty)); - /// Update results - Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName, tstRslt)); - } + /// Update results + Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName, tstRslt)); + } - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.TransitionAfter)); + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.TransitionAfter)); - /// Append the results to the CSV-file - allResults.Info(TestResult2CsvLine(testName, test.Part)); + /// Append the results to the CSV-file + allResults.Info(TestResult2CsvLine(testName, test.Part)); - if (++repetitionNr <= test.Repeats) - { - goto loop; - } + if (++repetitionNr <= test.Repeats) + { + goto loop; + } - stopTest: + stopTest: - ///----------------------/// - /// Quit this sequence /// - ///----------------------/// + ///----------------------/// + /// Quit this sequence /// + ///----------------------/// - State.Create("FixedStartMassCollection : Stopping diverter, gate, etc.") - .AddOperation(checkUiOp) - .AddOperation(cBrd.StopPreviousOp()) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.PreviousStopped)); + State.Create("FixedStartMassCollection : Stopping diverter, gate, etc.") + .AddOperation(checkUiOp) + .AddOperation(cBrd.StopPreviousOp()) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.PreviousStopped)); - /// Transition sequence at the end of test - /// Prevent overwriting 'retVal' in case it was set to non-default value earlier - switch (Transition(transitionAfter, (retVal == Event.Done) ? TransitionContext.AfterTest : TransitionContext.Stop)) - { - case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; } - case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; } - } + /// Transition sequence at the end of test + /// Prevent overwriting 'retVal' in case it was set to non-default value earlier + switch (Transition(transitionAfter, (retVal == Event.Done) ? TransitionContext.AfterTest : TransitionContext.Stop)) + { + case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; } + case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; } + } - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Completed)); + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Completed)); - /// Create a list with one item 'retVal' (default is Event.Done) and return it - IList retList = new List(1); - retList.Add(retVal); - return retList; - } + /// Create a list with one item 'retVal' (default is Event.Done) and return it + IList retList = new List(1); + retList.Add(retVal); + return retList; + } } } diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/TestParams.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/TestParams.cs index 12c419739..e33b83dfc 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/TestParams.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/TestParams.cs @@ -22,7 +22,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection.HeatMeters public float DeltaTempCold; public float ChangeInTimeWarm; public float ChangeInTimeCold; - public string HeatMetersPath; + public string Prompt; public override void InitializeAll() { @@ -41,7 +41,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection.HeatMeters "Delta T cold", "Change in time T warm", "Change in time T cold", - "Heat meters path", + Strings.Prompt, }; public override string ParamName(int i) { return paramNames[i]; } public override int ParamsCount() { return paramNames.Length; } @@ -59,7 +59,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection.HeatMeters case 6: return DeltaTempCold.ToString(); case 7: return ChangeInTimeWarm.ToString(); case 8: return ChangeInTimeCold.ToString(); - case 9: return HeatMetersPath; + case 9: return Prompt; default: return string.Empty; } } @@ -77,7 +77,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection.HeatMeters case 6: DeltaTempCold = Utils.ParseUFloat(strValue); return; case 7: ChangeInTimeWarm = Utils.ParseUFloat(strValue); return; case 8: ChangeInTimeCold = Utils.ParseUFloat(strValue); return; - case 9: HeatMetersPath = strValue; return; + case 9: Prompt = strValue; return; default: return; } } @@ -126,7 +126,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection.HeatMeters prms.DeltaTempCold = DeltaTempCold; prms.ChangeInTimeWarm = ChangeInTimeWarm; prms.ChangeInTimeCold = ChangeInTimeCold; - prms.HeatMetersPath = HeatMetersPath; + prms.Prompt = Prompt; } public IParamsProvider Clone() diff --git a/TestBenchFramework/Resources/Strings.Designer.cs b/TestBenchFramework/Resources/Strings.Designer.cs index d97567688..41046133f 100644 --- a/TestBenchFramework/Resources/Strings.Designer.cs +++ b/TestBenchFramework/Resources/Strings.Designer.cs @@ -2625,6 +2625,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Prompt. + /// + internal static string Prompt { + get { + return ResourceManager.GetString("Prompt", resourceCulture); + } + } + /// /// Looks up a localized string similar to Properties. /// diff --git a/TestBenchFramework/Resources/Strings.resx b/TestBenchFramework/Resources/Strings.resx index 9a6a9d891..e7ee8345f 100644 --- a/TestBenchFramework/Resources/Strings.resx +++ b/TestBenchFramework/Resources/Strings.resx @@ -1549,4 +1549,7 @@ Invalid {0} + + Prompt + \ No newline at end of file