Bug fix in CalculateDivTransitionTime( ), div. transition time stored in results, DiverterTestSeq calculates average transition time.
This commit is contained in:
@@ -76,8 +76,15 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
if (Diverter != null && StateMachine.Time <= DiverterAssociationValidUntil)
|
||||
{
|
||||
data.TransitionTime_ms = Const.DivTimeResolution * CalculateDivTransitionTime(data.Samples, Diverter.ThresholdLo, Diverter.ThresholdHi);
|
||||
|
||||
log.DebugFormat("{0} transition time = {1} ms", Diverter.Name, data.TransitionTime_ms);
|
||||
log.InfoFormat("{0} transition time = {1} ms", Diverter.Name, data.TransitionTime_ms);
|
||||
if (ToTank)
|
||||
{
|
||||
if (Diverter != null && Diverter.SwitchTimeStart != null) Diverter.SwitchTimeStart.Val = data.TransitionTime_ms / 1000.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Diverter != null && Diverter.SwitchTimeEnd != null) Diverter.SwitchTimeEnd.Val = data.TransitionTime_ms / 1000.0f;
|
||||
}
|
||||
|
||||
if (Plotter != null)
|
||||
{
|
||||
@@ -115,29 +122,29 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
int transitionStartIdx = 0;
|
||||
int transitionEndIdx = 0;
|
||||
|
||||
int level = samples[0];
|
||||
int level = 4*samples[0];
|
||||
for (int i = 1; i < SamplesCount; i++)
|
||||
{
|
||||
if (!startedRising && !startedFalling)
|
||||
{
|
||||
if (level <= thresholdLo && samples[i] > thresholdLo)
|
||||
if (level <= thresholdLo && 4*samples[i] > thresholdLo)
|
||||
{
|
||||
transitionStartIdx = i;
|
||||
startedRising = true;
|
||||
}
|
||||
else if (level >= thresholdHi && samples[i] < thresholdHi)
|
||||
else if (level >= thresholdHi && 4*samples[i] < thresholdHi)
|
||||
{
|
||||
transitionStartIdx = i;
|
||||
startedFalling = true;
|
||||
}
|
||||
}
|
||||
else if (startedRising && !stopped && level < thresholdHi && samples[i] >= thresholdHi)
|
||||
else if (startedRising && !stopped && level < thresholdHi && 4*samples[i] >= thresholdHi)
|
||||
{
|
||||
transitionEndIdx = i;
|
||||
stopped = true;
|
||||
break;
|
||||
}
|
||||
else if (startedFalling && !stopped && level > thresholdLo && samples[i] <= thresholdLo)
|
||||
else if (startedFalling && !stopped && level > thresholdLo && 4*samples[i] <= thresholdLo)
|
||||
{
|
||||
transitionEndIdx = i;
|
||||
stopped = true;
|
||||
@@ -145,6 +152,9 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
}
|
||||
}
|
||||
|
||||
log.DebugFormat("CalculateDivTransitionTime() ... thresholdLo={0} thresholdHi={1} startIx={2} endIx={3} time = {4} ms",
|
||||
thresholdLo, thresholdHi, transitionStartIdx, transitionEndIdx, 2 * (transitionEndIdx - transitionStartIdx));
|
||||
|
||||
return transitionEndIdx - transitionStartIdx;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -479,6 +479,11 @@ namespace TBF.Rig.TestMethods.DiverterTest
|
||||
///
|
||||
int remainingPulses = totalPulses;
|
||||
StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, 0);
|
||||
DiverterStart.Start(BatchRslts.Batch.BatchNr, test.Name, repetitionNr);
|
||||
DiverterEnd.Start(BatchRslts.Batch.BatchNr, test.Name, repetitionNr);
|
||||
|
||||
float[] divStartTimes = new float[testParams.DivRepetitions];
|
||||
float[] divEndTimes = new float[testParams.DivRepetitions];
|
||||
|
||||
for (int divRepetNr = 1; divRepetNr <= testParams.DivRepetitions; divRepetNr++)
|
||||
{
|
||||
@@ -500,7 +505,7 @@ namespace TBF.Rig.TestMethods.DiverterTest
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperations(readTempPressOps)
|
||||
.AddOperations(cameraMeasurementOps)
|
||||
.AddOperation(cBrd.FlyingStartStopTestOp(test, test.Qfrom, test.Qto, pulsesNow, true, false, 0, false))
|
||||
.AddOperation(cBrd.FlyingStartStopTestOp(test, test.Qfrom, test.Qto, pulsesNow, true, false, 0, true, DiverterStart, DiverterEnd))
|
||||
.AddOperation(processDataLoggingOp)
|
||||
.EnterState();
|
||||
do {
|
||||
@@ -554,6 +559,9 @@ namespace TBF.Rig.TestMethods.DiverterTest
|
||||
cumulativeWMPulses[i] += cBrd.PulsesWM(i);
|
||||
cumulativeTestTime[i] += cBrd.TestTimeWM(i);
|
||||
}
|
||||
|
||||
divStartTimes[divRepetNr - 1] = outPath.Diverter.SwitchTimeStart.Val;
|
||||
divEndTimes[divRepetNr - 1] = outPath.Diverter.SwitchTimeEnd.Val;
|
||||
}
|
||||
} /// end for ... diverter test loop
|
||||
|
||||
@@ -613,6 +621,17 @@ namespace TBF.Rig.TestMethods.DiverterTest
|
||||
log.WarnFormat("End mass = {0}kg", EndMass);
|
||||
TestEndTime = DateTime.Now;
|
||||
|
||||
/// Calculate average diverter start/end times
|
||||
divStartTimes[testParams.DivRepetitions - 1] = outPath.Diverter.SwitchTimeStart.Val;
|
||||
divEndTimes[testParams.DivRepetitions - 1] = outPath.Diverter.SwitchTimeEnd.Val;
|
||||
for (int i = 0; i < testParams.DivRepetitions - 1; i++)
|
||||
{
|
||||
outPath.Diverter.SwitchTimeStart.Val = outPath.Diverter.SwitchTimeStart.Val + divStartTimes[i];
|
||||
outPath.Diverter.SwitchTimeEnd.Val = outPath.Diverter.SwitchTimeEnd.Val + divEndTimes[i];
|
||||
}
|
||||
outPath.Diverter.SwitchTimeStart.Val = outPath.Diverter.SwitchTimeStart.Val / Convert.ToSingle(testParams.DivRepetitions);
|
||||
outPath.Diverter.SwitchTimeEnd.Val = outPath.Diverter.SwitchTimeEnd.Val / Convert.ToSingle(testParams.DivRepetitions);
|
||||
|
||||
if (test.DoDrainingAfter)
|
||||
{
|
||||
State.Create(string.Format("{0}({1}) : Open the drain valve", test.Method, test.Name))
|
||||
|
||||
Reference in New Issue
Block a user