(1) Nivotrack.ReadStableLevelOp implemented, (2) MettlerToledo.Standard.ReadStableMassOp bug fix, (3) UpdateWeights() clean-up, ver. 2.18.1065

This commit is contained in:
Milan Hanajik
2018-11-14 15:49:43 +01:00
parent 3ffdf4e2cc
commit b060068a95
4 changed files with 133 additions and 57 deletions
@@ -23,7 +23,8 @@ namespace TBF.BenchControl.MettlerToledo.Standard
DoubleBox result;
/// Operation specific
double[] massReadings;
double[] massReadings;
double[] sortedMassReadings;
int currentReadingsCount;
bool measurementCompleted;
@@ -48,7 +49,8 @@ namespace TBF.BenchControl.MettlerToledo.Standard
this.result = result;
massReadings = new double[totalReadingsCount];
currentReadingsCount = 0;
sortedMassReadings = new double[totalReadingsCount];
currentReadingsCount = 0;
measurementCompleted = false;
log.Debug(this.ToString());
@@ -114,17 +116,18 @@ namespace TBF.BenchControl.MettlerToledo.Standard
if (currentReadingsCount >= totalReadingsCount)
{
Array.Sort(massReadings);
Array.Copy(massReadings, sortedMassReadings, totalReadingsCount);
Array.Sort(sortedMassReadings);
#if STABLE_MASS_EXTRAS
if (method == Config.Entities.MassMethod.Spread)
{
/// Immediate mass measurement, end condition calculated below
if ((massReadings[totalReadingsCount - 2] - massReadings[1]) <= maxSpread)
if ((sortedMassReadings[totalReadingsCount - 2] - sortedMassReadings[1]) <= maxSpread)
{
double massSum = 0;
for (int i = 1; i < totalReadingsCount - 1; i++) massSum += massReadings[i];
for (int i = 1; i < totalReadingsCount - 1; i++) massSum += sortedMassReadings[i];
result.Val = (massSum / (totalReadingsCount - 2));
log.InfoFormat("ReadStableMassOp.Run() ... valid mass={0} ... returning Event.BalanceDone", result.Val);
@@ -137,10 +140,10 @@ namespace TBF.BenchControl.MettlerToledo.Standard
/// Immediate mass measurement, end condition calculated below
double massSum = 0;
for (int i = 1; i < totalReadingsCount - 1; i++) massSum += massReadings[i];
for (int i = 1; i < totalReadingsCount - 1; i++) massSum += sortedMassReadings[i];
double ave = (massSum / (totalReadingsCount - 2));
double sdev = 0;
for (int i = 1; i < totalReadingsCount - 1; i++) sdev += ((massReadings[i] - ave) * (massReadings[i] - ave));
for (int i = 1; i < totalReadingsCount - 1; i++) sdev += ((sortedMassReadings[i] - ave) * (sortedMassReadings[i] - ave));
if (Math.Sqrt(sdev / (totalReadingsCount - 2)) <= maxSpread)
{