Many changes, new results used, all test sequences modified, simulated tests rewritten.

This commit is contained in:
Milan Hanajik
2016-01-04 13:53:45 +01:00
parent 494c6edf76
commit 26982a5729
71 changed files with 2609 additions and 2692 deletions
@@ -86,9 +86,11 @@ namespace TBF.BenchControl.TestMethods.Adjustment
/// Start the test, initialize test results
Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, totalPulses));
TestResult tstRslt;
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
TestStartTime = DateTime.Now;
int flowSetTime0 = StateMachine.Time;
int flowSetTime = 0;
float estFlowSetTime = 10.0f;
//------------------------------------------------
@@ -104,9 +106,9 @@ namespace TBF.BenchControl.TestMethods.Adjustment
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
//Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
//Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
@@ -121,9 +123,9 @@ namespace TBF.BenchControl.TestMethods.Adjustment
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
//Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
//Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
@@ -138,9 +140,9 @@ namespace TBF.BenchControl.TestMethods.Adjustment
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
//Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
//Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; }
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
@@ -175,7 +177,8 @@ namespace TBF.BenchControl.TestMethods.Adjustment
//------------------------------------------------
if (mode == Config.Entities.DebugMode.Simulate)
{
tstRslt = MakeSimulated(test, 1, simulatedError);
/// TODO: Reimplement
//tstRslt = MakeSimulated(test, 1, simulatedError);
simulatedError *= 0.6f;
State.Create("Adjustment : Simulating the test")
@@ -192,12 +195,6 @@ namespace TBF.BenchControl.TestMethods.Adjustment
}
else
{
tstRslt = new TestResult(test, repetitionNr, MetersKind.Single);
tstRslt.DoNotEvaluate = true;
tstRslt.DoNotPublish = true;
tstRslt.TimeStart = DateTime.Now;
State.Create("Adjustment : Starting the test")
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
@@ -217,8 +214,7 @@ namespace TBF.BenchControl.TestMethods.Adjustment
queryEnd1 = cBrd.QueryMeasurementEndOp();
queryEnd2 = cBrd.QueryMeasurementEndOp();
bool firstTime = true; /// To reset sums for averaging
ResetAveragedData();
ClearAllStatistics();
/// Measurement loop - begin
while (true)
@@ -231,30 +227,10 @@ namespace TBF.BenchControl.TestMethods.Adjustment
case Event.MeasurementCompleted: goto one_test_completed;
}
if (firstTime)
{
firstTime = false; /// Do the following only once
tstRslt.TempInStart = TempIn.Val;
tstRslt.TempOutStart = TempOut.Val;
tstRslt.TempDivStart = TempDiv.Val;
tstRslt.PressInStart = PressureUp.Val;
tstRslt.PressOutStart = PressureDown.Val;
}
tstRslt.TempInEnd = TempIn.Val;
tstRslt.TempOutEnd = TempOut.Val;
tstRslt.TempDivEnd = TempDiv.Val;
tstRslt.PressInEnd = PressureUp.Val;
tstRslt.PressOutEnd = PressureDown.Val;
tstRslt.MassEndRaw = Mass.Val;
AccumulateAveragedData();
UpdateAllStatistics();
CurrentMassRaw = Mass.Val;
RefFreq.Val = cBrd.ReferenceFreq;
RefFlow.Val = cBrd.ReferenceFlow;
tstRslt.AmbientTempAve = AmbientTemp.Val;
tstRslt.AmbientPressAve = AmbientPressure.Val;
tstRslt.AmbientHumiAve = AmbientHumidity.Val;
string logstr = string.Format("E={0} f={1} q={2}", cBrd.EtPulses(0), cBrd.ReferenceFreq,
cBrd.ReferenceFlow * outPath.FlowMeter.NominalFlow);
@@ -266,7 +242,7 @@ namespace TBF.BenchControl.TestMethods.Adjustment
float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, true, cBrd, cBrd.TTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, true, cBrd, cBrd.TTime, progress));
}
/// Measurement loop - end
@@ -276,81 +252,92 @@ namespace TBF.BenchControl.TestMethods.Adjustment
Bridge.OnActivity(this, Strings.Adjustment_in_progress);
//------------------------------------------------
TestEndTime = DateTime.Now;
/// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest;
///
/// Populate TestResult data entity with data
///
UpdateTestRsltWithAveragedData(tstRslt);
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
tstRslt.TimeEnd = DateTime.Now;
tstRslt.BatchNr = Program.LocalSettings.BatchNr;
tstRslt.MassStart = 0;
tstRslt.MassEnd = 0;
tstRslt.MassDiff = 0;
tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3]
tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3]
tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3]
tstRslt.Time = cBrd.TTime; /// [s] measurement time
tstRslt.FlowMass = 0; /// [kg/h]
tstRslt.FlowVolume = 3600.0f * ltrPerRefPulse * cBrd.EtPulses(0) / tstRslt.Time; /// [l/h]
tstRslt.PulsesMaster = cBrd.EtPulses(0); /// Pulses of the master flow meter (test total)
tstRslt.VolumeMaster = ltrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
tstRslt.ConstMaster = outPath.FlowMeter.LtrPerPulseCorrected(tstRslt.FlowVolume / 1000.0f); /// Convert the flow to [m3/h]
tstRslt.VolumeCTV = tstRslt.ConstMaster * tstRslt.PulsesMaster; /// [l] 1000.0f is because density is in [kg/m3]
/// Corrected master pulses per liter
tstRslt.ErrorMaster = 0.0f; /// Cannot be determined without the collected water mass measurement
tstRslt.TimeDivStart0 = 0;
tstRslt.TimeDivStart1 = 0;
tstRslt.TimeDivStart2 = 0;
tstRslt.TimeDivStart3 = 0;
tstRslt.TimeDivStart4 = 0;
tstRslt.TimeDivStart5 = 0;
tstRslt.TimeDivEnd0 = 0;
tstRslt.TimeDivEnd1 = 0;
tstRslt.TimeDivEnd2 = 0;
tstRslt.TimeDivEnd3 = 0;
tstRslt.TimeDivEnd4 = 0;
tstRslt.TimeDivEnd5 = 0;
for (int i = 0; i < Config.Data.WMsCount; i++)
if (tstRslt != null)
{
if ((sensPath.RegisterReaders[i] != null) && (WaterMeters.Count > i) && !WaterMeters[i].Disabled)
{
tstRslt.Meters[i].SerialNr = (WaterMeters.Count > i) ? WaterMeters[i].SerialNr : string.Empty;
tstRslt.Meters[i].VolumeStart = 0; /// liter
tstRslt.Meters[i].VolumeEnd = 0; /// liter
tstRslt.Meters[i].PulsesPerLiter = (sensPath.RegisterReaders[i] == null ? 1.0f : sensPath.RegisterReaders[i].PulsesPerLtr);
if (sensPath.RegisterReaders[i].PulsesPerLtr <= float.Epsilon) tstRslt.Meters[i].VolumeMeter = 0;
else tstRslt.Meters[i].VolumeMeter = Convert.ToSingle(WMPulses[i]) / sensPath.RegisterReaders[i].PulsesPerLtr;
tstRslt.Meters[i].VolumeRef = tstRslt.ConstMaster * WMRefPulses[i]; /// liter
tstRslt.Meters[i].PulsesMeter = WMPulses[i];
tstRslt.Meters[i].PulsesMaster = WMRefPulses[i];
tstRslt.Meters[i].Time = cBrd.TTime;
if (WMPulses[i] > 0 && tstRslt.Meters[i].VolumeRef > 0)
{
tstRslt.Meters[i].VolumeErrorPct =
100 * (tstRslt.Meters[i].VolumeMeter - tstRslt.Meters[i].VolumeRef) / tstRslt.Meters[i].VolumeRef;
/// %
}
else
{
tstRslt.Meters[i].VolumeErrorPct = -100;
}
tstRslt.Meters[i].Passed = (tstRslt.Meters[i].VolumeErrorPct >= tstRslt.ErrLimLo + tstRslt.Uncertainty)
&& (tstRslt.Meters[i].VolumeErrorPct <= tstRslt.ErrLimHi - tstRslt.Uncertainty);
/// Auxiliary results
tstRslt.AmbientTempAve = AmbientTempStat.Average;
tstRslt.AmbientPressAve = AmbientPressureStat.Average;
tstRslt.AmbientHumiAve = AmbientHumidityStat.Average;
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]
tstRslt.Meters[i].Disabled = false;
}
else
/// 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.MassStart = 0;
tstRslt.MassEnd = 0;
tstRslt.FlowMass = 0; /// [kg/h]
tstRslt.FlowVolume = 3.6 * ltrPerRefPulse * cBrd.EtPulses(0) / tstRslt.TestTime; /// [m3/h]
tstRslt.VolumeMaster = ltrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
tstRslt.ConstMaster = outPath.FlowMeter.LtrPerPulseCorrected(tstRslt.FlowVolume); /// Calculate master flowmeter coefficient
tstRslt.VolumeCTV = tstRslt.ConstMaster * tstRslt.PulsesMaster; /// [l] 1000.0f is because density is in [kg/m3]
tstRslt.ErrorMaster = 0.0f; /// Cannot be determined without the collected water mass measurement
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{
tstRslt.Meters[i].Disabled = true;
Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, CompoundMeterId.Single);
GenericDevices.IRegisterReader regReader = (sensPath.RegisterReaders == null) ? null : sensPath.RegisterReaders[i];
if (meterRslt != null && regReader != null)
{
meterRslt.PulsesPerLiter = regReader.PulsesPerLtr;
meterRslt.PulsesMeter = Convert.ToDouble(WMPulses[i]);
meterRslt.PulsesMaster = Convert.ToDouble(WMRefPulses[i]);
meterRslt.VolumeStart = 0; /// liter
meterRslt.VolumeEnd = 0; /// liter
meterRslt.VolumeMeter = (meterRslt.PulsesPerLiter <= float.Epsilon) ? 0 : meterRslt.PulsesMeter / meterRslt.PulsesPerLiter;
meterRslt.VolumeRef = tstRslt.ConstMaster * meterRslt.PulsesMaster; /// liter
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 = meterRslt.Passed;
}
}
}
/// Add data - end
}
/// Update modeless dialog error information
Bridge.OnAdjustmentInProgress(this, new AdjustmentInProgressEventArgs(tstRslt));
@@ -365,11 +352,10 @@ namespace TBF.BenchControl.TestMethods.Adjustment
///
/// Add to results (after user quits the adjustment loop)
///
AddOrOverwriteResult(tstRslt);
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(tstRslt));
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName));
/// Append the results to the CSV-file
allResults.Info(TestResult2CsvLine(tstRslt));
allResults.Info(TestResult2CsvLine(testName, test.Part));
stopTest:
@@ -134,7 +134,7 @@ namespace TBF.BenchControl.TestMethods.CameraRoiDetection
/// Quit this sequence ///
///----------------------///
State.Create("FlyingStartCollectionMethod : Stopping diverter, gate, etc.")
State.Create("RoiDetection : Stopping diverter, gate, etc.")
.AddOperation(checkUiOp)
.AddOperation(cBrd.StopPreviousOp())
.EnterState();
@@ -61,10 +61,12 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
loop:
/// Start the test, initialize test results
Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, totalPulses));
Config.Entities.TestResult tstRslt = new Config.Entities.TestResult(test, repetitionNr, Config.Entities.MetersKind.Combined);
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
TestStartTime = DateTime.Now;
int flowSetTime0 = StateMachine.Time;
int flowSetTime = 0;
float estFlowSetTime = 10.0f;
//------------------------------------------------
@@ -80,9 +82,9 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
@@ -97,9 +99,9 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
@@ -152,9 +154,9 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; }
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
@@ -221,8 +223,7 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
}
while (!e.Contains(Event.BalanceDone));
tstRslt.TimeStart = DateTime.Now;
tstRslt.MassStartRaw = startMass.Val;
StartMassRaw = startMass.Val;
Mass.Val = startMass.Val;
//------------------------------------------------
@@ -247,8 +248,7 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
queryEnd1 = cBrd.QueryMeasurementEndOp();
queryEnd2 = cBrd.QueryMeasurementEndOp();
bool firstTime = true; /// To reset sums for averaging
ResetAveragedData();
ClearAllStatistics();
int estimtdEndTime = StateMachine.Time + (int)test.TstTime;
/// Measurement loop - begin
@@ -272,30 +272,10 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime));
}
if (firstTime)
{
firstTime = false; /// Do the following only once
tstRslt.TempInStart = TempIn.Val;
tstRslt.TempOutStart = TempOut.Val;
tstRslt.TempDivStart = TempDiv.Val;
tstRslt.PressInStart = PressureUp.Val;
tstRslt.PressOutStart = PressureDown.Val;
}
tstRslt.TempInEnd = TempIn.Val;
tstRslt.TempOutEnd = TempOut.Val;
tstRslt.TempDivEnd = TempDiv.Val;
tstRslt.PressInEnd = PressureUp.Val;
tstRslt.PressOutEnd = PressureDown.Val;
tstRslt.MassEndRaw = Mass.Val;
AccumulateAveragedData();
UpdateAllStatistics();
CurrentMassRaw = Mass.Val;
RefFreq.Val = cBrd.ReferenceFreq;
RefFlow.Val = cBrd.ReferenceFlow;
tstRslt.AmbientTempAve = AmbientTemp.Val;
tstRslt.AmbientPressAve = AmbientPressure.Val;
tstRslt.AmbientHumiAve = AmbientHumidity.Val;
string logstr = string.Format("E={0} f={1} q={2}", cBrd.EtPulses(0), cBrd.ReferenceFreq,
cBrd.ReferenceFlow * outPath.FlowMeter.NominalFlow);
@@ -306,17 +286,18 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
log.Debug(logstr);
float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime);
TestProgressEventArgs data = GetTestProgressData(test, tstRslt, true, cBrd, cBrd.TTime, progress);
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);
}
}
TestProgressEventArgs data = GetTestProgressData(test, repetitionNr, true, cBrd, cBrd.TTime, progress);
/// TODO: Reimplement
//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.OnTestProgress(this, data);
}
/// Measurement loop - end
@@ -361,8 +342,8 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
}
while (!e.Contains(Event.BalanceDone));
///
tstRslt.MassEndRaw = endMass.Val;
tstRslt.TimeEnd = DateTime.Now;
EndMassRaw = endMass.Val;
TestEndTime = DateTime.Now;
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_completed);
@@ -371,107 +352,121 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
/// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest;
/// Optionally supress pulses from the large water meter
if (testParams.SupressTrills)
{
for (int i = 0; i < tstRslt.Meters.Count; i += 2)
{
WMPulses[i] = 0;
tstRslt.Meters[i].PulsesMeter = 0;
}
}
///
/// Populate TestResult data entity with data
///
UpdateTestRsltWithAveragedData(tstRslt);
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
tstRslt.BatchNr = Program.LocalSettings.BatchNr;
tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections);
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections);
tstRslt.MassDiff = tstRslt.MassEnd - tstRslt.MassStart;
tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3]
tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3]
tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3]
tstRslt.Time = cBrd.TTime; /// [s] measurement time
tstRslt.FlowMass = 3600.0f * tstRslt.MassDiff / tstRslt.Time; /// [kg/h]
tstRslt.FlowVolume = 3600.0f * ltrPerRefPulse * cBrd.EtPulses(0) / tstRslt.Time; /// [l/h]
tstRslt.VolumeCTV = 1.00103f * 1000.0f * tstRslt.MassDiff / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3]
tstRslt.VolumeMaster = ltrPerRefPulse * cBrd.EtPulses(0); /// [l] volume from the master flow meter
tstRslt.PulsesMaster = cBrd.EtPulses(0); /// Pulses of the master flow meter (test total)
tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter
if (tstRslt.VolumeCTV <= float.Epsilon)
{
tstRslt.ErrorMaster = 0.1f;
}
else
{
tstRslt.ErrorMaster = 100 * (tstRslt.VolumeMaster - tstRslt.VolumeCTV) / tstRslt.VolumeCTV;
}
tstRslt.TimeDivStart0 = 0;
tstRslt.TimeDivStart1 = 0;
tstRslt.TimeDivStart2 = 0;
tstRslt.TimeDivStart3 = 0;
tstRslt.TimeDivStart4 = 0;
tstRslt.TimeDivStart5 = 0;
tstRslt.TimeDivEnd0 = 0;
tstRslt.TimeDivEnd1 = 0;
tstRslt.TimeDivEnd2 = 0;
tstRslt.TimeDivEnd3 = 0;
tstRslt.TimeDivEnd4 = 0;
tstRslt.TimeDivEnd5 = 0;
for (int iCmbnd = 0; iCmbnd < Config.Data.CompoundWMsCount; iCmbnd++)
if (tstRslt != null)
{
tstRslt.CombinedMeters[iCmbnd].VolumeRef = tstRslt.VolumeCTV; /// [l] must be calculated before main & aux. meter error
for (int i = 2 * iCmbnd; i < 2 * iCmbnd + 2; i++)
/// Auxiliary results
tstRslt.AmbientTempAve = AmbientTempStat.Average;
tstRslt.AmbientPressAve = AmbientPressureStat.Average;
tstRslt.AmbientHumiAve = AmbientHumidityStat.Average;
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 = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections);
tstRslt.MassEndRaw = endMass.Val;
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections);
tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.TestTime; /// [kg/h]
tstRslt.FlowVolume = 3.6 * ltrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h]
tstRslt.VolumeCTV = 1001.03 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.DensityOut; /// [l] 1001.03f is because density is in [kg/m3]
tstRslt.VolumeMaster = ltrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter
tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV);
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{
if (sensPath.RegisterReaders[i] == null || sensPath.RegisterReaders[i].PulsesPerLtr <= float.Epsilon)
{
tstRslt.Meters[i].PulsesPerLiter = 1.0f;
tstRslt.Meters[i].VolumeMeter = 0;
}
else
{
tstRslt.Meters[i].PulsesPerLiter = sensPath.RegisterReaders[i].PulsesPerLtr;
tstRslt.Meters[i].VolumeMeter = Convert.ToSingle(WMPulses[i]) / sensPath.RegisterReaders[i].PulsesPerLtr;
}
Results.Entities.MeterTestRslt mainMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundMain);
Results.Entities.MeterTestRslt auxMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundAux);
tstRslt.Meters[i].SerialNr = (WaterMeters.Count > i) ? WaterMeters[i].SerialNr : string.Empty;
tstRslt.Meters[i].VolumeStart = 0; /// [l]
tstRslt.Meters[i].VolumeEnd = 0; /// [l]
tstRslt.Meters[i].VolumeRef = tstRslt.VolumeCTV; /// [l]
if (WMRefPulses[i] != 0)
for (int isAux = 0; isAux <= 1; isAux++) /// 0=main, 1=aux
{
tstRslt.Meters[i].VolumeMeter *= ((float)cBrd.EtPulses(0) / (float)WMRefPulses[i]);
GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[2 * i + isAux];
Results.Entities.MeterTestRslt meterRslt = (isAux == 0) ? mainMeterRslt : auxMeterRslt;
if (meterRslt != null && regReader != null)
{
meterRslt.PulsesPerLiter = regReader.PulsesPerLtr;
/// Optionally supress pulses from the large water meter
meterRslt.PulsesMeter = (isAux == 0 && testParams.SupressTrills) ? 0 : Convert.ToDouble(WMPulses[2 * i + isAux]);
meterRslt.PulsesMaster = Convert.ToDouble(WMRefPulses[2 * i + isAux]);
meterRslt.TestTime = tstRslt.TestTime;
meterRslt.VolumeStart = 0;
meterRslt.VolumeEnd = 0;
meterRslt.VolumeRef = tstRslt.VolumeCTV;
meterRslt.VolumeMeter = (regReader.PulsesPerLtr <= float.Epsilon)
? 0 : meterRslt.PulsesMeter / meterRslt.PulsesPerLiter;
if (meterRslt.PulsesMaster != 0)
{
meterRslt.VolumeMeter *= (tstRslt.PulsesMaster / meterRslt.PulsesMaster);
}
meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, tstRslt.VolumeCTV); /// Main/Aux meter error is not usedfor evaluation
}
}
tstRslt.Meters[i].PulsesMeter = WMPulses[i];
tstRslt.Meters[i].PulsesMaster = WMRefPulses[i];
tstRslt.Meters[i].Time = cBrd.TTime;
Results.Entities.MeterTestRslt compoundMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Compound);
tstRslt.Meters[i].VolumeErrorPct = Formulas.ErrorFromVolumes(tstRslt.Meters[i].VolumeMeter, tstRslt.CombinedMeters[iCmbnd].VolumeRef); /// Not used
if (compoundMeterRslt != null && mainMeterRslt != null && auxMeterRslt != null)
{
compoundMeterRslt.VolumeRef = tstRslt.VolumeCTV;
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;
}
}
tstRslt.CombinedMeters[iCmbnd].VolumeMeter = tstRslt.Meters[2 * iCmbnd].VolumeMeter + tstRslt.Meters[2 * iCmbnd + 1].VolumeMeter;
tstRslt.CombinedMeters[iCmbnd].PulsesMaster = cBrd.EtPulses(0);
tstRslt.CombinedMeters[iCmbnd].Time = cBrd.TTime;
tstRslt.CombinedMeters[iCmbnd].VolumeErrorPct = Formulas.ErrorFromVolumes(tstRslt.CombinedMeters[iCmbnd].VolumeMeter, tstRslt.CombinedMeters[iCmbnd].VolumeRef);
tstRslt.CombinedMeters[iCmbnd].Passed = (tstRslt.CombinedMeters[iCmbnd].VolumeErrorPct >= tstRslt.ErrLimLo + tstRslt.Uncertainty)
&& (tstRslt.CombinedMeters[iCmbnd].VolumeErrorPct <= tstRslt.ErrLimHi - tstRslt.Uncertainty);
}
/// Add data - end
AddOrOverwriteResult(tstRslt);
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(tstRslt));
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName));
/// Append the results to the CSV-file
allResults.Info(TestResult2CsvLine(tstRslt));
allResults.Info(TestResult2CsvLine(testName, test.Part));
if (++repetitionNr <= test.Repeats)
@@ -78,8 +78,11 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
loop:
/// Start the test, initialize test results
Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, (int)totalPulses));
Config.Entities.TestResult tstRslt = new Config.Entities.TestResult(test, repetitionNr, Config.Entities.MetersKind.Combined);
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
TestStartTime = DateTime.Now;
Qrise = 0;
Qfall = 0;
if (!test.Emptying) /// Do not skip emptying if test.Emptying==true
{
@@ -112,7 +115,8 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
switching_flow_detection:
int flowSetTime0 = StateMachine.Time;
int flowDetectTime0 = StateMachine.Time;
int flowDetectTime = 0;
float estFlowSetTime = 100.0f;
/// Extract cameras from the current sensors path, add operations to the detection state
@@ -136,9 +140,9 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
flowDetectTime = StateMachine.Time - flowDetectTime0;
float progress = Formulas.TestProgress(flowDetectTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowDetectTime, progress));
if (e.Contains(Event.UiCmdStop)) goto stopTest;
}
@@ -154,9 +158,9 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
flowDetectTime = StateMachine.Time - flowDetectTime0;
float progress = Formulas.TestProgress(flowDetectTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowDetectTime, progress));
if (e.Contains(Event.UiCmdStop)) goto stopTest;
if (e.Contains(Event.RegulValveTimeOut))
@@ -210,9 +214,9 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
flowDetectTime = StateMachine.Time - flowDetectTime0;
float progress = Formulas.TestProgress(flowDetectTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowDetectTime, progress));
if (e.Contains(Event.UiCmdStop)) goto stopTest;
}
@@ -310,30 +314,29 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
if (rvPulse > 0)
{
Qrise = detectedFlow;
tstRslt.QRise = detectedFlow;
}
else
{
Qfall = detectedFlow;
tstRslt.QFall = detectedFlow;
}
UiBridge.Bridge.OnLog(this, string.Format("detected flow={0}\r\n", detectedFlow.ToString("F2")));
float qfrom_test = detectedFlow + testParams.RelativeQfrom;
float qto_test = detectedFlow + testParams.RelativeQto;
float qfrom_detected = detectedFlow + testParams.RelativeQfrom;
float qto_detected = detectedFlow + testParams.RelativeQto;
/// Update test results with the test flow determined from the detected switching flow
tstRslt.Qfrom = qfrom_test;
tstRslt.Qto = qto_test;
float Qave_lps = (qfrom_test + qto_test) / 7.2f;
tstRslt.TstTime = tstRslt.Volume / Qave_lps;
float Qave_lps = (qfrom_detected + qto_detected) / 7.2f;
float testTimeFromDetectedFlow = test.Volume / Qave_lps; /// Test volume wont be changed
float relativeQave = (testParams.RelativeQfrom + testParams.RelativeQto) / 2.0f;
bool goBackToInitFlow = ((rvPulse > 0) && (relativeQave < 0)) ||
((rvPulse < 0) && (relativeQave > 0));
if (goBackToInitFlow)
int flowSetTime0 = StateMachine.Time;
int flowSetTime = 0;
if (goBackToInitFlow)
{
//--------------------------------
State.Create("CombinedWithDetection : Switching flow detected, going back")
@@ -345,9 +348,9 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) goto stopTest;
if (e.Contains(Event.RegulValveTimeOut))
@@ -364,16 +367,16 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
//State.Create("set_RV_position",
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
.AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, qfrom_test, qto_test, outPath.PidCoef, RefFlow, 600)) /// timeout = 10 sec.
.AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, qfrom_detected, qto_detected, outPath.PidCoef, RefFlow, 600)) /// timeout = 10 sec.
//.AddOp(pOut.RegulValve.SetPositionOp(35.0f, 38.0f, uint.MaxValue))
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, testTimeFromDetectedFlow);
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) goto stopTest;
//if (e.Contains(Event.FlowTimeOut)) goto do_detection;
@@ -399,8 +402,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
}
while (!e.Contains(Event.BalanceDone));
tstRslt.TimeStart = DateTime.Now;
tstRslt.MassStartRaw = startMass.Val;
StartMassRaw = startMass.Val;
Mass.Val = startMass.Val;
//------------------------------------------------
@@ -410,7 +412,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
.AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro,
test.Qfrom, test.Qto, totalPulses, (float)test.TolerRed))
qfrom_detected, qto_detected, totalPulses, (float)test.TolerRed))
.EnterState();
do
{
@@ -426,9 +428,8 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
queryEnd1 = cBrd.QueryMeasurementEndOp();
queryEnd2 = cBrd.QueryMeasurementEndOp();
bool firstTime = true; /// Used to reset sums for averaging
ResetAveragedData();
int estimtdEndTime = StateMachine.Time + (int)tstRslt.TstTime;
ClearAllStatistics();
int estimtdEndTime = StateMachine.Time + (int)test.TstTime;
/// Measurement loop - begin
while (true)
@@ -451,25 +452,8 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime));
}
if (firstTime)
{
firstTime = false; /// Do the following only once
tstRslt.TempInStart = TempIn.Val;
tstRslt.TempOutStart = TempOut.Val;
tstRslt.TempDivStart = TempDiv.Val;
tstRslt.PressInStart = PressureUp.Val;
tstRslt.PressOutStart = PressureDown.Val;
}
tstRslt.TempInEnd = TempIn.Val;
tstRslt.TempOutEnd = TempOut.Val;
tstRslt.TempDivEnd = TempDiv.Val;
tstRslt.PressInEnd = PressureUp.Val;
tstRslt.PressOutEnd = PressureDown.Val;
tstRslt.MassEndRaw = Mass.Val;
AccumulateAveragedData();
UpdateAllStatistics();
CurrentMassRaw = Mass.Val;
string logstr = string.Format("E={0} f={1} q={2}", cBrd.EtPulses(0), cBrd.ReferenceFreq,
cBrd.ReferenceFlow * outPath.FlowMeter.NominalFlow);
@@ -481,17 +465,18 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime);
TestProgressEventArgs data = GetTestProgressData(test, tstRslt, true, cBrd, cBrd.TTime, progress);
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);
}
}
TestProgressEventArgs data = GetTestProgressData(test, repetitionNr, true, cBrd, cBrd.TTime, progress);
/// TODO: Reimplement
//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.OnTestProgress(this, data);
}
/// Measurement loop - end
@@ -514,8 +499,8 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
}
while (!e.Contains(Event.BalanceDone));
///
tstRslt.MassEndRaw = endMass.Val;
tstRslt.TimeEnd = DateTime.Now;
EndMassRaw = endMass.Val;
TestEndTime = DateTime.Now;
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_completed);
@@ -546,110 +531,127 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
}
while (!e.Contains(Event.PreviousStopped));
/// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results
/// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest;
/// Optionally supress pulses from the large water meter
if (testParams.SupressTrills)
{
for (int i = 0; i < tstRslt.Meters.Count; i += 2)
{
WMPulses[i] = 0;
tstRslt.Meters[i].PulsesMeter = 0;
}
}
///
/// Populate TestResult data entity with data
///
UpdateTestRsltWithAveragedData(tstRslt);
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
tstRslt.BatchNr = Program.LocalSettings.BatchNr;
tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections);
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections);
tstRslt.MassDiff = tstRslt.MassEnd - tstRslt.MassStart;
tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3]
tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3]
tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3]
tstRslt.Time = cBrd.TTime; /// [s] measurement time
tstRslt.FlowMass = 3600.0f * tstRslt.MassDiff / tstRslt.Time; /// [kg/h]
tstRslt.FlowVolume = 3600.0f * ltrPerRefPulse * cBrd.EtPulses(0) / tstRslt.Time; /// [l/h]
tstRslt.VolumeCTV = 1.00103f * 1000.0f * tstRslt.MassDiff / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3]
tstRslt.VolumeMaster = ltrPerRefPulse * cBrd.EtPulses(0); /// [l] volume from the master flow meter
tstRslt.PulsesMaster = cBrd.EtPulses(0); /// Pulses of the master flow meter (test total)
tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter
if (tstRslt.VolumeCTV <= float.Epsilon)
{
tstRslt.ErrorMaster = 0.1f;
}
else
{
tstRslt.ErrorMaster = 100 * (tstRslt.VolumeMaster - tstRslt.VolumeCTV) / tstRslt.VolumeCTV;
}
tstRslt.TimeDivStart0 = 0;
tstRslt.TimeDivStart1 = 0;
tstRslt.TimeDivStart2 = 0;
tstRslt.TimeDivStart3 = 0;
tstRslt.TimeDivStart4 = 0;
tstRslt.TimeDivStart5 = 0;
tstRslt.TimeDivEnd0 = 0;
tstRslt.TimeDivEnd1 = 0;
tstRslt.TimeDivEnd2 = 0;
tstRslt.TimeDivEnd3 = 0;
tstRslt.TimeDivEnd4 = 0;
tstRslt.TimeDivEnd5 = 0;
for (int iCmbnd = 0; iCmbnd < Config.Data.CompoundWMsCount; iCmbnd++)
if (tstRslt != null)
{
for (int i = 2 * iCmbnd; i < 2 * iCmbnd + 2; i++)
/// Auxiliary results
tstRslt.AmbientTempAve = AmbientTempStat.Average;
tstRslt.AmbientPressAve = AmbientPressureStat.Average;
tstRslt.AmbientHumiAve = AmbientHumidityStat.Average;
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 = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections);
tstRslt.MassEndRaw = endMass.Val;
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections);
tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.TestTime; /// [kg/h]
tstRslt.FlowVolume = 3.6 * ltrPerRefPulse * cBrd.EtPulses(0) / tstRslt.TestTime; /// [m3/h]
tstRslt.VolumeCTV = 1001.03 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3]
tstRslt.VolumeMaster = ltrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter
tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV);
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{
if (sensPath.RegisterReaders[i] == null || sensPath.RegisterReaders[i].PulsesPerLtr <= float.Epsilon)
{
tstRslt.Meters[i].VolumeMeter = 0;
}
else
{
tstRslt.Meters[i].PulsesPerLiter = (sensPath.RegisterReaders[i] == null ? 1.0f : sensPath.RegisterReaders[i].PulsesPerLtr);
tstRslt.Meters[i].VolumeMeter = Convert.ToSingle(WMPulses[i]) / sensPath.RegisterReaders[i].PulsesPerLtr;
}
Results.Entities.MeterTestRslt mainMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundMain);
Results.Entities.MeterTestRslt auxMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundAux);
tstRslt.Meters[i].SerialNr = (WaterMeters.Count > i) ? WaterMeters[i].SerialNr : string.Empty;
tstRslt.Meters[i].VolumeStart = 0; /// liter
tstRslt.Meters[i].VolumeEnd = 0; /// liter
tstRslt.Meters[i].VolumeRef = tstRslt.VolumeCTV; /// liter
if (WMRefPulses[i] != 0)
for (int isAux = 0; isAux <= 1; isAux++) /// 0=main, 1=aux
{
tstRslt.Meters[i].VolumeMeter *= ((float)cBrd.EtPulses(0) / (float)WMRefPulses[i]);
GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[2 * i + isAux];
Results.Entities.MeterTestRslt meterRslt = (isAux == 0) ? mainMeterRslt : auxMeterRslt;
if (meterRslt != null && regReader != null)
{
meterRslt.PulsesPerLiter = regReader.PulsesPerLtr;
/// Optionally supress pulses from the large water meter
meterRslt.PulsesMeter = (isAux == 0 && testParams.SupressTrills) ? 0 : Convert.ToDouble(WMPulses[2 * i + isAux]);
meterRslt.PulsesMaster = Convert.ToDouble(WMRefPulses[2 * i + isAux]);
meterRslt.TestTime = cBrd.TTime;
meterRslt.VolumeStart = 0;
meterRslt.VolumeEnd = 0;
meterRslt.VolumeRef = tstRslt.VolumeCTV;
meterRslt.VolumeMeter = (regReader.PulsesPerLtr <= float.Epsilon)
? 0 : meterRslt.PulsesMeter / meterRslt.PulsesPerLiter;
if (meterRslt.PulsesMaster != 0)
{
meterRslt.VolumeMeter *= (tstRslt.PulsesMaster / meterRslt.PulsesMaster);
}
meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, tstRslt.VolumeCTV); /// Main/Aux meter error is not usedfor evaluation
}
}
tstRslt.Meters[i].PulsesMeter = WMPulses[i];
tstRslt.Meters[i].PulsesMaster = WMRefPulses[i];
tstRslt.Meters[i].Time = cBrd.TTime;
Results.Entities.MeterTestRslt compoundMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Compound);
tstRslt.Meters[i].VolumeErrorPct = 0; /// Not used
if (compoundMeterRslt != null && mainMeterRslt != null && auxMeterRslt != null)
{
compoundMeterRslt.VolumeRef = tstRslt.VolumeCTV;
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;
if (Qrise != 0) BatchRslts.WaterMeters[i].QRise = Qrise;
if (Qfall != 0) BatchRslts.WaterMeters[i].QFall = Qfall;
}
}
tstRslt.CombinedMeters[iCmbnd].VolumeRef = tstRslt.VolumeCTV; /// liter
tstRslt.CombinedMeters[iCmbnd].VolumeMeter = tstRslt.Meters[2 * iCmbnd].VolumeMeter + tstRslt.Meters[2 * iCmbnd + 1].VolumeMeter;
tstRslt.CombinedMeters[iCmbnd].PulsesMaster = cBrd.EtPulses(0);
tstRslt.CombinedMeters[iCmbnd].Time = cBrd.TTime;
tstRslt.CombinedMeters[iCmbnd].VolumeErrorPct = Formulas.ErrorFromVolumes(tstRslt.CombinedMeters[iCmbnd].VolumeMeter, tstRslt.CombinedMeters[iCmbnd].VolumeRef);
tstRslt.CombinedMeters[iCmbnd].Passed = (tstRslt.CombinedMeters[iCmbnd].VolumeErrorPct >= tstRslt.ErrLimLo + tstRslt.Uncertainty)
&& (tstRslt.CombinedMeters[iCmbnd].VolumeErrorPct <= tstRslt.ErrLimHi - tstRslt.Uncertainty);
}
/// Add data - end
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(tstRslt));
AddOrOverwriteResult(tstRslt);
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName));
/// Append the results to the CSV-file
allResults.Info(TestResult2CsvLine(tstRslt));
allResults.Info(TestResult2CsvLine(testName, test.Part));
if (++repetitionNr <= test.Repeats)
{
@@ -62,10 +62,12 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
loop:
/// Start the test, initialize test results
Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, totalPulses));
Config.Entities.TestResult tstRslt = new Config.Entities.TestResult(test, repetitionNr, Config.Entities.MetersKind.Single);
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
TestStartTime = DateTime.Now;
int flowSetTime0 = StateMachine.Time;
int flowSetTime = 0;
float estFlowSetTime = 10.0f;
//------------------------------------------------
@@ -81,9 +83,9 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
@@ -98,9 +100,9 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
@@ -154,9 +156,9 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
@@ -171,9 +173,9 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; }
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
@@ -239,9 +241,6 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
for (int i = 0; i < Config.Data.WMsCount; i++)
{
tstRslt.Meters[i].VolumeStart = dataEntryCmpnt.WMStartState(i); /// Units: 1 liter
///-----
BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader =
sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader;
@@ -275,8 +274,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
}
while (!e.Contains(Event.BalanceDone));
tstRslt.TimeStart = DateTime.Now;
tstRslt.MassStartRaw = startMass.Val;
TestStartTime = DateTime.Now;
StartMassRaw = startMass.Val;
Mass.Val = startMass.Val;
//------------------------------------------------
@@ -315,8 +314,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
queryEnd1 = cBrd.QueryMeasurementEndOp();
queryEnd2 = cBrd.QueryMeasurementEndOp();
bool firstTime = true; /// To reset sums for averaging
ResetAveragedData();
ClearAllStatistics();
int estimtdEndTime = StateMachine.Time + (int)test.TstTime;
/// Measurement loop - begin
@@ -340,30 +338,10 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime));
}
if (firstTime)
{
firstTime = false; /// Do the following only once
tstRslt.TempInStart = TempIn.Val;
tstRslt.TempOutStart = TempOut.Val;
tstRslt.TempDivStart = TempDiv.Val;
tstRslt.PressInStart = PressureUp.Val;
tstRslt.PressOutStart = PressureDown.Val;
}
tstRslt.TempInEnd = TempIn.Val;
tstRslt.TempOutEnd = TempOut.Val;
tstRslt.TempDivEnd = TempDiv.Val;
tstRslt.PressInEnd = PressureUp.Val;
tstRslt.PressOutEnd = PressureDown.Val;
tstRslt.MassEndRaw = Mass.Val;
AccumulateAveragedData();
UpdateAllStatistics();
CurrentMassRaw = Mass.Val;
RefFreq.Val = cBrd.ReferenceFreq;
RefFlow.Val = cBrd.ReferenceFlow;
tstRslt.AmbientTempAve = AmbientTemp.Val;
tstRslt.AmbientPressAve = AmbientPressure.Val;
tstRslt.AmbientHumiAve = AmbientHumidity.Val;
string logstr = string.Format("E={0} f={1} q={2}", cBrd.EtPulses(0), cBrd.ReferenceFreq,
cBrd.ReferenceFlow * outPath.FlowMeter.NominalFlow);
@@ -375,7 +353,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, true, cBrd, cBrd.TTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, true, cBrd, cBrd.TTime, progress));
}
while (cBrd.EtPulses(0) < totalPulses);
/// Measurement loop - end
@@ -442,8 +420,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
}
while (!e.Contains(Event.BalanceDone));
///
tstRslt.MassEndRaw = endMass.Val;
tstRslt.TimeEnd = DateTime.Now;
EndMassRaw = endMass.Val;
TestEndTime = DateTime.Now;
State.Create("FixedStartAdvanced : Stopping diverter, gate, etc.")
@@ -458,11 +436,10 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
while (!e.Contains(Event.PreviousStopped));
tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections);
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections);
tstRslt.MassDiff = tstRslt.MassEnd - tstRslt.MassStart;
tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3]
tstRslt.VolumeCTV = 1.00103f * 1000.0f * tstRslt.MassDiff / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3]
double massStart = Formulas.CorrectedValue(startMass.Val, outPath.Balance.Corrections);
double massEnd = Formulas.CorrectedValue(endMass.Val, outPath.Balance.Corrections);
double densityOut = Formulas.WaterDensityFromTemp(TempOutStat.Average);
double volumeCTV = 1.00103f * 1000.0f * (massEnd - massStart) / densityOut;
///
/// Enter watermeter end states here
@@ -471,8 +448,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
{
Bridge.OnActivity(this, "Enter the water meter data");
State.Create("FixedStartAdvanced : Enter end-state")
.AddOperation(dataEntryCmpnt.ShowTestEndFormOp(tstRslt.VolumeCTV, tstRslt.ErrLimLo + tstRslt.Uncertainty,
tstRslt.ErrLimHi - tstRslt.Uncertainty))
.AddOperation(dataEntryCmpnt.ShowTestEndFormOp(volumeCTV, test.ErrLimLo + test.Uncertainty,
test.ErrLimHi - test.Uncertainty))
.AddOperation(checkUiOp)
.EnterState();
do
@@ -485,9 +462,6 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
for (int i = 0; i < Config.Data.WMsCount; i++)
{
tstRslt.Meters[i].VolumeEnd = dataEntryCmpnt.WMEndState(i);
///-----
BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader =
sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader;
@@ -506,82 +480,90 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
///
/// Populate TestResult data entity with data
///
UpdateTestRsltWithAveragedData(tstRslt);
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
tstRslt.BatchNr = Program.LocalSettings.BatchNr;
tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections);
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections);
tstRslt.MassDiff = tstRslt.MassEnd - tstRslt.MassStart;
tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3]
tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3]
tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3]
tstRslt.Time = cBrd.TTime; /// [s] measurement time
tstRslt.FlowMass = 3600.0f * tstRslt.MassDiff / tstRslt.Time; /// [kg/h]
tstRslt.FlowVolume = 3600.0f * ltrPerRefPulse * cBrd.EtPulses(0) / tstRslt.Time; /// [l/h]
tstRslt.VolumeCTV = 1.00103f * 1000.0f * tstRslt.MassDiff / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3]
tstRslt.VolumeMaster = ltrPerRefPulse * cBrd.EtPulses(0); /// [l] volume from the master flow meter
tstRslt.PulsesMaster = cBrd.EtPulses(0); /// Pulses of the master flow meter (test total)
tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter
if (tstRslt != null)
{
/// Auxiliary results
tstRslt.AmbientTempAve = AmbientTempStat.Average;
tstRslt.AmbientPressAve = AmbientPressureStat.Average;
tstRslt.AmbientHumiAve = AmbientHumidityStat.Average;
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.VolumeCTV <= float.Epsilon)
{
tstRslt.ErrorMaster = 0.1f;
}
else
{
tstRslt.ErrorMaster = 100 * (tstRslt.VolumeMaster - tstRslt.VolumeCTV) / tstRslt.VolumeCTV;
}
tstRslt.TimeDivStart0 = 0;
tstRslt.TimeDivStart1 = 0;
tstRslt.TimeDivStart2 = 0;
tstRslt.TimeDivStart3 = 0;
tstRslt.TimeDivStart4 = 0;
tstRslt.TimeDivStart5 = 0;
tstRslt.TimeDivEnd0 = 0;
tstRslt.TimeDivEnd1 = 0;
tstRslt.TimeDivEnd2 = 0;
tstRslt.TimeDivEnd3 = 0;
tstRslt.TimeDivEnd4 = 0;
tstRslt.TimeDivEnd5 = 0;
/// 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; /// [kg] calculated before displaying 'End state' dialog
tstRslt.MassEndRaw = endMass.Val;
tstRslt.MassEnd = massEnd; /// [kg] calculated before displaying 'End state' dialog
tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.TestTime; /// [kg/h]
tstRslt.FlowVolume = 3.6 * ltrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime;
tstRslt.VolumeCTV = volumeCTV; /// [kg] calculated before displaying 'End state' dialog
tstRslt.VolumeMaster = ltrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter
tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV);
for (int i = 0; i < Config.Data.WMsCount; i++)
{
if ((i < WaterMeters.Count) && !WaterMeters[i].Disabled)
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{
tstRslt.Meters[i].SerialNr = (i < WaterMeters.Count) ? WaterMeters[i].SerialNr : string.Empty;
tstRslt.Meters[i].VolumeMeter = tstRslt.Meters[i].VolumeEnd - tstRslt.Meters[i].VolumeStart;
tstRslt.Meters[i].VolumeRef = tstRslt.VolumeCTV; /// liter
tstRslt.Meters[i].PulsesMeter = 0;
tstRslt.Meters[i].PulsesMaster = tstRslt.PulsesMaster;
tstRslt.Meters[i].Time = cBrd.TTime;
if (tstRslt.Meters[i].VolumeRef > 0)
{
tstRslt.Meters[i].VolumeErrorPct =
100 * (tstRslt.Meters[i].VolumeMeter - tstRslt.Meters[i].VolumeRef) / tstRslt.Meters[i].VolumeRef;
/// %
}
else
{
tstRslt.Meters[i].VolumeErrorPct = -100;
}
tstRslt.Meters[i].Passed = (tstRslt.Meters[i].VolumeErrorPct >= tstRslt.ErrLimLo + tstRslt.Uncertainty)
&& (tstRslt.Meters[i].VolumeErrorPct <= tstRslt.ErrLimHi - tstRslt.Uncertainty);
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;
tstRslt.Meters[i].Disabled = false;
}
else
{
tstRslt.Meters[i].Disabled = 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;
}
}
}
/// Add data - end
AddOrOverwriteResult(tstRslt);
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(tstRslt));
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName));
/// Append the results to the CSV-file
allResults.Info(TestResult2CsvLine(tstRslt));
allResults.Info(TestResult2CsvLine(testName, test.Part));
if (++repetitionNr <= test.Repeats)
@@ -62,10 +62,12 @@ namespace TBF.BenchControl.TestMethods.FixedStartCombinedMeters
loop:
/// Start the test, initialize test results
Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, totalPulses));
Config.Entities.TestResult tstRslt = new Config.Entities.TestResult(test, repetitionNr, Config.Entities.MetersKind.Combined);
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
TestStartTime = DateTime.Now;
int flowSetTime0 = StateMachine.Time;
int flowSetTime = 0;
float estFlowSetTime = 10.0f;
//------------------------------------------------
@@ -81,9 +83,9 @@ namespace TBF.BenchControl.TestMethods.FixedStartCombinedMeters
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
@@ -98,9 +100,9 @@ namespace TBF.BenchControl.TestMethods.FixedStartCombinedMeters
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
@@ -154,9 +156,9 @@ namespace TBF.BenchControl.TestMethods.FixedStartCombinedMeters
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
@@ -171,9 +173,9 @@ namespace TBF.BenchControl.TestMethods.FixedStartCombinedMeters
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; }
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
@@ -239,9 +241,6 @@ namespace TBF.BenchControl.TestMethods.FixedStartCombinedMeters
for (int i = 0; i < Config.Data.WMsCount; i++)
{
tstRslt.Meters[i].VolumeStart = dataEntryCmpnt.WMStartState(i); /// Units: 1 liter
///
///-----
BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader =
sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader;
@@ -275,8 +274,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartCombinedMeters
}
while (!e.Contains(Event.BalanceDone));
tstRslt.TimeStart = DateTime.Now;
tstRslt.MassStartRaw = startMass.Val;
StartMassRaw = startMass.Val;
Mass.Val = startMass.Val;
//------------------------------------------------
@@ -315,8 +313,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartCombinedMeters
queryEnd1 = cBrd.QueryMeasurementEndOp();
queryEnd2 = cBrd.QueryMeasurementEndOp();
bool firstTime = true; /// To reset sums for averaging
ResetAveragedData();
ClearAllStatistics();
int estimtdEndTime = StateMachine.Time + (int)test.TstTime;
/// Measurement loop - begin
@@ -340,30 +337,10 @@ namespace TBF.BenchControl.TestMethods.FixedStartCombinedMeters
Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime));
}
if (firstTime)
{
firstTime = false; /// Do the following only once
tstRslt.TempInStart = TempIn.Val;
tstRslt.TempOutStart = TempOut.Val;
tstRslt.TempDivStart = TempDiv.Val;
tstRslt.PressInStart = PressureUp.Val;
tstRslt.PressOutStart = PressureDown.Val;
}
tstRslt.TempInEnd = TempIn.Val;
tstRslt.TempOutEnd = TempOut.Val;
tstRslt.TempDivEnd = TempDiv.Val;
tstRslt.PressInEnd = PressureUp.Val;
tstRslt.PressOutEnd = PressureDown.Val;
tstRslt.MassEndRaw = Mass.Val;
AccumulateAveragedData();
RefFreq.Val = cBrd.ReferenceFreq;
UpdateAllStatistics();
CurrentMassRaw = Mass.Val;
RefFreq.Val = cBrd.ReferenceFreq;
RefFlow.Val = cBrd.ReferenceFlow;
tstRslt.AmbientTempAve = AmbientTemp.Val;
tstRslt.AmbientPressAve = AmbientPressure.Val;
tstRslt.AmbientHumiAve = AmbientHumidity.Val;
string logstr = string.Format("E={0} f={1} q={2}", cBrd.EtPulses(0), cBrd.ReferenceFreq,
cBrd.ReferenceFlow * outPath.FlowMeter.NominalFlow);
@@ -375,17 +352,18 @@ namespace TBF.BenchControl.TestMethods.FixedStartCombinedMeters
float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime);
TestProgressEventArgs data = GetTestProgressData(test, tstRslt, true, cBrd, cBrd.TTime, progress);
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);
}
}
TestProgressEventArgs data = GetTestProgressData(test, repetitionNr, true, cBrd, cBrd.TTime, progress);
/// TODO: Reimplement
//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.OnTestProgress(this, data);
}
while (cBrd.EtPulses(0) < totalPulses);
@@ -453,8 +431,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartCombinedMeters
}
while (!e.Contains(Event.BalanceDone));
///
tstRslt.MassEndRaw = endMass.Val;
tstRslt.TimeEnd = DateTime.Now;
EndMassRaw = endMass.Val;
TestEndTime = DateTime.Now;
State.Create("FixedStartCombinedMeters : Stopping diverter, gate, etc.")
@@ -469,11 +447,10 @@ namespace TBF.BenchControl.TestMethods.FixedStartCombinedMeters
while (!e.Contains(Event.PreviousStopped));
tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections);
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections);
tstRslt.MassDiff = tstRslt.MassEnd - tstRslt.MassStart;
tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3]
tstRslt.VolumeCTV = 1.00103f * 1000.0f * tstRslt.MassDiff / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3]
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 = 1.00103f * 1000.0f * (massEnd - massStart) / densityOut;
///
/// Enter watermeter end states here
@@ -482,8 +459,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartCombinedMeters
{
Bridge.OnActivity(this, "Enter the water meter data");
State.Create("FixedStartCombinedMeters : Enter end-state")
.AddOperation(dataEntryCmpnt.ShowTestEndFormOp(tstRslt.VolumeCTV, tstRslt.ErrLimLo + tstRslt.Uncertainty,
tstRslt.ErrLimHi - tstRslt.Uncertainty))
.AddOperation(dataEntryCmpnt.ShowTestEndFormOp(volumeCTV, test.ErrLimLo + test.Uncertainty,
test.ErrLimHi - test.Uncertainty))
.AddOperation(checkUiOp)
.EnterState();
do
@@ -496,9 +473,6 @@ namespace TBF.BenchControl.TestMethods.FixedStartCombinedMeters
for (int i = 0; i < Config.Data.CompoundWMsCount * 2; i++)
{
tstRslt.Meters[i].VolumeEnd = dataEntryCmpnt.WMEndState(i);
///-----
BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader =
sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader;
@@ -517,82 +491,108 @@ namespace TBF.BenchControl.TestMethods.FixedStartCombinedMeters
///
/// Populate TestResult data entity with data
///
UpdateTestRsltWithAveragedData(tstRslt);
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
tstRslt.BatchNr = Program.LocalSettings.BatchNr;
tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections);
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections);
tstRslt.MassDiff = tstRslt.MassEnd - tstRslt.MassStart;
tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3]
tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3]
tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3]
tstRslt.Time = cBrd.TTime; /// [s] measurement time
tstRslt.FlowMass = 3600.0f * tstRslt.MassDiff / tstRslt.Time; /// [kg/h]
tstRslt.FlowVolume = 3600.0f * ltrPerRefPulse * cBrd.EtPulses(0) / tstRslt.Time; /// [l/h]
tstRslt.VolumeCTV = 1.00103f * 1000.0f * tstRslt.MassDiff / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3]
tstRslt.VolumeMaster = ltrPerRefPulse * cBrd.EtPulses(0); /// [l] volume from the master flow meter
tstRslt.PulsesMaster = cBrd.EtPulses(0); /// Pulses of the master flow meter (test total)
tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter
if (tstRslt.VolumeCTV <= float.Epsilon)
if (tstRslt != null)
{
tstRslt.ErrorMaster = 0.1f;
}
else
{
tstRslt.ErrorMaster = 100 * (tstRslt.VolumeMaster - tstRslt.VolumeCTV) / tstRslt.VolumeCTV;
}
tstRslt.TimeDivStart0 = 0;
tstRslt.TimeDivStart1 = 0;
tstRslt.TimeDivStart2 = 0;
tstRslt.TimeDivStart3 = 0;
tstRslt.TimeDivStart4 = 0;
tstRslt.TimeDivStart5 = 0;
tstRslt.TimeDivEnd0 = 0;
tstRslt.TimeDivEnd1 = 0;
tstRslt.TimeDivEnd2 = 0;
tstRslt.TimeDivEnd3 = 0;
tstRslt.TimeDivEnd4 = 0;
tstRslt.TimeDivEnd5 = 0;
/// Auxiliary results
tstRslt.AmbientTempAve = AmbientTempStat.Average;
tstRslt.AmbientPressAve = AmbientPressureStat.Average;
tstRslt.AmbientHumiAve = AmbientHumidityStat.Average;
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]
for (int iCmbnd = 0; iCmbnd < Config.Data.CompoundWMsCount; iCmbnd++)
{
tstRslt.CombinedMeters[iCmbnd].VolumeRef = tstRslt.VolumeCTV; /// [l] must be calculated before main & aux. meter error
tstRslt.CombinedMeters[iCmbnd].PulsesMaster = tstRslt.PulsesMaster;
/// 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; /// [l/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);
for (int i = 2 * iCmbnd; i < 2 * iCmbnd + 2; i++)
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{
tstRslt.Meters[i].PulsesPerLiter = 1.0f;
if (sensPath.RegisterReaders[i] != null && sensPath.RegisterReaders[i].PulsesPerLtr > float.Epsilon)
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
{
tstRslt.Meters[i].PulsesPerLiter = sensPath.RegisterReaders[i].PulsesPerLtr;
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
}
}
tstRslt.Meters[i].SerialNr = (i < WaterMeters.Count) ? WaterMeters[i].SerialNr : string.Empty;
tstRslt.Meters[i].VolumeMeter = tstRslt.Meters[i].VolumeEnd - tstRslt.Meters[i].VolumeStart; /// [l]
tstRslt.Meters[i].VolumeRef = tstRslt.VolumeCTV; /// [l]
tstRslt.Meters[i].PulsesMeter = 0;
tstRslt.Meters[i].PulsesMaster = tstRslt.PulsesMaster;
tstRslt.Meters[i].Time = cBrd.TTime;
Results.Entities.MeterTestRslt compoundMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Compound);
tstRslt.Meters[i].VolumeErrorPct = Formulas.ErrorFromVolumes(tstRslt.Meters[i].VolumeMeter, tstRslt.CombinedMeters[iCmbnd].VolumeRef); /// Not used
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;
}
}
tstRslt.CombinedMeters[iCmbnd].VolumeMeter = tstRslt.Meters[2 * iCmbnd].VolumeMeter + tstRslt.Meters[2 * iCmbnd + 1].VolumeMeter;
tstRslt.CombinedMeters[iCmbnd].Time = cBrd.TTime;
tstRslt.CombinedMeters[iCmbnd].VolumeErrorPct = Formulas.ErrorFromVolumes(tstRslt.CombinedMeters[iCmbnd].VolumeMeter, tstRslt.CombinedMeters[iCmbnd].VolumeRef);
tstRslt.CombinedMeters[iCmbnd].Passed = (tstRslt.CombinedMeters[iCmbnd].VolumeErrorPct >= tstRslt.ErrLimLo + tstRslt.Uncertainty)
&& (tstRslt.CombinedMeters[iCmbnd].VolumeErrorPct <= tstRslt.ErrLimHi - tstRslt.Uncertainty);
}
/// Add data - end
AddOrOverwriteResult(tstRslt);
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(tstRslt));
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName));
/// Append the results to the CSV-file
allResults.Info(TestResult2CsvLine(tstRslt));
allResults.Info(TestResult2CsvLine(testName, test.Part));
if (++repetitionNr <= test.Repeats)
@@ -62,10 +62,12 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
loop:
/// Start the test, initialize test results
Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, totalPulses));
Config.Entities.TestResult tstRslt = new Config.Entities.TestResult(test, repetitionNr, Config.Entities.MetersKind.Single);
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
TestStartTime = DateTime.Now;
int flowSetTime0 = StateMachine.Time;
int flowSetTime = 0;
float estFlowSetTime = 10.0f;
//------------------------------------------------
@@ -81,9 +83,9 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
@@ -98,9 +100,9 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
@@ -154,9 +156,9 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
@@ -171,9 +173,9 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; }
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
@@ -239,9 +241,6 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
for (int i = 0; i < Config.Data.WMsCount; i++)
{
tstRslt.Meters[i].VolumeStart = dataEntryCmpnt.WMStartState(i); /// Units: 1 liter
///-----
BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader =
sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader;
@@ -275,8 +274,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
}
while (!e.Contains(Event.BalanceDone));
tstRslt.TimeStart = DateTime.Now;
tstRslt.MassStartRaw = startMass.Val;
StartMassRaw = startMass.Val;
Mass.Val = startMass.Val;
//------------------------------------------------
@@ -315,8 +313,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
queryEnd1 = cBrd.QueryMeasurementEndOp();
queryEnd2 = cBrd.QueryMeasurementEndOp();
bool firstTime = true; /// To reset sums for averaging
ResetAveragedData();
ClearAllStatistics();
int estimtdEndTime = StateMachine.Time + (int)test.TstTime;
/// Measurement loop - begin
@@ -340,30 +337,10 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime));
}
if (firstTime)
{
firstTime = false; /// Do the following only once
tstRslt.TempInStart = TempIn.Val;
tstRslt.TempOutStart = TempOut.Val;
tstRslt.TempDivStart = TempDiv.Val;
tstRslt.PressInStart = PressureUp.Val;
tstRslt.PressOutStart = PressureDown.Val;
}
tstRslt.TempInEnd = TempIn.Val;
tstRslt.TempOutEnd = TempOut.Val;
tstRslt.TempDivEnd = TempDiv.Val;
tstRslt.PressInEnd = PressureUp.Val;
tstRslt.PressOutEnd = PressureDown.Val;
tstRslt.MassEndRaw = Mass.Val;
AccumulateAveragedData();
UpdateAllStatistics();
CurrentMassRaw = Mass.Val;
RefFreq.Val = cBrd.ReferenceFreq;
RefFlow.Val = cBrd.ReferenceFlow;
tstRslt.AmbientTempAve = AmbientTemp.Val;
tstRslt.AmbientPressAve = AmbientPressure.Val;
tstRslt.AmbientHumiAve = AmbientHumidity.Val;
string logstr = string.Format("E={0} f={1} q={2}", cBrd.EtPulses(0), cBrd.ReferenceFreq,
cBrd.ReferenceFlow * outPath.FlowMeter.NominalFlow);
@@ -375,7 +352,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, true, cBrd, cBrd.TTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, true, cBrd, cBrd.TTime, progress));
}
while (cBrd.EtPulses(0) < totalPulses);
/// Measurement loop - end
@@ -442,8 +419,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
}
while (!e.Contains(Event.BalanceDone));
///
tstRslt.MassEndRaw = endMass.Val;
tstRslt.TimeEnd = DateTime.Now;
EndMassRaw = endMass.Val;
TestEndTime = DateTime.Now;
State.Create("FixedStartMassCollection : Stopping diverter, gate, etc.")
@@ -458,11 +435,10 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
while (!e.Contains(Event.PreviousStopped));
tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections);
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections);
tstRslt.MassDiff = tstRslt.MassEnd - tstRslt.MassStart;
tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3]
tstRslt.VolumeCTV = 1.00103f * 1000.0f * tstRslt.MassDiff / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3]
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;
///
/// Enter watermeter end states here
@@ -471,8 +447,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
{
Bridge.OnActivity(this, "Enter the water meter data");
State.Create("FixedStartMassCollection : Enter end-state")
.AddOperation(dataEntryCmpnt.ShowTestEndFormOp(tstRslt.VolumeCTV, tstRslt.ErrLimLo + tstRslt.Uncertainty,
tstRslt.ErrLimHi - tstRslt.Uncertainty))
.AddOperation(dataEntryCmpnt.ShowTestEndFormOp(volumeCTV, test.ErrLimLo + test.Uncertainty,
test.ErrLimHi - test.Uncertainty))
.AddOperation(checkUiOp)
.EnterState();
do
@@ -485,9 +461,6 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
for (int i = 0; i < Config.Data.WMsCount; i++)
{
tstRslt.Meters[i].VolumeEnd = dataEntryCmpnt.WMEndState(i);
///-----
BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader =
sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader;
@@ -506,82 +479,90 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
///
/// Populate TestResult data entity with data
///
UpdateTestRsltWithAveragedData(tstRslt);
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
tstRslt.BatchNr = Program.LocalSettings.BatchNr;
tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections);
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections);
tstRslt.MassDiff = tstRslt.MassEnd - tstRslt.MassStart;
tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3]
tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3]
tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3]
tstRslt.Time = cBrd.TTime; /// [s] measurement time
tstRslt.FlowMass = 3600.0f * tstRslt.MassDiff / tstRslt.Time; /// [kg/h]
tstRslt.FlowVolume = 3600.0f * ltrPerRefPulse * cBrd.EtPulses(0) / tstRslt.Time; /// [l/h]
tstRslt.VolumeCTV = 1.00103f * 1000.0f * tstRslt.MassDiff / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3]
tstRslt.VolumeMaster = ltrPerRefPulse * cBrd.EtPulses(0); /// [l] volume from the master flow meter
tstRslt.PulsesMaster = cBrd.EtPulses(0); /// Pulses of the master flow meter (test total)
tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter
if (tstRslt != null)
{
/// Auxiliary results
tstRslt.AmbientTempAve = AmbientTempStat.Average;
tstRslt.AmbientPressAve = AmbientPressureStat.Average;
tstRslt.AmbientHumiAve = AmbientHumidityStat.Average;
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.VolumeCTV <= float.Epsilon)
{
tstRslt.ErrorMaster = 0.1f;
}
else
{
tstRslt.ErrorMaster = 100 * (tstRslt.VolumeMaster - tstRslt.VolumeCTV) / tstRslt.VolumeCTV;
}
tstRslt.TimeDivStart0 = 0;
tstRslt.TimeDivStart1 = 0;
tstRslt.TimeDivStart2 = 0;
tstRslt.TimeDivStart3 = 0;
tstRslt.TimeDivStart4 = 0;
tstRslt.TimeDivStart5 = 0;
tstRslt.TimeDivEnd0 = 0;
tstRslt.TimeDivEnd1 = 0;
tstRslt.TimeDivEnd2 = 0;
tstRslt.TimeDivEnd3 = 0;
tstRslt.TimeDivEnd4 = 0;
tstRslt.TimeDivEnd5 = 0;
/// 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; /// [l/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);
for (int i = 0; i < Config.Data.WMsCount; i++)
{
if ((i < WaterMeters.Count) && !WaterMeters[i].Disabled)
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{
tstRslt.Meters[i].SerialNr = (i < WaterMeters.Count) ? WaterMeters[i].SerialNr : string.Empty;
tstRslt.Meters[i].VolumeMeter = tstRslt.Meters[i].VolumeEnd - tstRslt.Meters[i].VolumeStart;
tstRslt.Meters[i].VolumeRef = tstRslt.VolumeCTV; /// liter
tstRslt.Meters[i].PulsesMeter = 0;
tstRslt.Meters[i].PulsesMaster = tstRslt.PulsesMaster;
tstRslt.Meters[i].Time = cBrd.TTime;
if (tstRslt.Meters[i].VolumeRef > 0)
{
tstRslt.Meters[i].VolumeErrorPct =
100 * (tstRslt.Meters[i].VolumeMeter - tstRslt.Meters[i].VolumeRef) / tstRslt.Meters[i].VolumeRef;
/// %
}
else
{
tstRslt.Meters[i].VolumeErrorPct = -100;
}
tstRslt.Meters[i].Passed = (tstRslt.Meters[i].VolumeErrorPct >= tstRslt.ErrLimLo + tstRslt.Uncertainty)
&& (tstRslt.Meters[i].VolumeErrorPct <= tstRslt.ErrLimHi - tstRslt.Uncertainty);
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;
tstRslt.Meters[i].Disabled = false;
}
else
{
tstRslt.Meters[i].Disabled = 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;
}
}
}
/// Add data - end
AddOrOverwriteResult(tstRslt);
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(tstRslt));
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName));
/// Append the results to the CSV-file
allResults.Info(TestResult2CsvLine(tstRslt));
allResults.Info(TestResult2CsvLine(testName, test.Part));
if (++repetitionNr <= test.Repeats)
@@ -59,12 +59,14 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
loop:
/// Start the test, initialize test results
Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, totalPulses));
Config.Entities.TestResult tstRslt = new Config.Entities.TestResult(test, repetitionNr, Config.Entities.MetersKind.Single);
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
TestStartTime = DateTime.Now;
//------------------------------------------------
Bridge.OnActivity(this, Strings.Setting_the_flow);
//------------------------------------------------
int flowSetTime0 = StateMachine.Time;
int flowSetTime = 0;
float estFlowSetTime = 10.0f;
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower);
@@ -76,9 +78,9 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
@@ -93,9 +95,9 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; }
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
@@ -121,8 +123,6 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
if (cameraRoi != null) measureOperations.Add(cameraRoi.MeasureOp());
}
tstRslt.TimeStart = DateTime.Now;
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_in_progress);
//------------------------------------------------
@@ -152,8 +152,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
queryEnd1 = cBrd.QueryMeasurementEndOp();
queryEnd2 = cBrd.QueryMeasurementEndOp();
bool firstTime = true; /// To reset sums for averaging
ResetAveragedData();
ClearAllStatistics();
int estimtdEndTime = StateMachine.Time + (int)test.TstTime;
/// Measurement loop - begin
@@ -177,30 +176,10 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime));
}
if (firstTime)
{
firstTime = false; /// Do the following only once
tstRslt.TempInStart = TempIn.Val;
tstRslt.TempOutStart = TempOut.Val;
tstRslt.TempDivStart = TempDiv.Val;
tstRslt.PressInStart = PressureUp.Val;
tstRslt.PressOutStart = PressureDown.Val;
}
tstRslt.TempInEnd = TempIn.Val;
tstRslt.TempOutEnd = TempOut.Val;
tstRslt.TempDivEnd = TempDiv.Val;
tstRslt.PressInEnd = PressureUp.Val;
tstRslt.PressOutEnd = PressureDown.Val;
tstRslt.MassEndRaw = Mass.Val;
AccumulateAveragedData();
UpdateAllStatistics();
CurrentMassRaw = Mass.Val;
RefFreq.Val = cBrd.ReferenceFreq;
RefFlow.Val = cBrd.ReferenceFlow;
tstRslt.AmbientTempAve = AmbientTemp.Val;
tstRslt.AmbientPressAve = AmbientPressure.Val;
tstRslt.AmbientHumiAve = AmbientHumidity.Val;
string logstr = string.Format("E={0} f={1} q={2}", cBrd.EtPulses(0), cBrd.ReferenceFreq,
cBrd.ReferenceFlow * outPath.FlowMeter.NominalFlow);
@@ -212,7 +191,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, true, cBrd, cBrd.TTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, true, cBrd, cBrd.TTime, progress));
}
/// Measurement loop - end
@@ -222,117 +201,120 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
Bridge.OnActivity(this, Strings.Test_completed);
//------------------------------------------------
TestEndTime = DateTime.Now;
/// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest;
///
/// Populate TestResult data entity with data
///
UpdateTestRsltWithAveragedData(tstRslt);
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
tstRslt.TimeEnd = DateTime.Now;
tstRslt.BatchNr = Program.LocalSettings.BatchNr;
tstRslt.MassStart = 0;
tstRslt.MassEnd = 0;
tstRslt.MassDiff = 0;
tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3]
tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3]
tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3]
tstRslt.Time = cBrd.TTime; /// [s] measurement time
tstRslt.FlowMass = 0; /// [kg/h]
tstRslt.FlowVolume = 3600.0f * ltrPerRefPulse * cBrd.EtPulses(0) / tstRslt.Time; /// [l/h]
tstRslt.PulsesMaster = cBrd.EtPulses(0); /// Pulses of the master flow meter (test total)
tstRslt.VolumeMaster = ltrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
tstRslt.ConstMaster = outPath.FlowMeter.LtrPerPulseCorrected(tstRslt.FlowVolume / 1000.0f); /// Convert the flow to [m3/h]
tstRslt.VolumeCTV = tstRslt.ConstMaster * tstRslt.PulsesMaster; /// [l] 1000.0f is because density is in [kg/m3]
/// Corrected master pulses per liter
tstRslt.ErrorMaster = 0.0f; /// Cannot be determined without the collected water mass measurement
tstRslt.TimeDivStart0 = 0;
tstRslt.TimeDivStart1 = 0;
tstRslt.TimeDivStart2 = 0;
tstRslt.TimeDivStart3 = 0;
tstRslt.TimeDivStart4 = 0;
tstRslt.TimeDivStart5 = 0;
tstRslt.TimeDivEnd0 = 0;
tstRslt.TimeDivEnd1 = 0;
tstRslt.TimeDivEnd2 = 0;
tstRslt.TimeDivEnd3 = 0;
tstRslt.TimeDivEnd4 = 0;
tstRslt.TimeDivEnd5 = 0;
for (int i = 0; i < Config.Data.WMsCount; i++)
if (tstRslt != null)
{
/// Reference to iPerl water meter or null:
WaterMeters.iPerl.WaterMeter iPerl = ((sensPath.RegisterReaders != null) && (i < sensPath.RegisterReaders.Length))
? (sensPath.RegisterReaders[i] as WaterMeters.iPerl.WaterMeter)
: null;
/// Auxiliary results
tstRslt.AmbientTempAve = AmbientTempStat.Average;
tstRslt.AmbientPressAve = AmbientPressureStat.Average;
tstRslt.AmbientHumiAve = AmbientHumidityStat.Average;
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 ((sensPath.RegisterReaders[i] != null) && (WaterMeters.Count > i) && !WaterMeters[i].Disabled)
/// 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 = 0;
tstRslt.MassStart = 0;
tstRslt.MassEndRaw = 0;
tstRslt.MassEnd = 0;
tstRslt.FlowMass = 0; /// [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.ConstMaster = outPath.FlowMeter.LtrPerPulseCorrected(tstRslt.FlowVolume); /// Corrected master pulses per liter
tstRslt.VolumeCTV = tstRslt.ConstMaster * tstRslt.PulsesMaster; /// [l] 1000.0f is because density is in [kg/m3]
tstRslt.ErrorMaster = 0.0; /// Cannot be determined without a mass measurement
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{
tstRslt.Meters[i].SerialNr = (WaterMeters.Count > i) ? WaterMeters[i].SerialNr : string.Empty;
tstRslt.Meters[i].PulsesPerLiter = sensPath.RegisterReaders[i].PulsesPerLtr;
Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single);
GenericDevices.IRegisterReader regReader = (sensPath.RegisterReaders == null) ? null : sensPath.RegisterReaders[i];
WaterMeters.iPerl.WaterMeter iPerl = regReader as WaterMeters.iPerl.WaterMeter;
if (iPerl != null)
if (meterRslt != null && regReader != null)
{
tstRslt.Meters[i].VolumeStart = (float)iPerl.VolumeLtrStart; /// liter
tstRslt.Meters[i].VolumeEnd = (float)iPerl.VolumeLtrEnd; /// liter
tstRslt.Meters[i].VolumeMeter = (float)Math.Abs(iPerl.VolumeLtrEnd - iPerl.VolumeLtrStart);
tstRslt.Meters[i].VolumeRef = tstRslt.VolumeCTV * (float)(iPerl.TimestampSecEnd - iPerl.TimestampSecStart) / tstRslt.Time;
iPerl.VolumeLtrRef = (double)tstRslt.Meters[i].VolumeRef;
tstRslt.Meters[i].Time = (float)(iPerl.TimestampSecEnd - iPerl.TimestampSecStart);
tstRslt.Meters[i].TimeStart = (float)iPerl.TimestampSecStart;
tstRslt.Meters[i].TimeEnd = (float)iPerl.TimestampSecEnd;
tstRslt.Meters[i].CalibFactor = (iPerl.CalibrationStruct != null) ? iPerl.CalibrationStruct.Calibration : 0;
tstRslt.Meters[i].Q2Correction = iPerl.CurrentQ2Correction;
}
else
{
tstRslt.Meters[i].VolumeStart = 0; /// liter
tstRslt.Meters[i].VolumeEnd = 0; /// liter
if (sensPath.RegisterReaders[i].PulsesPerLtr <= float.Epsilon) tstRslt.Meters[i].VolumeMeter = 0;
else tstRslt.Meters[i].VolumeMeter = Convert.ToSingle(WMPulses[i]) / sensPath.RegisterReaders[i].PulsesPerLtr;
tstRslt.Meters[i].VolumeRef = tstRslt.ConstMaster * WMRefPulses[i]; /// liter
tstRslt.Meters[i].Time = cBrd.TTime;
tstRslt.Meters[i].TimeStart = 0;
tstRslt.Meters[i].TimeEnd = 0;
tstRslt.Meters[i].CalibFactor = 0;
tstRslt.Meters[i].Q2Correction = 0;
}
meterRslt.PulsesPerLiter = regReader.PulsesPerLtr;
meterRslt.PulsesMeter = Convert.ToDouble(WMPulses[i]);
meterRslt.PulsesMaster = Convert.ToDouble(WMRefPulses[i]);
tstRslt.Meters[i].PulsesMeter = WMPulses[i];
tstRslt.Meters[i].PulsesMaster = WMRefPulses[i];
if (WMPulses[i] > 0 && tstRslt.Meters[i].VolumeRef > 0)
{
tstRslt.Meters[i].VolumeErrorPct =
100 * (tstRslt.Meters[i].VolumeMeter - tstRslt.Meters[i].VolumeRef) / tstRslt.Meters[i].VolumeRef;
/// %
}
else
{
tstRslt.Meters[i].VolumeErrorPct = -100;
}
tstRslt.Meters[i].Passed = (tstRslt.Meters[i].VolumeErrorPct >= tstRslt.ErrLimLo + tstRslt.Uncertainty)
&& (tstRslt.Meters[i].VolumeErrorPct <= tstRslt.ErrLimHi - tstRslt.Uncertainty);
}
else
{
tstRslt.Meters[i].Disabled = true;
}
if (iPerl != null)
{
meterRslt.TimestampStart = iPerl.TimestampSecStart;
meterRslt.TimestampEnd = iPerl.TimestampSecEnd;
meterRslt.TestTime = meterRslt.TimestampEnd - meterRslt.TimestampStart;
meterRslt.VolumeStart = iPerl.VolumeLtrStart; /// liter
meterRslt.VolumeEnd = iPerl.VolumeLtrEnd; /// liter
meterRslt.VolumeMeter = Math.Abs(iPerl.VolumeLtrEnd - iPerl.VolumeLtrStart);
meterRslt.VolumeRef = tstRslt.VolumeCTV * meterRslt.TestTime / tstRslt.TestTime;
iPerl.VolumeLtrRef = meterRslt.VolumeRef;
#if IPERLST
meterRslt.CalibFactor = (iPerl.CalibrationStruct != null) ? iPerl.CalibrationStruct.Calibration : 0;
meterRslt.Q2Correction = iPerl.CurrentQ2Correction;
#endif
iPerl.LastTestResult = meterRslt; /// Save this water meter test result to iPerl WM
iPerl.NominalTestFlow = 500.0 * (test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
}
else
{
meterRslt.TestTime = tstRslt.TestTime;
meterRslt.VolumeStart = 0;
meterRslt.VolumeEnd = 0;
meterRslt.VolumeMeter = (meterRslt.PulsesPerLiter <= float.Epsilon) ? 0 : meterRslt.PulsesMeter / meterRslt.PulsesPerLiter;
meterRslt.VolumeRef = tstRslt.ConstMaster * meterRslt.PulsesMaster; /// liter
}
if (iPerl != null)
{
iPerl.LastTestResult = tstRslt.Meters[i]; /// Save this water meter test result to iPerl WM
iPerl.NominalTestFlow = 500.0 * (double)(test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
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;
}
}
}
/// Add data - end
AddOrOverwriteResult(tstRslt);
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(tstRslt));
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName));
/// Append the results to the CSV-file
allResults.Info(TestResult2CsvLine(tstRslt));
allResults.Info(TestResult2CsvLine(testName, test.Part));
if (++repetitionNr <= test.Repeats)
@@ -10,7 +10,7 @@ using TBF.Boxes;
using TBF.Resources;
using TBF.UiBridge;
namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
{
public class FlyingStartCollectionMethodSeq : Sequences.SequenceBase
{
@@ -59,12 +59,11 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
loop:
/// Start the test, initialize test results
Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, totalPulses));
Config.Entities.TestResult tstRslt = new Config.Entities.TestResult(test, repetitionNr, Config.Entities.MetersKind.Single);
tstRslt.DoNotEvaluate = !testParams.Evaluate;
tstRslt.DoNotPublish = !testParams.Publish;
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
TestStartTime = DateTime.Now;
int flowSetTime0 = StateMachine.Time;
int flowSetTime = 0;
float estFlowSetTime = 10.0f;
//------------------------------------------------
@@ -72,7 +71,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
//------------------------------------------------
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower);
State.Create("FlyingStartCollectionMethod : Starting the pump")
State.Create("FlyingStartMassCollection : Starting the pump")
.AddOperation(checkUiOp)
.AddOperation(new Operations.TimerOp(5))
.EnterState();
@@ -80,16 +79,16 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.TimerExpired));
State.Create("FlyingStartCollectionMethod : Starting the pump")
State.Create("FlyingStartMassCollection : Starting the pump")
.AddOperation(checkUiOp)
.AddOperation(cBrd.SetValvesOp(inPath.Pump, null))
.EnterState();
@@ -97,9 +96,9 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
@@ -111,7 +110,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
///
/// Measure the weight and skip emptying if there is enough room in the tank
///
State.Create("FlyingStartCollectionMethod : Measuring the mass of water in the tank")
State.Create("FlyingStartMassCollection : Measuring the mass of water in the tank")
.AddOperation(checkUiOp)
.AddOperation(outPath.Balance.ReadMassOp(ref Mass))
.EnterState();
@@ -144,7 +143,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
//------------------------------------------------
Bridge.OnActivity(this, Strings.Setting_the_flow);
//------------------------------------------------
State.Create("FlyingStartCollectionMethod : Setting the flow")
State.Create("FlyingStartMassCollection : Setting the flow")
.AddOperation(checkUiOp)
.AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, outPath.PidCoef, RefFlow, 600)) /// timeout = 10 min.
.EnterState();
@@ -152,9 +151,9 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; }
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
@@ -180,7 +179,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
if (cameraRoi != null) measureOperations.Add(cameraRoi.MeasureOp());
}
State.Create("FlyingStartCollectionMethod : Waiting before 1st mass measurement")
State.Create("FlyingStartMassCollection : Waiting before 1st mass measurement")
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn))
.AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut))
@@ -208,7 +207,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
//------------------------------------------------
Bridge.OnActivity(this, Strings.Measuring_the_weight);
//------------------------------------------------
State.Create("FlyingStartCollectionMethod : Measuring the start mass")
State.Create("FlyingStartMassCollection : Measuring the start mass")
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn))
.AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut))
@@ -232,15 +231,14 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
LogProcessHeader(processDataLogger, "Measurement");
tstRslt.TimeStart = DateTime.Now;
tstRslt.MassStartRaw = startMass.Val;
StartMassRaw = startMass.Val;
log.WarnFormat("Start mass = {0}kg", startMass);
Mass.Val = startMass.Val;
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_in_progress);
//------------------------------------------------
State.Create("FlyingStartCollectionMethod : Starting the test")
State.Create("FlyingStartMassCollection : Starting the test")
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn))
.AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut))
@@ -274,9 +272,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders, ref WMPulses, ref WMTimes, ref WMRefPulses);
queryEnd1 = cBrd.QueryMeasurementEndOp();
bool firstTime = true; /// To reset sums for averaging
ResetAveragedData();
int estimtdEndTime = StateMachine.Time + (int)tstRslt.TstTime;
int estimtdEndTime = StateMachine.Time + (int)test.TstTime;
ClearAllStatistics();
/// Measurement loop - begin
State.Create("Read water meters")
@@ -315,30 +312,10 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
}
//------------------------------------------------
if (firstTime)
{
firstTime = false; /// Do the following only once
tstRslt.TempInStart = TempIn.Val;
tstRslt.TempOutStart = TempOut.Val;
tstRslt.TempDivStart = TempDiv.Val;
tstRslt.PressInStart = PressureUp.Val;
tstRslt.PressOutStart = PressureDown.Val;
}
tstRslt.TempInEnd = TempIn.Val;
tstRslt.TempOutEnd = TempOut.Val;
tstRslt.TempDivEnd = TempDiv.Val;
tstRslt.PressInEnd = PressureUp.Val;
tstRslt.PressOutEnd = PressureDown.Val;
tstRslt.MassEndRaw = Mass.Val;
AccumulateAveragedData();
UpdateAllStatistics();
CurrentMassRaw = Mass.Val;
RefFreq.Val = cBrd.ReferenceFreq;
RefFlow.Val = cBrd.ReferenceFlow;
tstRslt.AmbientTempAve = AmbientTemp.Val;
tstRslt.AmbientPressAve = AmbientPressure.Val;
tstRslt.AmbientHumiAve = AmbientHumidity.Val;
string logstr = string.Format("E={0} f={1} q={2}", cBrd.EtPulses(0), cBrd.ReferenceFreq,
cBrd.ReferenceFlow * outPath.FlowMeter.NominalFlow);
@@ -350,13 +327,13 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, true, cBrd, cBrd.TTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, true, cBrd, cBrd.TTime, progress));
}
while (true);
/// Measurement loop - end
test_completed:
State.Create("FlyingStartCollectionMethod : Waiting before 2nd mass measurement")
State.Create("FlyingStartMassCollection : Waiting before 2nd mass measurement")
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn))
.AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut))
@@ -384,7 +361,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
//------------------------------------------------
Bridge.OnActivity(this, Strings.Measuring_the_weight);
//------------------------------------------------
State.Create("FlyingStartCollectionMethod : Measuring the end mass")
State.Create("FlyingStartMassCollection : Measuring the end mass")
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn))
.AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut))
@@ -407,8 +384,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
while (!e.Contains(Event.BalanceDone));
///
log.WarnFormat("End mass = {0}kg", endMass);
tstRslt.MassEndRaw = endMass.Val;
tstRslt.TimeEnd = DateTime.Now;
EndMassRaw = endMass.Val;
TestEndTime = DateTime.Now;
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_completed);
@@ -420,116 +397,112 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
///
/// Populate TestResult data entity with data
///
UpdateTestRsltWithAveragedData(tstRslt);
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
tstRslt.BatchNr = Program.LocalSettings.BatchNr;
tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections);
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections);
tstRslt.MassDiff = tstRslt.MassEnd - tstRslt.MassStart;
tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3]
tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3]
tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3]
tstRslt.Time = cBrd.TTime; /// [s] measurement time
tstRslt.FlowMass = 3600.0f * tstRslt.MassDiff / tstRslt.Time; /// [kg/h]
tstRslt.FlowVolume = 3600.0f * ltrPerRefPulse * cBrd.EtPulses(0) / tstRslt.Time; /// [l/h]
tstRslt.VolumeCTV = 1.00103f * 1000.0f * tstRslt.MassDiff / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3]
tstRslt.VolumeMaster = ltrPerRefPulse * cBrd.EtPulses(0); /// [l] volume from the master flow meter
tstRslt.PulsesMaster = cBrd.EtPulses(0); /// Pulses of the master flow meter (test total)
tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter
if (tstRslt != null)
{
/// Auxiliary results
tstRslt.AmbientTempAve = AmbientTempStat.Average;
tstRslt.AmbientPressAve = AmbientPressureStat.Average;
tstRslt.AmbientHumiAve = AmbientHumidityStat.Average;
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.VolumeCTV <= float.Epsilon)
{
tstRslt.ErrorMaster = 0.0f;
}
else
{
tstRslt.ErrorMaster = 100 * (tstRslt.VolumeMaster - tstRslt.VolumeCTV) / tstRslt.VolumeCTV;
}
tstRslt.TimeDivStart0 = 0;
tstRslt.TimeDivStart1 = 0;
tstRslt.TimeDivStart2 = 0;
tstRslt.TimeDivStart3 = 0;
tstRslt.TimeDivStart4 = 0;
tstRslt.TimeDivStart5 = 0;
tstRslt.TimeDivEnd0 = 0;
tstRslt.TimeDivEnd1 = 0;
tstRslt.TimeDivEnd2 = 0;
tstRslt.TimeDivEnd3 = 0;
tstRslt.TimeDivEnd4 = 0;
tstRslt.TimeDivEnd5 = 0;
for (int i = 0; i < Config.Data.WMsCount; i++)
{
/// Reference to iPerl water meter or null:
WaterMeters.iPerl.WaterMeter iPerl = ((sensPath.RegisterReaders != null) && (i < sensPath.RegisterReaders.Length))
? (sensPath.RegisterReaders[i] as WaterMeters.iPerl.WaterMeter)
: null;
/// 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 = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections);
tstRslt.MassEndRaw = endMass.Val;
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections);
tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.TestTime; /// [kg/h]
tstRslt.FlowVolume = 3.6 * ltrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h]
tstRslt.VolumeCTV = 1001.03 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3]
tstRslt.VolumeMaster = ltrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter
tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV);
if ((sensPath.RegisterReaders[i] != null) && (WaterMeters.Count > i) && !WaterMeters[i].Disabled)
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{
tstRslt.Meters[i].SerialNr = (WaterMeters.Count > i) ? WaterMeters[i].SerialNr : string.Empty;
tstRslt.Meters[i].PulsesPerLiter = sensPath.RegisterReaders[i].PulsesPerLtr;
Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single);
GenericDevices.IRegisterReader regReader = (sensPath.RegisterReaders == null) ? null : sensPath.RegisterReaders[i];
WaterMeters.iPerl.WaterMeter iPerl = regReader as WaterMeters.iPerl.WaterMeter;
if (iPerl != null)
{
tstRslt.Meters[i].VolumeStart = (float)iPerl.VolumeLtrStart; /// liter
tstRslt.Meters[i].VolumeEnd = (float)iPerl.VolumeLtrEnd; /// liter
tstRslt.Meters[i].VolumeMeter = (float)Math.Abs(iPerl.VolumeLtrEnd - iPerl.VolumeLtrStart);
tstRslt.Meters[i].VolumeRef = tstRslt.VolumeCTV * (float)(iPerl.TimestampSecEnd - iPerl.TimestampSecStart) / tstRslt.Time;
iPerl.VolumeLtrRef = (double)tstRslt.Meters[i].VolumeRef;
tstRslt.Meters[i].Time = (float)(iPerl.TimestampSecEnd - iPerl.TimestampSecStart);
tstRslt.Meters[i].TimeStart = (float)iPerl.TimestampSecStart;
tstRslt.Meters[i].TimeEnd = (float)iPerl.TimestampSecEnd;
tstRslt.Meters[i].CalibFactor = (iPerl.CalibrationStruct != null) ? iPerl.CalibrationStruct.Calibration : 0;
tstRslt.Meters[i].Q2Correction = iPerl.CurrentQ2Correction;
}
else
{
tstRslt.Meters[i].VolumeStart = 0; /// liter
tstRslt.Meters[i].VolumeEnd = 0; /// liter
if (sensPath.RegisterReaders[i].PulsesPerLtr <= float.Epsilon) tstRslt.Meters[i].VolumeMeter = 0;
else tstRslt.Meters[i].VolumeMeter = Convert.ToSingle(WMPulses[i]) / sensPath.RegisterReaders[i].PulsesPerLtr;
tstRslt.Meters[i].VolumeRef = tstRslt.ConstMaster * WMRefPulses[i]; /// liter
tstRslt.Meters[i].Time = cBrd.TTime;
tstRslt.Meters[i].TimeStart = 0;
tstRslt.Meters[i].TimeEnd = 0;
tstRslt.Meters[i].CalibFactor = 0;
tstRslt.Meters[i].Q2Correction = 0;
}
tstRslt.Meters[i].PulsesMeter = WMPulses[i];
tstRslt.Meters[i].PulsesMaster = WMRefPulses[i];
if (WMPulses[i] > 0 && tstRslt.Meters[i].VolumeRef > 0)
if (meterRslt != null && regReader != null)
{
tstRslt.Meters[i].VolumeErrorPct =
100 * (tstRslt.Meters[i].VolumeMeter - tstRslt.Meters[i].VolumeRef) / tstRslt.Meters[i].VolumeRef;
/// %
}
else
{
tstRslt.Meters[i].VolumeErrorPct = -100;
}
tstRslt.Meters[i].Passed = (tstRslt.Meters[i].VolumeErrorPct >= tstRslt.ErrLimLo + tstRslt.Uncertainty)
&& (tstRslt.Meters[i].VolumeErrorPct <= tstRslt.ErrLimHi - tstRslt.Uncertainty);
}
else
{
tstRslt.Meters[i].Disabled = true;
}
meterRslt.PulsesPerLiter = regReader.PulsesPerLtr;
meterRslt.PulsesMeter = Convert.ToDouble(WMPulses[i]);
meterRslt.PulsesMaster = Convert.ToDouble(WMRefPulses[i]);
if (iPerl != null)
{
iPerl.LastTestResult = tstRslt.Meters[i]; /// Save this water meter test result to iPerl WM
iPerl.NominalTestFlow = 500.0 * (double)(test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
if (iPerl != null)
{
meterRslt.TimestampStart = iPerl.TimestampSecStart;
meterRslt.TimestampEnd = iPerl.TimestampSecEnd;
meterRslt.TestTime = meterRslt.TimestampEnd - meterRslt.TimestampStart;
meterRslt.VolumeStart = iPerl.VolumeLtrStart; /// liter
meterRslt.VolumeEnd = iPerl.VolumeLtrEnd; /// liter
meterRslt.VolumeMeter = Math.Abs(iPerl.VolumeLtrEnd - iPerl.VolumeLtrStart);
meterRslt.VolumeRef = tstRslt.VolumeCTV * meterRslt.TestTime / tstRslt.TestTime;
iPerl.VolumeLtrRef = meterRslt.VolumeRef;
#if IPERLST
meterRslt.CalibFactor = (iPerl.CalibrationStruct != null) ? iPerl.CalibrationStruct.Calibration : 0;
meterRslt.Q2Correction = iPerl.CurrentQ2Correction;
#endif
iPerl.LastTestResult = meterRslt; /// Save this water meter test result to iPerl WM
iPerl.NominalTestFlow = 500.0 * (double)(test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
}
else
{
meterRslt.TestTime = tstRslt.TestTime;
meterRslt.VolumeStart = 0; /// liter
meterRslt.VolumeEnd = 0; /// liter
meterRslt.VolumeMeter = (meterRslt.PulsesPerLiter <= float.Epsilon) ? 0 : meterRslt.PulsesMeter / meterRslt.PulsesPerLiter;
meterRslt.VolumeRef = tstRslt.ConstMaster * meterRslt.PulsesMaster; /// liter
}
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;
}
}
}
/// Add data - end
AddOrOverwriteResult(tstRslt);
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(tstRslt));
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName));
/// Append the results to the CSV-file
allResults.Info(TestResult2CsvLine(tstRslt));
allResults.Info(TestResult2CsvLine(testName, test.Part));
if (++repetitionNr <= test.Repeats)
@@ -543,7 +516,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
/// Quit this sequence ///
///----------------------///
State.Create("FlyingStartCollectionMethod : Stopping diverter, gate, etc.")
State.Create("FlyingStartMassCollection : Stopping diverter, gate, etc.")
.AddOperation(checkUiOp)
.AddOperation(cBrd.StopPreviousOp())
.EnterState();
@@ -8,12 +8,12 @@ using log4net;
using Config.Entities;
using TBF.BenchControl;
namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
{
public class TestMethod : ComponentBase, GenericDevices.ITestMethod
{
private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod));
public override string ToString() { return string.Format("TestMethods.FlyingStartCollectionMethod({0})", Cfg.ToString(1)); }
public override string ToString() { return string.Format("TestMethods.FlyingStartMassCollection({0})", Cfg.ToString(1)); }
readonly TestMethodCfg testMethodCfg;
@@ -8,7 +8,7 @@ using System.Xml.Serialization;
using Config.Entities;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
{
public class TestMethodCfg : ComponentCfgBase, Generic.IComponentCfg
{
@@ -6,7 +6,7 @@ using System.Windows.Forms;
using log4net;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
{
public partial class TestMethodCfgCtrl : UserControl, IComponentCfgCtrl
{
@@ -1,7 +1,7 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
{
partial class TestMethodCfgCtrl
{
@@ -3,7 +3,7 @@
///
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
{
public class TestMethodFactory : IComponentFactory
{
@@ -9,7 +9,7 @@ using Config.Entities;
using TBF.BenchControl.Generic;
using TBF.Resources;
namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
{
public class TestParams : TestParamsBase, IParamsProvider, ITestParams
{
@@ -47,7 +47,7 @@ namespace TBF.BenchControl.TestMethods.LeakTest
/// Start the test, initialize test results
Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, 1, inPath, benchPath, outPath, sensPath, 0));
TestResult tstRslt = new TestResult(test, 1, StateMachine.Procedure.MetersKind);
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, 1);
//------------------------------------------------
Bridge.OnActivity(this, Strings.Starting_the_pump);
@@ -123,6 +123,9 @@ namespace TBF.BenchControl.TestMethods.LeakTest
pressure_set:
ClearAllStatistics();
UpdateAllStatistics();
startTime = StateMachine.Time;
int estimtdEndTime = startTime + testParams.DurationPMax;
@@ -141,14 +144,11 @@ namespace TBF.BenchControl.TestMethods.LeakTest
{
e = StateMachine.WaitRunDevsRunOps();
tstRslt.TempInStart = TempIn.Val;
tstRslt.TempOutStart = TempOut.Val;
tstRslt.PressInStart = PressureUp.Val;
tstRslt.PressOutStart = PressureDown.Val;
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
UpdateAllStatistics();
int remainingTime = Math.Max(estimtdEndTime - StateMachine.Time, 0);
if (remainingTime > 60)
{
@@ -178,13 +178,10 @@ namespace TBF.BenchControl.TestMethods.LeakTest
{
e = StateMachine.WaitRunDevsRunOps();
tstRslt.TempInStart = TempIn.Val;
tstRslt.TempOutStart = TempOut.Val;
tstRslt.PressInStart = PressureUp.Val;
tstRslt.PressOutStart = PressureDown.Val;
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
UpdateAllStatistics();
}
while (e.Contains(Event.ValvesBusy));
@@ -204,23 +201,20 @@ namespace TBF.BenchControl.TestMethods.LeakTest
{
e = StateMachine.WaitRunDevsRunOps();
tstRslt.TempInStart = TempIn.Val;
tstRslt.TempOutStart = TempOut.Val;
tstRslt.PressInStart = PressureUp.Val;
tstRslt.PressOutStart = PressureDown.Val;
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
UpdateAllStatistics();
}
while (e.Contains(Event.ValvesBusy));
pump_is_off:
tstRslt.TimeStart = DateTime.Now;
TestStartTime = DateTime.Now;
startTime = StateMachine.Time;
estimtdEndTime = startTime + testParams.DurationLeak;
ResetAveragedData();
ClearAllStatistics();
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_in_progress);
@@ -236,9 +230,12 @@ namespace TBF.BenchControl.TestMethods.LeakTest
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
UpdateAllStatistics();
int remainingTime = Math.Max(estimtdEndTime - StateMachine.Time, 0);
if (remainingTime > 60)
{
@@ -248,14 +245,6 @@ namespace TBF.BenchControl.TestMethods.LeakTest
{
Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime));
}
tstRslt.TempInEnd = TempIn.Val;
tstRslt.TempOutEnd = TempOut.Val;
tstRslt.PressInEnd = PressureUp.Val;
tstRslt.PressOutEnd = PressureDown.Val;
tstRslt.MassEndRaw = Mass.Val;
AccumulateAveragedData();
}
while (e.Contains(Event.TimerBusy));
@@ -267,108 +256,118 @@ namespace TBF.BenchControl.TestMethods.LeakTest
Bridge.OnActivity(this, Strings.Test_completed);
//------------------------------------------------
TestEndTime = DateTime.Now;
/// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest;
///
/// Populate TestResult data entity with data
///
UpdateTestRsltWithAveragedData(tstRslt);
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
tstRslt.TimeEnd = DateTime.Now;
tstRslt.BatchNr = Program.LocalSettings.BatchNr;
tstRslt.MassStart = 0;
tstRslt.MassEnd = 0;
tstRslt.MassDiff = 0;
tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3]
tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg);/// [kg/m3]
tstRslt.DensityDiv = 0; /// [kg/m3]
tstRslt.Time = testParams.DurationPMax; /// [s] measurement time
tstRslt.FlowMass = 0; /// [kg/h]
tstRslt.FlowVolume = 0; /// [l/h]
tstRslt.PulsesMaster = 0; /// Pulses of the master flow meter (test total)
tstRslt.VolumeMaster = 0; /// [l] volume from the master flow meter
tstRslt.ConstMaster = 0; /// Convert the flow to [m3/h]
tstRslt.VolumeCTV = 0; /// [l] 1000.0f is because density is in [kg/m3]
tstRslt.ErrorMaster = 0;
tstRslt.TimeDivStart0 = 0;
tstRslt.TimeDivStart1 = 0;
tstRslt.TimeDivStart2 = 0;
tstRslt.TimeDivStart3 = 0;
tstRslt.TimeDivStart4 = 0;
tstRslt.TimeDivStart5 = 0;
tstRslt.TimeDivEnd0 = 0;
tstRslt.TimeDivEnd1 = 0;
tstRslt.TimeDivEnd2 = 0;
tstRslt.TimeDivEnd3 = 0;
tstRslt.TimeDivEnd4 = 0;
tstRslt.TimeDivEnd5 = 0;
if (StateMachine.Procedure.MetersKind == MetersKind.Single)
{
for (int i = 0; i < Config.Data.WMsCount; i++)
if (tstRslt != null)
{
if (sensPath.RegisterReaders[i] != null)
/// Auxiliary results
tstRslt.AmbientTempAve = AmbientTempStat.Average;
tstRslt.AmbientPressAve = AmbientPressureStat.Average;
tstRslt.AmbientHumiAve = AmbientHumidityStat.Average;
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 = 0;
/// Main results
tstRslt.StartTime = TestStartTime;
tstRslt.EndTime = TestEndTime;
tstRslt.FlowSetTime = 0;
tstRslt.TestTime = Convert.ToDouble(testParams.DurationPMax); /// [s] measurement time
tstRslt.PulsesMaster = 0; /// Pulses of the master flow meter (test total)
tstRslt.MassStartRaw = 0;
tstRslt.MassStart = 0;
tstRslt.MassEndRaw = 0;
tstRslt.MassEnd = 0;
tstRslt.FlowMass = 0; /// [kg/h]
tstRslt.FlowVolume = 0; /// [m3/h]
tstRslt.VolumeMaster = 0; /// [l] volume from the master flow meter
tstRslt.VolumeCTV = 0; /// [l] 1000.0f is because density is in [kg/m3]
tstRslt.ConstMaster = 0; /// Convert the flow to [m3/h]
tstRslt.ErrorMaster = 0;
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{
tstRslt.Meters[i].SerialNr = (WaterMeters.Count > i) ? WaterMeters[i].SerialNr : string.Empty;
tstRslt.Meters[i].VolumeStart = 0;
tstRslt.Meters[i].VolumeEnd = 0;
tstRslt.Meters[i].VolumeMeter = 0;
tstRslt.Meters[i].VolumeRef = 0;
tstRslt.Meters[i].PulsesMeter = 0;
tstRslt.Meters[i].PulsesMaster = 0;
tstRslt.Meters[i].Time = testParams.DurationPMax;
tstRslt.Meters[i].VolumeErrorPct = 0;
tstRslt.Meters[i].Passed = true;
if (StateMachine.Procedure.MetersKind == MetersKind.Single)
{
Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single);
if (meterRslt != null)
{
meterRslt.TestTime = tstRslt.TestTime;
meterRslt.Error = 0;
meterRslt.Passed = true;
meterRslt.TestDone = true;
}
}
else
{
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;
if (meterRslt != null)
{
meterRslt.TestTime = tstRslt.TestTime;
meterRslt.Error = 0;
meterRslt.Passed = true;
}
}
Results.Entities.MeterTestRslt compoundMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Compound);
if (compoundMeterRslt != null)
{
compoundMeterRslt.TestTime = tstRslt.TestTime;
compoundMeterRslt.Error = 0;
compoundMeterRslt.Passed = true;
mainMeterRslt.TestDone = auxMeterRslt.TestDone = compoundMeterRslt.TestDone = true;
}
}
}
}
}
else
{
for (int iCmbnd = 0; iCmbnd < Config.Data.CompoundWMsCount; iCmbnd++)
{
tstRslt.CombinedMeters[iCmbnd].VolumeRef = 0;
for (int i = 2 * iCmbnd; i < 2 * iCmbnd + 2; i++)
{
if (sensPath.RegisterReaders[i] == null || sensPath.RegisterReaders[i].PulsesPerLtr <= float.Epsilon)
{
tstRslt.Meters[i].PulsesPerLiter = 1.0f;
}
else
{
tstRslt.Meters[i].PulsesPerLiter = sensPath.RegisterReaders[i].PulsesPerLtr;
}
tstRslt.Meters[i].SerialNr = (WaterMeters.Count > i) ? WaterMeters[i].SerialNr : string.Empty;
tstRslt.Meters[i].VolumeStart = 0;
tstRslt.Meters[i].VolumeEnd = 0;
tstRslt.Meters[i].VolumeRef = 0;
tstRslt.Meters[i].VolumeMeter = 0;
tstRslt.Meters[i].Time = test.TstTime;
tstRslt.Meters[i].TimeStart = 0;
tstRslt.Meters[i].TimeEnd = testParams.DurationPMax;
tstRslt.Meters[i].PulsesMeter = 0;
tstRslt.Meters[i].PulsesMaster = 0;
tstRslt.Meters[i].VolumeErrorPct = 0;
tstRslt.Meters[i].Passed = true;
}
tstRslt.CombinedMeters[iCmbnd].VolumeMeter = 0;
tstRslt.CombinedMeters[iCmbnd].PulsesMaster = 0;
tstRslt.CombinedMeters[iCmbnd].Time = testParams.DurationPMax;
tstRslt.CombinedMeters[iCmbnd].VolumeErrorPct = 0;
tstRslt.CombinedMeters[iCmbnd].Passed = true;
}
}
/// Add data - end
AddOrOverwriteResult(tstRslt);
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(tstRslt));
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName));
/// Append the results to the CSV-file
allResults.Info(TestResult2CsvLine(tstRslt));
allResults.Info(TestResult2CsvLine(testName, test.Part));
stopTest:
@@ -47,7 +47,8 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
/// Start the test, initialize test results
Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, 1, inPath, benchPath, outPath, sensPath, 0));
TestResult tstRslt = new TestResult(test, 1, StateMachine.Procedure.MetersKind);
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, 1);
TestStartTime = DateTime.Now;
//------------------------------------------------
Bridge.OnActivity(this, Strings.Starting_the_pump);
@@ -103,11 +104,6 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
PressureUp.Val.ToString("F1"),
PressureUp.Val.ToString("F1")));
tstRslt.TempInStart = TempIn.Val;
tstRslt.TempOutStart = TempOut.Val;
tstRslt.PressInStart = PressureUp.Val;
tstRslt.PressOutStart = PressureDown.Val;
float step = (pumpPower < 40.0f) ? 5.0f : ((pumpPower < 60.0f) ? 3.0f : ((pumpPower < 80.0f) ? 2.0f : 1.0f));
if (PressureDown.Val < testParams.PressureLo)
@@ -128,10 +124,11 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
pressure_set:
tstRslt.TimeStart = DateTime.Now;
ClearAllStatistics();
UpdateAllStatistics();
startTime = StateMachine.Time;
int endTime = startTime + testParams.DurationPMax;
ResetAveragedData();
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_in_progress);
@@ -148,17 +145,13 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
{
e = StateMachine.WaitRunDevsRunOps();
tstRslt.TempInEnd = TempIn.Val;
tstRslt.TempOutEnd = TempOut.Val;
tstRslt.PressInEnd = PressureUp.Val;
tstRslt.PressOutEnd = PressureDown.Val;
tstRslt.MassEndRaw = Mass.Val;
AccumulateAveragedData();
CurrentMassRaw = Mass.Val;
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
UpdateAllStatistics();
int remainingTime = Math.Max(endTime - StateMachine.Time, 0);
if (remainingTime > 60)
{
@@ -173,7 +166,9 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
/// Measurement loop - end
test_completed:
test_completed:
TestEndTime = DateTime.Now;
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_completed);
@@ -185,102 +180,110 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
///
/// Populate TestResult data entity with data
///
UpdateTestRsltWithAveragedData(tstRslt);
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
tstRslt.TimeEnd = DateTime.Now;
tstRslt.BatchNr = Program.LocalSettings.BatchNr;
tstRslt.MassStart = 0;
tstRslt.MassEnd = 0;
tstRslt.MassDiff = 0;
tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3]
tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3]
tstRslt.DensityDiv = 0; /// [kg/m3]
tstRslt.Time = testParams.DurationPMax; /// [s] measurement time
tstRslt.FlowMass = 0; /// [kg/h]
tstRslt.FlowVolume = 0; /// [l/h]
tstRslt.PulsesMaster = 0; /// Pulses of the master flow meter (test total)
tstRslt.VolumeMaster = 0; /// [l] volume from the master flow meter
tstRslt.ConstMaster = 0; /// Convert the flow to [m3/h]
tstRslt.VolumeCTV = 0; /// [l] 1000.0f is because density is in [kg/m3]
tstRslt.ErrorMaster = 0;
tstRslt.TimeDivStart0 = 0;
tstRslt.TimeDivStart1 = 0;
tstRslt.TimeDivStart2 = 0;
tstRslt.TimeDivStart3 = 0;
tstRslt.TimeDivStart4 = 0;
tstRslt.TimeDivStart5 = 0;
tstRslt.TimeDivEnd0 = 0;
tstRslt.TimeDivEnd1 = 0;
tstRslt.TimeDivEnd2 = 0;
tstRslt.TimeDivEnd3 = 0;
tstRslt.TimeDivEnd4 = 0;
tstRslt.TimeDivEnd5 = 0;
if (StateMachine.Procedure.MetersKind == Config.Entities.MetersKind.Single)
{
for (int i = 0; i < Config.Data.WMsCount; i++)
{
if (sensPath.RegisterReaders[i] != null)
{
tstRslt.Meters[i].SerialNr = (WaterMeters.Count > i) ? WaterMeters[i].SerialNr : string.Empty;
tstRslt.Meters[i].VolumeStart = 0;
tstRslt.Meters[i].VolumeEnd = 0;
tstRslt.Meters[i].VolumeMeter = 0;
tstRslt.Meters[i].VolumeRef = 0;
tstRslt.Meters[i].PulsesMeter = 0;
tstRslt.Meters[i].PulsesMaster = 0;
tstRslt.Meters[i].Time = testParams.DurationPMax;
tstRslt.Meters[i].VolumeErrorPct = 0;
tstRslt.Meters[i].Passed = true;
}
}
}
else
if (tstRslt != null)
{
for (int iCmbnd = 0; iCmbnd < Config.Data.CompoundWMsCount; iCmbnd++)
/// Auxiliary results
tstRslt.AmbientTempAve = AmbientTempStat.Average;
tstRslt.AmbientPressAve = AmbientPressureStat.Average;
tstRslt.AmbientHumiAve = AmbientHumidityStat.Average;
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 = 0;
/// Main results
tstRslt.StartTime = TestStartTime;
tstRslt.EndTime = TestEndTime;
tstRslt.FlowSetTime = 0;
tstRslt.TestTime = Convert.ToDouble(testParams.DurationPMax); /// [s] measurement time
tstRslt.PulsesMaster = 0; /// Pulses of the master flow meter (test total)
tstRslt.MassStartRaw = 0;
tstRslt.MassStart = 0;
tstRslt.MassEndRaw = 0;
tstRslt.MassEnd = 0;
tstRslt.FlowMass = 0; /// [kg/h]
tstRslt.FlowVolume = 0; /// [m3/h]
tstRslt.VolumeMaster = 0; /// [l] volume from the master flow meter
tstRslt.VolumeCTV = 0; /// [l] 1000.0f is because density is in [kg/m3]
tstRslt.ConstMaster = 0; /// Convert the flow to [m3/h]
tstRslt.ErrorMaster = 0;
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{
tstRslt.CombinedMeters[iCmbnd].VolumeRef = 0;
for (int i = 2 * iCmbnd; i < 2 * iCmbnd + 2; i++)
if (StateMachine.Procedure.MetersKind == MetersKind.Single)
{
if (sensPath.RegisterReaders[i] == null || sensPath.RegisterReaders[i].PulsesPerLtr <= float.Epsilon)
{
tstRslt.Meters[i].PulsesPerLiter = 1.0f;
}
else
{
tstRslt.Meters[i].PulsesPerLiter = sensPath.RegisterReaders[i].PulsesPerLtr;
}
Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single);
tstRslt.Meters[i].SerialNr = (WaterMeters.Count > i) ? WaterMeters[i].SerialNr : string.Empty;
tstRslt.Meters[i].VolumeStart = 0;
tstRslt.Meters[i].VolumeEnd = 0;
tstRslt.Meters[i].VolumeRef = 0;
tstRslt.Meters[i].VolumeMeter = 0;
tstRslt.Meters[i].Time = test.TstTime;
tstRslt.Meters[i].TimeStart = 0;
tstRslt.Meters[i].TimeEnd = testParams.DurationPMax;
tstRslt.Meters[i].PulsesMeter = 0;
tstRslt.Meters[i].PulsesMaster = 0;
tstRslt.Meters[i].VolumeErrorPct = 0;
tstRslt.Meters[i].Passed = true;
if (meterRslt != null)
{
meterRslt.TestTime = tstRslt.TestTime;
meterRslt.Error = 0;
meterRslt.Passed = true;
meterRslt.TestDone = true;
}
}
else
{
Results.Entities.MeterTestRslt mainMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundMain);
Results.Entities.MeterTestRslt auxMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundAux);
tstRslt.CombinedMeters[iCmbnd].VolumeMeter = 0;
tstRslt.CombinedMeters[iCmbnd].PulsesMaster = 0;
tstRslt.CombinedMeters[iCmbnd].Time = testParams.DurationPMax;
tstRslt.CombinedMeters[iCmbnd].VolumeErrorPct = 0;
tstRslt.CombinedMeters[iCmbnd].Passed = true;
for (int isAux = 0; isAux <= 1; isAux++) /// 0=main, 1=aux
{
Results.Entities.MeterTestRslt meterRslt = (isAux == 0) ? mainMeterRslt : auxMeterRslt;
if (meterRslt != null)
{
meterRslt.TestTime = tstRslt.TestTime;
meterRslt.Error = 0;
meterRslt.Passed = true;
}
}
Results.Entities.MeterTestRslt compoundMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Compound);
if (compoundMeterRslt != null)
{
compoundMeterRslt.TestTime = tstRslt.TestTime;
compoundMeterRslt.Error = 0;
compoundMeterRslt.Passed = true;
mainMeterRslt.TestDone = auxMeterRslt.TestDone = compoundMeterRslt.TestDone = true;
}
}
}
}
/// Add data - end
AddOrOverwriteResult(tstRslt);
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(tstRslt));
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName));
/// Append the results to the CSV-file
allResults.Info(TestResult2CsvLine(tstRslt));
allResults.Info(TestResult2CsvLine(testName, test.Part));
stopTest:
@@ -30,39 +30,41 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
{
Elde.ControlBoardDev cBrd = StateMachine.ControlBoard;
IList<Event> e = new List<Event>(); /// Events from currently running operations
Event retVal = Event.Done;
checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state
IList<Event> e = new List<Event>(); /// Events from currently running operations
Event retVal = Event.Done;
checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state
ltrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h]
ltrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h]
/// Notes:
/// float timeHr = volumeLtr / (1000.0f * targetFlow);
/// float timeSec = 3600.0f * timeHr;
/// int refPulses = (int)(timeSec * (2000.0f * targetFlow / pOut.FlowMeter.NominalFlow));
int totalPulses = (int)(test.Volume / ltrPerRefPulse + 0.5f);
/// Notes:
/// float timeHr = volumeLtr / (1000.0f * targetFlow);
/// float timeSec = 3600.0f * timeHr;
/// int refPulses = (int)(timeSec * (2000.0f * targetFlow / pOut.FlowMeter.NominalFlow));
int totalPulses = (int)(test.Volume / ltrPerRefPulse + 0.5f);
processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this);
int repetitionNr = 1; /// First test: repetitionNr=1
processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this);
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; }
case Event.Error: { retVal = Event.Error; goto stopTest; }
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
}
//====================================
loop:
loop:
/// Start the test, initialize test results
Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, totalPulses));
Config.Entities.TestResult tstRslt = new Config.Entities.TestResult(test, repetitionNr, Config.Entities.MetersKind.Single);
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
TestStartTime = DateTime.Now;
int flowSetTime0 = StateMachine.Time;
int flowSetTime = 0;
float estFlowSetTime = 10.0f;
//------------------------------------------------
@@ -78,9 +80,9 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
@@ -95,51 +97,51 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.ValvesSet));
if (!test.Emptying) /// If condition met => skip measuring and force emptying
{
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
/// Measure the weight and skip emptying if there is enough room in the tank
///
State.Create("ReferenceFlowmeterCalibration : Measuring the mass of water in the tank")
.AddOperation(checkUiOp)
.AddOperation(outPath.Balance.ReadMassOp(ref Mass))
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.BalanceDone));
.AddOperation(checkUiOp)
.AddOperation(outPath.Balance.ReadMassOp(ref Mass))
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.BalanceDone));
float estimatedEndMass = Mass.Val + test.Volume;
if (estimatedEndMass < outPath.Balance.Capacity * Constants.TankFullFactor)
{
goto set_flow; /// Enough room in the tank -> skip emptying
}
}
float estimatedEndMass = Mass.Val + test.Volume;
if (estimatedEndMass < outPath.Balance.Capacity * Constants.TankFullFactor)
{
goto set_flow; /// Enough room in the tank -> skip emptying
}
}
///
/// 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; }
case Event.Error: { retVal = Event.Error; goto stopTest; }
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
}
set_flow:
set_flow:
//--------------------------------
//--------------------------------
State.Create("ReferenceFlowmeterCalibration : Setting the flow")
.AddOperation(checkUiOp)
.AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, outPath.PidCoef, RefFlow, 600)) /// timeout = 10 min.
@@ -148,12 +150,12 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
{
e = StateMachine.WaitRunDevsRunOps();
int flowSetTime = StateMachine.Time - flowSetTime0;
flowSetTime = StateMachine.Time - flowSetTime0;
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress));
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, false, cBrd, flowSetTime, progress));
if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; }
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; }
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
if (e.Contains(Event.RegulValveTimeOut))
{
Bridge.OnError(this, Strings.Timeout);
@@ -164,97 +166,75 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
}
while (!e.Contains(Event.FlowReached));
flow_set:
int time = StateMachine.Time;
float currentFlow = RefFlow.Val;
flow_set:
int time = StateMachine.Time;
float currentFlow = RefFlow.Val;
//------------------------------------------------
Bridge.OnActivity(this, Strings.Measuring_the_weight);
//------------------------------------------------
//------------------------------------------------
Bridge.OnActivity(this, Strings.Measuring_the_weight);
//------------------------------------------------
State.Create("ReferenceFlowmeterCalibration : Measuring the start 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 startMass, 5))
.AddOperation(cBrd.UpdateTankWeightOp())
.AddOperation(processDataLoggingOp)
.EnterState();
.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 startMass, 5))
.AddOperation(cBrd.UpdateTankWeightOp())
.AddOperation(processDataLoggingOp)
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.BalanceDone));
tstRslt.TimeStart = DateTime.Now;
tstRslt.MassStartRaw = startMass.Val;
Mass.Val = startMass.Val;
StartMassRaw = startMass.Val;
Mass.Val = startMass.Val;
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_in_progress);
//------------------------------------------------
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_in_progress);
//------------------------------------------------
State.Create("ReferenceFlowmeterCalibration : Starting the test")
.AddOperation(checkUiOp)
.AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro,
.AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro,
test.Qfrom, test.Qto, totalPulses, (float)test.TolerRed))
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.MeasurementStarted));
/// Measurement loop - preparation
readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders, ref WMPulses, ref WMRefPulses);
queryEnd1 = cBrd.QueryMeasurementEndOp();
readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders, ref WMPulses, ref WMRefPulses);
queryEnd1 = cBrd.QueryMeasurementEndOp();
queryEnd2 = cBrd.QueryMeasurementEndOp();
bool firstTime = true; /// To reset sums for averaging
ResetAveragedData();
ClearAllStatistics();
/// Measurement loop - begin
/// Measurement loop - begin
while (true)
{
//--------------------------------
switch (ReadRegistersTempPressAmbient(null, true))
//--------------------------------
switch (ReadRegistersTempPressAmbient(null, true))
{
case Event.Error: { retVal = Event.Error; goto stopTest; }
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
case Event.Error: { retVal = Event.Error; goto stopTest; }
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
case Event.MeasurementCompleted: goto test_completed;
}
if (firstTime)
{
firstTime = false; /// Do the following only once
tstRslt.TempInStart = TempIn.Val;
tstRslt.TempOutStart = TempOut.Val;
tstRslt.TempDivStart = TempDiv.Val;
tstRslt.PressInStart = PressureUp.Val;
tstRslt.PressOutStart = PressureDown.Val;
}
tstRslt.TempInEnd = TempIn.Val;
tstRslt.TempOutEnd = TempOut.Val;
tstRslt.TempDivEnd = TempDiv.Val;
tstRslt.PressInEnd = PressureUp.Val;
tstRslt.PressOutEnd = PressureDown.Val;
tstRslt.MassEndRaw = Mass.Val;
AccumulateAveragedData();
RefFreq.Val = cBrd.ReferenceFreq;
RefFlow.Val = cBrd.ReferenceFlow;
tstRslt.AmbientTempAve = AmbientTemp.Val;
tstRslt.AmbientPressAve = AmbientPressure.Val;
tstRslt.AmbientHumiAve = AmbientHumidity.Val;
UpdateAllStatistics();
CurrentMassRaw = Mass.Val;
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);
@@ -265,151 +245,140 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
log.Debug(logstr);
float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, true, cBrd, cBrd.TTime, progress));
float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, repetitionNr, true, cBrd, cBrd.TTime, progress));
}
/// Measurement loop - end
/// Measurement loop - end
test_completed:
State.Create("FlyingStartCollectionMethod : Waiting before 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(readRegistersOp)
.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 (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.TimerExpired));
//------------------------------------------------
Bridge.OnActivity(this, Strings.Measuring_the_weight);
//------------------------------------------------
State.Create("ReferenceFlowmeterCalibration : Measuring the end mass")
test_completed:
State.Create("ReferenceFlowmeterCalibration : Waiting before 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.ReadStableMassOp(ref endMass, 5))
.AddOperation(cBrd.UpdateTankWeightOp())
.AddOperation(processDataLoggingOp)
.EnterState();
.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(readRegistersOp)
.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 (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.TimerExpired));
//------------------------------------------------
Bridge.OnActivity(this, Strings.Measuring_the_weight);
//------------------------------------------------
State.Create("ReferenceFlowmeterCalibration : 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, 5))
.AddOperation(cBrd.UpdateTankWeightOp())
.AddOperation(processDataLoggingOp)
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.BalanceDone));
///
tstRslt.MassEndRaw = endMass.Val;
tstRslt.TimeEnd = DateTime.Now;
///
EndMassRaw = endMass.Val;
TestEndTime = DateTime.Now;
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_completed);
//------------------------------------------------
/// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results
/// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest;
///
/// Populate TestResult data entity with data
///
UpdateTestRsltWithAveragedData(tstRslt);
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
tstRslt.BatchNr = Program.LocalSettings.BatchNr;
tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections);
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections);
tstRslt.MassDiff = tstRslt.MassEnd - tstRslt.MassStart;
tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3]
tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3]
tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3]
tstRslt.Time = cBrd.TTime; /// [s] measurement time
tstRslt.FlowMass = 3600.0f * tstRslt.MassDiff / tstRslt.Time; /// [kg/h]
tstRslt.FlowVolume = 3600.0f * ltrPerRefPulse * cBrd.EtPulses(0) / tstRslt.Time; /// [l/h]
tstRslt.VolumeCTV = 1.00103f * 1000.0f * tstRslt.MassDiff / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3]
tstRslt.VolumeMaster = ltrPerRefPulse * cBrd.EtPulses(0); /// [l] volume from the master flow meter
tstRslt.PulsesMaster = cBrd.EtPulses(0); /// Pulses of the master flow meter (test total)
tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter
if (tstRslt.VolumeCTV <= float.Epsilon)
if (tstRslt != null)
{
tstRslt.ErrorMaster = 0.1f;
}
else
{
tstRslt.ErrorMaster = 100 * (tstRslt.VolumeMaster - tstRslt.VolumeCTV) / tstRslt.VolumeCTV;
/// Auxiliary results
tstRslt.AmbientTempAve = AmbientTempStat.Average;
tstRslt.AmbientPressAve = AmbientPressureStat.Average;
tstRslt.AmbientHumiAve = AmbientHumidityStat.Average;
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]
/// Update flowmeter constant with the measured one
if (outPath.FlowMeter.Idx1 > 0 && outPath.FlowMeter.Idx1 <= ReferenceFlowmetersCount)
{
LtrPerRefPulse[outPath.FlowMeter.Idx1 - 1] = tstRslt.ConstMaster;
log.InfoFormat("Updating LtrPerRefPulse[{0}] = {1}", outPath.FlowMeter.Idx1 - 1, tstRslt.ConstMaster);
}
/// 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 = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections);
tstRslt.MassEndRaw = endMass.Val;
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections);
tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.TestTime; /// [kg/h]
tstRslt.FlowVolume = 3.6 * ltrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h]
tstRslt.VolumeCTV = 1001.03 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3]
tstRslt.VolumeMaster = ltrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter
tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV);
/// Update flowmeter constant with the measured one
if (outPath.FlowMeter.Idx1 > 0 && outPath.FlowMeter.Idx1 <= ReferenceFlowmetersCount)
{
LtrPerRefPulse[outPath.FlowMeter.Idx1 - 1] = Convert.ToSingle(tstRslt.ConstMaster);
log.InfoFormat("Updating LtrPerRefPulse[{0}] = {1}", outPath.FlowMeter.Idx1 - 1, tstRslt.ConstMaster);
}
}
tstRslt.TimeDivStart0 = 0;
tstRslt.TimeDivStart1 = 0;
tstRslt.TimeDivStart2 = 0;
tstRslt.TimeDivStart3 = 0;
tstRslt.TimeDivStart4 = 0;
tstRslt.TimeDivStart5 = 0;
tstRslt.TimeDivEnd0 = 0;
tstRslt.TimeDivEnd1 = 0;
tstRslt.TimeDivEnd2 = 0;
tstRslt.TimeDivEnd3 = 0;
tstRslt.TimeDivEnd4 = 0;
tstRslt.TimeDivEnd5 = 0;
//for (int i = 0; i < Config.Data.WMsCount; i++)
//{
// if (sensPath.RegisterReaders[i] != null)
// {
// tstRslt.Meters[i].SerialNr = "wm" + (i + 1).ToString();
// tstRslt.Meters[i].VolumeStart = 0; /// liter
// tstRslt.Meters[i].VolumeEnd = 0; /// liter
// if (sensPath.RegisterReaders[i].PulsesPerLtr <= float.Epsilon) tstRslt.Meters[i].VolumeMeter = 0;
// else tstRslt.Meters[i].VolumeMeter = Convert.ToSingle(WMPulses[i]) / sensPath.RegisterReaders[i].PulsesPerLtr;
// tstRslt.Meters[i].VolumeRef = tstRslt.ConstMaster * WMRefPulses[i]; /// liter
// tstRslt.Meters[i].PulsesMeter = WMPulses[i];
// tstRslt.Meters[i].PulsesMaster = WMRefPulses[i];
// tstRslt.Meters[i].Time = cBrd.TTime;
// if (WMPulses[i] > 0 && tstRslt.Meters[i].VolumeRef > 0)
// {
// tstRslt.Meters[i].VolumeErrorPct =
// 100 * (tstRslt.Meters[i].VolumeMeter - tstRslt.Meters[i].VolumeRef) / tstRslt.Meters[i].VolumeRef;
// /// %
// }
// else
// {
// tstRslt.Meters[i].VolumeErrorPct = -100;
// }
// tstRslt.Meters[i].Passed = (tstRslt.Meters[i].VolumeErrorPct >= tstRslt.ErrLimLo + tstRslt.Uncertainty)
// && (tstRslt.Meters[i].VolumeErrorPct <= tstRslt.ErrLimHi - tstRslt.Uncertainty);
// }
//}
/// Add data - end
AddOrOverwriteResult(tstRslt);
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(tstRslt));
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName));
/// Append the results to the CSV-file
allResults.Info(TestResult2CsvLine(tstRslt));
allResults.Info(TestResult2CsvLine(testName, test.Part));
if (++repetitionNr <= test.Repeats)
@@ -439,7 +408,7 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
/// Prevent overwriting 'retVal' in case it was set to non-default value earlier
switch (Transition(transitionAfter, TransitionContext.AfterTest))
{
case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; }
case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; }
case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; }
}
@@ -11,6 +11,7 @@ using System.Windows.Forms;
using log4net;
using Config.Entities;
using TBF.Resources;
using TBF.BenchControl.Sequences;
using TBF.BenchControl.WaterMeters.iPerl;
namespace TBF.BenchControl.TestMethods.iPerlCommunication
@@ -262,6 +263,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
/// RFID multiplexer PCB / RFID serial port and worker thread related variables
///
static TestMethodCfg cfg;
static IList<string> testNames;
static IList<iPerlCommunicationParams> multiTestParams;
@@ -413,10 +415,12 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
/// Constructor for one iPerlCommunication 'test'
/// </summary>
/// <param name="waterMetersCount">Number of text boxes for serial numbers</param>
public iPerlCommunicationForm(IList<GenericDevices.IWaterMeter> waterMeters,
TestMethodCfg cfg, iPerlCommunicationParams testParams)
public iPerlCommunicationForm(IList<GenericDevices.IWaterMeter> waterMeters, TestMethodCfg cfg,
string testName, iPerlCommunicationParams testParams)
: this(waterMeters, cfg)
{
iPerlCommunicationForm.testNames = new List<string>();
iPerlCommunicationForm.testNames.Add(testName);
iPerlCommunicationForm.multiTestParams = new List<iPerlCommunicationParams>();
iPerlCommunicationForm.multiTestParams.Add(testParams);
@@ -429,9 +433,10 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
/// </summary>
/// <param name="waterMetersCount">Number of text boxes for serial numbers</param>
public iPerlCommunicationForm(IList<GenericDevices.IWaterMeter> waterMeters, TestMethodCfg cfg,
IList<iPerlCommunicationParams> multiTestParams)
IList<string> testNames, IList<iPerlCommunicationParams> multiTestParams)
: this(waterMeters, cfg)
{
iPerlCommunicationForm.testNames = testNames;
iPerlCommunicationForm.multiTestParams = multiTestParams;
if (multiTestParams.Count > 0) activityLabel.Text = multiTestParams[0].Activity;
@@ -534,9 +539,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
CommCompletedHandler = null;
AllCompletedHandler = null;
TestResult result = CommResult(StateMachine.Tests[0]); /// TODO: Pass the test info in a correct way
BenchControl.Sequences.SequenceBase.AddOrOverwriteResult(result); /// TODO: Pass the result in a correct way
TBF.UiBridge.Bridge.OnTestCompleted(this, new TBF.UiBridge.TestCompletedEventArgs(result));
UpdateRfidCommResult(StateMachine.Tests[0].Name); /// TODO: Pass the test info in a correct way
TBF.UiBridge.Bridge.OnTestCompleted(this, new TBF.UiBridge.TestCompletedEventArgs(StateMachine.Tests[0].Name));
formCompleted = true;
Program.LocalSettings.iPerlCommunicationsFormLeft = Location.X;
@@ -1158,82 +1163,25 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
}
/// <summary>
/// Create virtual test result with representing communication success/failure
/// Update test result representing RFID communication success/failure
/// </summary>
/// <param name="test"></param>
/// <returns></returns>
TestResult CommResult(Test test)
void UpdateRfidCommResult(string testName)
{
TestResult tstRslt = new TestResult(test, 1, MetersKind.Single);
Results.Entities.TestRslt tstRslt = ProcessData.BatchRslts.GetTestRslt(testName, 0);
tstRslt.DoNotEvaluate = false;
tstRslt.DoNotPublish = false;
for (int i = 0; i < Math.Min(ProcessData.BatchRslts.WMPositionsCount, waterMeters.Count); i++)
{
Results.Entities.MeterTestRslt meterRslt =
ProcessData.BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single);
WaterMeters.iPerl.WaterMeter iPerl = waterMeters[i] as WaterMeters.iPerl.WaterMeter;
tstRslt.TimeStart = DateTime.Now;
tstRslt.TimeEnd = DateTime.Now;
tstRslt.AmbientTempAve = 20.0f;
tstRslt.AmbientPressAve = 1000.0f;
tstRslt.AmbientHumiAve = 50.0f;
tstRslt.PressInStart = 1000.0f;
tstRslt.PressOutStart = 1000.0f;
tstRslt.TempInStart = 20.0f;
tstRslt.TempOutStart = 20.0f;
tstRslt.TempDivStart = 20.0f;
tstRslt.PressInEnd = 1000.0f;
tstRslt.PressOutEnd = 1000.0f;
tstRslt.TempInEnd = 20.0f;
tstRslt.TempOutEnd = 20.0f;
tstRslt.TempDivEnd = 20.0f;
tstRslt.PressInAvrg = 1000.0f;
tstRslt.PressOutAvrg = 1000.0f;
tstRslt.TempInAvrg = 20.0f;
tstRslt.TempOutAvrg = 20.0f;
tstRslt.TempDivAvrg = 20.0f;
tstRslt.BatchNr = Program.LocalSettings.BatchNr;
tstRslt.MassStartRaw = 0;
tstRslt.MassStart = 0;
tstRslt.MassEndRaw = 0;
tstRslt.MassEnd = 0;
tstRslt.MassDiff = 0;
tstRslt.DensityIn = Program.LocalSettings.RealDensity;
tstRslt.DensityOut = Program.LocalSettings.RealDensity;
tstRslt.DensityDiv = Program.LocalSettings.RealDensity;
tstRslt.Time = 0;
tstRslt.FlowMass = 0;
tstRslt.FlowVolume = 0;
tstRslt.VolumeCTV = 0;
tstRslt.VolumeMaster = 0;
tstRslt.PulsesMaster = 0;
tstRslt.ConstMaster = 0;
tstRslt.ErrorMaster = 0;
for (int i = 0; i < Config.Data.WMsCount; i++)
{
/// Reference to iPerl water meter or null:
WaterMeters.iPerl.WaterMeter iPerl = (i < iPerlCommunicationForm.waterMeters.Count) ? iPerlCommunicationForm.waterMeters[i] : null;
tstRslt.Meters[i].SerialNr = iPerl.SerialNr;
tstRslt.Meters[i].PulsesPerLiter = 0;
tstRslt.Meters[i].VolumeRef = 0;
tstRslt.Meters[i].Time = 0;
tstRslt.Meters[i].TimeStart = 0;
tstRslt.Meters[i].TimeEnd = 0;
tstRslt.Meters[i].PulsesMaster = 0;
tstRslt.Meters[i].VolumeStart = 0;
tstRslt.Meters[i].VolumeEnd = 0;
tstRslt.Meters[i].VolumeMeter = 0;
tstRslt.Meters[i].VolumeErrorPct = 0;
tstRslt.Meters[i].Passed = (!iPerl.CommFailed && !iPerl.Disabled);
tstRslt.Meters[i].PulsesMeter = 0;
tstRslt.Meters[i].Disabled = iPerl.Disabled;
}
return tstRslt;
if (meterRslt != null && iPerl != null)
{
meterRslt.Passed = (!iPerl.CommFailed && !iPerl.Disabled);
meterRslt.TestDone = true;
}
}
}
}
}
@@ -7,6 +7,7 @@ using System.Text;
using log4net;
using Config.Entities;
using TBF.BenchControl;
using TBF.BenchControl.Sequences;
using TBF.Boxes;
using TBF.Resources;
using TBF.UiBridge;
@@ -20,9 +21,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
System.Windows.Forms.Form modelessDlg;
///
delegate void iPerlCommFormDlgt(iPerlCommunicationSeq myRef, TestMethodCfg cfg, iPerlCommunicationParams testParams);
delegate void iPerlCommFormDlgt(iPerlCommunicationSeq myRef, TestMethodCfg cfg, string testName, iPerlCommunicationParams testParams);
///
void OpenIPerlCommForm(iPerlCommunicationSeq myRef, TestMethodCfg cfg, iPerlCommunicationParams testParams)
void OpenIPerlCommForm(iPerlCommunicationSeq myRef, TestMethodCfg cfg, string testName, iPerlCommunicationParams testParams)
{
StringBuilder sb = new StringBuilder();
IList<GenericDevices.IWaterMeter> wMtrs = new List<GenericDevices.IWaterMeter>();
@@ -36,7 +37,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
}
}
log.ErrorFormat("OpenIPerlCommForm(wms:{0})", sb);
myRef.modelessDlg = new iPerlCommunicationForm(WaterMeters, cfg, testParams);
myRef.modelessDlg = new iPerlCommunicationForm(WaterMeters, cfg, testName, testParams);
myRef.modelessDlg.Show();
}
@@ -73,17 +74,10 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
{
string fromTestName = testParams.Activity.Substring(Q2correctedFromCmd.Length);
TestResult oriTestResult = null;
foreach (var tr in results)
{
if ((tr.TestName == fromTestName)) { oriTestResult = tr; break; }
}
MakeCorrectedFrom(test.Name, fromTestName);
TestResult tstRslt = MakeCorrectedFrom(test, oriTestResult);
AddOrOverwriteResult(tstRslt);
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(tstRslt));
allResults.Info(TestResult2CsvLine(tstRslt)); /// Append the results to the CSV-file
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name));
allResults.Info(TestResult2CsvLine(test.Name, 0)); /// Append the results to the CSV-file
IList<Event> rList = new List<Event>(1);
rList.Add(Event.Done);
@@ -91,20 +85,16 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
}
else if (testParams.Activity.ToLower().Contains("simulate "))
{
TestResult tstRslt;
if (testParams.Activity.ToLower().Contains("q3")) MakeSimulated(test.Name, 1, 1, 0, -0.5f);
else if (testParams.Activity.ToLower().Contains("q2")) MakeSimulated(test.Name, 1, 1, 0, 0.5f);
else if (testParams.Activity.ToLower().Contains("q1")) MakeSimulated(test.Name, 1, 1, 0, -5.1f);
else if (testParams.Activity.ToLower().Contains("compound ok")) MakeSimulatedCompound(test.Name, 1, 1, 0, 0.7f, 1.0f);
else if (testParams.Activity.ToLower().Contains("compound nok")) MakeSimulatedCompound(test.Name, 1, 1, 0, 4.7f, 0.9f);
else if (testParams.Activity.ToLower().Contains("compound rise")) MakeSimulatedCompound(test.Name, 1, 1, 0, 0.7f, 0.0f);
else if (testParams.Activity.ToLower().Contains("compound fall")) MakeSimulatedCompound(test.Name, 1, 1, 0, 0.7f, 0.9f);
if (testParams.Activity.ToLower().Contains("q3")) tstRslt = MakeSimulated(test, 1, -0.5f);
else if (testParams.Activity.ToLower().Contains("q2")) tstRslt = MakeSimulated(test, 1, 0.5f);
else if (testParams.Activity.ToLower().Contains("q1")) tstRslt = MakeSimulated(test, 1, -5.1f);
else if (testParams.Activity.ToLower().Contains("compound ok")) tstRslt = MakeSimulatedCompound(test, CompoundTestType.Regular, 1, 0.7f);
else if (testParams.Activity.ToLower().Contains("compound nok")) tstRslt = MakeSimulatedCompound(test, CompoundTestType.Regular, 1, 4.7f);
else if (testParams.Activity.ToLower().Contains("compound rise")) tstRslt = MakeSimulatedCompound(test, CompoundTestType.DetectionRise, 1, 0.7f);
else if (testParams.Activity.ToLower().Contains("compound fall")) tstRslt = MakeSimulatedCompound(test, CompoundTestType.DetectionFall, 1, 0.7f);
else tstRslt = null;
AddOrOverwriteResult(tstRslt);
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(tstRslt));
allResults.Info(TestResult2CsvLine(tstRslt)); /// Append the results to the CSV-file
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name));
allResults.Info(TestResult2CsvLine(test.Name, 0)); /// Append the results to the CSV-file
for (int i = 0; i < Config.Data.WMsCount; i++)
{
@@ -113,7 +103,8 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
: null;
if (iPerl != null)
{
iPerl.LastTestResult = tstRslt.Meters[i]; /// Save this water meter test result to iPerl WM
/// TODO: Reimplement
//iPerl.LastTestResult = meterRslt; /// Save this water meter test result to iPerl WM
iPerl.NominalTestFlow = 500.0 * (double)(test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
}
}
@@ -177,36 +168,26 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
/// </summary>
/// <param name="oriTestRslt">Q2Adj test result</param>
/// <returns>Virtual Q2 test result</returns>
TestResult MakeCorrectedFrom(Test test, TestResult oriTestRslt)
/// <remarks>Assuming this test does not have multiple parts (part = 0)</remarks>
void MakeCorrectedFrom(string testName, string oriTestName)
{
TestResult tstRslt = new TestResult(test, 1, MetersKind.Single);
Results.Entities.TestRslt oriTestRslt = ProcessData.BatchRslts.GetTestRslt(oriTestName, 0);
Results.Entities.TestRslt tstRslt = ProcessData.BatchRslts.GetTestRslt(testName, 0);
tstRslt.BatchNr = Program.LocalSettings.BatchNr;
tstRslt.TimeStart = oriTestRslt.TimeStart;
tstRslt.TimeEnd = oriTestRslt.TimeEnd;
tstRslt.AmbientTempAve = oriTestRslt.AmbientTempAve;
tstRslt.AmbientPressAve = oriTestRslt.AmbientPressAve;
tstRslt.AmbientHumiAve = oriTestRslt.AmbientHumiAve;
tstRslt.PressInAvrg = oriTestRslt.PressInAvrg;
tstRslt.PressInStart = oriTestRslt.PressInStart;
tstRslt.PressInEnd = oriTestRslt.PressInEnd;
tstRslt.PressOutAvrg = oriTestRslt.PressOutAvrg;
tstRslt.PressOutStart = oriTestRslt.PressOutStart;
tstRslt.PressOutEnd = oriTestRslt.PressOutEnd;
tstRslt.TempInAvrg = oriTestRslt.TempInAvrg;
tstRslt.TempInStart = oriTestRslt.TempInStart;
tstRslt.TempInEnd = oriTestRslt.TempInEnd;
tstRslt.TempOutAvrg = oriTestRslt.TempOutAvrg;
tstRslt.TempOutStart = oriTestRslt.TempOutStart;
tstRslt.TempOutEnd = oriTestRslt.TempOutEnd;
tstRslt.TempDivAvrg = oriTestRslt.TempDivAvrg;
tstRslt.TempDivStart = oriTestRslt.TempDivStart;
tstRslt.TempDivEnd = oriTestRslt.TempDivEnd;
tstRslt.MassStartRaw = oriTestRslt.MassStartRaw;
if (oriTestRslt == null || tstRslt == null) return;
tstRslt.Components = oriTestRslt.Components;
tstRslt.StartTime = oriTestRslt.StartTime;
tstRslt.EndTime = oriTestRslt.EndTime;
tstRslt.FlowSetTime = oriTestRslt.FlowSetTime;
tstRslt.TestTime = oriTestRslt.TestTime;
tstRslt.PulsesMaster = oriTestRslt.PulsesMaster;
tstRslt.ConstMaster = oriTestRslt.ConstMaster;
tstRslt.MassStartRaw = oriTestRslt.MassStartRaw;
tstRslt.MassStart = oriTestRslt.MassStart;
tstRslt.MassEndRaw = oriTestRslt.MassEndRaw;
tstRslt.MassEnd = oriTestRslt.MassEnd;
tstRslt.MassDiff = oriTestRslt.MassEnd;
tstRslt.DensityIn = oriTestRslt.DensityIn;
tstRslt.DensityOut = oriTestRslt.DensityOut;
tstRslt.DensityDiv = oriTestRslt.DensityDiv;
@@ -215,64 +196,91 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
tstRslt.FlowVolume = oriTestRslt.FlowVolume;
tstRslt.VolumeCTV = oriTestRslt.VolumeCTV;
tstRslt.VolumeMaster = oriTestRslt.VolumeMaster;
tstRslt.Time = oriTestRslt.Time;
tstRslt.ErrorMaster = oriTestRslt.ErrorMaster;
tstRslt.PulsesMaster = oriTestRslt.PulsesMaster;
tstRslt.ConstMaster = oriTestRslt.ConstMaster;
tstRslt.TimeDivStart0 = oriTestRslt.TimeDivStart0;
tstRslt.TimeDivStart1 = oriTestRslt.TimeDivStart1;
tstRslt.TimeDivStart2 = oriTestRslt.TimeDivStart2;
tstRslt.TimeDivStart3 = oriTestRslt.TimeDivStart3;
tstRslt.TimeDivStart4 = oriTestRslt.TimeDivStart4;
tstRslt.TimeDivStart5 = oriTestRslt.TimeDivStart5;
tstRslt.TimeDivEnd0 = oriTestRslt.TimeDivEnd0;
tstRslt.TimeDivEnd1 = oriTestRslt.TimeDivEnd1;
tstRslt.TimeDivEnd2 = oriTestRslt.TimeDivEnd2;
tstRslt.TimeDivEnd3 = oriTestRslt.TimeDivEnd3;
tstRslt.TimeDivEnd4 = oriTestRslt.TimeDivEnd4;
tstRslt.TimeDivEnd5 = oriTestRslt.TimeDivEnd5;
for (int i = 0; i < Math.Min(tstRslt.Meters.Count, oriTestRslt.Meters.Count); i++)
tstRslt.AmbientTempAve = oriTestRslt.AmbientTempAve;
tstRslt.AmbientPressAve = oriTestRslt.AmbientPressAve;
tstRslt.AmbientHumiAve = oriTestRslt.AmbientHumiAve;
tstRslt.PressUpAvrg = oriTestRslt.PressUpAvrg;
tstRslt.PressUpStart = oriTestRslt.PressUpStart;
tstRslt.PressUpEnd = oriTestRslt.PressUpEnd;
tstRslt.PressUpMin = oriTestRslt.PressUpMin;
tstRslt.PressUpMax = oriTestRslt.PressUpMax;
tstRslt.PressDownAvrg = oriTestRslt.PressDownAvrg;
tstRslt.PressDownStart = oriTestRslt.PressDownStart;
tstRslt.PressDownEnd = oriTestRslt.PressDownEnd;
tstRslt.PressDownMin = oriTestRslt.PressDownMin;
tstRslt.PressDownMax = oriTestRslt.PressDownMax;
tstRslt.TempInAvrg = oriTestRslt.TempInAvrg;
tstRslt.TempInStart = oriTestRslt.TempInStart;
tstRslt.TempInEnd = oriTestRslt.TempInEnd;
tstRslt.TempInMin = oriTestRslt.TempInMin;
tstRslt.TempInMax = oriTestRslt.TempInMax;
tstRslt.TempOutAvrg = oriTestRslt.TempOutAvrg;
tstRslt.TempOutStart = oriTestRslt.TempOutStart;
tstRslt.TempOutEnd = oriTestRslt.TempOutEnd;
tstRslt.TempOutMin = oriTestRslt.TempOutMin;
tstRslt.TempOutMax = oriTestRslt.TempOutMax;
tstRslt.TempDivAvrg = oriTestRslt.TempDivAvrg;
tstRslt.TempDivStart = oriTestRslt.TempDivStart;
tstRslt.TempDivEnd = oriTestRslt.TempDivEnd;
tstRslt.TempDivMin = oriTestRslt.TempDivMin;
tstRslt.TempDivMax = oriTestRslt.TempDivMax;
tstRslt.FlowMin = oriTestRslt.FlowMin;
tstRslt.FlowMax = oriTestRslt.FlowMax;
tstRslt.Custom1 = oriTestRslt.Custom1;
tstRslt.Custom2 = oriTestRslt.Custom2;
tstRslt.Custom3 = oriTestRslt.Custom3;
tstRslt.Custom4 = oriTestRslt.Custom4;
tstRslt.Custom5 = oriTestRslt.Custom5;
tstRslt.Custom6 = oriTestRslt.Custom6;
tstRslt.Custom7 = oriTestRslt.Custom7;
tstRslt.Custom8 = oriTestRslt.Custom8;
for (int i = 0; i < ProcessData.BatchRslts.WMPositionsCount; i++)
{
Results.Entities.MeterTestRslt oriMeterRslt = ProcessData.BatchRslts.GetMeterTestRslt(oriTestName, i, CompoundMeterId.Single);
Results.Entities.MeterTestRslt meterRslt = ProcessData.BatchRslts.GetMeterTestRslt(testName, i, CompoundMeterId.Single);
/// Reference to iPerl water meter or null:
WaterMeters.iPerl.WaterMeter iPerl = ((sensPath.RegisterReaders != null) && (i < sensPath.RegisterReaders.Length))
? (sensPath.RegisterReaders[i] as WaterMeters.iPerl.WaterMeter)
: null;
tstRslt.Meters[i].SerialNr = oriTestRslt.Meters[i].SerialNr;
tstRslt.Meters[i].PulsesPerLiter = oriTestRslt.Meters[i].PulsesPerLiter;
tstRslt.Meters[i].VolumeRef = oriTestRslt.Meters[i].VolumeRef;
tstRslt.Meters[i].Time = oriTestRslt.Meters[i].Time;
tstRslt.Meters[i].TimeStart = oriTestRslt.Meters[i].TimeStart;
tstRslt.Meters[i].TimeEnd = oriTestRslt.Meters[i].TimeEnd;
tstRslt.Meters[i].PulsesMeter = oriTestRslt.Meters[i].PulsesMeter;
tstRslt.Meters[i].PulsesMaster = oriTestRslt.Meters[i].PulsesMaster;
tstRslt.Meters[i].Disabled = oriTestRslt.Meters[i].Disabled;
if (meterRslt != null && oriMeterRslt != null)
{
meterRslt.PulsesMeter = oriMeterRslt.PulsesMeter;
meterRslt.PulsesMaster = oriMeterRslt.PulsesMaster;
meterRslt.PulsesPerLiter = oriMeterRslt.PulsesPerLiter;
meterRslt.VolumeRef = oriMeterRslt.VolumeRef;
meterRslt.TestTime = oriMeterRslt.TestTime;
if (iPerl == null ||
Math.Abs(oriTestRslt.Meters[i].VolumeErrorPct) <= 0.5f ||
oriTestRslt.Meters[i].VolumeErrorPct < oriTestRslt.ErrLimLo + oriTestRslt.Uncertainty ||
oriTestRslt.Meters[i].VolumeErrorPct > oriTestRslt.ErrLimHi - oriTestRslt.Uncertainty)
{
/// Normal meter or iPerl without correction
tstRslt.Meters[i].VolumeStart = oriTestRslt.Meters[i].VolumeStart;
tstRslt.Meters[i].VolumeEnd = oriTestRslt.Meters[i].VolumeEnd;
tstRslt.Meters[i].VolumeMeter = oriTestRslt.Meters[i].VolumeMeter;
tstRslt.Meters[i].VolumeErrorPct = oriTestRslt.Meters[i].VolumeErrorPct;
tstRslt.Meters[i].Passed = oriTestRslt.Meters[i].Passed;
}
else
{
/// corrected iPerl
tstRslt.Meters[i].VolumeStart = 0;
tstRslt.Meters[i].VolumeEnd = 0;
tstRslt.Meters[i].VolumeMeter = oriTestRslt.Meters[i].VolumeRef;
tstRslt.Meters[i].VolumeErrorPct = 0;
tstRslt.Meters[i].Passed = true;
if (iPerl == null ||
Math.Abs(oriMeterRslt.Error) <= 0.5f ||
oriMeterRslt.Error < oriTestRslt.ErrLimLo() + oriTestRslt.Uncertainty() ||
oriMeterRslt.Error > oriTestRslt.ErrLimHi() - oriTestRslt.Uncertainty())
{
/// Normal meter or iPerl without correction
meterRslt.VolumeStart = oriMeterRslt.VolumeStart;
meterRslt.VolumeEnd = oriMeterRslt.VolumeEnd;
meterRslt.VolumeMeter = oriMeterRslt.VolumeMeter;
meterRslt.Error = oriMeterRslt.Error;
meterRslt.Passed = oriMeterRslt.Passed;
meterRslt.TestDone = true;
}
else
{
/// corrected iPerl
meterRslt.VolumeStart = 0;
meterRslt.VolumeEnd = 0;
meterRslt.VolumeMeter = oriMeterRslt.VolumeRef;
meterRslt.Error = 0;
meterRslt.Passed = true;
meterRslt.TestDone = true;
}
}
}
return tstRslt;
}
}
}