View
Oops, something went wrong.
View
@@ -581,6 +581,22 @@ public double GetAvgError()
}
/// <summary>
+ /// Returns whether or not any values have been collected.
+ /// </summary>
+ /// <remarks>
+ /// If no values have been collected, <see cref="GetAvgError"/> is 0, which
+ /// is invalid.
+ /// </remarks>
+ /// <returns>True if <see cref="GetAvgError"/> is currently valid.</returns>
+ public bool IsAvgErrorValid()
+ {
+ lock (m_lockObject)
+ {
+ return m_buf.Count != 0;
+ }
+ }
+
+ /// <summary>
/// Sets the percentage error which is considered tolerable for use
/// with <see cref="OnTarget"/>.
/// </summary>
@@ -629,10 +645,13 @@ public void SetAbsoluteTolerance(double absTolerance)
/// <param name="bufLength">The number of previous cycles to average.</param>
public void SetToleranceBuffer(int bufLength)
{
- m_bufLength = bufLength;
- while (m_buf.Count > bufLength)
+ lock (m_lockObject)
{
- m_bufTotal -= m_buf.Dequeue();
+ m_bufLength = bufLength;
+ while (m_buf.Count > bufLength)
+ {
+ m_bufTotal -= m_buf.Dequeue();
+ }
}
}
@@ -652,9 +671,9 @@ public bool OnTarget()
switch (m_toleranceType)
{
case ToleranceType.PercentTolerance:
- return Math.Abs(GetAvgError()) < (m_tolerance / 100 * (m_maximumInput - m_minimumInput));
+ return IsAvgErrorValid() && Math.Abs(GetAvgError()) < (m_tolerance / 100 * (m_maximumInput - m_minimumInput));
case ToleranceType.AbsoluteTolerance:
- return Math.Abs(GetAvgError()) < m_tolerance;
+ return IsAvgErrorValid() && Math.Abs(GetAvgError()) < m_tolerance;
default:
throw new InvalidOperationException("Tolerance type must be set before calling OnTarget");
}
View
@@ -1,4 +1,4 @@
-version: 2016.0.0.{build}
+version: 2016.0.1.{build}
skip_tags: true
os: Visual Studio 2015
configuration: AppVeyor