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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user