Masses are stored in double variables everywhere.

This commit is contained in:
Milan Hanajik
2016-10-07 14:06:54 +02:00
parent 9f2e8407a0
commit 4160420844
26 changed files with 104 additions and 111 deletions
@@ -41,7 +41,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
}
public static int BalancesCount { get { return nextBalanceIdx; } }
public static BalanceDev[] Balances;
public static float[] Masses;
public static double[] Masses;
///
protected int balanceNr; /// 0-based balance number
@@ -49,14 +49,14 @@ namespace TBF.BenchControl.MettlerToledo.Standard
protected StringBuilder stringBuilder;
public int BalanceNr { get { return balanceNr; } }
public float Capacity { get { return balanceCfg.Capacity; } }
public double Capacity { get { return balanceCfg.Capacity; } }
public int EmptyTimeSec { get { return balanceCfg.EmptyTimeSec; } }
/// Buoyancy
public float BuoyancyTemp { get { return balanceCfg.BuoyancyTemp; } }
public float BuoyancyPress { get { return balanceCfg.BuoyancyPress; } }
public float BuoyancyHumi { get { return balanceCfg.BuoyancyHumi; } }
public float WeightStandardDensity { get { return balanceCfg.WeightStandardDensity; } }
public double WeightStandardDensity { get { return balanceCfg.WeightStandardDensity; } }
/// <summary>The state of the mass measurement</summary>
@@ -64,8 +64,8 @@ namespace TBF.BenchControl.MettlerToledo.Standard
protected MsrmntState msrmntState;
/// <summary>The mass after StartMassMeasurement() when MsrmntState == MsrmntState.Valid</summary>
public float Mass { get { return mass; } }
protected float mass;
public double Mass { get { return mass; } }
protected double mass;
/// <summary>The time stamp after StartMassMeasurement() when MsrmntState == MsrmntState.Valid</summary>
public int MsrmntTimeStamp { get { return msrmntTimeStamp; } }
@@ -88,7 +88,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
balanceCfg = cfg as BalanceCfg;
balanceNr = nextBalanceIdx++;
Masses = new float[nextBalanceIdx]; /// (re)initialize the static array of masses of all balances
Masses = new double[nextBalanceIdx]; /// (re)initialize the static array of masses of all balances
///
if (Balances == null || Balances.Length < nextBalanceIdx)
{
@@ -121,7 +121,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
return (this.mass <= balanceCfg.Empty);
}
public bool IsEmpty(float mass)
public bool IsEmpty(double mass)
{
return (mass <= balanceCfg.Empty);
}
@@ -321,7 +321,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
else if (fields[0].Equals("S")) /// Stable mass: field[1] = <mass> field[2] = "kg"
{
if (fields.Length == 3 &&
float.TryParse(fields[1],
double.TryParse(fields[1],
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign,
CultureInfo.InvariantCulture,
out mass))
@@ -333,7 +333,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
log.InfoFormat("{0} - Balance response = \"{1}<cr><lf>\", Mass = {2}", Name, received, mass);
}
else if (fields.Length == 4 && (fields[1].Equals("S") || fields[1].Equals("D")) &&
float.TryParse(fields[2],
double.TryParse(fields[2],
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign,
CultureInfo.InvariantCulture,
out mass))
@@ -355,14 +355,14 @@ namespace TBF.BenchControl.MettlerToledo.Standard
{
msrmntState = MsrmntState.Failed;
log.WarnFormat("{0} Balance response = \"{1}<cr><lf>\", Overload or and unexpected error !!!", Name, received);
bool b = float.TryParse(fields[1], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out mass);
bool b = double.TryParse(fields[1], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out mass);
}
}
else if (fields[0].Equals("SD")) /// Dynamic mass: field[1] = <mass> field[2] = "kg"
{
if (fields.Length >= 3 &&
float.TryParse(fields[1],
double.TryParse(fields[1],
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign,
CultureInfo.InvariantCulture,
out mass))
@@ -384,14 +384,14 @@ namespace TBF.BenchControl.MettlerToledo.Standard
{
msrmntState = MsrmntState.Failed;
log.WarnFormat("{0} - Balance response = \"{1}<cr><lf>\", Overload or and unexpected error !!!", Name, received);
bool b = float.TryParse(fields[1], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out mass);
bool b = double.TryParse(fields[1], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out mass);
}
}
else if (fields[0].Equals("TB")) /// Taring
{
if (fields.Length >= 3 &&
float.TryParse(fields[1],
double.TryParse(fields[1],
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign,
CultureInfo.InvariantCulture,
out mass))
@@ -410,7 +410,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
else if (fields[0].Equals("T")) /// Taring
{
if (fields.Length >= 4 && fields[1].Equals("S") &&
float.TryParse(fields[2],
double.TryParse(fields[2],
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign,
CultureInfo.InvariantCulture,
out mass))
@@ -450,7 +450,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
/// </summary>
/// <param name="result">Reference to a variable for 'tara' in kg</param>
/// <returns>TaringOp instance reference casted to IOperaton</returns>
public IOperation TaringOp(ref FloatBox tara)
public IOperation TaringOp(ref DoubleBox tara)
{
return new TaringOp(this, ref tara);
}
@@ -460,7 +460,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
/// </summary>
/// <param name="result">Reference to a variable for the measured mass in kg</param>
/// <returns>ReadMassOp instance reference casted to IOperaton</returns>
public IOperation ReadMassOp(ref FloatBox mass)
public IOperation ReadMassOp(ref DoubleBox mass)
{
return new ReadMassOp(this, ref mass);
}
@@ -473,7 +473,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
/// <param name="maxSpread">Maximum spread of measurements in kg (otherwise the measurement continues)</param>
/// <param name="method">Method: false = slow (precise), true = fast (immediate)</param>
/// <returns>ReadMassAverageOp instance reference casted to IOperaton</returns>
public IOperation ReadStableMassOp(ref FloatBox mass, int readingsCount, float maxSpread, bool method)
public IOperation ReadStableMassOp(ref DoubleBox mass, int readingsCount, double maxSpread, bool method)
{
return new ReadStableMassOp(this, ref mass, readingsCount, maxSpread, method);
}